The Samba-Bugzilla – Attachment 6903 Details for
Bug 8465
Enable dirsort plugin on systems without dirfd()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add alternatives to dirfd() for systems that don't have it
0003-Add-workaround-for-missing-dirfd.patch (text/plain), 4.39 KB, created by
(account disabled)
on 2011-09-17 05:20:42 UTC
(
hide
)
Description:
Add alternatives to dirfd() for systems that don't have it
Filename:
MIME Type:
Creator:
(account disabled)
Created:
2011-09-17 05:20:42 UTC
Size:
4.39 KB
patch
obsolete
>From ae0ad292bc04a9acd55caf9d26d29138b0039923 Mon Sep 17 00:00:00 2001 >Date: Tue, 30 Aug 2011 18:05:54 -0700 >Subject: [PATCH 3/5] Add workaround for missing dirfd(). > >This provides for some alternative ways to get the fd for a DIR using >non-standard structure members that are available on some systems (e.g. >Solaris). >--- > source3/configure.in | 2 ++ > source3/m4/aclocal.m4 | 26 ++++++++++++++++++++++++++ > source3/modules/vfs_dirsort.c | 14 ++++++++++++-- > source3/wscript | 9 +++++++++ > 4 files changed, 49 insertions(+), 2 deletions(-) > >diff --git a/source3/configure.in b/source3/configure.in >index 9b49c96..73c80c3 100644 >--- a/source3/configure.in >+++ b/source3/configure.in >@@ -820,6 +820,8 @@ AC_TYPE_SIZE_T > AC_TYPE_PID_T > AC_STRUCT_ST_RDEV > AC_DIRENT_D_OFF >+AC_DIR_D_FD >+AC_DIR_DD_FD > AC_CHECK_TYPE(ssize_t, int) > AC_CHECK_TYPE(wchar_t, unsigned short) > >diff --git a/source3/m4/aclocal.m4 b/source3/m4/aclocal.m4 >index 6112a64..9fb9431 100644 >--- a/source3/m4/aclocal.m4 >+++ b/source3/m4/aclocal.m4 >@@ -11,6 +11,32 @@ if test $ac_cv_dirent_d_off = yes; then > fi > ]) > >+dnl test whether DIR has a d_fd member >+AC_DEFUN(AC_DIR_D_FD, >+[AC_CACHE_CHECK([for d_fd in DIR], ac_cv_dir_d_fd, >+[AC_TRY_COMPILE([ >+#include <unistd.h> >+#include <sys/types.h> >+#include <dirent.h>], [DIR d; d.d_fd;], >+ac_cv_dir_d_fd=yes, ac_cv_dir_d_fd=no)]) >+if test $ac_cv_dir_d_fd = yes; then >+ AC_DEFINE(HAVE_DIR_D_FD,1,[Whether DIR has a d_fd member]) >+fi >+]) >+ >+dnl test whether DIR has a dd_fd member >+AC_DEFUN(AC_DIR_DD_FD, >+[AC_CACHE_CHECK([for dd_fd in DIR], ac_cv_dir_dd_fd, >+[AC_TRY_COMPILE([ >+#include <unistd.h> >+#include <sys/types.h> >+#include <dirent.h>], [DIR d; d.dd_fd;], >+ac_cv_dir_dd_fd=yes, ac_cv_dir_dd_fd=no)]) >+if test $ac_cv_dir_dd_fd = yes; then >+ AC_DEFINE(HAVE_DIR_DD_FD,1,[Whether DIR has a dd_fd member]) >+fi >+]) >+ > dnl Mark specified module as shared > dnl SMB_MODULE(name,static_files,shared_files,subsystem,whatif-static,whatif-shared) > AC_DEFUN(SMB_MODULE, >diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c >index 92909a0..c3070de 100644 >--- a/source3/modules/vfs_dirsort.c >+++ b/source3/modules/vfs_dirsort.c >@@ -22,6 +22,16 @@ > #include "smbd/smbd.h" > #include "system/filesys.h" > >+#ifdef HAVE_DIRFD >+#define DIRFD(dir) dirfd(dir) >+#elif HAVE_DIR_D_FD >+#define DIRFD(dir) (dir->d_fd) >+#elif HAVE_DIR_DD_FD >+#define DIRFD(dir) (dir->dd_fd) >+#else >+#error "need either dirfd, DIR.d_fd, or DIR.dd_fd" >+#endif >+ > static int compare_dirent (const SMB_STRUCT_DIRENT *da, const SMB_STRUCT_DIRENT *db) > { > return StrCaseCmp(da->d_name, db->d_name); >@@ -118,7 +128,7 @@ static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle, > return NULL; > } > >- data->fd = dirfd(data->source_directory); >+ data->fd = DIRFD(data->source_directory); > > SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates, > struct dirsort_privates, return NULL); >@@ -158,7 +168,7 @@ static SMB_STRUCT_DIR *dirsort_fdopendir(vfs_handle_struct *handle, > return NULL; > } > >- data->fd = dirfd(data->source_directory); >+ data->fd = DIRFD(data->source_directory); > > SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates, > struct dirsort_privates, return NULL); >diff --git a/source3/wscript b/source3/wscript >index a1043c8..ecbc58a 100644 >--- a/source3/wscript >+++ b/source3/wscript >@@ -372,6 +372,13 @@ return acl_get_perm_np(permset_d, perm); > if conf.CHECK_FUNCS('dirfd'): > conf.DEFINE('HAVE_DIRFD_DECL', 1) > >+ conf.CHECK_STRUCTURE_MEMBER('DIR', 'd_fd', >+ headers='unistd.h sys/types.h dirent.h', >+ define='HAVE_DIR_D_FD') >+ conf.CHECK_STRUCTURE_MEMBER('DIR', 'dd_fd', >+ headers='unistd.h sys/types.h dirent.h', >+ define='HAVE_DIR_DD_FD') >+ > conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);', > 'HAVE_STATFS_F_FSID', > msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid", >@@ -1775,6 +1782,8 @@ main() { > > if conf.CONFIG_SET('HAVE_DIRFD_DECL'): > default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort')) >+ elif conf.CONFIG_SET('HAVE_DIR_D_FD') or conf.CONFIG_SET('HAVE_DIR_DD_FD'): >+ default_shared_modules.extend(TO_LIST('vfs_dirsort')) > > if conf.CONFIG_SET('HAVE_STATFS_F_FSID'): > default_shared_modules.extend(TO_LIST('vfs_fileid')) >-- >1.7.3.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 8465
: 6903