summaryrefslogtreecommitdiff
path: root/tools-util.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-02-02 21:45:08 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2017-02-06 23:43:16 -0900
commitd230eaea612b5649a9b84ca1f5bb41455251741e (patch)
treeaefbe80729fb2bed34e0b6e7e63cef323c29b18a /tools-util.c
parent5933f9478cc21e8b319309d2794948050d09b031 (diff)
Add a command to dump filesystem metadata
Diffstat (limited to 'tools-util.c')
-rw-r--r--tools-util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools-util.c b/tools-util.c
index c6e8855..0a95fbe 100644
--- a/tools-util.c
+++ b/tools-util.c
@@ -104,22 +104,23 @@ ssize_t read_string_list_or_die(const char *opt, const char * const list[],
return v;
}
-/* Returns size of file or block device, in units of 512 byte sectors: */
+/* Returns size of file or block device: */
u64 get_size(const char *path, int fd)
{
struct stat statbuf;
+ u64 ret;
+
if (fstat(fd, &statbuf))
die("Error statting %s: %s", path, strerror(errno));
if (!S_ISBLK(statbuf.st_mode))
- return statbuf.st_size >> 9;
+ return statbuf.st_size;
- u64 ret;
if (ioctl(fd, BLKGETSIZE64, &ret))
die("Error getting block device size on %s: %s\n",
path, strerror(errno));
- return ret >> 9;
+ return ret;
}
/* Returns blocksize in units of 512 byte sectors: */