Whamcloud - gitweb
debugfs: fix double-close bug in "rdump" and "dump -p"
authorAaron Crane <arc@aaroncrane.co.uk>
Mon, 4 Aug 2014 01:52:11 +0000 (21:52 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 4 Aug 2014 22:58:23 +0000 (18:58 -0400)
Previously, both of these usages called dump_file() with a true value as
the "preserve" argument, which caused it to in turn call fix_perms() to
make the permissions on the locally-dumped file match those found on the
ext2 filesystem. fix_perms() then attempted to close(2) the file descriptor
(if any) before returning (though it didn't attempt to report on any errors
found while doing so).

However, in both of these situations, the local file being dumped had been
opened by the caller of dump_file(), which also closes it (and reports on
any errors detected when closing). This meant that both "rdump" and "dump
-p" would then emit a spurious EBADF message when trying to re-close the
local file descriptor.

Deleting the spurious close(2) call in fix_perms() fixes the problem in both
commands.

Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/dump.c

index f4f1625..13bf06a 100644 (file)
@@ -91,9 +91,6 @@ static void fix_perms(const char *cmd, const struct ext2_inode *inode,
        if (i == -1)
                com_err(cmd, errno, "while changing ownership of %s", name);
 
-       if (fd != -1)
-               close(fd);
-
        ut.actime = inode->i_atime;
        ut.modtime = inode->i_mtime;
        if (utime(name, &ut) == -1)