Whamcloud - gitweb
ChangeLog, Makefile.in, debug_cmds.ct, debugfs.8.in, debugfs.c:
authorTheodore Ts'o <tytso@mit.edu>
Tue, 14 Sep 1999 20:55:37 +0000 (20:55 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 14 Sep 1999 20:55:37 +0000 (20:55 +0000)
  debugfs.c, debug_cmds.ct: Add new debugfs command "feature" which
   allows the user to set or clear filesystme features.  Add the -f
   (force) option to the open command.  Add the -h (superblock header
   only) option to the stats command.

debugfs/ChangeLog
debugfs/Makefile.in
debugfs/debug_cmds.ct
debugfs/debugfs.8.in
debugfs/debugfs.c

index 87615b4..2a2c479 100644 (file)
@@ -1,3 +1,10 @@
+1999-09-07    <tytso@rsts-11.mit.edu>
+
+       * debugfs.c, debug_cmds.ct: Add new debugfs command "feature"
+               which allows the user to set or clear filesystme features.
+               Add the -f (force) option to the open command.  Add the 
+               -h (superblock header only) option to the stats command.
+
 1999-07-30    <tytso@rsts-11.mit.edu>
 
        * debugfs.c (dump_inode): Fix debugfs message so it is the same
index 7516068..5890a29 100644 (file)
@@ -22,8 +22,8 @@ SRCS= debug_cmds.c $(srcdir)/debugfs.c $(srcdir)/util.c $(srcdir)/ls.c \
        $(srcdir)/ncheck.c $(srcdir)/icheck.c $(srcdir)/lsdel.c \
        $(srcdir)/dump.c
 
-LIBS= $(LIBEXT2FS) $(LIBSS) $(LIBCOM_ERR)  $(LIBUUID)
-DEPLIBS= $(LIBEXT2FS) $(LIBSS) $(LIBCOM_ERR)  $(LIBUUID)
+LIBS= $(LIBEXT2FS) $(LIBE2P) $(LIBSS) $(LIBCOM_ERR)  $(LIBUUID)
+DEPLIBS= $(LIBEXT2FS) $(LIBE2P) $(LIBSS) $(LIBCOM_ERR)  $(LIBUUID)
 
 .c.o:
        $(CC) -c $(ALL_CFLAGS) $< -o $@
@@ -73,13 +73,13 @@ distclean: clean
 # the Makefile.in file
 #
 debug_cmds.o: debug_cmds.c $(top_srcdir)/lib/ss/ss.h \
- $(top_srcdir)/lib/ss/copyright.h $(top_builddir)/lib/ss/ss_err.h
+ $(top_builddir)/lib/ss/ss_err.h
 debugfs.o: $(srcdir)/debugfs.c $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ss/ss.h $(top_srcdir)/lib/ss/copyright.h \
- $(top_builddir)/lib/ss/ss_err.h $(srcdir)/debugfs.h \
- $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/uuid/uuid.h $(srcdir)/../version.h
+ $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \
+ $(srcdir)/debugfs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
+ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/uuid/uuid.h \
+ $(srcdir)/../version.h
 util.o: $(srcdir)/util.c $(srcdir)/debugfs.h \
  $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/et/com_err.h \
  $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
index 00cd6c1..983c342 100644 (file)
@@ -13,6 +13,9 @@ request do_open_filesys, "Open a filesystem",
 request do_close_filesys, "Close the filesystem",
        close_filesys, close;
 
+request do_features, "Set/print superblock features",
+       feature, features;
+
 request do_dirty_filesys, "Mark the filesystem as dirty",
        dirty_filesys, dirty;
 
@@ -111,6 +114,3 @@ request do_cat, "Dump an inode out to stdout",
 
 end;
 
-
-
-
index bc4928e..c56a6bd 100644 (file)
@@ -100,6 +100,11 @@ to match
 Expand the directory
 .IR filespec .
 .TP
+.I feature [fs_feature] [-fs_feature] ...
+Set or clear various filesystem features in the superblock.  After setting
+or clearing any filesystem features that were requested, print the current
+state of the filesystem feature set.
+.TP
 .I find_free_block [goal]
 Find the first free block, starting from
 .I goal
@@ -181,8 +186,14 @@ device numbers must be specified.
 Take the requested list of inode numbers, and print a listing of pathnames
 to those inodes.
 .TP
-.I open [-w] device
-Open a file system for editing.  
+.I open [-w] [-f] device
+Open a filesystem for editing.  The 
+.I -w 
+flag causes the filesystem to be opened for writing.  The 
+.I -f 
+flag forces the filesystem to be opened even if there are some unknown 
+or incompatible filesystem features which would normally 
+prevent the filesystem from being opened.
 .TP
 .I pwd
 Print the current working directory.
@@ -215,8 +226,10 @@ Mark inode
 .I filespec
 as in use in the inode bitmap.
 .TP
-.I show_super_stats
-List the contents of the super block.
+.I show_super_stats [-h]
+List the contents of the super block and the block group descriptors.  If the
+.I -h
+flag is given, only print out the superblock contents.
 .TP
 .I stat filespec
 Display the contents of the inode structure of the inode
index 71c576d..d05922a 100644 (file)
@@ -83,10 +83,13 @@ void do_open_filesys(int argc, char **argv)
 #ifdef HAVE_OPTRESET
        optreset = 1;           /* Makes BSD getopt happy */
 #endif
-       while ((c = getopt (argc, argv, "w")) != EOF) {
+       while ((c = getopt (argc, argv, "wf")) != EOF) {
                switch (c) {
                case 'w':
-                       open_flags = EXT2_FLAG_RW;
+                       open_flags |= EXT2_FLAG_RW;
+                       break;
+               case 'f':
+                       open_flags |= EXT2_FLAG_FORCE;
                        break;
                default:
                        com_err(argv[0], 0, usage);
@@ -165,17 +168,54 @@ void do_init_filesys(int argc, char **argv)
        return;
 }
 
+static void print_features(struct ext2fs_sb * s, FILE *f)
+{
+#ifdef EXT2_DYNAMIC_REV
+       int     i, j, printed=0;
+__u32  *mask = &s->s_feature_compat, m;
+
+       printf ("Filesystem features:");
+       for (i=0; i <3; i++,mask++) {
+               for (j=0,m=1; j < 32; j++, m<<=1) {
+                       if (*mask & m) {
+                               fprintf(f, " %s", e2p_feature2string(i, m));
+                               printed++;
+                       }
+               }
+       }
+       if (printed == 0)
+               printf("(none)");
+       printf("\n");
+#endif
+}
+
 void do_show_super_stats(int argc, char *argv[])
 {
        int     i;
        FILE    *out;
        struct ext2fs_sb *sb;
        struct ext2_group_desc *gdp;
+       int     c, header_only = 0;
        char buf[80];
        const char *none = "(none)";
+       const char *usage = "Usage: show_super [-h]";
 
-       if (argc > 1) {
-               com_err(argv[0], 0, "Usage: show_super");
+       optind = 0;
+#ifdef HAVE_OPTRESET
+       optreset = 1;           /* Makes BSD getopt happy */
+#endif
+       while ((c = getopt (argc, argv, "h")) != EOF) {
+               switch (c) {
+               case 'h':
+                       header_only++;
+                       break;
+               default:
+                       com_err(argv[0], 0, usage);
+                       return;
+               }
+       }
+       if (optind != argc) {
+               com_err(argv[0], 0, usage);
                return;
        }
        if (check_fs_open(argv[0]))
@@ -201,6 +241,7 @@ void do_show_super_stats(int argc, char *argv[])
        else
                strcpy(buf, none);
        fprintf(out, "Filesystem UUID = %s\n", buf);
+       print_features(sb, out);
        fprintf(out, "Last mount time = %s", time_to_string(sb->s_mtime));
        fprintf(out, "Last write time = %s", time_to_string(sb->s_wtime));
        fprintf(out, "Mount counts = %d (maximal = %d)\n",
@@ -230,6 +271,11 @@ void do_show_super_stats(int argc, char *argv[])
                (current_fs->group_desc_count != 1) ? "s" : "",
                current_fs->desc_blocks,
                (current_fs->desc_blocks != 1) ? "s" : "");
+
+       if (header_only) {
+               close_pager(out);
+               return;
+       }
        
        gdp = &current_fs->group_desc[0];
        for (i = 0; i < current_fs->group_desc_count; i++, gdp++)
@@ -1170,6 +1216,9 @@ void do_mkdir(int argc, char *argv[])
                return;
        }
 
+       if (check_fs_read_write(argv[0]))
+               return;
+
        cp = strrchr(argv[1], '/');
        if (cp) {
                *cp = 0;
@@ -1237,6 +1286,9 @@ void do_kill_file(int argc, char *argv[])
        if (check_fs_open(argv[0]))
                return;
 
+       if (check_fs_read_write(argv[0]))
+               return;
+
        inode_num = string_to_inode(argv[1]);
        if (!inode_num) {
                com_err(argv[0], 0, "Cannot find file");
@@ -1258,6 +1310,9 @@ void do_rm(int argc, char *argv[])
        if (check_fs_open(argv[0]))
                return;
 
+       if (check_fs_read_write(argv[0]))
+               return;
+
        retval = ext2fs_namei(current_fs, root, cwd, argv[1], &inode_num);
        if (retval) {
                com_err(argv[0], retval, "while trying to resolve filename");
@@ -1319,6 +1374,26 @@ void do_expand_dir(int argc, char *argv[])
        return;
 }
 
+void do_features(int argc, char *argv[])
+{
+       int     i;
+       
+       if (check_fs_open(argv[0]))
+               return;
+
+       if ((argc != 1) && check_fs_read_write(argv[0]))
+               return;
+       for (i=1; i < argc; i++) {
+               if (e2p_edit_feature(argv[i],
+                                    &current_fs->super->s_feature_compat))
+                       com_err(argv[0], 0, "Unknown feature: %s\n",
+                               argv[i]);
+               else
+                       ext2fs_mark_super_dirty(current_fs);
+       }
+       print_features((struct ext2fs_sb *) current_fs->super, stdout);
+}
+
 static int source_file(const char *cmd_file, int sci_idx)
 {
        FILE            *f;