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/sqfs | |
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/sqfs')
-rw-r--r-- | lib/sqfs/Makemodule.am | 5 | ||||
-rw-r--r-- | lib/sqfs/src/dir_entry.c | 39 |
2 files changed, 42 insertions, 2 deletions
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/sqfs/src/dir_entry.c b/lib/sqfs/src/dir_entry.c new file mode 100644 index 0000000..8290ac8 --- /dev/null +++ b/lib/sqfs/src/dir_entry.c @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * dir_entry.c + * + * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at> + */ +#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 *sqfs_dir_entry_create(const char *name, sqfs_u16 mode, + sqfs_u16 flags) +{ + 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)) + return NULL; + if (SZ_ADD_OV(sizeof(*out), name_len, &len)) + return NULL; + + out = calloc(1, len); + if (out == NULL) + return NULL; + + out->mode = mode; + out->flags = flags; + memcpy(out->name, name, name_len); + return out; +} |