aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-03-11 19:11:05 -0700
committerRob Landley <rob@landley.net>2020-03-11 21:50:25 -0500
commit42be28f77458618c128d32d9273f6eca7f73a971 (patch)
tree9f21ea1ce1769f3a8aef5f9fc7709234add2b052
parent8a68f6dd4021986e10760a3a36d453809ac4be36 (diff)
downloadtoybox-42be28f77458618c128d32d9273f6eca7f73a971.tar.gz
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.
-rw-r--r--lib/lib.c2
1 files changed, 1 insertions, 1 deletions
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