[PATCH 6/6] nv: Allow wildcards when removing NV vars

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With this patch 'nv -r' can also take "*" and "?" wildcards for nv
variables. This makes it easier to remove multiple nv variables.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 common/globalvar.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index a2eaaa0..44e6528 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -10,6 +10,7 @@
 #include <libfile.h>
 #include <generated/utsrelease.h>
 #include <envfs.h>
+#include <fnmatch.h>
 
 static int nv_dirty;
 
@@ -293,22 +294,23 @@ int nvvar_add(const char *name, const char *value)
 
 int nvvar_remove(const char *name)
 {
-	struct param_d *p;
+	struct param_d *p, *tmp;
 	char *fname;
 
 	if (!IS_ENABLED(CONFIG_NVVAR))
 		return -ENOSYS;
 
-	p = get_param_by_name(&nv_device, name);
-	if (!p)
-		return -ENOENT;
+	list_for_each_entry_safe(p, tmp, &nv_device.parameters, list) {
+		if (fnmatch(name, p->name, 0))
+			continue;
 
-	fname = basprintf("/env/nv/%s", p->name);
+		fname = basprintf("/env/nv/%s", p->name);
 
-	dev_remove_param(p);
+		dev_remove_param(p);
 
-	unlink(fname);
-	free(fname);
+		unlink(fname);
+		free(fname);
+	}
 
 	return 0;
 }
-- 
2.8.1


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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux