aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 15:53:44 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 15:53:44 +0200
commita901d77efe116938bdaf5c0fc6075141ebb2bafc (patch)
treea6f97a891410c4159c80eafeb23b7d34c92f970f
parent9533dc84d7addf792db4f4702b6fc7d7ddd20e78 (diff)
Break up squashfs.h into topic related headers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/data_reader.h2
-rw-r--r--include/data_writer.h2
-rw-r--r--include/highlevel.h3
-rw-r--r--include/sqfs/compress.h2
-rw-r--r--include/sqfs/data.h28
-rw-r--r--include/sqfs/dir.h37
-rw-r--r--include/sqfs/inode.h131
-rw-r--r--include/sqfs/meta_reader.h6
-rw-r--r--include/sqfs/meta_writer.h6
-rw-r--r--include/sqfs/squashfs.h272
-rw-r--r--include/sqfs/super.h79
-rw-r--r--include/sqfs/xattr.h57
-rw-r--r--include/xattr_reader.h2
-rw-r--r--lib/Makemodule.am8
-rw-r--r--lib/sqfs/meta_writer.c2
-rw-r--r--lib/sqfs/read_super.c2
-rw-r--r--lib/sqfs/super.c2
-rw-r--r--lib/sqfs/xattr.c2
-rw-r--r--lib/sqfshelper/write_dir.c2
-rw-r--r--lib/sqfshelper/write_inode.c2
-rw-r--r--lib/sqfshelper/write_xattr.c1
-rw-r--r--lib/sqfshelper/xattr_reader.c1
-rw-r--r--mkfs/mkfs.h2
-rw-r--r--tar/tar2sqfs.c3
-rw-r--r--unpack/rdsquashfs.h2
25 files changed, 365 insertions, 291 deletions
diff --git a/include/data_reader.h b/include/data_reader.h
index 4a4763e..feba7a1 100644
--- a/include/data_reader.h
+++ b/include/data_reader.h
@@ -9,8 +9,8 @@
#include "config.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
+#include "sqfs/data.h"
#include "fstree.h"
typedef struct data_reader_t data_reader_t;
diff --git a/include/data_writer.h b/include/data_writer.h
index 7b1142f..081c468 100644
--- a/include/data_writer.h
+++ b/include/data_writer.h
@@ -9,8 +9,8 @@
#include "config.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
+#include "sqfs/data.h"
#include "fstree.h"
#include "util.h"
diff --git a/include/highlevel.h b/include/highlevel.h
index aae02cf..bea674e 100644
--- a/include/highlevel.h
+++ b/include/highlevel.h
@@ -9,9 +9,10 @@
#include "config.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
#include "sqfs/id_table.h"
+#include "sqfs/inode.h"
+#include "sqfs/data.h"
#include "data_reader.h"
#include "fstree.h"
diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h
index 1dfba12..c6de185 100644
--- a/include/sqfs/compress.h
+++ b/include/sqfs/compress.h
@@ -14,7 +14,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "squashfs.h"
+#include "sqfs/super.h"
typedef struct compressor_t compressor_t;
diff --git a/include/sqfs/data.h b/include/sqfs/data.h
new file mode 100644
index 0000000..1b70f45
--- /dev/null
+++ b/include/sqfs/data.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * data.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_DATA_H
+#define SQFS_DATA_H
+
+#include "config.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+
+#define SQFS_META_BLOCK_SIZE 8192
+
+#define SQFS_IS_BLOCK_COMPRESSED(size) (((size) & (1 << 24)) == 0)
+#define SQFS_ON_DISK_BLOCK_SIZE(size) ((size) & ((1 << 24) - 1))
+#define SQFS_IS_SPARSE_BLOCK(size) (SQFS_ON_DISK_BLOCK_SIZE(size) == 0)
+
+typedef struct {
+ uint64_t start_offset;
+ uint32_t size;
+ uint32_t pad0;
+} sqfs_fragment_t;
+
+#endif /* SQFS_DATA_H */
diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h
new file mode 100644
index 0000000..a1ca69c
--- /dev/null
+++ b/include/sqfs/dir.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * dir.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_DIR_H
+#define SQFS_DIR_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+#define SQFS_MAX_DIR_ENT 256
+
+typedef struct {
+ uint32_t count;
+ uint32_t start_block;
+ uint32_t inode_number;
+} sqfs_dir_header_t;
+
+typedef struct {
+ uint16_t offset;
+ int16_t inode_diff;
+ uint16_t type;
+ uint16_t size;
+ uint8_t name[];
+} sqfs_dir_entry_t;
+
+typedef struct {
+ uint32_t index;
+ uint32_t start_block;
+ uint32_t size;
+ uint8_t name[];
+} sqfs_dir_index_t;
+
+#endif /* SQFS_DIR_H */
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
new file mode 100644
index 0000000..ac809d3
--- /dev/null
+++ b/include/sqfs/inode.h
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * inode.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_INODE_H
+#define SQFS_INODE_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+typedef enum {
+ SQFS_INODE_DIR = 1,
+ SQFS_INODE_FILE = 2,
+ SQFS_INODE_SLINK = 3,
+ SQFS_INODE_BDEV = 4,
+ SQFS_INODE_CDEV = 5,
+ SQFS_INODE_FIFO = 6,
+ SQFS_INODE_SOCKET = 7,
+ SQFS_INODE_EXT_DIR = 8,
+ SQFS_INODE_EXT_FILE = 9,
+ SQFS_INODE_EXT_SLINK = 10,
+ SQFS_INODE_EXT_BDEV = 11,
+ SQFS_INODE_EXT_CDEV = 12,
+ SQFS_INODE_EXT_FIFO = 13,
+ SQFS_INODE_EXT_SOCKET = 14,
+} E_SQFS_INODE_TYPE;
+
+typedef struct {
+ uint16_t type;
+ uint16_t mode;
+ uint16_t uid_idx;
+ uint16_t gid_idx;
+ uint32_t mod_time;
+ uint32_t inode_number;
+} sqfs_inode_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t devno;
+} sqfs_inode_dev_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t devno;
+ uint32_t xattr_idx;
+} sqfs_inode_dev_ext_t;
+
+typedef struct {
+ uint32_t nlink;
+} sqfs_inode_ipc_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t xattr_idx;
+} sqfs_inode_ipc_ext_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t target_size;
+ /*uint8_t target[];*/
+} sqfs_inode_slink_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t target_size;
+ /*uint8_t target[];*/
+ uint32_t xattr_idx;
+} sqfs_inode_slink_ext_t;
+
+typedef struct {
+ uint32_t blocks_start;
+ uint32_t fragment_index;
+ uint32_t fragment_offset;
+ uint32_t file_size;
+ /*uint32_t block_sizes[];*/
+} sqfs_inode_file_t;
+
+typedef struct {
+ uint64_t blocks_start;
+ uint64_t file_size;
+ uint64_t sparse;
+ uint32_t nlink;
+ uint32_t fragment_idx;
+ uint32_t fragment_offset;
+ uint32_t xattr_idx;
+ /*uint32_t block_sizes[];*/
+} sqfs_inode_file_ext_t;
+
+typedef struct {
+ uint32_t start_block;
+ uint32_t nlink;
+ uint16_t size;
+ uint16_t offset;
+ uint32_t parent_inode;
+} sqfs_inode_dir_t;
+
+typedef struct {
+ uint32_t nlink;
+ uint32_t size;
+ uint32_t start_block;
+ uint32_t parent_inode;
+ uint16_t inodex_count;
+ uint16_t offset;
+ uint32_t xattr_idx;
+} sqfs_inode_dir_ext_t;
+
+typedef struct {
+ sqfs_inode_t base;
+ char *slink_target;
+ uint32_t *block_sizes;
+
+ union {
+ sqfs_inode_dev_t dev;
+ sqfs_inode_dev_ext_t dev_ext;
+ sqfs_inode_ipc_t ipc;
+ sqfs_inode_ipc_ext_t ipc_ext;
+ sqfs_inode_slink_t slink;
+ sqfs_inode_slink_ext_t slink_ext;
+ sqfs_inode_file_t file;
+ sqfs_inode_file_ext_t file_ext;
+ sqfs_inode_dir_t dir;
+ sqfs_inode_dir_ext_t dir_ext;
+ } data;
+
+ uint8_t extra[];
+} sqfs_inode_generic_t;
+
+#endif /* SQFS_INODE_H */
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index d5628af..0de7401 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -9,8 +9,10 @@
#include "config.h"
-#include "compress.h"
-#include "squashfs.h"
+#include "sqfs/compress.h"
+#include "sqfs/inode.h"
+#include "sqfs/data.h"
+#include "sqfs/dir.h"
typedef struct meta_reader_t meta_reader_t;
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index 762cc38..6c56c93 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -9,9 +9,9 @@
#include "config.h"
-#include "compress.h"
-#include "squashfs.h"
-#include "id_table.h"
+#include "sqfs/compress.h"
+#include "sqfs/id_table.h"
+#include "sqfs/data.h"
#include "fstree.h"
typedef struct {
diff --git a/include/sqfs/squashfs.h b/include/sqfs/squashfs.h
deleted file mode 100644
index eb35fdd..0000000
--- a/include/sqfs/squashfs.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * squashfs.h
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#ifndef SQUASHFS_H
-#define SQUASHFS_H
-
-#include "config.h"
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stddef.h>
-
-#define SQFS_MAGIC 0x73717368
-#define SQFS_VERSION_MAJOR 4
-#define SQFS_VERSION_MINOR 0
-#define SQFS_META_BLOCK_SIZE 8192
-#define SQFS_DEFAULT_BLOCK_SIZE 131072
-#define SQFS_DEVBLK_SIZE 4096
-#define SQFS_MAX_DIR_ENT 256
-
-#define SQFS_IS_BLOCK_COMPRESSED(size) (((size) & (1 << 24)) == 0)
-#define SQFS_ON_DISK_BLOCK_SIZE(size) ((size) & ((1 << 24) - 1))
-#define SQFS_IS_SPARSE_BLOCK(size) (SQFS_ON_DISK_BLOCK_SIZE(size) == 0)
-
-typedef struct {
- uint32_t magic;
- uint32_t inode_count;
- uint32_t modification_time;
- uint32_t block_size;
- uint32_t fragment_entry_count;
- uint16_t compression_id;
- uint16_t block_log;
- uint16_t flags;
- uint16_t id_count;
- uint16_t version_major;
- uint16_t version_minor;
- uint64_t root_inode_ref;
- uint64_t bytes_used;
- uint64_t id_table_start;
- uint64_t xattr_id_table_start;
- uint64_t inode_table_start;
- uint64_t directory_table_start;
- uint64_t fragment_table_start;
- uint64_t export_table_start;
-} __attribute__((packed)) sqfs_super_t;
-
-typedef struct {
- uint64_t start_offset;
- uint32_t size;
- uint32_t pad0;
-} sqfs_fragment_t;
-
-typedef struct {
- uint16_t type;
- uint16_t mode;
- uint16_t uid_idx;
- uint16_t gid_idx;
- uint32_t mod_time;
- uint32_t inode_number;
-} sqfs_inode_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t devno;
-} sqfs_inode_dev_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t devno;
- uint32_t xattr_idx;
-} sqfs_inode_dev_ext_t;
-
-typedef struct {
- uint32_t nlink;
-} sqfs_inode_ipc_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t xattr_idx;
-} sqfs_inode_ipc_ext_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t target_size;
- /*uint8_t target[];*/
-} sqfs_inode_slink_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t target_size;
- /*uint8_t target[];*/
- uint32_t xattr_idx;
-} sqfs_inode_slink_ext_t;
-
-typedef struct {
- uint32_t blocks_start;
- uint32_t fragment_index;
- uint32_t fragment_offset;
- uint32_t file_size;
- /*uint32_t block_sizes[];*/
-} sqfs_inode_file_t;
-
-typedef struct {
- uint64_t blocks_start;
- uint64_t file_size;
- uint64_t sparse;
- uint32_t nlink;
- uint32_t fragment_idx;
- uint32_t fragment_offset;
- uint32_t xattr_idx;
- /*uint32_t block_sizes[];*/
-} sqfs_inode_file_ext_t;
-
-typedef struct {
- uint32_t start_block;
- uint32_t nlink;
- uint16_t size;
- uint16_t offset;
- uint32_t parent_inode;
-} sqfs_inode_dir_t;
-
-typedef struct {
- uint32_t nlink;
- uint32_t size;
- uint32_t start_block;
- uint32_t parent_inode;
- uint16_t inodex_count;
- uint16_t offset;
- uint32_t xattr_idx;
-} sqfs_inode_dir_ext_t;
-
-typedef struct {
- sqfs_inode_t base;
- char *slink_target;
- uint32_t *block_sizes;
-
- union {
- sqfs_inode_dev_t dev;
- sqfs_inode_dev_ext_t dev_ext;
- sqfs_inode_ipc_t ipc;
- sqfs_inode_ipc_ext_t ipc_ext;
- sqfs_inode_slink_t slink;
- sqfs_inode_slink_ext_t slink_ext;
- sqfs_inode_file_t file;
- sqfs_inode_file_ext_t file_ext;
- sqfs_inode_dir_t dir;
- sqfs_inode_dir_ext_t dir_ext;
- } data;
-
- uint8_t extra[];
-} sqfs_inode_generic_t;
-
-typedef struct {
- uint32_t count;
- uint32_t start_block;
- uint32_t inode_number;
-} sqfs_dir_header_t;
-
-typedef struct {
- uint16_t offset;
- int16_t inode_diff;
- uint16_t type;
- uint16_t size;
- uint8_t name[];
-} sqfs_dir_entry_t;
-
-typedef struct {
- uint32_t index;
- uint32_t start_block;
- uint32_t size;
- uint8_t name[];
-} sqfs_dir_index_t;
-
-typedef struct {
- uint16_t type;
- uint16_t size;
- uint8_t key[];
-} sqfs_xattr_entry_t;
-
-typedef struct {
- uint32_t size;
- uint8_t value[];
-} sqfs_xattr_value_t;
-
-typedef struct {
- uint64_t xattr;
- uint32_t count;
- uint32_t size;
-} sqfs_xattr_id_t;
-
-typedef struct {
- uint64_t xattr_table_start;
- uint32_t xattr_ids;
- uint32_t unused;
-} sqfs_xattr_id_table_t;
-
-
-typedef enum {
- SQFS_COMP_GZIP = 1,
- SQFS_COMP_LZMA = 2,
- SQFS_COMP_LZO = 3,
- SQFS_COMP_XZ = 4,
- SQFS_COMP_LZ4 = 5,
- SQFS_COMP_ZSTD = 6,
-
- SQFS_COMP_MIN = 1,
- SQFS_COMP_MAX = 6,
-} E_SQFS_COMPRESSOR;
-
-typedef enum {
- SQFS_FLAG_UNCOMPRESSED_INODES = 0x0001,
- SQFS_FLAG_UNCOMPRESSED_DATA = 0x0002,
- SQFS_FLAG_UNCOMPRESSED_FRAGMENTS = 0x0008,
- SQFS_FLAG_NO_FRAGMENTS = 0x0010,
- SQFS_FLAG_ALWAYS_FRAGMENTS = 0x0020,
- SQFS_FLAG_DUPLICATES = 0x0040,
- SQFS_FLAG_EXPORTABLE = 0x0080,
- SQFS_FLAG_UNCOMPRESSED_XATTRS = 0x0100,
- SQFS_FLAG_NO_XATTRS = 0x0200,
- SQFS_FLAG_COMPRESSOR_OPTIONS = 0x0400,
- SQFS_FLAG_UNCOMPRESSED_IDS = 0x0800,
-} E_SQFS_SUPER_FLAGS;
-
-typedef enum {
- SQFS_INODE_DIR = 1,
- SQFS_INODE_FILE = 2,
- SQFS_INODE_SLINK = 3,
- SQFS_INODE_BDEV = 4,
- SQFS_INODE_CDEV = 5,
- SQFS_INODE_FIFO = 6,
- SQFS_INODE_SOCKET = 7,
- SQFS_INODE_EXT_DIR = 8,
- SQFS_INODE_EXT_FILE = 9,
- SQFS_INODE_EXT_SLINK = 10,
- SQFS_INODE_EXT_BDEV = 11,
- SQFS_INODE_EXT_CDEV = 12,
- SQFS_INODE_EXT_FIFO = 13,
- SQFS_INODE_EXT_SOCKET = 14,
-} E_SQFS_INODE_TYPE;
-
-typedef enum {
- SQUASHFS_XATTR_USER = 0,
- SQUASHFS_XATTR_TRUSTED = 1,
- SQUASHFS_XATTR_SECURITY = 2,
-
- SQUASHFS_XATTR_FLAG_OOL = 0x100,
- SQUASHFS_XATTR_PREFIX_MASK = 0xFF,
-} E_SQFS_XATTR_TYPE;
-
-/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
- E_SQFS_COMPRESSOR compressor);
-
-/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_write(sqfs_super_t *super, int fd);
-
-/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_read(sqfs_super_t *super, int fd);
-
-/* Get id from xattr key prefix or -1 if not supported */
-int sqfs_get_xattr_prefix_id(const char *key);
-
-/* Get a prefix string from the ID or NULL if unknown */
-const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id);
-
-/* Check if a given xattr key can be encoded in squashfs at all. */
-bool sqfs_has_xattr(const char *key);
-
-#endif /* SQUASHFS_H */
diff --git a/include/sqfs/super.h b/include/sqfs/super.h
new file mode 100644
index 0000000..51a3a9e
--- /dev/null
+++ b/include/sqfs/super.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * super.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_SUPER_H
+#define SQFS_SUPER_H
+
+#include "config.h"
+
+#include <stdint.h>
+#include <stddef.h>
+
+#define SQFS_MAGIC 0x73717368
+#define SQFS_VERSION_MAJOR 4
+#define SQFS_VERSION_MINOR 0
+#define SQFS_DEVBLK_SIZE 4096
+#define SQFS_DEFAULT_BLOCK_SIZE 131072
+
+typedef struct {
+ uint32_t magic;
+ uint32_t inode_count;
+ uint32_t modification_time;
+ uint32_t block_size;
+ uint32_t fragment_entry_count;
+ uint16_t compression_id;
+ uint16_t block_log;
+ uint16_t flags;
+ uint16_t id_count;
+ uint16_t version_major;
+ uint16_t version_minor;
+ uint64_t root_inode_ref;
+ uint64_t bytes_used;
+ uint64_t id_table_start;
+ uint64_t xattr_id_table_start;
+ uint64_t inode_table_start;
+ uint64_t directory_table_start;
+ uint64_t fragment_table_start;
+ uint64_t export_table_start;
+} __attribute__((packed)) sqfs_super_t;
+
+typedef enum {
+ SQFS_COMP_GZIP = 1,
+ SQFS_COMP_LZMA = 2,
+ SQFS_COMP_LZO = 3,
+ SQFS_COMP_XZ = 4,
+ SQFS_COMP_LZ4 = 5,
+ SQFS_COMP_ZSTD = 6,
+
+ SQFS_COMP_MIN = 1,
+ SQFS_COMP_MAX = 6,
+} E_SQFS_COMPRESSOR;
+
+typedef enum {
+ SQFS_FLAG_UNCOMPRESSED_INODES = 0x0001,
+ SQFS_FLAG_UNCOMPRESSED_DATA = 0x0002,
+ SQFS_FLAG_UNCOMPRESSED_FRAGMENTS = 0x0008,
+ SQFS_FLAG_NO_FRAGMENTS = 0x0010,
+ SQFS_FLAG_ALWAYS_FRAGMENTS = 0x0020,
+ SQFS_FLAG_DUPLICATES = 0x0040,
+ SQFS_FLAG_EXPORTABLE = 0x0080,
+ SQFS_FLAG_UNCOMPRESSED_XATTRS = 0x0100,
+ SQFS_FLAG_NO_XATTRS = 0x0200,
+ SQFS_FLAG_COMPRESSOR_OPTIONS = 0x0400,
+ SQFS_FLAG_UNCOMPRESSED_IDS = 0x0800,
+} E_SQFS_SUPER_FLAGS;
+
+/* Returns 0 on success. Prints error messages to stderr on failure. */
+int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
+ E_SQFS_COMPRESSOR compressor);
+
+/* Returns 0 on success. Prints error messages to stderr on failure. */
+int sqfs_super_write(sqfs_super_t *super, int fd);
+
+/* Returns 0 on success. Prints error messages to stderr on failure. */
+int sqfs_super_read(sqfs_super_t *super, int fd);
+
+#endif /* SQFS_SUPER_H */
diff --git a/include/sqfs/xattr.h b/include/sqfs/xattr.h
new file mode 100644
index 0000000..3d5da39
--- /dev/null
+++ b/include/sqfs/xattr.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * xattr.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_XATTR_H
+#define SQFS_XATTR_H
+
+#include "config.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+
+typedef enum {
+ SQUASHFS_XATTR_USER = 0,
+ SQUASHFS_XATTR_TRUSTED = 1,
+ SQUASHFS_XATTR_SECURITY = 2,
+
+ SQUASHFS_XATTR_FLAG_OOL = 0x100,
+ SQUASHFS_XATTR_PREFIX_MASK = 0xFF,
+} E_SQFS_XATTR_TYPE;
+
+typedef struct {
+ uint16_t type;
+ uint16_t size;
+ uint8_t key[];
+} sqfs_xattr_entry_t;
+
+typedef struct {
+ uint32_t size;
+ uint8_t value[];
+} sqfs_xattr_value_t;
+
+typedef struct {
+ uint64_t xattr;
+ uint32_t count;
+ uint32_t size;
+} sqfs_xattr_id_t;
+
+typedef struct {
+ uint64_t xattr_table_start;
+ uint32_t xattr_ids;
+ uint32_t unused;
+} sqfs_xattr_id_table_t;
+
+/* Get a prefix string from the ID or NULL if unknown */
+const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id);
+
+/* Get id from xattr key prefix or -1 if not supported */
+int sqfs_get_xattr_prefix_id(const char *key);
+
+/* Check if a given xattr key can be encoded in squashfs at all. */
+bool sqfs_has_xattr(const char *key);
+
+#endif /* SQFS_XATTR_H */
diff --git a/include/xattr_reader.h b/include/xattr_reader.h
index d9fe37b..9cacd35 100644
--- a/include/xattr_reader.h
+++ b/include/xattr_reader.h
@@ -9,8 +9,8 @@
#include "config.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
+#include "sqfs/data.h"
#include "fstree.h"
typedef struct xattr_reader_t xattr_reader_t;
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index 284a57c..d29c169 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -42,9 +42,11 @@ libutil_la_SOURCES += lib/util/read_data_at.c lib/util/alloc.c
libutil_la_CFLAGS = $(AM_CFLAGS)
libutil_la_CPPFLAGS = $(AM_CPPFLAGS)
-libsquashfs_la_SOURCES = include/sqfs/squashfs.h include/sqfs/meta_writer.h
+libsquashfs_la_SOURCES = include/sqfs/data.h include/sqfs/meta_writer.h
libsquashfs_la_SOURCES += include/sqfs/meta_reader.h include/sqfs/id_table.h
libsquashfs_la_SOURCES += include/sqfs/compress.h include/sqfs/block_processor.h
+libsquashfs_la_SOURCES += include/sqfs/super.h include/sqfs/inode.h
+libsquashfs_la_SOURCES += include/sqfs/dir.h include/sqfs/xattr.h
libsquashfs_la_SOURCES += lib/sqfs/meta_writer.c lib/sqfs/super.c
libsquashfs_la_SOURCES += lib/sqfs/id_table.c
libsquashfs_la_SOURCES += lib/sqfs/write_table.c include/highlevel.h
@@ -104,9 +106,11 @@ libfstree_a_CPPFLAGS += -DWITH_SELINUX
endif
sqfsincludedir = $(includedir)/sqfs
-sqfsinclude_HEADERS = include/sqfs/squashfs.h include/sqfs/meta_writer.h
+sqfsinclude_HEADERS = include/sqfs/data.h include/sqfs/meta_writer.h
sqfsinclude_HEADERS += include/sqfs/meta_reader.h include/sqfs/id_table.h
sqfsinclude_HEADERS += include/sqfs/compress.h include/sqfs/block_processor.h
+sqfsinclude_HEADERS += include/sqfs/super.h include/sqfs/inode.h
+sqfsinclude_HEADERS += include/sqfs/dir.h include/sqfs/xattr.h
noinst_LIBRARIES += libfstree.a libtar.a libsqfshelper.a
noinst_LTLIBRARIES += libutil.la
diff --git a/lib/sqfs/meta_writer.c b/lib/sqfs/meta_writer.c
index 5fd31db..1f7825a 100644
--- a/lib/sqfs/meta_writer.c
+++ b/lib/sqfs/meta_writer.c
@@ -7,7 +7,7 @@
#include "config.h"
#include "sqfs/meta_writer.h"
-#include "sqfs/squashfs.h"
+#include "sqfs/data.h"
#include "util.h"
#include <string.h>
diff --git a/lib/sqfs/read_super.c b/lib/sqfs/read_super.c
index 094cad5..b9525b3 100644
--- a/lib/sqfs/read_super.c
+++ b/lib/sqfs/read_super.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "sqfs/squashfs.h"
+#include "sqfs/super.h"
#include "util.h"
#include <endian.h>
diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c
index f4ca6d9..728c0e1 100644
--- a/lib/sqfs/super.c
+++ b/lib/sqfs/super.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "sqfs/squashfs.h"
+#include "sqfs/super.h"
#include "util.h"
#include <endian.h>
diff --git a/lib/sqfs/xattr.c b/lib/sqfs/xattr.c
index 21bd7a5..fb8cb79 100644
--- a/lib/sqfs/xattr.c
+++ b/lib/sqfs/xattr.c
@@ -5,7 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "sqfs/squashfs.h"
+#include "sqfs/xattr.h"
#include <string.h>
diff --git a/lib/sqfshelper/write_dir.c b/lib/sqfshelper/write_dir.c
index 695a902..2b94667 100644
--- a/lib/sqfshelper/write_dir.c
+++ b/lib/sqfshelper/write_dir.c
@@ -7,6 +7,8 @@
#include "config.h"
#include "sqfs/meta_writer.h"
+#include "sqfs/inode.h"
+#include "sqfs/dir.h"
#include "util.h"
#include <assert.h>
diff --git a/lib/sqfshelper/write_inode.c b/lib/sqfshelper/write_inode.c
index c550c13..020eb64 100644
--- a/lib/sqfshelper/write_inode.c
+++ b/lib/sqfshelper/write_inode.c
@@ -7,6 +7,8 @@
#include "config.h"
#include "sqfs/meta_writer.h"
+#include "sqfs/inode.h"
+#include "sqfs/dir.h"
#include "util.h"
#include <assert.h>
diff --git a/lib/sqfshelper/write_xattr.c b/lib/sqfshelper/write_xattr.c
index 9255695..ddedc55 100644
--- a/lib/sqfshelper/write_xattr.c
+++ b/lib/sqfshelper/write_xattr.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "sqfs/meta_writer.h"
+#include "sqfs/xattr.h"
#include "highlevel.h"
#include "util.h"
diff --git a/lib/sqfshelper/xattr_reader.c b/lib/sqfshelper/xattr_reader.c
index 46e1146..c13358d 100644
--- a/lib/sqfshelper/xattr_reader.c
+++ b/lib/sqfshelper/xattr_reader.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "sqfs/meta_reader.h"
+#include "sqfs/xattr.h"
#include "xattr_reader.h"
#include "util.h"
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index da800c0..24f8e9c 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -10,9 +10,9 @@
#include "config.h"
#include "sqfs/meta_writer.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
#include "sqfs/id_table.h"
+#include "sqfs/data.h"
#include "data_writer.h"
#include "highlevel.h"
#include "fstree.h"
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index af8cdf0..1e70562 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -6,9 +6,10 @@
*/
#include "config.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
#include "sqfs/id_table.h"
+#include "sqfs/xattr.h"
+#include "sqfs/data.h"
#include "data_writer.h"
#include "highlevel.h"
#include "fstree.h"
diff --git a/unpack/rdsquashfs.h b/unpack/rdsquashfs.h
index 348494d..6805bed 100644
--- a/unpack/rdsquashfs.h
+++ b/unpack/rdsquashfs.h
@@ -10,9 +10,9 @@
#include "config.h"
#include "sqfs/meta_reader.h"
-#include "sqfs/squashfs.h"
#include "sqfs/compress.h"
#include "sqfs/id_table.h"
+#include "sqfs/data.h"
#include "data_reader.h"
#include "highlevel.h"
#include "fstree.h"