OSDN Git Service

debugfs: fix rdump so it can start from the root directory
authorTheodore Ts'o <tytso@mit.edu>
Fri, 3 Jun 2016 03:05:11 +0000 (23:05 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 3 Jun 2016 03:29:07 +0000 (23:29 -0400)
Previously "rdump / /tmp/out" would fail with the error message:

rdump: File exists while making directory /tmp/out/

Also fix the fast symlink detection logic so that it works when a
symlink has one or more extended attributes.

Addresses-Debian-Bug: #766125

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/dump.c

index 1dc6154..4d38651 100644 (file)
@@ -210,7 +210,7 @@ static void rdump_symlink(ext2_ino_t ino, struct ext2_inode *inode,
 
        /* Apparently, this is the right way to detect and handle fast
         * symlinks; see do_stat() in debugfs.c. */
-       if (inode->i_blocks == 0)
+       if (ext2fs_inode_data_blocks2(current_fs, inode) == 0)
                strcpy(buf, (char *) inode->i_block);
        else {
                unsigned bytes = inode->i_size;
@@ -284,7 +284,7 @@ static void rdump_inode(ext2_ino_t ino, struct ext2_inode *inode,
                /* Create the directory with 0700 permissions, because we
                 * expect to have to create entries it.  Then fix its perms
                 * once we've done the traversal. */
-               if (mkdir(fullname, S_IRWXU) == -1) {
+               if (name[0] && mkdir(fullname, S_IRWXU) == -1) {
                        com_err("rdump", errno, "while making directory %s", fullname);
                        goto errout;
                }