]> arthur.barton.de Git - bup.git/commitdiff
Don't attempt to remove the Linux attr extents flag (see chattr(1)).
authorRob Browning <rlb@defaultvalue.org>
Sat, 10 Dec 2011 19:24:58 +0000 (13:24 -0600)
committerRob Browning <rlb@defaultvalue.org>
Thu, 18 Oct 2012 01:22:50 +0000 (20:22 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
lib/bup/_helpers.c

index 04a3bb9ce9a928ac3154a7d95a1f88202143efce..42e41f705d7593978f4b0659556d793b642f7da4 100644 (file)
@@ -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)
     {