From ac5f1ead36bfe4f02d98d53017110e9c88d6ba8f Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 10 Dec 2011 13:24:58 -0600 Subject: [PATCH] Don't attempt to remove the Linux attr extents flag (see chattr(1)). Signed-off-by: Rob Browning Reviewed-by: Zoran Zaric --- lib/bup/_helpers.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 04a3bb9..42e41f7 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -680,7 +680,7 @@ static PyObject *bup_get_linux_file_attr(PyObject *self, PyObject *args) static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args) { int rc; - unsigned long attr; + unsigned long orig_attr, attr; char *path; int fd; @@ -699,6 +699,15 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args) | EXT2_UNRM_FL | EXT2_NOATIME_FL | EXT2_DIRSYNC_FL | EXT2_SYNC_FL | EXT2_TOPDIR_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); + if (rc == -1) + { + close(fd); + return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); + } + attr |= (orig_attr & EXT4_EXTENTS_FL); + rc = ioctl(fd, FS_IOC_SETFLAGS, &attr); if (rc == -1) { -- 2.39.2