Re: [PATCH v2] t_snapshot_deleted_subvolume: add check for BTRFS_IOC_SNAP_DESTROY_V2

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Mon, Feb 05, 2024 at 04:49:07PM +0100, David Sterba wrote:
> On Wed, Jan 31, 2024 at 11:23:48PM -0500, Yang Xu wrote:
> > On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but the
> > macros BTRFS_IOC_SNAP_DESTROY_V2 is not defined. This will cause
> > compile error. Add check for BTRFS_IOC_SNAP_DESTROY_V2 to solve this
> > problem.
> > 
> > BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 were
> > introduced together with struct btrfs_ioctl_vol_args_v2 by the
> > commit 55e301fd57a6 ("Btrfs: move fs/btrfs/ioctl.h to
> > include/uapi/linux/btrfs.h"). So there is no need to check them.
> > 
> > Signed-off-by: Yang Xu <xuyang2018.jy@xxxxxxxxxxx>
> > ---
> >  configure.ac                       |  1 +
> >  src/t_snapshot_deleted_subvolume.c | 10 +++++-----
> >  2 files changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/configure.ac b/configure.ac
> > index b22fc52b..b14b1ab8 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -109,6 +109,7 @@ AC_CHECK_MEMBERS([struct btrfs_ioctl_vol_args_v2.subvolid], [], [], [[
> >  #include <stddef.h>
> >  #include <linux/btrfs.h>
> >  ]])
> > +AC_CHECK_DECLS([BTRFS_IOC_SNAP_DESTROY_V2],,,[#include <linux/btrfs.h>])
> >  
> >  AC_CONFIG_HEADERS([include/config.h])
> >  AC_CONFIG_FILES([include/builddefs])
> > diff --git a/src/t_snapshot_deleted_subvolume.c b/src/t_snapshot_deleted_subvolume.c
> > index c3adb1c4..402c0515 100644
> > --- a/src/t_snapshot_deleted_subvolume.c
> > +++ b/src/t_snapshot_deleted_subvolume.c
> > @@ -20,11 +20,6 @@
> >  #define BTRFS_IOCTL_MAGIC 0x94
> >  #endif
> >  
> > -#ifndef BTRFS_IOC_SNAP_DESTROY_V2
> > -#define BTRFS_IOC_SNAP_DESTROY_V2 \
> > -	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> > -#endif
> > -
> >  #ifndef BTRFS_IOC_SNAP_CREATE_V2
> >  #define BTRFS_IOC_SNAP_CREATE_V2 \
> >  	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
> > @@ -58,6 +53,11 @@ struct btrfs_ioctl_vol_args_v2 {
> >  };
> >  #endif
> >  
> > +#if !HAVE_DECL_BTRFS_IOC_SNAP_DESTROY_V2
> 
> This is right for AC_CHECK_DECLS. Other macros like AC_CHECK_HEADERS do
> not define the HAVE_... in case it's not found so the #if !HAVE_...
> would be wrong. Slightly confusing.

Won't AC_CHECK_HEADERS define the HAVE_... ? But how do we get the ...

  /* Define to 1 if you have the <linux/falloc.h> header file. */
  #define HAVE_LINUX_FALLOC_H 1

in include/config.h file?

> 
> > +#define BTRFS_IOC_SNAP_DESTROY_V2 \
> > +	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> > +#endif
> > +
> >  int main(int argc, char **argv)
> >  {
> >  	if (argc != 2) {
> > -- 
> > 2.39.3
> > 
> 





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux