Make the numbers for the "superblock backups" fit nicely on the screen,
even for larger partitions. Until now, partition sizes > 500 MB messed up the screen.
This commit is contained in:
parent
11b61c4563
commit
7f3b8ca95f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13637
@ -46,6 +46,7 @@ static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94";
|
|||||||
#include <sys/disklabel.h>
|
#include <sys/disklabel.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#ifndef STANDALONE
|
#ifndef STANDALONE
|
||||||
#include <a.out.h>
|
#include <a.out.h>
|
||||||
@ -121,6 +122,7 @@ struct dinode zino[MAXBSIZE / sizeof(struct dinode)];
|
|||||||
|
|
||||||
int fsi, fso;
|
int fsi, fso;
|
||||||
daddr_t alloc();
|
daddr_t alloc();
|
||||||
|
static int numbersperline();
|
||||||
|
|
||||||
mkfs(pp, fsys, fi, fo)
|
mkfs(pp, fsys, fi, fo)
|
||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
@ -620,11 +622,12 @@ mkfs(pp, fsys, fi, fo)
|
|||||||
*/
|
*/
|
||||||
if (!mfs)
|
if (!mfs)
|
||||||
printf("super-block backups (for fsck -b #) at:");
|
printf("super-block backups (for fsck -b #) at:");
|
||||||
|
i = numbersperline(sblock.fs_size * NSPF(&sblock));
|
||||||
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
|
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
|
||||||
initcg(cylno, utime);
|
initcg(cylno, utime);
|
||||||
if (mfs)
|
if (mfs)
|
||||||
continue;
|
continue;
|
||||||
if (cylno % 9 == 0)
|
if (cylno % i == 0)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno)));
|
printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno)));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -1263,3 +1266,34 @@ setblock(fs, cp, h)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine the number of block numbers that will nicely fit into a
|
||||||
|
* single line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
numbersperline(seccount)
|
||||||
|
long seccount;
|
||||||
|
{
|
||||||
|
int i, columns;
|
||||||
|
char *cp;
|
||||||
|
struct winsize ws;
|
||||||
|
extern char *getenv();
|
||||||
|
|
||||||
|
for (i = 0; seccount; i++, seccount /= 10)
|
||||||
|
;
|
||||||
|
i += 2; /* account for comma+space */
|
||||||
|
|
||||||
|
columns = 0;
|
||||||
|
if (ioctl(0, TIOCGWINSZ, &ws) != -1)
|
||||||
|
columns = ws.ws_col;
|
||||||
|
if (columns == 0 && (cp = getenv("COLUMNS")))
|
||||||
|
columns = atoi(cp);
|
||||||
|
if (columns == 0)
|
||||||
|
columns = 80; /* last resort */
|
||||||
|
i = columns / i;
|
||||||
|
if (i < 3)
|
||||||
|
i = 3; /* don't care */
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user