summaryrefslogtreecommitdiff
path: root/linux/fs_parser.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-11-29 21:08:00 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-11-29 21:27:09 -0500
commitde51418b60d7bf7d783d0ed112de00a63928c337 (patch)
tree077e848a35906d272a78676389312af7589de97a /linux/fs_parser.c
parent6829fb201072c495ce9e97850664540a0f8294f1 (diff)
Update bcachefs sources to bc01863fb6ef bcachefs: bcachefs_metadata_version_disk_accounting_big_endian
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'linux/fs_parser.c')
-rw-r--r--linux/fs_parser.c36
1 files changed, 36 insertions, 0 deletions
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 <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;
+}