summaryrefslogtreecommitdiff
path: root/include/linux/string_helpers.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-08-07 21:52:47 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-07-11 21:20:25 -0400
commit3eadfb81c186d8834c4db82bfa8730b5f2fd3f85 (patch)
treefa9f10d53452b7e4e864f884e09a4b938d1ba505 /include/linux/string_helpers.h
parente4b3e16f93817cee30bc4f6a1c396bbde6c50cab (diff)
lib/string_helpers: Add flags param to string_get_size()
The new flags parameter allows controlling - Whether or not the units suffix is separated by a space, for compatibility with sort -h - Whether or not to append a B suffix - we're not always printing bytes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Signed-off-by: Suren Baghdasaryan <surenb@google.com> Cc: Andy Shevchenko <andy@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Cc: "Noralf Trønnes" <noralf@tronnes.org> Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/string_helpers.h')
-rw-r--r--include/linux/string_helpers.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 44148f8febb9..ae51580b9aab 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -16,14 +16,13 @@ static inline bool string_is_terminated(const char *s, int len)
return memchr(s, '\0', len) ? true : false;
}
-/* Descriptions of the types of units to
- * print in */
-enum string_size_units {
- STRING_UNITS_10, /* use powers of 10^3 (standard SI) */
- STRING_UNITS_2, /* use binary powers of 2^10 */
+enum string_size_flags {
+ STRING_SIZE_BASE2 = (1 << 0),
+ STRING_SIZE_NOSPACE = (1 << 1),
+ STRING_SIZE_NOBYTES = (1 << 2),
};
-int string_get_size(u64 size, u64 blk_size, enum string_size_units units,
+int string_get_size(u64 size, u64 blk_size, enum string_size_flags flags,
char *buf, int len);
int parse_int_array_user(const char __user *from, size_t count, int **array);