Message ID | 20210113075110.31628-2-pvorel@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/3] lapi: Move struct file_handle into lapi/fcntl.h | expand |
Hi Petr > that way it can be used in fanotify tests > (some of use the struct, but not name_to_handle_at() syscall) > and the struct is defined in<fcntl.h> anyway. > > Although detection with HAVE_NAME_TO_HANDLE_AT works (at least on glibc, > musl and uclibc-ng) add proper autotools check for the struct presence. > > Signed-off-by: Petr Vorel<pvorel@suse.cz> > --- > configure.ac | 6 ++++++ > include/lapi/fcntl.h | 10 ++++++++++ > include/lapi/name_to_handle_at.h | 9 +-------- > 3 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 06be1c094..e44e25cc6 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -148,6 +148,12 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include<sys/acct.h>]) > AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include<linux/if_alg.h>]) > AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include<sys/fanotify.h>]) > AC_CHECK_TYPES([struct file_dedupe_range],,,[#include<linux/fs.h>]) > + > +AC_CHECK_TYPES([struct file_handle],,,[ > +#define _GNU_SOURCE I think file_handle struct doesn't need _GNU_SOURCE macro or I miss something? Other than this, this patchset LGTM. Acked-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com> > +#include<fcntl.h> > +]) > + > AC_CHECK_TYPES([struct fs_quota_statv],,,[#include<xfs/xqm.h>]) > AC_CHECK_TYPES([struct if_nextdqblk],,,[#include<linux/quota.h>]) > AC_CHECK_TYPES([struct iovec],,,[#include<sys/uio.h>]) > diff --git a/include/lapi/fcntl.h b/include/lapi/fcntl.h > index d6665915f..e08970c4f 100644 > --- a/include/lapi/fcntl.h > +++ b/include/lapi/fcntl.h > @@ -6,6 +6,7 @@ > #ifndef __LAPI_FCNTL_H__ > #define __LAPI_FCNTL_H__ > > +#include "config.h" > #include<fcntl.h> > #include<sys/socket.h> > > @@ -140,4 +141,13 @@ > # define MAX_HANDLE_SZ 128 > #endif > > +#ifndef HAVE_STRUCT_FILE_HANDLE > +struct file_handle { > + unsigned int handle_bytes; > + int handle_type; > + /* File identifier. */ > + unsigned char f_handle[0]; > +}; > +#endif /* HAVE_STRUCT_FILE_HANDLE */ > + > #endif /* __LAPI_FCNTL_H__ */ > diff --git a/include/lapi/name_to_handle_at.h b/include/lapi/name_to_handle_at.h > index 3484133d1..275db4ae0 100644 > --- a/include/lapi/name_to_handle_at.h > +++ b/include/lapi/name_to_handle_at.h > @@ -15,13 +15,6 @@ > #include "tst_test.h" > > #ifndef HAVE_NAME_TO_HANDLE_AT > -struct file_handle { > - unsigned int handle_bytes; > - int handle_type; > - /* File identifier. */ > - unsigned char f_handle[0]; > -}; > - > static inline int name_to_handle_at(int dfd, const char *pathname, > struct file_handle *handle, > int *mount_id, int flags) > @@ -35,7 +28,7 @@ static inline int open_by_handle_at(int mount_fd, struct file_handle *handle, > { > return tst_syscall(__NR_open_by_handle_at, mount_fd, handle, flags); > } > -#endif > +#endif /* HAVE_NAME_TO_HANDLE_AT */ > > /* Returns a valid pointer on success, NULL on errors */ > static inline struct file_handle *
Hi Xu, ... > > +AC_CHECK_TYPES([struct file_handle],,,[ > > +#define _GNU_SOURCE > I think file_handle struct doesn't need _GNU_SOURCE macro or I miss > something? It does require :). In glibc is guarded in sysdeps/unix/sysv/linux/bits/fcntl-linux.h with __USE_GNU which is controlled by user with _GNU_SOURCE. In musl (which is much easier to read) is just guarded by _GNU_SOURCE. That is the reason why I guarded it with __USE_GNU in uclibc-ng, when I backported there the implementation from musl. Kind regards, Petr > Other than this, this patchset LGTM. > Acked-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com> Thanks for your review! Kind regards, Petr > > +#include<fcntl.h> > > +])
Hi Petr > Hi Xu, > > ... >>> +AC_CHECK_TYPES([struct file_handle],,,[ >>> +#define _GNU_SOURCE >> I think file_handle struct doesn't need _GNU_SOURCE macro or I miss >> something? > > It does require :). > In glibc is guarded in sysdeps/unix/sysv/linux/bits/fcntl-linux.h with > __USE_GNU which is controlled by user with _GNU_SOURCE. > > In musl (which is much easier to read) is just guarded by _GNU_SOURCE. > > That is the reason why I guarded it with __USE_GNU in uclibc-ng, when I > backported there the implementation from musl. Thanks for your explanation, I see glibc code, you are right. I missed file_handle struct using _USE_GNU macro. Also, I see feature.h header uses _GNU_SOURCE controlling __USE_GNU. Best Regards Yang Xu > > Kind regards, > Petr > >> Other than this, this patchset LGTM. >> Acked-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com> > Thanks for your review! > > Kind regards, > Petr >>> +#include<fcntl.h> >>> +]) > > > . >
diff --git a/configure.ac b/configure.ac index 06be1c094..e44e25cc6 100644 --- a/configure.ac +++ b/configure.ac @@ -148,6 +148,12 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include <sys/fanotify.h>]) AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>]) + +AC_CHECK_TYPES([struct file_handle],,,[ +#define _GNU_SOURCE +#include <fcntl.h> +]) + AC_CHECK_TYPES([struct fs_quota_statv],,,[#include <xfs/xqm.h>]) AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) AC_CHECK_TYPES([struct iovec],,,[#include <sys/uio.h>]) diff --git a/include/lapi/fcntl.h b/include/lapi/fcntl.h index d6665915f..e08970c4f 100644 --- a/include/lapi/fcntl.h +++ b/include/lapi/fcntl.h @@ -6,6 +6,7 @@ #ifndef __LAPI_FCNTL_H__ #define __LAPI_FCNTL_H__ +#include "config.h" #include <fcntl.h> #include <sys/socket.h> @@ -140,4 +141,13 @@ # define MAX_HANDLE_SZ 128 #endif +#ifndef HAVE_STRUCT_FILE_HANDLE +struct file_handle { + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; +#endif /* HAVE_STRUCT_FILE_HANDLE */ + #endif /* __LAPI_FCNTL_H__ */ diff --git a/include/lapi/name_to_handle_at.h b/include/lapi/name_to_handle_at.h index 3484133d1..275db4ae0 100644 --- a/include/lapi/name_to_handle_at.h +++ b/include/lapi/name_to_handle_at.h @@ -15,13 +15,6 @@ #include "tst_test.h" #ifndef HAVE_NAME_TO_HANDLE_AT -struct file_handle { - unsigned int handle_bytes; - int handle_type; - /* File identifier. */ - unsigned char f_handle[0]; -}; - static inline int name_to_handle_at(int dfd, const char *pathname, struct file_handle *handle, int *mount_id, int flags) @@ -35,7 +28,7 @@ static inline int open_by_handle_at(int mount_fd, struct file_handle *handle, { return tst_syscall(__NR_open_by_handle_at, mount_fd, handle, flags); } -#endif +#endif /* HAVE_NAME_TO_HANDLE_AT */ /* Returns a valid pointer on success, NULL on errors */ static inline struct file_handle *
that way it can be used in fanotify tests (some of use the struct, but not name_to_handle_at() syscall) and the struct is defined in <fcntl.h> anyway. Although detection with HAVE_NAME_TO_HANDLE_AT works (at least on glibc, musl and uclibc-ng) add proper autotools check for the struct presence. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- configure.ac | 6 ++++++ include/lapi/fcntl.h | 10 ++++++++++ include/lapi/name_to_handle_at.h | 9 +-------- 3 files changed, 17 insertions(+), 8 deletions(-)