mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-22 00:04:31 +03:00
de51418b60
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
37 lines
849 B
C
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;
|
|
}
|