diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-03-20 16:54:15 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-03-20 16:54:15 -0500 |
commit | abdf84f38ae766f401961d82d4eefdad78ac24ed (patch) | |
tree | 736d3af4afdd4eb0f5777ab6799f3676b27f1f31 /debugfs/debugfs.c | |
parent | de1b76f69aae07c2aafdb532d2def800de7ea313 (diff) | |
download | android_external_e2fsprogs-abdf84f38ae766f401961d82d4eefdad78ac24ed.tar.gz android_external_e2fsprogs-abdf84f38ae766f401961d82d4eefdad78ac24ed.tar.bz2 android_external_e2fsprogs-abdf84f38ae766f401961d82d4eefdad78ac24ed.zip |
debugfs.c (make_link): Set the filetype information when creating
a link.
Diffstat (limited to 'debugfs/debugfs.c')
-rw-r--r-- | debugfs/debugfs.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 2752ff84..e16ac84d 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -818,9 +818,39 @@ void do_print_working_directory(int argc, char *argv[]) return; } +/* + * Given a mode, return the ext2 file type + */ +static int ext2_file_type(unsigned int mode) +{ + if (LINUX_S_ISREG(mode)) + return EXT2_FT_REG_FILE; + + if (LINUX_S_ISDIR(mode)) + return EXT2_FT_DIR; + + if (LINUX_S_ISCHR(mode)) + return EXT2_FT_CHRDEV; + + if (LINUX_S_ISBLK(mode)) + return EXT2_FT_BLKDEV; + + if (LINUX_S_ISLNK(mode)) + return EXT2_FT_SYMLINK; + + if (LINUX_S_ISFIFO(mode)) + return EXT2_FT_FIFO; + + if (LINUX_S_ISSOCK(mode)) + return EXT2_FT_SOCK; + + return 0; +} + static void make_link(char *sourcename, char *destname) { - ext2_ino_t inode; + ext2_ino_t ino; + struct ext2_inode inode; int retval; ext2_ino_t dir; char *dest, *cp, *basename; @@ -828,8 +858,8 @@ static void make_link(char *sourcename, char *destname) /* * Get the source inode */ - inode = string_to_inode(sourcename); - if (!inode) + ino = string_to_inode(sourcename); + if (!ino) return; basename = strrchr(sourcename, '/'); if (basename) @@ -859,8 +889,12 @@ static void make_link(char *sourcename, char *destname) dest = destname; } } + + if (debugfs_read_inode(ino, &inode, sourcename)) + return; - retval = ext2fs_link(current_fs, dir, dest, inode, 0); + retval = ext2fs_link(current_fs, dir, dest, ino, + ext2_file_type(inode.i_mode)); if (retval) com_err("make_link", retval, ""); return; |