ChangeLog, mke2fs.c, tune2fs.8.in:
tune2fs.8.in: Fix minor display bug in the nroff.
mke2fs.c (show_stats, write_inode_tables): Use the log10 function to
calculate the display of block numbers so that things look nice on an
80 character display.
mke2fs.c (usage): Add the sparse-super-flag to the usage message.
ChangeLog, e2fsck.c, pass1.c, pass2.c, problem.c, problem.h, unix.c:
unix.c (main): Move ext2fs_close() after e2fsck_free_context() since
e2fsck_free_context may reference data in ctx->fs.
e2fsck.c (e2fsck_reset_context): Make sure ctx->fs is non-NULL before
checking ctx->fs->dblist.
pass1.c (e2fsck_pass1): Use the device check subroutine on FIFO's and
Socket's, so that we catch bogus immutable inodes.
pass2.c (process_bad_inode): Process bad socket and fifo's.
problem.h, problem.c: Define new problem codes PR_2_BAD_FIFO and
PR_2_BAD_SOCKET.
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 5eacdad..d6eb6fb 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -91,7 +91,7 @@
"[-m reserved-blocks-percentage] [-qvSV]\n\t"
"[-o creator-os] [-g blocks-per-group] [-L volume-label]\n\t"
"[-M last-mounted-directory] [-r fs-revision] [-R raid_opts]\n\t"
- "device [blocks-count]\n",
+ "[-s sparse-super-flag] device [blocks-count]\n",
program_name);
exit(1);
}
@@ -108,6 +108,15 @@
return l;
}
+static int log10(unsigned int arg)
+{
+ int l;
+
+ for (l=0; arg ; l++)
+ arg = arg / 10;
+ return l;
+}
+
static void proceed_question(NOARGS)
{
fflush(stdout);
@@ -139,8 +148,8 @@
return;
} else if ((MAJOR(s.st_rdev) == HD_MAJOR &&
MINOR(s.st_rdev)%64 == 0) ||
- (MAJOR(s.st_rdev) == SCSI_DISK_MAJOR &&
- MINOR(s.st_rdev)%16 == 0)) {
+ (SCSI_BLK_MAJOR(MAJOR(s.st_rdev)) &&
+ MINOR(s.st_rdev)%16 == 0)) {
printf("%s is entire device, not just one partition!\n",
device_name);
proceed_question();
@@ -308,6 +317,7 @@
blk_t blk;
int i, j, num, count;
char *buf;
+ char format[20], backup[80];
buf = malloc(fs->blocksize * STRIDE_LENGTH);
if (!buf) {
@@ -315,12 +325,22 @@
exit(1);
}
memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
-
+
+ /*
+ * Figure out how many digits we need
+ */
+ i = log10(fs->group_desc_count);
+ sprintf(format, "%%%dd/%%%dld", i, i);
+ memset(backup, '\b', sizeof(backup)-1);
+ backup[sizeof(backup)-1] = 0;
+ if ((2*i)+1 < sizeof(backup))
+ backup[(2*i)+1] = 0;
+
if (!quiet)
printf("Writing inode tables: ");
for (i = 0; i < fs->group_desc_count; i++) {
if (!quiet)
- printf("%4d/%4ld", i, fs->group_desc_count);
+ printf(format, i, fs->group_desc_count);
blk = fs->group_desc[i].bg_inode_table;
num = fs->inode_blocks_per_group;
@@ -337,11 +357,11 @@
count, blk, error_message(retval));
}
if (!quiet)
- printf("\b\b\b\b\b\b\b\b\b");
+ fputs(backup, stdout);
}
free(buf);
if (!quiet)
- printf("done \n");
+ fputs("done \n", stdout);
}
static void create_root_dir(ext2_filsys fs)
@@ -453,7 +473,7 @@
struct ext2fs_sb *s = (struct ext2fs_sb *) fs->super;
char buf[80];
blk_t group_block;
- int i, col_left;
+ int i, need, col_left;
if (param.s_blocks_count != s->s_blocks_count)
printf("warning: %d blocks unused.\n\n",
@@ -497,10 +517,12 @@
group_block += s->s_blocks_per_group;
if (!ext2fs_bg_has_super(fs, i))
continue;
- if (!col_left--) {
+ need = log10(group_block) + 2;
+ if (need > col_left) {
printf("\n\t");
- col_left = 6;
+ col_left = 72;
}
+ col_left -= need;
printf("%u", group_block);
if (i != fs->group_desc_count - 1)
printf(", ");