duplicity-talk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Duplicity-talk] Fixes for device file handling


From: Kaspar Brand
Subject: [Duplicity-talk] Fixes for device file handling
Date: Wed, 02 Sep 2009 08:17:50 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

The attached patch fixes two issues when handling device files:

1) makes sure that minor numbers > 255 are properly handled
   (path.py)

2) makes sure that major/minor numbers are correctly parsed
   when processing an existing archive (tarfile.py)

Without these fixes, incremental backups don't work properly, in my
case - they are added to every time, because duplicity fails to match
them with the corresponding records in previous backups.

More specifically: on my platform, I have devices with minor numbers >
255, so "self.stat.st_rdev & 0xff" doesn't fit. As duplicity is
requiring Python 2.3 in any case, it seems safe to use os.major/os.minor
by now.

The second issue starts occuring with Python 2.5, actually: int() will
no longer convert strings which include a null byte, so
tarinfo.devmajor/tarinfo.devminor always end up with being set to 0 when
an existing archive is processed (_buftoinfo). Shortening the buffer by
one byte (i.e., leaving out the trailing null byte) does the trick.

The diff is against trunk, but applies cleanly to stable, too.

Thanks,
Kaspar

=== modified file 'duplicity/path.py'
--- duplicity/path.py   2009-07-04 13:47:20 +0000
+++ duplicity/path.py   2009-09-02 05:21:13 +0000
@@ -88,10 +88,9 @@
             raise PathException("Unknown type")
 
         self.mode = stat.S_IMODE(st_mode)
-        # The following can be replaced with major(), minor() macros
-        # in later versions of python (>= 2.3 I think)
         if self.type in ("chr", "blk"):
-            self.devnums = (self.stat.st_rdev >> 8, self.stat.st_rdev & 0xff)
+            self.devnums = (os.major(self.stat.st_rdev),
+                            os.minor(self.stat.st_rdev))
 
     def blank(self):
         """Black out self - set type and stat to None"""

=== modified file 'duplicity/tarfile.py'
--- duplicity/tarfile.py        2009-08-25 13:28:15 +0000
+++ duplicity/tarfile.py        2009-09-02 05:22:36 +0000
@@ -1076,8 +1076,8 @@
         tarinfo.uname = nts(buf[265:297])
         tarinfo.gname = nts(buf[297:329])
         try:
-            tarinfo.devmajor = int(buf[329:337], 8)
-            tarinfo.devminor = int(buf[337:345], 8)
+            tarinfo.devmajor = int(buf[329:336], 8)
+            tarinfo.devminor = int(buf[337:344], 8)
         except ValueError:
             tarinfo.devmajor = tarinfo.devmajor = 0
         tarinfo.prefix = buf[345:500]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]