Commit aa33c44f authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Finish off sparse annotation.

- Fix all the sparse bitwise warnings.  Had to change all the enums
  storing little endian values to #defines because we cannot set enums
  to be little endian so we had lots of bitwise warnings from sparse.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent 2a54ecd7
...@@ -48,6 +48,9 @@ ToDo/Notes: ...@@ -48,6 +48,9 @@ ToDo/Notes:
Affected files are fs/ntfs/layout.h, logfile.h, and time.h. Affected files are fs/ntfs/layout.h, logfile.h, and time.h.
- Do proper type casting when using ntfs_is_*_recordp() in - Do proper type casting when using ntfs_is_*_recordp() in
fs/ntfs/logfile.c, mft.c, and super.c. fs/ntfs/logfile.c, mft.c, and super.c.
- Fix all the sparse bitwise warnings. Had to change all the enums
storing little endian values to #defines because we cannot set enums
to be little endian so we had lots of bitwise warnings from sparse.
2.1.18 - Fix scheduling latencies at mount time as well as an endianness bug. 2.1.18 - Fix scheduling latencies at mount time as well as an endianness bug.
......
...@@ -1203,7 +1203,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn, ...@@ -1203,7 +1203,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
* Warning: Never use @val when looking for attribute types which can be * Warning: Never use @val when looking for attribute types which can be
* non-resident as this most likely will result in a crash! * non-resident as this most likely will result in a crash!
*/ */
static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name, static int ntfs_attr_find(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u32 name_len, const IGNORE_CASE_BOOL ic,
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx) const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
{ {
...@@ -1475,7 +1475,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start, ...@@ -1475,7 +1475,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
* On actual error, ntfs_external_attr_find() returns -EIO. In this case * On actual error, ntfs_external_attr_find() returns -EIO. In this case
* @ctx->attr is undefined and in particular do not rely on it not changing. * @ctx->attr is undefined and in particular do not rely on it not changing.
*/ */
static int ntfs_external_attr_find(const ATTR_TYPES type, static int ntfs_external_attr_find(const ATTR_TYPE type,
const ntfschar *name, const u32 name_len, const ntfschar *name, const u32 name_len,
const IGNORE_CASE_BOOL ic, const VCN lowest_vcn, const IGNORE_CASE_BOOL ic, const VCN lowest_vcn,
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx) const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
...@@ -1620,7 +1620,8 @@ static int ntfs_external_attr_find(const ATTR_TYPES type, ...@@ -1620,7 +1620,8 @@ static int ntfs_external_attr_find(const ATTR_TYPES type,
} else { } else {
/* We want an extent record. */ /* We want an extent record. */
ctx->mrec = map_extent_mft_record(base_ni, ctx->mrec = map_extent_mft_record(base_ni,
al_entry->mft_reference, &ni); le64_to_cpu(
al_entry->mft_reference), &ni);
ctx->ntfs_ino = ni; ctx->ntfs_ino = ni;
if (IS_ERR(ctx->mrec)) { if (IS_ERR(ctx->mrec)) {
ntfs_error(vol->sb, "Failed to map " ntfs_error(vol->sb, "Failed to map "
...@@ -1799,7 +1800,7 @@ static int ntfs_external_attr_find(const ATTR_TYPES type, ...@@ -1799,7 +1800,7 @@ static int ntfs_external_attr_find(const ATTR_TYPES type,
* When -errno != -ENOENT, an error occured during the lookup. @ctx->attr is * When -errno != -ENOENT, an error occured during the lookup. @ctx->attr is
* then undefined and in particular you should not rely on it not changing. * then undefined and in particular you should not rely on it not changing.
*/ */
int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name, int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len, const VCN lowest_vcn, const u8 *val, const u32 val_len,
ntfs_attr_search_ctx *ctx) ntfs_attr_search_ctx *ctx)
......
...@@ -81,7 +81,7 @@ extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn); ...@@ -81,7 +81,7 @@ extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn, extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
const BOOL need_write); const BOOL need_write);
int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name, int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len, const VCN lowest_vcn, const u8 *val, const u32 val_len,
ntfs_attr_search_ctx *ctx); ntfs_attr_search_ctx *ctx);
......
...@@ -97,24 +97,26 @@ static ntfs_collate_func_t ntfs_do_collate0x1[4] = { ...@@ -97,24 +97,26 @@ static ntfs_collate_func_t ntfs_do_collate0x1[4] = {
* For speed we use the collation rule @cr as an index into two tables of * For speed we use the collation rule @cr as an index into two tables of
* function pointers to call the appropriate collation function. * function pointers to call the appropriate collation function.
*/ */
int ntfs_collate(ntfs_volume *vol, COLLATION_RULES cr, int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
const void *data1, const int data1_len, const void *data1, const int data1_len,
const void *data2, const int data2_len) { const void *data2, const int data2_len) {
int i;
ntfs_debug("Entering."); ntfs_debug("Entering.");
/* /*
* FIXME: At the moment we only support COLLATION_BINARY and * FIXME: At the moment we only support COLLATION_BINARY and
* COLLATION_NTOFS_ULONG, so we BUG() for everything else for now. * COLLATION_NTOFS_ULONG, so we BUG() for everything else for now.
*/ */
BUG_ON(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG); BUG_ON(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG);
cr = le32_to_cpu(cr); i = le32_to_cpu(cr);
BUG_ON(cr < 0); BUG_ON(i < 0);
if (cr <= 0x02) if (i <= 0x02)
return ntfs_do_collate0x0[cr](vol, data1, data1_len, return ntfs_do_collate0x0[i](vol, data1, data1_len,
data2, data2_len); data2, data2_len);
BUG_ON(cr < 0x10); BUG_ON(i < 0x10);
cr -= 0x10; i -= 0x10;
if (likely(cr <= 3)) if (likely(i <= 3))
return ntfs_do_collate0x1[cr](vol, data1, data1_len, return ntfs_do_collate0x1[i](vol, data1, data1_len,
data2, data2_len); data2, data2_len);
BUG(); BUG();
return 0; return 0;
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
#include "types.h" #include "types.h"
#include "volume.h" #include "volume.h"
static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULES cr) { static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
int i;
/* /*
* FIXME: At the moment we only support COLLATION_BINARY and * FIXME: At the moment we only support COLLATION_BINARY and
* COLLATION_NTOFS_ULONG, so we return false for everything else for * COLLATION_NTOFS_ULONG, so we return false for everything else for
...@@ -34,14 +36,14 @@ static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULES cr) { ...@@ -34,14 +36,14 @@ static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULES cr) {
*/ */
if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG)) if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG))
return FALSE; return FALSE;
cr = le32_to_cpu(cr); i = le32_to_cpu(cr);
if (likely(((cr >= 0) && (cr <= 0x02)) || if (likely(((i >= 0) && (i <= 0x02)) ||
((cr >= 0x10) && (cr <= 0x13)))) ((i >= 0x10) && (i <= 0x13))))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULES cr, extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
const void *data1, const int data1_len, const void *data1, const int data1_len,
const void *data2, const int data2_len); const void *data2, const int data2_len);
......
...@@ -203,7 +203,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index, ...@@ -203,7 +203,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
* position in the compression block is one byte before its end so the * position in the compression block is one byte before its end so the
* first two checks do not detect it. * first two checks do not detect it.
*/ */
if (cb == cb_end || !le16_to_cpup((u16*)cb) || if (cb == cb_end || !le16_to_cpup((le16*)cb) ||
(*dest_index == dest_max_index && (*dest_index == dest_max_index &&
*dest_ofs == dest_max_ofs)) { *dest_ofs == dest_max_ofs)) {
int i; int i;
...@@ -255,7 +255,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index, ...@@ -255,7 +255,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
/* Setup the current sub-block source pointers and validate range. */ /* Setup the current sub-block source pointers and validate range. */
cb_sb_start = cb; cb_sb_start = cb;
cb_sb_end = cb_sb_start + (le16_to_cpup((u16*)cb) & NTFS_SB_SIZE_MASK) cb_sb_end = cb_sb_start + (le16_to_cpup((le16*)cb) & NTFS_SB_SIZE_MASK)
+ 3; + 3;
if (cb_sb_end > cb_end) if (cb_sb_end > cb_end)
goto return_overflow; goto return_overflow;
...@@ -277,7 +277,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index, ...@@ -277,7 +277,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
dp_addr = (u8*)page_address(dp) + do_sb_start; dp_addr = (u8*)page_address(dp) + do_sb_start;
/* Now, we are ready to process the current sub-block (sb). */ /* Now, we are ready to process the current sub-block (sb). */
if (!(le16_to_cpup((u16*)cb) & NTFS_SB_IS_COMPRESSED)) { if (!(le16_to_cpup((le16*)cb) & NTFS_SB_IS_COMPRESSED)) {
ntfs_debug("Found uncompressed sub-block."); ntfs_debug("Found uncompressed sub-block.");
/* This sb is not compressed, just copy it into destination. */ /* This sb is not compressed, just copy it into destination. */
...@@ -382,7 +382,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index, ...@@ -382,7 +382,7 @@ static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
lg++; lg++;
/* Get the phrase token into i. */ /* Get the phrase token into i. */
pt = le16_to_cpup((u16*)cb); pt = le16_to_cpup((le16*)cb);
/* /*
* Calculate starting position of the byte sequence in * Calculate starting position of the byte sequence in
......
...@@ -214,7 +214,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no) ...@@ -214,7 +214,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
* value with IS_ERR() and if true, the function failed and the error code is * value with IS_ERR() and if true, the function failed and the error code is
* obtained from PTR_ERR(). * obtained from PTR_ERR().
*/ */
struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPES type, struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
ntfschar *name, u32 name_len) ntfschar *name, u32 name_len)
{ {
struct inode *vi; struct inode *vi;
...@@ -2404,7 +2404,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -2404,7 +2404,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
*/ */
int ntfs_write_inode(struct inode *vi, int sync) int ntfs_write_inode(struct inode *vi, int sync)
{ {
s64 nt; sle64 nt;
ntfs_inode *ni = NTFS_I(vi); ntfs_inode *ni = NTFS_I(vi);
ntfs_attr_search_ctx *ctx; ntfs_attr_search_ctx *ctx;
MFT_RECORD *m; MFT_RECORD *m;
......
...@@ -53,7 +53,7 @@ struct _ntfs_inode { ...@@ -53,7 +53,7 @@ struct _ntfs_inode {
* name_len = 0 for files and name = I30 (global constant) and * name_len = 0 for files and name = I30 (global constant) and
* name_len = 4 for directories. * name_len = 4 for directories.
*/ */
ATTR_TYPES type; /* Attribute type of this fake inode. */ ATTR_TYPE type; /* Attribute type of this fake inode. */
ntfschar *name; /* Attribute name of this fake inode. */ ntfschar *name; /* Attribute name of this fake inode. */
u32 name_len; /* Attribute name length of this fake inode. */ u32 name_len; /* Attribute name length of this fake inode. */
runlist runlist; /* If state has the NI_NonResident bit set, runlist runlist; /* If state has the NI_NonResident bit set,
...@@ -96,7 +96,7 @@ struct _ntfs_inode { ...@@ -96,7 +96,7 @@ struct _ntfs_inode {
u32 block_size; /* Size of an index block. */ u32 block_size; /* Size of an index block. */
u32 vcn_size; /* Size of a vcn in this u32 vcn_size; /* Size of a vcn in this
index. */ index. */
COLLATION_RULES collation_rule; /* The collation rule COLLATION_RULE collation_rule; /* The collation rule
for the index. */ for the index. */
u8 block_size_bits; /* Log2 of the above. */ u8 block_size_bits; /* Log2 of the above. */
u8 vcn_size_bits; /* Log2 of the above. */ u8 vcn_size_bits; /* Log2 of the above. */
...@@ -252,7 +252,7 @@ typedef struct { ...@@ -252,7 +252,7 @@ typedef struct {
unsigned long mft_no; unsigned long mft_no;
ntfschar *name; ntfschar *name;
u32 name_len; u32 name_len;
ATTR_TYPES type; ATTR_TYPE type;
} ntfs_attr; } ntfs_attr;
typedef int (*test_t)(struct inode *, void *); typedef int (*test_t)(struct inode *, void *);
...@@ -260,7 +260,7 @@ typedef int (*test_t)(struct inode *, void *); ...@@ -260,7 +260,7 @@ typedef int (*test_t)(struct inode *, void *);
extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na); extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na);
extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no); extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no);
extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPES type, extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
ntfschar *name, u32 name_len); ntfschar *name, u32 name_len);
extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name, extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
u32 name_len); u32 name_len);
......
...@@ -112,52 +112,49 @@ typedef struct { ...@@ -112,52 +112,49 @@ typedef struct {
* Magic identifiers present at the beginning of all ntfs record containing * Magic identifiers present at the beginning of all ntfs record containing
* records (like mft records for example). * records (like mft records for example).
*/ */
typedef enum { /* Found in $MFT/$DATA. */
/* Found in $MFT/$DATA. */ #define magic_FILE const_cpu_to_le32(0x454c4946) /* Mft entry. */
magic_FILE = const_cpu_to_le32(0x454c4946), /* Mft entry. */ #define magic_INDX const_cpu_to_le32(0x58444e49) /* Index buffer. */
magic_INDX = const_cpu_to_le32(0x58444e49), /* Index buffer. */ #define magic_HOLE const_cpu_to_le32(0x454c4f48) /* ? (NTFS 3.0+?) */
magic_HOLE = const_cpu_to_le32(0x454c4f48), /* ? (NTFS 3.0+?) */
/* Found in $LogFile/$DATA. */
magic_RSTR = const_cpu_to_le32(0x52545352), /* Restart page. */
magic_RCRD = const_cpu_to_le32(0x44524352), /* Log record page. */
/* Found in $LogFile/$DATA. (May be found in $MFT/$DATA, also?) */ /* Found in $LogFile/$DATA. */
magic_CHKD = const_cpu_to_le32(0x424b4843), /* Modified by chkdsk. */ #define magic_RSTR const_cpu_to_le32(0x52545352) /* Restart page. */
#define magic_RCRD const_cpu_to_le32(0x44524352) /* Log record page. */
/* Found in all ntfs record containing records. */ /* Found in $LogFile/$DATA. (May be found in $MFT/$DATA, also?) */
magic_BAAD = const_cpu_to_le32(0x44414142), /* Failed multi sector #define magic_CHKD const_cpu_to_le32(0x424b4843) /* Modified by chkdsk. */
transfer was detected. */
/* /* Found in all ntfs record containing records. */
* Found in $LogFile/$DATA when a page is full or 0xff bytes and is #define magic_BAAD const_cpu_to_le32(0x44414142) /* Failed multi sector
* thus not initialized. User has to initialize the page before using transfer was detected. */
* it. /*
*/ * Found in $LogFile/$DATA when a page is full or 0xff bytes and is thus not
magic_empty = const_cpu_to_le32(0xffffffff),/* Record is empty and has * initialized. User has to initialize the page before using it.
to be initialized before */
it can be used. */ #define magic_empty const_cpu_to_le32(0xffffffff)/* Record is empty and has to
} NTFS_RECORD_TYPES; be initialized before it
can be used. */
typedef le32 NTFS_RECORD_TYPE;
/* /*
* Generic magic comparison macros. Finally found a use for the ## preprocessor * Generic magic comparison macros. Finally found a use for the ## preprocessor
* operator! (-8 * operator! (-8
*/ */
static inline BOOL __ntfs_is_magic(le32 x, NTFS_RECORD_TYPES r) static inline BOOL __ntfs_is_magic(le32 x, NTFS_RECORD_TYPE r)
{ {
return (x == (__force le32)r); return (x == (__force le32)r);
} }
#define ntfs_is_magic(x, m) __ntfs_is_magic(x, magic_##m) #define ntfs_is_magic(x, m) __ntfs_is_magic(x, magic_##m)
static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPES r) static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPE r)
{ {
return (*p == (__force le32)r); return (*p == (__force le32)r);
} }
#define ntfs_is_magicp(p, m) __ntfs_is_magicp(p, magic_##m) #define ntfs_is_magicp(p, m) __ntfs_is_magicp(p, magic_##m)
/* /*
* Specialised magic comparison macros for the NTFS_RECORD_TYPES defined above. * Specialised magic comparison macros for the NTFS_RECORD_TYPEs defined above.
*/ */
#define ntfs_is_file_record(x) ( ntfs_is_magic (x, FILE) ) #define ntfs_is_file_record(x) ( ntfs_is_magic (x, FILE) )
#define ntfs_is_file_recordp(p) ( ntfs_is_magicp(p, FILE) ) #define ntfs_is_file_recordp(p) ( ntfs_is_magicp(p, FILE) )
...@@ -199,8 +196,8 @@ static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPES r) ...@@ -199,8 +196,8 @@ static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPES r)
* (usa_count * 2) has to be less than or equal to 510. * (usa_count * 2) has to be less than or equal to 510.
*/ */
typedef struct { typedef struct {
NTFS_RECORD_TYPES magic; /* A four-byte magic identifying the NTFS_RECORD_TYPE magic; /* A four-byte magic identifying the record
record type and/or status. */ type and/or status. */
le16 usa_ofs; /* Offset to the Update Sequence Array (usa) le16 usa_ofs; /* Offset to the Update Sequence Array (usa)
from the start of the ntfs record. */ from the start of the ntfs record. */
le16 usa_count; /* Number of le16 sized entries in the usa le16 usa_count; /* Number of le16 sized entries in the usa
...@@ -259,11 +256,10 @@ typedef enum { ...@@ -259,11 +256,10 @@ typedef enum {
* These are the so far known MFT_RECORD_* flags (16-bit) which contain * These are the so far known MFT_RECORD_* flags (16-bit) which contain
* information about the mft record in which they are present. * information about the mft record in which they are present.
*/ */
typedef enum { #define MFT_RECORD_IN_USE const_cpu_to_le16(0x0001)
MFT_RECORD_IN_USE = const_cpu_to_le16(0x0001), #define MFT_RECORD_IS_DIRECTORY const_cpu_to_le16(0x0002)
MFT_RECORD_IS_DIRECTORY = const_cpu_to_le16(0x0002),
MFT_REC_SPACE_FILLER = 0xffff /* Just to make flags 16-bit. */ typedef le16 MFT_RECORD_FLAGS;
} __attribute__ ((__packed__)) MFT_RECORD_FLAGS;
/* /*
* mft references (aka file references or file record segment references) are * mft references (aka file references or file record segment references) are
...@@ -336,7 +332,7 @@ typedef le64 leMFT_REF; ...@@ -336,7 +332,7 @@ typedef le64 leMFT_REF;
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */ /* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
NTFS_RECORD_TYPES magic;/* Usually the magic is "FILE". */ NTFS_RECORD_TYPE magic; /* Usually the magic is "FILE". */
le16 usa_ofs; /* See NTFS_RECORD definition above. */ le16 usa_ofs; /* See NTFS_RECORD definition above. */
le16 usa_count; /* See NTFS_RECORD definition above. */ le16 usa_count; /* See NTFS_RECORD definition above. */
...@@ -403,38 +399,40 @@ typedef struct { ...@@ -403,38 +399,40 @@ typedef struct {
} __attribute__ ((__packed__)) MFT_RECORD; } __attribute__ ((__packed__)) MFT_RECORD;
/* /*
* System defined attributes (32-bit). Each attribute type has a corresponding * System defined attributes (32-bit). Each attribute type has a corresponding
* attribute name (Unicode string of maximum 64 character length) as described * attribute name (Unicode string of maximum 64 character length) as described
* by the attribute definitions present in the data attribute of the $AttrDef * by the attribute definitions present in the data attribute of the $AttrDef
* system file. On NTFS 3.0 volumes the names are just as the types are named * system file. On NTFS 3.0 volumes the names are just as the types are named
* in the below enum exchanging AT_ for the dollar sign ($). If that isn't a * in the below defines exchanging AT_ for the dollar sign ($). If that is not
* revealing choice of symbol... (-; * a revealing choice of symbol I do not know what is... (-;
*/ */
typedef enum { #define AT_UNUSED const_cpu_to_le32( 0)
AT_UNUSED = const_cpu_to_le32( 0), #define AT_STANDARD_INFORMATION const_cpu_to_le32( 0x10)
AT_STANDARD_INFORMATION = const_cpu_to_le32( 0x10), #define AT_ATTRIBUTE_LIST const_cpu_to_le32( 0x20)
AT_ATTRIBUTE_LIST = const_cpu_to_le32( 0x20), #define AT_FILE_NAME const_cpu_to_le32( 0x30)
AT_FILE_NAME = const_cpu_to_le32( 0x30), #define AT_OBJECT_ID const_cpu_to_le32( 0x40)
AT_OBJECT_ID = const_cpu_to_le32( 0x40), #define AT_SECURITY_DESCRIPTOR const_cpu_to_le32( 0x50)
AT_SECURITY_DESCRIPTOR = const_cpu_to_le32( 0x50), #define AT_VOLUME_NAME const_cpu_to_le32( 0x60)
AT_VOLUME_NAME = const_cpu_to_le32( 0x60), #define AT_VOLUME_INFORMATION const_cpu_to_le32( 0x70)
AT_VOLUME_INFORMATION = const_cpu_to_le32( 0x70), #define AT_DATA const_cpu_to_le32( 0x80)
AT_DATA = const_cpu_to_le32( 0x80), #define AT_INDEX_ROOT const_cpu_to_le32( 0x90)
AT_INDEX_ROOT = const_cpu_to_le32( 0x90), #define AT_INDEX_ALLOCATION const_cpu_to_le32( 0xa0)
AT_INDEX_ALLOCATION = const_cpu_to_le32( 0xa0), #define AT_BITMAP const_cpu_to_le32( 0xb0)
AT_BITMAP = const_cpu_to_le32( 0xb0), #define AT_REPARSE_POINT const_cpu_to_le32( 0xc0)
AT_REPARSE_POINT = const_cpu_to_le32( 0xc0), #define AT_EA_INFORMATION const_cpu_to_le32( 0xd0)
AT_EA_INFORMATION = const_cpu_to_le32( 0xd0), #define AT_EA const_cpu_to_le32( 0xe0)
AT_EA = const_cpu_to_le32( 0xe0), #define AT_PROPERTY_SET const_cpu_to_le32( 0xf0)
AT_PROPERTY_SET = const_cpu_to_le32( 0xf0), #define AT_LOGGED_UTILITY_STREAM const_cpu_to_le32( 0x100)
AT_LOGGED_UTILITY_STREAM = const_cpu_to_le32( 0x100), #define AT_FIRST_USER_DEFINED_ATTRIBUTE const_cpu_to_le32( 0x1000)
AT_FIRST_USER_DEFINED_ATTRIBUTE = const_cpu_to_le32( 0x1000), #define AT_END const_cpu_to_le32(0xffffffff)
AT_END = const_cpu_to_le32(0xffffffff),
} ATTR_TYPES; typedef le32 ATTR_TYPE;
/* /*
* The collation rules for sorting views/indexes/etc (32-bit). * The collation rules for sorting views/indexes/etc (32-bit).
* *
* COLLATION_BINARY - Collate by binary compare where the first byte is most
* significant.
* COLLATION_UNICODE_STRING - Collate Unicode strings by comparing their binary * COLLATION_UNICODE_STRING - Collate Unicode strings by comparing their binary
* Unicode values, except that when a character can be uppercased, the * Unicode values, except that when a character can be uppercased, the
* upper case value collates before the lower case one. * upper case value collates before the lower case one.
...@@ -468,40 +466,32 @@ typedef enum { ...@@ -468,40 +466,32 @@ typedef enum {
* the 2nd object_id. If the first le32 values of both object_ids were * the 2nd object_id. If the first le32 values of both object_ids were
* equal then the second le32 values would be compared, etc. * equal then the second le32 values would be compared, etc.
*/ */
typedef enum { #define COLLATION_BINARY const_cpu_to_le32(0x00)
COLLATION_BINARY = const_cpu_to_le32(0x00), /* Collate by #define COLLATION_FILE_NAME const_cpu_to_le32(0x01)
binary compare where the first byte is #define COLLATION_UNICODE_STRING const_cpu_to_le32(0x02)
most significant. */ #define COLLATION_NTOFS_ULONG const_cpu_to_le32(0x10)
COLLATION_FILE_NAME = const_cpu_to_le32(0x01), /* Collate file #define COLLATION_NTOFS_SID const_cpu_to_le32(0x11)
names as Unicode strings. */ #define COLLATION_NTOFS_SECURITY_HASH const_cpu_to_le32(0x12)
COLLATION_UNICODE_STRING = const_cpu_to_le32(0x02), /* Collate Unicode #define COLLATION_NTOFS_ULONGS const_cpu_to_le32(0x13)
strings by comparing their binary
Unicode values, except that when a typedef le32 COLLATION_RULE;
character can be uppercased, the upper
case value collates before the lower
case one. */
COLLATION_NTOFS_ULONG = const_cpu_to_le32(0x10),
COLLATION_NTOFS_SID = const_cpu_to_le32(0x11),
COLLATION_NTOFS_SECURITY_HASH = const_cpu_to_le32(0x12),
COLLATION_NTOFS_ULONGS = const_cpu_to_le32(0x13),
} COLLATION_RULES;
/* /*
* The flags (32-bit) describing attribute properties in the attribute * The flags (32-bit) describing attribute properties in the attribute
* definition structure. FIXME: This information is from Regis's information * definition structure. FIXME: This information is from Regis's information
* and, according to him, it is not certain and probably incomplete. * and, according to him, it is not certain and probably incomplete.
* The INDEXABLE flag is fairly certainly correct as only the file name * The INDEXABLE flag is fairly certainly correct as only the file name
* attribute has this flag set and this is the only attribute indexed in NT4. * attribute has this flag set and this is the only attribute indexed in NT4.
*/ */
typedef enum { #define INDEXABLE const_cpu_to_le32(0x02) /* Attribute can be
INDEXABLE = const_cpu_to_le32(0x02), /* Attribute can be indexed. */
indexed. */ #define NEED_TO_REGENERATE const_cpu_to_le32(0x40) /* Need to regenerate
NEED_TO_REGENERATE = const_cpu_to_le32(0x40), /* Need to regenerate during regeneration
during regeneration phase. */
phase. */ #define CAN_BE_NON_RESIDENT const_cpu_to_le32(0x80) /* Attribute can be
CAN_BE_NON_RESIDENT = const_cpu_to_le32(0x80), /* Attribute can be non-resident. */
non-resident. */
} ATTR_DEF_FLAGS; typedef le32 ATTR_DEF_FLAGS;
/* /*
* The data attribute of FILE_AttrDef contains a sequence of attribute * The data attribute of FILE_AttrDef contains a sequence of attribute
...@@ -516,10 +506,10 @@ typedef struct { ...@@ -516,10 +506,10 @@ typedef struct {
/*hex ofs*/ /*hex ofs*/
/* 0*/ ntfschar name[0x40]; /* Unicode name of the attribute. Zero /* 0*/ ntfschar name[0x40]; /* Unicode name of the attribute. Zero
terminated. */ terminated. */
/* 80*/ ATTR_TYPES type; /* Type of the attribute. */ /* 80*/ ATTR_TYPE type; /* Type of the attribute. */
/* 84*/ le32 display_rule; /* Default display rule. /* 84*/ le32 display_rule; /* Default display rule.
FIXME: What does it mean? (AIA) */ FIXME: What does it mean? (AIA) */
/* 88*/ COLLATION_RULES collation_rule; /* Default collation rule. */ /* 88*/ COLLATION_RULE collation_rule; /* Default collation rule. */
/* 8c*/ ATTR_DEF_FLAGS flags; /* Flags describing the attribute. */ /* 8c*/ ATTR_DEF_FLAGS flags; /* Flags describing the attribute. */
/* 90*/ le64 min_size; /* Optional minimum attribute size. */ /* 90*/ le64 min_size; /* Optional minimum attribute size. */
/* 98*/ le64 max_size; /* Maximum size of attribute. */ /* 98*/ le64 max_size; /* Maximum size of attribute. */
...@@ -529,14 +519,14 @@ typedef struct { ...@@ -529,14 +519,14 @@ typedef struct {
/* /*
* Attribute flags (16-bit). * Attribute flags (16-bit).
*/ */
typedef enum { #define ATTR_IS_COMPRESSED const_cpu_to_le16(0x0001)
ATTR_IS_COMPRESSED = const_cpu_to_le16(0x0001), #define ATTR_COMPRESSION_MASK const_cpu_to_le16(0x00ff) /* Compression method
ATTR_COMPRESSION_MASK = const_cpu_to_le16(0x00ff), /* Compression mask. Also, first
method mask. Also, first illegal value. */
illegal value. */ #define ATTR_IS_ENCRYPTED const_cpu_to_le16(0x4000)
ATTR_IS_ENCRYPTED = const_cpu_to_le16(0x4000), #define ATTR_IS_SPARSE const_cpu_to_le16(0x8000)
ATTR_IS_SPARSE = const_cpu_to_le16(0x8000),
} __attribute__ ((__packed__)) ATTR_FLAGS; typedef le16 ATTR_FLAGS;
/* /*
* Attribute compression. * Attribute compression.
...@@ -608,18 +598,18 @@ typedef enum { ...@@ -608,18 +598,18 @@ typedef enum {
/* /*
* Flags of resident attributes (8-bit). * Flags of resident attributes (8-bit).
*/ */
typedef enum { #define RESIDENT_ATTR_IS_INDEXED 0x01 /* Attribute is referenced in an index
RESIDENT_ATTR_IS_INDEXED = 0x01, /* Attribute is referenced in an index (has implications for deleting and
(has implications for deleting and modifying the attribute). */
modifying the attribute). */
} __attribute__ ((__packed__)) RESIDENT_ATTR_FLAGS; typedef u8 RESIDENT_ATTR_FLAGS;
/* /*
* Attribute record header. Always aligned to 8-byte boundary. * Attribute record header. Always aligned to 8-byte boundary.
*/ */
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0*/ ATTR_TYPES type; /* The (32-bit) type of the attribute. */ /* 0*/ ATTR_TYPE type; /* The (32-bit) type of the attribute. */
/* 4*/ le32 length; /* Byte size of the resident part of the /* 4*/ le32 length; /* Byte size of the resident part of the
attribute (aligned to 8-byte boundary). attribute (aligned to 8-byte boundary).
Used to get to the next attribute. */ Used to get to the next attribute. */
...@@ -713,57 +703,56 @@ typedef ATTR_RECORD ATTR_REC; ...@@ -713,57 +703,56 @@ typedef ATTR_RECORD ATTR_REC;
/* /*
* File attribute flags (32-bit). * File attribute flags (32-bit).
*/ *
typedef enum { * The following flags are only present in the STANDARD_INFORMATION attribute
/* * (in the field file_attributes).
* These flags are only present in the STANDARD_INFORMATION attribute */
* (in the field file_attributes). #define FILE_ATTR_READONLY const_cpu_to_le32(0x00000001)
*/ #define FILE_ATTR_HIDDEN const_cpu_to_le32(0x00000002)
FILE_ATTR_READONLY = const_cpu_to_le32(0x00000001), #define FILE_ATTR_SYSTEM const_cpu_to_le32(0x00000004)
FILE_ATTR_HIDDEN = const_cpu_to_le32(0x00000002), /* Old DOS volid. Unused in NT. = cpu_to_le32(0x00000008), */
FILE_ATTR_SYSTEM = const_cpu_to_le32(0x00000004),
/* Old DOS volid. Unused in NT. = cpu_to_le32(0x00000008), */ #define FILE_ATTR_DIRECTORY const_cpu_to_le32(0x00000010)
/* FILE_ATTR_DIRECTORY is not considered valid in NT. It is reserved for the
FILE_ATTR_DIRECTORY = const_cpu_to_le32(0x00000010), DOS SUBDIRECTORY flag. */
/* FILE_ATTR_DIRECTORY is not considered valid in NT. It is reserved #define FILE_ATTR_ARCHIVE const_cpu_to_le32(0x00000020)
for the DOS SUBDIRECTORY flag. */ #define FILE_ATTR_DEVICE const_cpu_to_le32(0x00000040)
FILE_ATTR_ARCHIVE = const_cpu_to_le32(0x00000020), #define FILE_ATTR_NORMAL const_cpu_to_le32(0x00000080)
FILE_ATTR_DEVICE = const_cpu_to_le32(0x00000040),
FILE_ATTR_NORMAL = const_cpu_to_le32(0x00000080), #define FILE_ATTR_TEMPORARY const_cpu_to_le32(0x00000100)
#define FILE_ATTR_SPARSE_FILE const_cpu_to_le32(0x00000200)
FILE_ATTR_TEMPORARY = const_cpu_to_le32(0x00000100), #define FILE_ATTR_REPARSE_POINT const_cpu_to_le32(0x00000400)
FILE_ATTR_SPARSE_FILE = const_cpu_to_le32(0x00000200), #define FILE_ATTR_COMPRESSED const_cpu_to_le32(0x00000800)
FILE_ATTR_REPARSE_POINT = const_cpu_to_le32(0x00000400),
FILE_ATTR_COMPRESSED = const_cpu_to_le32(0x00000800), #define FILE_ATTR_OFFLINE const_cpu_to_le32(0x00001000)
#define FILE_ATTR_NOT_CONTENT_INDEXED const_cpu_to_le32(0x00002000)
FILE_ATTR_OFFLINE = const_cpu_to_le32(0x00001000), #define FILE_ATTR_ENCRYPTED const_cpu_to_le32(0x00004000)
FILE_ATTR_NOT_CONTENT_INDEXED = const_cpu_to_le32(0x00002000),
FILE_ATTR_ENCRYPTED = const_cpu_to_le32(0x00004000), #define FILE_ATTR_VALID_FLAGS const_cpu_to_le32(0x00007fb7)
/* FILE_ATTR_VALID_FLAGS masks out the old DOS VolId and the FILE_ATTR_DEVICE
FILE_ATTR_VALID_FLAGS = const_cpu_to_le32(0x00007fb7), and preserves everything else. This mask is used to obtain all flags that
/* FILE_ATTR_VALID_FLAGS masks out the old DOS VolId and the are valid for reading. */
FILE_ATTR_DEVICE and preserves everything else. This mask #define FILE_ATTR_VALID_SET_FLAGS const_cpu_to_le32(0x000031a7)
is used to obtain all flags that are valid for reading. */ /* FILE_ATTR_VALID_SET_FLAGS masks out the old DOS VolId, the F_A_DEVICE,
FILE_ATTR_VALID_SET_FLAGS = const_cpu_to_le32(0x000031a7), F_A_DIRECTORY, F_A_SPARSE_FILE, F_A_REPARSE_POINT, F_A_COMPRESSED, and
/* FILE_ATTR_VALID_SET_FLAGS masks out the old DOS VolId, the F_A_ENCRYPTED and preserves the rest. This mask is used to to obtain all
F_A_DEVICE, F_A_DIRECTORY, F_A_SPARSE_FILE, F_A_REPARSE_POINT, flags that are valid for setting. */
F_A_COMPRESSED and F_A_ENCRYPTED and preserves the rest. This mask
is used to to obtain all flags that are valid for setting. */ /*
* The following flags are only present in the FILE_NAME attribute (in the
/* * field file_attributes).
* These flags are only present in the FILE_NAME attribute (in the */
* field file_attributes). #define FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT const_cpu_to_le32(0x10000000)
*/ /* This is a copy of the corresponding bit from the mft record, telling us
FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT = const_cpu_to_le32(0x10000000), whether this is a directory or not, i.e. whether it has an index root
/* This is a copy of the corresponding bit from the mft record, telling attribute or not. */
us whether this is a directory or not, i.e. whether it has an #define FILE_ATTR_DUP_VIEW_INDEX_PRESENT const_cpu_to_le32(0x20000000)
index root attribute or not. */ /* This is a copy of the corresponding bit from the mft record, telling us
FILE_ATTR_DUP_VIEW_INDEX_PRESENT = const_cpu_to_le32(0x20000000), whether this file has a view index present (eg. object id index, quota
/* This is a copy of the corresponding bit from the mft record, telling index, one of the security indexes or the encrypting file system related
us whether this file has a view index present (eg. object id index, indexes). */
quota index, one of the security indexes or the encrypting file
system related indexes). */ typedef le32 FILE_ATTR_FLAGS;
} FILE_ATTR_FLAGS;
/* /*
* NOTE on times in NTFS: All times are in MS standard time format, i.e. they * NOTE on times in NTFS: All times are in MS standard time format, i.e. they
...@@ -896,7 +885,7 @@ typedef struct { ...@@ -896,7 +885,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0*/ ATTR_TYPES type; /* Type of referenced attribute. */ /* 0*/ ATTR_TYPE type; /* Type of referenced attribute. */
/* 4*/ le16 length; /* Byte size of this entry (8-byte aligned). */ /* 4*/ le16 length; /* Byte size of this entry (8-byte aligned). */
/* 6*/ u8 name_length; /* Size in Unicode chars of the name of the /* 6*/ u8 name_length; /* Size in Unicode chars of the name of the
attribute or 0 if unnamed. */ attribute or 0 if unnamed. */
...@@ -934,28 +923,26 @@ typedef struct { ...@@ -934,28 +923,26 @@ typedef struct {
/* /*
* Possible namespaces for filenames in ntfs (8-bit). * Possible namespaces for filenames in ntfs (8-bit).
*/ */
typedef enum { #define FILE_NAME_POSIX 0x00
FILE_NAME_POSIX = 0x00, /* This is the largest namespace. It is case sensitive and allows all
/* This is the largest namespace. It is case sensitive and Unicode characters except for: '\0' and '/'. Beware that in
allows all Unicode characters except for: '\0' and '/'. WinNT/2k files which eg have the same name except for their case
Beware that in WinNT/2k files which eg have the same name will not be distinguished by the standard utilities and thus a "del
except for their case will not be distinguished by the filename" will delete both "filename" and "fileName" without
standard utilities and thus a "del filename" will delete warning. */
both "filename" and "fileName" without warning. */ #define FILE_NAME_WIN32 0x01
FILE_NAME_WIN32 = 0x01, /* The standard WinNT/2k NTFS long filenames. Case insensitive. All
/* The standard WinNT/2k NTFS long filenames. Case insensitive. Unicode chars except: '\0', '"', '*', '/', ':', '<', '>', '?', '\',
All Unicode chars except: '\0', '"', '*', '/', ':', '<', and '|'. Further, names cannot end with a '.' or a space. */
'>', '?', '\' and '|'. Further, names cannot end with a '.' #define FILE_NAME_DOS 0x02
or a space. */ /* The standard DOS filenames (8.3 format). Uppercase only. All 8-bit
FILE_NAME_DOS = 0x02, characters greater space, except: '"', '*', '+', ',', '/', ':', ';',
/* The standard DOS filenames (8.3 format). Uppercase only. '<', '=', '>', '?', and '\'. */
All 8-bit characters greater space, except: '"', '*', '+', #define FILE_NAME_WIN32_AND_DOS 0x03
',', '/', ':', ';', '<', '=', '>', '?' and '\'. */ /* 3 means that both the Win32 and the DOS filenames are identical and
FILE_NAME_WIN32_AND_DOS = 0x03, hence have been saved in this single filename record. */
/* 3 means that both the Win32 and the DOS filenames are
identical and hence have been saved in this single filename typedef u8 FILE_NAME_TYPE_FLAGS;
record. */
} __attribute__ ((__packed__)) FILE_NAME_TYPE_FLAGS;
/* /*
* Attribute: Filename (0x30). * Attribute: Filename (0x30).
...@@ -1261,30 +1248,31 @@ typedef enum { ...@@ -1261,30 +1248,31 @@ typedef enum {
/* /*
* The predefined ACE types (8-bit, see below). * The predefined ACE types (8-bit, see below).
*/ */
typedef enum { #define ACCESS_MIN_MS_ACE_TYPE 0
ACCESS_MIN_MS_ACE_TYPE = 0, #define ACCESS_ALLOWED_ACE_TYPE 0
ACCESS_ALLOWED_ACE_TYPE = 0, #define ACCESS_DENIED_ACE_TYPE 1
ACCESS_DENIED_ACE_TYPE = 1, #define SYSTEM_AUDIT_ACE_TYPE 2
SYSTEM_AUDIT_ACE_TYPE = 2, #define SYSTEM_ALARM_ACE_TYPE 3 /* Not implemented as of
SYSTEM_ALARM_ACE_TYPE = 3, /* Not implemented as of Win2k. */ Win2k. */
ACCESS_MAX_MS_V2_ACE_TYPE = 3, #define ACCESS_MAX_MS_V2_ACE_TYPE 3
ACCESS_ALLOWED_COMPOUND_ACE_TYPE= 4, #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 4
ACCESS_MAX_MS_V3_ACE_TYPE = 4, #define ACCESS_MAX_MS_V3_ACE_TYPE 4
/* The following are Win2k only. */ /* The following are Win2k only. */
ACCESS_MIN_MS_OBJECT_ACE_TYPE = 5, #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 5
ACCESS_ALLOWED_OBJECT_ACE_TYPE = 5, #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 5
ACCESS_DENIED_OBJECT_ACE_TYPE = 6, #define ACCESS_DENIED_OBJECT_ACE_TYPE 6
SYSTEM_AUDIT_OBJECT_ACE_TYPE = 7, #define SYSTEM_AUDIT_OBJECT_ACE_TYPE 7
SYSTEM_ALARM_OBJECT_ACE_TYPE = 8, #define SYSTEM_ALARM_OBJECT_ACE_TYPE 8
ACCESS_MAX_MS_OBJECT_ACE_TYPE = 8, #define ACCESS_MAX_MS_OBJECT_ACE_TYPE 8
ACCESS_MAX_MS_V4_ACE_TYPE = 8, #define ACCESS_MAX_MS_V4_ACE_TYPE 8
/* This one is for WinNT&2k. */ /* This one is for WinNT/2k. */
ACCESS_MAX_MS_ACE_TYPE = 8, #define ACCESS_MAX_MS_ACE_TYPE 8
} __attribute__ ((__packed__)) ACE_TYPES;
typedef u8 ACE_TYPES;
/* /*
* The ACE flags (8-bit) for audit and inheritance (see below). * The ACE flags (8-bit) for audit and inheritance (see below).
...@@ -1296,19 +1284,19 @@ typedef enum { ...@@ -1296,19 +1284,19 @@ typedef enum {
* FAILED_ACCESS_ACE_FLAG is only used with system audit and alarm ACE types * FAILED_ACCESS_ACE_FLAG is only used with system audit and alarm ACE types
* to indicate that a message is generated (in Windows!) for failed accesses. * to indicate that a message is generated (in Windows!) for failed accesses.
*/ */
typedef enum { /* The inheritance flags. */
/* The inheritance flags. */ #define OBJECT_INHERIT_ACE 0x01
OBJECT_INHERIT_ACE = 0x01, #define CONTAINER_INHERIT_ACE 0x02
CONTAINER_INHERIT_ACE = 0x02, #define NO_PROPAGATE_INHERIT_ACE 0x04
NO_PROPAGATE_INHERIT_ACE = 0x04, #define INHERIT_ONLY_ACE 0x08
INHERIT_ONLY_ACE = 0x08, #define INHERITED_ACE 0x10 /* Win2k only. */
INHERITED_ACE = 0x10, /* Win2k only. */ #define VALID_INHERIT_FLAGS 0x1f
VALID_INHERIT_FLAGS = 0x1f,
/* The audit flags. */ /* The audit flags. */
SUCCESSFUL_ACCESS_ACE_FLAG = 0x40, #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
FAILED_ACCESS_ACE_FLAG = 0x80, #define FAILED_ACCESS_ACE_FLAG 0x80
} __attribute__ ((__packed__)) ACE_FLAGS;
typedef u8 ACE_FLAGS;
/* /*
* An ACE is an access-control entry in an access-control list (ACL). * An ACE is an access-control entry in an access-control list (ACL).
...@@ -1330,136 +1318,135 @@ typedef struct { ...@@ -1330,136 +1318,135 @@ typedef struct {
/* /*
* The access mask (32-bit). Defines the access rights. * The access mask (32-bit). Defines the access rights.
*
* The specific rights (bits 0 to 15). These depend on the type of the object
* being secured by the ACE.
*/ */
typedef enum {
/*
* The specific rights (bits 0 to 15). Depend on the type of the
* object being secured by the ACE.
*/
/* Specific rights for files and directories are as follows: */ /* Specific rights for files and directories are as follows: */
/* Right to read data from the file. (FILE) */ /* Right to read data from the file. (FILE) */
FILE_READ_DATA = const_cpu_to_le32(0x00000001), #define FILE_READ_DATA const_cpu_to_le32(0x00000001)
/* Right to list contents of a directory. (DIRECTORY) */ /* Right to list contents of a directory. (DIRECTORY) */
FILE_LIST_DIRECTORY = const_cpu_to_le32(0x00000001), #define FILE_LIST_DIRECTORY const_cpu_to_le32(0x00000001)
/* Right to write data to the file. (FILE) */ /* Right to write data to the file. (FILE) */
FILE_WRITE_DATA = const_cpu_to_le32(0x00000002), #define FILE_WRITE_DATA const_cpu_to_le32(0x00000002)
/* Right to create a file in the directory. (DIRECTORY) */ /* Right to create a file in the directory. (DIRECTORY) */
FILE_ADD_FILE = const_cpu_to_le32(0x00000002), #define FILE_ADD_FILE const_cpu_to_le32(0x00000002)
/* Right to append data to the file. (FILE) */ /* Right to append data to the file. (FILE) */
FILE_APPEND_DATA = const_cpu_to_le32(0x00000004), #define FILE_APPEND_DATA const_cpu_to_le32(0x00000004)
/* Right to create a subdirectory. (DIRECTORY) */ /* Right to create a subdirectory. (DIRECTORY) */
FILE_ADD_SUBDIRECTORY = const_cpu_to_le32(0x00000004), #define FILE_ADD_SUBDIRECTORY const_cpu_to_le32(0x00000004)
/* Right to read extended attributes. (FILE/DIRECTORY) */ /* Right to read extended attributes. (FILE/DIRECTORY) */
FILE_READ_EA = const_cpu_to_le32(0x00000008), #define FILE_READ_EA const_cpu_to_le32(0x00000008)
/* Right to write extended attributes. (FILE/DIRECTORY) */ /* Right to write extended attributes. (FILE/DIRECTORY) */
FILE_WRITE_EA = const_cpu_to_le32(0x00000010), #define FILE_WRITE_EA const_cpu_to_le32(0x00000010)
/* Right to execute a file. (FILE) */ /* Right to execute a file. (FILE) */
FILE_EXECUTE = const_cpu_to_le32(0x00000020), #define FILE_EXECUTE const_cpu_to_le32(0x00000020)
/* Right to traverse the directory. (DIRECTORY) */ /* Right to traverse the directory. (DIRECTORY) */
FILE_TRAVERSE = const_cpu_to_le32(0x00000020), #define FILE_TRAVERSE const_cpu_to_le32(0x00000020)
/* /*
* Right to delete a directory and all the files it contains (its * Right to delete a directory and all the files it contains (its children),
* children), even if the files are read-only. (DIRECTORY) * even if the files are read-only. (DIRECTORY)
*/ */
FILE_DELETE_CHILD = const_cpu_to_le32(0x00000040), #define FILE_DELETE_CHILD const_cpu_to_le32(0x00000040)
/* Right to read file attributes. (FILE/DIRECTORY) */ /* Right to read file attributes. (FILE/DIRECTORY) */
FILE_READ_ATTRIBUTES = const_cpu_to_le32(0x00000080), #define FILE_READ_ATTRIBUTES const_cpu_to_le32(0x00000080)
/* Right to change file attributes. (FILE/DIRECTORY) */ /* Right to change file attributes. (FILE/DIRECTORY) */
FILE_WRITE_ATTRIBUTES = const_cpu_to_le32(0x00000100), #define FILE_WRITE_ATTRIBUTES const_cpu_to_le32(0x00000100)
/* /*
* The standard rights (bits 16 to 23). Are independent of the type of * The standard rights (bits 16 to 23). These are independent of the type of
* object being secured. * object being secured.
*/ */
/* Right to delete the object. */ /* Right to delete the object. */
DELETE = const_cpu_to_le32(0x00010000), #define DELETE const_cpu_to_le32(0x00010000)
/* /*
* Right to read the information in the object's security descriptor, * Right to read the information in the object's security descriptor, not
* not including the information in the SACL. I.e. right to read the * including the information in the SACL. I.e. right to read the security
* security descriptor and owner. * descriptor and owner.
*/ */
READ_CONTROL = const_cpu_to_le32(0x00020000), #define READ_CONTROL const_cpu_to_le32(0x00020000)
/* Right to modify the DACL in the object's security descriptor. */ /* Right to modify the DACL in the object's security descriptor. */
WRITE_DAC = const_cpu_to_le32(0x00040000), #define WRITE_DAC const_cpu_to_le32(0x00040000)
/* Right to change the owner in the object's security descriptor. */ /* Right to change the owner in the object's security descriptor. */
WRITE_OWNER = const_cpu_to_le32(0x00080000), #define WRITE_OWNER const_cpu_to_le32(0x00080000)
/* /*
* Right to use the object for synchronization. Enables a process to * Right to use the object for synchronization. Enables a process to wait until
* wait until the object is in the signalled state. Some object types * the object is in the signalled state. Some object types do not support this
* do not support this access right. * access right.
*/ */
SYNCHRONIZE = const_cpu_to_le32(0x00100000), #define SYNCHRONIZE const_cpu_to_le32(0x00100000)
/* /*
* The following STANDARD_RIGHTS_* are combinations of the above for * The following STANDARD_RIGHTS_* are combinations of the above for
* convenience and are defined by the Win32 API. * convenience and are defined by the Win32 API.
*/ */
/* These are currently defined to READ_CONTROL. */ /* These are currently defined to READ_CONTROL. */
STANDARD_RIGHTS_READ = const_cpu_to_le32(0x00020000), #define STANDARD_RIGHTS_READ const_cpu_to_le32(0x00020000)
STANDARD_RIGHTS_WRITE = const_cpu_to_le32(0x00020000), #define STANDARD_RIGHTS_WRITE const_cpu_to_le32(0x00020000)
STANDARD_RIGHTS_EXECUTE = const_cpu_to_le32(0x00020000), #define STANDARD_RIGHTS_EXECUTE const_cpu_to_le32(0x00020000)
/* Combines DELETE, READ_CONTROL, WRITE_DAC, and WRITE_OWNER access. */ /* Combines DELETE, READ_CONTROL, WRITE_DAC, and WRITE_OWNER access. */
STANDARD_RIGHTS_REQUIRED = const_cpu_to_le32(0x000f0000), #define STANDARD_RIGHTS_REQUIRED const_cpu_to_le32(0x000f0000)
/* /*
* Combines DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, and * Combines DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, and
* SYNCHRONIZE access. * SYNCHRONIZE access.
*/ */
STANDARD_RIGHTS_ALL = const_cpu_to_le32(0x001f0000), #define STANDARD_RIGHTS_ALL const_cpu_to_le32(0x001f0000)
/* /*
* The access system ACL and maximum allowed access types (bits 24 to * The access system ACL and maximum allowed access types (bits 24 to
* 25, bits 26 to 27 are reserved). * 25, bits 26 to 27 are reserved).
*/ */
ACCESS_SYSTEM_SECURITY = const_cpu_to_le32(0x01000000), #define ACCESS_SYSTEM_SECURITY const_cpu_to_le32(0x01000000)
MAXIMUM_ALLOWED = const_cpu_to_le32(0x02000000), #define MAXIMUM_ALLOWED const_cpu_to_le32(0x02000000)
/* /*
* The generic rights (bits 28 to 31). These map onto the standard and * The generic rights (bits 28 to 31). These map onto the standard and specific
* specific rights. * rights.
*/ */
/* Read, write, and execute access. */ /* Read, write, and execute access. */
GENERIC_ALL = const_cpu_to_le32(0x10000000), #define GENERIC_ALL const_cpu_to_le32(0x10000000)
/* Execute access. */ /* Execute access. */
GENERIC_EXECUTE = const_cpu_to_le32(0x20000000), #define GENERIC_EXECUTE const_cpu_to_le32(0x20000000)
/* /*
* Write access. For files, this maps onto: * Write access. For files, this maps onto:
* FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA | * FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA |
* FILE_WRITE_EA | STANDARD_RIGHTS_WRITE | SYNCHRONIZE * FILE_WRITE_EA | STANDARD_RIGHTS_WRITE | SYNCHRONIZE
* For directories, the mapping has the same numberical value. See * For directories, the mapping has the same numberical value. See above for
* above for the descriptions of the rights granted. * the descriptions of the rights granted.
*/ */
GENERIC_WRITE = const_cpu_to_le32(0x40000000), #define GENERIC_WRITE const_cpu_to_le32(0x40000000)
/* /*
* Read access. For files, this maps onto: * Read access. For files, this maps onto:
* FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA | * FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA |
* STANDARD_RIGHTS_READ | SYNCHRONIZE * STANDARD_RIGHTS_READ | SYNCHRONIZE
* For directories, the mapping has the same numberical value. See * For directories, the mapping has the same numberical value. See above for
* above for the descriptions of the rights granted. * the descriptions of the rights granted.
*/ */
GENERIC_READ = const_cpu_to_le32(0x80000000), #define GENERIC_READ const_cpu_to_le32(0x80000000)
} ACCESS_MASK;
typedef le32 ACCESS_MASK;
/* /*
* The generic mapping array. Used to denote the mapping of each generic * The generic mapping array. Used to denote the mapping of each generic
...@@ -1495,10 +1482,10 @@ typedef struct { ...@@ -1495,10 +1482,10 @@ typedef struct {
/* /*
* The object ACE flags (32-bit). * The object ACE flags (32-bit).
*/ */
typedef enum { #define ACE_OBJECT_TYPE_PRESENT const_cpu_to_le32(1)
ACE_OBJECT_TYPE_PRESENT = const_cpu_to_le32(1), #define ACE_INHERITED_OBJECT_TYPE_PRESENT const_cpu_to_le32(2)
ACE_INHERITED_OBJECT_TYPE_PRESENT = const_cpu_to_le32(2),
} OBJECT_ACE_FLAGS; typedef le32 OBJECT_ACE_FLAGS;
typedef struct { typedef struct {
/* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */ /* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */
...@@ -1595,22 +1582,22 @@ typedef enum { ...@@ -1595,22 +1582,22 @@ typedef enum {
* security descriptor are contiguous in memory and all pointer fields are * security descriptor are contiguous in memory and all pointer fields are
* expressed as offsets from the beginning of the security descriptor. * expressed as offsets from the beginning of the security descriptor.
*/ */
typedef enum { #define SE_OWNER_DEFAULTED const_cpu_to_le16(0x0001)
SE_OWNER_DEFAULTED = const_cpu_to_le16(0x0001), #define SE_GROUP_DEFAULTED const_cpu_to_le16(0x0002)
SE_GROUP_DEFAULTED = const_cpu_to_le16(0x0002), #define SE_DACL_PRESENT const_cpu_to_le16(0x0004)
SE_DACL_PRESENT = const_cpu_to_le16(0x0004), #define SE_DACL_DEFAULTED const_cpu_to_le16(0x0008)
SE_DACL_DEFAULTED = const_cpu_to_le16(0x0008), #define SE_SACL_PRESENT const_cpu_to_le16(0x0010)
SE_SACL_PRESENT = const_cpu_to_le16(0x0010), #define SE_SACL_DEFAULTED const_cpu_to_le16(0x0020)
SE_SACL_DEFAULTED = const_cpu_to_le16(0x0020), #define SE_DACL_AUTO_INHERIT_REQ const_cpu_to_le16(0x0100)
SE_DACL_AUTO_INHERIT_REQ = const_cpu_to_le16(0x0100), #define SE_SACL_AUTO_INHERIT_REQ const_cpu_to_le16(0x0200)
SE_SACL_AUTO_INHERIT_REQ = const_cpu_to_le16(0x0200), #define SE_DACL_AUTO_INHERITED const_cpu_to_le16(0x0400)
SE_DACL_AUTO_INHERITED = const_cpu_to_le16(0x0400), #define SE_SACL_AUTO_INHERITED const_cpu_to_le16(0x0800)
SE_SACL_AUTO_INHERITED = const_cpu_to_le16(0x0800), #define SE_DACL_PROTECTED const_cpu_to_le16(0x1000)
SE_DACL_PROTECTED = const_cpu_to_le16(0x1000), #define SE_SACL_PROTECTED const_cpu_to_le16(0x2000)
SE_SACL_PROTECTED = const_cpu_to_le16(0x2000), #define SE_RM_CONTROL_VALID const_cpu_to_le16(0x4000)
SE_RM_CONTROL_VALID = const_cpu_to_le16(0x4000), #define SE_SELF_RELATIVE const_cpu_to_le16(0x8000)
SE_SELF_RELATIVE = const_cpu_to_le16(0x8000),
} __attribute__ ((__packed__)) SECURITY_DESCRIPTOR_CONTROL; typedef le16 SECURITY_DESCRIPTOR_CONTROL;
/* /*
* Self-relative security descriptor. Contains the owner and group SIDs as well * Self-relative security descriptor. Contains the owner and group SIDs as well
...@@ -1794,19 +1781,19 @@ typedef struct { ...@@ -1794,19 +1781,19 @@ typedef struct {
/* /*
* Possible flags for the volume (16-bit). * Possible flags for the volume (16-bit).
*/ */
typedef enum { #define VOLUME_IS_DIRTY const_cpu_to_le16(0x0001)
VOLUME_IS_DIRTY = const_cpu_to_le16(0x0001), #define VOLUME_RESIZE_LOG_FILE const_cpu_to_le16(0x0002)
VOLUME_RESIZE_LOG_FILE = const_cpu_to_le16(0x0002), #define VOLUME_UPGRADE_ON_MOUNT const_cpu_to_le16(0x0004)
VOLUME_UPGRADE_ON_MOUNT = const_cpu_to_le16(0x0004), #define VOLUME_MOUNTED_ON_NT4 const_cpu_to_le16(0x0008)
VOLUME_MOUNTED_ON_NT4 = const_cpu_to_le16(0x0008), #define VOLUME_DELETE_USN_UNDERWAY const_cpu_to_le16(0x0010)
VOLUME_DELETE_USN_UNDERWAY = const_cpu_to_le16(0x0010), #define VOLUME_REPAIR_OBJECT_ID const_cpu_to_le16(0x0020)
VOLUME_REPAIR_OBJECT_ID = const_cpu_to_le16(0x0020), #define VOLUME_MODIFIED_BY_CHKDSK const_cpu_to_le16(0x8000)
VOLUME_MODIFIED_BY_CHKDSK = const_cpu_to_le16(0x8000), #define VOLUME_FLAGS_MASK const_cpu_to_le16(0x803f)
VOLUME_FLAGS_MASK = const_cpu_to_le16(0x803f),
/* To make our life easier when checking if we must mount read-only. */
#define VOLUME_MUST_MOUNT_RO_MASK const_cpu_to_le16(0x8037)
/* To make our life easier when checking if we must mount read-only. */ typedef le16 VOLUME_FLAGS;
VOLUME_MUST_MOUNT_RO_MASK = const_cpu_to_le16(0x8037),
} __attribute__ ((__packed__)) VOLUME_FLAGS;
/* /*
* Attribute: Volume information (0x70). * Attribute: Volume information (0x70).
...@@ -1836,25 +1823,26 @@ typedef struct { ...@@ -1836,25 +1823,26 @@ typedef struct {
/* /*
* Index header flags (8-bit). * Index header flags (8-bit).
*
* When index header is in an index root attribute:
*/ */
typedef enum { #define SMALL_INDEX 0 /* The index is small enough to fit inside the index root
/* When index header is in an index root attribute: */ attribute and there is no index allocation attribute
SMALL_INDEX = 0, /* The index is small enough to fit inside the present. */
index root attribute and there is no index #define LARGE_INDEX 1 /* The index is too large to fit in the index root
allocation attribute present. */ attribute and/or an index allocation attribute is
LARGE_INDEX = 1, /* The index is too large to fit in the index present. */
root attribute and/or an index allocation /*
attribute is present. */ * When index header is in an index block, i.e. is part of index allocation
/* * attribute:
* When index header is in an index block, i.e. is part of index */
* allocation attribute: #define LEAF_NODE 0 /* This is a leaf node, i.e. there are no more nodes
*/ branching off it. */
LEAF_NODE = 0, /* This is a leaf node, i.e. there are no more #define INDEX_NODE 1 /* This node indexes other nodes, i.e. it is not a leaf
nodes branching off it. */ node. */
INDEX_NODE = 1, /* This node indexes other nodes, i.e. is not a #define NODE_MASK 1 /* Mask for accessing the *_NODE bits. */
leaf node. */
NODE_MASK = 1, /* Mask for accessing the *_NODE bits. */ typedef u8 INDEX_HEADER_FLAGS;
} __attribute__ ((__packed__)) INDEX_HEADER_FLAGS;
/* /*
* This is the header for indexes, describing the INDEX_ENTRY records, which * This is the header for indexes, describing the INDEX_ENTRY records, which
...@@ -1904,11 +1892,11 @@ typedef struct { ...@@ -1904,11 +1892,11 @@ typedef struct {
* dircetories do not contain entries for themselves, though. * dircetories do not contain entries for themselves, though.
*/ */
typedef struct { typedef struct {
ATTR_TYPES type; /* Type of the indexed attribute. Is ATTR_TYPE type; /* Type of the indexed attribute. Is
$FILE_NAME for directories, zero $FILE_NAME for directories, zero
for view indexes. No other values for view indexes. No other values
allowed. */ allowed. */
COLLATION_RULES collation_rule; /* Collation rule used to sort the COLLATION_RULE collation_rule; /* Collation rule used to sort the
index entries. If type is $FILE_NAME, index entries. If type is $FILE_NAME,
this must be COLLATION_FILE_NAME. */ this must be COLLATION_FILE_NAME. */
le32 index_block_size; /* Size of each index block in bytes (in le32 index_block_size; /* Size of each index block in bytes (in
...@@ -1937,7 +1925,7 @@ typedef struct { ...@@ -1937,7 +1925,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */ /* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
NTFS_RECORD_TYPES magic;/* Magic is "INDX". */ NTFS_RECORD_TYPE magic; /* Magic is "INDX". */
le16 usa_ofs; /* See NTFS_RECORD definition. */ le16 usa_ofs; /* See NTFS_RECORD definition. */
le16 usa_count; /* See NTFS_RECORD definition. */ le16 usa_count; /* See NTFS_RECORD definition. */
...@@ -1980,27 +1968,28 @@ typedef struct { ...@@ -1980,27 +1968,28 @@ typedef struct {
/* /*
* Quota flags (32-bit). * Quota flags (32-bit).
*
* The user quota flags. Names explain meaning.
*/ */
typedef enum { #define QUOTA_FLAG_DEFAULT_LIMITS const_cpu_to_le32(0x00000001)
/* The user quota flags. Names explain meaning. */ #define QUOTA_FLAG_LIMIT_REACHED const_cpu_to_le32(0x00000002)
QUOTA_FLAG_DEFAULT_LIMITS = const_cpu_to_le32(0x00000001), #define QUOTA_FLAG_ID_DELETED const_cpu_to_le32(0x00000004)
QUOTA_FLAG_LIMIT_REACHED = const_cpu_to_le32(0x00000002),
QUOTA_FLAG_ID_DELETED = const_cpu_to_le32(0x00000004), #define QUOTA_FLAG_USER_MASK const_cpu_to_le32(0x00000007)
/* Bit mask for user quota flags. */
QUOTA_FLAG_USER_MASK = const_cpu_to_le32(0x00000007),
/* Bit mask for user quota flags. */ /* These flags are only present in the quota defaults index entry, i.e. in the
entry where owner_id = QUOTA_DEFAULTS_ID. */
/* These flags are only present in the quota defaults index entry, #define QUOTA_FLAG_TRACKING_ENABLED const_cpu_to_le32(0x00000010)
i.e. in the entry where owner_id = QUOTA_DEFAULTS_ID. */ #define QUOTA_FLAG_ENFORCEMENT_ENABLED const_cpu_to_le32(0x00000020)
QUOTA_FLAG_TRACKING_ENABLED = const_cpu_to_le32(0x00000010), #define QUOTA_FLAG_TRACKING_REQUESTED const_cpu_to_le32(0x00000040)
QUOTA_FLAG_ENFORCEMENT_ENABLED = const_cpu_to_le32(0x00000020), #define QUOTA_FLAG_LOG_THRESHOLD const_cpu_to_le32(0x00000080)
QUOTA_FLAG_TRACKING_REQUESTED = const_cpu_to_le32(0x00000040), #define QUOTA_FLAG_LOG_LIMIT const_cpu_to_le32(0x00000100)
QUOTA_FLAG_LOG_THRESHOLD = const_cpu_to_le32(0x00000080), #define QUOTA_FLAG_OUT_OF_DATE const_cpu_to_le32(0x00000200)
QUOTA_FLAG_LOG_LIMIT = const_cpu_to_le32(0x00000100), #define QUOTA_FLAG_CORRUPT const_cpu_to_le32(0x00000400)
QUOTA_FLAG_OUT_OF_DATE = const_cpu_to_le32(0x00000200), #define QUOTA_FLAG_PENDING_DELETES const_cpu_to_le32(0x00000800)
QUOTA_FLAG_CORRUPT = const_cpu_to_le32(0x00000400),
QUOTA_FLAG_PENDING_DELETES = const_cpu_to_le32(0x00000800), typedef le32 QUOTA_FLAGS;
} QUOTA_FLAGS;
/* /*
* The system file FILE_Extend/$Quota contains two indexes $O and $Q. Quotas * The system file FILE_Extend/$Quota contains two indexes $O and $Q. Quotas
...@@ -2040,11 +2029,9 @@ typedef struct { ...@@ -2040,11 +2029,9 @@ typedef struct {
/* /*
* Predefined owner_id values (32-bit). * Predefined owner_id values (32-bit).
*/ */
typedef enum { #define QUOTA_INVALID_ID const_cpu_to_le32(0x00000000)
QUOTA_INVALID_ID = const_cpu_to_le32(0x00000000), #define QUOTA_DEFAULTS_ID const_cpu_to_le32(0x00000001)
QUOTA_DEFAULTS_ID = const_cpu_to_le32(0x00000001), #define QUOTA_FIRST_USER_ID const_cpu_to_le32(0x00000100)
QUOTA_FIRST_USER_ID = const_cpu_to_le32(0x00000100),
} PREDEFINED_OWNER_IDS;
/* /*
* Current constants for quota control entries. * Current constants for quota control entries.
...@@ -2057,18 +2044,14 @@ typedef enum { ...@@ -2057,18 +2044,14 @@ typedef enum {
/* /*
* Index entry flags (16-bit). * Index entry flags (16-bit).
*/ */
typedef enum { #define INDEX_ENTRY_NODE const_cpu_to_le16(1) /* This entry contains a
INDEX_ENTRY_NODE = const_cpu_to_le16(1), /* This entry contains a sub-node, i.e. a reference to an index block in form of
sub-node, i.e. a reference to an a virtual cluster number (see below). */
index block in form of a virtual #define INDEX_ENTRY_END const_cpu_to_le16(2) /* This signifies the last entry
cluster number (see below). */ in an index block. The index entry does not represent
INDEX_ENTRY_END = const_cpu_to_le16(2), /* This signifies the last a file but it can point to a sub-node. */
entry in an index block. The
index entry does not represent a typedef le16 INDEX_ENTRY_FLAGS;
file but it can point to a
sub-node. */
INDEX_ENTRY_SPACE_FILLER = 0xffff, /* Just to force 16-bit width. */
} __attribute__ ((__packed__)) INDEX_ENTRY_FLAGS;
/* /*
* This the index entry header (see below). * This the index entry header (see below).
...@@ -2198,29 +2181,29 @@ typedef struct { ...@@ -2198,29 +2181,29 @@ typedef struct {
* be slow. (E.g. the data is stored on a tape drive.) * be slow. (E.g. the data is stored on a tape drive.)
* bit 31: Microsoft bit. If set, the tag is owned by Microsoft. User * bit 31: Microsoft bit. If set, the tag is owned by Microsoft. User
* defined tags have to use zero here. * defined tags have to use zero here.
*
* These are the predefined reparse point tags:
*/ */
typedef enum { #define IO_REPARSE_TAG_IS_ALIAS const_cpu_to_le32(0x20000000)
IO_REPARSE_TAG_IS_ALIAS = const_cpu_to_le32(0x20000000), #define IO_REPARSE_TAG_IS_HIGH_LATENCY const_cpu_to_le32(0x40000000)
IO_REPARSE_TAG_IS_HIGH_LATENCY = const_cpu_to_le32(0x40000000), #define IO_REPARSE_TAG_IS_MICROSOFT const_cpu_to_le32(0x80000000)
IO_REPARSE_TAG_IS_MICROSOFT = const_cpu_to_le32(0x80000000),
IO_REPARSE_TAG_RESERVED_ZERO = const_cpu_to_le32(0x00000000), #define IO_REPARSE_TAG_RESERVED_ZERO const_cpu_to_le32(0x00000000)
IO_REPARSE_TAG_RESERVED_ONE = const_cpu_to_le32(0x00000001), #define IO_REPARSE_TAG_RESERVED_ONE const_cpu_to_le32(0x00000001)
IO_REPARSE_TAG_RESERVED_RANGE = const_cpu_to_le32(0x00000001), #define IO_REPARSE_TAG_RESERVED_RANGE const_cpu_to_le32(0x00000001)
IO_REPARSE_TAG_NSS = const_cpu_to_le32(0x68000005), #define IO_REPARSE_TAG_NSS const_cpu_to_le32(0x68000005)
IO_REPARSE_TAG_NSS_RECOVER = const_cpu_to_le32(0x68000006), #define IO_REPARSE_TAG_NSS_RECOVER const_cpu_to_le32(0x68000006)
IO_REPARSE_TAG_SIS = const_cpu_to_le32(0x68000007), #define IO_REPARSE_TAG_SIS const_cpu_to_le32(0x68000007)
IO_REPARSE_TAG_DFS = const_cpu_to_le32(0x68000008), #define IO_REPARSE_TAG_DFS const_cpu_to_le32(0x68000008)
IO_REPARSE_TAG_MOUNT_POINT = const_cpu_to_le32(0x88000003), #define IO_REPARSE_TAG_MOUNT_POINT const_cpu_to_le32(0x88000003)
IO_REPARSE_TAG_HSM = const_cpu_to_le32(0xa8000004), #define IO_REPARSE_TAG_HSM const_cpu_to_le32(0xa8000004)
IO_REPARSE_TAG_SYMBOLIC_LINK = const_cpu_to_le32(0xe8000000), #define IO_REPARSE_TAG_SYMBOLIC_LINK const_cpu_to_le32(0xe8000000)
IO_REPARSE_TAG_VALID_VALUES = const_cpu_to_le32(0xe000ffff), #define IO_REPARSE_TAG_VALID_VALUES const_cpu_to_le32(0xe000ffff)
} PREDEFINED_REPARSE_TAGS;
/* /*
* Attribute: Reparse point (0xc0). * Attribute: Reparse point (0xc0).
...@@ -2254,9 +2237,9 @@ typedef struct { ...@@ -2254,9 +2237,9 @@ typedef struct {
/* /*
* Extended attribute flags (8-bit). * Extended attribute flags (8-bit).
*/ */
typedef enum { #define NEED_EA 0x80
NEED_EA = 0x80,
} __attribute__ ((__packed__)) EA_FLAGS; typedef u8 EA_FLAGS;
/* /*
* Attribute: Extended attribute (EA) (0xe0). * Attribute: Extended attribute (EA) (0xe0).
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */ /* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
/* 0*/ NTFS_RECORD_TYPES magic;/* The magic is "RSTR". */ /* 0*/ NTFS_RECORD_TYPE magic; /* The magic is "RSTR". */
/* 4*/ le16 usa_ofs; /* See NTFS_RECORD definition in layout.h. /* 4*/ le16 usa_ofs; /* See NTFS_RECORD definition in layout.h.
When creating, set this to be immediately When creating, set this to be immediately
after this header structure (without any after this header structure (without any
......
...@@ -44,7 +44,7 @@ static void __format_mft_record(MFT_RECORD *m, const int size, ...@@ -44,7 +44,7 @@ static void __format_mft_record(MFT_RECORD *m, const int size,
m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1); m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1); m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1);
/* Set the update sequence number to 1. */ /* Set the update sequence number to 1. */
*(u16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1); *(le16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1);
m->lsn = cpu_to_le64(0LL); m->lsn = cpu_to_le64(0LL);
m->sequence_number = cpu_to_le16(1); m->sequence_number = cpu_to_le16(1);
m->link_count = cpu_to_le16(0); m->link_count = cpu_to_le16(0);
...@@ -311,11 +311,11 @@ void unmap_mft_record(ntfs_inode *ni) ...@@ -311,11 +311,11 @@ void unmap_mft_record(ntfs_inode *ni)
/** /**
* map_extent_mft_record - load an extent inode and attach it to its base * map_extent_mft_record - load an extent inode and attach it to its base
* @base_ni: base ntfs inode * @base_ni: base ntfs inode
* @mref: mft reference of the extent inode to load (in little endian) * @mref: mft reference of the extent inode to load
* @ntfs_ino: on successful return, pointer to the ntfs_inode structure * @ntfs_ino: on successful return, pointer to the ntfs_inode structure
* *
* Load the extent mft record @mref and attach it to its base inode @base_ni. * Load the extent mft record @mref and attach it to its base inode @base_ni.
* Return the mapped extent mft record if IS_ERR(result) is false. Otherwise * Return the mapped extent mft record if IS_ERR(result) is false. Otherwise
* PTR_ERR(result) gives the negative error code. * PTR_ERR(result) gives the negative error code.
* *
* On successful return, @ntfs_ino contains a pointer to the ntfs_inode * On successful return, @ntfs_ino contains a pointer to the ntfs_inode
...@@ -328,8 +328,8 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref, ...@@ -328,8 +328,8 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
ntfs_inode *ni = NULL; ntfs_inode *ni = NULL;
ntfs_inode **extent_nis = NULL; ntfs_inode **extent_nis = NULL;
int i; int i;
unsigned long mft_no = MREF_LE(mref); unsigned long mft_no = MREF(mref);
u16 seq_no = MSEQNO_LE(mref); u16 seq_no = MSEQNO(mref);
BOOL destroy_ni = FALSE; BOOL destroy_ni = FALSE;
ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).", ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).",
......
...@@ -122,8 +122,9 @@ int post_read_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -122,8 +122,9 @@ int post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
*/ */
int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
{ {
le16 *usa_pos, *data_pos;
u16 usa_ofs, usa_count, usn; u16 usa_ofs, usa_count, usn;
u16 *usa_pos, *data_pos; le16 le_usn;
/* Sanity check + only fixup if it makes sense. */ /* Sanity check + only fixup if it makes sense. */
if (!b || ntfs_is_baad_record(b->magic) || if (!b || ntfs_is_baad_record(b->magic) ||
...@@ -140,7 +141,7 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -140,7 +141,7 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
(size >> NTFS_BLOCK_SIZE_BITS) != usa_count) (size >> NTFS_BLOCK_SIZE_BITS) != usa_count)
return -EINVAL; return -EINVAL;
/* Position of usn in update sequence array. */ /* Position of usn in update sequence array. */
usa_pos = (u16*)((u8*)b + usa_ofs); usa_pos = (le16*)((u8*)b + usa_ofs);
/* /*
* Cyclically increment the update sequence number * Cyclically increment the update sequence number
* (skipping 0 and -1, i.e. 0xffff). * (skipping 0 and -1, i.e. 0xffff).
...@@ -148,10 +149,10 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -148,10 +149,10 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
usn = le16_to_cpup(usa_pos) + 1; usn = le16_to_cpup(usa_pos) + 1;
if (usn == 0xffff || !usn) if (usn == 0xffff || !usn)
usn = 1; usn = 1;
usn = cpu_to_le16(usn); le_usn = cpu_to_le16(usn);
*usa_pos = usn; *usa_pos = le_usn;
/* Position in data of first u16 that needs fixing up. */ /* Position in data of first u16 that needs fixing up. */
data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1; data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1;
/* Fixup all sectors. */ /* Fixup all sectors. */
while (usa_count--) { while (usa_count--) {
/* /*
...@@ -160,9 +161,9 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -160,9 +161,9 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
*/ */
*(++usa_pos) = *data_pos; *(++usa_pos) = *data_pos;
/* Apply fixup to data. */ /* Apply fixup to data. */
*data_pos = usn; *data_pos = le_usn;
/* Increment position in data as well. */ /* Increment position in data as well. */
data_pos += NTFS_BLOCK_SIZE/sizeof(u16); data_pos += NTFS_BLOCK_SIZE/sizeof(le16);
} }
return 0; return 0;
} }
...@@ -177,16 +178,16 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -177,16 +178,16 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
*/ */
void post_write_mst_fixup(NTFS_RECORD *b) void post_write_mst_fixup(NTFS_RECORD *b)
{ {
u16 *usa_pos, *data_pos; le16 *usa_pos, *data_pos;
u16 usa_ofs = le16_to_cpu(b->usa_ofs); u16 usa_ofs = le16_to_cpu(b->usa_ofs);
u16 usa_count = le16_to_cpu(b->usa_count) - 1; u16 usa_count = le16_to_cpu(b->usa_count) - 1;
/* Position of usn in update sequence array. */ /* Position of usn in update sequence array. */
usa_pos = (u16*)b + usa_ofs/sizeof(u16); usa_pos = (le16*)b + usa_ofs/sizeof(le16);
/* Position in protected data of first u16 that needs fixing up. */ /* Position in protected data of first u16 that needs fixing up. */
data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1; data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1;
/* Fixup all sectors. */ /* Fixup all sectors. */
while (usa_count--) { while (usa_count--) {
...@@ -197,6 +198,6 @@ void post_write_mst_fixup(NTFS_RECORD *b) ...@@ -197,6 +198,6 @@ void post_write_mst_fixup(NTFS_RECORD *b)
*data_pos = *(++usa_pos); *data_pos = *(++usa_pos);
/* Increment position in data as well. */ /* Increment position in data as well. */
data_pos += NTFS_BLOCK_SIZE/sizeof(u16); data_pos += NTFS_BLOCK_SIZE/sizeof(le16);
} }
} }
...@@ -37,7 +37,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol) ...@@ -37,7 +37,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
{ {
ntfs_index_context *ictx; ntfs_index_context *ictx;
QUOTA_CONTROL_ENTRY *qce; QUOTA_CONTROL_ENTRY *qce;
const u32 qid = QUOTA_DEFAULTS_ID; const le32 qid = QUOTA_DEFAULTS_ID;
int err; int err;
ntfs_debug("Entering."); ntfs_debug("Entering.");
......
...@@ -322,7 +322,7 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags) ...@@ -322,7 +322,7 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
int err; int err;
ntfs_debug("Entering, old flags = 0x%x, new flags = 0x%x.", ntfs_debug("Entering, old flags = 0x%x, new flags = 0x%x.",
vol->vol_flags, flags); le16_to_cpu(vol->vol_flags), le16_to_cpu(flags));
if (vol->vol_flags == flags) if (vol->vol_flags == flags)
goto done; goto done;
BUG_ON(!ni); BUG_ON(!ni);
...@@ -386,7 +386,8 @@ static inline int ntfs_set_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) ...@@ -386,7 +386,8 @@ static inline int ntfs_set_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags)
static inline int ntfs_clear_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) static inline int ntfs_clear_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags)
{ {
flags &= VOLUME_FLAGS_MASK; flags &= VOLUME_FLAGS_MASK;
return ntfs_write_volume_flags(vol, vol->vol_flags & ~flags); flags = vol->vol_flags & cpu_to_le16(~le16_to_cpu(flags));
return ntfs_write_volume_flags(vol, flags);
} }
#endif /* NTFS_RW */ #endif /* NTFS_RW */
......
...@@ -96,7 +96,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len, ...@@ -96,7 +96,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
const ntfschar *upcase, const u32 upcase_len) const ntfschar *upcase, const u32 upcase_len)
{ {
u32 cnt, min_len; u32 cnt, min_len;
ntfschar c1, c2; u16 c1, c2;
min_len = name1_len; min_len = name1_len;
if (name1_len > name2_len) if (name1_len > name2_len)
...@@ -144,7 +144,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len, ...@@ -144,7 +144,7 @@ int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
*/ */
int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n) int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
{ {
ntfschar c1, c2; u16 c1, c2;
size_t i; size_t i;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
...@@ -181,8 +181,8 @@ int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n) ...@@ -181,8 +181,8 @@ int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n, int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
const ntfschar *upcase, const u32 upcase_size) const ntfschar *upcase, const u32 upcase_size)
{ {
ntfschar c1, c2;
size_t i; size_t i;
u16 c1, c2;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
if ((c1 = le16_to_cpu(s1[i])) < upcase_size) if ((c1 = le16_to_cpu(s1[i])) < upcase_size)
...@@ -203,7 +203,7 @@ void ntfs_upcase_name(ntfschar *name, u32 name_len, const ntfschar *upcase, ...@@ -203,7 +203,7 @@ void ntfs_upcase_name(ntfschar *name, u32 name_len, const ntfschar *upcase,
const u32 upcase_len) const u32 upcase_len)
{ {
u32 i; u32 i;
ntfschar u; u16 u;
for (i = 0; i < name_len; i++) for (i = 0; i < name_len; i++)
if ((u = le16_to_cpu(name[i])) < upcase_len) if ((u = le16_to_cpu(name[i])) < upcase_len)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Part of the Linux-NTFS project. * Part of the Linux-NTFS project.
* *
* Copyright (c) 2001 Richard Russon <ntfs@flatcap.org> * Copyright (c) 2001 Richard Russon <ntfs@flatcap.org>
* Copyright (c) 2001-2003 Anton Altaparmakov * Copyright (c) 2001-2004 Anton Altaparmakov
* *
* Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov. * Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov.
* Modified for kernel inclusion 10 September 2001 by Anton Altparmakov. * Modified for kernel inclusion 10 September 2001 by Anton Altparmakov.
...@@ -87,4 +87,3 @@ ntfschar *generate_default_upcase(void) ...@@ -87,4 +87,3 @@ ntfschar *generate_default_upcase(void)
uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]); uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]);
return uc; return uc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment