aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
15 files changed, 46 insertions, 42 deletions
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);