diff options
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/gpfs.c | 96 | ||||
-rw-r--r-- | source3/modules/vfs_gpfs.c | 7 | ||||
-rw-r--r-- | source3/modules/vfs_gpfs.h | 2 |
3 files changed, 39 insertions, 66 deletions
diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index b2ca704e04..933d491e0a 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -44,6 +44,38 @@ static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufferP); static int (*gpfs_fcntl_fn)(gpfs_file_t fileDesc, void *fcntlArgP); static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idP); +int gpfswrap_init(void) +{ + static void *l; + + if (l != NULL) { + return 0; + } + + l = dlopen("libgpfs.so", RTLD_LAZY); + if (l == NULL) { + return -1; + } + + gpfs_set_share_fn = dlsym(l, "gpfs_set_share"); + gpfs_set_lease_fn = dlsym(l, "gpfs_set_lease"); + gpfs_getacl_fn = dlsym(l, "gpfs_getacl"); + gpfs_putacl_fn = dlsym(l, "gpfs_putacl"); + gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path"); + gpfs_set_winattrs_path_fn = dlsym(l, "gpfs_set_winattrs_path"); + gpfs_get_winattrs_path_fn = dlsym(l, "gpfs_get_winattrs_path"); + gpfs_get_winattrs_fn = dlsym(l, "gpfs_get_winattrs"); + gpfs_prealloc_fn = dlsym(l, "gpfs_prealloc"); + gpfs_ftruncate_fn = dlsym(l, "gpfs_ftruncate"); + gpfs_lib_init_fn = dlsym(l, "gpfs_lib_init"); + gpfs_set_times_path_fn = dlsym(l, "gpfs_set_times_path"); + gpfs_quotactl_fn = dlsym(l, "gpfs_quotactl"); + gpfs_fcntl_fn = dlsym(l, "gpfs_fcntl"); + gpfs_getfilesetid_fn = dlsym(l, "gpfs_getfilesetid"); + + return 0; +} + bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, uint32 share_access) { @@ -331,67 +363,3 @@ int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft) return rc; } - -static bool init_gpfs_function_lib(void *plibhandle_pointer, - const char *libname, - void *pfn_pointer, const char *fn_name) -{ - bool did_open_here = false; - void **libhandle_pointer = (void **)plibhandle_pointer; - void **fn_pointer = (void **)pfn_pointer; - - DEBUG(10, ("trying to load name %s from %s\n", - fn_name, libname)); - - if (*libhandle_pointer == NULL) { - *libhandle_pointer = dlopen(libname, RTLD_LAZY); - did_open_here = true; - } - if (*libhandle_pointer == NULL) { - DEBUG(10, ("Could not open lib %s\n", libname)); - return false; - } - - *fn_pointer = dlsym(*libhandle_pointer, fn_name); - if (*fn_pointer == NULL) { - DEBUG(10, ("Did not find symbol %s in lib %s\n", - fn_name, libname)); - if (did_open_here) { - dlclose(*libhandle_pointer); - *libhandle_pointer = NULL; - } - return false; - } - - return true; -} - -static bool init_gpfs_function(void *fn_pointer, const char *fn_name) -{ - static void *libgpfs_handle = NULL; - - return init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so", - fn_pointer, fn_name); -} - -void init_gpfs(void) -{ - init_gpfs_function(&gpfs_set_share_fn, "gpfs_set_share"); - init_gpfs_function(&gpfs_set_lease_fn, "gpfs_set_lease"); - init_gpfs_function(&gpfs_getacl_fn, "gpfs_getacl"); - init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl"); - init_gpfs_function(&gpfs_get_realfilename_path_fn, - "gpfs_get_realfilename_path"); - init_gpfs_function(&gpfs_get_winattrs_path_fn,"gpfs_get_winattrs_path"); - init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path"); - init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs"); - init_gpfs_function(&gpfs_prealloc_fn, "gpfs_prealloc"); - init_gpfs_function(&gpfs_ftruncate_fn, "gpfs_ftruncate"); - init_gpfs_function(&gpfs_lib_init_fn,"gpfs_lib_init"); - init_gpfs_function(&gpfs_set_times_path_fn, "gpfs_set_times_path"); - init_gpfs_function(&gpfs_quotactl_fn, "gpfs_quotactl"); - init_gpfs_function(&gpfs_fcntl_fn, "gpfs_fcntl"); - init_gpfs_function(&gpfs_getfilesetid_fn, "gpfs_getfilesetid"); - - return; -} diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 3d99830b15..7d1ea88416 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -2347,7 +2347,12 @@ static struct vfs_fn_pointers vfs_gpfs_fns = { NTSTATUS vfs_gpfs_init(void); NTSTATUS vfs_gpfs_init(void) { - init_gpfs(); + int ret; + + ret = gpfswrap_init(); + if (ret != 0) { + DEBUG(1, ("Could not initialize GPFS library wrapper\n")); + } return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs", &vfs_gpfs_fns); diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h index 728231f146..37b58f712c 100644 --- a/source3/modules/vfs_gpfs.h +++ b/source3/modules/vfs_gpfs.h @@ -27,6 +27,7 @@ #define GPFS_GETACL_NATIVE 0x00000004 #endif +int gpfswrap_init(void); bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, uint32 share_access); int set_gpfs_lease(int fd, int leasetype); @@ -44,5 +45,4 @@ int get_gpfs_quota(const char *pathname, int type, int id, int get_gpfs_fset_id(const char *pathname, int *fset_id); int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft); -void init_gpfs(void); void smbd_gpfs_lib_init(void); |