]> arthur.barton.de Git - bup.git/commitdiff
restore: create fifos with mkfifo, not mknod
authorGreg Troxel <gdt@lexort.com>
Wed, 5 Jun 2019 20:55:32 +0000 (16:55 -0400)
committerRob Browning <rlb@defaultvalue.org>
Sun, 18 Aug 2019 17:03:46 +0000 (12:03 -0500)
I recently did a restore of a large bup backup, about 34G worth.  All
worked well, including metadata, except that bup threw an exception on
restoring fifos (that I didn't need; they were in /var and were sockets
in use by daemons when the backup happened).

The problem was that mknod was being called for the fifo, and given only
two argumetns.  mknod(2) on NetBSD says it takes three arguments.
mkfifo takes two.  I am guessing that mknod in python calls mknod the OS
call, and on Linux somehow the third null argument works out somehow.
But it seems irregular to make a fifo with mknod.

I realize python is not POSIX, but mknod(2) requires three arguments:
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html

It would be nice to have a test of backing up and restoring a fifo; that
would have caught this.

The following patch makes my restore go smoothly.

Signed-off-by: Greg Troxel <gdt@lexort.com>
[rlb@defaultvalue.org: adjust commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py

index e0923808ff60395027d069e2452a5c2b0a97b8dc..2f3ee06e0ad57839f5fc66c90f7feae21070981f 100644 (file)
@@ -357,7 +357,7 @@ class Metadata:
             os.mknod(path, 0o600 | stat.S_IFBLK, self.rdev)
         elif stat.S_ISFIFO(self.mode):
             assert(self._recognized_file_type())
-            os.mknod(path, 0o600 | stat.S_IFIFO)
+            os.mkfifo(path, 0o600 | stat.S_IFIFO)
         elif stat.S_ISSOCK(self.mode):
             try:
                 os.mknod(path, 0o600 | stat.S_IFSOCK)