|
Kmods SIG |
8b815c |
From 4534a70b7056fd4b9a1c6db5a4ce3c98546b291e Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
8b815c |
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
8b815c |
Date: Fri, 13 Aug 2021 17:21:29 +0300
|
|
Kmods SIG |
8b815c |
Subject: [Backport 4534a70b7056] src: Add headers and misc files
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
This adds headers and misc files
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
8b815c |
---
|
|
Kmods SIG |
8b815c |
src/debug.h | 64 +++
|
|
Kmods SIG |
8b815c |
src/ntfs.h | 1238 ++++++++++++++++++++++++++++++++++++++++++++
|
|
Kmods SIG |
8b815c |
src/ntfs_fs.h | 1092 ++++++++++++++++++++++++++++++++++++++
|
|
Kmods SIG |
8b815c |
src/upcase.c | 105 ++++
|
|
Kmods SIG |
8b815c |
4 files changed, 2499 insertions(+)
|
|
Kmods SIG |
8b815c |
create mode 100644 src/debug.h
|
|
Kmods SIG |
8b815c |
create mode 100644 src/ntfs.h
|
|
Kmods SIG |
8b815c |
create mode 100644 src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
create mode 100644 src/upcase.c
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
diff --git a/src/debug.h b/src/debug.h
|
|
Kmods SIG |
8b815c |
new file mode 100644
|
|
Kmods SIG |
8b815c |
index 0000000000000000000000000000000000000000..dfaa4c79dc6d86677b0b3de5c98a54a23ef637d6
|
|
Kmods SIG |
8b815c |
--- /dev/null
|
|
Kmods SIG |
8b815c |
+++ b/src/debug.h
|
|
Kmods SIG |
8b815c |
@@ -0,0 +1,64 @@
|
|
Kmods SIG |
8b815c |
+/* SPDX-License-Identifier: GPL-2.0 */
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * useful functions for debuging
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+// clang-format off
|
|
Kmods SIG |
8b815c |
+#ifndef Add2Ptr
|
|
Kmods SIG |
8b815c |
+#define Add2Ptr(P, I) ((void *)((u8 *)(P) + (I)))
|
|
Kmods SIG |
8b815c |
+#define PtrOffset(B, O) ((size_t)((size_t)(O) - (size_t)(B)))
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define QuadAlign(n) (((n) + 7u) & (~7u))
|
|
Kmods SIG |
8b815c |
+#define IsQuadAligned(n) (!((size_t)(n)&7u))
|
|
Kmods SIG |
8b815c |
+#define Quad2Align(n) (((n) + 15u) & (~15u))
|
|
Kmods SIG |
8b815c |
+#define IsQuad2Aligned(n) (!((size_t)(n)&15u))
|
|
Kmods SIG |
8b815c |
+#define Quad4Align(n) (((n) + 31u) & (~31u))
|
|
Kmods SIG |
8b815c |
+#define IsSizeTAligned(n) (!((size_t)(n) & (sizeof(size_t) - 1)))
|
|
Kmods SIG |
8b815c |
+#define DwordAlign(n) (((n) + 3u) & (~3u))
|
|
Kmods SIG |
8b815c |
+#define IsDwordAligned(n) (!((size_t)(n)&3u))
|
|
Kmods SIG |
8b815c |
+#define WordAlign(n) (((n) + 1u) & (~1u))
|
|
Kmods SIG |
8b815c |
+#define IsWordAligned(n) (!((size_t)(n)&1u))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_PRINTK
|
|
Kmods SIG |
8b815c |
+__printf(2, 3)
|
|
Kmods SIG |
8b815c |
+void ntfs_printk(const struct super_block *sb, const char *fmt, ...);
|
|
Kmods SIG |
8b815c |
+__printf(2, 3)
|
|
Kmods SIG |
8b815c |
+void ntfs_inode_printk(struct inode *inode, const char *fmt, ...);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+static inline __printf(2, 3)
|
|
Kmods SIG |
8b815c |
+void ntfs_printk(const struct super_block *sb, const char *fmt, ...)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline __printf(2, 3)
|
|
Kmods SIG |
8b815c |
+void ntfs_inode_printk(struct inode *inode, const char *fmt, ...)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Logging macros ( thanks Joe Perches <joe@perches.com> for implementation )
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define ntfs_err(sb, fmt, ...) ntfs_printk(sb, KERN_ERR fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+#define ntfs_warn(sb, fmt, ...) ntfs_printk(sb, KERN_WARNING fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+#define ntfs_info(sb, fmt, ...) ntfs_printk(sb, KERN_INFO fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+#define ntfs_notice(sb, fmt, ...) \
|
|
Kmods SIG |
8b815c |
+ ntfs_printk(sb, KERN_NOTICE fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define ntfs_inode_err(inode, fmt, ...) \
|
|
Kmods SIG |
8b815c |
+ ntfs_inode_printk(inode, KERN_ERR fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+#define ntfs_inode_warn(inode, fmt, ...) \
|
|
Kmods SIG |
8b815c |
+ ntfs_inode_printk(inode, KERN_WARNING fmt, ##__VA_ARGS__)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define ntfs_malloc(s) kmalloc(s, GFP_NOFS)
|
|
Kmods SIG |
8b815c |
+#define ntfs_zalloc(s) kzalloc(s, GFP_NOFS)
|
|
Kmods SIG |
8b815c |
+#define ntfs_vmalloc(s) kvmalloc(s, GFP_KERNEL)
|
|
Kmods SIG |
8b815c |
+#define ntfs_free(p) kfree(p)
|
|
Kmods SIG |
8b815c |
+#define ntfs_vfree(p) kvfree(p)
|
|
Kmods SIG |
8b815c |
+#define ntfs_memdup(src, len) kmemdup(src, len, GFP_NOFS)
|
|
Kmods SIG |
8b815c |
+// clang-format on
|
|
Kmods SIG |
8b815c |
diff --git a/src/ntfs.h b/src/ntfs.h
|
|
Kmods SIG |
8b815c |
new file mode 100644
|
|
Kmods SIG |
8b815c |
index 0000000000000000000000000000000000000000..40398e6c39c9383de1f917f6ef29d4d0238df7d7
|
|
Kmods SIG |
8b815c |
--- /dev/null
|
|
Kmods SIG |
8b815c |
+++ b/src/ntfs.h
|
|
Kmods SIG |
8b815c |
@@ -0,0 +1,1238 @@
|
|
Kmods SIG |
8b815c |
+/* SPDX-License-Identifier: GPL-2.0 */
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * on-disk ntfs structs
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+// clang-format off
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* TODO:
|
|
Kmods SIG |
8b815c |
+ * - Check 4K mft record and 512 bytes cluster
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Activate this define to use binary search in indexes
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+#define NTFS3_INDEX_BINARY_SEARCH
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Check each run for marked clusters
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+#define NTFS3_CHECK_FREE_CLST
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define NTFS_NAME_LEN 255
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * ntfs.sys used 500 maximum links
|
|
Kmods SIG |
8b815c |
+ * on-disk struct allows up to 0xffff
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+#define NTFS_LINK_MAX 0x400
|
|
Kmods SIG |
8b815c |
+//#define NTFS_LINK_MAX 0xffff
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Activate to use 64 bit clusters instead of 32 bits in ntfs.sys
|
|
Kmods SIG |
8b815c |
+ * Logical and virtual cluster number
|
|
Kmods SIG |
8b815c |
+ * If needed, may be redefined to use 64 bit value
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+//#define CONFIG_NTFS3_64BIT_CLUSTER
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define NTFS_LZNT_MAX_CLUSTER 4096
|
|
Kmods SIG |
8b815c |
+#define NTFS_LZNT_CUNIT 4
|
|
Kmods SIG |
8b815c |
+#define NTFS_LZNT_CLUSTERS (1u<
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct GUID {
|
|
Kmods SIG |
8b815c |
+ __le32 Data1;
|
|
Kmods SIG |
8b815c |
+ __le16 Data2;
|
|
Kmods SIG |
8b815c |
+ __le16 Data3;
|
|
Kmods SIG |
8b815c |
+ u8 Data4[8];
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * this struct repeats layout of ATTR_FILE_NAME
|
|
Kmods SIG |
8b815c |
+ * at offset 0x40
|
|
Kmods SIG |
8b815c |
+ * it used to store global constants NAME_MFT/NAME_MIRROR...
|
|
Kmods SIG |
8b815c |
+ * most constant names are shorter than 10
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+struct cpu_str {
|
|
Kmods SIG |
8b815c |
+ u8 len;
|
|
Kmods SIG |
8b815c |
+ u8 unused;
|
|
Kmods SIG |
8b815c |
+ u16 name[10];
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct le_str {
|
|
Kmods SIG |
8b815c |
+ u8 len;
|
|
Kmods SIG |
8b815c |
+ u8 unused;
|
|
Kmods SIG |
8b815c |
+ __le16 name[];
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(SECTOR_SHIFT == 9);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_64BIT_CLUSTER
|
|
Kmods SIG |
8b815c |
+typedef u64 CLST;
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(size_t) == 8);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+typedef u32 CLST;
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SPARSE_LCN64 ((u64)-1)
|
|
Kmods SIG |
8b815c |
+#define SPARSE_LCN ((CLST)-1)
|
|
Kmods SIG |
8b815c |
+#define RESIDENT_LCN ((CLST)-2)
|
|
Kmods SIG |
8b815c |
+#define COMPRESSED_LCN ((CLST)-3)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define COMPRESSION_UNIT 4
|
|
Kmods SIG |
8b815c |
+#define COMPRESS_MAX_CLUSTER 0x1000
|
|
Kmods SIG |
8b815c |
+#define MFT_INCREASE_CHUNK 1024
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum RECORD_NUM {
|
|
Kmods SIG |
8b815c |
+ MFT_REC_MFT = 0,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_MIRR = 1,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_LOG = 2,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_VOL = 3,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_ATTR = 4,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_ROOT = 5,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_BITMAP = 6,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_BOOT = 7,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_BADCLUST = 8,
|
|
Kmods SIG |
8b815c |
+ //MFT_REC_QUOTA = 9,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_SECURE = 9, // NTFS 3.0
|
|
Kmods SIG |
8b815c |
+ MFT_REC_UPCASE = 10,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_EXTEND = 11, // NTFS 3.0
|
|
Kmods SIG |
8b815c |
+ MFT_REC_RESERVED = 11,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_FREE = 16,
|
|
Kmods SIG |
8b815c |
+ MFT_REC_USER = 24,
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum ATTR_TYPE {
|
|
Kmods SIG |
8b815c |
+ ATTR_ZERO = cpu_to_le32(0x00),
|
|
Kmods SIG |
8b815c |
+ ATTR_STD = cpu_to_le32(0x10),
|
|
Kmods SIG |
8b815c |
+ ATTR_LIST = cpu_to_le32(0x20),
|
|
Kmods SIG |
8b815c |
+ ATTR_NAME = cpu_to_le32(0x30),
|
|
Kmods SIG |
8b815c |
+ // ATTR_VOLUME_VERSION on Nt4
|
|
Kmods SIG |
8b815c |
+ ATTR_ID = cpu_to_le32(0x40),
|
|
Kmods SIG |
8b815c |
+ ATTR_SECURE = cpu_to_le32(0x50),
|
|
Kmods SIG |
8b815c |
+ ATTR_LABEL = cpu_to_le32(0x60),
|
|
Kmods SIG |
8b815c |
+ ATTR_VOL_INFO = cpu_to_le32(0x70),
|
|
Kmods SIG |
8b815c |
+ ATTR_DATA = cpu_to_le32(0x80),
|
|
Kmods SIG |
8b815c |
+ ATTR_ROOT = cpu_to_le32(0x90),
|
|
Kmods SIG |
8b815c |
+ ATTR_ALLOC = cpu_to_le32(0xA0),
|
|
Kmods SIG |
8b815c |
+ ATTR_BITMAP = cpu_to_le32(0xB0),
|
|
Kmods SIG |
8b815c |
+ // ATTR_SYMLINK on Nt4
|
|
Kmods SIG |
8b815c |
+ ATTR_REPARSE = cpu_to_le32(0xC0),
|
|
Kmods SIG |
8b815c |
+ ATTR_EA_INFO = cpu_to_le32(0xD0),
|
|
Kmods SIG |
8b815c |
+ ATTR_EA = cpu_to_le32(0xE0),
|
|
Kmods SIG |
8b815c |
+ ATTR_PROPERTYSET = cpu_to_le32(0xF0),
|
|
Kmods SIG |
8b815c |
+ ATTR_LOGGED_UTILITY_STREAM = cpu_to_le32(0x100),
|
|
Kmods SIG |
8b815c |
+ ATTR_END = cpu_to_le32(0xFFFFFFFF)
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(enum ATTR_TYPE) == 4);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum FILE_ATTRIBUTE {
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_READONLY = cpu_to_le32(0x00000001),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_HIDDEN = cpu_to_le32(0x00000002),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_SYSTEM = cpu_to_le32(0x00000004),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_ARCHIVE = cpu_to_le32(0x00000020),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_DEVICE = cpu_to_le32(0x00000040),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_TEMPORARY = cpu_to_le32(0x00000100),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_SPARSE_FILE = cpu_to_le32(0x00000200),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_REPARSE_POINT = cpu_to_le32(0x00000400),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_COMPRESSED = cpu_to_le32(0x00000800),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_OFFLINE = cpu_to_le32(0x00001000),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = cpu_to_le32(0x00002000),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_ENCRYPTED = cpu_to_le32(0x00004000),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_VALID_FLAGS = cpu_to_le32(0x00007fb7),
|
|
Kmods SIG |
8b815c |
+ FILE_ATTRIBUTE_DIRECTORY = cpu_to_le32(0x10000000),
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(enum FILE_ATTRIBUTE) == 4);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_MFT;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_MIRROR;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_LOGFILE;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_VOLUME;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_ATTRDEF;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_ROOT;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_BITMAP;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_BOOT;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_BADCLUS;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_QUOTA;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_SECURE;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_UPCASE;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_EXTEND;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_OBJID;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_REPARSE;
|
|
Kmods SIG |
8b815c |
+extern const struct cpu_str NAME_USNJRNL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+extern const __le16 I30_NAME[4];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SII_NAME[4];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SDH_NAME[4];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SO_NAME[2];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SQ_NAME[2];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SR_NAME[2];
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+extern const __le16 BAD_NAME[4];
|
|
Kmods SIG |
8b815c |
+extern const __le16 SDS_NAME[4];
|
|
Kmods SIG |
8b815c |
+extern const __le16 WOF_NAME[17]; /* WofCompressedData */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* MFT record number structure */
|
|
Kmods SIG |
8b815c |
+struct MFT_REF {
|
|
Kmods SIG |
8b815c |
+ __le32 low; // The low part of the number
|
|
Kmods SIG |
8b815c |
+ __le16 high; // The high part of the number
|
|
Kmods SIG |
8b815c |
+ __le16 seq; // The sequence number of MFT record
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(__le64) == sizeof(struct MFT_REF));
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline CLST ino_get(const struct MFT_REF *ref)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_64BIT_CLUSTER
|
|
Kmods SIG |
8b815c |
+ return le32_to_cpu(ref->low) | ((u64)le16_to_cpu(ref->high) << 32);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+ return le32_to_cpu(ref->low);
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct NTFS_BOOT {
|
|
Kmods SIG |
8b815c |
+ u8 jump_code[3]; // 0x00: Jump to boot code
|
|
Kmods SIG |
8b815c |
+ u8 system_id[8]; // 0x03: System ID, equals "NTFS "
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // NOTE: this member is not aligned(!)
|
|
Kmods SIG |
8b815c |
+ // bytes_per_sector[0] must be 0
|
|
Kmods SIG |
8b815c |
+ // bytes_per_sector[1] must be multiplied by 256
|
|
Kmods SIG |
8b815c |
+ u8 bytes_per_sector[2]; // 0x0B: Bytes per sector
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u8 sectors_per_clusters;// 0x0D: Sectors per cluster
|
|
Kmods SIG |
8b815c |
+ u8 unused1[7];
|
|
Kmods SIG |
8b815c |
+ u8 media_type; // 0x15: Media type (0xF8 - harddisk)
|
|
Kmods SIG |
8b815c |
+ u8 unused2[2];
|
|
Kmods SIG |
8b815c |
+ __le16 sct_per_track; // 0x18: number of sectors per track
|
|
Kmods SIG |
8b815c |
+ __le16 heads; // 0x1A: number of heads per cylinder
|
|
Kmods SIG |
8b815c |
+ __le32 hidden_sectors; // 0x1C: number of 'hidden' sectors
|
|
Kmods SIG |
8b815c |
+ u8 unused3[4];
|
|
Kmods SIG |
8b815c |
+ u8 bios_drive_num; // 0x24: BIOS drive number =0x80
|
|
Kmods SIG |
8b815c |
+ u8 unused4;
|
|
Kmods SIG |
8b815c |
+ u8 signature_ex; // 0x26: Extended BOOT signature =0x80
|
|
Kmods SIG |
8b815c |
+ u8 unused5;
|
|
Kmods SIG |
8b815c |
+ __le64 sectors_per_volume;// 0x28: size of volume in sectors
|
|
Kmods SIG |
8b815c |
+ __le64 mft_clst; // 0x30: first cluster of $MFT
|
|
Kmods SIG |
8b815c |
+ __le64 mft2_clst; // 0x38: first cluster of $MFTMirr
|
|
Kmods SIG |
8b815c |
+ s8 record_size; // 0x40: size of MFT record in clusters(sectors)
|
|
Kmods SIG |
8b815c |
+ u8 unused6[3];
|
|
Kmods SIG |
8b815c |
+ s8 index_size; // 0x44: size of INDX record in clusters(sectors)
|
|
Kmods SIG |
8b815c |
+ u8 unused7[3];
|
|
Kmods SIG |
8b815c |
+ __le64 serial_num; // 0x48: Volume serial number
|
|
Kmods SIG |
8b815c |
+ __le32 check_sum; // 0x50: Simple additive checksum of all
|
|
Kmods SIG |
8b815c |
+ // of the u32's which precede the 'check_sum'
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u8 boot_code[0x200 - 0x50 - 2 - 4]; // 0x54:
|
|
Kmods SIG |
8b815c |
+ u8 boot_magic[2]; // 0x1FE: Boot signature =0x55 + 0xAA
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct NTFS_BOOT) == 0x200);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum NTFS_SIGNATURE {
|
|
Kmods SIG |
8b815c |
+ NTFS_FILE_SIGNATURE = cpu_to_le32(0x454C4946), // 'FILE'
|
|
Kmods SIG |
8b815c |
+ NTFS_INDX_SIGNATURE = cpu_to_le32(0x58444E49), // 'INDX'
|
|
Kmods SIG |
8b815c |
+ NTFS_CHKD_SIGNATURE = cpu_to_le32(0x444B4843), // 'CHKD'
|
|
Kmods SIG |
8b815c |
+ NTFS_RSTR_SIGNATURE = cpu_to_le32(0x52545352), // 'RSTR'
|
|
Kmods SIG |
8b815c |
+ NTFS_RCRD_SIGNATURE = cpu_to_le32(0x44524352), // 'RCRD'
|
|
Kmods SIG |
8b815c |
+ NTFS_BAAD_SIGNATURE = cpu_to_le32(0x44414142), // 'BAAD'
|
|
Kmods SIG |
8b815c |
+ NTFS_HOLE_SIGNATURE = cpu_to_le32(0x454C4F48), // 'HOLE'
|
|
Kmods SIG |
8b815c |
+ NTFS_FFFF_SIGNATURE = cpu_to_le32(0xffffffff),
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(enum NTFS_SIGNATURE) == 4);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* MFT Record header structure */
|
|
Kmods SIG |
8b815c |
+struct NTFS_RECORD_HEADER {
|
|
Kmods SIG |
8b815c |
+ /* Record magic number, equals 'FILE'/'INDX'/'RSTR'/'RCRD' */
|
|
Kmods SIG |
8b815c |
+ enum NTFS_SIGNATURE sign; // 0x00:
|
|
Kmods SIG |
8b815c |
+ __le16 fix_off; // 0x04:
|
|
Kmods SIG |
8b815c |
+ __le16 fix_num; // 0x06:
|
|
Kmods SIG |
8b815c |
+ __le64 lsn; // 0x08: Log file sequence number
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct NTFS_RECORD_HEADER) == 0x10);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline int is_baad(const struct NTFS_RECORD_HEADER *hdr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return hdr->sign == NTFS_BAAD_SIGNATURE;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Possible bits in struct MFT_REC.flags */
|
|
Kmods SIG |
8b815c |
+enum RECORD_FLAG {
|
|
Kmods SIG |
8b815c |
+ RECORD_FLAG_IN_USE = cpu_to_le16(0x0001),
|
|
Kmods SIG |
8b815c |
+ RECORD_FLAG_DIR = cpu_to_le16(0x0002),
|
|
Kmods SIG |
8b815c |
+ RECORD_FLAG_SYSTEM = cpu_to_le16(0x0004),
|
|
Kmods SIG |
8b815c |
+ RECORD_FLAG_UNKNOWN = cpu_to_le16(0x0008),
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* MFT Record structure */
|
|
Kmods SIG |
8b815c |
+struct MFT_REC {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_RECORD_HEADER rhdr; // 'FILE'
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ __le16 seq; // 0x10: Sequence number for this record
|
|
Kmods SIG |
8b815c |
+ __le16 hard_links; // 0x12: The number of hard links to record
|
|
Kmods SIG |
8b815c |
+ __le16 attr_off; // 0x14: Offset to attributes
|
|
Kmods SIG |
8b815c |
+ __le16 flags; // 0x16: See RECORD_FLAG
|
|
Kmods SIG |
8b815c |
+ __le32 used; // 0x18: The size of used part
|
|
Kmods SIG |
8b815c |
+ __le32 total; // 0x1C: Total record size
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF parent_ref; // 0x20: Parent MFT record
|
|
Kmods SIG |
8b815c |
+ __le16 next_attr_id; // 0x28: The next attribute Id
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ __le16 res; // 0x2A: High part of mft record?
|
|
Kmods SIG |
8b815c |
+ __le32 mft_record; // 0x2C: Current mft record number
|
|
Kmods SIG |
8b815c |
+ __le16 fixups[]; // 0x30:
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define MFTRECORD_FIXUP_OFFSET_1 offsetof(struct MFT_REC, res)
|
|
Kmods SIG |
8b815c |
+#define MFTRECORD_FIXUP_OFFSET_3 offsetof(struct MFT_REC, fixups)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(MFTRECORD_FIXUP_OFFSET_1 == 0x2A);
|
|
Kmods SIG |
8b815c |
+static_assert(MFTRECORD_FIXUP_OFFSET_3 == 0x30);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_rec_base(const struct MFT_REC *rec)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *r = &rec->parent_ref;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return !r->low && !r->high && !r->seq;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_mft_rec5(const struct MFT_REC *rec)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return le16_to_cpu(rec->rhdr.fix_off) >=
|
|
Kmods SIG |
8b815c |
+ offsetof(struct MFT_REC, fixups);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_rec_inuse(const struct MFT_REC *rec)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return rec->flags & RECORD_FLAG_IN_USE;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool clear_rec_inuse(struct MFT_REC *rec)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return rec->flags &= ~RECORD_FLAG_IN_USE;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Possible values of ATTR_RESIDENT.flags */
|
|
Kmods SIG |
8b815c |
+#define RESIDENT_FLAG_INDEXED 0x01
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ATTR_RESIDENT {
|
|
Kmods SIG |
8b815c |
+ __le32 data_size; // 0x10: The size of data
|
|
Kmods SIG |
8b815c |
+ __le16 data_off; // 0x14: Offset to data
|
|
Kmods SIG |
8b815c |
+ u8 flags; // 0x16: resident flags ( 1 - indexed )
|
|
Kmods SIG |
8b815c |
+ u8 res; // 0x17:
|
|
Kmods SIG |
8b815c |
+}; // sizeof() = 0x18
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ATTR_NONRESIDENT {
|
|
Kmods SIG |
8b815c |
+ __le64 svcn; // 0x10: Starting VCN of this segment
|
|
Kmods SIG |
8b815c |
+ __le64 evcn; // 0x18: End VCN of this segment
|
|
Kmods SIG |
8b815c |
+ __le16 run_off; // 0x20: Offset to packed runs
|
|
Kmods SIG |
8b815c |
+ // Unit of Compression size for this stream, expressed
|
|
Kmods SIG |
8b815c |
+ // as a log of the cluster size.
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // 0 means file is not compressed
|
|
Kmods SIG |
8b815c |
+ // 1, 2, 3, and 4 are potentially legal values if the
|
|
Kmods SIG |
8b815c |
+ // stream is compressed, however the implementation
|
|
Kmods SIG |
8b815c |
+ // may only choose to use 4, or possibly 3. Note
|
|
Kmods SIG |
8b815c |
+ // that 4 means cluster size time 16. If convenient
|
|
Kmods SIG |
8b815c |
+ // the implementation may wish to accept a
|
|
Kmods SIG |
8b815c |
+ // reasonable range of legal values here (1-5?),
|
|
Kmods SIG |
8b815c |
+ // even if the implementation only generates
|
|
Kmods SIG |
8b815c |
+ // a smaller set of values itself.
|
|
Kmods SIG |
8b815c |
+ u8 c_unit; // 0x22
|
|
Kmods SIG |
8b815c |
+ u8 res1[5]; // 0x23:
|
|
Kmods SIG |
8b815c |
+ __le64 alloc_size; // 0x28: The allocated size of attribute in bytes
|
|
Kmods SIG |
8b815c |
+ // (multiple of cluster size)
|
|
Kmods SIG |
8b815c |
+ __le64 data_size; // 0x30: The size of attribute in bytes <= alloc_size
|
|
Kmods SIG |
8b815c |
+ __le64 valid_size; // 0x38: The size of valid part in bytes <= data_size
|
|
Kmods SIG |
8b815c |
+ __le64 total_size; // 0x40: The sum of the allocated clusters for a file
|
|
Kmods SIG |
8b815c |
+ // (present only for the first segment (0 == vcn)
|
|
Kmods SIG |
8b815c |
+ // of compressed attribute)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+}; // sizeof()=0x40 or 0x48 (if compressed)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Possible values of ATTRIB.flags: */
|
|
Kmods SIG |
8b815c |
+#define ATTR_FLAG_COMPRESSED cpu_to_le16(0x0001)
|
|
Kmods SIG |
8b815c |
+#define ATTR_FLAG_COMPRESSED_MASK cpu_to_le16(0x00FF)
|
|
Kmods SIG |
8b815c |
+#define ATTR_FLAG_ENCRYPTED cpu_to_le16(0x4000)
|
|
Kmods SIG |
8b815c |
+#define ATTR_FLAG_SPARSED cpu_to_le16(0x8000)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ATTRIB {
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type; // 0x00: The type of this attribute
|
|
Kmods SIG |
8b815c |
+ __le32 size; // 0x04: The size of this attribute
|
|
Kmods SIG |
8b815c |
+ u8 non_res; // 0x08: Is this attribute non-resident ?
|
|
Kmods SIG |
8b815c |
+ u8 name_len; // 0x09: This attribute name length
|
|
Kmods SIG |
8b815c |
+ __le16 name_off; // 0x0A: Offset to the attribute name
|
|
Kmods SIG |
8b815c |
+ __le16 flags; // 0x0C: See ATTR_FLAG_XXX
|
|
Kmods SIG |
8b815c |
+ __le16 id; // 0x0E: unique id (per record)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ union {
|
|
Kmods SIG |
8b815c |
+ struct ATTR_RESIDENT res; // 0x10
|
|
Kmods SIG |
8b815c |
+ struct ATTR_NONRESIDENT nres; // 0x10
|
|
Kmods SIG |
8b815c |
+ };
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Define attribute sizes */
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_RESIDENT 0x18
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_NONRESIDENT_EX 0x48
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_NONRESIDENT 0x40
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_RESIDENT_LE cpu_to_le16(0x18)
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_NONRESIDENT_EX_LE cpu_to_le16(0x48)
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_NONRESIDENT_LE cpu_to_le16(0x40)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u64 attr_ondisk_size(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->non_res ? ((attr->flags &
|
|
Kmods SIG |
8b815c |
+ (ATTR_FLAG_COMPRESSED | ATTR_FLAG_SPARSED)) ?
|
|
Kmods SIG |
8b815c |
+ le64_to_cpu(attr->nres.total_size) :
|
|
Kmods SIG |
8b815c |
+ le64_to_cpu(attr->nres.alloc_size)) :
|
|
Kmods SIG |
8b815c |
+ QuadAlign(le32_to_cpu(attr->res.data_size));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u64 attr_size(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->non_res ? le64_to_cpu(attr->nres.data_size) :
|
|
Kmods SIG |
8b815c |
+ le32_to_cpu(attr->res.data_size);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_attr_encrypted(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->flags & ATTR_FLAG_ENCRYPTED;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_attr_sparsed(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->flags & ATTR_FLAG_SPARSED;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_attr_compressed(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->flags & ATTR_FLAG_COMPRESSED;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_attr_ext(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->flags & (ATTR_FLAG_SPARSED | ATTR_FLAG_COMPRESSED);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_attr_indexed(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return !attr->non_res && (attr->res.flags & RESIDENT_FLAG_INDEXED);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline __le16 const *attr_name(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(attr, le16_to_cpu(attr->name_off));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u64 attr_svcn(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr->non_res ? le64_to_cpu(attr->nres.svcn) : 0;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* the size of resident attribute by its resident size */
|
|
Kmods SIG |
8b815c |
+#define BYTES_PER_RESIDENT(b) (0x18 + (b))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ATTRIB) == 0x48);
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(((struct ATTRIB *)NULL)->res) == 0x08);
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(((struct ATTRIB *)NULL)->nres) == 0x38);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void *resident_data_ex(const struct ATTRIB *attr, u32 datasize)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ u32 asize, rsize;
|
|
Kmods SIG |
8b815c |
+ u16 off;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (attr->non_res)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ asize = le32_to_cpu(attr->size);
|
|
Kmods SIG |
8b815c |
+ off = le16_to_cpu(attr->res.data_off);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (asize < datasize + off)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ rsize = le32_to_cpu(attr->res.data_size);
|
|
Kmods SIG |
8b815c |
+ if (rsize < datasize)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(attr, off);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void *resident_data(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(attr, le16_to_cpu(attr->res.data_off));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void *attr_run(const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(attr, le16_to_cpu(attr->nres.run_off));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Standard information attribute (0x10) */
|
|
Kmods SIG |
8b815c |
+struct ATTR_STD_INFO {
|
|
Kmods SIG |
8b815c |
+ __le64 cr_time; // 0x00: File creation file
|
|
Kmods SIG |
8b815c |
+ __le64 m_time; // 0x08: File modification time
|
|
Kmods SIG |
8b815c |
+ __le64 c_time; // 0x10: Last time any attribute was modified
|
|
Kmods SIG |
8b815c |
+ __le64 a_time; // 0x18: File last access time
|
|
Kmods SIG |
8b815c |
+ enum FILE_ATTRIBUTE fa; // 0x20: Standard DOS attributes & more
|
|
Kmods SIG |
8b815c |
+ __le32 max_ver_num; // 0x24: Maximum Number of Versions
|
|
Kmods SIG |
8b815c |
+ __le32 ver_num; // 0x28: Version Number
|
|
Kmods SIG |
8b815c |
+ __le32 class_id; // 0x2C: Class Id from bidirectional Class Id index
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ATTR_STD_INFO) == 0x30);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SECURITY_ID_INVALID 0x00000000
|
|
Kmods SIG |
8b815c |
+#define SECURITY_ID_FIRST 0x00000100
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ATTR_STD_INFO5 {
|
|
Kmods SIG |
8b815c |
+ __le64 cr_time; // 0x00: File creation file
|
|
Kmods SIG |
8b815c |
+ __le64 m_time; // 0x08: File modification time
|
|
Kmods SIG |
8b815c |
+ __le64 c_time; // 0x10: Last time any attribute was modified
|
|
Kmods SIG |
8b815c |
+ __le64 a_time; // 0x18: File last access time
|
|
Kmods SIG |
8b815c |
+ enum FILE_ATTRIBUTE fa; // 0x20: Standard DOS attributes & more
|
|
Kmods SIG |
8b815c |
+ __le32 max_ver_num; // 0x24: Maximum Number of Versions
|
|
Kmods SIG |
8b815c |
+ __le32 ver_num; // 0x28: Version Number
|
|
Kmods SIG |
8b815c |
+ __le32 class_id; // 0x2C: Class Id from bidirectional Class Id index
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ __le32 owner_id; // 0x30: Owner Id of the user owning the file.
|
|
Kmods SIG |
8b815c |
+ __le32 security_id; // 0x34: The Security Id is a key in the $SII Index and $SDS
|
|
Kmods SIG |
8b815c |
+ __le64 quota_charge; // 0x38:
|
|
Kmods SIG |
8b815c |
+ __le64 usn; // 0x40: Last Update Sequence Number of the file. This is a direct
|
|
Kmods SIG |
8b815c |
+ // index into the file $UsnJrnl. If zero, the USN Journal is
|
|
Kmods SIG |
8b815c |
+ // disabled.
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ATTR_STD_INFO5) == 0x48);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* attribute list entry structure (0x20) */
|
|
Kmods SIG |
8b815c |
+struct ATTR_LIST_ENTRY {
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type; // 0x00: The type of attribute
|
|
Kmods SIG |
8b815c |
+ __le16 size; // 0x04: The size of this record
|
|
Kmods SIG |
8b815c |
+ u8 name_len; // 0x06: The length of attribute name
|
|
Kmods SIG |
8b815c |
+ u8 name_off; // 0x07: The offset to attribute name
|
|
Kmods SIG |
8b815c |
+ __le64 vcn; // 0x08: Starting VCN of this attribute
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF ref; // 0x10: MFT record number with attribute
|
|
Kmods SIG |
8b815c |
+ __le16 id; // 0x18: struct ATTRIB ID
|
|
Kmods SIG |
8b815c |
+ __le16 name[3]; // 0x1A: Just to align. To get real name can use bNameOffset
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+}; // sizeof(0x20)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u32 le_size(u8 name_len)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return QuadAlign(offsetof(struct ATTR_LIST_ENTRY, name) +
|
|
Kmods SIG |
8b815c |
+ name_len * sizeof(short));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* returns 0 if 'attr' has the same type and name */
|
|
Kmods SIG |
8b815c |
+static inline int le_cmp(const struct ATTR_LIST_ENTRY *le,
|
|
Kmods SIG |
8b815c |
+ const struct ATTRIB *attr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return le->type != attr->type || le->name_len != attr->name_len ||
|
|
Kmods SIG |
8b815c |
+ (!le->name_len &&
|
|
Kmods SIG |
8b815c |
+ memcmp(Add2Ptr(le, le->name_off),
|
|
Kmods SIG |
8b815c |
+ Add2Ptr(attr, le16_to_cpu(attr->name_off)),
|
|
Kmods SIG |
8b815c |
+ le->name_len * sizeof(short)));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline __le16 const *le_name(const struct ATTR_LIST_ENTRY *le)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(le, le->name_off);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* File name types (the field type in struct ATTR_FILE_NAME ) */
|
|
Kmods SIG |
8b815c |
+#define FILE_NAME_POSIX 0
|
|
Kmods SIG |
8b815c |
+#define FILE_NAME_UNICODE 1
|
|
Kmods SIG |
8b815c |
+#define FILE_NAME_DOS 2
|
|
Kmods SIG |
8b815c |
+#define FILE_NAME_UNICODE_AND_DOS (FILE_NAME_DOS | FILE_NAME_UNICODE)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Filename attribute structure (0x30) */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DUP_INFO {
|
|
Kmods SIG |
8b815c |
+ __le64 cr_time; // 0x00: File creation file
|
|
Kmods SIG |
8b815c |
+ __le64 m_time; // 0x08: File modification time
|
|
Kmods SIG |
8b815c |
+ __le64 c_time; // 0x10: Last time any attribute was modified
|
|
Kmods SIG |
8b815c |
+ __le64 a_time; // 0x18: File last access time
|
|
Kmods SIG |
8b815c |
+ __le64 alloc_size; // 0x20: Data attribute allocated size, multiple of cluster size
|
|
Kmods SIG |
8b815c |
+ __le64 data_size; // 0x28: Data attribute size <= Dataalloc_size
|
|
Kmods SIG |
8b815c |
+ enum FILE_ATTRIBUTE fa; // 0x30: Standard DOS attributes & more
|
|
Kmods SIG |
8b815c |
+ __le16 ea_size; // 0x34: Packed EAs
|
|
Kmods SIG |
8b815c |
+ __le16 reparse; // 0x36: Used by Reparse
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+}; // 0x38
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ATTR_FILE_NAME {
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF home; // 0x00: MFT record for directory
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DUP_INFO dup;// 0x08
|
|
Kmods SIG |
8b815c |
+ u8 name_len; // 0x40: File name length in words
|
|
Kmods SIG |
8b815c |
+ u8 type; // 0x41: File name type
|
|
Kmods SIG |
8b815c |
+ __le16 name[]; // 0x42: File name
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(((struct ATTR_FILE_NAME *)NULL)->dup) == 0x38);
|
|
Kmods SIG |
8b815c |
+static_assert(offsetof(struct ATTR_FILE_NAME, name) == 0x42);
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_ATTRIBUTE_FILENAME 0x44
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_ATTRIBUTE_FILENAME_MAX (0x42 + 255 * 2)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct ATTRIB *attr_from_name(struct ATTR_FILE_NAME *fname)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (struct ATTRIB *)((char *)fname - SIZEOF_RESIDENT);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u16 fname_full_size(const struct ATTR_FILE_NAME *fname)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ // don't return struct_size(fname, name, fname->name_len);
|
|
Kmods SIG |
8b815c |
+ return offsetof(struct ATTR_FILE_NAME, name) +
|
|
Kmods SIG |
8b815c |
+ fname->name_len * sizeof(short);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u8 paired_name(u8 type)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (type == FILE_NAME_UNICODE)
|
|
Kmods SIG |
8b815c |
+ return FILE_NAME_DOS;
|
|
Kmods SIG |
8b815c |
+ if (type == FILE_NAME_DOS)
|
|
Kmods SIG |
8b815c |
+ return FILE_NAME_UNICODE;
|
|
Kmods SIG |
8b815c |
+ return FILE_NAME_POSIX;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Index entry defines ( the field flags in NtfsDirEntry ) */
|
|
Kmods SIG |
8b815c |
+#define NTFS_IE_HAS_SUBNODES cpu_to_le16(1)
|
|
Kmods SIG |
8b815c |
+#define NTFS_IE_LAST cpu_to_le16(2)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Directory entry structure */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE {
|
|
Kmods SIG |
8b815c |
+ union {
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF ref; // 0x00: MFT record number with this file
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ __le16 data_off; // 0x00:
|
|
Kmods SIG |
8b815c |
+ __le16 data_size; // 0x02:
|
|
Kmods SIG |
8b815c |
+ __le32 res; // 0x04: must be 0
|
|
Kmods SIG |
8b815c |
+ } view;
|
|
Kmods SIG |
8b815c |
+ };
|
|
Kmods SIG |
8b815c |
+ __le16 size; // 0x08: The size of this entry
|
|
Kmods SIG |
8b815c |
+ __le16 key_size; // 0x0A: The size of File name length in bytes + 0x42
|
|
Kmods SIG |
8b815c |
+ __le16 flags; // 0x0C: Entry flags: NTFS_IE_XXX
|
|
Kmods SIG |
8b815c |
+ __le16 res; // 0x0E:
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // Here any indexed attribute can be placed
|
|
Kmods SIG |
8b815c |
+ // One of them is:
|
|
Kmods SIG |
8b815c |
+ // struct ATTR_FILE_NAME AttrFileName;
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // The last 8 bytes of this structure contains
|
|
Kmods SIG |
8b815c |
+ // the VBN of subnode
|
|
Kmods SIG |
8b815c |
+ // !!! Note !!!
|
|
Kmods SIG |
8b815c |
+ // This field is presented only if (flags & NTFS_IE_HAS_SUBNODES)
|
|
Kmods SIG |
8b815c |
+ // __le64 vbn;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct NTFS_DE) == 0x10);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void de_set_vbn_le(struct NTFS_DE *e, __le64 vcn)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ __le64 *v = Add2Ptr(e, le16_to_cpu(e->size) - sizeof(__le64));
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ *v = vcn;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void de_set_vbn(struct NTFS_DE *e, CLST vcn)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ __le64 *v = Add2Ptr(e, le16_to_cpu(e->size) - sizeof(__le64));
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ *v = cpu_to_le64(vcn);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline __le64 de_get_vbn_le(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return *(__le64 *)Add2Ptr(e, le16_to_cpu(e->size) - sizeof(__le64));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline CLST de_get_vbn(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ __le64 *v = Add2Ptr(e, le16_to_cpu(e->size) - sizeof(__le64));
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return le64_to_cpu(*v);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct NTFS_DE *de_get_next(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(e, le16_to_cpu(e->size));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct ATTR_FILE_NAME *de_get_fname(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return le16_to_cpu(e->key_size) >= SIZEOF_ATTRIBUTE_FILENAME ?
|
|
Kmods SIG |
8b815c |
+ Add2Ptr(e, sizeof(struct NTFS_DE)) :
|
|
Kmods SIG |
8b815c |
+ NULL;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool de_is_last(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return e->flags & NTFS_IE_LAST;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool de_has_vcn(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return e->flags & NTFS_IE_HAS_SUBNODES;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool de_has_vcn_ex(const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (e->flags & NTFS_IE_HAS_SUBNODES) &&
|
|
Kmods SIG |
8b815c |
+ (u64)(-1) != *((u64 *)Add2Ptr(e, le16_to_cpu(e->size) -
|
|
Kmods SIG |
8b815c |
+ sizeof(__le64)));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define MAX_BYTES_PER_NAME_ENTRY \
|
|
Kmods SIG |
8b815c |
+ QuadAlign(sizeof(struct NTFS_DE) + \
|
|
Kmods SIG |
8b815c |
+ offsetof(struct ATTR_FILE_NAME, name) + \
|
|
Kmods SIG |
8b815c |
+ NTFS_NAME_LEN * sizeof(short))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct INDEX_HDR {
|
|
Kmods SIG |
8b815c |
+ __le32 de_off; // 0x00: The offset from the start of this structure
|
|
Kmods SIG |
8b815c |
+ // to the first NTFS_DE
|
|
Kmods SIG |
8b815c |
+ __le32 used; // 0x04: The size of this structure plus all
|
|
Kmods SIG |
8b815c |
+ // entries (quad-word aligned)
|
|
Kmods SIG |
8b815c |
+ __le32 total; // 0x08: The allocated size of for this structure plus all entries
|
|
Kmods SIG |
8b815c |
+ u8 flags; // 0x0C: 0x00 = Small directory, 0x01 = Large directory
|
|
Kmods SIG |
8b815c |
+ u8 res[3];
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // de_off + used <= total
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct INDEX_HDR) == 0x10);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct NTFS_DE *hdr_first_de(const struct INDEX_HDR *hdr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ u32 de_off = le32_to_cpu(hdr->de_off);
|
|
Kmods SIG |
8b815c |
+ u32 used = le32_to_cpu(hdr->used);
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE *e = Add2Ptr(hdr, de_off);
|
|
Kmods SIG |
8b815c |
+ u16 esize;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (de_off >= used || de_off >= le32_to_cpu(hdr->total))
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ esize = le16_to_cpu(e->size);
|
|
Kmods SIG |
8b815c |
+ if (esize < sizeof(struct NTFS_DE) || de_off + esize > used)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return e;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct NTFS_DE *hdr_next_de(const struct INDEX_HDR *hdr,
|
|
Kmods SIG |
8b815c |
+ const struct NTFS_DE *e)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ size_t off = PtrOffset(hdr, e);
|
|
Kmods SIG |
8b815c |
+ u32 used = le32_to_cpu(hdr->used);
|
|
Kmods SIG |
8b815c |
+ u16 esize;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (off >= used)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ esize = le16_to_cpu(e->size);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (esize < sizeof(struct NTFS_DE) ||
|
|
Kmods SIG |
8b815c |
+ off + esize + sizeof(struct NTFS_DE) > used)
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return Add2Ptr(e, esize);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool hdr_has_subnode(const struct INDEX_HDR *hdr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return hdr->flags & 1;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct INDEX_BUFFER {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_RECORD_HEADER rhdr; // 'INDX'
|
|
Kmods SIG |
8b815c |
+ __le64 vbn; // 0x10: vcn if index >= cluster or vsn id index < cluster
|
|
Kmods SIG |
8b815c |
+ struct INDEX_HDR ihdr; // 0x18:
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct INDEX_BUFFER) == 0x28);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool ib_is_empty(const struct INDEX_BUFFER *ib)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ const struct NTFS_DE *first = hdr_first_de(&ib->ihdr);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return !first || de_is_last(first);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool ib_is_leaf(const struct INDEX_BUFFER *ib)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return !(ib->ihdr.flags & 1);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Index root structure ( 0x90 ) */
|
|
Kmods SIG |
8b815c |
+enum COLLATION_RULE {
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_BINARY = cpu_to_le32(0),
|
|
Kmods SIG |
8b815c |
+ // $I30
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_FILENAME = cpu_to_le32(0x01),
|
|
Kmods SIG |
8b815c |
+ // $SII of $Secure and $Q of Quota
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_UINT = cpu_to_le32(0x10),
|
|
Kmods SIG |
8b815c |
+ // $O of Quota
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_SID = cpu_to_le32(0x11),
|
|
Kmods SIG |
8b815c |
+ // $SDH of $Secure
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_SECURITY_HASH = cpu_to_le32(0x12),
|
|
Kmods SIG |
8b815c |
+ // $O of ObjId and "$R" for Reparse
|
|
Kmods SIG |
8b815c |
+ NTFS_COLLATION_TYPE_UINTS = cpu_to_le32(0x13)
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(enum COLLATION_RULE) == 4);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+struct INDEX_ROOT {
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type; // 0x00: The type of attribute to index on
|
|
Kmods SIG |
8b815c |
+ enum COLLATION_RULE rule; // 0x04: The rule
|
|
Kmods SIG |
8b815c |
+ __le32 index_block_size;// 0x08: The size of index record
|
|
Kmods SIG |
8b815c |
+ u8 index_block_clst; // 0x0C: The number of clusters or sectors per index
|
|
Kmods SIG |
8b815c |
+ u8 res[3];
|
|
Kmods SIG |
8b815c |
+ struct INDEX_HDR ihdr; // 0x10:
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct INDEX_ROOT) == 0x20);
|
|
Kmods SIG |
8b815c |
+static_assert(offsetof(struct INDEX_ROOT, ihdr) == 0x10);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define VOLUME_FLAG_DIRTY cpu_to_le16(0x0001)
|
|
Kmods SIG |
8b815c |
+#define VOLUME_FLAG_RESIZE_LOG_FILE cpu_to_le16(0x0002)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct VOLUME_INFO {
|
|
Kmods SIG |
8b815c |
+ __le64 res1; // 0x00
|
|
Kmods SIG |
8b815c |
+ u8 major_ver; // 0x08: NTFS major version number (before .)
|
|
Kmods SIG |
8b815c |
+ u8 minor_ver; // 0x09: NTFS minor version number (after .)
|
|
Kmods SIG |
8b815c |
+ __le16 flags; // 0x0A: Volume flags, see VOLUME_FLAG_XXX
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+}; // sizeof=0xC
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_ATTRIBUTE_VOLUME_INFO 0xc
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define NTFS_LABEL_MAX_LENGTH (0x100 / sizeof(short))
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_INDEXABLE cpu_to_le32(0x00000002)
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_DUPALLOWED cpu_to_le32(0x00000004)
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_MUST_BE_INDEXED cpu_to_le32(0x00000010)
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_MUST_BE_NAMED cpu_to_le32(0x00000020)
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_MUST_BE_RESIDENT cpu_to_le32(0x00000040)
|
|
Kmods SIG |
8b815c |
+#define NTFS_ATTR_LOG_ALWAYS cpu_to_le32(0x00000080)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* $AttrDef file entry */
|
|
Kmods SIG |
8b815c |
+struct ATTR_DEF_ENTRY {
|
|
Kmods SIG |
8b815c |
+ __le16 name[0x40]; // 0x00: Attr name
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type; // 0x80: struct ATTRIB type
|
|
Kmods SIG |
8b815c |
+ __le32 res; // 0x84:
|
|
Kmods SIG |
8b815c |
+ enum COLLATION_RULE rule; // 0x88:
|
|
Kmods SIG |
8b815c |
+ __le32 flags; // 0x8C: NTFS_ATTR_XXX (see above)
|
|
Kmods SIG |
8b815c |
+ __le64 min_sz; // 0x90: Minimum attribute data size
|
|
Kmods SIG |
8b815c |
+ __le64 max_sz; // 0x98: Maximum attribute data size
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ATTR_DEF_ENTRY) == 0xa0);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Object ID (0x40) */
|
|
Kmods SIG |
8b815c |
+struct OBJECT_ID {
|
|
Kmods SIG |
8b815c |
+ struct GUID ObjId; // 0x00: Unique Id assigned to file
|
|
Kmods SIG |
8b815c |
+ struct GUID BirthVolumeId;// 0x10: Birth Volume Id is the Object Id of the Volume on
|
|
Kmods SIG |
8b815c |
+ // which the Object Id was allocated. It never changes
|
|
Kmods SIG |
8b815c |
+ struct GUID BirthObjectId; // 0x20: Birth Object Id is the first Object Id that was
|
|
Kmods SIG |
8b815c |
+ // ever assigned to this MFT Record. I.e. If the Object Id
|
|
Kmods SIG |
8b815c |
+ // is changed for some reason, this field will reflect the
|
|
Kmods SIG |
8b815c |
+ // original value of the Object Id.
|
|
Kmods SIG |
8b815c |
+ struct GUID DomainId; // 0x30: Domain Id is currently unused but it is intended to be
|
|
Kmods SIG |
8b815c |
+ // used in a network environment where the local machine is
|
|
Kmods SIG |
8b815c |
+ // part of a Windows 2000 Domain. This may be used in a Windows
|
|
Kmods SIG |
8b815c |
+ // 2000 Advanced Server managed domain.
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct OBJECT_ID) == 0x40);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* O Directory entry structure ( rule = 0x13 ) */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE_O {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE de;
|
|
Kmods SIG |
8b815c |
+ struct GUID ObjId; // 0x10: Unique Id assigned to file
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF ref; // 0x20: MFT record number with this file
|
|
Kmods SIG |
8b815c |
+ struct GUID BirthVolumeId; // 0x28: Birth Volume Id is the Object Id of the Volume on
|
|
Kmods SIG |
8b815c |
+ // which the Object Id was allocated. It never changes
|
|
Kmods SIG |
8b815c |
+ struct GUID BirthObjectId; // 0x38: Birth Object Id is the first Object Id that was
|
|
Kmods SIG |
8b815c |
+ // ever assigned to this MFT Record. I.e. If the Object Id
|
|
Kmods SIG |
8b815c |
+ // is changed for some reason, this field will reflect the
|
|
Kmods SIG |
8b815c |
+ // original value of the Object Id.
|
|
Kmods SIG |
8b815c |
+ // This field is valid if data_size == 0x48
|
|
Kmods SIG |
8b815c |
+ struct GUID BirthDomainId; // 0x48: Domain Id is currently unused but it is intended
|
|
Kmods SIG |
8b815c |
+ // to be used in a network environment where the local
|
|
Kmods SIG |
8b815c |
+ // machine is part of a Windows 2000 Domain. This may be
|
|
Kmods SIG |
8b815c |
+ // used in a Windows 2000 Advanced Server managed domain.
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct NTFS_DE_O) == 0x58);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define NTFS_OBJECT_ENTRY_DATA_SIZE1 \
|
|
Kmods SIG |
8b815c |
+ 0x38 // struct NTFS_DE_O.BirthDomainId is not used
|
|
Kmods SIG |
8b815c |
+#define NTFS_OBJECT_ENTRY_DATA_SIZE2 \
|
|
Kmods SIG |
8b815c |
+ 0x48 // struct NTFS_DE_O.BirthDomainId is used
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Q Directory entry structure ( rule = 0x11 ) */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE_Q {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE de;
|
|
Kmods SIG |
8b815c |
+ __le32 owner_id; // 0x10: Unique Id assigned to file
|
|
Kmods SIG |
8b815c |
+ __le32 Version; // 0x14: 0x02
|
|
Kmods SIG |
8b815c |
+ __le32 flags2; // 0x18: Quota flags, see above
|
|
Kmods SIG |
8b815c |
+ __le64 BytesUsed; // 0x1C:
|
|
Kmods SIG |
8b815c |
+ __le64 ChangeTime; // 0x24:
|
|
Kmods SIG |
8b815c |
+ __le64 WarningLimit; // 0x28:
|
|
Kmods SIG |
8b815c |
+ __le64 HardLimit; // 0x34:
|
|
Kmods SIG |
8b815c |
+ __le64 ExceededTime; // 0x3C:
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // SID is placed here
|
|
Kmods SIG |
8b815c |
+}; // sizeof() = 0x44
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_NTFS_DE_Q 0x44
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SecurityDescriptorsBlockSize 0x40000 // 256K
|
|
Kmods SIG |
8b815c |
+#define SecurityDescriptorMaxSize 0x20000 // 128K
|
|
Kmods SIG |
8b815c |
+#define Log2OfSecurityDescriptorsBlockSize 18
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct SECURITY_KEY {
|
|
Kmods SIG |
8b815c |
+ __le32 hash; // Hash value for descriptor
|
|
Kmods SIG |
8b815c |
+ __le32 sec_id; // Security Id (guaranteed unique)
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Security descriptors (the content of $Secure::SDS data stream) */
|
|
Kmods SIG |
8b815c |
+struct SECURITY_HDR {
|
|
Kmods SIG |
8b815c |
+ struct SECURITY_KEY key; // 0x00: Security Key
|
|
Kmods SIG |
8b815c |
+ __le64 off; // 0x08: Offset of this entry in the file
|
|
Kmods SIG |
8b815c |
+ __le32 size; // 0x10: Size of this entry, 8 byte aligned
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Security descriptor itself is placed here
|
|
Kmods SIG |
8b815c |
+ // Total size is 16 byte aligned
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+} __packed;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_SECURITY_HDR 0x14
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* SII Directory entry structure */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE_SII {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE de;
|
|
Kmods SIG |
8b815c |
+ __le32 sec_id; // 0x10: Key: sizeof(security_id) = wKeySize
|
|
Kmods SIG |
8b815c |
+ struct SECURITY_HDR sec_hdr; // 0x14:
|
|
Kmods SIG |
8b815c |
+} __packed;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_SII_DIRENTRY 0x28
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* SDH Directory entry structure */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE_SDH {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE de;
|
|
Kmods SIG |
8b815c |
+ struct SECURITY_KEY key; // 0x10: Key
|
|
Kmods SIG |
8b815c |
+ struct SECURITY_HDR sec_hdr; // 0x18: Data
|
|
Kmods SIG |
8b815c |
+ __le16 magic[2]; // 0x2C: 0x00490049 "I I"
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_SDH_DIRENTRY 0x30
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct REPARSE_KEY {
|
|
Kmods SIG |
8b815c |
+ __le32 ReparseTag; // 0x00: Reparse Tag
|
|
Kmods SIG |
8b815c |
+ struct MFT_REF ref; // 0x04: MFT record number with this file
|
|
Kmods SIG |
8b815c |
+}; // sizeof() = 0x0C
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(offsetof(struct REPARSE_KEY, ref) == 0x04);
|
|
Kmods SIG |
8b815c |
+#define SIZEOF_REPARSE_KEY 0x0C
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Reparse Directory entry structure */
|
|
Kmods SIG |
8b815c |
+struct NTFS_DE_R {
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE de;
|
|
Kmods SIG |
8b815c |
+ struct REPARSE_KEY key; // 0x10: Reparse Key
|
|
Kmods SIG |
8b815c |
+ u32 zero; // 0x1c
|
|
Kmods SIG |
8b815c |
+}; // sizeof() = 0x20
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct NTFS_DE_R) == 0x20);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* CompressReparseBuffer.WofVersion */
|
|
Kmods SIG |
8b815c |
+#define WOF_CURRENT_VERSION cpu_to_le32(1)
|
|
Kmods SIG |
8b815c |
+/* CompressReparseBuffer.WofProvider */
|
|
Kmods SIG |
8b815c |
+#define WOF_PROVIDER_WIM cpu_to_le32(1)
|
|
Kmods SIG |
8b815c |
+/* CompressReparseBuffer.WofProvider */
|
|
Kmods SIG |
8b815c |
+#define WOF_PROVIDER_SYSTEM cpu_to_le32(2)
|
|
Kmods SIG |
8b815c |
+/* CompressReparseBuffer.ProviderVer */
|
|
Kmods SIG |
8b815c |
+#define WOF_PROVIDER_CURRENT_VERSION cpu_to_le32(1)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define WOF_COMPRESSION_XPRESS4K cpu_to_le32(0) // 4k
|
|
Kmods SIG |
8b815c |
+#define WOF_COMPRESSION_LZX32K cpu_to_le32(1) // 32k
|
|
Kmods SIG |
8b815c |
+#define WOF_COMPRESSION_XPRESS8K cpu_to_le32(2) // 8k
|
|
Kmods SIG |
8b815c |
+#define WOF_COMPRESSION_XPRESS16K cpu_to_le32(3) // 16k
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * ATTR_REPARSE (0xC0)
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * The reparse struct GUID structure is used by all 3rd party layered drivers to
|
|
Kmods SIG |
8b815c |
+ * store data in a reparse point. For non-Microsoft tags, The struct GUID field
|
|
Kmods SIG |
8b815c |
+ * cannot be GUID_NULL.
|
|
Kmods SIG |
8b815c |
+ * The constraints on reparse tags are defined below.
|
|
Kmods SIG |
8b815c |
+ * Microsoft tags can also be used with this format of the reparse point buffer.
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+struct REPARSE_POINT {
|
|
Kmods SIG |
8b815c |
+ __le32 ReparseTag; // 0x00:
|
|
Kmods SIG |
8b815c |
+ __le16 ReparseDataLength;// 0x04:
|
|
Kmods SIG |
8b815c |
+ __le16 Reserved;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct GUID Guid; // 0x08:
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Here GenericReparseBuffer is placed
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct REPARSE_POINT) == 0x18);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// Maximum allowed size of the reparse data.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// The value of the following constant needs to satisfy the following
|
|
Kmods SIG |
8b815c |
+// conditions:
|
|
Kmods SIG |
8b815c |
+// (1) Be at least as large as the largest of the reserved tags.
|
|
Kmods SIG |
8b815c |
+// (2) Be strictly smaller than all the tags in use.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define IO_REPARSE_TAG_RESERVED_RANGE 1
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// The reparse tags are a ULONG. The 32 bits are laid out as follows:
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
|
Kmods SIG |
8b815c |
+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
|
Kmods SIG |
8b815c |
+// +-+-+-+-+-----------------------+-------------------------------+
|
|
Kmods SIG |
8b815c |
+// |M|R|N|R| Reserved bits | Reparse Tag Value |
|
|
Kmods SIG |
8b815c |
+// +-+-+-+-+-----------------------+-------------------------------+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// M is the Microsoft bit. When set to 1, it denotes a tag owned by Microsoft.
|
|
Kmods SIG |
8b815c |
+// All ISVs must use a tag with a 0 in this position.
|
|
Kmods SIG |
8b815c |
+// Note: If a Microsoft tag is used by non-Microsoft software, the
|
|
Kmods SIG |
8b815c |
+// behavior is not defined.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// R is reserved. Must be zero for non-Microsoft tags.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// N is name surrogate. When set to 1, the file represents another named
|
|
Kmods SIG |
8b815c |
+// entity in the system.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// The M and N bits are OR-able.
|
|
Kmods SIG |
8b815c |
+// The following macros check for the M and N bit values:
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// Macro to determine whether a reparse point tag corresponds to a tag
|
|
Kmods SIG |
8b815c |
+// owned by Microsoft.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define IsReparseTagMicrosoft(_tag) (((_tag)&IO_REPARSE_TAG_MICROSOFT))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// Macro to determine whether a reparse point tag is a name surrogate
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define IsReparseTagNameSurrogate(_tag) (((_tag)&IO_REPARSE_TAG_NAME_SURROGATE))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// The following constant represents the bits that are valid to use in
|
|
Kmods SIG |
8b815c |
+// reparse tags.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define IO_REPARSE_TAG_VALID_VALUES 0xF000FFFF
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// Macro to determine whether a reparse tag is a valid tag.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+#define IsReparseTagValid(_tag) \
|
|
Kmods SIG |
8b815c |
+ (!((_tag) & ~IO_REPARSE_TAG_VALID_VALUES) && \
|
|
Kmods SIG |
8b815c |
+ ((_tag) > IO_REPARSE_TAG_RESERVED_RANGE))
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+// Microsoft tags for reparse points.
|
|
Kmods SIG |
8b815c |
+//
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum IO_REPARSE_TAG {
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_SYMBOLIC_LINK = cpu_to_le32(0),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_NAME_SURROGATE = cpu_to_le32(0x20000000),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_MICROSOFT = cpu_to_le32(0x80000000),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_MOUNT_POINT = cpu_to_le32(0xA0000003),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_SYMLINK = cpu_to_le32(0xA000000C),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_HSM = cpu_to_le32(0xC0000004),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_SIS = cpu_to_le32(0x80000007),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_DEDUP = cpu_to_le32(0x80000013),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_COMPRESS = cpu_to_le32(0x80000017),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // The reparse tag 0x80000008 is reserved for Microsoft internal use
|
|
Kmods SIG |
8b815c |
+ // (may be published in the future)
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Microsoft reparse tag reserved for DFS
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_DFS = cpu_to_le32(0x8000000A),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Microsoft reparse tag reserved for the file system filter manager
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_FILTER_MANAGER = cpu_to_le32(0x8000000B),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Non-Microsoft tags for reparse points
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Tag allocated to CONGRUENT, May 2000. Used by IFSTEST
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_IFSTEST_CONGRUENT = cpu_to_le32(0x00000009),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Tag allocated to ARKIVIO
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_ARKIVIO = cpu_to_le32(0x0000000C),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Tag allocated to SOLUTIONSOFT
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_SOLUTIONSOFT = cpu_to_le32(0x2000000D),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ // Tag allocated to COMMVAULT
|
|
Kmods SIG |
8b815c |
+ //
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_COMMVAULT = cpu_to_le32(0x0000000E),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // OneDrive??
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD = cpu_to_le32(0x9000001A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_1 = cpu_to_le32(0x9000101A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_2 = cpu_to_le32(0x9000201A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_3 = cpu_to_le32(0x9000301A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_4 = cpu_to_le32(0x9000401A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_5 = cpu_to_le32(0x9000501A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_6 = cpu_to_le32(0x9000601A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_7 = cpu_to_le32(0x9000701A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_8 = cpu_to_le32(0x9000801A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_9 = cpu_to_le32(0x9000901A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_A = cpu_to_le32(0x9000A01A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_B = cpu_to_le32(0x9000B01A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_C = cpu_to_le32(0x9000C01A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_D = cpu_to_le32(0x9000D01A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_E = cpu_to_le32(0x9000E01A),
|
|
Kmods SIG |
8b815c |
+ IO_REPARSE_TAG_CLOUD_F = cpu_to_le32(0x9000F01A),
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SYMLINK_FLAG_RELATIVE 1
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Microsoft reparse buffer. (see DDK for details) */
|
|
Kmods SIG |
8b815c |
+struct REPARSE_DATA_BUFFER {
|
|
Kmods SIG |
8b815c |
+ __le32 ReparseTag; // 0x00:
|
|
Kmods SIG |
8b815c |
+ __le16 ReparseDataLength; // 0x04:
|
|
Kmods SIG |
8b815c |
+ __le16 Reserved;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ union {
|
|
Kmods SIG |
8b815c |
+ // If ReparseTag == 0xA0000003 (IO_REPARSE_TAG_MOUNT_POINT)
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ __le16 SubstituteNameOffset; // 0x08
|
|
Kmods SIG |
8b815c |
+ __le16 SubstituteNameLength; // 0x0A
|
|
Kmods SIG |
8b815c |
+ __le16 PrintNameOffset; // 0x0C
|
|
Kmods SIG |
8b815c |
+ __le16 PrintNameLength; // 0x0E
|
|
Kmods SIG |
8b815c |
+ __le16 PathBuffer[]; // 0x10
|
|
Kmods SIG |
8b815c |
+ } MountPointReparseBuffer;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // If ReparseTag == 0xA000000C (IO_REPARSE_TAG_SYMLINK)
|
|
Kmods SIG |
8b815c |
+ // https://msdn.microsoft.com/en-us/library/cc232006.aspx
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ __le16 SubstituteNameOffset; // 0x08
|
|
Kmods SIG |
8b815c |
+ __le16 SubstituteNameLength; // 0x0A
|
|
Kmods SIG |
8b815c |
+ __le16 PrintNameOffset; // 0x0C
|
|
Kmods SIG |
8b815c |
+ __le16 PrintNameLength; // 0x0E
|
|
Kmods SIG |
8b815c |
+ // 0-absolute path 1- relative path, SYMLINK_FLAG_RELATIVE
|
|
Kmods SIG |
8b815c |
+ __le32 Flags; // 0x10
|
|
Kmods SIG |
8b815c |
+ __le16 PathBuffer[]; // 0x14
|
|
Kmods SIG |
8b815c |
+ } SymbolicLinkReparseBuffer;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // If ReparseTag == 0x80000017U
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ __le32 WofVersion; // 0x08 == 1
|
|
Kmods SIG |
8b815c |
+ /* 1 - WIM backing provider ("WIMBoot"),
|
|
Kmods SIG |
8b815c |
+ * 2 - System compressed file provider
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ __le32 WofProvider; // 0x0C
|
|
Kmods SIG |
8b815c |
+ __le32 ProviderVer; // 0x10: == 1 WOF_FILE_PROVIDER_CURRENT_VERSION == 1
|
|
Kmods SIG |
8b815c |
+ __le32 CompressionFormat; // 0x14: 0, 1, 2, 3. See WOF_COMPRESSION_XXX
|
|
Kmods SIG |
8b815c |
+ } CompressReparseBuffer;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ u8 DataBuffer[1]; // 0x08
|
|
Kmods SIG |
8b815c |
+ } GenericReparseBuffer;
|
|
Kmods SIG |
8b815c |
+ };
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ATTR_EA_INFO (0xD0) */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define FILE_NEED_EA 0x80 // See ntifs.h
|
|
Kmods SIG |
8b815c |
+/* FILE_NEED_EA, indicates that the file to which the EA belongs cannot be
|
|
Kmods SIG |
8b815c |
+ * interpreted without understanding the associated extended attributes.
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+struct EA_INFO {
|
|
Kmods SIG |
8b815c |
+ __le16 size_pack; // 0x00: Size of buffer to hold in packed form
|
|
Kmods SIG |
8b815c |
+ __le16 count; // 0x02: Count of EA's with FILE_NEED_EA bit set
|
|
Kmods SIG |
8b815c |
+ __le32 size; // 0x04: Size of buffer to hold in unpacked form
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct EA_INFO) == 8);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ATTR_EA (0xE0) */
|
|
Kmods SIG |
8b815c |
+struct EA_FULL {
|
|
Kmods SIG |
8b815c |
+ __le32 size; // 0x00: (not in packed)
|
|
Kmods SIG |
8b815c |
+ u8 flags; // 0x04
|
|
Kmods SIG |
8b815c |
+ u8 name_len; // 0x05
|
|
Kmods SIG |
8b815c |
+ __le16 elength; // 0x06
|
|
Kmods SIG |
8b815c |
+ u8 name[]; // 0x08
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static_assert(offsetof(struct EA_FULL, name) == 8);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define ACL_REVISION 2
|
|
Kmods SIG |
8b815c |
+#define ACL_REVISION_DS 4
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define SE_SELF_RELATIVE cpu_to_le16(0x8000)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct SECURITY_DESCRIPTOR_RELATIVE {
|
|
Kmods SIG |
8b815c |
+ u8 Revision;
|
|
Kmods SIG |
8b815c |
+ u8 Sbz1;
|
|
Kmods SIG |
8b815c |
+ __le16 Control;
|
|
Kmods SIG |
8b815c |
+ __le32 Owner;
|
|
Kmods SIG |
8b815c |
+ __le32 Group;
|
|
Kmods SIG |
8b815c |
+ __le32 Sacl;
|
|
Kmods SIG |
8b815c |
+ __le32 Dacl;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct SECURITY_DESCRIPTOR_RELATIVE) == 0x14);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ACE_HEADER {
|
|
Kmods SIG |
8b815c |
+ u8 AceType;
|
|
Kmods SIG |
8b815c |
+ u8 AceFlags;
|
|
Kmods SIG |
8b815c |
+ __le16 AceSize;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ACE_HEADER) == 4);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ACL {
|
|
Kmods SIG |
8b815c |
+ u8 AclRevision;
|
|
Kmods SIG |
8b815c |
+ u8 Sbz1;
|
|
Kmods SIG |
8b815c |
+ __le16 AclSize;
|
|
Kmods SIG |
8b815c |
+ __le16 AceCount;
|
|
Kmods SIG |
8b815c |
+ __le16 Sbz2;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+static_assert(sizeof(struct ACL) == 8);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct SID {
|
|
Kmods SIG |
8b815c |
+ u8 Revision;
|
|
Kmods SIG |
8b815c |
+ u8 SubAuthorityCount;
|
|
Kmods SIG |
8b815c |
+ u8 IdentifierAuthority[6];
|
|
Kmods SIG |
8b815c |
+ __le32 SubAuthority[];
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+static_assert(offsetof(struct SID, SubAuthority) == 8);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+// clang-format on
|
|
Kmods SIG |
8b815c |
diff --git a/src/ntfs_fs.h b/src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
new file mode 100644
|
|
Kmods SIG |
8b815c |
index 0000000000000000000000000000000000000000..0c3ac89c3115da8131a66281c1c3c7da112d07ff
|
|
Kmods SIG |
8b815c |
--- /dev/null
|
|
Kmods SIG |
8b815c |
+++ b/src/ntfs_fs.h
|
|
Kmods SIG |
8b815c |
@@ -0,0 +1,1092 @@
|
|
Kmods SIG |
8b815c |
+/* SPDX-License-Identifier: GPL-2.0 */
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+// clang-format off
|
|
Kmods SIG |
8b815c |
+#define MINUS_ONE_T ((size_t)(-1))
|
|
Kmods SIG |
8b815c |
+/* Biggest MFT / smallest cluster */
|
|
Kmods SIG |
8b815c |
+#define MAXIMUM_BYTES_PER_MFT 4096
|
|
Kmods SIG |
8b815c |
+#define NTFS_BLOCKS_PER_MFT_RECORD (MAXIMUM_BYTES_PER_MFT / 512)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define MAXIMUM_BYTES_PER_INDEX 4096
|
|
Kmods SIG |
8b815c |
+#define NTFS_BLOCKS_PER_INODE (MAXIMUM_BYTES_PER_INDEX / 512)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ntfs specific error code when fixup failed*/
|
|
Kmods SIG |
8b815c |
+#define E_NTFS_FIXUP 555
|
|
Kmods SIG |
8b815c |
+/* ntfs specific error code about resident->nonresident*/
|
|
Kmods SIG |
8b815c |
+#define E_NTFS_NONRESIDENT 556
|
|
Kmods SIG |
8b815c |
+/* ntfs specific error code about punch hole*/
|
|
Kmods SIG |
8b815c |
+#define E_NTFS_NOTALIGNED 557
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* sbi->flags */
|
|
Kmods SIG |
8b815c |
+#define NTFS_FLAGS_NODISCARD 0x00000001
|
|
Kmods SIG |
8b815c |
+/* Set when LogFile is replaying */
|
|
Kmods SIG |
8b815c |
+#define NTFS_FLAGS_LOG_REPLAYING 0x00000008
|
|
Kmods SIG |
8b815c |
+/* Set when we changed first MFT's which copy must be updated in $MftMirr */
|
|
Kmods SIG |
8b815c |
+#define NTFS_FLAGS_MFTMIRR 0x00001000
|
|
Kmods SIG |
8b815c |
+#define NTFS_FLAGS_NEED_REPLAY 0x04000000
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ni->ni_flags */
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Data attribute is external compressed (lzx/xpress)
|
|
Kmods SIG |
8b815c |
+ * 1 - WOF_COMPRESSION_XPRESS4K
|
|
Kmods SIG |
8b815c |
+ * 2 - WOF_COMPRESSION_XPRESS8K
|
|
Kmods SIG |
8b815c |
+ * 3 - WOF_COMPRESSION_XPRESS16K
|
|
Kmods SIG |
8b815c |
+ * 4 - WOF_COMPRESSION_LZX32K
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_COMPRESSED_MASK 0x0000000f
|
|
Kmods SIG |
8b815c |
+/* Data attribute is deduplicated */
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_DEDUPLICATED 0x00000010
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_EA 0x00000020
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_DIR 0x00000040
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_RESIDENT 0x00000080
|
|
Kmods SIG |
8b815c |
+#define NI_FLAG_UPDATE_PARENT 0x00000100
|
|
Kmods SIG |
8b815c |
+// clang-format on
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ntfs_mount_options {
|
|
Kmods SIG |
8b815c |
+ struct nls_table *nls;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ kuid_t fs_uid;
|
|
Kmods SIG |
8b815c |
+ kgid_t fs_gid;
|
|
Kmods SIG |
8b815c |
+ u16 fs_fmask_inv;
|
|
Kmods SIG |
8b815c |
+ u16 fs_dmask_inv;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ unsigned uid : 1, /* uid was set */
|
|
Kmods SIG |
8b815c |
+ gid : 1, /* gid was set */
|
|
Kmods SIG |
8b815c |
+ fmask : 1, /* fmask was set */
|
|
Kmods SIG |
8b815c |
+ dmask : 1, /*dmask was set*/
|
|
Kmods SIG |
8b815c |
+ sys_immutable : 1, /* immutable system files */
|
|
Kmods SIG |
8b815c |
+ discard : 1, /* issue discard requests on deletions */
|
|
Kmods SIG |
8b815c |
+ sparse : 1, /*create sparse files*/
|
|
Kmods SIG |
8b815c |
+ showmeta : 1, /*show meta files*/
|
|
Kmods SIG |
8b815c |
+ nohidden : 1, /*do not show hidden files*/
|
|
Kmods SIG |
8b815c |
+ force : 1, /*rw mount dirty volume*/
|
|
Kmods SIG |
8b815c |
+ no_acs_rules : 1, /*exclude acs rules*/
|
|
Kmods SIG |
8b815c |
+ prealloc : 1 /*preallocate space when file is growing*/
|
|
Kmods SIG |
8b815c |
+ ;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* special value to unpack and deallocate*/
|
|
Kmods SIG |
8b815c |
+#define RUN_DEALLOCATE ((struct runs_tree *)(size_t)1)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* TODO: use rb tree instead of array */
|
|
Kmods SIG |
8b815c |
+struct runs_tree {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_run *runs;
|
|
Kmods SIG |
8b815c |
+ size_t count; // Currently used size a ntfs_run storage.
|
|
Kmods SIG |
8b815c |
+ size_t allocated; // Currently allocated ntfs_run storage size.
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ntfs_buffers {
|
|
Kmods SIG |
8b815c |
+ /* Biggest MFT / smallest cluster = 4096 / 512 = 8 */
|
|
Kmods SIG |
8b815c |
+ /* Biggest index / smallest cluster = 4096 / 512 = 8 */
|
|
Kmods SIG |
8b815c |
+ struct buffer_head *bh[PAGE_SIZE >> SECTOR_SHIFT];
|
|
Kmods SIG |
8b815c |
+ u32 bytes;
|
|
Kmods SIG |
8b815c |
+ u32 nbufs;
|
|
Kmods SIG |
8b815c |
+ u32 off;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum ALLOCATE_OPT {
|
|
Kmods SIG |
8b815c |
+ ALLOCATE_DEF = 0, // Allocate all clusters
|
|
Kmods SIG |
8b815c |
+ ALLOCATE_MFT = 1, // Allocate for MFT
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum bitmap_mutex_classes {
|
|
Kmods SIG |
8b815c |
+ BITMAP_MUTEX_CLUSTERS = 0,
|
|
Kmods SIG |
8b815c |
+ BITMAP_MUTEX_MFT = 1,
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct wnd_bitmap {
|
|
Kmods SIG |
8b815c |
+ struct super_block *sb;
|
|
Kmods SIG |
8b815c |
+ struct rw_semaphore rw_lock;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct runs_tree run;
|
|
Kmods SIG |
8b815c |
+ size_t nbits;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ size_t total_zeroes; // total number of free bits
|
|
Kmods SIG |
8b815c |
+ u16 *free_bits; // free bits in each window
|
|
Kmods SIG |
8b815c |
+ size_t nwnd;
|
|
Kmods SIG |
8b815c |
+ u32 bits_last; // bits in last window
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct rb_root start_tree; // extents, sorted by 'start'
|
|
Kmods SIG |
8b815c |
+ struct rb_root count_tree; // extents, sorted by 'count + start'
|
|
Kmods SIG |
8b815c |
+ size_t count; // extents count
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /*
|
|
Kmods SIG |
8b815c |
+ * -1 Tree is activated but not updated (too many fragments)
|
|
Kmods SIG |
8b815c |
+ * 0 - Tree is not activated
|
|
Kmods SIG |
8b815c |
+ * 1 - Tree is activated and updated
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ int uptodated;
|
|
Kmods SIG |
8b815c |
+ size_t extent_min; // Minimal extent used while building
|
|
Kmods SIG |
8b815c |
+ size_t extent_max; // Upper estimate of biggest free block
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /* Zone [bit, end) */
|
|
Kmods SIG |
8b815c |
+ size_t zone_bit;
|
|
Kmods SIG |
8b815c |
+ size_t zone_end;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ bool set_tail; // not necessary in driver
|
|
Kmods SIG |
8b815c |
+ bool inited;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+typedef int (*NTFS_CMP_FUNC)(const void *key1, size_t len1, const void *key2,
|
|
Kmods SIG |
8b815c |
+ size_t len2, const void *param);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum index_mutex_classed {
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_I30 = 0,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_SII = 1,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_SDH = 2,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_SO = 3,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_SQ = 4,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_SR = 5,
|
|
Kmods SIG |
8b815c |
+ INDEX_MUTEX_TOTAL
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ntfs_index - allocation unit inside directory */
|
|
Kmods SIG |
8b815c |
+struct ntfs_index {
|
|
Kmods SIG |
8b815c |
+ struct runs_tree bitmap_run;
|
|
Kmods SIG |
8b815c |
+ struct runs_tree alloc_run;
|
|
Kmods SIG |
8b815c |
+ /* read/write access to 'bitmap_run'/'alloc_run' while ntfs_readdir */
|
|
Kmods SIG |
8b815c |
+ struct rw_semaphore run_lock;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /*TODO: remove 'cmp'*/
|
|
Kmods SIG |
8b815c |
+ NTFS_CMP_FUNC cmp;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u8 index_bits; // log2(root->index_block_size)
|
|
Kmods SIG |
8b815c |
+ u8 idx2vbn_bits; // log2(root->index_block_clst)
|
|
Kmods SIG |
8b815c |
+ u8 vbn2vbo_bits; // index_block_size < cluster? 9 : cluster_bits
|
|
Kmods SIG |
8b815c |
+ u8 type; // index_mutex_classed
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Minimum mft zone */
|
|
Kmods SIG |
8b815c |
+#define NTFS_MIN_MFT_ZONE 100
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* ntfs file system in-core superblock data */
|
|
Kmods SIG |
8b815c |
+struct ntfs_sb_info {
|
|
Kmods SIG |
8b815c |
+ struct super_block *sb;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u32 discard_granularity;
|
|
Kmods SIG |
8b815c |
+ u64 discard_granularity_mask_inv; // ~(discard_granularity_mask_inv-1)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u32 cluster_size; // bytes per cluster
|
|
Kmods SIG |
8b815c |
+ u32 cluster_mask; // == cluster_size - 1
|
|
Kmods SIG |
8b815c |
+ u64 cluster_mask_inv; // ~(cluster_size - 1)
|
|
Kmods SIG |
8b815c |
+ u32 block_mask; // sb->s_blocksize - 1
|
|
Kmods SIG |
8b815c |
+ u32 blocks_per_cluster; // cluster_size / sb->s_blocksize
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u32 record_size;
|
|
Kmods SIG |
8b815c |
+ u32 sector_size;
|
|
Kmods SIG |
8b815c |
+ u32 index_size;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u8 sector_bits;
|
|
Kmods SIG |
8b815c |
+ u8 cluster_bits;
|
|
Kmods SIG |
8b815c |
+ u8 record_bits;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u64 maxbytes; // Maximum size for normal files
|
|
Kmods SIG |
8b815c |
+ u64 maxbytes_sparse; // Maximum size for sparse file
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u32 flags; // See NTFS_FLAGS_XXX
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ CLST bad_clusters; // The count of marked bad clusters
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u16 max_bytes_per_attr; // maximum attribute size in record
|
|
Kmods SIG |
8b815c |
+ u16 attr_size_tr; // attribute size threshold (320 bytes)
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /* Records in $Extend */
|
|
Kmods SIG |
8b815c |
+ CLST objid_no;
|
|
Kmods SIG |
8b815c |
+ CLST quota_no;
|
|
Kmods SIG |
8b815c |
+ CLST reparse_no;
|
|
Kmods SIG |
8b815c |
+ CLST usn_jrnl_no;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct ATTR_DEF_ENTRY *def_table; // attribute definition table
|
|
Kmods SIG |
8b815c |
+ u32 def_entries;
|
|
Kmods SIG |
8b815c |
+ u32 ea_max_size;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct MFT_REC *new_rec;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ u16 *upcase;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ u64 lbo, lbo2;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni;
|
|
Kmods SIG |
8b815c |
+ struct wnd_bitmap bitmap; // $MFT::Bitmap
|
|
Kmods SIG |
8b815c |
+ /*
|
|
Kmods SIG |
8b815c |
+ * MFT records [11-24) used to expand MFT itself
|
|
Kmods SIG |
8b815c |
+ * They always marked as used in $MFT::Bitmap
|
|
Kmods SIG |
8b815c |
+ * 'reserved_bitmap' contains real bitmap of these records
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ ulong reserved_bitmap; // bitmap of used records [11 - 24)
|
|
Kmods SIG |
8b815c |
+ size_t next_free; // The next record to allocate from
|
|
Kmods SIG |
8b815c |
+ size_t used; // mft valid size in records
|
|
Kmods SIG |
8b815c |
+ u32 recs_mirr; // Number of records in MFTMirr
|
|
Kmods SIG |
8b815c |
+ u8 next_reserved;
|
|
Kmods SIG |
8b815c |
+ u8 reserved_bitmap_inited;
|
|
Kmods SIG |
8b815c |
+ } mft;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct wnd_bitmap bitmap; // $Bitmap::Data
|
|
Kmods SIG |
8b815c |
+ CLST next_free_lcn;
|
|
Kmods SIG |
8b815c |
+ } used;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ u64 size; // in bytes
|
|
Kmods SIG |
8b815c |
+ u64 blocks; // in blocks
|
|
Kmods SIG |
8b815c |
+ u64 ser_num;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni;
|
|
Kmods SIG |
8b815c |
+ __le16 flags; // cached current VOLUME_INFO::flags, VOLUME_FLAG_DIRTY
|
|
Kmods SIG |
8b815c |
+ u8 major_ver;
|
|
Kmods SIG |
8b815c |
+ u8 minor_ver;
|
|
Kmods SIG |
8b815c |
+ char label[65];
|
|
Kmods SIG |
8b815c |
+ bool real_dirty; /* real fs state*/
|
|
Kmods SIG |
8b815c |
+ } volume;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_index index_sii;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_index index_sdh;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni;
|
|
Kmods SIG |
8b815c |
+ u32 next_id;
|
|
Kmods SIG |
8b815c |
+ u64 next_off;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ __le32 def_security_id;
|
|
Kmods SIG |
8b815c |
+ } security;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_index index_r;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni;
|
|
Kmods SIG |
8b815c |
+ u64 max_size; // 16K
|
|
Kmods SIG |
8b815c |
+ } reparse;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_index index_o;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni;
|
|
Kmods SIG |
8b815c |
+ } objid;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct mutex mtx_lznt;
|
|
Kmods SIG |
8b815c |
+ struct lznt *lznt;
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_LZX_XPRESS
|
|
Kmods SIG |
8b815c |
+ struct mutex mtx_xpress;
|
|
Kmods SIG |
8b815c |
+ struct xpress_decompressor *xpress;
|
|
Kmods SIG |
8b815c |
+ struct mutex mtx_lzx;
|
|
Kmods SIG |
8b815c |
+ struct lzx_decompressor *lzx;
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+ } compress;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct ntfs_mount_options options;
|
|
Kmods SIG |
8b815c |
+ struct ratelimit_state msg_ratelimit;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * one MFT record(usually 1024 bytes), consists of attributes
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+struct mft_inode {
|
|
Kmods SIG |
8b815c |
+ struct rb_node node;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_sb_info *sbi;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct MFT_REC *mrec;
|
|
Kmods SIG |
8b815c |
+ struct ntfs_buffers nb;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ CLST rno;
|
|
Kmods SIG |
8b815c |
+ bool dirty;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* nested class for ntfs_inode::ni_lock */
|
|
Kmods SIG |
8b815c |
+enum ntfs_inode_mutex_lock_class {
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_DIRTY,
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_SECURITY,
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_OBJID,
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_REPARSE,
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_NORMAL,
|
|
Kmods SIG |
8b815c |
+ NTFS_INODE_MUTEX_PARENT,
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * ntfs inode - extends linux inode. consists of one or more mft inodes
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+struct ntfs_inode {
|
|
Kmods SIG |
8b815c |
+ struct mft_inode mi; // base record
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /*
|
|
Kmods SIG |
8b815c |
+ * Valid size: [0 - i_valid) - these range in file contains valid data
|
|
Kmods SIG |
8b815c |
+ * Range [i_valid - inode->i_size) - contains 0
|
|
Kmods SIG |
8b815c |
+ * Usually i_valid <= inode->i_size
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ u64 i_valid;
|
|
Kmods SIG |
8b815c |
+ struct timespec64 i_crtime;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct mutex ni_lock;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /* file attributes from std */
|
|
Kmods SIG |
8b815c |
+ enum FILE_ATTRIBUTE std_fa;
|
|
Kmods SIG |
8b815c |
+ __le32 std_security_id;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /*
|
|
Kmods SIG |
8b815c |
+ * tree of mft_inode
|
|
Kmods SIG |
8b815c |
+ * not empty when primary MFT record (usually 1024 bytes) can't save all attributes
|
|
Kmods SIG |
8b815c |
+ * e.g. file becomes too fragmented or contains a lot of names
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ struct rb_root mi_tree;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ /*
|
|
Kmods SIG |
8b815c |
+ * This member is used in ntfs_readdir to ensure that all subrecords are loaded
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+ u8 mi_loaded;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ union {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_index dir;
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct rw_semaphore run_lock;
|
|
Kmods SIG |
8b815c |
+ struct runs_tree run;
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_LZX_XPRESS
|
|
Kmods SIG |
8b815c |
+ struct page *offs_page;
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+ } file;
|
|
Kmods SIG |
8b815c |
+ };
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct {
|
|
Kmods SIG |
8b815c |
+ struct runs_tree run;
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le; // 1K aligned memory
|
|
Kmods SIG |
8b815c |
+ size_t size;
|
|
Kmods SIG |
8b815c |
+ bool dirty;
|
|
Kmods SIG |
8b815c |
+ } attr_list;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ size_t ni_flags; // NI_FLAG_XXX
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ struct inode vfs_inode;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct indx_node {
|
|
Kmods SIG |
8b815c |
+ struct ntfs_buffers nb;
|
|
Kmods SIG |
8b815c |
+ struct INDEX_BUFFER *index;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+struct ntfs_fnd {
|
|
Kmods SIG |
8b815c |
+ int level;
|
|
Kmods SIG |
8b815c |
+ struct indx_node *nodes[20];
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE *de[20];
|
|
Kmods SIG |
8b815c |
+ struct NTFS_DE *root_de;
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+enum REPARSE_SIGN {
|
|
Kmods SIG |
8b815c |
+ REPARSE_NONE = 0,
|
|
Kmods SIG |
8b815c |
+ REPARSE_COMPRESSED = 1,
|
|
Kmods SIG |
8b815c |
+ REPARSE_DEDUPLICATED = 2,
|
|
Kmods SIG |
8b815c |
+ REPARSE_LINK = 3
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* functions from attrib.c*/
|
|
Kmods SIG |
8b815c |
+int attr_load_runs(struct ATTRIB *attr, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct runs_tree *run, const CLST *vcn);
|
|
Kmods SIG |
8b815c |
+int attr_allocate_clusters(struct ntfs_sb_info *sbi, struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ CLST vcn, CLST lcn, CLST len, CLST *pre_alloc,
|
|
Kmods SIG |
8b815c |
+ enum ALLOCATE_OPT opt, CLST *alen, const size_t fr,
|
|
Kmods SIG |
8b815c |
+ CLST *new_lcn);
|
|
Kmods SIG |
8b815c |
+int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le, struct mft_inode *mi,
|
|
Kmods SIG |
8b815c |
+ u64 new_size, struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ struct ATTRIB **ins_attr, struct page *page);
|
|
Kmods SIG |
8b815c |
+int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len, struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ u64 new_size, const u64 *new_valid, bool keep_prealloc,
|
|
Kmods SIG |
8b815c |
+ struct ATTRIB **ret);
|
|
Kmods SIG |
8b815c |
+int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
|
|
Kmods SIG |
8b815c |
+ CLST *len, bool *new);
|
|
Kmods SIG |
8b815c |
+int attr_data_read_resident(struct ntfs_inode *ni, struct page *page);
|
|
Kmods SIG |
8b815c |
+int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
|
|
Kmods SIG |
8b815c |
+int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len, struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ CLST vcn);
|
|
Kmods SIG |
8b815c |
+int attr_load_runs_range(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len, struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ u64 from, u64 to);
|
|
Kmods SIG |
8b815c |
+int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct runs_tree *run, u64 frame, u64 frames,
|
|
Kmods SIG |
8b815c |
+ u8 frame_bits, u32 *ondisk_size, u64 *vbo_data);
|
|
Kmods SIG |
8b815c |
+int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ CLST frame, CLST *clst_data);
|
|
Kmods SIG |
8b815c |
+int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
|
|
Kmods SIG |
8b815c |
+ u64 new_valid);
|
|
Kmods SIG |
8b815c |
+int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes);
|
|
Kmods SIG |
8b815c |
+int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* functions from attrlist.c*/
|
|
Kmods SIG |
8b815c |
+void al_destroy(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+bool al_verify(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr);
|
|
Kmods SIG |
8b815c |
+struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le);
|
|
Kmods SIG |
8b815c |
+struct ATTR_LIST_ENTRY *al_find_le(struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le,
|
|
Kmods SIG |
8b815c |
+ const struct ATTRIB *attr);
|
|
Kmods SIG |
8b815c |
+struct ATTR_LIST_ENTRY *al_find_ex(struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le,
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type, const __le16 *name,
|
|
Kmods SIG |
8b815c |
+ u8 name_len, const CLST *vcn);
|
|
Kmods SIG |
8b815c |
+int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
|
|
Kmods SIG |
8b815c |
+ u8 name_len, CLST svcn, __le16 id, const struct MFT_REF *ref,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY **new_le);
|
|
Kmods SIG |
8b815c |
+bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le);
|
|
Kmods SIG |
8b815c |
+bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, size_t name_len,
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *ref);
|
|
Kmods SIG |
8b815c |
+int al_update(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+static inline size_t al_aligned(size_t size)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (size + 1023) & ~(size_t)1023;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from bitfunc.c */
|
|
Kmods SIG |
8b815c |
+bool are_bits_clear(const ulong *map, size_t bit, size_t nbits);
|
|
Kmods SIG |
8b815c |
+bool are_bits_set(const ulong *map, size_t bit, size_t nbits);
|
|
Kmods SIG |
8b815c |
+size_t get_set_bits_ex(const ulong *map, size_t bit, size_t nbits);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from dir.c */
|
|
Kmods SIG |
8b815c |
+int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
|
|
Kmods SIG |
8b815c |
+ u8 *buf, int buf_len);
|
|
Kmods SIG |
8b815c |
+int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
|
|
Kmods SIG |
8b815c |
+ struct cpu_str *uni, u32 max_ulen,
|
|
Kmods SIG |
8b815c |
+ enum utf16_endian endian);
|
|
Kmods SIG |
8b815c |
+struct inode *dir_search_u(struct inode *dir, const struct cpu_str *uni,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+bool dir_is_empty(struct inode *dir);
|
|
Kmods SIG |
8b815c |
+extern const struct file_operations ntfs_dir_operations;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from file.c*/
|
|
Kmods SIG |
8b815c |
+int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
|
|
Kmods SIG |
8b815c |
+ struct kstat *stat, u32 request_mask, u32 flags);
|
|
Kmods SIG |
8b815c |
+void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn,
|
|
Kmods SIG |
8b815c |
+ CLST len);
|
|
Kmods SIG |
8b815c |
+int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
|
|
Kmods SIG |
8b815c |
+ struct iattr *attr);
|
|
Kmods SIG |
8b815c |
+int ntfs_file_open(struct inode *inode, struct file *file);
|
|
Kmods SIG |
8b815c |
+int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
|
Kmods SIG |
8b815c |
+ __u64 start, __u64 len);
|
|
Kmods SIG |
8b815c |
+extern const struct inode_operations ntfs_special_inode_operations;
|
|
Kmods SIG |
8b815c |
+extern const struct inode_operations ntfs_file_inode_operations;
|
|
Kmods SIG |
8b815c |
+extern const struct file_operations ntfs_file_operations;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from frecord.c */
|
|
Kmods SIG |
8b815c |
+void ni_remove_mi(struct ntfs_inode *ni, struct mft_inode *mi);
|
|
Kmods SIG |
8b815c |
+struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+void ni_clear(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+int ni_load_mi_ex(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+int ni_load_mi(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
|
|
Kmods SIG |
8b815c |
+ struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY **entry_o,
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type, const __le16 *name,
|
|
Kmods SIG |
8b815c |
+ u8 name_len, const CLST *vcn,
|
|
Kmods SIG |
8b815c |
+ struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY **le,
|
|
Kmods SIG |
8b815c |
+ struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len, CLST vcn,
|
|
Kmods SIG |
8b815c |
+ struct mft_inode **pmi);
|
|
Kmods SIG |
8b815c |
+int ni_load_all_mi(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+bool ni_add_subrecord(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, size_t name_len, bool base_only,
|
|
Kmods SIG |
8b815c |
+ const __le16 *id);
|
|
Kmods SIG |
8b815c |
+int ni_create_attr_list(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+int ni_expand_list(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+int ni_insert_nonresident(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len,
|
|
Kmods SIG |
8b815c |
+ const struct runs_tree *run, CLST svcn, CLST len,
|
|
Kmods SIG |
8b815c |
+ __le16 flags, struct ATTRIB **new_attr,
|
|
Kmods SIG |
8b815c |
+ struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+int ni_insert_resident(struct ntfs_inode *ni, u32 data_size,
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type, const __le16 *name, u8 name_len,
|
|
Kmods SIG |
8b815c |
+ struct ATTRIB **new_attr, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+int ni_remove_attr_le(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le);
|
|
Kmods SIG |
8b815c |
+int ni_delete_all(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ const struct cpu_str *uni,
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *home,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY **entry);
|
|
Kmods SIG |
8b815c |
+struct ATTR_FILE_NAME *ni_fname_type(struct ntfs_inode *ni, u8 name_type,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY **entry);
|
|
Kmods SIG |
8b815c |
+int ni_new_attr_flags(struct ntfs_inode *ni, enum FILE_ATTRIBUTE new_fa);
|
|
Kmods SIG |
8b815c |
+enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ void *buffer);
|
|
Kmods SIG |
8b815c |
+int ni_write_inode(struct inode *inode, int sync, const char *hint);
|
|
Kmods SIG |
8b815c |
+#define _ni_write_inode(i, w) ni_write_inode(i, w, __func__)
|
|
Kmods SIG |
8b815c |
+int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
|
|
Kmods SIG |
8b815c |
+ __u64 vbo, __u64 len);
|
|
Kmods SIG |
8b815c |
+int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page);
|
|
Kmods SIG |
8b815c |
+int ni_decompress_file(struct ntfs_inode *ni);
|
|
Kmods SIG |
8b815c |
+int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,
|
|
Kmods SIG |
8b815c |
+ u32 pages_per_frame);
|
|
Kmods SIG |
8b815c |
+int ni_write_frame(struct ntfs_inode *ni, struct page **pages,
|
|
Kmods SIG |
8b815c |
+ u32 pages_per_frame);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from fslog.c */
|
|
Kmods SIG |
8b815c |
+int log_replay(struct ntfs_inode *ni, bool *initialized);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from fsntfs.c */
|
|
Kmods SIG |
8b815c |
+bool ntfs_fix_pre_write(struct NTFS_RECORD_HEADER *rhdr, size_t bytes);
|
|
Kmods SIG |
8b815c |
+int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes,
|
|
Kmods SIG |
8b815c |
+ bool simple);
|
|
Kmods SIG |
8b815c |
+int ntfs_extend_init(struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+int ntfs_loadlog_and_replay(struct ntfs_inode *ni, struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+const struct ATTR_DEF_ENTRY *ntfs_query_def(struct ntfs_sb_info *sbi,
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE Type);
|
|
Kmods SIG |
8b815c |
+int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
|
|
Kmods SIG |
8b815c |
+ CLST *new_lcn, CLST *new_len,
|
|
Kmods SIG |
8b815c |
+ enum ALLOCATE_OPT opt);
|
|
Kmods SIG |
8b815c |
+int ntfs_look_free_mft(struct ntfs_sb_info *sbi, CLST *rno, bool mft,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_inode *ni, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+void ntfs_mark_rec_free(struct ntfs_sb_info *sbi, CLST rno);
|
|
Kmods SIG |
8b815c |
+int ntfs_clear_mft_tail(struct ntfs_sb_info *sbi, size_t from, size_t to);
|
|
Kmods SIG |
8b815c |
+int ntfs_refresh_zone(struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+int ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait);
|
|
Kmods SIG |
8b815c |
+enum NTFS_DIRTY_FLAGS {
|
|
Kmods SIG |
8b815c |
+ NTFS_DIRTY_CLEAR = 0,
|
|
Kmods SIG |
8b815c |
+ NTFS_DIRTY_DIRTY = 1,
|
|
Kmods SIG |
8b815c |
+ NTFS_DIRTY_ERROR = 2,
|
|
Kmods SIG |
8b815c |
+};
|
|
Kmods SIG |
8b815c |
+int ntfs_set_state(struct ntfs_sb_info *sbi, enum NTFS_DIRTY_FLAGS dirty);
|
|
Kmods SIG |
8b815c |
+int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
|
|
Kmods SIG |
8b815c |
+int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
|
|
Kmods SIG |
8b815c |
+ const void *buffer, int wait);
|
|
Kmods SIG |
8b815c |
+int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ u64 vbo, const void *buf, size_t bytes);
|
|
Kmods SIG |
8b815c |
+struct buffer_head *ntfs_bread_run(struct ntfs_sb_info *sbi,
|
|
Kmods SIG |
8b815c |
+ const struct runs_tree *run, u64 vbo);
|
|
Kmods SIG |
8b815c |
+int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ u64 vbo, void *buf, u32 bytes, struct ntfs_buffers *nb);
|
|
Kmods SIG |
8b815c |
+int ntfs_read_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
|
|
Kmods SIG |
8b815c |
+ struct NTFS_RECORD_HEADER *rhdr, u32 bytes,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_buffers *nb);
|
|
Kmods SIG |
8b815c |
+int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
|
|
Kmods SIG |
8b815c |
+ u32 bytes, struct ntfs_buffers *nb);
|
|
Kmods SIG |
8b815c |
+int ntfs_write_bh(struct ntfs_sb_info *sbi, struct NTFS_RECORD_HEADER *rhdr,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_buffers *nb, int sync);
|
|
Kmods SIG |
8b815c |
+int ntfs_bio_pages(struct ntfs_sb_info *sbi, const struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ struct page **pages, u32 nr_pages, u64 vbo, u32 bytes,
|
|
Kmods SIG |
8b815c |
+ u32 op);
|
|
Kmods SIG |
8b815c |
+int ntfs_bio_fill_1(struct ntfs_sb_info *sbi, const struct runs_tree *run);
|
|
Kmods SIG |
8b815c |
+int ntfs_vbo_to_lbo(struct ntfs_sb_info *sbi, const struct runs_tree *run,
|
|
Kmods SIG |
8b815c |
+ u64 vbo, u64 *lbo, u64 *bytes);
|
|
Kmods SIG |
8b815c |
+struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST nRec,
|
|
Kmods SIG |
8b815c |
+ bool dir);
|
|
Kmods SIG |
8b815c |
+extern const u8 s_default_security[0x50];
|
|
Kmods SIG |
8b815c |
+bool is_sd_valid(const struct SECURITY_DESCRIPTOR_RELATIVE *sd, u32 len);
|
|
Kmods SIG |
8b815c |
+int ntfs_security_init(struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+int ntfs_get_security_by_id(struct ntfs_sb_info *sbi, __le32 security_id,
|
|
Kmods SIG |
8b815c |
+ struct SECURITY_DESCRIPTOR_RELATIVE **sd,
|
|
Kmods SIG |
8b815c |
+ size_t *size);
|
|
Kmods SIG |
8b815c |
+int ntfs_insert_security(struct ntfs_sb_info *sbi,
|
|
Kmods SIG |
8b815c |
+ const struct SECURITY_DESCRIPTOR_RELATIVE *sd,
|
|
Kmods SIG |
8b815c |
+ u32 size, __le32 *security_id, bool *inserted);
|
|
Kmods SIG |
8b815c |
+int ntfs_reparse_init(struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+int ntfs_objid_init(struct ntfs_sb_info *sbi);
|
|
Kmods SIG |
8b815c |
+int ntfs_objid_remove(struct ntfs_sb_info *sbi, struct GUID *guid);
|
|
Kmods SIG |
8b815c |
+int ntfs_insert_reparse(struct ntfs_sb_info *sbi, __le32 rtag,
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *ref);
|
|
Kmods SIG |
8b815c |
+int ntfs_remove_reparse(struct ntfs_sb_info *sbi, __le32 rtag,
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *ref);
|
|
Kmods SIG |
8b815c |
+void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST lcn, CLST len, bool trim);
|
|
Kmods SIG |
8b815c |
+int run_deallocate(struct ntfs_sb_info *sbi, struct runs_tree *run, bool trim);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from index.c */
|
|
Kmods SIG |
8b815c |
+int indx_used_bit(struct ntfs_index *indx, struct ntfs_inode *ni, size_t *bit);
|
|
Kmods SIG |
8b815c |
+void fnd_clear(struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+static inline struct ntfs_fnd *fnd_get(void)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ntfs_zalloc(sizeof(struct ntfs_fnd));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+static inline void fnd_put(struct ntfs_fnd *fnd)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (fnd) {
|
|
Kmods SIG |
8b815c |
+ fnd_clear(fnd);
|
|
Kmods SIG |
8b815c |
+ ntfs_free(fnd);
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+void indx_clear(struct ntfs_index *idx);
|
|
Kmods SIG |
8b815c |
+int indx_init(struct ntfs_index *indx, struct ntfs_sb_info *sbi,
|
|
Kmods SIG |
8b815c |
+ const struct ATTRIB *attr, enum index_mutex_classed type);
|
|
Kmods SIG |
8b815c |
+struct INDEX_ROOT *indx_get_root(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct ATTRIB **attr, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+int indx_read(struct ntfs_index *idx, struct ntfs_inode *ni, CLST vbn,
|
|
Kmods SIG |
8b815c |
+ struct indx_node **node);
|
|
Kmods SIG |
8b815c |
+int indx_find(struct ntfs_index *indx, struct ntfs_inode *dir,
|
|
Kmods SIG |
8b815c |
+ const struct INDEX_ROOT *root, const void *Key, size_t KeyLen,
|
|
Kmods SIG |
8b815c |
+ const void *param, int *diff, struct NTFS_DE **entry,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ const struct INDEX_ROOT *root, struct NTFS_DE **entry,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+int indx_find_raw(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ const struct INDEX_ROOT *root, struct NTFS_DE **entry,
|
|
Kmods SIG |
8b815c |
+ size_t *off, struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+int indx_insert_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ const struct NTFS_DE *new_de, const void *param,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ const void *key, u32 key_len, const void *param);
|
|
Kmods SIG |
8b815c |
+int indx_update_dup(struct ntfs_inode *ni, struct ntfs_sb_info *sbi,
|
|
Kmods SIG |
8b815c |
+ const struct ATTR_FILE_NAME *fname,
|
|
Kmods SIG |
8b815c |
+ const struct NTFS_DUP_INFO *dup, int sync);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from inode.c */
|
|
Kmods SIG |
8b815c |
+struct inode *ntfs_iget5(struct super_block *sb, const struct MFT_REF *ref,
|
|
Kmods SIG |
8b815c |
+ const struct cpu_str *name);
|
|
Kmods SIG |
8b815c |
+int ntfs_set_size(struct inode *inode, u64 new_size);
|
|
Kmods SIG |
8b815c |
+int reset_log_file(struct inode *inode);
|
|
Kmods SIG |
8b815c |
+int ntfs_get_block(struct inode *inode, sector_t vbn,
|
|
Kmods SIG |
8b815c |
+ struct buffer_head *bh_result, int create);
|
|
Kmods SIG |
8b815c |
+int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
|
|
Kmods SIG |
8b815c |
+int ntfs_sync_inode(struct inode *inode);
|
|
Kmods SIG |
8b815c |
+int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
|
|
Kmods SIG |
8b815c |
+ struct inode *i2);
|
|
Kmods SIG |
8b815c |
+int inode_write_data(struct inode *inode, const void *data, size_t bytes);
|
|
Kmods SIG |
8b815c |
+struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
|
|
Kmods SIG |
8b815c |
+ struct inode *dir, struct dentry *dentry,
|
|
Kmods SIG |
8b815c |
+ const struct cpu_str *uni, umode_t mode,
|
|
Kmods SIG |
8b815c |
+ dev_t dev, const char *symname, u32 size,
|
|
Kmods SIG |
8b815c |
+ struct ntfs_fnd *fnd);
|
|
Kmods SIG |
8b815c |
+int ntfs_link_inode(struct inode *inode, struct dentry *dentry);
|
|
Kmods SIG |
8b815c |
+int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry);
|
|
Kmods SIG |
8b815c |
+void ntfs_evict_inode(struct inode *inode);
|
|
Kmods SIG |
8b815c |
+extern const struct inode_operations ntfs_link_inode_operations;
|
|
Kmods SIG |
8b815c |
+extern const struct address_space_operations ntfs_aops;
|
|
Kmods SIG |
8b815c |
+extern const struct address_space_operations ntfs_aops_cmpr;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from name_i.c*/
|
|
Kmods SIG |
8b815c |
+int fill_name_de(struct ntfs_sb_info *sbi, void *buf, const struct qstr *name,
|
|
Kmods SIG |
8b815c |
+ const struct cpu_str *uni);
|
|
Kmods SIG |
8b815c |
+struct dentry *ntfs3_get_parent(struct dentry *child);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+extern const struct inode_operations ntfs_dir_inode_operations;
|
|
Kmods SIG |
8b815c |
+extern const struct inode_operations ntfs_special_inode_operations;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from record.c */
|
|
Kmods SIG |
8b815c |
+int mi_get(struct ntfs_sb_info *sbi, CLST rno, struct mft_inode **mi);
|
|
Kmods SIG |
8b815c |
+void mi_put(struct mft_inode *mi);
|
|
Kmods SIG |
8b815c |
+int mi_init(struct mft_inode *mi, struct ntfs_sb_info *sbi, CLST rno);
|
|
Kmods SIG |
8b815c |
+int mi_read(struct mft_inode *mi, bool is_mft);
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr);
|
|
Kmods SIG |
8b815c |
+// TODO: id?
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *mi_find_attr(struct mft_inode *mi, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ enum ATTR_TYPE type, const __le16 *name,
|
|
Kmods SIG |
8b815c |
+ size_t name_len, const __le16 *id);
|
|
Kmods SIG |
8b815c |
+static inline struct ATTRIB *rec_find_attr_le(struct mft_inode *rec,
|
|
Kmods SIG |
8b815c |
+ struct ATTR_LIST_ENTRY *le)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return mi_find_attr(rec, NULL, le->type, le_name(le), le->name_len,
|
|
Kmods SIG |
8b815c |
+ &le->id);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+int mi_write(struct mft_inode *mi, int wait);
|
|
Kmods SIG |
8b815c |
+int mi_format_new(struct mft_inode *mi, struct ntfs_sb_info *sbi, CLST rno,
|
|
Kmods SIG |
8b815c |
+ __le16 flags, bool is_mft);
|
|
Kmods SIG |
8b815c |
+void mi_mark_free(struct mft_inode *mi);
|
|
Kmods SIG |
8b815c |
+struct ATTRIB *mi_insert_attr(struct mft_inode *mi, enum ATTR_TYPE type,
|
|
Kmods SIG |
8b815c |
+ const __le16 *name, u8 name_len, u32 asize,
|
|
Kmods SIG |
8b815c |
+ u16 name_off);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+bool mi_remove_attr(struct mft_inode *mi, struct ATTRIB *attr);
|
|
Kmods SIG |
8b815c |
+bool mi_resize_attr(struct mft_inode *mi, struct ATTRIB *attr, int bytes);
|
|
Kmods SIG |
8b815c |
+int mi_pack_runs(struct mft_inode *mi, struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct runs_tree *run, CLST len);
|
|
Kmods SIG |
8b815c |
+static inline bool mi_is_ref(const struct mft_inode *mi,
|
|
Kmods SIG |
8b815c |
+ const struct MFT_REF *ref)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (le32_to_cpu(ref->low) != mi->rno)
|
|
Kmods SIG |
8b815c |
+ return false;
|
|
Kmods SIG |
8b815c |
+ if (ref->seq != mi->mrec->seq)
|
|
Kmods SIG |
8b815c |
+ return false;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_64BIT_CLUSTER
|
|
Kmods SIG |
8b815c |
+ return le16_to_cpu(ref->high) == (mi->rno >> 32);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+ return !ref->high;
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void mi_get_ref(const struct mft_inode *mi, struct MFT_REF *ref)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ ref->low = cpu_to_le32(mi->rno);
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_64BIT_CLUSTER
|
|
Kmods SIG |
8b815c |
+ ref->high = cpu_to_le16(mi->rno >> 32);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+ ref->high = 0;
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+ ref->seq = mi->mrec->seq;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from run.c */
|
|
Kmods SIG |
8b815c |
+bool run_lookup_entry(const struct runs_tree *run, CLST vcn, CLST *lcn,
|
|
Kmods SIG |
8b815c |
+ CLST *len, size_t *index);
|
|
Kmods SIG |
8b815c |
+void run_truncate(struct runs_tree *run, CLST vcn);
|
|
Kmods SIG |
8b815c |
+void run_truncate_head(struct runs_tree *run, CLST vcn);
|
|
Kmods SIG |
8b815c |
+void run_truncate_around(struct runs_tree *run, CLST vcn);
|
|
Kmods SIG |
8b815c |
+bool run_lookup(const struct runs_tree *run, CLST vcn, size_t *Index);
|
|
Kmods SIG |
8b815c |
+bool run_add_entry(struct runs_tree *run, CLST vcn, CLST lcn, CLST len,
|
|
Kmods SIG |
8b815c |
+ bool is_mft);
|
|
Kmods SIG |
8b815c |
+bool run_collapse_range(struct runs_tree *run, CLST vcn, CLST len);
|
|
Kmods SIG |
8b815c |
+bool run_get_entry(const struct runs_tree *run, size_t index, CLST *vcn,
|
|
Kmods SIG |
8b815c |
+ CLST *lcn, CLST *len);
|
|
Kmods SIG |
8b815c |
+bool run_is_mapped_full(const struct runs_tree *run, CLST svcn, CLST evcn);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+int run_pack(const struct runs_tree *run, CLST svcn, CLST len, u8 *run_buf,
|
|
Kmods SIG |
8b815c |
+ u32 run_buf_size, CLST *packed_vcns);
|
|
Kmods SIG |
8b815c |
+int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
|
|
Kmods SIG |
8b815c |
+ CLST svcn, CLST evcn, CLST vcn, const u8 *run_buf,
|
|
Kmods SIG |
8b815c |
+ u32 run_buf_size);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#ifdef NTFS3_CHECK_FREE_CLST
|
|
Kmods SIG |
8b815c |
+int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
|
|
Kmods SIG |
8b815c |
+ CLST svcn, CLST evcn, CLST vcn, const u8 *run_buf,
|
|
Kmods SIG |
8b815c |
+ u32 run_buf_size);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+#define run_unpack_ex run_unpack
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+int run_get_highest_vcn(CLST vcn, const u8 *run_buf, u64 *highest_vcn);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from super.c */
|
|
Kmods SIG |
8b815c |
+void *ntfs_set_shared(void *ptr, u32 bytes);
|
|
Kmods SIG |
8b815c |
+void *ntfs_put_shared(void *ptr);
|
|
Kmods SIG |
8b815c |
+void ntfs_unmap_meta(struct super_block *sb, CLST lcn, CLST len);
|
|
Kmods SIG |
8b815c |
+int ntfs_discard(struct ntfs_sb_info *sbi, CLST Lcn, CLST Len);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from bitmap.c*/
|
|
Kmods SIG |
8b815c |
+int __init ntfs3_init_bitmap(void);
|
|
Kmods SIG |
8b815c |
+void ntfs3_exit_bitmap(void);
|
|
Kmods SIG |
8b815c |
+void wnd_close(struct wnd_bitmap *wnd);
|
|
Kmods SIG |
8b815c |
+static inline size_t wnd_zeroes(const struct wnd_bitmap *wnd)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return wnd->total_zeroes;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+int wnd_init(struct wnd_bitmap *wnd, struct super_block *sb, size_t nbits);
|
|
Kmods SIG |
8b815c |
+int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits);
|
|
Kmods SIG |
8b815c |
+int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits);
|
|
Kmods SIG |
8b815c |
+bool wnd_is_free(struct wnd_bitmap *wnd, size_t bit, size_t bits);
|
|
Kmods SIG |
8b815c |
+bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Possible values for 'flags' 'wnd_find' */
|
|
Kmods SIG |
8b815c |
+#define BITMAP_FIND_MARK_AS_USED 0x01
|
|
Kmods SIG |
8b815c |
+#define BITMAP_FIND_FULL 0x02
|
|
Kmods SIG |
8b815c |
+size_t wnd_find(struct wnd_bitmap *wnd, size_t to_alloc, size_t hint,
|
|
Kmods SIG |
8b815c |
+ size_t flags, size_t *allocated);
|
|
Kmods SIG |
8b815c |
+int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits);
|
|
Kmods SIG |
8b815c |
+void wnd_zone_set(struct wnd_bitmap *wnd, size_t Lcn, size_t Len);
|
|
Kmods SIG |
8b815c |
+int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from upcase.c */
|
|
Kmods SIG |
8b815c |
+int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2,
|
|
Kmods SIG |
8b815c |
+ const u16 *upcase, bool bothcase);
|
|
Kmods SIG |
8b815c |
+int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
|
|
Kmods SIG |
8b815c |
+ const u16 *upcase, bool bothcase);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from xattr.c */
|
|
Kmods SIG |
8b815c |
+#ifdef CONFIG_NTFS3_FS_POSIX_ACL
|
|
Kmods SIG |
8b815c |
+struct posix_acl *ntfs_get_acl(struct inode *inode, int type);
|
|
Kmods SIG |
8b815c |
+int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
|
|
Kmods SIG |
8b815c |
+ struct posix_acl *acl, int type);
|
|
Kmods SIG |
8b815c |
+int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
|
|
Kmods SIG |
8b815c |
+ struct inode *dir);
|
|
Kmods SIG |
8b815c |
+#else
|
|
Kmods SIG |
8b815c |
+#define ntfs_get_acl NULL
|
|
Kmods SIG |
8b815c |
+#define ntfs_set_acl NULL
|
|
Kmods SIG |
8b815c |
+#endif
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode);
|
|
Kmods SIG |
8b815c |
+int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
|
|
Kmods SIG |
8b815c |
+ int mask);
|
|
Kmods SIG |
8b815c |
+ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
|
|
Kmods SIG |
8b815c |
+extern const struct xattr_handler *ntfs_xattr_handlers[];
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+int ntfs_save_wsl_perm(struct inode *inode);
|
|
Kmods SIG |
8b815c |
+void ntfs_get_wsl_perm(struct inode *inode);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* globals from lznt.c */
|
|
Kmods SIG |
8b815c |
+struct lznt *get_lznt_ctx(int level);
|
|
Kmods SIG |
8b815c |
+size_t compress_lznt(const void *uncompressed, size_t uncompressed_size,
|
|
Kmods SIG |
8b815c |
+ void *compressed, size_t compressed_size,
|
|
Kmods SIG |
8b815c |
+ struct lznt *ctx);
|
|
Kmods SIG |
8b815c |
+ssize_t decompress_lznt(const void *compressed, size_t compressed_size,
|
|
Kmods SIG |
8b815c |
+ void *uncompressed, size_t uncompressed_size);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_ntfs3(struct ntfs_sb_info *sbi)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return sbi->volume.major_ver >= 3;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*(sb->s_flags & SB_ACTIVE)*/
|
|
Kmods SIG |
8b815c |
+static inline bool is_mounted(struct ntfs_sb_info *sbi)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return !!sbi->sb->s_root;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool ntfs_is_meta_file(struct ntfs_sb_info *sbi, CLST rno)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return rno < MFT_REC_FREE || rno == sbi->objid_no ||
|
|
Kmods SIG |
8b815c |
+ rno == sbi->quota_no || rno == sbi->reparse_no ||
|
|
Kmods SIG |
8b815c |
+ rno == sbi->usn_jrnl_no;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void ntfs_unmap_page(struct page *page)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ kunmap(page);
|
|
Kmods SIG |
8b815c |
+ put_page(page);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct page *ntfs_map_page(struct address_space *mapping,
|
|
Kmods SIG |
8b815c |
+ unsigned long index)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ struct page *page = read_mapping_page(mapping, index, NULL);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (!IS_ERR(page)) {
|
|
Kmods SIG |
8b815c |
+ kmap(page);
|
|
Kmods SIG |
8b815c |
+ if (!PageError(page))
|
|
Kmods SIG |
8b815c |
+ return page;
|
|
Kmods SIG |
8b815c |
+ ntfs_unmap_page(page);
|
|
Kmods SIG |
8b815c |
+ return ERR_PTR(-EIO);
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+ return page;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline size_t wnd_zone_bit(const struct wnd_bitmap *wnd)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return wnd->zone_bit;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline size_t wnd_zone_len(const struct wnd_bitmap *wnd)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return wnd->zone_end - wnd->zone_bit;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void run_init(struct runs_tree *run)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ run->runs = NULL;
|
|
Kmods SIG |
8b815c |
+ run->count = 0;
|
|
Kmods SIG |
8b815c |
+ run->allocated = 0;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct runs_tree *run_alloc(void)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ntfs_zalloc(sizeof(struct runs_tree));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void run_close(struct runs_tree *run)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ ntfs_vfree(run->runs);
|
|
Kmods SIG |
8b815c |
+ memset(run, 0, sizeof(*run));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void run_free(struct runs_tree *run)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (run) {
|
|
Kmods SIG |
8b815c |
+ ntfs_vfree(run->runs);
|
|
Kmods SIG |
8b815c |
+ ntfs_free(run);
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool run_is_empty(struct runs_tree *run)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return !run->count;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* NTFS uses quad aligned bitmaps */
|
|
Kmods SIG |
8b815c |
+static inline size_t bitmap_size(size_t bits)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return QuadAlign((bits + 7) >> 3);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define _100ns2seconds 10000000
|
|
Kmods SIG |
8b815c |
+#define SecondsToStartOf1970 0x00000002B6109100
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#define NTFS_TIME_GRAN 100
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * kernel2nt
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * converts in-memory kernel timestamp into nt time
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+static inline __le64 kernel2nt(const struct timespec64 *ts)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ // 10^7 units of 100 nanoseconds one second
|
|
Kmods SIG |
8b815c |
+ return cpu_to_le64(_100ns2seconds *
|
|
Kmods SIG |
8b815c |
+ (ts->tv_sec + SecondsToStartOf1970) +
|
|
Kmods SIG |
8b815c |
+ ts->tv_nsec / NTFS_TIME_GRAN);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * nt2kernel
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * converts on-disk nt time into kernel timestamp
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+static inline void nt2kernel(const __le64 tm, struct timespec64 *ts)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ u64 t = le64_to_cpu(tm) - _100ns2seconds * SecondsToStartOf1970;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ // WARNING: do_div changes its first argument(!)
|
|
Kmods SIG |
8b815c |
+ ts->tv_nsec = do_div(t, _100ns2seconds) * 100;
|
|
Kmods SIG |
8b815c |
+ ts->tv_sec = t;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct ntfs_sb_info *ntfs_sb(struct super_block *sb)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return sb->s_fs_info;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Align up on cluster boundary */
|
|
Kmods SIG |
8b815c |
+static inline u64 ntfs_up_cluster(const struct ntfs_sb_info *sbi, u64 size)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (size + sbi->cluster_mask) & sbi->cluster_mask_inv;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* Align up on cluster boundary */
|
|
Kmods SIG |
8b815c |
+static inline u64 ntfs_up_block(const struct super_block *sb, u64 size)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (size + sb->s_blocksize - 1) & ~(u64)(sb->s_blocksize - 1);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline CLST bytes_to_cluster(const struct ntfs_sb_info *sbi, u64 size)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (size + sbi->cluster_mask) >> sbi->cluster_bits;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u64 bytes_to_block(const struct super_block *sb, u64 size)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct buffer_head *ntfs_bread(struct super_block *sb,
|
|
Kmods SIG |
8b815c |
+ sector_t block)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ struct buffer_head *bh = sb_bread(sb, block);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (bh)
|
|
Kmods SIG |
8b815c |
+ return bh;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ ntfs_err(sb, "failed to read volume at offset 0x%llx",
|
|
Kmods SIG |
8b815c |
+ (u64)block << sb->s_blocksize_bits);
|
|
Kmods SIG |
8b815c |
+ return NULL;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_power_of2(size_t v)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return v && !(v & (v - 1));
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline struct ntfs_inode *ntfs_i(struct inode *inode)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return container_of(inode, struct ntfs_inode, vfs_inode);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_compressed(const struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return (ni->std_fa & FILE_ATTRIBUTE_COMPRESSED) ||
|
|
Kmods SIG |
8b815c |
+ (ni->ni_flags & NI_FLAG_COMPRESSED_MASK);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline int ni_ext_compress_bits(const struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return 0xb + (ni->ni_flags & NI_FLAG_COMPRESSED_MASK);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/* bits - 0xc, 0xd, 0xe, 0xf, 0x10 */
|
|
Kmods SIG |
8b815c |
+static inline void ni_set_ext_compress_bits(struct ntfs_inode *ni, u8 bits)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ ni->ni_flags |= (bits - 0xb) & NI_FLAG_COMPRESSED_MASK;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_dedup(const struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ni->ni_flags & NI_FLAG_DEDUPLICATED;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_encrypted(const struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ni->std_fa & FILE_ATTRIBUTE_ENCRYPTED;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline bool is_sparsed(const struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ni->std_fa & FILE_ATTRIBUTE_SPARSE_FILE;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline int is_resident(struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return ni->ni_flags & NI_FLAG_RESIDENT;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void le16_sub_cpu(__le16 *var, u16 val)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ *var = cpu_to_le16(le16_to_cpu(*var) - val);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void le32_sub_cpu(__le32 *var, u32 val)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ *var = cpu_to_le32(le32_to_cpu(*var) - val);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void nb_put(struct ntfs_buffers *nb)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ u32 i, nbufs = nb->nbufs;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (!nbufs)
|
|
Kmods SIG |
8b815c |
+ return;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ for (i = 0; i < nbufs; i++)
|
|
Kmods SIG |
8b815c |
+ put_bh(nb->bh[i]);
|
|
Kmods SIG |
8b815c |
+ nb->nbufs = 0;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void put_indx_node(struct indx_node *in)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (!in)
|
|
Kmods SIG |
8b815c |
+ return;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ ntfs_free(in->index);
|
|
Kmods SIG |
8b815c |
+ nb_put(&in->nb);
|
|
Kmods SIG |
8b815c |
+ ntfs_free(in);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void mi_clear(struct mft_inode *mi)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ nb_put(&mi->nb);
|
|
Kmods SIG |
8b815c |
+ ntfs_free(mi->mrec);
|
|
Kmods SIG |
8b815c |
+ mi->mrec = NULL;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void ni_lock(struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_NORMAL);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void ni_lock_dir(struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_PARENT);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void ni_unlock(struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ mutex_unlock(&ni->ni_lock);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline int ni_trylock(struct ntfs_inode *ni)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return mutex_trylock(&ni->ni_lock);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline int attr_load_runs_attr(struct ntfs_inode *ni,
|
|
Kmods SIG |
8b815c |
+ struct ATTRIB *attr,
|
|
Kmods SIG |
8b815c |
+ struct runs_tree *run, CLST vcn)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ return attr_load_runs_vcn(ni, attr->type, attr_name(attr),
|
|
Kmods SIG |
8b815c |
+ attr->name_len, run, vcn);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline void le64_sub_cpu(__le64 *var, u64 val)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ *var = cpu_to_le64(le64_to_cpu(*var) - val);
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
diff --git a/src/upcase.c b/src/upcase.c
|
|
Kmods SIG |
8b815c |
new file mode 100644
|
|
Kmods SIG |
8b815c |
index 0000000000000000000000000000000000000000..9617382aca64b3ee322f7f769fbff38b8db52dbb
|
|
Kmods SIG |
8b815c |
--- /dev/null
|
|
Kmods SIG |
8b815c |
+++ b/src/upcase.c
|
|
Kmods SIG |
8b815c |
@@ -0,0 +1,105 @@
|
|
Kmods SIG |
8b815c |
+// SPDX-License-Identifier: GPL-2.0
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+#include <linux/blkdev.h>
|
|
Kmods SIG |
8b815c |
+#include <linux/buffer_head.h>
|
|
Kmods SIG |
8b815c |
+#include <linux/module.h>
|
|
Kmods SIG |
8b815c |
+#include <linux/nls.h>
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+#include "debug.h"
|
|
Kmods SIG |
8b815c |
+#include "ntfs.h"
|
|
Kmods SIG |
8b815c |
+#include "ntfs_fs.h"
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+static inline u16 upcase_unicode_char(const u16 *upcase, u16 chr)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ if (chr < 'a')
|
|
Kmods SIG |
8b815c |
+ return chr;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (chr <= 'z')
|
|
Kmods SIG |
8b815c |
+ return chr - ('a' - 'A');
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return upcase[chr];
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+/*
|
|
Kmods SIG |
8b815c |
+ * Thanks Kari Argillander <kari.argillander@gmail.com> for idea and implementation 'bothcase'
|
|
Kmods SIG |
8b815c |
+ *
|
|
Kmods SIG |
8b815c |
+ * Straigth way to compare names:
|
|
Kmods SIG |
8b815c |
+ * - case insensitive
|
|
Kmods SIG |
8b815c |
+ * - if name equals and 'bothcases' then
|
|
Kmods SIG |
8b815c |
+ * - case sensitive
|
|
Kmods SIG |
8b815c |
+ * 'Straigth way' code scans input names twice in worst case
|
|
Kmods SIG |
8b815c |
+ * Optimized code scans input names only once
|
|
Kmods SIG |
8b815c |
+ */
|
|
Kmods SIG |
8b815c |
+int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2,
|
|
Kmods SIG |
8b815c |
+ const u16 *upcase, bool bothcase)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ int diff1 = 0;
|
|
Kmods SIG |
8b815c |
+ int diff2;
|
|
Kmods SIG |
8b815c |
+ size_t len = min(l1, l2);
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (!bothcase && upcase)
|
|
Kmods SIG |
8b815c |
+ goto case_insentive;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ for (; len; s1++, s2++, len--) {
|
|
Kmods SIG |
8b815c |
+ diff1 = le16_to_cpu(*s1) - le16_to_cpu(*s2);
|
|
Kmods SIG |
8b815c |
+ if (diff1) {
|
|
Kmods SIG |
8b815c |
+ if (bothcase && upcase)
|
|
Kmods SIG |
8b815c |
+ goto case_insentive;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return diff1;
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+ return l1 - l2;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+case_insentive:
|
|
Kmods SIG |
8b815c |
+ for (; len; s1++, s2++, len--) {
|
|
Kmods SIG |
8b815c |
+ diff2 = upcase_unicode_char(upcase, le16_to_cpu(*s1)) -
|
|
Kmods SIG |
8b815c |
+ upcase_unicode_char(upcase, le16_to_cpu(*s2));
|
|
Kmods SIG |
8b815c |
+ if (diff2)
|
|
Kmods SIG |
8b815c |
+ return diff2;
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ diff2 = l1 - l2;
|
|
Kmods SIG |
8b815c |
+ return diff2 ? diff2 : diff1;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
|
|
Kmods SIG |
8b815c |
+ const u16 *upcase, bool bothcase)
|
|
Kmods SIG |
8b815c |
+{
|
|
Kmods SIG |
8b815c |
+ const u16 *s1 = uni1->name;
|
|
Kmods SIG |
8b815c |
+ const __le16 *s2 = uni2->name;
|
|
Kmods SIG |
8b815c |
+ size_t l1 = uni1->len;
|
|
Kmods SIG |
8b815c |
+ size_t l2 = uni2->len;
|
|
Kmods SIG |
8b815c |
+ size_t len = min(l1, l2);
|
|
Kmods SIG |
8b815c |
+ int diff1 = 0;
|
|
Kmods SIG |
8b815c |
+ int diff2;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ if (!bothcase && upcase)
|
|
Kmods SIG |
8b815c |
+ goto case_insentive;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ for (; len; s1++, s2++, len--) {
|
|
Kmods SIG |
8b815c |
+ diff1 = *s1 - le16_to_cpu(*s2);
|
|
Kmods SIG |
8b815c |
+ if (diff1) {
|
|
Kmods SIG |
8b815c |
+ if (bothcase && upcase)
|
|
Kmods SIG |
8b815c |
+ goto case_insentive;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ return diff1;
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+ return l1 - l2;
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+case_insentive:
|
|
Kmods SIG |
8b815c |
+ for (; len; s1++, s2++, len--) {
|
|
Kmods SIG |
8b815c |
+ diff2 = upcase_unicode_char(upcase, *s1) -
|
|
Kmods SIG |
8b815c |
+ upcase_unicode_char(upcase, le16_to_cpu(*s2));
|
|
Kmods SIG |
8b815c |
+ if (diff2)
|
|
Kmods SIG |
8b815c |
+ return diff2;
|
|
Kmods SIG |
8b815c |
+ }
|
|
Kmods SIG |
8b815c |
+
|
|
Kmods SIG |
8b815c |
+ diff2 = l1 - l2;
|
|
Kmods SIG |
8b815c |
+ return diff2 ? diff2 : diff1;
|
|
Kmods SIG |
8b815c |
+}
|
|
Kmods SIG |
8b815c |
--
|
|
Kmods SIG |
8b815c |
2.31.1
|
|
Kmods SIG |
8b815c |
|