]> arthur.barton.de Git - bup.git/commitdiff
Quash stat(2) st_rdev unless we're going to need it for mknod().
authorRob Browning <rlb@defaultvalue.org>
Tue, 17 Sep 2013 01:47:28 +0000 (20:47 -0500)
committerRob Browning <rlb@defaultvalue.org>
Wed, 18 Sep 2013 17:30:33 +0000 (12:30 -0500)
On some platforms (i.e. kFreeBSD), the st_rdev value isn't completely
stable.  For example, given "date > foo; cp -a foo foo-2", the st_rdev
value may differ between the two files.

Since we only need the st_rdev value for the call to mknod() when
restoring character and block special files, set it to zero for
anything else.

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

index 81c234fa2e2dcec7123ffe64dc68e4b9a712d248..168d1c97edb41d0d8c5eeaf531826619d9110522 100644 (file)
@@ -199,7 +199,6 @@ class Metadata:
     def _add_common(self, path, st):
         self.uid = st.st_uid
         self.gid = st.st_gid
-        self.rdev = st.st_rdev
         self.atime = st.st_atime
         self.mtime = st.st_mtime
         self.ctime = st.st_ctime
@@ -211,6 +210,14 @@ class Metadata:
         if entry:
             self.group = entry.gr_name
         self.mode = st.st_mode
+        # Only collect st_rdev if we might need it for a mknod()
+        # during restore.  On some platforms (i.e. kFreeBSD), it isn't
+        # stable for other file types.  For example "cp -a" will
+        # change it for a plain file.
+        if stat.S_ISCHR(st.st_mode) or stat.S_ISBLK(st.st_mode):
+            self.rdev = st.st_rdev
+        else:
+            self.rdev = 0
 
     def _same_common(self, other):
         """Return true or false to indicate similarity in the hardlink sense."""