]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
findsuper.c, ChangeLog:
authorTheodore Ts'o <tytso@mit.edu>
Fri, 18 Jun 1999 00:51:31 +0000 (00:51 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 18 Jun 1999 00:51:31 +0000 (00:51 +0000)
  findsuper.c: Added documentation from aeb@cwi.nl; some minor code
   cleanups.

misc/ChangeLog
misc/findsuper.c

index d3718b790a8972f81d56e2b24d2b53c9ec29c665..014db64b6c0f3690f44d254730a0eb05308f5bf7 100644 (file)
@@ -1,3 +1,8 @@
+1999-05-02    <tytso@rsts-11.mit.edu>
+
+       * findsuper.c: Added documentation from aeb@cwi.nl; some minor
+               code cleanups.
+
 1999-05-20    <tytso@rsts-11.mit.edu>
 
        * dumpe2fs.c, dumpe2fs.8.in: Added new command-line options which
index 2a059f898a1cb32535d39ef8a055ead6e6091223..3a1ef3bd4612d01475a42ffc62655635af12837b 100644 (file)
  *             Steve
  * ssd@nevets.oau.org
  * ssd@mae.engr.ucf.edu
+ * 
  */
 
+/*
+ * Documentation addendum added by Andreas dwguest@win.tue.nl/aeb@cwi.nl
+ * 
+ * The program findsuper is a utility that scans a disk and finds
+ * copies of ext2 superblocks (by checking for the ext2 signature; it
+ * will occasionally find other blocks that by coincidence have this
+ * signature - often these can be recognised by their ridiculous
+ * dates).
+ * 
+ * For each superblock found, it prints the offset in bytes, the
+ * offset in 1024-byte blocks, the size of ext2 partition in 1024-byte
+ * blocks, the filesystem blocksize (given as log(blocksize)-10, so
+ * that 0 means 1024), the block group number (0 for older ext2
+ * systems), and a timestamp (s_mtime).
+ * 
+ * This program can be used to retrieve partitions that have been
+ * lost.  The superblock for block group 0 is found 1 block (2
+ * sectors) after the partition start.
+ * 
+ * For new systems that have a block group number in the superblock it
+ * is immediately clear which superblock is the first of a partition.
+ * For old systems where no group numbers are given, the first
+ * superblock can be recognised by the timestamp: all superblock
+ * copies have the creation time in s_mtime, except the first, which
+ * has the last time e2fsck or tune2fs wrote to the filesystem.
+ * 
+ */
+
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -82,15 +112,17 @@ main(int argc, char *argv[])
        for (;!feof(f) &&  (i=fseek(f,sk,SEEK_SET))!= -1; sk+=skiprate){
                if (i=fread(&ext2,sizeof(ext2),1, f)!=1) {
                        perror("read failed");
-               } else if (ext2.s_magic == EXT2_SUPER_MAGIC){
-                       tm = ext2.s_mtime;
-                       s=ctime(&tm);
-                       s[24]=0;
-                       printf("%9ld %9ld %9ld %5ld %4d %s\n", sk,
-                              sk/1024, ext2.s_blocks_count,
-                              ext2.s_log_block_size,
-                              ext2.s_block_group_nr, s);
                }
+               if (ext2.s_magic != EXT2_SUPER_MAGIC)
+                       continue;
+               
+               tm = ext2.s_mtime;
+               s=ctime(&tm);
+               s[24]=0;
+               printf("%9ld %9ld %9ld %5ld %4d %s\n", sk,
+                      sk/1024, ext2.s_blocks_count,
+                      ext2.s_log_block_size,
+                      ext2.s_block_group_nr, s);
        }
        printf("Failed on %d at %ld\n", i, sk);
        fclose(f);