Whamcloud - gitweb
Add support for specifiying - as the image file (to send the image
authorTheodore Ts'o <tytso@mit.edu>
Thu, 9 Aug 2001 10:04:32 +0000 (06:04 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 9 Aug 2001 10:04:32 +0000 (06:04 -0400)
file to standard out).

Save the journal inode if it is internal to the raw image file.

misc/e2image.8.in
misc/e2image.c

index 411a7fd..d7fb252 100644 (file)
@@ -31,9 +31,16 @@ the recovery of catastrophically corrupted filesystems.  In the future,
 e2fsck will be enhanced to be able to use the image file to help
 recover a badly damaged filesystem.
 .PP
+If  
+.I image-file
+is -, then the output of 
+.B e2image
+will be sent to standard output.
+.PP
 The 
 .B \-r
-option will create a raw image file instead.  A raw image file differs
+option will create a raw image file instead of a normal image file.  
+A raw image file differs
 from a normal image file in two ways.  First, the filesystem metadata is
 placed in the proper position so that e2fsck, dumpe2fs, debugfs,
 etc. can be run directly on the raw image file.  In order to minimize
@@ -42,7 +49,7 @@ created as a sparse file.  (Beware of copying or
 compressing/decompressing this file with utilities that don't understand
 how to create sparse files; the file will become as large as the
 filesystem itself!)  Secondly, the raw image file also includes indirect
-blocks and data blocks, which the current image file does not have ---
+blocks and data blocks, which the current image file does not have,
 although this may change in the future.
 .PP
 It is a very good idea to periodically (at boot time and 
index 0a2ed63..600cd7b 100644 (file)
@@ -362,7 +362,8 @@ static void write_raw_image_file(ext2_filsys fs, int fd)
                        continue;
                
                stashed_ino = ino;
-               if (LINUX_S_ISDIR(inode.i_mode)) {
+               if (LINUX_S_ISDIR(inode.i_mode) ||
+                   ino == fs->super->s_journal_inum) {
                        retval = ext2fs_block_iterate2(fs, ino, 0, 
                                       block_buf, process_dir_block, &pb);
                        if (retval) {
@@ -436,15 +437,19 @@ int main (int argc, char ** argv)
                exit(1);
        }
 
+       if (strcmp(outfn, "-") == 0)
+               fd = 1;
+       else {
 #ifdef HAVE_OPEN64
-       fd = open64(outfn, O_CREAT|O_TRUNC|O_WRONLY, 0600);
+               fd = open64(outfn, O_CREAT|O_TRUNC|O_WRONLY, 0600);
 #else
-       fd = open(outfn, O_CREAT|O_TRUNC|O_WRONLY, 0600);
+               fd = open(outfn, O_CREAT|O_TRUNC|O_WRONLY, 0600);
 #endif
-       if (fd < 0) {
-               com_err(program_name, errno, _("while trying to open %s"),
-                       argv[optind+1]);
-               exit(1);
+               if (fd < 0) {
+                       com_err(program_name, errno,
+                               _("while trying to open %s"), argv[optind+1]);
+                       exit(1);
+               }
        }
 
        if (raw_flag)
@@ -455,5 +460,3 @@ int main (int argc, char ** argv)
        ext2fs_close (fs);
        exit (0);
 }
-
-