Mercurial > nomad
changeset 895:d9e0b59c30f0
objstore: move objstore_{,sym}link to obj_link.c
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 19 Dec 2022 20:11:14 -0500 |
parents | f089372dfed0 |
children | 577429b83842 |
files | src/objstore/obj_link.c src/objstore/obj_ops.c |
diffstat | 2 files changed, 58 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/src/objstore/obj_link.c Mon Dec 19 19:51:07 2022 -0500 +++ b/src/objstore/obj_link.c Mon Dec 19 20:11:14 2022 -0500 @@ -101,3 +101,61 @@ return ret; } + +int objstore_symlink(struct objstore_open_obj_info *diropen, const char *name, + uint32_t owner, uint32_t group, uint16_t mode, + const char *target, struct noid *child) +{ + struct objver *newver; + struct obj *dir; + struct txn *txn; + int ret; + + if (!diropen || !name || !target) + return -EINVAL; + + /* must have a type */ + if (!NATTR_ISLNK(mode)) + return -EINVAL; + + dir = diropen->obj; + + if (diropen->qualified) + return -EROFS; + + MXLOCK(&dir->lock); + + if (!NATTR_ISDIR(diropen->ver->attrs.mode)) { + ret = -ENOTDIR; + goto err; + } + + txn = txn_begin(diropen->ver->obj->clone); + if (IS_ERR(txn)) { + ret = PTR_ERR(txn); + goto err; + } + + newver = obj_cow(txn, diropen); + if (IS_ERR(newver)) { + ret = PTR_ERR(newver); + goto err_txn; + } + + ret = dir_symlink(txn, newver, name, owner, group, mode, target, child); + +err_txn: + ret = txn_commitabort(txn, ret); + newver = NULL; /* prevent accidental use */ + +err: + MXUNLOCK(&dir->lock); + + return ret; +} + +int objstore_link(struct objstore_open_obj_info *diropen, const char *name, + struct objstore_open_obj_info *tgtopen) +{ + return -ENOTSUP; +}
--- a/src/objstore/obj_ops.c Mon Dec 19 19:51:07 2022 -0500 +++ b/src/objstore/obj_ops.c Mon Dec 19 20:11:14 2022 -0500 @@ -219,64 +219,6 @@ return ret; } -int objstore_symlink(struct objstore_open_obj_info *diropen, const char *name, - uint32_t owner, uint32_t group, uint16_t mode, - const char *target, struct noid *child) -{ - struct objver *newver; - struct obj *dir; - struct txn *txn; - int ret; - - if (!diropen || !name || !target) - return -EINVAL; - - /* must have a type */ - if (!NATTR_ISLNK(mode)) - return -EINVAL; - - dir = diropen->obj; - - if (diropen->qualified) - return -EROFS; - - MXLOCK(&dir->lock); - - if (!NATTR_ISDIR(diropen->ver->attrs.mode)) { - ret = -ENOTDIR; - goto err; - } - - txn = txn_begin(diropen->ver->obj->clone); - if (IS_ERR(txn)) { - ret = PTR_ERR(txn); - goto err; - } - - newver = obj_cow(txn, diropen); - if (IS_ERR(newver)) { - ret = PTR_ERR(newver); - goto err_txn; - } - - ret = dir_symlink(txn, newver, name, owner, group, mode, target, child); - -err_txn: - ret = txn_commitabort(txn, ret); - newver = NULL; /* prevent accidental use */ - -err: - MXUNLOCK(&dir->lock); - - return ret; -} - -int objstore_link(struct objstore_open_obj_info *diropen, const char *name, - struct objstore_open_obj_info *tgtopen) -{ - return -ENOTSUP; -} - int objstore_unlink(struct objstore_open_obj_info *diropen, const char *name, const struct noid *desired, bool rmdir) {