summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_xattr_tdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/modules/vfs_xattr_tdb.c')
-rw-r--r--source3/modules/vfs_xattr_tdb.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 29864a8f94..208066bedc 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -110,7 +110,7 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx,
status = xattr_tdb_pull_attrs(mem_ctx, &data, presult);
TALLOC_FREE(data.dptr);
- return NT_STATUS_OK;
+ return status;
}
/*
@@ -165,6 +165,9 @@ static ssize_t xattr_tdb_getattr(struct db_context *db_ctx,
ssize_t result = -1;
NTSTATUS status;
+ DEBUG(10, ("xattr_tdb_getattr called for file %s, name %s\n",
+ file_id_string_tos(id), name));
+
status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs);
if (!NT_STATUS_IS_OK(status)) {
@@ -250,6 +253,9 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
struct tdb_xattrs *attribs;
uint32_t i;
+ DEBUG(10, ("xattr_tdb_setattr called for file %s, name %s\n",
+ file_id_string_tos(id), name));
+
rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id);
if (rec == NULL) {
@@ -269,6 +275,11 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
for (i=0; i<attribs->num_xattrs; i++) {
if (strcmp(attribs->xattrs[i].name, name) == 0) {
+ if (flags & XATTR_CREATE) {
+ TALLOC_FREE(rec);
+ errno = EEXIST;
+ return -1;
+ }
break;
}
}
@@ -276,6 +287,12 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
if (i == attribs->num_xattrs) {
struct tdb_xattr *tmp;
+ if (flags & XATTR_REPLACE) {
+ TALLOC_FREE(rec);
+ errno = ENOATTR;
+ return -1;
+ }
+
tmp = TALLOC_REALLOC_ARRAY(
attribs, attribs->xattrs, struct tdb_xattr,
attribs->num_xattrs + 1);
@@ -558,7 +575,8 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db)
struct db_context *db;
const char *dbname;
- dbname = lp_parm_const_string(snum, "ea", "tdb", lock_path("eas.tdb"));
+ dbname = lp_parm_const_string(snum, "xattr", "tdb",
+ lock_path("xattr.tdb"));
if (dbname == NULL) {
errno = ENOTSUP;
@@ -660,7 +678,7 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
* Destructor for the VFS private data
*/
-static void close_ea_db(void **data)
+static void close_xattr_db(void **data)
{
struct db_context **p_db = (struct db_context **)data;
TALLOC_FREE(*p_db);
@@ -688,14 +706,14 @@ static int xattr_tdb_connect(vfs_handle_struct *handle, const char *service,
}
if (!xattr_tdb_init(snum, &db)) {
- DEBUG(5, ("Could not init ea tdb\n"));
+ DEBUG(5, ("Could not init xattr tdb\n"));
lp_do_parameter(snum, "ea support", "False");
return 0;
}
lp_do_parameter(snum, "ea support", "True");
- SMB_VFS_HANDLE_SET_DATA(handle, db, close_ea_db,
+ SMB_VFS_HANDLE_SET_DATA(handle, db, close_xattr_db,
struct db_context, return -1);
return 0;