Added formatting fixes for larger numbers in fsck and df; made mkfs

test for devices larger than 4GB, so it won't try to test them (and print
a warning message), but it will write the FS.
This commit is contained in:
Ben Gras 2005-06-30 13:04:57 +00:00
parent 037d5ffb26
commit ebd38d9a92
4 changed files with 31 additions and 22 deletions

View file

@ -381,7 +381,7 @@ fortune: fortune.c
fsck: fsck.c
$(CCLD) -o $@ $?
@install -S 1024k $@
@install -S 4096k $@
fsck1: fsck1.c
$(CCLD) -o $@ $?

View file

@ -117,13 +117,13 @@ int main(int argc, char *argv[])
if (Pflag) {
printf(!iflag ? "\
Filesystem %4d-blocks Used Available Capacity Mounted on\n" : "\
Filesystem Inodes IUsed IFree %%IUsed Mounted on\n",
Filesystem %4d-blocks Used Available Capacity Mounted on\n" : "\
Filesystem Inodes IUsed IFree %%IUsed Mounted on\n",
unitsize);
} else {
printf("%s\n", !iflag ? "\
Filesystem 1K-Blocks Free Used % Files% Mounted on" : "\
Filesystem Files Free Used % BUsed% Mounted on"
Filesystem 1K-Blocks Free Used % Files% Mounted on" : "\
Filesystem Files Free Used % BUsed% Mounted on"
);
}
@ -358,7 +358,7 @@ int df(const struct mtab *mt)
while (n < 15) { putchar(' '); n++; }
if (!Pflag && !iflag) {
printf(" %7ld %7ld %7ld %3d%% %3d%% %s\n",
printf(" %9ld %9ld %9ld %3d%% %3d%% %s\n",
L(totblocks), /* Blocks */
L(totblocks - busyblocks), /* free */
L(busyblocks), /* used */
@ -368,7 +368,7 @@ int df(const struct mtab *mt)
);
}
if (!Pflag && iflag) {
printf(" %7ld %7ld %7ld %3d%% %3d%% %s\n",
printf(" %9ld %9ld %9ld %3d%% %3d%% %s\n",
L(sp->s_ninodes), /* Files */
L(sp->s_ninodes - i_count), /* free */
L(i_count), /* used */
@ -378,7 +378,7 @@ int df(const struct mtab *mt)
);
}
if (Pflag && !iflag) {
printf(" %7ld %7ld %7ld %4d%% %s\n",
printf(" %9ld %9ld %9ld %4d%% %s\n",
L(totblocks), /* Blocks */
L(busyblocks), /* Used */
totblocks - busyblocks, /* Available */
@ -387,7 +387,7 @@ int df(const struct mtab *mt)
);
}
if (Pflag && iflag) {
printf(" %7ld %7ld %7ld %4d%% %s\n",
printf(" %9ld %9ld %9ld %4d%% %s\n",
L(sp->s_ninodes), /* Inodes */
L(i_count), /* IUsed */
L(sp->s_ninodes - i_count), /* IAvail */

View file

@ -309,7 +309,11 @@ unsigned nelem, elsize;
{
char *p;
if ((p = (char *)malloc((size_t)nelem * elsize)) == 0)fatal("out of memory");
if ((p = (char *)malloc((size_t)nelem * elsize)) == 0) {
fprintf(stderr, "Tried to allocate %dkB\n",
nelem*elsize/1024);
fatal("out of memory");
}
memset((void *) p, 0, (size_t)nelem * elsize);
return(p);
}
@ -1438,21 +1442,21 @@ void printtotal()
printf("blocksize = %5d ", block_size);
printf("zonesize = %5d\n", ZONE_SIZE);
printf("\n");
pr("%6u Regular file%s\n", nregular, "", "s");
pr("%6u Director%s\n", ndirectory, "y", "ies");
pr("%6u Block special file%s\n", nblkspec, "", "s");
pr("%6u Character special file%s\n", ncharspec, "", "s");
pr("%8u Regular file%s\n", nregular, "", "s");
pr("%8u Director%s\n", ndirectory, "y", "ies");
pr("%8u Block special file%s\n", nblkspec, "", "s");
pr("%8u Character special file%s\n", ncharspec, "", "s");
if (nbadinode != 0) pr("%6u Bad inode%s\n", nbadinode, "", "s");
pr("%6u Free inode%s\n", nfreeinode, "", "s");
pr("%6u Named pipe%s\n", npipe, "", "s");
pr("%6u Symbolic link%s\n", nsyml, "", "s");
pr("%8u Free inode%s\n", nfreeinode, "", "s");
pr("%8u Named pipe%s\n", npipe, "", "s");
pr("%8u Symbolic link%s\n", nsyml, "", "s");
/* Don't print some fields.
printf("\n");
pr("%6u Data zone%s\n", ztype[0], "", "s");
pr("%6u Single indirect zone%s\n", ztype[1], "", "s");
pr("%6u Double indirect zone%s\n", ztype[2], "", "s");
pr("%8u Data zone%s\n", ztype[0], "", "s");
pr("%8u Single indirect zone%s\n", ztype[1], "", "s");
pr("%8u Double indirect zone%s\n", ztype[2], "", "s");
*/
lpr("%6ld Free zone%s\n", nfreezone, "", "s");
lpr("%8ld Free zone%s\n", nfreezone, "", "s");
}
/* Check the device which name is given by `f'. The inodes listed by `clist'

View file

@ -55,7 +55,7 @@
#define BIN 2
#define BINGRP 2
#define BIT_MAP_SHIFT 13
#define N_BLOCKS (1024L * 1024)
#define N_BLOCKS MAX_BLOCK_NR
#define N_BLOCKS16 (128L * 1024)
#define INODE_MAX ((unsigned) 65535)
@ -323,6 +323,11 @@ char *argv[];
special(argv[--optind]);
#ifdef UNIX
if(ULONG_MAX / block_size <= blocks-1) {
fprintf(stderr, "Warning: mkfs not testing device, it's too big.\n");
donttest = 1;
}
if (!donttest) {
short *testb;
ssize_t w;