[OpenWrt-Devel] [PATCH procd 5/9] instance, ujail: wire remount / read only option (-o)

Etienne CHAMPETIER champetier.etienne at gmail.com
Mon Nov 30 18:09:23 EST 2015


Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
---
 service/instance.c | 10 ++++++++++
 service/instance.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/service/instance.c b/service/instance.c
index 0f4e711..586c0ee 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -83,6 +83,7 @@ enum {
 	JAIL_ATTR_SYSFS,
 	JAIL_ATTR_UBUS,
 	JAIL_ATTR_LOG,
+	JAIL_ATTR_RONLY,
 	JAIL_ATTR_MOUNT,
 	__JAIL_ATTR_MAX,
 };
@@ -93,6 +94,7 @@ static const struct blobmsg_policy jail_attr[__JAIL_ATTR_MAX] = {
 	[JAIL_ATTR_SYSFS] = { "sysfs", BLOBMSG_TYPE_BOOL },
 	[JAIL_ATTR_UBUS] = { "ubus", BLOBMSG_TYPE_BOOL },
 	[JAIL_ATTR_LOG] = { "log", BLOBMSG_TYPE_BOOL },
+	[JAIL_ATTR_RONLY] = { "ronly", BLOBMSG_TYPE_BOOL },
 	[JAIL_ATTR_MOUNT] = { "mount", BLOBMSG_TYPE_TABLE },
 };
 
@@ -205,6 +207,9 @@ jail_run(struct service_instance *in, char **argv)
 	if (jail->log)
 		argv[argc++] = "-l";
 
+	if (jail->ronly)
+		argv[argc++] = "-o";
+
 	blobmsg_list_for_each(&jail->mount, var) {
 		const char *type = blobmsg_data(var->data);
 
@@ -662,6 +667,10 @@ instance_jail_parse(struct service_instance *in, struct blob_attr *attr)
 		jail->log = blobmsg_get_bool(tb[JAIL_ATTR_LOG]);
 		jail->argc++;
 	}
+	if (tb[JAIL_ATTR_RONLY]) {
+		jail->ronly = blobmsg_get_bool(tb[JAIL_ATTR_RONLY]);
+		jail->argc++;
+	}
 	if (tb[JAIL_ATTR_MOUNT]) {
 		struct blob_attr *cur;
 		int rem;
@@ -965,6 +974,7 @@ void instance_dump(struct blob_buf *b, struct service_instance *in, int verbose)
 		blobmsg_add_u8(b, "sysfs", in->jail.sysfs);
 		blobmsg_add_u8(b, "ubus", in->jail.ubus);
 		blobmsg_add_u8(b, "log", in->jail.log);
+		blobmsg_add_u8(b, "ronly", in->jail.ronly);
 		blobmsg_close_table(b, r);
 		if (!avl_is_empty(&in->jail.mount.avl)) {
 			struct blobmsg_list_node *var;
diff --git a/service/instance.h b/service/instance.h
index 19f780d..80268af 100644
--- a/service/instance.h
+++ b/service/instance.h
@@ -27,6 +27,7 @@ struct jail {
 	bool sysfs;
 	bool ubus;
 	bool log;
+	bool ronly;
 	char *name;
 	struct blobmsg_list mount;
 	int argc;
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list