util-linux/util-linux-2.11y-procpartit...

71 lines
2.3 KiB
Diff

--- util-linux-2.11y/disk-utils/blockdev.c.procpartitions 2002-03-08 17:57:02.000000000 -0500
+++ util-linux-2.11y/disk-utils/blockdev.c 2003-01-13 14:28:41.000000000 -0500
@@ -290,6 +290,7 @@
char ptname[200];
char device[210];
int ma, mi, sz;
+ char iobuf[32*1024];
procpt = fopen(PROC_PARTITIONS, "r");
if (!procpt) {
@@ -297,6 +298,7 @@
progname, PROC_PARTITIONS);
exit(1);
}
+ setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
while (fgets(line, sizeof(line), procpt)) {
if (sscanf (line, " %d %d %d %[^\n ]",
--- util-linux-2.11y/fdisk/fdisk.c.procpartitions 2003-01-13 14:28:41.000000000 -0500
+++ util-linux-2.11y/fdisk/fdisk.c 2003-01-13 14:28:41.000000000 -0500
@@ -2371,12 +2371,14 @@
FILE *procpt;
char line[100], ptname[100], devname[120], *s;
int ma, mi, sz;
+ char iobuf[32*1024];
procpt = fopen(PROC_PARTITIONS, "r");
if (procpt == NULL) {
fprintf(stderr, _("cannot open %s\n"), PROC_PARTITIONS);
return;
}
+ setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
while (fgets(line, sizeof(line), procpt)) {
if (sscanf (line, " %d %d %d %[^\n ]",
--- util-linux-2.11y/mount/mount_by_label.c.procpartitions 2002-11-26 04:23:49.000000000 -0500
+++ util-linux-2.11y/mount/mount_by_label.c 2003-01-13 14:31:53.000000000 -0500
@@ -136,9 +136,7 @@
char device[110];
int firstPass;
int handleOnFirst;
-#if 0
char iobuf[32*1024]; /* For setvbuf */
-#endif
if (uuidCache)
return;
@@ -155,7 +153,6 @@
PROC_PARTITIONS);
return;
}
-#if 0
/* Ugly kludge - the contents of /proc/partitions change in time,
and this causes failures when the file is not read in one go.
In particular, one cannot use stdio on /proc/partitions.
@@ -166,9 +163,12 @@
to keep statistics in /proc/partitions. Of course, statistics belong
in some /proc/diskstats, not in some /proc file that happened to
exist already. */
-
+/* Until someone actually implements something else, /proc/partitions _IS_
+ /proc/diskstats. And no matter what file we are reading, we will still
+ need to increase the buffer size, because 8k is just not Enough For
+ Everyone even if stats aren't in /proc/partitions.
+*/
setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
-#endif
for (firstPass = 1; firstPass >= 0; firstPass--) {
fseek(procpt, 0, SEEK_SET);