changeset 878:fe84110a0b10

common: extend LINK to include more args and a return value These should have been part of the RPC from the beginning. Since nothing implements LINK yet, we can modify it without dealing with protocol version issues. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Dec 2022 16:32:57 -0500
parents 250aed8c967d
children 0c94a9835dfd
files docs/fs-protocol.md src/common/fscall.c src/common/include/nomad/fscall.h src/common/rpc_fs.x
diffstat 4 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/docs/fs-protocol.md	Fri Dec 16 20:25:01 2022 -0500
+++ b/docs/fs-protocol.md	Sat Dec 17 16:32:57 2022 -0500
@@ -159,6 +159,9 @@
 use as the target.  If a null oid is specified and there are multiple
 dirents with the same name, the operation fails with `ENOTUNIQ`.
 
+Symlinks have their own owner, group, and mode.  The returned oid is used
+only for symlinks.
+
 Inputs
 ------
 * directory open file handle
@@ -166,10 +169,13 @@
 * target path
 * desired target oid
 * symlink
+* symlink owner
+* symlink group
+* symlink mode
 
 Outputs
 -------
-None.
+* new symlink oid
 
 Limitations
 -----------
--- a/src/common/fscall.c	Fri Dec 16 20:25:01 2022 -0500
+++ b/src/common/fscall.c	Sat Dec 17 16:32:57 2022 -0500
@@ -299,26 +299,33 @@
 }
 
 int fscall_symlink(struct fscall_state *state, const uint32_t parent_handle,
-		   const char *name, const char *target)
+		   const char *name, const uint32_t owner, const uint32_t group,
+		   const uint16_t mode, const char *target, struct noid *child)
 {
 	struct rpc_link_req link_req;
+	struct rpc_link_res link_res;
 	int ret;
 
 	link_req.parent = parent_handle;
 	link_req.name = (char *) name;
 	link_req.target_name = (char *) target;
 	link_req.target_handle = 0;
+	link_req.owner = owner;
+	link_req.group = group;
+	link_req.mode = mode;
 	link_req.symlink = true;
 
 	ret = __fscall(state->sock, NRPC_LINK,
 		       (void *) xdr_rpc_link_req,
-		       NULL,
+		       (void *) xdr_rpc_link_res,
 		       &link_req,
-		       NULL,
-		       0);
+		       &link_res,
+		       sizeof(link_res));
 	if (ret)
 		return ret;
 
+	*child = link_res.oid;
+
 	return 0;
 }
 
@@ -326,23 +333,30 @@
 		const char *name, const uint32_t target_handle)
 {
 	struct rpc_link_req link_req;
+	struct rpc_link_res link_res;
 	int ret;
 
 	link_req.parent = parent_handle;
 	link_req.name = (char *) name;
 	link_req.target_name = NULL;
 	link_req.target_handle = target_handle;
+	link_req.owner = 0;
+	link_req.group = 0;
+	link_req.mode = 0;
 	link_req.symlink = false;
 
 	ret = __fscall(state->sock, NRPC_LINK,
 		       (void *) xdr_rpc_link_req,
-		       NULL,
+		       (void *) xdr_rpc_link_res,
 		       &link_req,
-		       NULL,
-		       0);
+		       &link_res,
+		       sizeof(link_res));
 	if (ret)
 		return ret;
 
+	if (!noid_is_null(&link_res.oid))
+		return -EINVAL;
+
 	return 0;
 }
 
--- a/src/common/include/nomad/fscall.h	Fri Dec 16 20:25:01 2022 -0500
+++ b/src/common/include/nomad/fscall.h	Sat Dec 17 16:32:57 2022 -0500
@@ -61,8 +61,11 @@
 			 const char *name, const uint32_t owner,
 			 const uint32_t group, uint16_t mode, uint64_t dev,
 			 struct noid *child);
-extern int fscall_symlink(struct fscall_state *state, const uint32_t parent_handle,
-			  const char *name, const char *target);
+extern int fscall_symlink(struct fscall_state *state,
+			  const uint32_t parent_handle, const char *name,
+			  const uint32_t owner, const uint32_t group,
+			  const uint16_t mode, const char *target,
+			  struct noid *child);
 extern int fscall_link(struct fscall_state *state, const uint32_t parent_handle,
 		       const char *name, const uint32_t target_handle);
 extern int fscall_unlink(struct fscall_state *state, const uint32_t parent_handle,
--- a/src/common/rpc_fs.x	Fri Dec 16 20:25:01 2022 -0500
+++ b/src/common/rpc_fs.x	Sat Dec 17 16:32:57 2022 -0500
@@ -97,9 +97,16 @@
 	string		name<>;
 	string		target_name<>; /* symlink only */
 	HANDLE(target_handle); /* hardlink only */
+	uint32_t	owner;
+	uint32_t	group;
+	uint16_t	mode;
 	bool		symlink;
 };
 
+struct rpc_link_res {
+	struct noid	oid;
+};
+
 %/***** UNLINK *****/
 struct rpc_unlink_req {
 	HANDLE(parent);