]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
debugfs.c (make_link): Set the filetype information when creating
authorTheodore Ts'o <tytso@mit.edu>
Sat, 20 Mar 2004 21:54:15 +0000 (16:54 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 20 Mar 2004 21:54:15 +0000 (16:54 -0500)
a link.

TODO
debugfs/ChangeLog
debugfs/debugfs.c

diff --git a/TODO b/TODO
index 38b7574347a8ba7243fadb50e68568921ff89189..3339705382beb9b7d0f70a5a1f087724f9dc45a5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-Need to process the bad block inode *before* doing the inod scan.
+Need to process the bad block inode *before* doing the inode scan.
 
 Also check to see if the first block of the inode table is not on the
 bad block scan, and fix that.  We need to check for an inaccurate
@@ -193,10 +193,6 @@ TODO list.
 
                                                        - Ted
 
------------------------------------------------------------------
-
-Debugfs's link command should set the file type information
-
 ---------------------------------------------------------------
 From e2fsprogs Debian TODO file as of 1.10-13.
 
index 17f96c9bd899fe0a450bfecff90cfd7fd26dd202..3f546c8ee844c8a8a68225c3021883fe301a7714 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-20  Theodore Ts'o  <tytso@mit.edu>
+
+       * debugfs.c (make_link): Set the filetype information when
+               creating a link.
+
 2004-02-28  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.35
index 2752ff843e28f64f0e49e77e064094b3530afd87..e16ac84d12b0cee65d4c5b6387b1c81fccb697cb 100644 (file)
@@ -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;