aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-02 19:50:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-10 09:22:04 +0200
commite7ecb1f92ae618a56ee8eabb6cbf98365de3695a (patch)
tree8d6d53df2c1654ecf5f4c587d8b7b2592a68c4f2
parentec593e0b94656a5481f82ee0f33728ced297ac48 (diff)
Move sqfs_dir_entry_t code from libio into libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--bin/gensquashfs/src/fstree_from_file.c2
-rw-r--r--bin/tar2sqfs/src/process_tarball.c6
-rw-r--r--include/fstree.h2
-rw-r--r--include/io/dir_iterator.h2
-rw-r--r--include/sqfs/dir_entry.h (renamed from include/io/dir_entry.h)26
-rw-r--r--include/sqfs/predef.h1
-rw-r--r--lib/fstree/Makemodule.am15
-rw-r--r--lib/fstree/src/fstree.c6
-rw-r--r--lib/fstree/test/add_by_path.c3
-rw-r--r--lib/fstree/test/fstree_sort.c3
-rw-r--r--lib/fstree/test/gen_inode_numbers.c4
-rw-r--r--lib/fstree/test/get_path.c3
-rw-r--r--lib/fstree/test/mknode_dir.c3
-rw-r--r--lib/fstree/test/mknode_simple.c3
-rw-r--r--lib/io/Makemodule.am12
-rw-r--r--lib/io/src/dir_tree_iterator.c2
-rw-r--r--lib/io/src/unix/dir_iterator.c5
-rw-r--r--lib/sqfs/Makemodule.am5
-rw-r--r--lib/sqfs/src/dir_entry.c (renamed from lib/io/src/dir_entry.c)17
-rw-r--r--lib/tar/src/iterator.c5
-rw-r--r--lib/tar/test/tar_iterator3.c2
21 files changed, 68 insertions, 59 deletions
diff --git a/bin/gensquashfs/src/fstree_from_file.c b/bin/gensquashfs/src/fstree_from_file.c
index 16fa516..2d7a62d 100644
--- a/bin/gensquashfs/src/fstree_from_file.c
+++ b/bin/gensquashfs/src/fstree_from_file.c
@@ -112,7 +112,7 @@ static const struct callback_t {
} file_list_hooks[] = {
{ "dir", S_IFDIR, 0, false, true, add_generic },
{ "slink", S_IFLNK, 0, true, false, add_generic },
- { "link", S_IFLNK, DIR_ENTRY_FLAG_HARD_LINK, true, false, add_generic },
+ { "link", S_IFLNK, SQFS_DIR_ENTRY_FLAG_HARD_LINK, true, false, add_generic },
{ "nod", 0, 0, true, false, add_device },
{ "pipe", S_IFIFO, 0, false, false, add_generic },
{ "sock", S_IFSOCK, 0, false, false, add_generic },
diff --git a/bin/tar2sqfs/src/process_tarball.c b/bin/tar2sqfs/src/process_tarball.c
index ecb9095..331936d 100644
--- a/bin/tar2sqfs/src/process_tarball.c
+++ b/bin/tar2sqfs/src/process_tarball.c
@@ -101,7 +101,7 @@ static int create_node_and_repack_data(sqfs_writer_t *sqfs, dir_iterator_t *it,
goto fail_errno;
if (!cfg.quiet) {
- if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) {
+ if (ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) {
printf("Hard link %s -> %s\n", ent->name, link);
} else {
printf("Packing %s\n", ent->name);
@@ -130,7 +130,7 @@ fail_errno:
static int set_root_attribs(sqfs_writer_t *sqfs, dir_iterator_t *it,
const sqfs_dir_entry_t *ent)
{
- if ((ent->flags & DIR_ENTRY_FLAG_HARD_LINK) || !S_ISDIR(ent->mode)) {
+ if ((ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) || !S_ISDIR(ent->mode)) {
fprintf(stderr, "'%s' is not a directory!\n", ent->name);
return -1;
}
@@ -204,7 +204,7 @@ int process_tarball(dir_iterator_t *it, sqfs_writer_t *sqfs)
}
if (link != NULL &&
- ((ent->flags & DIR_ENTRY_FLAG_HARD_LINK) ||
+ ((ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) ||
!no_symlink_retarget)) {
if (canonicalize_name(link) == 0 &&
!strncmp(link, root_becomes, rootlen) &&
diff --git a/include/fstree.h b/include/fstree.h
index 0d60616..402d6a2 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -15,7 +15,7 @@
#include <stdio.h>
#include "sqfs/predef.h"
-#include "io/dir_entry.h"
+#include "sqfs/dir_entry.h"
#include "compat.h"
typedef struct fstree_defaults_t fstree_defaults_t;
diff --git a/include/io/dir_iterator.h b/include/io/dir_iterator.h
index 18c0e9a..1801123 100644
--- a/include/io/dir_iterator.h
+++ b/include/io/dir_iterator.h
@@ -7,7 +7,7 @@
#ifndef IO_DIR_ITERATOR_H
#define IO_DIR_ITERATOR_H
-#include "io/dir_entry.h"
+#include "sqfs/dir_entry.h"
#include "sqfs/predef.h"
/**
diff --git a/include/io/dir_entry.h b/include/sqfs/dir_entry.h
index 8ff8cf0..5f80bab 100644
--- a/include/io/dir_entry.h
+++ b/include/sqfs/dir_entry.h
@@ -1,26 +1,28 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* dir_entry.h
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
-#ifndef IO_DIR_ENTRY_H
-#define IO_DIR_ENTRY_H
+#ifndef SQFS_DIR_ENTRY_H
+#define SQFS_DIR_ENTRY_H
#include "sqfs/predef.h"
typedef enum {
- DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001,
+ SQFS_DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001,
- DIR_ENTRY_FLAG_HARD_LINK = 0x0002,
-} DIR_ENTRY_FLAG;
+ SQFS_DIR_ENTRY_FLAG_HARD_LINK = 0x0002,
+
+ SQFS_DIR_ENTRY_FLAG_ALL = 0x0003,
+} SQFS_DIR_ENTRY_FLAG;
/**
* @struct sqfs_dir_entry_t
*
* @brief A directory entry returned by a @ref dir_iterator_t
*/
-typedef struct {
+struct sqfs_dir_entry_t {
/**
* @brief Total size of file entries
*/
@@ -71,7 +73,7 @@ typedef struct {
sqfs_u16 mode;
/**
- * @brief Combination of DIR_ENTRY_FLAG values
+ * @brief Combination of SQFS_DIR_ENTRY_FLAG values
*/
sqfs_u16 flags;
@@ -82,16 +84,18 @@ typedef struct {
* Windows with encoding-aware APIs, the name is converted to UTF-8.
*/
char name[];
-} sqfs_dir_entry_t;
+};
#ifdef __cplusplus
extern "C" {
#endif
-sqfs_dir_entry_t *dir_entry_create(const char *name);
+SQFS_API sqfs_dir_entry_t *sqfs_dir_entry_create(const char *name,
+ sqfs_u16 mode,
+ sqfs_u16 flags);
#ifdef __cplusplus
}
#endif
-#endif /* IO_DIR_ENTRY_H */
+#endif /* SQFS_DIR_ENTRY_H */
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index 989649a..12ed7c7 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -98,6 +98,7 @@ typedef struct sqfs_readdir_state_t sqfs_readdir_state_t;
typedef struct sqfs_xattr_t sqfs_xattr_t;
typedef struct sqfs_istream_t sqfs_istream_t;
typedef struct sqfs_ostream_t sqfs_ostream_t;
+typedef struct sqfs_dir_entry_t sqfs_dir_entry_t;
typedef struct sqfs_fragment_t sqfs_fragment_t;
typedef struct sqfs_dir_header_t sqfs_dir_header_t;
diff --git a/lib/fstree/Makemodule.am b/lib/fstree/Makemodule.am
index 8eeaa86..2ce43d7 100644
--- a/lib/fstree/Makemodule.am
+++ b/lib/fstree/Makemodule.am
@@ -5,23 +5,26 @@ libfstree_a_SOURCES = include/fstree.h lib/fstree/src/fstree.c \
noinst_LIBRARIES += libfstree.a
test_mknode_simple_SOURCES = lib/fstree/test/mknode_simple.c
-test_mknode_simple_LDADD = libfstree.a libio.a libutil.a libcompat.a
+test_mknode_simple_LDADD = libfstree.a libsquashfs.la libutil.a libcompat.a
test_mknode_dir_SOURCES = lib/fstree/test/mknode_dir.c
-test_mknode_dir_LDADD = libfstree.a libio.a libutil.a libcompat.a
+test_mknode_dir_LDADD = libfstree.a libsquashfs.la libutil.a libcompat.a
test_gen_inode_numbers_SOURCES = lib/fstree/test/gen_inode_numbers.c
-test_gen_inode_numbers_LDADD = libcommon.a libfstree.a libio.a \
+test_gen_inode_numbers_LDADD = libcommon.a libfstree.a libsquashfs.la \
libutil.a libcompat.a
test_add_by_path_SOURCES = lib/fstree/test/add_by_path.c
-test_add_by_path_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
+test_add_by_path_LDADD = libcommon.a libfstree.a libsquashfs.la \
+ libutil.a libcompat.a
test_get_path_SOURCES = lib/fstree/test/get_path.c
-test_get_path_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
+test_get_path_LDADD = libcommon.a libfstree.a libsquashfs.la \
+ libutil.a libcompat.a
test_fstree_sort_SOURCES = lib/fstree/test/fstree_sort.c
-test_fstree_sort_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
+test_fstree_sort_LDADD = libcommon.a libfstree.a libsquashfs.la \
+ libutil.a libcompat.a
FSTREE_TESTS = \
test_mknode_simple test_mknode_dir test_gen_inode_numbers \
diff --git a/lib/fstree/src/fstree.c b/lib/fstree/src/fstree.c
index 432a380..225fcf0 100644
--- a/lib/fstree/src/fstree.c
+++ b/lib/fstree/src/fstree.c
@@ -102,7 +102,7 @@ static tree_node_t *mknode(fstree_t *fs, tree_node_t *parent, const char *name,
ptr = n->name + name_len + 1;
strcpy(ptr, extra);
- if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) {
+ if (ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) {
if (canonicalize_name(ptr)) {
free(n);
errno = EINVAL;
@@ -113,7 +113,7 @@ static tree_node_t *mknode(fstree_t *fs, tree_node_t *parent, const char *name,
ptr = NULL;
}
- if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) {
+ if (ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) {
n->mode = S_IFLNK | 0777;
n->flags |= FLAG_LINK_IS_HARD;
}
@@ -143,7 +143,7 @@ static tree_node_t *mknode(fstree_t *fs, tree_node_t *parent, const char *name,
return NULL;
}
- if (ent->flags & DIR_ENTRY_FLAG_HARD_LINK) {
+ if (ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) {
n->next_by_type = fs->links_unresolved;
fs->links_unresolved = n;
}
diff --git a/lib/fstree/test/add_by_path.c b/lib/fstree/test/add_by_path.c
index b9f4b75..d59467c 100644
--- a/lib/fstree/test/add_by_path.c
+++ b/lib/fstree/test/add_by_path.c
@@ -13,10 +13,9 @@
static sqfs_dir_entry_t *mkentry(const char *name, sqfs_u16 mode, sqfs_u32 uid,
sqfs_u32 gid)
{
- sqfs_dir_entry_t *ent = dir_entry_create(name);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(name, mode, 0);
TEST_NOT_NULL(ent);
- ent->mode = mode;
ent->uid = uid;
ent->gid = gid;
return ent;
diff --git a/lib/fstree/test/fstree_sort.c b/lib/fstree/test/fstree_sort.c
index 6f20ce7..a5f83ac 100644
--- a/lib/fstree/test/fstree_sort.c
+++ b/lib/fstree/test/fstree_sort.c
@@ -12,11 +12,10 @@
static tree_node_t *mkentry(fstree_t *fs, const char *name)
{
- sqfs_dir_entry_t *ent = dir_entry_create(name);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(name, S_IFBLK | 0600, 0);
tree_node_t *out;
TEST_NOT_NULL(ent);
- ent->mode = S_IFBLK | 0600;
ent->rdev = 1337;
out = fstree_add_generic(fs, ent, NULL);
diff --git a/lib/fstree/test/gen_inode_numbers.c b/lib/fstree/test/gen_inode_numbers.c
index 34d8322..1a3ec4c 100644
--- a/lib/fstree/test/gen_inode_numbers.c
+++ b/lib/fstree/test/gen_inode_numbers.c
@@ -12,12 +12,10 @@
static tree_node_t *gen_node(fstree_t *fs, const char *path)
{
- sqfs_dir_entry_t *ent = dir_entry_create(path);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(path, S_IFDIR | 0755, 0);
tree_node_t *ret;
TEST_NOT_NULL(ent);
- ent->mode = S_IFDIR | 0755;
-
ret = fstree_add_generic(fs, ent, NULL);
free(ent);
return ret;
diff --git a/lib/fstree/test/get_path.c b/lib/fstree/test/get_path.c
index f248c79..57eb5ab 100644
--- a/lib/fstree/test/get_path.c
+++ b/lib/fstree/test/get_path.c
@@ -12,9 +12,8 @@
static sqfs_dir_entry_t *mkentry(const char *name)
{
- sqfs_dir_entry_t *ent = dir_entry_create(name);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(name, S_IFDIR | 0750, 0);
TEST_NOT_NULL(ent);
- ent->mode = S_IFDIR | 0750;
ent->uid = 1000;
ent->gid = 100;
return ent;
diff --git a/lib/fstree/test/mknode_dir.c b/lib/fstree/test/mknode_dir.c
index f852706..08a1b13 100644
--- a/lib/fstree/test/mknode_dir.c
+++ b/lib/fstree/test/mknode_dir.c
@@ -11,9 +11,8 @@
static sqfs_dir_entry_t *mkentry(const char *name)
{
- sqfs_dir_entry_t *ent = dir_entry_create(name);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(name, S_IFDIR | 0654, 0);
TEST_NOT_NULL(ent);
- ent->mode = S_IFDIR | 0654;
ent->uid = 123;
ent->gid = 456;
ent->rdev = 789;
diff --git a/lib/fstree/test/mknode_simple.c b/lib/fstree/test/mknode_simple.c
index d871c5a..5af6d5f 100644
--- a/lib/fstree/test/mknode_simple.c
+++ b/lib/fstree/test/mknode_simple.c
@@ -11,9 +11,8 @@
static sqfs_dir_entry_t *mkentry(const char *name, sqfs_u16 mode)
{
- sqfs_dir_entry_t *ent = dir_entry_create(name);
+ sqfs_dir_entry_t *ent = sqfs_dir_entry_create(name, mode | 0654, 0);
TEST_NOT_NULL(ent);
- ent->mode = mode | 0654;
ent->uid = 123;
ent->gid = 456;
ent->rdev = 789;
diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am
index 732c15b..c2d1a15 100644
--- a/lib/io/Makemodule.am
+++ b/lib/io/Makemodule.am
@@ -1,8 +1,8 @@
-libio_a_SOURCES = include/io/xfrm.h include/io/std.h include/io/dir_entry.h \
+libio_a_SOURCES = include/io/xfrm.h include/io/std.h \
include/io/dir_iterator.h include/io/mem.h lib/io/src/internal.h \
lib/io/src/xfrm/ostream.c \
lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c \
- lib/io/src/dir_entry.c lib/io/src/mem.c lib/io/src/std.c
+ lib/io/src/mem.c lib/io/src/std.c
libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS)
libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS)
@@ -23,22 +23,22 @@ test_istream_mem_LDADD = libio.a libcompat.a
test_istream_mem_CPPFLAGS = $(AM_CPPFLAGS)
test_dir_iterator_SOURCES = lib/io/test/dir_iterator.c
-test_dir_iterator_LDADD = libio.a libutil.a libcompat.a
+test_dir_iterator_LDADD = libio.a libsquashfs.la libutil.a libcompat.a
test_dir_iterator_CPPFLAGS = $(AM_CPPFLAGS)
test_dir_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
test_dir_tree_iterator_SOURCES = lib/io/test/dir_tree_iterator.c
-test_dir_tree_iterator_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator_LDADD = libio.a libsquashfs.la libutil.a libcompat.a
test_dir_tree_iterator_CPPFLAGS = $(AM_CPPFLAGS)
test_dir_tree_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
test_dir_tree_iterator2_SOURCES = lib/io/test/dir_tree_iterator2.c
-test_dir_tree_iterator2_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator2_LDADD = libio.a libsquashfs.la libutil.a libcompat.a
test_dir_tree_iterator2_CPPFLAGS = $(AM_CPPFLAGS)
test_dir_tree_iterator2_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
test_dir_tree_iterator3_SOURCES = lib/io/test/dir_tree_iterator3.c
-test_dir_tree_iterator3_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator3_LDADD = libio.a libsquashfs.la libutil.a libcompat.a
test_dir_tree_iterator3_CPPFLAGS = $(AM_CPPFLAGS)
test_dir_tree_iterator3_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
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;
}
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index e929286..0efd39b 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -8,7 +8,8 @@ LIBSQFS_HEARDS = include/sqfs/meta_writer.h \
include/sqfs/dir_writer.h include/sqfs/io.h \
include/sqfs/data_reader.h include/sqfs/block.h \
include/sqfs/xattr_reader.h include/sqfs/xattr_writer.h \
- include/sqfs/frag_table.h include/sqfs/block_writer.h
+ include/sqfs/frag_table.h include/sqfs/block_writer.h \
+ include/sqfs/dir_entry.h
libsquashfs_la_SOURCES = $(LIBSQFS_HEARDS) lib/sqfs/src/id_table.c \
lib/sqfs/src/super.c lib/sqfs/src/readdir.c lib/sqfs/src/xattr/xattr.c \
@@ -33,7 +34,7 @@ libsquashfs_la_SOURCES = $(LIBSQFS_HEARDS) lib/sqfs/src/id_table.c \
lib/sqfs/src/frag_table.c lib/sqfs/src/block_writer.c \
lib/sqfs/src/misc.c lib/sqfs/src/io/istream.c \
lib/sqfs/src/io/ostream.c lib/sqfs/src/io/file.c \
- lib/sqfs/src/io/stream_api.c
+ lib/sqfs/src/io/stream_api.c lib/sqfs/src/dir_entry.c
libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS)
libsquashfs_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBSQUASHFS_SO_VERSION)
libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
diff --git a/lib/io/src/dir_entry.c b/lib/sqfs/src/dir_entry.c
index 1bfc887..8290ac8 100644
--- a/lib/io/src/dir_entry.c
+++ b/lib/sqfs/src/dir_entry.c
@@ -1,19 +1,26 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* dir_entry.c
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "io/dir_entry.h"
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
+#include "sqfs/dir_entry.h"
#include "compat.h"
#include <stdlib.h>
#include <string.h>
-sqfs_dir_entry_t *dir_entry_create(const char *name)
+sqfs_dir_entry_t *sqfs_dir_entry_create(const char *name, sqfs_u16 mode,
+ sqfs_u16 flags)
{
- size_t len, name_len;
sqfs_dir_entry_t *out;
+ size_t len, name_len;
+
+ if (flags & ~SQFS_DIR_ENTRY_FLAG_ALL)
+ return NULL;
name_len = strlen(name);
if (SZ_ADD_OV(name_len, 1, &name_len))
@@ -25,6 +32,8 @@ sqfs_dir_entry_t *dir_entry_create(const char *name)
if (out == NULL)
return NULL;
+ out->mode = mode;
+ out->flags = flags;
memcpy(out->name, name, name_len);
return out;
}
diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c
index b11be77..6b456d6 100644
--- a/lib/tar/src/iterator.c
+++ b/lib/tar/src/iterator.c
@@ -209,7 +209,7 @@ retry:
return tar->state;
}
- *out = dir_entry_create(tar->current.name);
+ *out = sqfs_dir_entry_create(tar->current.name, tar->current.mode, 0);
if ((*out) == NULL) {
tar->state = SQFS_ERROR_ALLOC;
return tar->state;
@@ -219,11 +219,10 @@ retry:
(*out)->rdev = tar->current.devno;
(*out)->uid = tar->current.uid;
(*out)->gid = tar->current.gid;
- (*out)->mode = tar->current.mode;
if (tar->current.is_hard_link) {
(*out)->mode = (S_IFLNK | 0777);
- (*out)->flags |= DIR_ENTRY_FLAG_HARD_LINK;
+ (*out)->flags |= SQFS_DIR_ENTRY_FLAG_HARD_LINK;
}
if (S_ISREG((*out)->mode))
diff --git a/lib/tar/test/tar_iterator3.c b/lib/tar/test/tar_iterator3.c
index 36a9060..f8d0bda 100644
--- a/lib/tar/test/tar_iterator3.c
+++ b/lib/tar/test/tar_iterator3.c
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
"20CharsForLnkTest003/20CharsForLnkTest004/"
"01234567890123456789");
TEST_EQUAL_UI(ent->mode, S_IFLNK | 0777);
- TEST_ASSERT((ent->flags & DIR_ENTRY_FLAG_HARD_LINK) != 0);
+ TEST_ASSERT((ent->flags & SQFS_DIR_ENTRY_FLAG_HARD_LINK) != 0);
free(ent);
ret = it->read_link(it, &link);