s4-ntvfs: Rename xattr_tdb.c to posix_eadb.c and make more generally useful
[kai/samba.git] / source4 / ntvfs / posix / python / pyxattr_tdb.c
index 34b449f70f1403ef44c934d635c22bac3a5f3d39..d1be87951498b9a302082b1de4336de2e02a4be7 100644 (file)
 
 #include <Python.h>
 #include "includes.h"
-#include <tdb.h>
-#include "lib/util/tdb_wrap.h"
+#include "system/filesys.h"
+#include "tdb_compat.h"
+#include "lib/tdb_wrap/tdb_wrap.h"
 #include "librpc/ndr/libndr.h"
 #include "lib/util/wrap_xattr.h"
-#include "ntvfs/posix/vfs_posix.h"
+#include "ntvfs/posix/posix_eadb.h"
 #include "libcli/util/pyerrors.h"
+#include "param/pyparam.h"
 
 void initxattr_tdb(void);
 
@@ -50,17 +52,18 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
        blob.length = blobsize;
        mem_ctx = talloc_new(NULL);
        eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
-                               TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                            TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                            py_default_loadparm_context(mem_ctx));
 
        if (eadb == NULL) {
                PyErr_SetFromErrno(PyExc_IOError);
                talloc_free(mem_ctx);
                return NULL;
        }
-       status = push_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, -1,
-                                                                        &blob);
+       status = push_xattr_blob_tdb_raw(eadb, attribute, filename, -1,
+                                        &blob);
        if (!NT_STATUS_IS_OK(status)) {
-               PyErr_FromNTSTATUS(status);
+               PyErr_SetNTSTATUS(status);
                talloc_free(mem_ctx);
                return NULL;
        }
@@ -82,7 +85,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 
        mem_ctx = talloc_new(NULL);
        eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
-                               TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                            TDB_DEFAULT, O_RDWR|O_CREAT, 0600, py_default_loadparm_context(mem_ctx));
        if (eadb == NULL) {
                PyErr_SetFromErrno(PyExc_IOError);
                talloc_free(mem_ctx);
@@ -90,8 +93,8 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
        }
        status = pull_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, 
                                                                         -1, 100, &blob);
-       if (!NT_STATUS_IS_OK(status) || blob.length < 0) {
-               PyErr_FromNTSTATUS(status);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
                talloc_free(mem_ctx);
                return NULL;
        }