From 42be28f77458618c128d32d9273f6eca7f73a971 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 11 Mar 2020 19:11:05 -0700 Subject: fdlength: device size is reported in bytes, not blocks. The shift was a remnant from when BLKGETSIZE (which measures in blocks) was being used on Linux. The Mac has two separate ioctls for block count and block size, which we're already multiplying together. And on Linux we're using BLKGETSIZE64, which returns a result in bytes, not blocks. So lose the shift. --- lib/lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index 2ac5c74c..364ce07e 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -478,7 +478,7 @@ off_t fdlength(int fd) if (!fstat(fd, &st) && S_ISREG(st.st_mode)) return st.st_size; // If the ioctl works for this, return it. - if (get_block_device_size(fd, &size)) return size<<9; + if (get_block_device_size(fd, &size)) return size; // 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 -- cgit v1.2.3