diff -uNr e2fsprogs-1.32/misc/tune2fs.8.in 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.8.in --- e2fsprogs-1.32/misc/tune2fs.8.in 2002-10-25 17:31:08.000000000 -0400 +++ 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.8.in 2003-03-22 13:13:05.000000000 -0500 @@ -8,6 +8,10 @@ .SH SYNOPSIS .B tune2fs [ +.B \-b +.I superblock +] +[ .B \-l ] [ @@ -87,6 +91,32 @@ adjusts tunable filesystem parameters on a Linux second extended filesystem. .SH OPTIONS .TP +.BI \-b " superblock" +Instead of using the normal superblock, use an alternative superblock +specified by +.IR superblock . +This option is normally used when the primary superblock has been +corrupted. The location of the backup superblock is dependent on the +filesystem's blocksize. For filesystems with 1k blocksizes, a backup +superblock can be found at block 8193; for filesystems with 2k +blocksizes, at block 16384; and for 4k blocksizes, at block 32768. +.IP +Additional backup superblocks can be determined by using the +.B mke2fs +program using the +.B \-n +option to print out where the superblocks were created. The +.B \-b +option to +.BR mke2fs , +which specifies blocksize of the filesystem must be specified in order +for the superblock locations that are printed out to be accurate. +.IP +If an alternative superblock is specified and +the filesystem is not opened read-only, e2fsck will make sure that the +primary superblock is updated appropriately upon completion of the +filesystem check. +.TP .BI \-c " max-mount-counts" Adjust the maximal mounts count between two filesystem checks. If .I max-mount-counts diff -uNr e2fsprogs-1.32/misc/tune2fs.c 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.c --- e2fsprogs-1.32/misc/tune2fs.c 2002-10-15 17:44:46.000000000 -0400 +++ 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.c 2003-03-22 13:06:56.000000000 -0500 @@ -58,6 +58,7 @@ char * new_label, *new_last_mounted, *new_UUID; static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag; static int m_flag, M_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag; +static int b_flag = 0; static time_t last_check_time; static int print_label; static int max_mount_count, mount_count, mount_flags; @@ -78,9 +79,8 @@ static void usage(void) { fprintf(stderr, - _("Usage: %s [-c max-mounts-count] [-e errors-behavior] " - "[-g group]\n" - "\t[-i interval[d|m|w]] [-j] [-J journal-options]\n" + _("Usage: %s [-b superblock] [-c max-mounts-count] [-e errors-behavior]\n " + "\t[-g group] [-i interval[d|m|w]] [-j] [-J journal-options]\n" "\t[-l] [-s sparse-flag] [-m reserved-blocks-percent]\n" "\t[-o [^]mount-options[,...]] [-r reserved-blocks-count]\n" "\t[-u user] [-C mount-count] [-L volume-label] " @@ -462,9 +462,12 @@ struct passwd * pw; printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); - while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:J:L:M:O:T:U:")) != EOF) + while ((c = getopt(argc, argv, "b:c:e:fg:i:jlm:o:r:s:u:C:J:L:M:O:T:U:")) != EOF) switch (c) { + case 'b': + b_flag = atoi(optarg); + break; case 'c': max_mount_count = strtol (optarg, &tmp, 0); if (*tmp || max_mount_count > 16000) { @@ -712,15 +715,27 @@ else parse_tune2fs_options(argc, argv); - retval = ext2fs_open (device_name, open_flag, 0, 0, - unix_io_manager, &fs); - if (retval) { - com_err (program_name, retval, _("while trying to open %s"), - device_name); - fprintf(stderr, - _("Couldn't find valid filesystem superblock.\n")); - exit(1); - } + if (b_flag) { + int blocksize; + for (blocksize = EXT2_MIN_BLOCK_SIZE; + blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) { + retval = ext2fs_open (device_name, open_flag, b_flag, blocksize, + unix_io_manager, &fs); + if (!retval) + break; + } + } else { + retval = ext2fs_open (device_name, open_flag, 0, 0, + unix_io_manager, &fs); + if (retval) { + com_err (program_name, retval, _("while trying to open %s"), + device_name); + fprintf(stderr, + _("Couldn't find valid filesystem superblock.\n")); + exit(1); + } + } + sb = fs->super; if (print_label) { /* For e2label emulation */