summaryrefslogtreecommitdiffstats
path: root/libmount/python/tab.c
diff options
context:
space:
mode:
authorKarel Zak2013-08-22 12:10:13 +0200
committerKarel Zak2013-08-22 12:10:13 +0200
commitb7e47ac1ac3f2d17536e8864db9c8bdada340b87 (patch)
tree0c881eeba9c54a1d1b5eccd0dc3376dd9fe0bd61 /libmount/python/tab.c
parentlibmount: cleanup libmnt_fs list after mnt_table_remove_fs() (diff)
downloadkernel-qcow2-util-linux-b7e47ac1ac3f2d17536e8864db9c8bdada340b87.tar.gz
kernel-qcow2-util-linux-b7e47ac1ac3f2d17536e8864db9c8bdada340b87.tar.xz
kernel-qcow2-util-linux-b7e47ac1ac3f2d17536e8864db9c8bdada340b87.zip
pylibmount: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/python/tab.c')
-rw-r--r--libmount/python/tab.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libmount/python/tab.c b/libmount/python/tab.c
index 480203cb4..817643cf8 100644
--- a/libmount/python/tab.c
+++ b/libmount/python/tab.c
@@ -546,19 +546,27 @@ void Table_unref(struct libmnt_table *tab)
if (!tab)
return;
+ DBG(TAB, pymnt_debug_h(tab, "un-referencing filesystems"));
+
iter = mnt_new_iter(MNT_ITER_BACKWARD);
/* remove pylibmount specific references to the entries */
while (mnt_table_next_fs(tab, iter, &fs) == 0)
Py_XDECREF(mnt_fs_get_userdata(fs));
+ DBG(TAB, pymnt_debug_h(tab, "un-referencing table"));
+
mnt_unref_table(tab);
mnt_free_iter(iter);
}
static void Table_destructor(TableObject *self)
{
+ DBG(TAB, pymnt_debug_h(self->tab, "destrutor py-obj: %p, py-refcnt=%d",
+ self, (int) ((PyObject *) self)->ob_refcnt));
Table_unref(self->tab);
+ self->tab = NULL;
+
mnt_free_iter(self->iter);
Py_XDECREF(self->errcb);
self->ob_type->tp_free((PyObject*)self);
@@ -571,6 +579,8 @@ static PyObject *Table_new(PyTypeObject *type,
TableObject *self = (TableObject*)type->tp_alloc(type, 0);
if (self) {
+ DBG(TAB, pymnt_debug_h(self, "new"));
+
self->tab = NULL;
self->iter = NULL;
self->errcb = NULL;
@@ -588,12 +598,15 @@ static int Table_init(TableObject *self, PyObject *args, PyObject *kwds)
char *kwlist[] = {"path", "errcb", NULL};
PyObject *errcb = NULL;
struct stat buf;
+
memset (&buf, 0, sizeof(struct stat));
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sO",
kwlist, &path, &errcb))
return -1;
+ DBG(TAB, pymnt_debug_h(self, "init"));
+
Table_unref(self->tab);
self->tab = NULL;
@@ -615,6 +628,8 @@ static int Table_init(TableObject *self, PyObject *args, PyObject *kwds)
}
if (path) {
+ DBG(TAB, pymnt_debug_h(self, "init: path defined (%s)", path));
+
if (stat(path, &buf)) {
/* TODO: weird */
PyErr_SetFromErrno(PyExc_RuntimeError);
@@ -624,8 +639,10 @@ static int Table_init(TableObject *self, PyObject *args, PyObject *kwds)
self->tab = mnt_new_table_from_file(path);
else if (S_ISDIR(buf.st_mode))
self->tab = mnt_new_table_from_dir(path);
- } else
+ } else {
+ DBG(TAB, pymnt_debug_h(self, "init: allocate empty table"));
self->tab = mnt_new_table();
+ }
/* Always set custom handler when using libmount from python */
mnt_table_set_parser_errcb(self->tab, pymnt_table_parser_errcb);
@@ -679,6 +696,8 @@ PyObject *PyObjectResultTab(struct libmnt_table *tab)
result = mnt_table_get_userdata(tab);
if (result) {
Py_INCREF(result);
+ DBG(TAB, pymnt_debug_h(tab, "result py-obj %p: already exists, py-refcnt=%d",
+ result, (int) ((PyObject *) result)->ob_refcnt));
return (PyObject *) result;
}
@@ -694,6 +713,9 @@ PyObject *PyObjectResultTab(struct libmnt_table *tab)
Py_INCREF(result);
mnt_ref_table(tab);
+
+ DBG(TAB, pymnt_debug_h(tab, "result py-obj %p new, py-refcnt=%d",
+ result, (int) ((PyObject *) result)->ob_refcnt));
result->tab = tab;
result->iter = mnt_new_iter(MNT_ITER_FORWARD);
mnt_table_set_userdata(result->tab, result);
@@ -767,6 +789,8 @@ void Table_AddModuleObject(PyObject *mod)
if (PyType_Ready(&TableType) < 0)
return;
+ DBG(TAB, pymnt_debug("add to module"));
+
Py_INCREF(&TableType);
PyModule_AddObject(mod, "Table", (PyObject *)&TableType);
}