diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-28 16:47:44 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-01-01 21:14:22 -0500 |
commit | 9cc3b7debbe27955d480f35f0d7aa8a97c51c3af (patch) | |
tree | de7515857db1bd2db4b9c3a32022bfaf15f1fb01 /tools-util.c | |
parent | 38f8daa2b17627488c51f2e0c150213bd1636e00 (diff) |
Unit handling cleanups
The option code has been switching to keeping things in display units -
bytes - and this transitions more libbcachefs.c code to bytes as well,
to match, and also fixes device add.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'tools-util.c')
-rw-r--r-- | tools-util.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/tools-util.c b/tools-util.c index 98cb3503..9491779b 100644 --- a/tools-util.c +++ b/tools-util.c @@ -94,12 +94,12 @@ void xpread(int fd, void *buf, size_t count, off_t offset) } } -void xpwrite(int fd, const void *buf, size_t count, off_t offset) +void xpwrite(int fd, const void *buf, size_t count, off_t offset, const char *msg) { ssize_t r = pwrite(fd, buf, count, offset); if (r != count) - die("write error (ret %zi err %m)", r); + die("error writing %s (ret %zi err %m)", msg, r); } struct stat xfstatat(int dirfd, const char *path, int flags) @@ -242,7 +242,7 @@ u64 get_size(const char *path, int fd) return ret; } -/* Returns blocksize in units of 512 byte sectors: */ +/* Returns blocksize, in bytes: */ unsigned get_blocksize(const char *path, int fd) { struct stat statbuf = xfstat(fd); @@ -403,24 +403,6 @@ char *strcmp_prefix(char *a, const char *a_prefix) return *a_prefix ? NULL : a; } -unsigned hatoi_validate(const char *s, const char *msg) -{ - u64 v; - - if (bch2_strtoull_h(s, &v)) - die("bad %s %s", msg, s); - - v /= 512; - - if (v > USHRT_MAX) - die("%s too large\n", msg); - - if (!v) - die("%s too small\n", msg); - - return v; -} - /* crc32c */ static u32 crc32c_default(u32 crc, const void *buf, size_t size) |