changeset 794:14dbffbeb60c

objstore: use passed in owner/group information for file creation Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 02 Apr 2020 14:46:29 -0400
parents 55b8061a7cf9
children b842f65a6a06
files src/client/cmd_dir.c src/objstore/include/nomad/objstore.h src/objstore/obj_dir_create.c src/objstore/obj_ops.c src/objstore/objstore_impl.h
diffstat 5 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/client/cmd_dir.c	Thu Apr 02 14:45:21 2020 -0400
+++ b/src/client/cmd_dir.c	Thu Apr 02 14:46:29 2020 -0400
@@ -36,7 +36,8 @@
 	if (!oh)
 		return -EINVAL;
 
-	return objstore_create(oh->cookie, req->path, req->mode, &res->oid);
+	return objstore_create(oh->cookie, req->path, req->owner, req->group,
+			       req->mode, &res->oid);
 }
 
 int cmd_lookup(struct fsconn *conn, union cmd *cmd)
--- a/src/objstore/include/nomad/objstore.h	Thu Apr 02 14:45:21 2020 -0400
+++ b/src/objstore/include/nomad/objstore.h	Thu Apr 02 14:46:29 2020 -0400
@@ -162,7 +162,8 @@
 				   const char *name, struct noid **child,
 				   uint8_t **type);
 extern int objstore_create(struct objstore_open_obj_info *dircookie,
-			   const char *name, uint16_t mode, struct noid *child);
+			   const char *name, uint32_t owner, uint32_t group,
+			   uint16_t mode, struct noid *child);
 extern int objstore_unlink(struct objstore_open_obj_info *dircookie,
 			   const char *name, const struct noid *desired);
 extern int objstore_getdent(struct objstore_open_obj_info *dircookie,
--- a/src/objstore/obj_dir_create.c	Thu Apr 02 14:45:21 2020 -0400
+++ b/src/objstore/obj_dir_create.c	Thu Apr 02 14:46:29 2020 -0400
@@ -25,8 +25,8 @@
 #include <jeffpc/time.h>
 
 /* allocate a new oid - the child */
-static int __dir_create_allocoid(struct txn *txn, uint16_t mode,
-				 struct noid *oid)
+static int __dir_create_allocoid(struct txn *txn, uint32_t owner, uint32_t group,
+				 uint16_t mode, struct noid *oid)
 {
 	const uint64_t now = gettime();
 	struct nattr attrs = {
@@ -37,8 +37,8 @@
 		.btime = now,
 		.ctime = now,
 		.mtime = now,
-		.owner = 0,
-		.group = 0,
+		.owner = owner,
+		.group = group,
 	};
 
 	return obj_create(txn, &attrs, oid);
@@ -218,7 +218,7 @@
 }
 
 int dir_create(struct txn *txn, struct objver *dirver, const char *name,
-	       uint16_t mode, struct noid *child)
+	       uint32_t owner, uint32_t group, uint16_t mode, struct noid *child)
 {
 	uint8_t raw[DIR_BLOCK_SIZE];
 	struct ndirent_mem ent;
@@ -245,7 +245,7 @@
 	}
 
 	/* make new oid for the child */
-	ret = __dir_create_allocoid(txn, mode, child);
+	ret = __dir_create_allocoid(txn, owner, group, mode, child);
 	if (ret)
 		return ret;
 
--- a/src/objstore/obj_ops.c	Thu Apr 02 14:45:21 2020 -0400
+++ b/src/objstore/obj_ops.c	Thu Apr 02 14:46:29 2020 -0400
@@ -473,7 +473,8 @@
 }
 
 int objstore_create(struct objstore_open_obj_info *diropen, const char *name,
-		    uint16_t mode, struct noid *child)
+		    uint32_t owner, uint32_t group, uint16_t mode,
+		    struct noid *child)
 {
 	struct txn txn;
 	struct obj *dir;
@@ -509,7 +510,7 @@
 	if (ret)
 		goto err_txn;
 
-	ret = dir_create(&txn, diropen->ver, name, mode, child);
+	ret = dir_create(&txn, diropen->ver, name, owner, group, mode, child);
 
 err_txn:
 	ret = txn_commitabort(&txn, ret);
--- a/src/objstore/objstore_impl.h	Thu Apr 02 14:45:21 2020 -0400
+++ b/src/objstore/objstore_impl.h	Thu Apr 02 14:46:29 2020 -0400
@@ -82,7 +82,8 @@
 extern int dir_getdent(struct objver *dirver, const uint64_t offset,
 		       struct ndirent *child);
 extern int dir_create(struct txn *txn, struct objver *dirver, const char *name,
-		      uint16_t mode, struct noid *child);
+		      uint32_t owner, uint32_t group, uint16_t mode,
+		      struct noid *child);
 extern int dir_unlink(struct txn *txn, struct objver *dirver, const char *name,
 		      const struct noid *desired);