linux/fs/ntfs/volume.h
<<
>>
Prefs
   1/*
   2 * volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
   3 *            of the Linux-NTFS project.
   4 *
   5 * Copyright (c) 2001-2006 Anton Altaparmakov
   6 * Copyright (c) 2002 Richard Russon
   7 *
   8 * This program/include file is free software; you can redistribute it and/or
   9 * modify it under the terms of the GNU General Public License as published
  10 * by the Free Software Foundation; either version 2 of the License, or
  11 * (at your option) any later version.
  12 *
  13 * This program/include file is distributed in the hope that it will be
  14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 * GNU General Public License for more details.
  17 *
  18 * You should have received a copy of the GNU General Public License
  19 * along with this program (in the main directory of the Linux-NTFS
  20 * distribution in the file COPYING); if not, write to the Free Software
  21 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22 */
  23
  24#ifndef _LINUX_NTFS_VOLUME_H
  25#define _LINUX_NTFS_VOLUME_H
  26
  27#include <linux/rwsem.h>
  28#include <linux/uidgid.h>
  29
  30#include "types.h"
  31#include "layout.h"
  32
  33/*
  34 * The NTFS in memory super block structure.
  35 */
  36typedef struct {
  37        /*
  38         * FIXME: Reorder to have commonly used together element within the
  39         * same cache line, aiming at a cache line size of 32 bytes. Aim for
  40         * 64 bytes for less commonly used together elements. Put most commonly
  41         * used elements to front of structure. Obviously do this only when the
  42         * structure has stabilized... (AIA)
  43         */
  44        /* Device specifics. */
  45        struct super_block *sb;         /* Pointer back to the super_block. */
  46        LCN nr_blocks;                  /* Number of sb->s_blocksize bytes
  47                                           sized blocks on the device. */
  48        /* Configuration provided by user at mount time. */
  49        unsigned long flags;            /* Miscellaneous flags, see below. */
  50        kuid_t uid;                     /* uid that files will be mounted as. */
  51        kgid_t gid;                     /* gid that files will be mounted as. */
  52        umode_t fmask;                  /* The mask for file permissions. */
  53        umode_t dmask;                  /* The mask for directory
  54                                           permissions. */
  55        u8 mft_zone_multiplier;         /* Initial mft zone multiplier. */
  56        u8 on_errors;                   /* What to do on filesystem errors. */
  57        /* NTFS bootsector provided information. */
  58        u16 sector_size;                /* in bytes */
  59        u8 sector_size_bits;            /* log2(sector_size) */
  60        u32 cluster_size;               /* in bytes */
  61        u32 cluster_size_mask;          /* cluster_size - 1 */
  62        u8 cluster_size_bits;           /* log2(cluster_size) */
  63        u32 mft_record_size;            /* in bytes */
  64        u32 mft_record_size_mask;       /* mft_record_size - 1 */
  65        u8 mft_record_size_bits;        /* log2(mft_record_size) */
  66        u32 index_record_size;          /* in bytes */
  67        u32 index_record_size_mask;     /* index_record_size - 1 */
  68        u8 index_record_size_bits;      /* log2(index_record_size) */
  69        LCN nr_clusters;                /* Volume size in clusters == number of
  70                                           bits in lcn bitmap. */
  71        LCN mft_lcn;                    /* Cluster location of mft data. */
  72        LCN mftmirr_lcn;                /* Cluster location of copy of mft. */
  73        u64 serial_no;                  /* The volume serial number. */
  74        /* Mount specific NTFS information. */
  75        u32 upcase_len;                 /* Number of entries in upcase[]. */
  76        ntfschar *upcase;               /* The upcase table. */
  77
  78        s32 attrdef_size;               /* Size of the attribute definition
  79                                           table in bytes. */
  80        ATTR_DEF *attrdef;              /* Table of attribute definitions.
  81                                           Obtained from FILE_AttrDef. */
  82
  83#ifdef NTFS_RW
  84        /* Variables used by the cluster and mft allocators. */
  85        s64 mft_data_pos;               /* Mft record number at which to
  86                                           allocate the next mft record. */
  87        LCN mft_zone_start;             /* First cluster of the mft zone. */
  88        LCN mft_zone_end;               /* First cluster beyond the mft zone. */
  89        LCN mft_zone_pos;               /* Current position in the mft zone. */
  90        LCN data1_zone_pos;             /* Current position in the first data
  91                                           zone. */
  92        LCN data2_zone_pos;             /* Current position in the second data
  93                                           zone. */
  94#endif /* NTFS_RW */
  95
  96        struct inode *mft_ino;          /* The VFS inode of $MFT. */
  97
  98        struct inode *mftbmp_ino;       /* Attribute inode for $MFT/$BITMAP. */
  99        struct rw_semaphore mftbmp_lock; /* Lock for serializing accesses to the
 100                                            mft record bitmap ($MFT/$BITMAP). */
 101#ifdef NTFS_RW
 102        struct inode *mftmirr_ino;      /* The VFS inode of $MFTMirr. */
 103        int mftmirr_size;               /* Size of mft mirror in mft records. */
 104
 105        struct inode *logfile_ino;      /* The VFS inode of $LogFile. */
 106#endif /* NTFS_RW */
 107
 108        struct inode *lcnbmp_ino;       /* The VFS inode of $Bitmap. */
 109        struct rw_semaphore lcnbmp_lock; /* Lock for serializing accesses to the
 110                                            cluster bitmap ($Bitmap/$DATA). */
 111
 112        struct inode *vol_ino;          /* The VFS inode of $Volume. */
 113        VOLUME_FLAGS vol_flags;         /* Volume flags. */
 114        u8 major_ver;                   /* Ntfs major version of volume. */
 115        u8 minor_ver;                   /* Ntfs minor version of volume. */
 116
 117        struct inode *root_ino;         /* The VFS inode of the root
 118                                           directory. */
 119        struct inode *secure_ino;       /* The VFS inode of $Secure (NTFS3.0+
 120                                           only, otherwise NULL). */
 121        struct inode *extend_ino;       /* The VFS inode of $Extend (NTFS3.0+
 122                                           only, otherwise NULL). */
 123#ifdef NTFS_RW
 124        /* $Quota stuff is NTFS3.0+ specific.  Unused/NULL otherwise. */
 125        struct inode *quota_ino;        /* The VFS inode of $Quota. */
 126        struct inode *quota_q_ino;      /* Attribute inode for $Quota/$Q. */
 127        /* $UsnJrnl stuff is NTFS3.0+ specific.  Unused/NULL otherwise. */
 128        struct inode *usnjrnl_ino;      /* The VFS inode of $UsnJrnl. */
 129        struct inode *usnjrnl_max_ino;  /* Attribute inode for $UsnJrnl/$Max. */
 130        struct inode *usnjrnl_j_ino;    /* Attribute inode for $UsnJrnl/$J. */
 131#endif /* NTFS_RW */
 132        struct nls_table *nls_map;
 133} ntfs_volume;
 134
 135/*
 136 * Defined bits for the flags field in the ntfs_volume structure.
 137 */
 138typedef enum {
 139        NV_Errors,              /* 1: Volume has errors, prevent remount rw. */
 140        NV_ShowSystemFiles,     /* 1: Return system files in ntfs_readdir(). */
 141        NV_CaseSensitive,       /* 1: Treat file names as case sensitive and
 142                                      create filenames in the POSIX namespace.
 143                                      Otherwise be case insensitive but still
 144                                      create file names in POSIX namespace. */
 145        NV_LogFileEmpty,        /* 1: $LogFile journal is empty. */
 146        NV_QuotaOutOfDate,      /* 1: $Quota is out of date. */
 147        NV_UsnJrnlStamped,      /* 1: $UsnJrnl has been stamped. */
 148        NV_SparseEnabled,       /* 1: May create sparse files. */
 149} ntfs_volume_flags;
 150
 151/*
 152 * Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo()
 153 * functions.
 154 */
 155#define DEFINE_NVOL_BIT_OPS(flag)                                       \
 156static inline int NVol##flag(ntfs_volume *vol)          \
 157{                                                       \
 158        return test_bit(NV_##flag, &(vol)->flags);      \
 159}                                                       \
 160static inline void NVolSet##flag(ntfs_volume *vol)      \
 161{                                                       \
 162        set_bit(NV_##flag, &(vol)->flags);              \
 163}                                                       \
 164static inline void NVolClear##flag(ntfs_volume *vol)    \
 165{                                                       \
 166        clear_bit(NV_##flag, &(vol)->flags);            \
 167}
 168
 169/* Emit the ntfs volume bitops functions. */
 170DEFINE_NVOL_BIT_OPS(Errors)
 171DEFINE_NVOL_BIT_OPS(ShowSystemFiles)
 172DEFINE_NVOL_BIT_OPS(CaseSensitive)
 173DEFINE_NVOL_BIT_OPS(LogFileEmpty)
 174DEFINE_NVOL_BIT_OPS(QuotaOutOfDate)
 175DEFINE_NVOL_BIT_OPS(UsnJrnlStamped)
 176DEFINE_NVOL_BIT_OPS(SparseEnabled)
 177
 178#endif /* _LINUX_NTFS_VOLUME_H */
 179