aboutsummaryrefslogtreecommitdiff
path: root/lib/functions.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-01-23 13:20:38 -0500
committerRob Landley <rob@landley.net>2007-01-23 13:20:38 -0500
commite2580dbebbd43f668913b3d2ae6c0636161636ed (patch)
treee5d7b0482d6e117894599e08161cb7e1a56cc12f /lib/functions.c
parentb882f1e237a68c3d1074cbf63bda0207afb989b9 (diff)
downloadtoybox-e2580dbebbd43f668913b3d2ae6c0636161636ed.tar.gz
More random progress on mke2fs. Nothing to see yet.
Diffstat (limited to 'lib/functions.c')
-rw-r--r--lib/functions.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/functions.c b/lib/functions.c
index b8c122e0..88258ddc 100644
--- a/lib/functions.c
+++ b/lib/functions.c
@@ -397,6 +397,14 @@ char *itoa(int n)
return itoa_buf;
}
+off_t fdlength(int fd)
+{
+ int size;
+
+ if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512L;
+ return -1;
+}
+
/*
This might be of use or might not. Unknown yet...
@@ -405,11 +413,11 @@ char *itoa(int n)
off_t fdlength(int fd)
{
off_t bottom = 0, top = 0, pos;
- long size;
+ int size;
// If the ioctl works for this, return it.
- if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512;
+ if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512L;
// If not, do a binary search for the last location we can read. (Some
// block devices don't do BLKGETSIZE right.) This should probably have