aboutsummaryrefslogtreecommitdiff
path: root/bin/tar2sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-05-29 20:16:38 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-05-30 14:47:14 +0200
commit50b67940c793e72656787469ced6e0245bb580b4 (patch)
treea35e728c1b5193867bba61747b4410898fd40ce2 /bin/tar2sqfs
parent926987f338f7b3aba99dc25afd442ddd3e70d16d (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/tar2sqfs')
-rw-r--r--bin/tar2sqfs/src/process_tarball.c32
1 files changed, 11 insertions, 21 deletions
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) {