* [TUHS] question about mkfs(8) and stdio
@ 2003-12-15 0:48 John Holden
0 siblings, 0 replies; 3+ messages in thread
From: John Holden @ 2003-12-15 0:48 UTC (permalink / raw)
> you will see the super block backup loop does not fflush(stdio) between
> printf()s
Was there a 'setbuf(stdout, NULL)' at the beginning? This would force immediate
output from any printf's (less efficient than a fflush)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [TUHS] question about mkfs(8) and stdio
@ 2003-12-15 1:22 Michael Sokolov
0 siblings, 0 replies; 3+ messages in thread
From: Michael Sokolov @ 2003-12-15 1:22 UTC (permalink / raw)
Kenneth Stailey <kstailey at yahoo.com> wrote:
> Did stdio buffering change over time?
Line buffering was a Berkeley innovation. stdout became line-buffered by
default (when it is a terminal) in 4.0BSD. 4.2BSD added setlinebuf(3) to allow
people to make stdout or stderr line-buffered when they want to. 4.3BSD
extended it to work on any stream, not just stdout or stderr.
> If you look at an old BSD mkfs for cylinder-group style file systems (not 7th
> Ed filesystems)
Ahmm, you call that old? To me it's new... It's a (wonderful) 4.2BSD
innovation.
> but I have memories that the superblocks were printed out one at a time as if
> fflush(stdout) was called between them rather than one line at a time with
> line-buffered stdio.
I use 4.3BSD-* systems every day and have been for the past several years, and
you can take my word for it that on all 4.3BSD-* systems, including Quasijarus,
plain 4.3, and Ultrix the alternate superblock list output from mkfs/newfs
appears one line at a time on the tty.
> At some point I thought "SysV must have broke this"
I'm curious, where does SysV fit into this? It's the wonderful 4.2BSD
filesystem a BSD-only thing that Missed'em-five people treated as a satanic
manifestation?
> since newfs would print out
> a complete row of superblock numbers at once with a big delay between the rows
That's exactly what it does. BTW mkfs = newfs. mkfs was/is the original UNIX
filesystem creator. It was almost completely rewritten in 4.2BSD to create the
new filesystems. At the same time the newfs program was written as a user-
friendly front-end to mkfs (it merely exec'ed mkfs with a bunch of options).
The situation remained in 4.3. In 4.3-Tahoe/Quasijarus mkfs.c and newfs.c are
compiled and linked into one binary called newfs, CSRG was forced to do this in
order to support disk labels.
MS
^ permalink raw reply [flat|nested] 3+ messages in thread
* [TUHS] question about mkfs(8) and stdio
@ 2003-12-14 19:11 Kenneth Stailey
0 siblings, 0 replies; 3+ messages in thread
From: Kenneth Stailey @ 2003-12-14 19:11 UTC (permalink / raw)
Did stdio buffering change over time?
If you look at an old BSD mkfs for cylinder-group style file systems (not 7th
Ed filesystems) you will see the super block backup loop does not fflush(stdio)
between printf()s
printf("super-block backups (for fsck -b#) at:");
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
initcg(cylno);
if (cylno % 10 == 0)
printf("\n");
printf(" %d,", fsbtodb(&sblock, cgsblock(&sblock, cylno)));
}
but I have memories that the superblocks were printed out one at a time as if
fflush(stdout) was called between them rather than one line at a time with
line-buffered stdio.
At some point I thought "SysV must have broke this" since newfs would print out
a complete row of superblock numbers at once with a big delay between the rows
rather than each superblock number with a short delay between each number.
But when I go searching the oldest BSD code has no fflush(stdout) the way
modern FreeBSD does:
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
initcg(cylno, utime);
if (mfs)
continue;
j = snprintf(tmpbuf, sizeof(tmpbuf), " %ld%s",
fsbtodb(&sblock, cgsblock(&sblock, cylno)),
cylno < (sblock.fs_ncg-1) ? "," : "" );
if (i + j >= width) {
printf("\n");
i = 0;
}
i += j;
printf("%s", tmpbuf);
fflush(stdout);
}
Did stdio buffering change over time so that line buffering became the default?
Thanks,
Ken
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-15 1:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-15 0:48 [TUHS] question about mkfs(8) and stdio John Holden
-- strict thread matches above, loose matches on Subject: below --
2003-12-15 1:22 Michael Sokolov
2003-12-14 19:11 Kenneth Stailey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).