From: Rob Browning Date: Sat, 10 Dec 2011 19:24:58 +0000 (-0600) Subject: Don't attempt to remove the Linux attr extents flag (see chattr(1)). X-Git-Tag: bup-0.25-rc2~122 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=ac5f1ead36bfe4f02d98d53017110e9c88d6ba8f Don't attempt to remove the Linux attr extents flag (see chattr(1)). Signed-off-by: Rob Browning Reviewed-by: Zoran Zaric --- 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) {