# HG changeset patch # User Josef 'Jeff' Sipek # Date 1671312777 18000 # Node ID fe84110a0b10e4875d4e7e705379f7b0637215ee # Parent 250aed8c967d236dc76179fcb5cf83399f8f4ea0 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 diff -r 250aed8c967d -r fe84110a0b10 docs/fs-protocol.md --- 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 ----------- diff -r 250aed8c967d -r fe84110a0b10 src/common/fscall.c --- 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; } diff -r 250aed8c967d -r fe84110a0b10 src/common/include/nomad/fscall.h --- 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, diff -r 250aed8c967d -r fe84110a0b10 src/common/rpc_fs.x --- 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);