Blame SOURCES/0222-report-wrap-more-dump-dir-functions.patch

4b6aa8
From 7b74a0c3f22933da64394972e43bbed4c4fb1b35 Mon Sep 17 00:00:00 2001
4b6aa8
From: Jakub Filak <jfilak@redhat.com>
4b6aa8
Date: Mon, 8 Jun 2015 19:56:41 +0200
4b6aa8
Subject: [PATCH] report: wrap more dump dir functions
4b6aa8
4b6aa8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
4b6aa8
---
4b6aa8
 src/report-python/dump_dir.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
4b6aa8
 1 file changed, 57 insertions(+)
4b6aa8
4b6aa8
diff --git a/src/report-python/dump_dir.c b/src/report-python/dump_dir.c
4b6aa8
index f087563..b4a1e88 100644
4b6aa8
--- a/src/report-python/dump_dir.c
4b6aa8
+++ b/src/report-python/dump_dir.c
4b6aa8
@@ -77,6 +77,42 @@ static PyObject *p_dd_delete(PyObject *pself, PyObject *args)
4b6aa8
     Py_RETURN_NONE;
4b6aa8
 }
4b6aa8
 
4b6aa8
+/* void dd_rename(struct dump_dir *dd, const char *new_name); */
4b6aa8
+static PyObject *p_dd_rename(PyObject *pself, PyObject *args)
4b6aa8
+{
4b6aa8
+    p_dump_dir *self = (p_dump_dir*)pself;
4b6aa8
+    if (!self->dd)
4b6aa8
+    {
4b6aa8
+        PyErr_SetString(ReportError, "dump dir is not open");
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    const char *new_name;
4b6aa8
+    if (!PyArg_ParseTuple(args, "s", &new_name))
4b6aa8
+    {
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    return Py_BuildValue("i", dd_rename(self->dd, new_name));
4b6aa8
+}
4b6aa8
+
4b6aa8
+/* void dd_create_basic_files(struct dump_dir *dd, uid_t uid, const char *chroot_dir); */
4b6aa8
+static PyObject *p_dd_create_basic_files(PyObject *pself, PyObject *args)
4b6aa8
+{
4b6aa8
+    p_dump_dir *self = (p_dump_dir*)pself;
4b6aa8
+    if (!self->dd)
4b6aa8
+    {
4b6aa8
+        PyErr_SetString(ReportError, "dump dir is not open");
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    uid_t uid;
4b6aa8
+    const char *chroot_dir = NULL;
4b6aa8
+    if (!PyArg_ParseTuple(args, "i|z", &uid, &chroot_dir))
4b6aa8
+    {
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    dd_create_basic_files(self->dd, uid, chroot_dir);
4b6aa8
+    Py_RETURN_NONE;
4b6aa8
+}
4b6aa8
+
4b6aa8
 /* int dd_exist(struct dump_dir *dd, const char *path); */
4b6aa8
 static PyObject *p_dd_exist(PyObject *pself, PyObject *args)
4b6aa8
 {
4b6aa8
@@ -160,6 +196,24 @@ static PyObject *p_dd_save_binary(PyObject *pself, PyObject *args)
4b6aa8
     Py_RETURN_NONE;
4b6aa8
 }
4b6aa8
 
4b6aa8
+/* void dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path); */
4b6aa8
+static PyObject *p_dd_copy_file(PyObject *pself, PyObject *args)
4b6aa8
+{
4b6aa8
+    p_dump_dir *self = (p_dump_dir*)pself;
4b6aa8
+    if (!self->dd)
4b6aa8
+    {
4b6aa8
+        PyErr_SetString(ReportError, "dump dir is not open");
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    const char *name;
4b6aa8
+    const char *source_path;
4b6aa8
+    if (!PyArg_ParseTuple(args, "ss", &name, &source_path))
4b6aa8
+    {
4b6aa8
+        return NULL;
4b6aa8
+    }
4b6aa8
+    return Py_BuildValue("i", dd_copy_file(self->dd, name, source_path));
4b6aa8
+}
4b6aa8
+
4b6aa8
 /* int dd_delete_item(struct dump_dir *dd, const char *name); */
4b6aa8
 static PyObject *p_dd_delete_item(PyObject *pself, PyObject *args)
4b6aa8
 {
4b6aa8
@@ -200,10 +254,13 @@ static PyMethodDef p_dump_dir_methods[] = {
4b6aa8
     /* method_name, func, flags, doc_string */
4b6aa8
     { "close"      , p_dd_close, METH_NOARGS, NULL },
4b6aa8
     { "delete"     , p_dd_delete, METH_NOARGS, NULL },
4b6aa8
+    { "rename"     , p_dd_rename, METH_VARARGS, NULL },
4b6aa8
+    { "create_basic_files", p_dd_create_basic_files, METH_VARARGS, NULL },
4b6aa8
     { "exist"      , p_dd_exist, METH_VARARGS, NULL },
4b6aa8
     { "load_text"  , p_dd_load_text, METH_VARARGS, NULL },
4b6aa8
     { "save_text"  , p_dd_save_text, METH_VARARGS, NULL },
4b6aa8
     { "save_binary", p_dd_save_binary, METH_VARARGS, NULL },
4b6aa8
+    { "copy_file"  , p_dd_copy_file, METH_VARARGS, NULL },
4b6aa8
     { "delete_item", p_dd_delete_item, METH_VARARGS, NULL },
4b6aa8
     { NULL }
4b6aa8
 };
4b6aa8
-- 
4b6aa8
1.8.3.1
4b6aa8