summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-12-20 16:32:22 +0100
committerJose M. Guisado <jguisado@soleta.eu>2022-12-20 16:32:22 +0100
commit99a98f92365f28c8e0050fc406dc3cdb0beac236 (patch)
treee109db5738613922aa5b7043322e074a0d45fb0a
parent74784533592823753eb13376757059f85e2237f6 (diff)
context: add readonly optional param to assign_device
assign_device with readonly set to false by default to keep consistency with Context object constructor.
-rw-r--r--context.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/context.c b/context.c
index 805a2b7..0248bb3 100644
--- a/context.c
+++ b/context.c
@@ -78,23 +78,23 @@ static int Context_init(ContextObject *self, PyObject *args, PyObject *kwds)
return 0;
}
-#define Context_assign_device_HELP "assign_device(device)\n\n" \
+#define Context_assign_device_HELP "assign_device(device, readonly=False)\n\n" \
"Open the device, discovery topology, geometry, detect disklabel " \
"and switch the current label driver to reflect the probing result. "
static PyObject *Context_assign_device(ContextObject *self, PyObject *args, PyObject *kwds)
{
+ static char *kwlist[] = { "readonly", NULL };
+ int readonly = 0;
char *fname;
- if (!PyArg_ParseTuple(args, "s", &fname)) {
+ if (!PyArg_ParseTupleAndKeywords(args,
+ kwds, "s|p", kwlist,
+ &readonly)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return NULL;
}
- /* Assert self->cxt */
-
- /* XXX: readonly */
- fdisk_assign_device(self->cxt, fname, 1);
-
+ fdisk_assign_device(self->cxt, fname, readonly);
fdisk_get_partitions(self->cxt, &self->tb);
Py_INCREF(Py_None);