summaryrefslogtreecommitdiff
path: root/bin/gensquashfs/mkfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-27 20:19:46 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-27 20:41:21 +0200
commit687e44297071c95004d47e389fc409b951a8f9ff (patch)
tree6383b32c960a32bfb1393b774cc72a54fe2b94b1 /bin/gensquashfs/mkfs.c
parent6a0d2f053ba32c63bb9a3c40135f8d5bb46c9cb0 (diff)
Cleanup/fix: gensquashfs: split directory scanning from xattr scanning
On the one hand, this commit cleanes the code a bit by splitting the "scan directory contents" code from the "scan xattrs from directory contents" and moving the later in a seperate file. On the other hand, the xattr scanning is now done *after* the fstree is post processed, which includes sorting it. This way, the xattrs are always added in a deterministic, reproducible order. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/mkfs.c')
-rw-r--r--bin/gensquashfs/mkfs.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/bin/gensquashfs/mkfs.c b/bin/gensquashfs/mkfs.c
index b1542d1..87778d9 100644
--- a/bin/gensquashfs/mkfs.c
+++ b/bin/gensquashfs/mkfs.c
@@ -150,11 +150,6 @@ static int read_fstree(fstree_t *fs, options_t *opt, sqfs_xattr_writer_t *xwr,
FILE *fp;
int ret;
- if (opt->infile == NULL) {
- return fstree_from_dir(fs, opt->packdir, selinux_handle,
- xwr, opt->dirscan_flags);
- }
-
fp = fopen(opt->infile, "rb");
if (fp == NULL) {
perror(opt->infile);
@@ -203,23 +198,27 @@ int main(int argc, char **argv)
goto out;
}
- if (read_fstree(&sqfs.fs, &opt, sqfs.xwr, sehnd)) {
- if (sehnd != NULL)
- selinux_close_context_file(sehnd);
- goto out;
+ if (opt.infile == NULL) {
+ if (fstree_from_dir(&sqfs.fs, opt.packdir, opt.dirscan_flags))
+ goto out;
+ } else {
+ if (read_fstree(&sqfs.fs, &opt, sqfs.xwr, sehnd))
+ goto out;
}
if (opt.force_uid || opt.force_gid)
override_owner_dfs(&opt, sqfs.fs.root);
- if (sehnd != NULL) {
- selinux_close_context_file(sehnd);
- sehnd = NULL;
- }
-
if (fstree_post_process(&sqfs.fs))
goto out;
+ if (opt.infile == NULL) {
+ if (xattrs_from_dir(&sqfs.fs, opt.packdir, sehnd,
+ sqfs.xwr, opt.dirscan_flags)) {
+ goto out;
+ }
+ }
+
if (pack_files(sqfs.data, &sqfs.fs, &opt))
goto out;
@@ -229,5 +228,7 @@ int main(int argc, char **argv)
status = EXIT_SUCCESS;
out:
sqfs_writer_cleanup(&sqfs, status);
+ if (sehnd != NULL)
+ selinux_close_context_file(sehnd);
return status;
}