]> arthur.barton.de Git - bup.git/commitdiff
Handle ntfs-3g EINVAL for attr save/restore
authorRob Browning <rlb@defaultvalue.org>
Wed, 7 Sep 2016 04:34:24 +0000 (23:34 -0500)
committerRob Browning <rlb@defaultvalue.org>
Wed, 7 Sep 2016 04:50:36 +0000 (23:50 -0500)
It appears that ntfs-3g now returns EINVAL for unsupported ioctls
including FS_IOC_GET_FLAGS and FS_IOC_SET_FLAGS.

Treat EINVAL like the existing expected errors for these calls, but
since there's evidence to suggest that other devices/filesystems use
EINVAL to indicate more serious trouble and use ENOTTY to indicate
unsupported ioctls, include a request to report any occurrences of
EINVAL when ntfs-3g is not involved.

Thanks to Mark J Hewitt for reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py

index f77edbe3aef09f1d7d91fa1a9b89d0747b3a0e77..3dd8af9dc718043c4783b1b82d3b5bcb2f96d88a 100644 (file)
@@ -5,6 +5,7 @@
 # This code is covered under the terms of the GNU Library General
 # Public License as described in the bup LICENSE file.
 
+from errno import EACCES, EINVAL, ENOTTY, ENOSYS, EOPNOTSUPP
 from io import BytesIO
 import errno, os, sys, stat, time, pwd, grp, socket, struct
 
@@ -188,6 +189,8 @@ _rec_tag_linux_xattr = 7      # getfattr(1) setfattr(1)
 _rec_tag_hardlink_target = 8 # hard link target path
 _rec_tag_common_v2 = 9 # times, user, group, type, perms, etc. (current)
 
+_warned_about_attr_einval = None
+
 
 class ApplyError(Exception):
     # Thrown when unable to apply any given bit of metadata to a path.
@@ -585,9 +588,17 @@ class Metadata:
             except OSError as e:
                 if e.errno == errno.EACCES:
                     add_error('read Linux attr: %s' % e)
-                elif e.errno in (errno.ENOTTY, errno.ENOSYS, errno.EOPNOTSUPP):
+                elif e.errno in (ENOTTY, ENOSYS, EOPNOTSUPP):
                     # Assume filesystem doesn't support attrs.
                     return
+                elif e.errno == EINVAL:
+                    global _warned_about_attr_einval
+                    if not _warned_about_attr_einval:
+                        log("Ignoring attr EINVAL;"
+                            + " if you're not using ntfs-3g, please report: "
+                            + repr(path) + '\n')
+                        _warned_about_attr_einval = True
+                    return
                 else:
                     raise
 
@@ -615,10 +626,13 @@ class Metadata:
             try:
                 set_linux_file_attr(path, self.linux_attr)
             except OSError as e:
-                if e.errno in (errno.ENOTTY, errno.EOPNOTSUPP, errno.ENOSYS,
-                               errno.EACCES):
+                if e.errno in (EACCES, ENOTTY, EOPNOTSUPP, ENOSYS):
                     raise ApplyError('Linux chattr: %s (0x%s)'
                                      % (e, hex(self.linux_attr)))
+                elif e.errno == EINVAL:
+                    msg = "if you're not using ntfs-3g, please report"
+                    raise ApplyError('Linux chattr: %s (0x%s) (%s)'
+                                     % (e, hex(self.linux_attr), msg))
                 else:
                     raise