debugfs: fix rdump so it can start from the root directory

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>
debian
Theodore Ts'o 2016-06-02 23:05:11 -04:00
parent 377e3a9657
commit ebb8b1aa04
1 changed files with 2 additions and 2 deletions

View 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;
}