From e2580dbebbd43f668913b3d2ae6c0636161636ed Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 23 Jan 2007 13:20:38 -0500 Subject: More random progress on mke2fs. Nothing to see yet. --- lib/functions.c | 12 ++++++++++-- lib/lib.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') 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 { -- cgit v1.2.3