Changeset 228 for branches/samba-3.2.x/source/modules/gpfs.c
- Timestamp:
- May 26, 2009, 9:44:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/modules/gpfs.c
r133 r228 25 25 #include "vfs_gpfs.h" 26 26 27 static void *libgpfs_handle = NULL;28 27 static bool gpfs_share_modes; 29 28 static bool gpfs_leases; … … 136 135 } 137 136 137 static bool init_gpfs_function_lib(void *plibhandle_pointer, 138 const char *libname, 139 void *pfn_pointer, const char *fn_name) 140 { 141 bool did_open_here = false; 142 void **libhandle_pointer = (void **)plibhandle_pointer; 143 void **fn_pointer = (void **)pfn_pointer; 144 145 if (*libhandle_pointer == NULL) { 146 *libhandle_pointer = sys_dlopen(libname, RTLD_LAZY); 147 did_open_here = true; 148 } 149 if (*libhandle_pointer == NULL) { 150 DEBUG(10, ("Could not open lib %s\n", libname)); 151 return false; 152 } 153 154 *fn_pointer = sys_dlsym(*libhandle_pointer, fn_name); 155 if (*fn_pointer == NULL) { 156 DEBUG(10, ("Did not find symbol %s in lib %s\n", 157 fn_name, libname)); 158 if (did_open_here) { 159 sys_dlclose(*libhandle_pointer); 160 *libhandle_pointer = NULL; 161 } 162 return false; 163 } 164 165 return true; 166 } 167 168 static bool init_gpfs_function(void *fn_pointer, const char *fn_name) 169 { 170 static void *libgpfs_handle = NULL; 171 static void *libgpfs_gpl_handle = NULL; 172 173 if (init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so", 174 fn_pointer, fn_name)) { 175 return true; 176 } 177 if (init_gpfs_function_lib(&libgpfs_gpl_handle, "libgpfs_gpl.so", 178 fn_pointer, fn_name)) { 179 return true; 180 } 181 return false; 182 } 183 138 184 void init_gpfs(void) 139 185 { 140 if (libgpfs_handle != NULL) { 141 return; 142 } 143 144 libgpfs_handle = sys_dlopen("libgpfs_gpl.so", RTLD_LAZY); 145 146 if (libgpfs_handle == NULL) { 147 DEBUG(10, ("sys_dlopen for libgpfs_gpl failed: %s\n", 148 strerror(errno))); 149 return; 150 } 151 152 DEBUG(10, ("libgpfs_gpl.so loaded\n")); 153 154 gpfs_set_share_fn = sys_dlsym(libgpfs_handle, "gpfs_set_share"); 155 if (gpfs_set_share_fn == NULL) { 156 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 157 "'gpfs_set_share'\n")); 158 goto failed; 159 } 160 161 gpfs_set_lease_fn = sys_dlsym(libgpfs_handle, "gpfs_set_lease"); 162 if (gpfs_set_lease_fn == NULL) { 163 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 164 "'gpfs_set_lease'\n")); 165 sys_dlclose(libgpfs_handle); 166 167 goto failed; 168 } 169 170 gpfs_getacl_fn = sys_dlsym(libgpfs_handle, "gpfs_getacl"); 171 if (gpfs_getacl_fn == NULL) { 172 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 173 "'gpfs_getacl'\n")); 174 goto failed; 175 } 176 177 gpfs_putacl_fn = sys_dlsym(libgpfs_handle, "gpfs_putacl"); 178 if (gpfs_putacl_fn == NULL) { 179 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 180 "'gpfs_putacl'\n")); 181 goto failed; 182 } 186 init_gpfs_function(&gpfs_set_share_fn, "gpfs_set_share"); 187 init_gpfs_function(&gpfs_set_lease_fn, "gpfs_set_lease"); 188 init_gpfs_function(&gpfs_getacl_fn, "gpfs_getacl"); 189 init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl"); 183 190 184 191 gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); … … 186 193 187 194 return; 188 189 failed:190 sys_dlclose(libgpfs_handle);191 /* leave libgpfs_handle != NULL around, no point192 in trying twice */193 gpfs_set_share_fn = NULL;194 gpfs_set_lease_fn = NULL;195 gpfs_getacl_fn = NULL;196 gpfs_putacl_fn = NULL;197 195 } 198 196
Note:
See TracChangeset
for help on using the changeset viewer.