From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 6/6] nv: Allow wildcards when removing NV vars
Date: Fri, 22 Jul 2016 12:39:19 +0200 [thread overview]
Message-ID: <1469183959-9002-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1469183959-9002-1-git-send-email-s.hauer@pengutronix.de>
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@pengutronix.de>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2016-07-22 10:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 10:39 nv variable changes Sascha Hauer
2016-07-22 10:39 ` [PATCH 1/6] nv: Do not save nv variables while loading Sascha Hauer
2016-07-22 10:39 ` [PATCH 2/6] nv: Save nv variables on shutdown Sascha Hauer
2016-07-22 10:39 ` [PATCH 3/6] nv: Add option to explicitly save nv variables Sascha Hauer
2016-07-22 10:39 ` [PATCH 4/6] nv: Allow to set/remove multiple variables with one command Sascha Hauer
2016-07-22 10:39 ` [PATCH 5/6] nv: Use dev_remove_param to delete nv variable Sascha Hauer
2016-07-22 10:39 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469183959-9002-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox