instance, ujail: wire remount / read only option (-o)
authorEtienne CHAMPETIER <champetier.etienne@gmail.com>
Mon, 30 Nov 2015 23:09:23 +0000 (23:09 +0000)
committerJohn Crispin <blogic@openwrt.org>
Fri, 11 Dec 2015 11:03:22 +0000 (12:03 +0100)
Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
service/instance.c
service/instance.h

index c478d4b982bfdf997e8a63526178b1be2bc62d30..26faa9a5e930398c8d78cc16ee2f9c650095cf55 100644 (file)
@@ -81,6 +81,7 @@ enum {
        JAIL_ATTR_SYSFS,
        JAIL_ATTR_UBUS,
        JAIL_ATTR_LOG,
+       JAIL_ATTR_RONLY,
        JAIL_ATTR_MOUNT,
        __JAIL_ATTR_MAX,
 };
@@ -91,6 +92,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 },
 };
 
@@ -198,6 +200,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);
 
@@ -655,6 +660,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;
@@ -943,6 +952,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;
index 5a768418fc5cd38abcabedb808648f1682f6dd87..43844dc11f68b125628a0145d6c289e8caa5a236 100644 (file)
@@ -27,6 +27,7 @@ struct jail {
        bool sysfs;
        bool ubus;
        bool log;
+       bool ronly;
        char *name;
        struct blobmsg_list mount;
        int argc;