aboutsummaryrefslogtreecommitdiff
path: root/lib/io
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 /lib/io
parentec593e0b94656a5481f82ee0f33728ced297ac48 (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')
-rw-r--r--lib/io/Makemodule.am12
-rw-r--r--lib/io/src/dir_entry.c30
-rw-r--r--lib/io/src/dir_tree_iterator.c2
-rw-r--r--lib/io/src/unix/dir_iterator.c5
4 files changed, 9 insertions, 40 deletions
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_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;
}