1 Mount has to read /proc/partitions in one gulp. It doesn't. Failed for me
2 after a hard powerdown (oops) and the resulting fsck-the-world frenzy on
3 startup, before the mount -a. Falure cause is identical (getting out of
4 sync with the text at the 1K boundary), but failure mode not quite so
5 drastic as it doesn't bail out like fsck does.
7 --- util-linux-2.11y/disk-utils/blockdev.c.procpartitions 2002-03-08 17:57:02.000000000 -0500
8 +++ util-linux-2.11y/disk-utils/blockdev.c 2003-01-13 14:28:41.000000000 -0500
13 + char iobuf[32*1024];
15 procpt = fopen(PROC_PARTITIONS, "r");
18 progname, PROC_PARTITIONS);
21 + setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
23 while (fgets(line, sizeof(line), procpt)) {
24 if (sscanf (line, " %d %d %d %[^\n ]",
25 --- util-linux-2.11y/fdisk/fdisk.c.procpartitions 2003-01-13 14:28:41.000000000 -0500
26 +++ util-linux-2.11y/fdisk/fdisk.c 2003-01-13 14:28:41.000000000 -0500
27 @@ -2371,12 +2371,14 @@
29 char line[100], ptname[100], devname[120], *s;
31 + char iobuf[32*1024];
33 procpt = fopen(PROC_PARTITIONS, "r");
35 fprintf(stderr, _("cannot open %s\n"), PROC_PARTITIONS);
38 + setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
40 while (fgets(line, sizeof(line), procpt)) {
41 if (sscanf (line, " %d %d %d %[^\n ]",
42 --- util-linux-2.11y/mount/mount_by_label.c.procpartitions 2002-11-26 04:23:49.000000000 -0500
43 +++ util-linux-2.11y/mount/mount_by_label.c 2003-01-13 14:31:53.000000000 -0500
49 char iobuf[32*1024]; /* For setvbuf */
59 /* Ugly kludge - the contents of /proc/partitions change in time,
60 and this causes failures when the file is not read in one go.
61 In particular, one cannot use stdio on /proc/partitions.
63 to keep statistics in /proc/partitions. Of course, statistics belong
64 in some /proc/diskstats, not in some /proc file that happened to
67 +/* Until someone actually implements something else, /proc/partitions _IS_
68 + /proc/diskstats. And no matter what file we are reading, we will still
69 + need to increase the buffer size, because 8k is just not Enough For
70 + Everyone even if stats aren't in /proc/partitions.
72 setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
75 for (firstPass = 1; firstPass >= 0; firstPass--) {
76 fseek(procpt, 0, SEEK_SET);