# HG changeset patch # User Josef 'Jeff' Sipek # Date 1671497085 18000 # Node ID 77a35abc6a248e518c4517bbd340fb194f5fa709 # Parent aa5470a5ef8ac6d67c41fbc819ea167ba312c4f7 objstore: move dir buffer making helper to dir.c This is where it belongs since it doesn't do anything directly with objects. Signed-off-by: Josef 'Jeff' Sipek diff -r aa5470a5ef8a -r 77a35abc6a24 src/objstore/dir.c --- a/src/objstore/dir.c Mon Dec 19 19:39:43 2022 -0500 +++ b/src/objstore/dir.c Mon Dec 19 19:44:45 2022 -0500 @@ -166,3 +166,41 @@ return 0; } + +int dir_make_buffer(uint64_t this_host, uint64_t this_uniq, + uint64_t parent_host, uint64_t parent_uniq, + struct buffer *buf) +{ + struct ndirent_tgt tgt; + struct dirblock block; + int ret; + + dirblock_init(&block); + + ret = buffer_truncate(buf, 0); + if (ret) + return ret; + + /* '.' dirent */ + tgt.type = NDIRENT_TYPE_DIR; + tgt.deleted = false; + tgt.host = this_host; + tgt.uniq = this_uniq; + + ret = dirblock_add_dirent(&block, ".", &tgt); + if (ret) + return ret; + + /* '..' dirent */ + tgt.type = NDIRENT_TYPE_DIR; + tgt.deleted = false; + tgt.host = parent_host; + tgt.uniq = parent_uniq; + + ret = dirblock_add_dirent(&block, "..", &tgt); + if (ret) + return ret; + + /* serialize */ + return dirblock_serialize(&block, buf); +} diff -r aa5470a5ef8a -r 77a35abc6a24 src/objstore/include/nomad/objstore_backend.h --- a/src/objstore/include/nomad/objstore_backend.h Mon Dec 19 19:39:43 2022 -0500 +++ b/src/objstore/include/nomad/objstore_backend.h Mon Dec 19 19:44:45 2022 -0500 @@ -279,8 +279,8 @@ extern struct objver *obj_add_version(struct obj *obj, const struct nvclock *clock); -extern int obj_make_dir_buffer(uint64_t this_host, uint64_t this_uniq, - uint64_t parent_host, uint64_t parent_uniq, - struct buffer *buf); +extern int dir_make_buffer(uint64_t this_host, uint64_t this_uniq, + uint64_t parent_host, uint64_t parent_uniq, + struct buffer *buf); #endif diff -r aa5470a5ef8a -r 77a35abc6a24 src/objstore/obj_dir.c --- a/src/objstore/obj_dir.c Mon Dec 19 19:39:43 2022 -0500 +++ b/src/objstore/obj_dir.c Mon Dec 19 19:44:45 2022 -0500 @@ -50,44 +50,6 @@ return 0; } -int obj_make_dir_buffer(uint64_t this_host, uint64_t this_uniq, - uint64_t parent_host, uint64_t parent_uniq, - struct buffer *buf) -{ - struct ndirent_tgt tgt; - struct dirblock block; - int ret; - - dirblock_init(&block); - - ret = buffer_truncate(buf, 0); - if (ret) - return ret; - - /* '.' dirent */ - tgt.type = NDIRENT_TYPE_DIR; - tgt.deleted = false; - tgt.host = this_host; - tgt.uniq = this_uniq; - - ret = dirblock_add_dirent(&block, ".", &tgt); - if (ret) - return ret; - - /* '..' dirent */ - tgt.type = NDIRENT_TYPE_DIR; - tgt.deleted = false; - tgt.host = parent_host; - tgt.uniq = parent_uniq; - - ret = dirblock_add_dirent(&block, "..", &tgt); - if (ret) - return ret; - - /* serialize */ - return dirblock_serialize(&block, buf); -} - /* find an entry - no matter what its state is (conflicts, all_deleted, etc.) */ int dir_lookup_entry(struct objver *dirver, const char *name, uint8_t *raw, struct ndirent_mem *ent, uint64_t *_off, diff -r aa5470a5ef8a -r 77a35abc6a24 src/objstore/obj_dir_create.c --- a/src/objstore/obj_dir_create.c Mon Dec 19 19:39:43 2022 -0500 +++ b/src/objstore/obj_dir_create.c Mon Dec 19 19:44:45 2022 -0500 @@ -79,11 +79,11 @@ buffer_init_static(&contents, raw, sizeof(raw), sizeof(raw), true); - ret = obj_make_dir_buffer(noid_get_allocator(&child->obj->oid), - noid_get_uniq(&child->obj->oid), - noid_get_allocator(&dirver->obj->oid), - noid_get_uniq(&dirver->obj->oid), - &contents); + ret = dir_make_buffer(noid_get_allocator(&child->obj->oid), + noid_get_uniq(&child->obj->oid), + noid_get_allocator(&dirver->obj->oid), + noid_get_uniq(&dirver->obj->oid), + &contents); if (ret) goto err; diff -r aa5470a5ef8a -r 77a35abc6a24 src/objstore/posix/obj_create.c --- a/src/objstore/posix/obj_create.c Mon Dec 19 19:39:43 2022 -0500 +++ b/src/objstore/posix/obj_create.c Mon Dec 19 19:44:45 2022 -0500 @@ -163,7 +163,7 @@ if (ret) return ret; - ret = obj_make_dir_buffer(host, uniq, host, uniq, &contents); + ret = dir_make_buffer(host, uniq, host, uniq, &contents); if (ret) goto err;