diff options
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -2505,3 +2505,19 @@ u64 disk_size(char *path) else return sfs.f_bsize * sfs.f_blocks; } + +u64 get_partition_size(char *dev) +{ + u64 result; + int fd = open(dev, O_RDONLY); + + if (fd < 0) + return 0; + if (ioctl(fd, BLKGETSIZE64, &result) < 0) { + close(fd); + return 0; + } + close(fd); + + return result; +} |