Date: Fri, 26 Jan 1996 02:43:06 -0800 (PST) From: asami@cs.berkeley.edu (Satoshi Asami) To: joerg@freefall.freebsd.org Cc: CVS-committers@freefall.freebsd.org, cvs-sbin@freefall.freebsd.org Subject: Re: cvs commit: src/sbin/newfs mkfs.c Message-ID: <199601261043.CAA01515@silvia.HIP.Berkeley.EDU> In-Reply-To: <199601252344.PAA18190@freefall.freebsd.org> (message from Joerg Wunsch on Thu, 25 Jan 1996 15:44:34 -0800 (PST))
next in thread | previous in thread | raw e-mail | index | archive | help
* 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. Hey, how about this one. I think the output looks even nicer, especially when you go over >5GB or >50GB. :) Satoshi P.S. I'm not sure if the terminal routine is supposed to wrap to the beginning of the line when you write to the last char...it works here, but if it looks funny at your place, you may need to change "i+j>width" to "i+j>=width">... ------- Index: mkfs.c =================================================================== RCS file: /usr/cvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.9 diff -c -r1.9 mkfs.c *** 1.9 1996/01/25 23:44:32 --- mkfs.c 1996/01/26 10:36:55 *************** *** 122,128 **** int fsi, fso; daddr_t alloc(); ! static int numbersperline(); mkfs(pp, fsys, fi, fo) struct partition *pp; --- 122,128 ---- int fsi, fso; daddr_t alloc(); ! static int charsperline(); mkfs(pp, fsys, fi, fo) struct partition *pp; *************** *** 138,143 **** --- 138,145 ---- time_t utime; quad_t sizepb; void started(); + int width; + char tmpbuf[100]; /* XXX this will break in about 2,500 years */ #ifndef STANDALONE time(&utime); *************** *** 621,635 **** * then print out indices of cylinder groups. */ if (!mfs) ! printf("super-block backups (for fsck -b #) at:"); ! i = numbersperline(sblock.fs_size * NSPF(&sblock)); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); if (mfs) continue; ! if (cylno % i == 0) printf("\n"); ! printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); fflush(stdout); } if (!mfs) --- 623,643 ---- * then print out indices of cylinder groups. */ if (!mfs) ! printf("super-block backups (for fsck -b #) at:\n"); ! i = 0; ! width = charsperline(); for (cylno = 0; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime); if (mfs) continue; ! j = sprintf(tmpbuf, " %d,", ! fsbtodb(&sblock, cgsblock(&sblock, cylno))); ! if (i+j > width) { printf("\n"); ! i = 0; ! } ! i += j; ! printf("%s", tmpbuf); fflush(stdout); } if (!mfs) *************** *** 1268,1290 **** } /* ! * 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; --- 1276,1293 ---- } /* ! * Determine the number of characters in a * single line. */ static int ! charsperline() { ! int columns; char *cp; struct winsize ws; extern char *getenv(); columns = 0; if (ioctl(0, TIOCGWINSZ, &ws) != -1) columns = ws.ws_col; *************** *** 1292,1299 **** columns = atoi(cp); if (columns == 0) columns = 80; /* last resort */ ! i = columns / i; ! if (i < 3) ! i = 3; /* don't care */ ! return i; } --- 1295,1299 ---- columns = atoi(cp); if (columns == 0) columns = 80; /* last resort */ ! return columns; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601261043.CAA01515>