# HG changeset patch # User Josef 'Jeff' Sipek # Date 1671497597 18000 # Node ID 9f9224e301a2d94abc9bf6749dd31b084d1810e9 # Parent 577429b838422c7ca66947a7649a2a3860eb001e objstore: move objstore_lookup_{one,all} to obj_dir.c Signed-off-by: Josef 'Jeff' Sipek diff -r 577429b83842 -r 9f9224e301a2 src/objstore/obj_dir.c --- 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) { diff -r 577429b83842 -r 9f9224e301a2 src/objstore/obj_ops.c --- 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; -}