diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-02 19:50:05 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-10 09:22:04 +0200 |
commit | e7ecb1f92ae618a56ee8eabb6cbf98365de3695a (patch) | |
tree | 8d6d53df2c1654ecf5f4c587d8b7b2592a68c4f2 /lib/io/src | |
parent | ec593e0b94656a5481f82ee0f33728ced297ac48 (diff) |
Move sqfs_dir_entry_t code from libio into libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/src')
-rw-r--r-- | lib/io/src/dir_entry.c | 30 | ||||
-rw-r--r-- | lib/io/src/dir_tree_iterator.c | 2 | ||||
-rw-r--r-- | lib/io/src/unix/dir_iterator.c | 5 |
3 files changed, 3 insertions, 34 deletions
diff --git a/lib/io/src/dir_entry.c b/lib/io/src/dir_entry.c deleted file mode 100644 index 1bfc887..0000000 --- a/lib/io/src/dir_entry.c +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * dir_entry.c - * - * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at> - */ -#include "io/dir_entry.h" -#include "compat.h" - -#include <stdlib.h> -#include <string.h> - -sqfs_dir_entry_t *dir_entry_create(const char *name) -{ - size_t len, name_len; - sqfs_dir_entry_t *out; - - name_len = strlen(name); - if (SZ_ADD_OV(name_len, 1, &name_len)) - return NULL; - if (SZ_ADD_OV(sizeof(*out), name_len, &len)) - return NULL; - - out = calloc(1, len); - if (out == NULL) - return NULL; - - memcpy(out->name, name, name_len); - return out; -} diff --git a/lib/io/src/dir_tree_iterator.c b/lib/io/src/dir_tree_iterator.c index 989907b..7af4b5e 100644 --- a/lib/io/src/dir_tree_iterator.c +++ b/lib/io/src/dir_tree_iterator.c @@ -59,7 +59,7 @@ static bool should_skip(const dir_tree_iterator_t *dir, const sqfs_dir_entry_t * return true; if ((dir->cfg.flags & DIR_SCAN_ONE_FILESYSTEM)) { - if (ent->flags & DIR_ENTRY_FLAG_MOUNT_POINT) + if (ent->flags & SQFS_DIR_ENTRY_FLAG_MOUNT_POINT) return true; } diff --git a/lib/io/src/unix/dir_iterator.c b/lib/io/src/unix/dir_iterator.c index 99713fd..1cec198 100644 --- a/lib/io/src/unix/dir_iterator.c +++ b/lib/io/src/unix/dir_iterator.c @@ -100,7 +100,7 @@ static int dir_next(dir_iterator_t *base, sqfs_dir_entry_t **out) return it->state; } - *out = dir_entry_create(it->ent->d_name); + *out = sqfs_dir_entry_create(it->ent->d_name, it->sb.st_mode, 0); if ((*out) == NULL) { it->state = SQFS_ERROR_ALLOC; return it->state; @@ -111,13 +111,12 @@ static int dir_next(dir_iterator_t *base, sqfs_dir_entry_t **out) (*out)->rdev = it->sb.st_rdev; (*out)->uid = it->sb.st_uid; (*out)->gid = it->sb.st_gid; - (*out)->mode = it->sb.st_mode; if (S_ISREG(it->sb.st_mode)) (*out)->size = it->sb.st_size; if ((*out)->dev != it->device) - (*out)->flags |= DIR_ENTRY_FLAG_MOUNT_POINT; + (*out)->flags |= SQFS_DIR_ENTRY_FLAG_MOUNT_POINT; return it->state; } |