From 3b0662fc95e4fefb489ba332d417f0733eb37f44 Mon Sep 17 00:00:00 2001 From: Aaron Crane Date: Sun, 3 Aug 2014 21:52:11 -0400 Subject: [PATCH] debugfs: fix double-close bug in "rdump" and "dump -p" 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 Signed-off-by: Theodore Ts'o --- debugfs/dump.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/debugfs/dump.c b/debugfs/dump.c index f4f1625ff..13bf06afe 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -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) -- 2.47.2