svn commit: trunk/busybox: libbb miscutils util-linux
vda at busybox.net
vda at busybox.net
Sun Jan 27 23:41:35 UTC 2008
Author: vda
Date: 2008-01-27 15:41:34 -0800 (Sun, 27 Jan 2008)
New Revision: 20913
Log:
mkswap, readahead: stop using fdlength, it is reported to be unreliable
Modified:
trunk/busybox/libbb/xfuncs.c
trunk/busybox/miscutils/readahead.c
trunk/busybox/util-linux/mkswap.c
Changeset:
Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c 2008-01-27 23:24:31 UTC (rev 20912)
+++ trunk/busybox/libbb/xfuncs.c 2008-01-27 23:41:34 UTC (rev 20913)
@@ -475,6 +475,7 @@
}
// Return how long the file at fd is, if there's any way to determine it.
+#ifdef UNUSED
off_t fdlength(int fd)
{
off_t bottom = 0, top = 0, pos;
@@ -513,6 +514,7 @@
return pos + 1;
}
+#endif
int bb_putchar(int ch)
{
Modified: trunk/busybox/miscutils/readahead.c
===================================================================
--- trunk/busybox/miscutils/readahead.c 2008-01-27 23:24:31 UTC (rev 20912)
+++ trunk/busybox/miscutils/readahead.c 2008-01-27 23:41:34 UTC (rev 20913)
@@ -22,9 +22,16 @@
while (*++argv) {
int fd = open_or_warn(*argv, O_RDONLY);
if (fd >= 0) {
- int r = readahead(fd, 0, fdlength(fd));
+ off_t len;
+ int r;
+
+ /* fdlength was reported to be unreliable - use seek */
+ len = xlseek(fd, 0, SEEK_END);
+ xlseek(fd, 0, SEEK_SET);
+ r = readahead(fd, 0, len);
close(fd);
- if (r >= 0) continue;
+ if (r >= 0)
+ continue;
}
retval = EXIT_FAILURE;
}
Modified: trunk/busybox/util-linux/mkswap.c
===================================================================
--- trunk/busybox/util-linux/mkswap.c 2008-01-27 23:24:31 UTC (rev 20912)
+++ trunk/busybox/util-linux/mkswap.c 2008-01-27 23:41:34 UTC (rev 20913)
@@ -64,9 +64,11 @@
// Figure out how big the device is and announce our intentions.
fd = xopen(argv[1], O_RDWR);
- len = fdlength(fd);
+ /* fdlength was reported to be unreliable - use seek */
+ len = xlseek(fd, 0, SEEK_END);
+ xlseek(fd, 0, SEEK_SET);
pagesize = getpagesize();
- printf("Setting up swapspace version 1, size = %"OFF_FMT"d bytes\n",
+ printf("Setting up swapspace version 1, size = %"OFF_FMT"u bytes\n",
len - pagesize);
mkswap_selinux_setcontext(fd, argv[1]);
More information about the busybox-cvs
mailing list