From 19fbebec161c749e5bfe440e4514e2bc2d2ac3d4 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 19 Jun 2019 13:21:52 +0200 Subject: Cleanup fstree code Replace default_$FIELD with a struct stat. Merge the rest of add_node/add_file into mknode and add by path+stat. Expose the mknode function and replace all the duplicated node pointer arithmetic magic with a call to mknode. Plus a generic cleanup by utlizing new util functions. Signed-off-by: David Oberhollenzer --- lib/sqfs/deserialize_fstree.c | 10 ++++++---- lib/sqfs/write_inode.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/sqfs') diff --git a/lib/sqfs/deserialize_fstree.c b/lib/sqfs/deserialize_fstree.c index 95dce98..2994007 100644 --- a/lib/sqfs/deserialize_fstree.c +++ b/lib/sqfs/deserialize_fstree.c @@ -158,10 +158,12 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp, memset(out, 0, sizeof(*out)); out->block_size = super->block_size; - out->default_uid = 0; - out->default_gid = 0; - out->default_mode = 0755; - out->default_mtime = super->modification_time; + out->defaults.st_uid = 0; + out->defaults.st_gid = 0; + out->defaults.st_mode = 0755; + out->defaults.st_mtime = super->modification_time; + out->defaults.st_ctime = super->modification_time; + out->defaults.st_atime = super->modification_time; out->root = tree_node_from_inode(root, &idtbl, "", super->block_size); free(root); diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c index 961013c..ee4ebc6 100644 --- a/lib/sqfs/write_inode.c +++ b/lib/sqfs/write_inode.c @@ -95,7 +95,7 @@ int meta_writer_write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im, base.mode = htole16(node->mode); base.uid_idx = htole16(uid_idx); base.gid_idx = htole16(gid_idx); - base.mod_time = htole32(fs->default_mtime); + base.mod_time = htole32(fs->defaults.st_mtime); base.inode_number = htole32(node->inode_num); if (meta_writer_append(im, &base, sizeof(base))) { -- cgit v1.2.3