Commit b779e3a0 authored by Anton Altaparmakov's avatar Anton Altaparmakov

Merge ssh://linux-ntfs@bkbits.net/ntfs-2.6-devel

into cantab.net:/home/src/ntfs-2.6-devel
parents 87292b19 70e642bc
...@@ -277,6 +277,11 @@ ChangeLog ...@@ -277,6 +277,11 @@ ChangeLog
Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
2.1.19:
- Minor bugfix in handling of the default upcase table.
- Many internal cleanups and improvements. Many thanks to Linus
Torvalds and Al Viro for the help and advice with the sparse
annotations and cleanups.
2.1.18: 2.1.18:
- Fix scheduling latencies at mount time. (Ingo Molnar) - Fix scheduling latencies at mount time. (Ingo Molnar)
- Fix endianness bug in a little traversed portion of the attribute - Fix endianness bug in a little traversed portion of the attribute
......
...@@ -21,7 +21,7 @@ ToDo/Notes: ...@@ -21,7 +21,7 @@ ToDo/Notes:
- Enable the code for setting the NT4 compatibility flag when we start - Enable the code for setting the NT4 compatibility flag when we start
making NTFS 1.2 specific modifications. making NTFS 1.2 specific modifications.
2.1.19-WIP 2.1.19 - Many cleanups, improvements, and a minor bug fix.
- Update ->setattr (fs/ntfs/inode.c::ntfs_setattr()) to refuse to - Update ->setattr (fs/ntfs/inode.c::ntfs_setattr()) to refuse to
change the uid, gid, and mode of an inode as we do not support NTFS change the uid, gid, and mode of an inode as we do not support NTFS
...@@ -34,6 +34,26 @@ ToDo/Notes: ...@@ -34,6 +34,26 @@ ToDo/Notes:
- Update ->truncate (fs/ntfs/inode.c::ntfs_truncate()) to check if the - Update ->truncate (fs/ntfs/inode.c::ntfs_truncate()) to check if the
inode size has changed and to only output an error if so. inode size has changed and to only output an error if so.
- Rename fs/ntfs/attrib.h::attribute_value_length() to ntfs_attr_size(). - Rename fs/ntfs/attrib.h::attribute_value_length() to ntfs_attr_size().
- Add le{16,32,64} as well as sle{16,32,64} data types to
fs/ntfs/types.h.
- Change ntfschar to be le16 instead of u16 in fs/ntfs/types.h.
- Add le versions of VCN, LCN, and LSN called leVCN, leLCN, and leLSN,
respectively, to fs/ntfs/types.h.
- Update endianness conversion macros in fs/ntfs/endian.h to use the
new types as appropriate.
- Do proper type casting when using sle64_to_cpup() in fs/ntfs/dir.c
and index.c.
- Add leMFT_REF data type to fs/ntfs/layout.h.
- Update all NTFS header files with the new little endian data types.
Affected files are fs/ntfs/layout.h, logfile.h, and time.h.
- Do proper type casting when using ntfs_is_*_recordp() in
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.
- Fix a bug found by the new sparse bitwise warnings where the default
upcase table was defined as a pointer to wchar_t rather than ntfschar
in fs/ntfs/ntfs.h and super.c.
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.
......
...@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ ...@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
index.o inode.o mft.o mst.o namei.o super.o sysctl.o unistr.o \ index.o inode.o mft.o mst.o namei.o super.o sysctl.o unistr.o \
upcase.o upcase.o
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.19-WIP\" EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.19\"
ifeq ($(CONFIG_NTFS_DEBUG),y) ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG EXTRA_CFLAGS += -DDEBUG
......
...@@ -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
......
...@@ -299,7 +299,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname, ...@@ -299,7 +299,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
goto err_out; goto err_out;
} }
/* Get the starting vcn of the index_block holding the child node. */ /* Get the starting vcn of the index_block holding the child node. */
vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8));
ia_mapping = VFS_I(dir_ni)->i_mapping; ia_mapping = VFS_I(dir_ni)->i_mapping;
/* /*
* We are done with the index root and the mft record. Release them, * We are done with the index root and the mft record. Release them,
...@@ -551,7 +551,8 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname, ...@@ -551,7 +551,8 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
} }
/* Child node present, descend into it. */ /* Child node present, descend into it. */
old_vcn = vcn; old_vcn = vcn;
vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); vcn = sle64_to_cpup((sle64*)((u8*)ie +
le16_to_cpu(ie->length) - 8));
if (vcn >= 0) { if (vcn >= 0) {
/* If vcn is in the same page cache page as old_vcn we /* If vcn is in the same page cache page as old_vcn we
* recycle the mapped page. */ * recycle the mapped page. */
......
...@@ -24,24 +24,70 @@ ...@@ -24,24 +24,70 @@
#define _LINUX_NTFS_ENDIAN_H #define _LINUX_NTFS_ENDIAN_H
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include "types.h"
/* /*
* Signed endianness conversion defines. * Signed endianness conversion functions.
*/ */
#define sle16_to_cpu(x) ((s16)__le16_to_cpu((s16)(x)))
#define sle32_to_cpu(x) ((s32)__le32_to_cpu((s32)(x)))
#define sle64_to_cpu(x) ((s64)__le64_to_cpu((s64)(x)))
#define sle16_to_cpup(x) ((s16)__le16_to_cpu(*(s16*)(x))) static inline s16 sle16_to_cpu(sle16 x)
#define sle32_to_cpup(x) ((s32)__le32_to_cpu(*(s32*)(x))) {
#define sle64_to_cpup(x) ((s64)__le64_to_cpu(*(s64*)(x))) return le16_to_cpu((__force le16)x);
}
#define cpu_to_sle16(x) ((s16)__cpu_to_le16((s16)(x))) static inline s32 sle32_to_cpu(sle32 x)
#define cpu_to_sle32(x) ((s32)__cpu_to_le32((s32)(x))) {
#define cpu_to_sle64(x) ((s64)__cpu_to_le64((s64)(x))) return le32_to_cpu((__force le32)x);
}
#define cpu_to_sle16p(x) ((s16)__cpu_to_le16(*(s16*)(x))) static inline s64 sle64_to_cpu(sle64 x)
#define cpu_to_sle32p(x) ((s32)__cpu_to_le32(*(s32*)(x))) {
#define cpu_to_sle64p(x) ((s64)__cpu_to_le64(*(s64*)(x))) return le64_to_cpu((__force le64)x);
}
static inline s16 sle16_to_cpup(sle16 *x)
{
return le16_to_cpu(*(__force le16*)x);
}
static inline s32 sle32_to_cpup(sle32 *x)
{
return le32_to_cpu(*(__force le32*)x);
}
static inline s64 sle64_to_cpup(sle64 *x)
{
return le64_to_cpu(*(__force le64*)x);
}
static inline sle16 cpu_to_sle16(s16 x)
{
return (__force sle16)cpu_to_le16(x);
}
static inline sle32 cpu_to_sle32(s32 x)
{
return (__force sle32)cpu_to_le32(x);
}
static inline sle64 cpu_to_sle64(s64 x)
{
return (__force sle64)cpu_to_le64(x);
}
static inline sle16 cpu_to_sle16p(s16 *x)
{
return (__force sle16)cpu_to_le16(*x);
}
static inline sle32 cpu_to_sle32p(s32 *x)
{
return (__force sle32)cpu_to_le32(*x);
}
static inline sle64 cpu_to_sle64p(s64 *x)
{
return (__force sle64)cpu_to_le64(*x);
}
#endif /* _LINUX_NTFS_ENDIAN_H */ #endif /* _LINUX_NTFS_ENDIAN_H */
...@@ -265,7 +265,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ...@@ -265,7 +265,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
goto err_out; goto err_out;
} }
/* Get the starting vcn of the index_block holding the child node. */ /* Get the starting vcn of the index_block holding the child node. */
vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8));
ia_mapping = VFS_I(idx_ni)->i_mapping; ia_mapping = VFS_I(idx_ni)->i_mapping;
/* /*
* We are done with the index root and the mft record. Release them, * We are done with the index root and the mft record. Release them,
...@@ -427,7 +427,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ...@@ -427,7 +427,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
} }
/* Child node present, descend into it. */ /* Child node present, descend into it. */
old_vcn = vcn; old_vcn = vcn;
vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8));
if (vcn >= 0) { if (vcn >= 0) {
/* /*
* If vcn is in the same page cache page as old_vcn we recycle * If vcn is in the same page cache page as old_vcn we recycle
......
...@@ -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);
......
This diff is collapsed.
...@@ -497,7 +497,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi) ...@@ -497,7 +497,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi)
* empty block after a non-empty block has been encountered * empty block after a non-empty block has been encountered
* means we are done. * means we are done.
*/ */
if (!ntfs_is_empty_recordp(kaddr)) if (!ntfs_is_empty_recordp((le32*)kaddr))
logfile_is_empty = FALSE; logfile_is_empty = FALSE;
else if (!logfile_is_empty) else if (!logfile_is_empty)
break; break;
...@@ -505,20 +505,20 @@ BOOL ntfs_check_logfile(struct inode *log_vi) ...@@ -505,20 +505,20 @@ BOOL ntfs_check_logfile(struct inode *log_vi)
* A log record page means there cannot be a restart page after * A log record page means there cannot be a restart page after
* this so no need to continue searching. * this so no need to continue searching.
*/ */
if (ntfs_is_rcrd_recordp(kaddr)) if (ntfs_is_rcrd_recordp((le32*)kaddr))
break; break;
/* /*
* A modified by chkdsk restart page means we cannot handle * A modified by chkdsk restart page means we cannot handle
* this log file. * this log file.
*/ */
if (ntfs_is_chkd_recordp(kaddr)) { if (ntfs_is_chkd_recordp((le32*)kaddr)) {
ntfs_error(vol->sb, "$LogFile has been modified by " ntfs_error(vol->sb, "$LogFile has been modified by "
"chkdsk. Mount this volume in " "chkdsk. Mount this volume in "
"Windows."); "Windows.");
goto err_out; goto err_out;
} }
/* If not a restart page, continue. */ /* If not a restart page, continue. */
if (!ntfs_is_rstr_recordp(kaddr)) { if (!ntfs_is_rstr_recordp((le32*)kaddr)) {
/* Skip to the minimum page size for the next one. */ /* Skip to the minimum page size for the next one. */
if (!pos) if (!pos)
pos = NTFS_BLOCK_SIZE >> 1; pos = NTFS_BLOCK_SIZE >> 1;
......
...@@ -67,34 +67,34 @@ ...@@ -67,34 +67,34 @@
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*/ u16 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
alignment). */ alignment). */
/* 6*/ u16 usa_count; /* See NTFS_RECORD definition in layout.h. */ /* 6*/ le16 usa_count; /* See NTFS_RECORD definition in layout.h. */
/* 8*/ LSN chkdsk_lsn; /* The last log file sequence number found by /* 8*/ leLSN chkdsk_lsn; /* The last log file sequence number found by
chkdsk. Only used when the magic is changed chkdsk. Only used when the magic is changed
to "CHKD". Otherwise this is zero. */ to "CHKD". Otherwise this is zero. */
/* 16*/ u32 system_page_size; /* Byte size of system pages when the log file /* 16*/ le32 system_page_size; /* Byte size of system pages when the log file
was created, has to be >= 512 and a power of was created, has to be >= 512 and a power of
2. Use this to calculate the required size 2. Use this to calculate the required size
of the usa (usa_count) and add it to usa_ofs. of the usa (usa_count) and add it to usa_ofs.
Then verify that the result is less than the Then verify that the result is less than the
value of the restart_area_offset. */ value of the restart_area_offset. */
/* 20*/ u32 log_page_size; /* Byte size of log file pages, has to be >= /* 20*/ le32 log_page_size; /* Byte size of log file pages, has to be >=
512 and a power of 2. The default is 4096 512 and a power of 2. The default is 4096
and is used when the system page size is and is used when the system page size is
between 4096 and 8192. Otherwise this is between 4096 and 8192. Otherwise this is
set to the system page size instead. */ set to the system page size instead. */
/* 24*/ u16 restart_area_offset;/* Byte offset from the start of this header to /* 24*/ le16 restart_area_offset;/* Byte offset from the start of this header to
the RESTART_AREA. Value has to be aligned the RESTART_AREA. Value has to be aligned
to 8-byte boundary. When creating, set this to 8-byte boundary. When creating, set this
to be after the usa. */ to be after the usa. */
/* 26*/ s16 minor_ver; /* Log file minor version. Only check if major /* 26*/ sle16 minor_ver; /* Log file minor version. Only check if major
version is 1. */ version is 1. */
/* 28*/ s16 major_ver; /* Log file major version. We only support /* 28*/ sle16 major_ver; /* Log file major version. We only support
version 1.1. */ version 1.1. */
/* sizeof() = 30 (0x1e) bytes */ /* sizeof() = 30 (0x1e) bytes */
} __attribute__ ((__packed__)) RESTART_PAGE_HEADER; } __attribute__ ((__packed__)) RESTART_PAGE_HEADER;
...@@ -123,16 +123,16 @@ typedef enum { ...@@ -123,16 +123,16 @@ typedef enum {
*/ */
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0*/ LSN current_lsn; /* The current, i.e. last LSN inside the log /* 0*/ leLSN current_lsn; /* The current, i.e. last LSN inside the log
when the restart area was last written. when the restart area was last written.
This happens often but what is the interval? This happens often but what is the interval?
Is it just fixed time or is it every time a Is it just fixed time or is it every time a
check point is written or somethine else? check point is written or somethine else?
On create set to 0. */ On create set to 0. */
/* 8*/ u16 log_clients; /* Number of log client records in the array of /* 8*/ le16 log_clients; /* Number of log client records in the array of
log client records which follows this log client records which follows this
restart area. Must be 1. */ restart area. Must be 1. */
/* 10*/ u16 client_free_list; /* The index of the first free log client record /* 10*/ le16 client_free_list; /* The index of the first free log client record
in the array of log client records. in the array of log client records.
LOGFILE_NO_CLIENT means that there are no LOGFILE_NO_CLIENT means that there are no
free log client records in the array. free log client records in the array.
...@@ -148,7 +148,7 @@ typedef struct { ...@@ -148,7 +148,7 @@ typedef struct {
and presumably later, the logfile is always and presumably later, the logfile is always
open, even on clean shutdown so this should open, even on clean shutdown so this should
always be LOGFILE_NO_CLIENT. */ always be LOGFILE_NO_CLIENT. */
/* 12*/ u16 client_in_use_list; /* The index of the first in-use log client /* 12*/ le16 client_in_use_list;/* The index of the first in-use log client
record in the array of log client records. record in the array of log client records.
LOGFILE_NO_CLIENT means that there are no LOGFILE_NO_CLIENT means that there are no
in-use log client records in the array. If in-use log client records in the array. If
...@@ -181,13 +181,13 @@ typedef struct { ...@@ -181,13 +181,13 @@ typedef struct {
clean. If on the other hand the logfile is clean. If on the other hand the logfile is
open and this bit is clear, we can be almost open and this bit is clear, we can be almost
certain that the logfile is dirty. */ certain that the logfile is dirty. */
/* 16*/ u32 seq_number_bits; /* How many bits to use for the sequence /* 16*/ le32 seq_number_bits; /* How many bits to use for the sequence
number. This is calculated as 67 - the number. This is calculated as 67 - the
number of bits required to store the logfile number of bits required to store the logfile
size in bytes and this can be used in with size in bytes and this can be used in with
the specified file_size as a consistency the specified file_size as a consistency
check. */ check. */
/* 20*/ u16 restart_area_length;/* Length of the restart area including the /* 20*/ le16 restart_area_length;/* Length of the restart area including the
client array. Following checks required if client array. Following checks required if
version matches. Otherwise, skip them. version matches. Otherwise, skip them.
restart_area_offset + restart_area_length restart_area_offset + restart_area_length
...@@ -195,7 +195,7 @@ typedef struct { ...@@ -195,7 +195,7 @@ typedef struct {
restart_area_length has to be >= restart_area_length has to be >=
client_array_offset + (log_clients * client_array_offset + (log_clients *
sizeof(log client record)). */ sizeof(log client record)). */
/* 22*/ u16 client_array_offset;/* Offset from the start of this record to /* 22*/ le16 client_array_offset;/* Offset from the start of this record to
the first log client record if versions are the first log client record if versions are
matched. When creating, set this to be matched. When creating, set this to be
after this restart area structure, aligned after this restart area structure, aligned
...@@ -217,7 +217,7 @@ typedef struct { ...@@ -217,7 +217,7 @@ typedef struct {
the client array. This probably means that the client array. This probably means that
the RESTART_AREA record is actually bigger the RESTART_AREA record is actually bigger
in WinXP and later. */ in WinXP and later. */
/* 24*/ s64 file_size; /* Usable byte size of the log file. If the /* 24*/ sle64 file_size; /* Usable byte size of the log file. If the
restart_area_offset + the offset of the restart_area_offset + the offset of the
file_size are > 510 then corruption has file_size are > 510 then corruption has
occured. This is the very first check when occured. This is the very first check when
...@@ -230,28 +230,28 @@ typedef struct { ...@@ -230,28 +230,28 @@ typedef struct {
then it has to be at least big enough to then it has to be at least big enough to
store the two restart pages and 48 (0x30) store the two restart pages and 48 (0x30)
log record pages. */ log record pages. */
/* 32*/ u32 last_lsn_data_length;/* Length of data of last LSN, not including /* 32*/ le32 last_lsn_data_length;/* Length of data of last LSN, not including
the log record header. On create set to the log record header. On create set to
0. */ 0. */
/* 36*/ u16 log_record_header_length;/* Byte size of the log record header. If /* 36*/ le16 log_record_header_length;/* Byte size of the log record header.
the version matches then check that the If the version matches then check that the
value of log_record_header_length is a value of log_record_header_length is a
multiple of 8, i.e. multiple of 8, i.e.
(log_record_header_length + 7) & ~7 == (log_record_header_length + 7) & ~7 ==
log_record_header_length. When creating set log_record_header_length. When creating set
it to sizeof(LOG_RECORD_HEADER), aligned to it to sizeof(LOG_RECORD_HEADER), aligned to
8 bytes. */ 8 bytes. */
/* 38*/ u16 log_page_data_offset;/* Offset to the start of data in a log record /* 38*/ le16 log_page_data_offset;/* Offset to the start of data in a log record
page. Must be a multiple of 8. On create page. Must be a multiple of 8. On create
set it to immediately after the update set it to immediately after the update
sequence array of the log record page. */ sequence array of the log record page. */
/* 40*/ u32 restart_log_open_count;/* A counter that gets incremented every time /* 40*/ le32 restart_log_open_count;/* A counter that gets incremented every
the logfile is restarted which happens at time the logfile is restarted which happens
mount time when the logfile is opened. When at mount time when the logfile is opened.
creating set to a random value. Win2k sets When creating set to a random value. Win2k
it to the low 32 bits of the current system sets it to the low 32 bits of the current
time in NTFS format (see time.h). */ system time in NTFS format (see time.h). */
/* 44*/ u32 reserved; /* Reserved/alignment to 8-byte boundary. */ /* 44*/ le32 reserved; /* Reserved/alignment to 8-byte boundary. */
/* sizeof() = 48 (0x30) bytes */ /* sizeof() = 48 (0x30) bytes */
} __attribute__ ((__packed__)) RESTART_AREA; } __attribute__ ((__packed__)) RESTART_AREA;
...@@ -261,32 +261,32 @@ typedef struct { ...@@ -261,32 +261,32 @@ typedef struct {
*/ */
typedef struct { typedef struct {
/*Ofs*/ /*Ofs*/
/* 0*/ LSN oldest_lsn; /* Oldest LSN needed by this client. On create /* 0*/ leLSN oldest_lsn; /* Oldest LSN needed by this client. On create
set to 0. */ set to 0. */
/* 8*/ LSN client_restart_lsn; /* LSN at which this client needs to restart /* 8*/ leLSN client_restart_lsn;/* LSN at which this client needs to restart
the volume, i.e. the current position within the volume, i.e. the current position within
the log file. At present, if clean this the log file. At present, if clean this
should = current_lsn in restart area but it should = current_lsn in restart area but it
probably also = current_lsn when dirty most probably also = current_lsn when dirty most
of the time. At create set to 0. */ of the time. At create set to 0. */
/* 16*/ u16 prev_client; /* The offset to the previous log client record /* 16*/ le16 prev_client; /* The offset to the previous log client record
in the array of log client records. in the array of log client records.
LOGFILE_NO_CLIENT means there is no previous LOGFILE_NO_CLIENT means there is no previous
client record, i.e. this is the first one. client record, i.e. this is the first one.
This is always LOGFILE_NO_CLIENT. */ This is always LOGFILE_NO_CLIENT. */
/* 18*/ u16 next_client; /* The offset to the next log client record in /* 18*/ le16 next_client; /* The offset to the next log client record in
the array of log client records. the array of log client records.
LOGFILE_NO_CLIENT means there are no next LOGFILE_NO_CLIENT means there are no next
client records, i.e. this is the last one. client records, i.e. this is the last one.
This is always LOGFILE_NO_CLIENT. */ This is always LOGFILE_NO_CLIENT. */
/* 20*/ u16 seq_number; /* On Win2k and presumably earlier, this is set /* 20*/ le16 seq_number; /* On Win2k and presumably earlier, this is set
to zero every time the logfile is restarted to zero every time the logfile is restarted
and it is incremented when the logfile is and it is incremented when the logfile is
closed at dismount time. Thus it is 0 when closed at dismount time. Thus it is 0 when
dirty and 1 when clean. On WinXP and dirty and 1 when clean. On WinXP and
presumably later, this is always 0. */ presumably later, this is always 0. */
/* 22*/ u8 reserved[6]; /* Reserved/alignment. */ /* 22*/ u8 reserved[6]; /* Reserved/alignment. */
/* 28*/ u32 client_name_length; /* Length of client name in bytes. Should /* 28*/ le32 client_name_length;/* Length of client name in bytes. Should
always be 8. */ always be 8. */
/* 32*/ ntfschar client_name[64];/* Name of the client in Unicode. Should /* 32*/ ntfschar client_name[64];/* Name of the client in Unicode. Should
always be "NTFS" with the remaining bytes always be "NTFS" with the remaining bytes
......
...@@ -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).",
...@@ -980,7 +980,7 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc) ...@@ -980,7 +980,7 @@ static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc)
ntfs_debug("Inode 0x%lx is not in icache.", mft_no); ntfs_debug("Inode 0x%lx is not in icache.", mft_no);
/* The inode is not in icache. */ /* The inode is not in icache. */
/* Skip the record if it is not a mft record (type "FILE"). */ /* Skip the record if it is not a mft record (type "FILE"). */
if (!ntfs_is_mft_recordp(maddr)) { if (!ntfs_is_mft_recordp((le32*)maddr)) {
ntfs_debug("Mft record 0x%lx is not a FILE record, " ntfs_debug("Mft record 0x%lx is not a FILE record, "
"continuing search.", mft_no); "continuing search.", mft_no);
continue; continue;
......
...@@ -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);
} }
} }
...@@ -156,7 +156,7 @@ extern int ntfs_read_compressed_block(struct page *page); ...@@ -156,7 +156,7 @@ extern int ntfs_read_compressed_block(struct page *page);
/* From fs/ntfs/super.c */ /* From fs/ntfs/super.c */
#define default_upcase_len 0x10000 #define default_upcase_len 0x10000
extern wchar_t *default_upcase; extern ntfschar *default_upcase;
extern unsigned long ntfs_nr_upcase_users; extern unsigned long ntfs_nr_upcase_users;
extern struct semaphore ntfs_lock; extern struct semaphore ntfs_lock;
......
...@@ -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 */
...@@ -511,8 +512,10 @@ static BOOL is_boot_sector_ntfs(const struct super_block *sb, ...@@ -511,8 +512,10 @@ static BOOL is_boot_sector_ntfs(const struct super_block *sb,
* field. If checksum is zero, no checking is done. * field. If checksum is zero, no checking is done.
*/ */
if ((void*)b < (void*)&b->checksum && b->checksum) { if ((void*)b < (void*)&b->checksum && b->checksum) {
u32 i, *u; le32 *u;
for (i = 0, u = (u32*)b; u < (u32*)(&b->checksum); ++u) u32 i;
for (i = 0, u = (le32*)b; u < (le32*)(&b->checksum); ++u)
i += le32_to_cpup(u); i += le32_to_cpup(u);
if (le32_to_cpu(b->checksum) != i) if (le32_to_cpu(b->checksum) != i)
goto not_ntfs; goto not_ntfs;
...@@ -521,7 +524,7 @@ static BOOL is_boot_sector_ntfs(const struct super_block *sb, ...@@ -521,7 +524,7 @@ static BOOL is_boot_sector_ntfs(const struct super_block *sb,
if (b->oem_id != magicNTFS) if (b->oem_id != magicNTFS)
goto not_ntfs; goto not_ntfs;
/* Check bytes per sector value is between 256 and 4096. */ /* Check bytes per sector value is between 256 and 4096. */
if (le16_to_cpu(b->bpb.bytes_per_sector) < 0x100 || if (le16_to_cpu(b->bpb.bytes_per_sector) < 0x100 ||
le16_to_cpu(b->bpb.bytes_per_sector) > 0x1000) le16_to_cpu(b->bpb.bytes_per_sector) > 0x1000)
goto not_ntfs; goto not_ntfs;
/* Check sectors per cluster value is valid. */ /* Check sectors per cluster value is valid. */
...@@ -1003,7 +1006,7 @@ static BOOL check_mft_mirror(ntfs_volume *vol) ...@@ -1003,7 +1006,7 @@ static BOOL check_mft_mirror(ntfs_volume *vol)
++index; ++index;
} }
/* Make sure the record is ok. */ /* Make sure the record is ok. */
if (ntfs_is_baad_recordp(kmft)) { if (ntfs_is_baad_recordp((le32*)kmft)) {
ntfs_error(sb, "Incomplete multi sector transfer " ntfs_error(sb, "Incomplete multi sector transfer "
"detected in mft record %i.", i); "detected in mft record %i.", i);
mm_unmap_out: mm_unmap_out:
...@@ -1012,7 +1015,7 @@ static BOOL check_mft_mirror(ntfs_volume *vol) ...@@ -1012,7 +1015,7 @@ static BOOL check_mft_mirror(ntfs_volume *vol)
ntfs_unmap_page(mft_page); ntfs_unmap_page(mft_page);
return FALSE; return FALSE;
} }
if (ntfs_is_baad_recordp(kmirr)) { if (ntfs_is_baad_recordp((le32*)kmirr)) {
ntfs_error(sb, "Incomplete multi sector transfer " ntfs_error(sb, "Incomplete multi sector transfer "
"detected in mft mirror record %i.", i); "detected in mft mirror record %i.", i);
goto mm_unmap_out; goto mm_unmap_out;
...@@ -2571,7 +2574,7 @@ kmem_cache_t *ntfs_attr_ctx_cache; ...@@ -2571,7 +2574,7 @@ kmem_cache_t *ntfs_attr_ctx_cache;
kmem_cache_t *ntfs_index_ctx_cache; kmem_cache_t *ntfs_index_ctx_cache;
/* A global default upcase table and a corresponding reference count. */ /* A global default upcase table and a corresponding reference count. */
wchar_t *default_upcase = NULL; ntfschar *default_upcase = NULL;
unsigned long ntfs_nr_upcase_users = 0; unsigned long ntfs_nr_upcase_users = 0;
/* Driver wide semaphore. */ /* Driver wide semaphore. */
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
* measured as the number of 100-nano-second intervals since 1st January 1601, * measured as the number of 100-nano-second intervals since 1st January 1601,
* 00:00:00 UTC. * 00:00:00 UTC.
*/ */
static inline s64 utc2ntfs(const struct timespec ts) static inline sle64 utc2ntfs(const struct timespec ts)
{ {
/* /*
* Convert the seconds to 100ns intervals, add the nano-seconds * Convert the seconds to 100ns intervals, add the nano-seconds
...@@ -61,7 +61,7 @@ static inline s64 utc2ntfs(const struct timespec ts) ...@@ -61,7 +61,7 @@ static inline s64 utc2ntfs(const struct timespec ts)
* Get the current time from the Linux kernel, convert it to its corresponding * Get the current time from the Linux kernel, convert it to its corresponding
* NTFS time and return that in little endian format. * NTFS time and return that in little endian format.
*/ */
static inline s64 get_current_ntfs_time(void) static inline sle64 get_current_ntfs_time(void)
{ {
return utc2ntfs(current_kernel_time()); return utc2ntfs(current_kernel_time());
} }
...@@ -82,7 +82,7 @@ static inline s64 get_current_ntfs_time(void) ...@@ -82,7 +82,7 @@ static inline s64 get_current_ntfs_time(void)
* measured as the number of 100 nano-second intervals since 1st January 1601, * measured as the number of 100 nano-second intervals since 1st January 1601,
* 00:00:00 UTC. * 00:00:00 UTC.
*/ */
static inline struct timespec ntfs2utc(const s64 time) static inline struct timespec ntfs2utc(const sle64 time)
{ {
struct timespec ts; struct timespec ts;
......
...@@ -23,8 +23,17 @@ ...@@ -23,8 +23,17 @@
#ifndef _LINUX_NTFS_TYPES_H #ifndef _LINUX_NTFS_TYPES_H
#define _LINUX_NTFS_TYPES_H #define _LINUX_NTFS_TYPES_H
#include <linux/types.h>
typedef __le16 le16;
typedef __le32 le32;
typedef __le64 le64;
typedef __u16 __bitwise sle16;
typedef __u32 __bitwise sle32;
typedef __u64 __bitwise sle64;
/* 2-byte Unicode character type. */ /* 2-byte Unicode character type. */
typedef u16 ntfschar; typedef le16 ntfschar;
#define UCHAR_T_SIZE_BITS 1 #define UCHAR_T_SIZE_BITS 1
/* /*
...@@ -32,7 +41,9 @@ typedef u16 ntfschar; ...@@ -32,7 +41,9 @@ typedef u16 ntfschar;
* and VCN, to allow for type checking and better code readability. * and VCN, to allow for type checking and better code readability.
*/ */
typedef s64 VCN; typedef s64 VCN;
typedef sle64 leVCN;
typedef s64 LCN; typedef s64 LCN;
typedef sle64 leLCN;
/* /*
* The NTFS journal $LogFile uses log sequence numbers which are signed 64-bit * The NTFS journal $LogFile uses log sequence numbers which are signed 64-bit
...@@ -40,6 +51,7 @@ typedef s64 LCN; ...@@ -40,6 +51,7 @@ typedef s64 LCN;
* code readability. * code readability.
*/ */
typedef s64 LSN; typedef s64 LSN;
typedef sle64 leLSN;
/** /**
* runlist_element - in memory vcn to lcn mapping array element * runlist_element - in memory vcn to lcn mapping array element
......
...@@ -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