From de51418b60d7bf7d783d0ed112de00a63928c337 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 29 Nov 2024 21:08:00 -0500 Subject: Update bcachefs sources to bc01863fb6ef bcachefs: bcachefs_metadata_version_disk_accounting_big_endian Signed-off-by: Kent Overstreet --- linux/fs_parser.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 linux/fs_parser.c (limited to 'linux/fs_parser.c') diff --git a/linux/fs_parser.c b/linux/fs_parser.c new file mode 100644 index 00000000..b1cd0c72 --- /dev/null +++ b/linux/fs_parser.c @@ -0,0 +1,36 @@ + +#include +#include +#include + +const struct constant_table bool_names[] = { + { "0", false }, + { "1", true }, + { "false", false }, + { "no", false }, + { "true", true }, + { "yes", true }, + { }, +}; + +static const struct constant_table * +__lookup_constant(const struct constant_table *tbl, const char *name) +{ + for ( ; tbl->name; tbl++) + if (strcmp(name, tbl->name) == 0) + return tbl; + return NULL; +} + +/** + * lookup_constant - Look up a constant by name in an ordered table + * @tbl: The table of constants to search. + * @name: The name to look up. + * @not_found: The value to return if the name is not found. + */ +int lookup_constant(const struct constant_table *tbl, const char *name, int not_found) +{ + const struct constant_table *p = __lookup_constant(tbl, name); + + return p ? p->value : not_found; +} -- cgit v1.2.3