bcachefs-tools/linux/fs_parser.c
Kent Overstreet de51418b60 Update bcachefs sources to bc01863fb6ef bcachefs: bcachefs_metadata_version_disk_accounting_big_endian
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-11-29 21:27:09 -05:00

37 lines
849 B
C

#include <linux/kernel.h>
#include <linux/fs_parser.h>
#include <string.h>
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;
}