diff options
author | Karel Zak <kzak@redhat.com> | 2010-03-11 00:59:04 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2010-03-11 00:59:04 +0100 |
commit | 530381d2d506d75c4dd1607bb6f556d17537f911 (patch) | |
tree | 6f3acc541d60024a658f6471f090d065207d8cd8 | |
parent | d0f2bb89f01a26310f1b0a51690c2acb4a72446e (diff) | |
download | util-linux-old-530381d2d506d75c4dd1607bb6f556d17537f911.tar.gz |
lib: use fstat() as fallback in blkdev_get_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | lib/blkdev.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/blkdev.c b/lib/blkdev.c index 824a87c4..aa323f21 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -138,6 +138,15 @@ blkdev_get_size(int fd, unsigned long long *bytes) } #endif /* HAVE_SYS_DISKLABEL_H */ + { + struct stat st; + + if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { + *bytes = st.st_size; + return 0; + } + } + *bytes = blkdev_find_size(fd); return 0; } |