diff mbox

[2/5] nvram: add nvram_query_eq()

Message ID 1476424893-7292-3-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Oct. 14, 2016, 6:01 a.m. UTC
From: Oliver O'Halloran <oohall@gmail.com>

Adds a helper that looks for the given NVRAM config string and checks
that associated value is equal to the supplied value.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 core/nvram-format.c | 11 +++++++++++
 include/nvram.h     |  1 +
 2 files changed, 12 insertions(+)
diff mbox

Patch

diff --git a/core/nvram-format.c b/core/nvram-format.c
index b98aee1430ff..b110d804ffb7 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -262,3 +262,14 @@  const char *nvram_query(const char *key)
 
 	return NULL;
 }
+
+
+bool nvram_query_eq(const char *key, const char *value)
+{
+	const char *s = nvram_query(key);
+
+	if (!s)
+		return false;
+
+	return !strcmp(s, value);
+}
diff --git a/include/nvram.h b/include/nvram.h
index d87561d79397..288b536827b5 100644
--- a/include/nvram.h
+++ b/include/nvram.h
@@ -23,5 +23,6 @@  void nvram_reinit(void);
 bool nvram_validate(void);
 
 const char *nvram_query(const char *name);
+bool nvram_query_eq(const char *key, const char *value);
 
 #endif /* __NVRAM_H */