diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-20 11:01:10 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-20 11:01:10 +0200 |
commit | c2e01ed987e942005fa66f11d96b8edb1d930c99 (patch) | |
tree | 856042ae5b3b1928a8ca7275c996f68972a5f680 /mkfs/xattr.c | |
parent | 93f5a822b208b7df1c9a3f15685f397e0ce344aa (diff) |
cleanup: internalize meta reader/writer implementations
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/xattr.c')
-rw-r--r-- | mkfs/xattr.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/mkfs/xattr.c b/mkfs/xattr.c index 8f1a816..b7f433e 100644 --- a/mkfs/xattr.c +++ b/mkfs/xattr.c @@ -89,12 +89,13 @@ static int write_kv_pairs(sqfs_info_t *info, meta_writer_t *mw, int write_xattr(sqfs_info_t *info) { - uint64_t kv_start, id_start, *tbl; + uint64_t kv_start, id_start, block, *tbl; size_t i = 0, count = 0, blocks; sqfs_xattr_id_table_t idtbl; sqfs_xattr_id_t id_ent; meta_writer_t *mw; tree_xattr_t *it; + uint32_t offset; ssize_t ret; if (info->fs.xattr == NULL) @@ -108,8 +109,7 @@ int write_xattr(sqfs_info_t *info) kv_start = info->super.bytes_used; for (it = info->fs.xattr; it != NULL; it = it->next) { - it->block = mw->block_offset; - it->offset = mw->offset; + meta_writer_get_position(mw, &it->block, &it->offset); it->size = 0; if (write_kv_pairs(info, mw, it)) @@ -121,8 +121,10 @@ int write_xattr(sqfs_info_t *info) if (meta_writer_flush(mw)) goto fail_mw; - info->super.bytes_used += mw->block_offset; - mw->block_offset = 0; + meta_writer_get_position(mw, &block, &offset); + meta_writer_reset(mw); + + info->super.bytes_used += block; /* allocate location table */ blocks = (count * sizeof(id_ent)) / SQFS_META_BLOCK_SIZE; @@ -138,8 +140,8 @@ int write_xattr(sqfs_info_t *info) } /* write ID table referring to key value pairs, record offsets */ - id_start = mw->block_offset; - tbl[i++] = htole64(info->super.bytes_used + id_start); + id_start = 0; + tbl[i++] = htole64(info->super.bytes_used); for (it = info->fs.xattr; it != NULL; it = it->next) { id_ent.xattr = htole64((it->block << 16) | it->offset); @@ -149,8 +151,10 @@ int write_xattr(sqfs_info_t *info) if (meta_writer_append(mw, &id_ent, sizeof(id_ent))) goto fail_tbl; - if (mw->block_offset != id_start) { - id_start = mw->block_offset; + meta_writer_get_position(mw, &block, &offset); + + if (block != id_start) { + id_start = block; tbl[i++] = htole64(info->super.bytes_used + id_start); } } @@ -158,8 +162,8 @@ int write_xattr(sqfs_info_t *info) if (meta_writer_flush(mw)) goto fail_tbl; - info->super.bytes_used += mw->block_offset; - mw->block_offset = 0; + meta_writer_get_position(mw, &block, &offset); + info->super.bytes_used += block; /* write offset table */ idtbl.xattr_table_start = htole64(kv_start); |