From 59cf7e0da802aa8f560434bd521c30f5bb5d3e21 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 3 May 2001 15:05:55 +0000 Subject: [PATCH] ChangeLog, debugfs.8.in, debugfs.c: debugfs.c (do_open_filesys, main): Add -i option which will allow debugfs to examine ext2 image files. --- debugfs/ChangeLog | 5 +++++ debugfs/debugfs.8.in | 30 ++++++++++++++++++++++++++---- debugfs/debugfs.c | 12 +++++++++--- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index e0bb10c..a88452f 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,8 @@ +2001-05-03 Theodore Tso + + * debugfs.c (do_open_filesys, main): Add -i option which will + allow debugfs to examine ext2 image files. + 2001-03-29 Theodore Tso * debugfs.c (dump_blocks, dump_inode, internal_dump_inode): Add diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in index 7ac4552..ccc1aeb 100644 --- a/debugfs/debugfs.8.in +++ b/debugfs/debugfs.8.in @@ -34,6 +34,9 @@ request .B \-c ] [ +.B \-i +] +[ device ] ] @@ -49,16 +52,35 @@ is the special file corresponding to the device containing the ext2 file system (e.g /dev/hdXX). .SH OPTIONS .TP -.I -w +.I \-w Specifies that the file system should be opened in read-write mode. Without this option, the file system is opened in read-only mode. .TP -.I -c +.I \-c Specifies that the file system should be opened in catastrophic mode, in which the inode and group bitmaps are not read initially. This can be useful for filesystems with significant corruption, but because of this, catastrophic mode forces the filesystem to be opened read-only. .TP +.I \-i +Specifies that +.I device +represents an ext2 image file created by the +.B e2image +program. Since the ext2 image file only contains the superblock, block +group descriptor, block and inode allocation bitmaps, and +the inode table, many +.B debugfs +commands will not function properly. +.B Warning: +no safety checks are in place, and +.B debugfs +may fail in interesting ways if commands such as +.IR ls ", " dump ", " +etc. are tried. +.B debugfs +is a debugging tool. It has rough edges! +.TP .I -b blocksize Forces the use of the given block size for the file system, rather than detecting the correct block size as normal. @@ -217,7 +239,7 @@ 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] [-f] [-c] [-b blocksize] [-s superblock] device +.I open [-w] [-f] [-i] [-c] [-b blocksize] [-s superblock] device Open a filesystem for editing. The .I -w flag causes the filesystem to be opened for writing. The @@ -225,7 +247,7 @@ flag causes the filesystem to be opened for writing. The 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. The -.IR -c ", " -b ", and " -s +.IR -c ", " -b ", " -i ", " and " -s options behave the same as those to .B debugfs itself. diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 21f2b09..d263919 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -106,8 +106,11 @@ void do_open_filesys(int argc, char **argv) #ifdef HAVE_OPTRESET optreset = 1; /* Makes BSD getopt happy */ #endif - while ((c = getopt (argc, argv, "wfcb:s:")) != EOF) { + while ((c = getopt (argc, argv, "iwfcb:s:")) != EOF) { switch (c) { + case 'i': + open_flags |= EXT2_FLAG_IMAGE_FILE; + break; case 'w': open_flags |= EXT2_FLAG_RW; break; @@ -1530,7 +1533,7 @@ int main(int argc, char **argv) E2FSPROGS_VERSION, E2FSPROGS_DATE, EXT2FS_VERSION, EXT2FS_DATE); - while ((c = getopt (argc, argv, "wcR:f:b:s:V")) != EOF) { + while ((c = getopt (argc, argv, "iwcR:f:b:s:V")) != EOF) { switch (c) { case 'R': request = optarg; @@ -1538,8 +1541,11 @@ int main(int argc, char **argv) case 'f': cmd_file = optarg; break; + case 'i': + open_flags |= EXT2_FLAG_IMAGE_FILE; + break; case 'w': - open_flags = EXT2_FLAG_RW; + open_flags |= EXT2_FLAG_RW; break; case 'b': blocksize = strtoul(optarg, &tmp, 0); -- 1.8.3.1