From: Rob Browning Date: Sat, 20 Oct 2012 17:35:39 +0000 (-0500) Subject: Depend on the kernel headers, not the ext2 headers, for Linux attr support. X-Git-Tag: bup-0.25-rc2~116 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=70bb58a2d12108561641f17b78bfe73efdad2f59 Depend on the kernel headers, not the ext2 headers, for Linux attr support. Switch to the kernel FS_* defines (in linux/ext2_fs.h) instead of the EXT* defines (in ext2fs/ext2_fs.h -- from the ext2fs headers). Also add FS_NOCOW_FL to the "modifiable flags" mask whenever it's available. Reported-by: Yung-Chin Oei Signed-off-by: Rob Browning Reviewed-by: Yung-Chin Oei --- diff --git a/config/configure b/config/configure index 6f33939..b96c23c 100755 --- a/config/configure +++ b/config/configure @@ -58,8 +58,8 @@ AC_CHECK_HEADERS unistd.h # For FS_IOC_GETFLAGS and FS_IOC_SETFLAGS. AC_CHECK_HEADERS linux/fs.h AC_CHECK_HEADERS sys/ioctl.h -# For attr related flags like EXT2_COMPR_FL. -AC_CHECK_HEADERS ext2fs/ext2_fs.h +# For attr related flags like FS_COMPR_FL. +AC_CHECK_HEADERS linux/ext2_fs.h AC_CHECK_FUNCS utimensat AC_CHECK_FUNCS utimes diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 42e41f7..63f88cf 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -27,15 +27,20 @@ #ifdef HAVE_SYS_IOCTL_H #include #endif -#ifdef HAVE_EXT2FS_EXT2_FS_H -#include +#ifdef HAVE_LINUX_EXT2_FS_H +#include #endif #if defined(FS_IOC_GETFLAGS) && defined(FS_IOC_SETFLAGS) \ - && defined(HAVE_EXT2FS_EXT2_FS_H) + && defined(HAVE_LINUX_EXT2_FS_H) #define BUP_HAVE_FILE_ATTRS 1 #endif +#ifndef FS_NOCOW_FL +// Of course, this assumes it's a bitfield value. +#define FS_NOCOW_FL 0 +#endif + static int istty2 = 0; // Probably we should use autoconf or something and set HAVE_PY_GETARGCARGV... @@ -694,19 +699,19 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args) // Restrict attr to modifiable flags acdeijstuADST -- see // chattr(1) and the e2fsprogs source. Letter to flag mapping is // in pf.c flags_array[]. - attr &= EXT2_APPEND_FL | EXT2_COMPR_FL | EXT2_NODUMP_FL | EXT4_EXTENTS_FL - | EXT2_IMMUTABLE_FL | EXT3_JOURNAL_DATA_FL | EXT2_SECRM_FL | EXT2_NOTAIL_FL - | EXT2_UNRM_FL | EXT2_NOATIME_FL | EXT2_DIRSYNC_FL | EXT2_SYNC_FL - | EXT2_TOPDIR_FL; + attr &= FS_APPEND_FL | FS_COMPR_FL | FS_NODUMP_FL | FS_EXTENT_FL + | FS_IMMUTABLE_FL | FS_JOURNAL_DATA_FL | FS_SECRM_FL | FS_NOTAIL_FL + | FS_UNRM_FL | FS_NOATIME_FL | FS_DIRSYNC_FL | FS_SYNC_FL + | FS_TOPDIR_FL | FS_NOCOW_FL; // The extents flag can't be removed, so don't (see chattr(1) and chattr.c). - rc = ioctl(fd, EXT2_IOC_GETFLAGS, &orig_attr); + rc = ioctl(fd, FS_IOC_GETFLAGS, &orig_attr); if (rc == -1) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); } - attr |= (orig_attr & EXT4_EXTENTS_FL); + attr |= (orig_attr & FS_EXTENT_FL); rc = ioctl(fd, FS_IOC_SETFLAGS, &attr); if (rc == -1)