aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-29 02:56:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-29 23:44:05 +0200
commitf21fa23162d294b1327aaa3528444c1aaceb5b5a (patch)
tree79d723a2da8c751c589fe899f252969f24a6247c /bin
parente976555d39b3361a061b33f59108b5cb75f71a62 (diff)
Move dir entry remapping from gensquashfs to libutil
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin')
-rw-r--r--bin/gensquashfs/src/fstree_from_file.c31
-rw-r--r--bin/gensquashfs/src/mkfs.c3
2 files changed, 11 insertions, 23 deletions
diff --git a/bin/gensquashfs/src/fstree_from_file.c b/bin/gensquashfs/src/fstree_from_file.c
index 77f9ebd..8f1b50b 100644
--- a/bin/gensquashfs/src/fstree_from_file.c
+++ b/bin/gensquashfs/src/fstree_from_file.c
@@ -21,17 +21,13 @@ struct glob_context {
const char *filename;
size_t line_num;
- struct stat *basic;
unsigned int glob_flags;
char *name_pattern;
};
enum {
- GLOB_MODE_FROM_SRC = 0x01,
- GLOB_UID_FROM_SRC = 0x02,
- GLOB_GID_FROM_SRC = 0x04,
- GLOB_FLAG_PATH = 0x08,
+ GLOB_FLAG_PATH = 0x00010000,
};
static const struct {
@@ -167,17 +163,6 @@ static int glob_node_callback(void *user, tree_node_t *root, dir_entry_t *ent)
struct glob_context *ctx = user;
int ret;
- if (!(ctx->glob_flags & GLOB_MODE_FROM_SRC)) {
- ent->mode &= ~(07777);
- ent->mode |= ctx->basic->st_mode & 07777;
- }
-
- if (!(ctx->glob_flags & GLOB_UID_FROM_SRC))
- ent->uid = ctx->basic->st_uid;
-
- if (!(ctx->glob_flags & GLOB_GID_FROM_SRC))
- ent->gid = ctx->basic->st_gid;
-
if (ctx->name_pattern != NULL) {
if (ctx->glob_flags & GLOB_FLAG_PATH) {
char *path = full_path(root, ent);
@@ -256,7 +241,6 @@ static int glob_files(fstree_t *fs, const char *filename, size_t line_num,
memset(&ctx, 0, sizeof(ctx));
ctx.filename = filename;
ctx.line_num = line_num;
- ctx.basic = basic;
ctx.glob_flags = glob_flags;
/* fetch the actual target node */
@@ -365,8 +349,11 @@ static int glob_files(fstree_t *fs, const char *filename, size_t line_num,
/* do the scan */
memset(&cfg, 0, sizeof(cfg));
- cfg.flags = scan_flags;
- cfg.def_mtime = fs->defaults.mtime;
+ cfg.flags = scan_flags | glob_flags;
+ cfg.def_mtime = basic->st_mtime;
+ cfg.def_uid = basic->st_uid;
+ cfg.def_gid = basic->st_gid;
+ cfg.def_mode = basic->st_mode;
if (basepath == NULL) {
dir = dir_tree_iterator_create(extra == NULL ? "." : extra,
@@ -530,7 +517,7 @@ static int handle_line(fstree_t *fs, const char *filename,
if (cb->is_glob && *line == '*') {
++line;
mode = 0;
- glob_flags |= GLOB_MODE_FROM_SRC;
+ glob_flags |= DIR_SCAN_KEEP_MODE;
} else {
if ((line = read_u32(line, &mode, 8)) == NULL || mode > 07777)
goto fail_mode;
@@ -542,7 +529,7 @@ static int handle_line(fstree_t *fs, const char *filename,
if (cb->is_glob && *line == '*') {
++line;
uid = 0;
- glob_flags |= GLOB_UID_FROM_SRC;
+ glob_flags |= DIR_SCAN_KEEP_UID;
} else {
if ((line = read_u32(line, &uid, 10)) == NULL)
goto fail_uid_gid;
@@ -554,7 +541,7 @@ static int handle_line(fstree_t *fs, const char *filename,
if (cb->is_glob && *line == '*') {
++line;
gid = 0;
- glob_flags |= GLOB_GID_FROM_SRC;
+ glob_flags |= DIR_SCAN_KEEP_GID;
} else {
if ((line = read_u32(line, &gid, 10)) == NULL)
goto fail_uid_gid;
diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c
index f2973b6..051b6ac 100644
--- a/bin/gensquashfs/src/mkfs.c
+++ b/bin/gensquashfs/src/mkfs.c
@@ -171,7 +171,8 @@ int main(int argc, char **argv)
int ret;
memset(&cfg, 0, sizeof(cfg));
- cfg.flags = opt.dirscan_flags;
+ cfg.flags = opt.dirscan_flags | DIR_SCAN_KEEP_UID |
+ DIR_SCAN_KEEP_GID | DIR_SCAN_KEEP_MODE;
cfg.def_mtime = sqfs.fs.defaults.mtime;
dir = dir_tree_iterator_create(opt.packdir, &cfg);