]> xenbits.xensource.com Git - xen.git/commitdiff
libflask: Add boolean manipulation functions
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 2 Feb 2012 15:24:13 +0000 (15:24 +0000)
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 2 Feb 2012 15:24:13 +0000 (15:24 +0000)
Add wrappers for getting and setting policy booleans by name or ID.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
tools/flask/libflask/flask_op.c
tools/flask/libflask/include/libflask.h

index d4b8ef01f59ab9dd85ddd5d2cdd1811dab5fb46f..412a05d7c5390280f908434fd6245cd191b8b792 100644 (file)
@@ -109,6 +109,65 @@ int flask_setenforce(xc_interface *xc_handle, int mode)
     return 0;
 }
 
+int flask_getbool_byid(xc_interface *xc_handle, int id, char *name, int *curr, int *pend)
+{
+    flask_op_t op;
+    char buf[255];
+    int rv;
+
+    op.cmd = FLASK_GETBOOL2;
+    op.buf = buf;
+    op.size = 255;
+
+    snprintf(buf, sizeof buf, "%i", id);
+
+    rv = xc_flask_op(xc_handle, &op);
+
+    if ( rv )
+        return rv;
+    
+    sscanf(buf, "%i %i %s", curr, pend, name);
+
+    return rv;
+}
+
+int flask_getbool_byname(xc_interface *xc_handle, char *name, int *curr, int *pend)
+{
+    flask_op_t op;
+    char buf[255];
+    int rv;
+
+    op.cmd = FLASK_GETBOOL_NAMED;
+    op.buf = buf;
+    op.size = 255;
+
+    strncpy(buf, name, op.size);
+
+    rv = xc_flask_op(xc_handle, &op);
+
+    if ( rv )
+        return rv;
+    
+    sscanf(buf, "%i %i", curr, pend);
+
+    return rv;
+}
+
+int flask_setbool(xc_interface *xc_handle, char *name, int value, int commit)
+{
+    flask_op_t op;
+    char buf[255];
+    int size = 255;
+
+    op.cmd = FLASK_SETBOOL_NAMED;
+    op.buf = buf;
+    op.size = size;
+
+    snprintf(buf, size, "%s %i %i", name, value, commit);
+
+    return xc_flask_op(xc_handle, &op);
+}
+
 int flask_add_pirq(xc_interface *xc_handle, unsigned int pirq, char *scontext)
 {
     int err;
index e4c34b8746b3807ea8ceecb63aaa8dbf14d1ee3f..b8a6ca934ea47c15c4c70940cd19adc535d42670 100644 (file)
@@ -21,6 +21,9 @@ int flask_context_to_sid(xc_interface *xc_handle, char *buf, uint32_t size, uint
 int flask_sid_to_context(xc_interface *xc_handle, int sid, char *buf, uint32_t size);
 int flask_getenforce(xc_interface *xc_handle);
 int flask_setenforce(xc_interface *xc_handle, int mode);
+int flask_getbool_byid(xc_interface *xc_handle, int id, char *name, int *curr, int *pend);
+int flask_getbool_byname(xc_interface *xc_handle, char *name, int *curr, int *pend);
+int flask_setbool(xc_interface *xc_handle, char *name, int value, int commit);
 int flask_add_pirq(xc_interface *xc_handle, unsigned int pirq, char *scontext);
 int flask_add_ioport(xc_interface *xc_handle, unsigned long low, unsigned long high,
                       char *scontext);