From 7d7c594644d9b374e522f208b1f0bd5ab8abb9ab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Mar 2002 03:00:39 +0000 Subject: Removed HAVE_LIBDL from most places (except system.c). Added checks for dlopen & friends into configure.in. This should help building on *BSD where dl*** calls are in libc. Jeremy (This used to be commit ac1baba35d7a399bf800ced49a4384e39955e3eb) --- source3/smbd/vfs.c | 422 ++++++++++++++++++++++++----------------------------- 1 file changed, 194 insertions(+), 228 deletions(-) (limited to 'source3/smbd/vfs.c') diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 6416d8e73e..4e2e353ed8 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -119,50 +119,47 @@ struct vfs_ops default_vfs_ops = { static BOOL vfs_init_default(connection_struct *conn) { - DEBUG(3, ("Initialising default vfs hooks\n")); + DEBUG(3, ("Initialising default vfs hooks\n")); - memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops)); - return True; + memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops)); + return True; } /**************************************************************************** initialise custom vfs hooks ****************************************************************************/ -#ifdef HAVE_LIBDL static BOOL vfs_init_custom(connection_struct *conn) { int vfs_version = -1; - struct vfs_ops *ops, *(*init_fptr)(int *, struct vfs_ops *); + struct vfs_ops *ops, *(*init_fptr)(int *, struct vfs_ops *); - DEBUG(3, ("Initialising custom vfs hooks from %s\n", - lp_vfsobj(SNUM(conn)))); + DEBUG(3, ("Initialising custom vfs hooks from %s\n", lp_vfsobj(SNUM(conn)))); - /* Open object file */ + /* Open object file */ - if ((conn->dl_handle = sys_dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) { + if ((conn->dl_handle = sys_dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) { DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), dlerror())); return False; - } + } - /* Get handle on vfs_init() symbol */ + /* Get handle on vfs_init() symbol */ - init_fptr = (struct vfs_ops *(*)(int *, struct vfs_ops *))sys_dlsym(conn->dl_handle, "vfs_init"); + init_fptr = (struct vfs_ops *(*)(int *, struct vfs_ops *))sys_dlsym(conn->dl_handle, "vfs_init"); - if (init_fptr == NULL) { - DEBUG(0, ("No vfs_init() symbol found in %s\n", - lp_vfsobj(SNUM(conn)))); + if (init_fptr == NULL) { + DEBUG(0, ("No vfs_init() symbol found in %s\n", lp_vfsobj(SNUM(conn)))); return False; - } + } - /* Initialise vfs_ops structure */ + /* Initialise vfs_ops structure */ conn->vfs_ops = default_vfs_ops; - if ((ops = init_fptr(&vfs_version, &default_vfs_ops)) == NULL) { - DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); + if ((ops = init_fptr(&vfs_version, &default_vfs_ops)) == NULL) { + DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); return False; - } + } if (vfs_version != SMB_VFS_INTERFACE_VERSION) { DEBUG(0, ("vfs_init returned wrong interface version info (was %d, should be %d)\n", @@ -174,9 +171,8 @@ static BOOL vfs_init_custom(connection_struct *conn) memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops)); } - return True; + return True; } -#endif /***************************************************************** Generic VFS init. @@ -185,7 +181,6 @@ static BOOL vfs_init_custom(connection_struct *conn) BOOL smbd_vfs_init(connection_struct *conn) { if (*lp_vfsobj(SNUM(conn))) { -#ifdef HAVE_LIBDL /* Loadable object file */ @@ -195,10 +190,6 @@ BOOL smbd_vfs_init(connection_struct *conn) } return True; -#else - DEBUG(0, ("smbd_vfs_init: No libdl present - cannot use VFS objects\n")); - return False; -#endif } /* Normal share - initialise with disk access functions */ @@ -305,7 +296,7 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count) while (total < byte_count) { ssize_t ret = fsp->conn->vfs_ops.read(fsp, fsp->fd, buf + total, - byte_count - total); + byte_count - total); if (ret == 0) return total; if (ret == -1) { @@ -571,12 +562,11 @@ int vfs_ChDir(connection_struct *conn, char *path) /* number of list structures for a caching GetWd function. */ #define MAX_GETWDCACHE (50) -struct -{ - SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */ - SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */ - char *dos_path; /* The pathname in DOS format. */ - BOOL valid; +struct { + SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */ + SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */ + char *dos_path; /* The pathname in DOS format. */ + BOOL valid; } ino_list[MAX_GETWDCACHE]; extern BOOL use_getwd_cache; @@ -612,98 +602,86 @@ static void array_promote(char *array,int elsize,int element) char *vfs_GetWd(connection_struct *conn, char *path) { - pstring s; - static BOOL getwd_cache_init = False; - SMB_STRUCT_STAT st, st2; - int i; - - *s = 0; - - if (!use_getwd_cache) - return(vfs_getwd(conn,path)); - - /* init the cache */ - if (!getwd_cache_init) - { - getwd_cache_init = True; - for (i=0;i