[PATCH 1/2] state: refuse to set dirty parameter via setenv

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 5 23:47:29 PST 2018


The dirty parameter is readonly, so refuse to set it.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/state/state.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/state/state.c b/common/state/state.c
index 6399bd3736..5a1a1af856 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -153,6 +153,11 @@ void state_backend_set_readonly(struct state *state)
 	state_storage_set_readonly(&state->storage);
 }
 
+static int state_set_deny(struct param_d *p, void *priv)
+{
+	return -EROFS;
+}
+
 static struct state *state_new(const char *name)
 {
 	struct state *state;
@@ -172,7 +177,7 @@ static struct state *state_new(const char *name)
 	}
 
 	state->dirty = 1;
-	dev_add_param_bool(&state->dev, "dirty", NULL, NULL, &state->dirty,
+	dev_add_param_bool(&state->dev, "dirty", state_set_deny, NULL, &state->dirty,
 			   NULL);
 	state->save_on_shutdown = 1;
 	dev_add_param_bool(&state->dev, "save_on_shutdown", NULL, NULL,
-- 
2.15.1




More information about the barebox mailing list