aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libf2fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libf2fs.c')
-rw-r--r--lib/libf2fs.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 01ef4e9..73c551b 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -422,6 +422,9 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
{
int32_t fd = 0;
uint32_t sector_size;
+#ifndef BLKGETSIZE64
+ uint32_t total_sectors;
+#endif
struct stat stat_buf;
struct hd_geometry geom;
u_int64_t wanted_total_sectors = c->total_sectors;
@@ -454,11 +457,20 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
}
}
- if (ioctl(fd, BLKGETSIZE, &c->total_sectors) < 0) {
+#ifdef BLKGETSIZE64
+ if (ioctl(fd, BLKGETSIZE64, &c->total_sectors) < 0) {
MSG(0, "\tError: Cannot get the device size\n");
return -1;
}
-
+ c->total_sectors /= c->sector_size;
+#else
+ if (ioctl(fd, BLKGETSIZE, &total_sectors) < 0) {
+ MSG(0, "\tError: Cannot get the device size\n");
+ return -1;
+ }
+ total_sectors /= c->sector_size;
+ c->total_sectors = total_sectors;
+#endif
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
c->start_sector = 0;
else