aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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 {