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

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