diff options
author | Elliott Hughes <enh@google.com> | 2020-03-11 19:11:05 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-03-11 21:50:25 -0500 |
commit | 42be28f77458618c128d32d9273f6eca7f73a971 (patch) | |
tree | 9f21ea1ce1769f3a8aef5f9fc7709234add2b052 /lib | |
parent | 8a68f6dd4021986e10760a3a36d453809ac4be36 (diff) | |
download | toybox-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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |