|
Kmods SIG |
50e2b3 |
From 1acf1a564b6034b5af1e7fb23cb98cb3bb4f6003 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
50e2b3 |
From: Namjae Jeon <namjae.jeon@samsung.com>
|
|
Kmods SIG |
50e2b3 |
Date: Mon, 2 Mar 2020 15:21:32 +0900
|
|
Kmods SIG |
50e2b3 |
Subject: [Backport 1acf1a564b60] exfat: add in-memory and on-disk structures
|
|
Kmods SIG |
50e2b3 |
and headers
|
|
Kmods SIG |
50e2b3 |
MIME-Version: 1.0
|
|
Kmods SIG |
50e2b3 |
Content-Type: text/plain; charset=UTF-8
|
|
Kmods SIG |
50e2b3 |
Content-Transfer-Encoding: 8bit
|
|
Kmods SIG |
50e2b3 |
|
|
Kmods SIG |
50e2b3 |
This adds in-memory and on-disk structures and headers.
|
|
Kmods SIG |
50e2b3 |
|
|
Kmods SIG |
50e2b3 |
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
|
|
Kmods SIG |
50e2b3 |
Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>
|
|
Kmods SIG |
50e2b3 |
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
|
|
Kmods SIG |
50e2b3 |
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
|
Kmods SIG |
50e2b3 |
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Kmods SIG |
50e2b3 |
---
|
|
Kmods SIG |
50e2b3 |
src/exfat_fs.h | 519 +++++++++++++++++++++++++++++++++++++++++++
|
|
Kmods SIG |
50e2b3 |
src/exfat_raw.h | 184 +++++++++++++++
|
|
Kmods SIG |
50e2b3 |
2 files changed, 703 insertions(+)
|
|
Kmods SIG |
50e2b3 |
create mode 100644 src/exfat_fs.h
|
|
Kmods SIG |
50e2b3 |
create mode 100644 src/exfat_raw.h
|
|
Kmods SIG |
50e2b3 |
|
|
Kmods SIG |
50e2b3 |
diff --git a/src/exfat_fs.h b/src/exfat_fs.h
|
|
Kmods SIG |
50e2b3 |
new file mode 100644
|
|
Kmods SIG |
50e2b3 |
index 0000000000000000000000000000000000000000..67d4e46fb81003d0c367862ee986b37c80e7fa4e
|
|
Kmods SIG |
50e2b3 |
--- /dev/null
|
|
Kmods SIG |
50e2b3 |
+++ b/src/exfat_fs.h
|
|
Kmods SIG |
50e2b3 |
@@ -0,0 +1,519 @@
|
|
Kmods SIG |
50e2b3 |
+/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#ifndef _EXFAT_FS_H
|
|
Kmods SIG |
50e2b3 |
+#define _EXFAT_FS_H
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#include <linux/fs.h>
|
|
Kmods SIG |
50e2b3 |
+#include <linux/ratelimit.h>
|
|
Kmods SIG |
50e2b3 |
+#include <linux/nls.h>
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_SUPER_MAGIC 0x2011BAB0UL
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_ROOT_INO 1
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_SB_DIRTY 0
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_CLUSTERS_UNTRACKED (~0u)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * exfat error flags
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+enum exfat_error_mode {
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_ERRORS_CONT, /* ignore error and continue */
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_ERRORS_PANIC, /* panic on error */
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_ERRORS_RO, /* remount r/o on error */
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * exfat nls lossy flag
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+enum {
|
|
Kmods SIG |
50e2b3 |
+ NLS_NAME_NO_LOSSY, /* no lossy */
|
|
Kmods SIG |
50e2b3 |
+ NLS_NAME_LOSSY, /* just detected incorrect filename(s) */
|
|
Kmods SIG |
50e2b3 |
+ NLS_NAME_OVERLEN, /* the length is over than its limit */
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_HASH_BITS 8
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_HASH_SIZE (1UL << EXFAT_HASH_BITS)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * Type Definitions
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define ES_2_ENTRIES 2
|
|
Kmods SIG |
50e2b3 |
+#define ES_ALL_ENTRIES 0
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define DIR_DELETED 0xFFFF0321
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* type values */
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_UNUSED 0x0000
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_DELETED 0x0001
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_INVALID 0x0002
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_CRITICAL_PRI 0x0100
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_BITMAP 0x0101
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_UPCASE 0x0102
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_VOLUME 0x0103
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_DIR 0x0104
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_FILE 0x011F
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_CRITICAL_SEC 0x0200
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_STREAM 0x0201
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_EXTEND 0x0202
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_ACL 0x0203
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_BENIGN_PRI 0x0400
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_GUID 0x0401
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_PADDING 0x0402
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_ACLTAB 0x0403
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_BENIGN_SEC 0x0800
|
|
Kmods SIG |
50e2b3 |
+#define TYPE_ALL 0x0FFF
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define MAX_CHARSET_SIZE 6 /* max size of multi-byte character */
|
|
Kmods SIG |
50e2b3 |
+#define MAX_NAME_LENGTH 255 /* max len of file name excluding NULL */
|
|
Kmods SIG |
50e2b3 |
+#define MAX_VFSNAME_BUF_SIZE ((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define FAT_CACHE_SIZE 128
|
|
Kmods SIG |
50e2b3 |
+#define FAT_CACHE_HASH_SIZE 64
|
|
Kmods SIG |
50e2b3 |
+#define BUF_CACHE_SIZE 256
|
|
Kmods SIG |
50e2b3 |
+#define BUF_CACHE_HASH_SIZE 64
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_HINT_NONE -1
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_MIN_SUBDIR 2
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * helpers for cluster size to byte conversion.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_CLU_TO_B(b, sbi) ((b) << (sbi)->cluster_size_bits)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_CLU(b, sbi) ((b) >> (sbi)->cluster_size_bits)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_CLU_ROUND_UP(b, sbi) \
|
|
Kmods SIG |
50e2b3 |
+ (((b - 1) >> (sbi)->cluster_size_bits) + 1)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_CLU_OFFSET(off, sbi) ((off) & ((sbi)->cluster_size - 1))
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * helpers for block size to byte conversion.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_BLK_TO_B(b, sb) ((b) << (sb)->s_blocksize_bits)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_BLK(b, sb) ((b) >> (sb)->s_blocksize_bits)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_BLK_ROUND_UP(b, sb) \
|
|
Kmods SIG |
50e2b3 |
+ (((b - 1) >> (sb)->s_blocksize_bits) + 1)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_BLK_OFFSET(off, sb) ((off) & ((sb)->s_blocksize - 1))
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * helpers for block size to dentry size conversion.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_DEN_IDX(b, sbi) \
|
|
Kmods SIG |
50e2b3 |
+ ((b) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS))
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_B_TO_DEN(b) ((b) >> DENTRY_SIZE_BITS)
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_DEN_TO_B(b) ((b) << DENTRY_SIZE_BITS)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * helpers for fat entry.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define FAT_ENT_SIZE (4)
|
|
Kmods SIG |
50e2b3 |
+#define FAT_ENT_SIZE_BITS (2)
|
|
Kmods SIG |
50e2b3 |
+#define FAT_ENT_OFFSET_SECTOR(sb, loc) (EXFAT_SB(sb)->FAT1_start_sector + \
|
|
Kmods SIG |
50e2b3 |
+ (((u64)loc << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
|
|
Kmods SIG |
50e2b3 |
+#define FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc) \
|
|
Kmods SIG |
50e2b3 |
+ ((loc << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * helpers for bitmap.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+#define CLUSTER_TO_BITMAP_ENT(clu) ((clu) - EXFAT_RESERVED_CLUSTERS)
|
|
Kmods SIG |
50e2b3 |
+#define BITMAP_ENT_TO_CLUSTER(ent) ((ent) + EXFAT_RESERVED_CLUSTERS)
|
|
Kmods SIG |
50e2b3 |
+#define BITS_PER_SECTOR(sb) ((sb)->s_blocksize * BITS_PER_BYTE)
|
|
Kmods SIG |
50e2b3 |
+#define BITS_PER_SECTOR_MASK(sb) (BITS_PER_SECTOR(sb) - 1)
|
|
Kmods SIG |
50e2b3 |
+#define BITMAP_OFFSET_SECTOR_INDEX(sb, ent) \
|
|
Kmods SIG |
50e2b3 |
+ ((ent / BITS_PER_BYTE) >> (sb)->s_blocksize_bits)
|
|
Kmods SIG |
50e2b3 |
+#define BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent) (ent & BITS_PER_SECTOR_MASK(sb))
|
|
Kmods SIG |
50e2b3 |
+#define BITMAP_OFFSET_BYTE_IN_SECTOR(sb, ent) \
|
|
Kmods SIG |
50e2b3 |
+ ((ent / BITS_PER_BYTE) & ((sb)->s_blocksize - 1))
|
|
Kmods SIG |
50e2b3 |
+#define BITS_PER_BYTE_MASK 0x7
|
|
Kmods SIG |
50e2b3 |
+#define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+struct exfat_dentry_namebuf {
|
|
Kmods SIG |
50e2b3 |
+ char *lfn;
|
|
Kmods SIG |
50e2b3 |
+ int lfnbuf_len; /* usally MAX_UNINAME_BUF_SIZE */
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* unicode name structure */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_uni_name {
|
|
Kmods SIG |
50e2b3 |
+ /* +3 for null and for converting */
|
|
Kmods SIG |
50e2b3 |
+ unsigned short name[MAX_NAME_LENGTH + 3];
|
|
Kmods SIG |
50e2b3 |
+ unsigned short name_hash;
|
|
Kmods SIG |
50e2b3 |
+ unsigned char name_len;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* directory structure */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_chain {
|
|
Kmods SIG |
50e2b3 |
+ unsigned int dir;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int size;
|
|
Kmods SIG |
50e2b3 |
+ unsigned char flags;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* first empty entry hint information */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_hint_femp {
|
|
Kmods SIG |
50e2b3 |
+ /* entry index of a directory */
|
|
Kmods SIG |
50e2b3 |
+ int eidx;
|
|
Kmods SIG |
50e2b3 |
+ /* count of continuous empty entry */
|
|
Kmods SIG |
50e2b3 |
+ int count;
|
|
Kmods SIG |
50e2b3 |
+ /* the cluster that first empty slot exists in */
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain cur;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* hint structure */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_hint {
|
|
Kmods SIG |
50e2b3 |
+ unsigned int clu;
|
|
Kmods SIG |
50e2b3 |
+ union {
|
|
Kmods SIG |
50e2b3 |
+ unsigned int off; /* cluster offset */
|
|
Kmods SIG |
50e2b3 |
+ int eidx; /* entry index */
|
|
Kmods SIG |
50e2b3 |
+ };
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+struct exfat_entry_set_cache {
|
|
Kmods SIG |
50e2b3 |
+ /* sector number that contains file_entry */
|
|
Kmods SIG |
50e2b3 |
+ sector_t sector;
|
|
Kmods SIG |
50e2b3 |
+ /* byte offset in the sector */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int offset;
|
|
Kmods SIG |
50e2b3 |
+ /* flag in stream entry. 01 for cluster chain, 03 for contig. */
|
|
Kmods SIG |
50e2b3 |
+ int alloc_flag;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int num_entries;
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_dentry entries[];
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+struct exfat_dir_entry {
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain dir;
|
|
Kmods SIG |
50e2b3 |
+ int entry;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int type;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int start_clu;
|
|
Kmods SIG |
50e2b3 |
+ unsigned char flags;
|
|
Kmods SIG |
50e2b3 |
+ unsigned short attr;
|
|
Kmods SIG |
50e2b3 |
+ loff_t size;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int num_subdirs;
|
|
Kmods SIG |
50e2b3 |
+ struct timespec64 atime;
|
|
Kmods SIG |
50e2b3 |
+ struct timespec64 mtime;
|
|
Kmods SIG |
50e2b3 |
+ struct timespec64 crtime;
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_dentry_namebuf namebuf;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * exfat mount in-memory data
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_mount_options {
|
|
Kmods SIG |
50e2b3 |
+ kuid_t fs_uid;
|
|
Kmods SIG |
50e2b3 |
+ kgid_t fs_gid;
|
|
Kmods SIG |
50e2b3 |
+ unsigned short fs_fmask;
|
|
Kmods SIG |
50e2b3 |
+ unsigned short fs_dmask;
|
|
Kmods SIG |
50e2b3 |
+ /* permission for setting the [am]time */
|
|
Kmods SIG |
50e2b3 |
+ unsigned short allow_utime;
|
|
Kmods SIG |
50e2b3 |
+ /* charset for filename input/display */
|
|
Kmods SIG |
50e2b3 |
+ char *iocharset;
|
|
Kmods SIG |
50e2b3 |
+ /* on error: continue, panic, remount-ro */
|
|
Kmods SIG |
50e2b3 |
+ enum exfat_error_mode errors;
|
|
Kmods SIG |
50e2b3 |
+ unsigned utf8:1, /* Use of UTF-8 character set */
|
|
Kmods SIG |
50e2b3 |
+ discard:1; /* Issue discard requests on deletions */
|
|
Kmods SIG |
50e2b3 |
+ int time_offset; /* Offset of timestamps from UTC (in minutes) */
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * EXFAT file system superblock in-memory data
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_sb_info {
|
|
Kmods SIG |
50e2b3 |
+ unsigned long long num_sectors; /* num of sectors in volume */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int num_clusters; /* num of clusters in volume */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int cluster_size; /* cluster size in bytes */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int cluster_size_bits;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int sect_per_clus; /* cluster size in sectors */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int sect_per_clus_bits;
|
|
Kmods SIG |
50e2b3 |
+ unsigned long long FAT1_start_sector; /* FAT1 start sector */
|
|
Kmods SIG |
50e2b3 |
+ unsigned long long FAT2_start_sector; /* FAT2 start sector */
|
|
Kmods SIG |
50e2b3 |
+ unsigned long long data_start_sector; /* data area start sector */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int num_FAT_sectors; /* num of FAT sectors */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int root_dir; /* root dir cluster */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int dentries_per_clu; /* num of dentries per cluster */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int vol_flag; /* volume dirty flag */
|
|
Kmods SIG |
50e2b3 |
+ struct buffer_head *pbr_bh; /* buffer_head of PBR sector */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ unsigned int map_clu; /* allocation bitmap start cluster */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int map_sectors; /* num of allocation bitmap sectors */
|
|
Kmods SIG |
50e2b3 |
+ struct buffer_head **vol_amap; /* allocation bitmap */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ unsigned short *vol_utbl; /* upcase table */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ unsigned int clu_srch_ptr; /* cluster search pointer */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int used_clusters; /* number of used clusters */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ unsigned long s_state;
|
|
Kmods SIG |
50e2b3 |
+ struct mutex s_lock; /* superblock lock */
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_mount_options options;
|
|
Kmods SIG |
50e2b3 |
+ struct nls_table *nls_io; /* Charset used for input and display */
|
|
Kmods SIG |
50e2b3 |
+ struct ratelimit_state ratelimit;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ spinlock_t inode_hash_lock;
|
|
Kmods SIG |
50e2b3 |
+ struct hlist_head inode_hashtable[EXFAT_HASH_SIZE];
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ struct rcu_head rcu;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * EXFAT file system inode in-memory data
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+struct exfat_inode_info {
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain dir;
|
|
Kmods SIG |
50e2b3 |
+ int entry;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int type;
|
|
Kmods SIG |
50e2b3 |
+ unsigned short attr;
|
|
Kmods SIG |
50e2b3 |
+ unsigned int start_clu;
|
|
Kmods SIG |
50e2b3 |
+ unsigned char flags;
|
|
Kmods SIG |
50e2b3 |
+ /*
|
|
Kmods SIG |
50e2b3 |
+ * the copy of low 32bit of i_version to check
|
|
Kmods SIG |
50e2b3 |
+ * the validation of hint_stat.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int version;
|
|
Kmods SIG |
50e2b3 |
+ /* file offset or dentry index for readdir */
|
|
Kmods SIG |
50e2b3 |
+ loff_t rwoffset;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ /* hint for cluster last accessed */
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_hint hint_bmap;
|
|
Kmods SIG |
50e2b3 |
+ /* hint for entry index we try to lookup next time */
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_hint hint_stat;
|
|
Kmods SIG |
50e2b3 |
+ /* hint for first empty entry */
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_hint_femp hint_femp;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ spinlock_t cache_lru_lock;
|
|
Kmods SIG |
50e2b3 |
+ struct list_head cache_lru;
|
|
Kmods SIG |
50e2b3 |
+ int nr_caches;
|
|
Kmods SIG |
50e2b3 |
+ /* for avoiding the race between alloc and free */
|
|
Kmods SIG |
50e2b3 |
+ unsigned int cache_valid_id;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ /*
|
|
Kmods SIG |
50e2b3 |
+ * NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access.
|
|
Kmods SIG |
50e2b3 |
+ * physically allocated size.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+ loff_t i_size_ondisk;
|
|
Kmods SIG |
50e2b3 |
+ /* block-aligned i_size (used in cont_write_begin) */
|
|
Kmods SIG |
50e2b3 |
+ loff_t i_size_aligned;
|
|
Kmods SIG |
50e2b3 |
+ /* on-disk position of directory entry or 0 */
|
|
Kmods SIG |
50e2b3 |
+ loff_t i_pos;
|
|
Kmods SIG |
50e2b3 |
+ /* hash by i_location */
|
|
Kmods SIG |
50e2b3 |
+ struct hlist_node i_hash_fat;
|
|
Kmods SIG |
50e2b3 |
+ /* protect bmap against truncate */
|
|
Kmods SIG |
50e2b3 |
+ struct rw_semaphore truncate_lock;
|
|
Kmods SIG |
50e2b3 |
+ struct inode vfs_inode;
|
|
Kmods SIG |
50e2b3 |
+ /* File creation time */
|
|
Kmods SIG |
50e2b3 |
+ struct timespec64 i_crtime;
|
|
Kmods SIG |
50e2b3 |
+};
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ return sb->s_fs_info;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ return container_of(inode, struct exfat_inode_info, vfs_inode);
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * If ->i_mode can't hold 0222 (i.e. ATTR_RO), we use ->i_attrs to
|
|
Kmods SIG |
50e2b3 |
+ * save ATTR_RO instead of ->i_mode.
|
|
Kmods SIG |
50e2b3 |
+ *
|
|
Kmods SIG |
50e2b3 |
+ * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
|
|
Kmods SIG |
50e2b3 |
+ * bit, it's just used as flag for app.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+static inline int exfat_mode_can_hold_ro(struct inode *inode)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ if (S_ISDIR(inode->i_mode))
|
|
Kmods SIG |
50e2b3 |
+ return 0;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ if ((~sbi->options.fs_fmask) & 0222)
|
|
Kmods SIG |
50e2b3 |
+ return 1;
|
|
Kmods SIG |
50e2b3 |
+ return 0;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* Convert attribute bits and a mask to the UNIX mode. */
|
|
Kmods SIG |
50e2b3 |
+static inline mode_t exfat_make_mode(struct exfat_sb_info *sbi,
|
|
Kmods SIG |
50e2b3 |
+ unsigned short attr, mode_t mode)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ if ((attr & ATTR_READONLY) && !(attr & ATTR_SUBDIR))
|
|
Kmods SIG |
50e2b3 |
+ mode &= ~0222;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ if (attr & ATTR_SUBDIR)
|
|
Kmods SIG |
50e2b3 |
+ return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ return (mode & ~sbi->options.fs_fmask) | S_IFREG;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* Return the FAT attribute byte for this inode */
|
|
Kmods SIG |
50e2b3 |
+static inline unsigned short exfat_make_attr(struct inode *inode)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ unsigned short attr = EXFAT_I(inode)->attr;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+ if (S_ISDIR(inode->i_mode))
|
|
Kmods SIG |
50e2b3 |
+ attr |= ATTR_SUBDIR;
|
|
Kmods SIG |
50e2b3 |
+ if (exfat_mode_can_hold_ro(inode) && !(inode->i_mode & 0222))
|
|
Kmods SIG |
50e2b3 |
+ attr |= ATTR_READONLY;
|
|
Kmods SIG |
50e2b3 |
+ return attr;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline void exfat_save_attr(struct inode *inode, unsigned short attr)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ if (exfat_mode_can_hold_ro(inode))
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_I(inode)->attr = attr & (ATTR_RWMASK | ATTR_READONLY);
|
|
Kmods SIG |
50e2b3 |
+ else
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_I(inode)->attr = attr & ATTR_RWMASK;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline bool exfat_is_last_sector_in_cluster(struct exfat_sb_info *sbi,
|
|
Kmods SIG |
50e2b3 |
+ sector_t sec)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ return ((sec - sbi->data_start_sector + 1) &
|
|
Kmods SIG |
50e2b3 |
+ ((1 << sbi->sect_per_clus_bits) - 1)) == 0;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int clus)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ return ((clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) +
|
|
Kmods SIG |
50e2b3 |
+ sbi->data_start_sector;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+static inline int exfat_sector_to_cluster(struct exfat_sb_info *sbi,
|
|
Kmods SIG |
50e2b3 |
+ sector_t sec)
|
|
Kmods SIG |
50e2b3 |
+{
|
|
Kmods SIG |
50e2b3 |
+ return ((sec - sbi->data_start_sector) >> sbi->sect_per_clus_bits) +
|
|
Kmods SIG |
50e2b3 |
+ EXFAT_RESERVED_CLUSTERS;
|
|
Kmods SIG |
50e2b3 |
+}
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* super.c */
|
|
Kmods SIG |
50e2b3 |
+int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flag);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* fatent.c */
|
|
Kmods SIG |
50e2b3 |
+#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain *p_chain);
|
|
Kmods SIG |
50e2b3 |
+int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain);
|
|
Kmods SIG |
50e2b3 |
+int exfat_ent_get(struct super_block *sb, unsigned int loc,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int *content);
|
|
Kmods SIG |
50e2b3 |
+int exfat_ent_set(struct super_block *sb, unsigned int loc,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int content);
|
|
Kmods SIG |
50e2b3 |
+int exfat_count_ext_entries(struct super_block *sb, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry, struct exfat_dentry *p_entry);
|
|
Kmods SIG |
50e2b3 |
+int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int len);
|
|
Kmods SIG |
50e2b3 |
+int exfat_zeroed_cluster(struct inode *dir, unsigned int clu);
|
|
Kmods SIG |
50e2b3 |
+int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int *ret_clu);
|
|
Kmods SIG |
50e2b3 |
+int exfat_count_num_clusters(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain *p_chain, unsigned int *ret_count);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* balloc.c */
|
|
Kmods SIG |
50e2b3 |
+int exfat_load_bitmap(struct super_block *sb);
|
|
Kmods SIG |
50e2b3 |
+void exfat_free_bitmap(struct exfat_sb_info *sbi);
|
|
Kmods SIG |
50e2b3 |
+int exfat_set_bitmap(struct inode *inode, unsigned int clu);
|
|
Kmods SIG |
50e2b3 |
+void exfat_clear_bitmap(struct inode *inode, unsigned int clu);
|
|
Kmods SIG |
50e2b3 |
+unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
|
|
Kmods SIG |
50e2b3 |
+int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* file.c */
|
|
Kmods SIG |
50e2b3 |
+extern const struct file_operations exfat_file_operations;
|
|
Kmods SIG |
50e2b3 |
+int __exfat_truncate(struct inode *inode, loff_t new_size);
|
|
Kmods SIG |
50e2b3 |
+void exfat_truncate(struct inode *inode, loff_t size);
|
|
Kmods SIG |
50e2b3 |
+int exfat_setattr(struct dentry *dentry, struct iattr *attr);
|
|
Kmods SIG |
50e2b3 |
+int exfat_getattr(const struct path *path, struct kstat *stat,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int request_mask, unsigned int query_flags);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* namei.c */
|
|
Kmods SIG |
50e2b3 |
+extern const struct dentry_operations exfat_dentry_ops;
|
|
Kmods SIG |
50e2b3 |
+extern const struct dentry_operations exfat_utf8_dentry_ops;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* cache.c */
|
|
Kmods SIG |
50e2b3 |
+int exfat_cache_init(void);
|
|
Kmods SIG |
50e2b3 |
+void exfat_cache_shutdown(void);
|
|
Kmods SIG |
50e2b3 |
+void exfat_cache_init_inode(struct inode *inode);
|
|
Kmods SIG |
50e2b3 |
+void exfat_cache_inval_inode(struct inode *inode);
|
|
Kmods SIG |
50e2b3 |
+int exfat_get_cluster(struct inode *inode, unsigned int cluster,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int *fclus, unsigned int *dclus,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int *last_dclus, int allow_eof);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* dir.c */
|
|
Kmods SIG |
50e2b3 |
+extern const struct inode_operations exfat_dir_inode_operations;
|
|
Kmods SIG |
50e2b3 |
+extern const struct file_operations exfat_dir_operations;
|
|
Kmods SIG |
50e2b3 |
+unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
|
|
Kmods SIG |
50e2b3 |
+int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry, unsigned int type, unsigned int start_clu,
|
|
Kmods SIG |
50e2b3 |
+ unsigned long long size);
|
|
Kmods SIG |
50e2b3 |
+int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry, int num_entries, struct exfat_uni_name *p_uniname);
|
|
Kmods SIG |
50e2b3 |
+int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry, int order, int num_entries);
|
|
Kmods SIG |
50e2b3 |
+int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry);
|
|
Kmods SIG |
50e2b3 |
+int exfat_update_dir_chksum_with_entry_set(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_entry_set_cache *es, int sync);
|
|
Kmods SIG |
50e2b3 |
+int exfat_calc_num_entries(struct exfat_uni_name *p_uniname);
|
|
Kmods SIG |
50e2b3 |
+int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname,
|
|
Kmods SIG |
50e2b3 |
+ int num_entries, unsigned int type);
|
|
Kmods SIG |
50e2b3 |
+int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu);
|
|
Kmods SIG |
50e2b3 |
+int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir,
|
|
Kmods SIG |
50e2b3 |
+ int entry, sector_t *sector, int *offset);
|
|
Kmods SIG |
50e2b3 |
+struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain *p_dir, int entry, struct buffer_head **bh,
|
|
Kmods SIG |
50e2b3 |
+ sector_t *sector);
|
|
Kmods SIG |
50e2b3 |
+struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_chain *p_dir, int entry, unsigned int type,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_dentry **file_ep);
|
|
Kmods SIG |
50e2b3 |
+int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* inode.c */
|
|
Kmods SIG |
50e2b3 |
+extern const struct inode_operations exfat_file_inode_operations;
|
|
Kmods SIG |
50e2b3 |
+void exfat_sync_inode(struct inode *inode);
|
|
Kmods SIG |
50e2b3 |
+struct inode *exfat_build_inode(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_dir_entry *info, loff_t i_pos);
|
|
Kmods SIG |
50e2b3 |
+void exfat_hash_inode(struct inode *inode, loff_t i_pos);
|
|
Kmods SIG |
50e2b3 |
+void exfat_unhash_inode(struct inode *inode);
|
|
Kmods SIG |
50e2b3 |
+struct inode *exfat_iget(struct super_block *sb, loff_t i_pos);
|
|
Kmods SIG |
50e2b3 |
+int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
|
|
Kmods SIG |
50e2b3 |
+void exfat_evict_inode(struct inode *inode);
|
|
Kmods SIG |
50e2b3 |
+int exfat_block_truncate_page(struct inode *inode, loff_t from);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* exfat/nls.c */
|
|
Kmods SIG |
50e2b3 |
+unsigned short exfat_toupper(struct super_block *sb, unsigned short a);
|
|
Kmods SIG |
50e2b3 |
+int exfat_uniname_ncmp(struct super_block *sb, unsigned short *a,
|
|
Kmods SIG |
50e2b3 |
+ unsigned short *b, unsigned int len);
|
|
Kmods SIG |
50e2b3 |
+int exfat_utf16_to_nls(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_uni_name *uniname, unsigned char *p_cstring,
|
|
Kmods SIG |
50e2b3 |
+ int len);
|
|
Kmods SIG |
50e2b3 |
+int exfat_nls_to_utf16(struct super_block *sb,
|
|
Kmods SIG |
50e2b3 |
+ const unsigned char *p_cstring, const int len,
|
|
Kmods SIG |
50e2b3 |
+ struct exfat_uni_name *uniname, int *p_lossy);
|
|
Kmods SIG |
50e2b3 |
+int exfat_create_upcase_table(struct super_block *sb);
|
|
Kmods SIG |
50e2b3 |
+void exfat_free_upcase_table(struct exfat_sb_info *sbi);
|
|
Kmods SIG |
50e2b3 |
+unsigned short exfat_high_surrogate(unicode_t u);
|
|
Kmods SIG |
50e2b3 |
+unsigned short exfat_low_surrogate(unicode_t u);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* exfat/misc.c */
|
|
Kmods SIG |
50e2b3 |
+void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
|
|
Kmods SIG |
50e2b3 |
+ __printf(3, 4) __cold;
|
|
Kmods SIG |
50e2b3 |
+#define exfat_fs_error(sb, fmt, args...) \
|
|
Kmods SIG |
50e2b3 |
+ __exfat_fs_error(sb, 1, fmt, ## args)
|
|
Kmods SIG |
50e2b3 |
+#define exfat_fs_error_ratelimit(sb, fmt, args...) \
|
|
Kmods SIG |
50e2b3 |
+ __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
|
|
Kmods SIG |
50e2b3 |
+ fmt, ## args)
|
|
Kmods SIG |
50e2b3 |
+void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
|
|
Kmods SIG |
50e2b3 |
+ __printf(3, 4) __cold;
|
|
Kmods SIG |
50e2b3 |
+void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
|
Kmods SIG |
50e2b3 |
+ u8 tz, __le16 time, __le16 date, u8 time_ms);
|
|
Kmods SIG |
50e2b3 |
+void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
|
Kmods SIG |
50e2b3 |
+ u8 *tz, __le16 *time, __le16 *date, u8 *time_ms);
|
|
Kmods SIG |
50e2b3 |
+unsigned short exfat_calc_chksum_2byte(void *data, int len,
|
|
Kmods SIG |
50e2b3 |
+ unsigned short chksum, int type);
|
|
Kmods SIG |
50e2b3 |
+void exfat_update_bh(struct super_block *sb, struct buffer_head *bh, int sync);
|
|
Kmods SIG |
50e2b3 |
+void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
|
|
Kmods SIG |
50e2b3 |
+ unsigned int size, unsigned char flags);
|
|
Kmods SIG |
50e2b3 |
+void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#endif /* !_EXFAT_FS_H */
|
|
Kmods SIG |
50e2b3 |
diff --git a/src/exfat_raw.h b/src/exfat_raw.h
|
|
Kmods SIG |
50e2b3 |
new file mode 100644
|
|
Kmods SIG |
50e2b3 |
index 0000000000000000000000000000000000000000..2a841010e6490ccafd5d12844a48a93fc6ee4bbf
|
|
Kmods SIG |
50e2b3 |
--- /dev/null
|
|
Kmods SIG |
50e2b3 |
+++ b/src/exfat_raw.h
|
|
Kmods SIG |
50e2b3 |
@@ -0,0 +1,184 @@
|
|
Kmods SIG |
50e2b3 |
+/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Kmods SIG |
50e2b3 |
+/*
|
|
Kmods SIG |
50e2b3 |
+ * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
|
|
Kmods SIG |
50e2b3 |
+ */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#ifndef _EXFAT_RAW_H
|
|
Kmods SIG |
50e2b3 |
+#define _EXFAT_RAW_H
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#include <linux/types.h>
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define PBR_SIGNATURE 0xAA55
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_MAX_FILE_LEN 255
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define VOL_CLEAN 0x0000
|
|
Kmods SIG |
50e2b3 |
+#define VOL_DIRTY 0x0002
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_EOF_CLUSTER 0xFFFFFFFFu
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_BAD_CLUSTER 0xFFFFFFF7u
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_FREE_CLUSTER 0
|
|
Kmods SIG |
50e2b3 |
+/* Cluster 0, 1 are reserved, the first cluster is 2 in the cluster heap. */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_RESERVED_CLUSTERS 2
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_FIRST_CLUSTER 2
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_DATA_CLUSTER_COUNT(sbi) \
|
|
Kmods SIG |
50e2b3 |
+ ((sbi)->num_clusters - EXFAT_RESERVED_CLUSTERS)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* AllocationPossible and NoFatChain field in GeneralSecondaryFlags Field */
|
|
Kmods SIG |
50e2b3 |
+#define ALLOC_FAT_CHAIN 0x01
|
|
Kmods SIG |
50e2b3 |
+#define ALLOC_NO_FAT_CHAIN 0x03
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define DENTRY_SIZE 32 /* directory entry size */
|
|
Kmods SIG |
50e2b3 |
+#define DENTRY_SIZE_BITS 5
|
|
Kmods SIG |
50e2b3 |
+/* exFAT allows 8388608(256MB) directory entries */
|
|
Kmods SIG |
50e2b3 |
+#define MAX_EXFAT_DENTRIES 8388608
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* dentry types */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_UNUSED 0x00 /* end of directory */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_DELETE (~0x80)
|
|
Kmods SIG |
50e2b3 |
+#define IS_EXFAT_DELETED(x) ((x) < 0x80) /* deleted file (0x01~0x7F) */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_INVAL 0x80 /* invalid value */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_BITMAP 0x81 /* allocation bitmap */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_UPCASE 0x82 /* upcase table */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_VOLUME 0x83 /* volume label */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_FILE 0x85 /* file or dir */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_GUID 0xA0
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_PADDING 0xA1
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_ACLTAB 0xA2
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_STREAM 0xC0 /* stream entry */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_NAME 0xC1 /* file name entry */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_ACL 0xC2 /* stream entry */
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define IS_EXFAT_CRITICAL_PRI(x) (x < 0xA0)
|
|
Kmods SIG |
50e2b3 |
+#define IS_EXFAT_BENIGN_PRI(x) (x < 0xC0)
|
|
Kmods SIG |
50e2b3 |
+#define IS_EXFAT_CRITICAL_SEC(x) (x < 0xE0)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* checksum types */
|
|
Kmods SIG |
50e2b3 |
+#define CS_DIR_ENTRY 0
|
|
Kmods SIG |
50e2b3 |
+#define CS_PBR_SECTOR 1
|
|
Kmods SIG |
50e2b3 |
+#define CS_DEFAULT 2
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* file attributes */
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_READONLY 0x0001
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_HIDDEN 0x0002
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_SYSTEM 0x0004
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_VOLUME 0x0008
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_SUBDIR 0x0010
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_ARCHIVE 0x0020
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define ATTR_RWMASK (ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME | \
|
|
Kmods SIG |
50e2b3 |
+ ATTR_SUBDIR | ATTR_ARCHIVE)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define PBR64_JUMP_BOOT_LEN 3
|
|
Kmods SIG |
50e2b3 |
+#define PBR64_OEM_NAME_LEN 8
|
|
Kmods SIG |
50e2b3 |
+#define PBR64_RESERVED_LEN 53
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_FILE_NAME_LEN 15
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* EXFAT BIOS parameter block (64 bytes) */
|
|
Kmods SIG |
50e2b3 |
+struct bpb64 {
|
|
Kmods SIG |
50e2b3 |
+ __u8 jmp_boot[PBR64_JUMP_BOOT_LEN];
|
|
Kmods SIG |
50e2b3 |
+ __u8 oem_name[PBR64_OEM_NAME_LEN];
|
|
Kmods SIG |
50e2b3 |
+ __u8 res_zero[PBR64_RESERVED_LEN];
|
|
Kmods SIG |
50e2b3 |
+} __packed;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* EXFAT EXTEND BIOS parameter block (56 bytes) */
|
|
Kmods SIG |
50e2b3 |
+struct bsx64 {
|
|
Kmods SIG |
50e2b3 |
+ __le64 vol_offset;
|
|
Kmods SIG |
50e2b3 |
+ __le64 vol_length;
|
|
Kmods SIG |
50e2b3 |
+ __le32 fat_offset;
|
|
Kmods SIG |
50e2b3 |
+ __le32 fat_length;
|
|
Kmods SIG |
50e2b3 |
+ __le32 clu_offset;
|
|
Kmods SIG |
50e2b3 |
+ __le32 clu_count;
|
|
Kmods SIG |
50e2b3 |
+ __le32 root_cluster;
|
|
Kmods SIG |
50e2b3 |
+ __le32 vol_serial;
|
|
Kmods SIG |
50e2b3 |
+ __u8 fs_version[2];
|
|
Kmods SIG |
50e2b3 |
+ __le16 vol_flags;
|
|
Kmods SIG |
50e2b3 |
+ __u8 sect_size_bits;
|
|
Kmods SIG |
50e2b3 |
+ __u8 sect_per_clus_bits;
|
|
Kmods SIG |
50e2b3 |
+ __u8 num_fats;
|
|
Kmods SIG |
50e2b3 |
+ __u8 phy_drv_no;
|
|
Kmods SIG |
50e2b3 |
+ __u8 perc_in_use;
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved2[7];
|
|
Kmods SIG |
50e2b3 |
+} __packed;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* EXFAT PBR[BPB+BSX] (120 bytes) */
|
|
Kmods SIG |
50e2b3 |
+struct pbr64 {
|
|
Kmods SIG |
50e2b3 |
+ struct bpb64 bpb;
|
|
Kmods SIG |
50e2b3 |
+ struct bsx64 bsx;
|
|
Kmods SIG |
50e2b3 |
+} __packed;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* Common PBR[Partition Boot Record] (512 bytes) */
|
|
Kmods SIG |
50e2b3 |
+struct pbr {
|
|
Kmods SIG |
50e2b3 |
+ union {
|
|
Kmods SIG |
50e2b3 |
+ __u8 raw[64];
|
|
Kmods SIG |
50e2b3 |
+ struct bpb64 f64;
|
|
Kmods SIG |
50e2b3 |
+ } bpb;
|
|
Kmods SIG |
50e2b3 |
+ union {
|
|
Kmods SIG |
50e2b3 |
+ __u8 raw[56];
|
|
Kmods SIG |
50e2b3 |
+ struct bsx64 f64;
|
|
Kmods SIG |
50e2b3 |
+ } bsx;
|
|
Kmods SIG |
50e2b3 |
+ __u8 boot_code[390];
|
|
Kmods SIG |
50e2b3 |
+ __le16 signature;
|
|
Kmods SIG |
50e2b3 |
+} __packed;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+struct exfat_dentry {
|
|
Kmods SIG |
50e2b3 |
+ __u8 type;
|
|
Kmods SIG |
50e2b3 |
+ union {
|
|
Kmods SIG |
50e2b3 |
+ struct {
|
|
Kmods SIG |
50e2b3 |
+ __u8 num_ext;
|
|
Kmods SIG |
50e2b3 |
+ __le16 checksum;
|
|
Kmods SIG |
50e2b3 |
+ __le16 attr;
|
|
Kmods SIG |
50e2b3 |
+ __le16 reserved1;
|
|
Kmods SIG |
50e2b3 |
+ __le16 create_time;
|
|
Kmods SIG |
50e2b3 |
+ __le16 create_date;
|
|
Kmods SIG |
50e2b3 |
+ __le16 modify_time;
|
|
Kmods SIG |
50e2b3 |
+ __le16 modify_date;
|
|
Kmods SIG |
50e2b3 |
+ __le16 access_time;
|
|
Kmods SIG |
50e2b3 |
+ __le16 access_date;
|
|
Kmods SIG |
50e2b3 |
+ __u8 create_time_ms;
|
|
Kmods SIG |
50e2b3 |
+ __u8 modify_time_ms;
|
|
Kmods SIG |
50e2b3 |
+ __u8 create_tz;
|
|
Kmods SIG |
50e2b3 |
+ __u8 modify_tz;
|
|
Kmods SIG |
50e2b3 |
+ __u8 access_tz;
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved2[7];
|
|
Kmods SIG |
50e2b3 |
+ } __packed file; /* file directory entry */
|
|
Kmods SIG |
50e2b3 |
+ struct {
|
|
Kmods SIG |
50e2b3 |
+ __u8 flags;
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved1;
|
|
Kmods SIG |
50e2b3 |
+ __u8 name_len;
|
|
Kmods SIG |
50e2b3 |
+ __le16 name_hash;
|
|
Kmods SIG |
50e2b3 |
+ __le16 reserved2;
|
|
Kmods SIG |
50e2b3 |
+ __le64 valid_size;
|
|
Kmods SIG |
50e2b3 |
+ __le32 reserved3;
|
|
Kmods SIG |
50e2b3 |
+ __le32 start_clu;
|
|
Kmods SIG |
50e2b3 |
+ __le64 size;
|
|
Kmods SIG |
50e2b3 |
+ } __packed stream; /* stream extension directory entry */
|
|
Kmods SIG |
50e2b3 |
+ struct {
|
|
Kmods SIG |
50e2b3 |
+ __u8 flags;
|
|
Kmods SIG |
50e2b3 |
+ __le16 unicode_0_14[EXFAT_FILE_NAME_LEN];
|
|
Kmods SIG |
50e2b3 |
+ } __packed name; /* file name directory entry */
|
|
Kmods SIG |
50e2b3 |
+ struct {
|
|
Kmods SIG |
50e2b3 |
+ __u8 flags;
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved[18];
|
|
Kmods SIG |
50e2b3 |
+ __le32 start_clu;
|
|
Kmods SIG |
50e2b3 |
+ __le64 size;
|
|
Kmods SIG |
50e2b3 |
+ } __packed bitmap; /* allocation bitmap directory entry */
|
|
Kmods SIG |
50e2b3 |
+ struct {
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved1[3];
|
|
Kmods SIG |
50e2b3 |
+ __le32 checksum;
|
|
Kmods SIG |
50e2b3 |
+ __u8 reserved2[12];
|
|
Kmods SIG |
50e2b3 |
+ __le32 start_clu;
|
|
Kmods SIG |
50e2b3 |
+ __le64 size;
|
|
Kmods SIG |
50e2b3 |
+ } __packed upcase; /* up-case table directory entry */
|
|
Kmods SIG |
50e2b3 |
+ } __packed dentry;
|
|
Kmods SIG |
50e2b3 |
+} __packed;
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_TZ_VALID (1 << 7)
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+/* Jan 1 GMT 00:00:00 1980 */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_MIN_TIMESTAMP_SECS 315532800LL
|
|
Kmods SIG |
50e2b3 |
+/* Dec 31 GMT 23:59:59 2107 */
|
|
Kmods SIG |
50e2b3 |
+#define EXFAT_MAX_TIMESTAMP_SECS 4354819199LL
|
|
Kmods SIG |
50e2b3 |
+
|
|
Kmods SIG |
50e2b3 |
+#endif /* !_EXFAT_RAW_H */
|
|
Kmods SIG |
50e2b3 |
--
|
|
Kmods SIG |
50e2b3 |
2.31.1
|
|
Kmods SIG |
50e2b3 |
|