Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
0004  *        of the Linux-NTFS project.
0005  *
0006  * Copyright (c) 2001-2006 Anton Altaparmakov
0007  * Copyright (c) 2002 Richard Russon
0008  */
0009 
0010 #ifndef _LINUX_NTFS_VOLUME_H
0011 #define _LINUX_NTFS_VOLUME_H
0012 
0013 #include <linux/rwsem.h>
0014 #include <linux/uidgid.h>
0015 
0016 #include "types.h"
0017 #include "layout.h"
0018 
0019 /*
0020  * The NTFS in memory super block structure.
0021  */
0022 typedef struct {
0023     /*
0024      * FIXME: Reorder to have commonly used together element within the
0025      * same cache line, aiming at a cache line size of 32 bytes. Aim for
0026      * 64 bytes for less commonly used together elements. Put most commonly
0027      * used elements to front of structure. Obviously do this only when the
0028      * structure has stabilized... (AIA)
0029      */
0030     /* Device specifics. */
0031     struct super_block *sb;     /* Pointer back to the super_block. */
0032     LCN nr_blocks;          /* Number of sb->s_blocksize bytes
0033                        sized blocks on the device. */
0034     /* Configuration provided by user at mount time. */
0035     unsigned long flags;        /* Miscellaneous flags, see below. */
0036     kuid_t uid;         /* uid that files will be mounted as. */
0037     kgid_t gid;         /* gid that files will be mounted as. */
0038     umode_t fmask;          /* The mask for file permissions. */
0039     umode_t dmask;          /* The mask for directory
0040                        permissions. */
0041     u8 mft_zone_multiplier;     /* Initial mft zone multiplier. */
0042     u8 on_errors;           /* What to do on filesystem errors. */
0043     /* NTFS bootsector provided information. */
0044     u16 sector_size;        /* in bytes */
0045     u8 sector_size_bits;        /* log2(sector_size) */
0046     u32 cluster_size;       /* in bytes */
0047     u32 cluster_size_mask;      /* cluster_size - 1 */
0048     u8 cluster_size_bits;       /* log2(cluster_size) */
0049     u32 mft_record_size;        /* in bytes */
0050     u32 mft_record_size_mask;   /* mft_record_size - 1 */
0051     u8 mft_record_size_bits;    /* log2(mft_record_size) */
0052     u32 index_record_size;      /* in bytes */
0053     u32 index_record_size_mask; /* index_record_size - 1 */
0054     u8 index_record_size_bits;  /* log2(index_record_size) */
0055     LCN nr_clusters;        /* Volume size in clusters == number of
0056                        bits in lcn bitmap. */
0057     LCN mft_lcn;            /* Cluster location of mft data. */
0058     LCN mftmirr_lcn;        /* Cluster location of copy of mft. */
0059     u64 serial_no;          /* The volume serial number. */
0060     /* Mount specific NTFS information. */
0061     u32 upcase_len;         /* Number of entries in upcase[]. */
0062     ntfschar *upcase;       /* The upcase table. */
0063 
0064     s32 attrdef_size;       /* Size of the attribute definition
0065                        table in bytes. */
0066     ATTR_DEF *attrdef;      /* Table of attribute definitions.
0067                        Obtained from FILE_AttrDef. */
0068 
0069 #ifdef NTFS_RW
0070     /* Variables used by the cluster and mft allocators. */
0071     s64 mft_data_pos;       /* Mft record number at which to
0072                        allocate the next mft record. */
0073     LCN mft_zone_start;     /* First cluster of the mft zone. */
0074     LCN mft_zone_end;       /* First cluster beyond the mft zone. */
0075     LCN mft_zone_pos;       /* Current position in the mft zone. */
0076     LCN data1_zone_pos;     /* Current position in the first data
0077                        zone. */
0078     LCN data2_zone_pos;     /* Current position in the second data
0079                        zone. */
0080 #endif /* NTFS_RW */
0081 
0082     struct inode *mft_ino;      /* The VFS inode of $MFT. */
0083 
0084     struct inode *mftbmp_ino;   /* Attribute inode for $MFT/$BITMAP. */
0085     struct rw_semaphore mftbmp_lock; /* Lock for serializing accesses to the
0086                         mft record bitmap ($MFT/$BITMAP). */
0087 #ifdef NTFS_RW
0088     struct inode *mftmirr_ino;  /* The VFS inode of $MFTMirr. */
0089     int mftmirr_size;       /* Size of mft mirror in mft records. */
0090 
0091     struct inode *logfile_ino;  /* The VFS inode of $LogFile. */
0092 #endif /* NTFS_RW */
0093 
0094     struct inode *lcnbmp_ino;   /* The VFS inode of $Bitmap. */
0095     struct rw_semaphore lcnbmp_lock; /* Lock for serializing accesses to the
0096                         cluster bitmap ($Bitmap/$DATA). */
0097 
0098     struct inode *vol_ino;      /* The VFS inode of $Volume. */
0099     VOLUME_FLAGS vol_flags;     /* Volume flags. */
0100     u8 major_ver;           /* Ntfs major version of volume. */
0101     u8 minor_ver;           /* Ntfs minor version of volume. */
0102 
0103     struct inode *root_ino;     /* The VFS inode of the root
0104                        directory. */
0105     struct inode *secure_ino;   /* The VFS inode of $Secure (NTFS3.0+
0106                        only, otherwise NULL). */
0107     struct inode *extend_ino;   /* The VFS inode of $Extend (NTFS3.0+
0108                        only, otherwise NULL). */
0109 #ifdef NTFS_RW
0110     /* $Quota stuff is NTFS3.0+ specific.  Unused/NULL otherwise. */
0111     struct inode *quota_ino;    /* The VFS inode of $Quota. */
0112     struct inode *quota_q_ino;  /* Attribute inode for $Quota/$Q. */
0113     /* $UsnJrnl stuff is NTFS3.0+ specific.  Unused/NULL otherwise. */
0114     struct inode *usnjrnl_ino;  /* The VFS inode of $UsnJrnl. */
0115     struct inode *usnjrnl_max_ino;  /* Attribute inode for $UsnJrnl/$Max. */
0116     struct inode *usnjrnl_j_ino;    /* Attribute inode for $UsnJrnl/$J. */
0117 #endif /* NTFS_RW */
0118     struct nls_table *nls_map;
0119 } ntfs_volume;
0120 
0121 /*
0122  * Defined bits for the flags field in the ntfs_volume structure.
0123  */
0124 typedef enum {
0125     NV_Errors,      /* 1: Volume has errors, prevent remount rw. */
0126     NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
0127     NV_CaseSensitive,   /* 1: Treat file names as case sensitive and
0128                       create filenames in the POSIX namespace.
0129                       Otherwise be case insensitive but still
0130                       create file names in POSIX namespace. */
0131     NV_LogFileEmpty,    /* 1: $LogFile journal is empty. */
0132     NV_QuotaOutOfDate,  /* 1: $Quota is out of date. */
0133     NV_UsnJrnlStamped,  /* 1: $UsnJrnl has been stamped. */
0134     NV_SparseEnabled,   /* 1: May create sparse files. */
0135 } ntfs_volume_flags;
0136 
0137 /*
0138  * Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo()
0139  * functions.
0140  */
0141 #define DEFINE_NVOL_BIT_OPS(flag)                   \
0142 static inline int NVol##flag(ntfs_volume *vol)      \
0143 {                           \
0144     return test_bit(NV_##flag, &(vol)->flags);  \
0145 }                           \
0146 static inline void NVolSet##flag(ntfs_volume *vol)  \
0147 {                           \
0148     set_bit(NV_##flag, &(vol)->flags);      \
0149 }                           \
0150 static inline void NVolClear##flag(ntfs_volume *vol)    \
0151 {                           \
0152     clear_bit(NV_##flag, &(vol)->flags);        \
0153 }
0154 
0155 /* Emit the ntfs volume bitops functions. */
0156 DEFINE_NVOL_BIT_OPS(Errors)
0157 DEFINE_NVOL_BIT_OPS(ShowSystemFiles)
0158 DEFINE_NVOL_BIT_OPS(CaseSensitive)
0159 DEFINE_NVOL_BIT_OPS(LogFileEmpty)
0160 DEFINE_NVOL_BIT_OPS(QuotaOutOfDate)
0161 DEFINE_NVOL_BIT_OPS(UsnJrnlStamped)
0162 DEFINE_NVOL_BIT_OPS(SparseEnabled)
0163 
0164 #endif /* _LINUX_NTFS_VOLUME_H */