summaryrefslogtreecommitdiff
path: root/_obnammodule.c
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-12-02 21:38:35 +0000
committerLars Wirzenius <liw@liw.fi>2011-12-02 21:38:35 +0000
commit4a390d5cb91f97e21de95018a28b39d84a5cf647 (patch)
tree9d8b951a95a0c27f20d63036be67b56c2d87e758 /_obnammodule.c
parent3dd22f263375a4d7c4f700842e8fe4cbf2d887d6 (diff)
downloadobnam-4a390d5cb91f97e21de95018a28b39d84a5cf647.tar.gz
add llistxattr system call wrapper
Diffstat (limited to '_obnammodule.c')
-rw-r--r--_obnammodule.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/_obnammodule.c b/_obnammodule.c
index 3bd00818..1515fef9 100644
--- a/_obnammodule.c
+++ b/_obnammodule.c
@@ -43,7 +43,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <attr/xattr.h>
#include <unistd.h>
+#include <stdlib.h>
static PyObject *
@@ -123,6 +125,48 @@ lstat_wrapper(PyObject *self, PyObject *args)
}
+static PyObject *
+llistxattr_wrapper(PyObject *self, PyObject *args)
+{
+ const char *filename;
+ size_t bufsize;
+ PyObject *o;
+
+ if (!PyArg_ParseTuple(args, "s", &filename))
+ return NULL;
+
+ bufsize = 0;
+ o = NULL;
+ do {
+ bufsize += 1024;
+ char *buf = malloc(bufsize);
+ ssize_t n = llistxattr(filename, buf, bufsize);
+
+ if (n >= 0)
+ o = Py_BuildValue("s#", buf, (int) n);
+ else if (n == -1 && errno != ERANGE)
+ o = Py_BuildValue("i", errno);
+ free(buf);
+ } while (o == NULL);
+
+ return o;
+}
+
+
+static PyObject *
+lgetxattr_wrapper(PyObject *self, PyObject *args)
+{
+ return NULL;
+}
+
+
+static PyObject *
+lsetxattr_wrapper(PyObject *self, PyObject *args)
+{
+ return NULL;
+}
+
+
static PyMethodDef methods[] = {
{"fadvise_dontneed", fadvise_dontneed, METH_VARARGS,
"Call posix_fadvise(2) with POSIX_FADV_DONTNEED argument."},
@@ -130,6 +174,12 @@ static PyMethodDef methods[] = {
"lutimes(2) wrapper; args are filename, atime, and mtime."},
{"lstat", lstat_wrapper, METH_VARARGS,
"lstat(2) wrapper; arg is filename, returns tuple."},
+ {"llistxattr", llistxattr_wrapper, METH_VARARGS,
+ "llistxattr(2) wrapper; arg is filename, returns tuple."},
+ {"lgetxattrs", lgetxattr_wrapper, METH_VARARGS,
+ "lgetxattr(2) wrapper; arg is filename, returns tuple."},
+ {"lsetxattrs", lsetxattr_wrapper, METH_VARARGS,
+ "lsetxattr(2) wrapper; arg is filename, returns errno."},
{NULL, NULL, 0, NULL} /* Sentinel */
};