aboutsummaryrefslogtreecommitdiff
path: root/fs/squashfs/sqfs_utils.h
diff options
context:
space:
mode:
authorJoao Marcos Costa <joaomarcos.costa@bootlin.com>2020-07-30 15:33:47 +0200
committerTom Rini <trini@konsulko.com>2020-08-07 22:31:32 -0400
commitc51006130370b48b7eb5a93ada745385aa27f6bf (patch)
treeecd8782353da828ee0761eaa83d6ed2fe3f6c9bd /fs/squashfs/sqfs_utils.h
parent550a9e7902ce2a6103d97d70a22bad64e4fab7fd (diff)
downloadu-boot-c51006130370b48b7eb5a93ada745385aa27f6bf.zip
u-boot-c51006130370b48b7eb5a93ada745385aa27f6bf.tar.gz
u-boot-c51006130370b48b7eb5a93ada745385aa27f6bf.tar.bz2
fs/squashfs: new filesystem
Add support for SquashFS filesystem. Right now, it does not support compression but support for zlib will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
Diffstat (limited to 'fs/squashfs/sqfs_utils.h')
-rw-r--r--fs/squashfs/sqfs_utils.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/squashfs/sqfs_utils.h b/fs/squashfs/sqfs_utils.h
new file mode 100644
index 0000000..1260abe
--- /dev/null
+++ b/fs/squashfs/sqfs_utils.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#ifndef SQFS_UTILS_H
+#define SQFS_UTILS_H
+
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+#include <stdbool.h>
+
+#define SQFS_FRAGMENT_INDEX_OFFSET(A) ((A) % SQFS_MAX_ENTRIES)
+#define SQFS_FRAGMENT_INDEX(A) ((A) / SQFS_MAX_ENTRIES)
+#define SQFS_BLOCK_SIZE(A) ((A) & GENMASK(23, 0))
+#define SQFS_CHECK_FLAG(flag, bit) (((flag) >> (bit)) & 1)
+/* Useful for both fragment and data blocks */
+#define SQFS_COMPRESSED_BLOCK(A) (!((A) & BIT(24)))
+/* SQFS_COMPRESSED_DATA strictly used with super block's 'flags' member */
+#define SQFS_COMPRESSED_DATA(A) (!((A) & 0x0002))
+#define SQFS_IS_FRAGMENTED(A) ((A) != 0xFFFFFFFF)
+/*
+ * These two macros work as getters for a metada block header, retrieving the
+ * data size and if it is compressed/uncompressed
+ */
+#define SQFS_COMPRESSED_METADATA(A) (!((A) & BIT(15)))
+#define SQFS_METADATA_SIZE(A) ((A) & GENMASK(14, 0))
+
+struct squashfs_super_block_flags {
+ /* check: unused
+ * uncompressed_ids: not supported
+ */
+ bool uncompressed_inodes;
+ bool uncompressed_data;
+ bool check;
+ bool uncompressed_frags;
+ bool no_frags;
+ bool always_frags;
+ bool duplicates;
+ bool exportable;
+ bool uncompressed_xattrs;
+ bool no_xattrs;
+ bool compressor_options;
+ bool uncompressed_ids;
+};
+
+#endif /* SQFS_UTILS_H */