aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-07-18 05:43:44 -0500
committerRob Landley <rob@landley.net>2008-07-18 05:43:44 -0500
commitf15387d8d3a383cd83f4bae8eb4c7dc6a15210d5 (patch)
treed636520ce9d648e7ab158c4e007def38ac3bc0c2 /lib
parent15b231591d3e95d502b2cee1d7d6192177230c15 (diff)
downloadtoybox-f15387d8d3a383cd83f4bae8eb4c7dc6a15210d5.tar.gz
Roberto Foglietta pointed out that readall() needs fdlength() to restore
the original position before exiting.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 959cd46c..d1568932 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -474,7 +474,7 @@ long atolx(char *c)
// Return how long the file at fd is, if there's any way to determine it.
off_t fdlength(int fd)
{
- off_t bottom = 0, top = 0, pos;
+ off_t bottom = 0, top = 0, pos, old;
int size;
// If the ioctl works for this, return it.
@@ -485,6 +485,7 @@ off_t fdlength(int fd)
// block devices don't do BLKGETSIZE right.) This should probably have
// a CONFIG option...
+ old = lseek(fd, 0, SEEK_CUR);
do {
char temp;
@@ -506,6 +507,8 @@ off_t fdlength(int fd)
}
} while (bottom + 1 != top);
+ lseek(fd, old, SEEK_SET);
+
return pos + 1;
}