Mercurial > nomad
changeset 897:9f9224e301a2
objstore: move objstore_lookup_{one,all} to obj_dir.c
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 19 Dec 2022 19:53:17 -0500 |
parents | 577429b83842 |
children | cbeaf88784a3 |
files | src/objstore/obj_dir.c src/objstore/obj_ops.c |
diffstat | 2 files changed, 46 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/src/objstore/obj_dir.c Mon Dec 19 20:11:20 2022 -0500 +++ b/src/objstore/obj_dir.c Mon Dec 19 19:53:17 2022 -0500 @@ -364,6 +364,52 @@ return ret; } +int objstore_lookup_one(struct objstore_open_obj_info *diropen, + const char *name, const struct noid *desired, + struct noid *child, uint8_t *type) +{ + struct obj *dir; + int ret; + + if (!diropen || !name || !desired || !child || !type) + return -EINVAL; + + dir = diropen->obj; + + *type = NDIRENT_TYPE_UNKNOWN; /* unknown by default */ + + MXLOCK(&dir->lock); + if (!NATTR_ISDIR(diropen->ver->attrs.mode)) + ret = -ENOTDIR; + else + ret = dir_lookup_one(diropen->ver, name, desired, child, type); + MXUNLOCK(&dir->lock); + + return ret; +} + +ssize_t objstore_lookup_all(struct objstore_open_obj_info *diropen, + const char *name, struct noid **child, + uint8_t **type) +{ + struct obj *dir; + ssize_t ret; + + if (!diropen || !name || !child || !type) + return -EINVAL; + + dir = diropen->obj; + + MXLOCK(&dir->lock); + if (!NATTR_ISDIR(diropen->ver->attrs.mode)) + ret = -ENOTDIR; + else + ret = dir_lookup_all(diropen->ver, name, child, type); + MXUNLOCK(&dir->lock); + + return ret; +} + int objstore_getdent(struct objstore_open_obj_info *diropen, const uint64_t offset, struct ndirent *child) {
--- a/src/objstore/obj_ops.c Mon Dec 19 20:11:20 2022 -0500 +++ b/src/objstore/obj_ops.c Mon Dec 19 19:53:17 2022 -0500 @@ -165,56 +165,3 @@ return ret; } - -/* - * Directory operations - * - * Technically, the following are not wrappers around object ops. However, - * they kind of belong here. - */ - -int objstore_lookup_one(struct objstore_open_obj_info *diropen, - const char *name, const struct noid *desired, - struct noid *child, uint8_t *type) -{ - struct obj *dir; - int ret; - - if (!diropen || !name || !desired || !child || !type) - return -EINVAL; - - dir = diropen->obj; - - *type = NDIRENT_TYPE_UNKNOWN; /* unknown by default */ - - MXLOCK(&dir->lock); - if (!NATTR_ISDIR(diropen->ver->attrs.mode)) - ret = -ENOTDIR; - else - ret = dir_lookup_one(diropen->ver, name, desired, child, type); - MXUNLOCK(&dir->lock); - - return ret; -} - -ssize_t objstore_lookup_all(struct objstore_open_obj_info *diropen, - const char *name, struct noid **child, - uint8_t **type) -{ - struct obj *dir; - ssize_t ret; - - if (!diropen || !name || !child || !type) - return -EINVAL; - - dir = diropen->obj; - - MXLOCK(&dir->lock); - if (!NATTR_ISDIR(diropen->ver->attrs.mode)) - ret = -ENOTDIR; - else - ret = dir_lookup_all(diropen->ver, name, child, type); - MXUNLOCK(&dir->lock); - - return ret; -}