From e7ecb1f92ae618a56ee8eabb6cbf98365de3695a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 2 Jul 2023 19:50:05 +0200 Subject: Move sqfs_dir_entry_t code from libio into libsquashfs Signed-off-by: David Oberhollenzer --- include/fstree.h | 2 +- include/io/dir_entry.h | 97 -------------------------------------------- include/io/dir_iterator.h | 2 +- include/sqfs/dir_entry.h | 101 ++++++++++++++++++++++++++++++++++++++++++++++ include/sqfs/predef.h | 1 + 5 files changed, 104 insertions(+), 99 deletions(-) delete mode 100644 include/io/dir_entry.h create mode 100644 include/sqfs/dir_entry.h (limited to 'include') 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 #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_entry.h b/include/io/dir_entry.h deleted file mode 100644 index 8ff8cf0..0000000 --- a/include/io/dir_entry.h +++ /dev/null @@ -1,97 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * dir_entry.h - * - * Copyright (C) 2023 David Oberhollenzer - */ -#ifndef IO_DIR_ENTRY_H -#define IO_DIR_ENTRY_H - -#include "sqfs/predef.h" - -typedef enum { - DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001, - - DIR_ENTRY_FLAG_HARD_LINK = 0x0002, -} DIR_ENTRY_FLAG; - -/** - * @struct sqfs_dir_entry_t - * - * @brief A directory entry returned by a @ref dir_iterator_t - */ -typedef struct { - /** - * @brief Total size of file entries - */ - sqfs_u64 size; - - /** - * @brief Unix time stamp when the entry was last modified. - * - * If necessary, the OS native time stamp is converted to Unix time. - */ - sqfs_s64 mtime; - - /** - * @brief Device number where the entry is stored on. - * - * On Windows and other non-Unix OSes, a dummy value is stored here. - */ - sqfs_u64 dev; - - /** - * @brief Device number for device special files. - * - * On Windows and other non-Unix OSes, a dummy value is stored here. - */ - sqfs_u64 rdev; - - /** - * @brief ID of the user that owns the entry. - * - * On Windows and other non-Unix OSes, this always reports user 0. - */ - sqfs_u64 uid; - - /** - * @brief ID of the group that owns the entry. - * - * On Windows and other non-Unix OSes, this always reports group 0. - */ - sqfs_u64 gid; - - /** - * @brief Unix style permissions and entry type. - * - * On Windows and other non-Unix OSes, this is synthesized from the - * Unix-like file type, default 0755 permissions for directories or - * 0644 for files. - */ - sqfs_u16 mode; - - /** - * @brief Combination of DIR_ENTRY_FLAG values - */ - sqfs_u16 flags; - - /** - * @brief Name of the entry - * - * On Unix-like OSes, the name is returned as-is. On systems like - * 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); - -#ifdef __cplusplus -} -#endif - -#endif /* IO_DIR_ENTRY_H */ 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/sqfs/dir_entry.h b/include/sqfs/dir_entry.h new file mode 100644 index 0000000..5f80bab --- /dev/null +++ b/include/sqfs/dir_entry.h @@ -0,0 +1,101 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * dir_entry.h + * + * Copyright (C) 2023 David Oberhollenzer + */ +#ifndef SQFS_DIR_ENTRY_H +#define SQFS_DIR_ENTRY_H + +#include "sqfs/predef.h" + +typedef enum { + SQFS_DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001, + + 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 + */ +struct sqfs_dir_entry_t { + /** + * @brief Total size of file entries + */ + sqfs_u64 size; + + /** + * @brief Unix time stamp when the entry was last modified. + * + * If necessary, the OS native time stamp is converted to Unix time. + */ + sqfs_s64 mtime; + + /** + * @brief Device number where the entry is stored on. + * + * On Windows and other non-Unix OSes, a dummy value is stored here. + */ + sqfs_u64 dev; + + /** + * @brief Device number for device special files. + * + * On Windows and other non-Unix OSes, a dummy value is stored here. + */ + sqfs_u64 rdev; + + /** + * @brief ID of the user that owns the entry. + * + * On Windows and other non-Unix OSes, this always reports user 0. + */ + sqfs_u64 uid; + + /** + * @brief ID of the group that owns the entry. + * + * On Windows and other non-Unix OSes, this always reports group 0. + */ + sqfs_u64 gid; + + /** + * @brief Unix style permissions and entry type. + * + * On Windows and other non-Unix OSes, this is synthesized from the + * Unix-like file type, default 0755 permissions for directories or + * 0644 for files. + */ + sqfs_u16 mode; + + /** + * @brief Combination of SQFS_DIR_ENTRY_FLAG values + */ + sqfs_u16 flags; + + /** + * @brief Name of the entry + * + * On Unix-like OSes, the name is returned as-is. On systems like + * Windows with encoding-aware APIs, the name is converted to UTF-8. + */ + char name[]; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +SQFS_API sqfs_dir_entry_t *sqfs_dir_entry_create(const char *name, + sqfs_u16 mode, + sqfs_u16 flags); + +#ifdef __cplusplus +} +#endif + +#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; -- cgit v1.2.3