bdf program bug?
Lawrence F. Strickland
larry at jc3b21.UUCP
Thu Feb 4 08:13:07 AEST 1988
Back in January, Paul Vixie posted a pd df command similar to the Berkely
df. In it, he said:
* Paul Vixie, paul%vixie at uunet.uu.net
*
* Known to work on INTERACTIVE 386/ix, and should therefore work perfectly
* on Microport/386 and whatever the AT&T 6386 calls its OS. Should work okay
* on 3B's. Should work, in fact, anywhere where the output of 'df -t' is
* the same as 'System V/386', which may or may not be all SysV.[23] systems.
Having a 3b2, I figured that there was no way that anything written for
another machine would work correctly on a 3b2! I was right. The 3b2 has a
SLIGHTLY different output for df -t (or maybe its a difference in fscanf,
it is a bit hard to tell). It caused a core dump of the original program.
After fixing that, the columns no longer lined up properly, so I fixed that.
Anyway, THANKS PAUL for a nice program. The changes are very trivial, and
should not (famous last words :-) affect the program on *386* machines
(Sorry, but I can't test it). Here are the diffs: (apply with patch)
*** bdf.c Wed Feb 3 12:32:32 1988
--- bdf.c.new Wed Feb 3 14:40:40 1988
***************
*** 70,76
if (iflag) header_part2();
header_part3();
! while (EOF != fscanf(df, "%s (%s ): %d blocks %d i-nodes",
filesys, device, &fblocks, &finodes)) {
if (EOF == fscanf(df, " total: %d blocks %d i-nodes",
&tblocks, &tinodes)) {
--- 70,76 -----
if (iflag) header_part2();
header_part3();
! while (EOF != fscanf(df, "%s (%[^ )] ): %d blocks %d i-nodes",
filesys, device, &fblocks, &finodes)) {
if (EOF == fscanf(df, " total: %d blocks %d i-nodes",
&tblocks, &tinodes)) {
***************
*** 92,98
static void
header_part1() {
! printf("Filesystem kbytes used avail capacity");
}
static void
header_part2() {
--- 92,98 -----
static void
header_part1() {
! printf("Filesystem kbytes used avail capacity");
}
static void
header_part2() {
***************
*** 96,102
}
static void
header_part2() {
! printf(" iused ifree %%iused");
}
static void
header_part3() {
--- 96,102 -----
}
static void
header_part2() {
! printf(" iused ifree %%iused");
}
static void
header_part3() {
***************
*** 100,106
}
static void
header_part3() {
! printf(" Mounted on\n");
}
static void
--- 100,106 -----
}
static void
header_part3() {
! printf(" Mounted on\n");
}
static void
***************
*** 111,117
int used_kb = total_kb - free_kb;
int capacity = (100 * used_kb) / total_kb;
! printf("%12s %7d %7d %7d %3d%% ",
device, total_kb, used_kb, free_kb, capacity);
}
--- 111,117 -----
int used_kb = total_kb - free_kb;
int capacity = (100 * used_kb) / total_kb;
! printf("%12s %6d %7d%7d %3d%% ",
device, total_kb, used_kb, free_kb, capacity);
}
***************
*** 122,128
int used_inodes = total_inodes - free_inodes;
int percent_used = (100 * used_inodes) / total_inodes;
! printf("%6d %6d %3d%% ", used_inodes, free_inodes, percent_used);
}
static void
--- 122,128 -----
int used_inodes = total_inodes - free_inodes;
int percent_used = (100 * used_inodes) / total_inodes;
! printf("%5d %5d %3d%% ", used_inodes, free_inodes, percent_used);
}
static void
--
+--------------------------------------+-- St. Petersburg Junior College --+
| Lawrence F. Strickland | P.O. Box 13489 |
| ...gatech!codas!usfvax2!jc3b21!larry | St. Petersburg, FL 33733 |
+-(or) ...gatech!usfvax2!jc3b21!larry -+-- Phone: +1 813 341 4705 ---------+
More information about the Comp.sources.bugs
mailing list