From 50b67940c793e72656787469ced6e0245bb580b4 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 29 May 2023 20:16:38 +0200 Subject: libfstree: accept dir_entry_t instead of path and struct stat Because the dir_entry_t also has a flag for had links, the regular node and hard-link node interface can be unified. This simplifies the users of libfstree (gensquashfs, tar2sqfs) since we can simply hose the entries from an iterator directly into the tree. Signed-off-by: David Oberhollenzer --- bin/tar2sqfs/src/process_tarball.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'bin/tar2sqfs') diff --git a/bin/tar2sqfs/src/process_tarball.c b/bin/tar2sqfs/src/process_tarball.c index 2399dfa..ef49d20 100644 --- a/bin/tar2sqfs/src/process_tarball.c +++ b/bin/tar2sqfs/src/process_tarball.c @@ -93,31 +93,18 @@ static int create_node_and_repack_data(sqfs_writer_t *sqfs, dir_iterator_t *it, const dir_entry_t *ent, const char *link) { tree_node_t *node; - struct stat sb; - if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) { - node = fstree_add_hard_link(&sqfs->fs, ent->name, link); - if (node == NULL) - goto fail_errno; - - if (!cfg.quiet) - printf("Hard link %s -> %s\n", ent->name, link); - return 0; - } - - memset(&sb, 0, sizeof(sb)); - sb.st_mode = ent->mode; - sb.st_uid = ent->uid; - sb.st_gid = ent->gid; - sb.st_rdev = ent->rdev; - sb.st_mtime = keep_time ? ent->mtime : sqfs->fs.defaults.mtime; - - node = fstree_add_generic(&sqfs->fs, ent->name, &sb, link); + node = fstree_add_generic(&sqfs->fs, ent, link); if (node == NULL) goto fail_errno; - if (!cfg.quiet) - printf("Packing %s\n", ent->name); + if (!cfg.quiet) { + if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) { + printf("Hard link %s -> %s\n", ent->name, link); + } else { + printf("Packing %s\n", ent->name); + } + } if (!cfg.no_xattr) { if (copy_xattr(sqfs, ent->name, node, it)) @@ -234,6 +221,9 @@ int process_tarball(istream_t *input_file, sqfs_writer_t *sqfs) is_root = true; } + if (!keep_time) + ent->mtime = sqfs->fs.defaults.mtime; + if (is_root) { ret = set_root_attribs(sqfs, it, ent); } else if (skip) { -- cgit v1.2.3