mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] fs: add parseopt_b for loop mount option
@ 2017-06-01  9:36 Philipp Zabel
  2017-06-01  9:36 ` [PATCH v2 2/3] fs: add cdev_create_from_file " Philipp Zabel
  2017-06-01  9:36 ` [PATCH v2 3/3] commands: mount: mention file loop mounts in the help text Philipp Zabel
  0 siblings, 2 replies; 3+ messages in thread
From: Philipp Zabel @ 2017-06-01  9:36 UTC (permalink / raw)
  To: barebox

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
No changes since v1.
---
 fs/parseopt.c | 26 ++++++++++++++++++++++++++
 fs/parseopt.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/fs/parseopt.c b/fs/parseopt.c
index 12dbe1813c..8ff83019a7 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 a8523b6a10..abf3be3f35 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);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-01  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01  9:36 [PATCH v2 1/3] fs: add parseopt_b for loop mount option Philipp Zabel
2017-06-01  9:36 ` [PATCH v2 2/3] fs: add cdev_create_from_file " Philipp Zabel
2017-06-01  9:36 ` [PATCH v2 3/3] commands: mount: mention file loop mounts in the help text Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox