aboutsummaryrefslogtreecommitdiff
path: root/lib
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
parentb882f1e237a68c3d1074cbf63bda0207afb989b9 (diff)
downloadtoybox-e2580dbebbd43f668913b3d2ae6c0636161636ed.tar.gz
More random progress on mke2fs. Nothing to see yet.
Diffstat (limited to 'lib')
-rw-r--r--lib/functions.c12
-rw-r--r--lib/lib.h1
2 files changed, 11 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
diff --git a/lib/lib.h b/lib/lib.h
index e343fd13..e2dc13ec 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -58,6 +58,7 @@ void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
void itoa_to_buf(int n, char *buf, unsigned buflen);
char *utoa(unsigned n);
char *itoa(int n);
+off_t fdlength(int fd);
// getmountlist.c
struct mtab_list {