summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2017-06-01 12:37:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-01 14:19:50 +0200
commit7bcbc91a5eb2c3fbb3a6d67103ca0ff8fc8e4412 (patch)
treecfd0b7a770a0c0df2fd0ed23abe93302e63ab493
parent53f063f88db5ea9c60201953ed51807d2ff5903d (diff)
downloadbarebox-7bcbc91a5eb2c3fbb3a6d67103ca0ff8fc8e4412.tar.gz
fs: add parseopt_b for loop mount option
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--fs/parseopt.c26
-rw-r--r--fs/parseopt.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/parseopt.c b/fs/parseopt.c
index 12dbe18..8ff8301 100644
--- a/fs/parseopt.c
+++ b/fs/parseopt.c
@@ -2,6 +2,32 @@
#include "parseopt.h"
+void parseopt_b(const char *options, const char *opt, bool *val)
+{
+ const char *start;
+ size_t optlen = strlen(opt);
+
+again:
+ start = strstr(options, opt);
+
+ if (!start) {
+ *val = false;
+ return;
+ }
+
+ if (start > options && start[-1] != ',') {
+ options = start;
+ goto again;
+ }
+
+ if (start[optlen] != ',' && start[optlen] != '\0') {
+ options = start;
+ goto again;
+ }
+
+ *val = true;
+}
+
void parseopt_hu(const char *options, const char *opt, unsigned short *val)
{
const char *start;
diff --git a/fs/parseopt.h b/fs/parseopt.h
index a8523b6..abf3be3 100644
--- a/fs/parseopt.h
+++ b/fs/parseopt.h
@@ -1 +1,2 @@
+void parseopt_b(const char *options, const char *opt, bool *val);
void parseopt_hu(const char *options, const char *opt, unsigned short *val);