Merge endianness fixes required for the strict endians code to compile.

Conflicts:
	libntfs-3g/attrib.c
	libntfs-3g/dir.c
	libntfs-3g/logfile.c
	libntfs-3g/volume.c
	ntfsprogs/ntfscp.c
	ntfsprogs/ntfsdump_logfile.c
	ntfsprogs/ntfsfallocate.c
	ntfsprogs/ntfsfix.c
	ntfsprogs/ntfsinfo.c
	ntfsprogs/ntfsresize.c
	ntfsprogs/ntfstruncate.c
edge.strict_endians
Erik Larsson 2016-01-28 09:21:09 +01:00
commit 760ddd62cf
40 changed files with 389 additions and 375 deletions

View File

@ -197,7 +197,7 @@ extern int ntfs_inode_nidata_hash(const struct CACHED_GENERIC *item);
extern ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni,
const MFT_REF mref);
const leMFT_REF mref);
extern int ntfs_inode_attach_all_extents(ntfs_inode *ni);

View File

@ -902,7 +902,7 @@ typedef enum {
FILE_ATTR_READONLY = const_cpu_to_le32(0x00000001),
FILE_ATTR_HIDDEN = const_cpu_to_le32(0x00000002),
FILE_ATTR_SYSTEM = const_cpu_to_le32(0x00000004),
/* Old DOS volid. Unused in NT. = cpu_to_le32(0x00000008), */
/* Old DOS volid. Unused in NT. = const_cpu_to_le32(0x00000008), */
FILE_ATTR_DIRECTORY = const_cpu_to_le32(0x00000010),
/* FILE_ATTR_DIRECTORY is not considered valid in NT. It is reserved

View File

@ -102,7 +102,7 @@ static __inline__ ntfs_time timespec2ntfs(struct timespec spec)
units = (s64)spec.tv_sec * 10000000
+ NTFS_TIME_OFFSET + spec.tv_nsec/100;
return (cpu_to_le64(units));
return (cpu_to_sle64(units));
}
/*

View File

@ -96,7 +96,7 @@ static void NAttrSetFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
na->ni->flags = le32_or(na->ni->flags, flag);
else
ntfs_log_trace("Denied setting flag %d for not unnamed data "
"attribute\n", flag);
"attribute\n", le32_to_cpu(flag));
}
static void NAttrClearFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
@ -405,7 +405,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
le16 cs;
ntfs_log_enter("Entering for inode %lld, attr 0x%x.\n",
(unsigned long long)ni->mft_no, type);
(unsigned long long)ni->mft_no, le32_to_cpu(type));
if (!ni || !ni->vol || !ni->mrec) {
errno = EINVAL;
@ -452,7 +452,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
* does not detect or fix them so we need to cope with it, too.
*/
if (le32_eq(type, AT_ATTRIBUTE_LIST))
a->flags = 0;
a->flags = const_cpu_to_le16(0);
if (le32_eq(type, AT_DATA)
&& (a->non_resident ? sle64_cmpz(a->initialized_size) : le32_cmpz(a->value_length))) {
@ -484,7 +484,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
errno = EIO;
ntfs_log_perror("Inode %lld has corrupt attribute flags "
"(0x%x <> 0x%x)",(unsigned long long)ni->mft_no,
a->flags, na->ni->flags);
le16_to_cpu(a->flags), le32_to_cpu(na->ni->flags));
goto put_err_out;
}
@ -494,7 +494,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
errno = EIO;
ntfs_log_perror("Compressed inode %lld attr 0x%x has "
"no compression unit",
(unsigned long long)ni->mft_no, type);
(unsigned long long)ni->mft_no, le32_to_cpu(type));
goto put_err_out;
}
ntfs_attr_init(na, TRUE, a->flags,
@ -561,7 +561,7 @@ int ntfs_attr_map_runlist(ntfs_attr *na, VCN vcn)
ntfs_attr_search_ctx *ctx;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, vcn 0x%llx.\n",
(unsigned long long)na->ni->mft_no, na->type, (long long)vcn);
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type), (long long)vcn);
lcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);
if (lcn >= 0 || lcn == LCN_HOLE || lcn == LCN_ENOENT)
@ -643,7 +643,7 @@ static int ntfs_attr_map_partial_runlist(ntfs_attr *na, VCN vcn)
rl = na->rl;
if (rl) {
na->rl = rl;
highest_vcn = le64_to_cpu(a->highest_vcn);
highest_vcn = sle64_to_cpu(a->highest_vcn);
if (highest_vcn < needed) {
/* corruption detection on unchanged runlists */
if (newrunlist
@ -704,7 +704,7 @@ int ntfs_attr_map_whole_runlist(ntfs_attr *na)
int not_mapped;
ntfs_log_enter("Entering for inode %llu, attr 0x%x.\n",
(unsigned long long)na->ni->mft_no, na->type);
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type));
/* avoid multiple full runlist mappings */
if (NAttrFullyMapped(na)) {
@ -831,7 +831,7 @@ LCN ntfs_attr_vcn_to_lcn(ntfs_attr *na, const VCN vcn)
return (LCN)LCN_EINVAL;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", (unsigned long
long)na->ni->mft_no, na->type);
long)na->ni->mft_no, le32_to_cpu(na->type));
retry:
/* Convert vcn to lcn. If that fails map the runlist and retry once. */
lcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);
@ -883,7 +883,7 @@ runlist_element *ntfs_attr_find_vcn(ntfs_attr *na, const VCN vcn)
}
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, vcn %llx\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)vcn);
retry:
rl = na->rl;
@ -1040,7 +1040,7 @@ res_err_out:
count--;
total2++;
} else {
*(u16*)((u8*)b+count-2) = cpu_to_le16(efs_padding_length);
*(le16*)((u8*)b+count-2) = cpu_to_le16(efs_padding_length);
count -= 2;
total2 +=2;
}
@ -1176,7 +1176,7 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
ntfs_log_enter("Entering for inode %lld attr 0x%x pos %lld count "
"%lld\n", (unsigned long long)na->ni->mft_no,
na->type, (long long)pos, (long long)count);
le32_to_cpu(na->type), (long long)pos, (long long)count);
ret = ntfs_attr_pread_i(na, pos, count, b);
@ -1800,7 +1800,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
BOOL compressed;
ntfs_log_enter("Entering for inode %lld, attr 0x%x, pos 0x%llx, count "
"0x%llx.\n", (long long)na->ni->mft_no, na->type,
"0x%llx.\n", (long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)pos, (long long)count);
if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) {
@ -2349,7 +2349,7 @@ int ntfs_attr_pclose(ntfs_attr *na)
BOOL compressed;
ntfs_log_enter("Entering for inode 0x%llx, attr 0x%x.\n",
na->ni->mft_no, na->type);
na->ni->mft_no, le32_to_cpu(na->type));
if (!na || !na->ni || !na->ni->vol) {
errno = EINVAL;
@ -2568,7 +2568,7 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt,
BOOL warn;
ntfs_log_trace("Entering for inode 0x%llx, attr type 0x%x, pos 0x%llx.\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)pos);
if (bk_cnt < 0 || bk_size % NTFS_BLOCK_SIZE) {
errno = EINVAL;
@ -2624,7 +2624,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
s64 written, i;
ntfs_log_trace("Entering for inode 0x%llx, attr type 0x%x, pos 0x%llx.\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)pos);
if (bk_cnt < 0 || bk_size % NTFS_BLOCK_SIZE) {
errno = EINVAL;
@ -2742,7 +2742,7 @@ static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
ntfschar *upcase;
u32 upcase_len;
ntfs_log_trace("attribute type 0x%x.\n", type);
ntfs_log_trace("attribute type 0x%x.\n", le32_to_cpu(type));
if (ctx->ntfs_ino) {
vol = ctx->ntfs_ino->vol;
@ -2967,7 +2967,7 @@ static int ntfs_external_attr_find(ATTR_TYPES type, const ntfschar *name,
ni = ctx->ntfs_ino;
base_ni = ctx->base_ntfs_ino;
ntfs_log_trace("Entering for inode %lld, attribute type 0x%x.\n",
(unsigned long long)ni->mft_no, type);
(unsigned long long)ni->mft_no, le32_to_cpu(type));
if (!base_ni) {
/* First call happens with the base mft record. */
base_ni = ctx->base_ntfs_ino = ctx->ntfs_ino;
@ -3350,7 +3350,7 @@ int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
ntfs_inode *base_ni;
int ret = -1;
ntfs_log_enter("Entering for attribute type 0x%x\n", type);
ntfs_log_enter("Entering for attribute type 0x%x\n", le32_to_cpu(type));
if (!ctx || !ctx->mrec || !ctx->attr || (name && name != AT_UNNAMED &&
(!ctx->ntfs_ino || !(vol = ctx->ntfs_ino->vol) ||
@ -3518,7 +3518,7 @@ ATTR_DEF *ntfs_attr_find_in_attrdef(const ntfs_volume *vol,
if (!vol || !vol->attrdef || le32_cmpz(type)) {
errno = EINVAL;
ntfs_log_perror("%s: type=%d", __FUNCTION__, type);
ntfs_log_perror("%s: type=%d", __FUNCTION__, le32_to_cpu(type));
return NULL;
}
for (ad = vol->attrdef; (u8*)ad - (u8*)vol->attrdef <
@ -3533,7 +3533,7 @@ ATTR_DEF *ntfs_attr_find_in_attrdef(const ntfs_volume *vol,
break;
}
errno = ENOENT;
ntfs_log_perror("%s: type=%d", __FUNCTION__, type);
ntfs_log_perror("%s: type=%d", __FUNCTION__, le32_to_cpu(type));
return NULL;
}
@ -3594,7 +3594,7 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type,
((max_size > 0) && (size > max_size))) {
errno = ERANGE;
ntfs_log_perror("Attr type %d size check failed (min,size,max="
"%lld,%lld,%lld)", type, (long long)min_size,
"%lld,%lld,%lld)", le32_to_cpu(type), (long long)min_size,
(long long)size, (long long)max_size);
return -1;
}
@ -3774,7 +3774,7 @@ int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
ntfs_inode *base_ni;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, flags 0x%x.\n",
(long long) ni->mft_no, (unsigned) type, (unsigned) data_flags);
(long long) ni->mft_no, (unsigned) le32_to_cpu(type), (unsigned) le16_to_cpu(data_flags));
if (!ni || (!name && name_len)) {
errno = EINVAL;
@ -3828,7 +3828,7 @@ int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
a->non_resident = 0;
a->name_length = name_len;
a->name_offset = (name_len
? cpu_to_le16(offsetof(ATTR_RECORD, resident_end))
? const_cpu_to_le16(offsetof(ATTR_RECORD, resident_end))
: const_cpu_to_le16(0));
a->flags = data_flags;
a->instance = m->next_attr_instance;
@ -3907,8 +3907,8 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, lowest_vcn %lld, "
"dataruns_size %d, flags 0x%x.\n",
(long long) ni->mft_no, (unsigned) type,
(long long) lowest_vcn, dataruns_size, (unsigned) flags);
(long long) ni->mft_no, (unsigned) le32_to_cpu(type),
(long long) lowest_vcn, dataruns_size, (unsigned) le16_to_cpu(flags));
if (!ni || dataruns_size <= 0 || (!name && name_len)) {
errno = EINVAL;
@ -3935,7 +3935,7 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
if (!ntfs_attr_find(type, name, name_len, CASE_SENSITIVE, NULL, 0,
ctx)) {
err = EEXIST;
ntfs_log_perror("Attribute 0x%x already present", type);
ntfs_log_perror("Attribute 0x%x already present", le32_to_cpu(type));
goto put_err_out;
}
if (errno != ENOENT) {
@ -3974,10 +3974,10 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
? STANDARD_COMPRESSION_UNIT : 0;
/* If @lowest_vcn == 0, than setup empty attribute. */
if (!lowest_vcn) {
a->highest_vcn = cpu_to_sle64(-1);
a->allocated_size = 0;
a->data_size = 0;
a->initialized_size = 0;
a->highest_vcn = const_cpu_to_sle64(-1);
a->allocated_size = const_cpu_to_sle64(0);
a->data_size = const_cpu_to_sle64(0);
a->initialized_size = const_cpu_to_sle64(0);
/* Set empty mapping pairs. */
*((u8*)a + le16_to_cpu(a->mapping_pairs_offset)) = 0;
}
@ -4196,7 +4196,7 @@ int ntfs_attr_add(ntfs_inode *ni, ATTR_TYPES type,
}
ntfs_log_trace("Entering for inode %lld, attr %x, size %lld.\n",
(long long)ni->mft_no, type, (long long)size);
(long long)ni->mft_no, le32_to_cpu(type), (long long)size);
if (ni->nr_extents == -1)
ni = ni->base_ni;
@ -4418,7 +4418,7 @@ int ntfs_attr_rm(ntfs_attr *na)
}
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n",
(long long) na->ni->mft_no, na->type);
(long long) na->ni->mft_no, le32_to_cpu(na->type));
/* Free cluster allocation. */
if (NAttrNonResident(na)) {
@ -4766,7 +4766,7 @@ int ntfs_attr_make_non_resident(ntfs_attr *na,
int mp_size, mp_ofs, name_ofs, arec_size, err;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", (unsigned long
long)na->ni->mft_no, na->type);
long)na->ni->mft_no, le32_to_cpu(na->type));
/* Some preliminary sanity checking. */
if (NAttrNonResident(na)) {
@ -4874,7 +4874,7 @@ int ntfs_attr_make_non_resident(ntfs_attr *na,
a->name_offset = cpu_to_le16(name_ofs);
/* Setup the fields specific to non-resident attributes. */
a->lowest_vcn = cpu_to_sle64(0);
a->lowest_vcn = const_cpu_to_sle64(0);
a->highest_vcn = cpu_to_sle64((new_allocated_size - 1) >>
vol->cluster_size_bits);
@ -4891,7 +4891,7 @@ int ntfs_attr_make_non_resident(ntfs_attr *na,
if (le16_eq(le16_and(a->flags, ATTR_COMPRESSION_MASK), ATTR_IS_COMPRESSED)) {
/* support only ATTR_IS_COMPRESSED compression mode */
a->compression_unit = STANDARD_COMPRESSION_UNIT;
a->compressed_size = const_cpu_to_le64(0);
a->compressed_size = const_cpu_to_sle64(0);
} else {
a->compression_unit = 0;
a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK));
@ -4960,7 +4960,7 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
int err, ret = STATUS_ERROR;
ntfs_log_trace("Inode 0x%llx attr 0x%x new size %lld\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)newsize);
/* Get the attribute record that needs modification. */
@ -5263,7 +5263,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
s64 arec_size, bytes_read;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", (unsigned long
long)na->ni->mft_no, na->type);
long)na->ni->mft_no, le32_to_cpu(na->type));
/* Should be called for the first extent of the attribute. */
if (sle64_to_cpu(a->lowest_vcn)) {
@ -5337,7 +5337,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
/* Convert the attribute record to describe a resident attribute. */
a->non_resident = 0;
a->flags = 0;
a->flags = const_cpu_to_le16(0);
a->value_length = cpu_to_le32(na->data_size);
a->value_offset = cpu_to_le16(val_ofs);
/*
@ -5425,7 +5425,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m,
int sparse, ret = 0;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x\n",
(unsigned long long)na->ni->mft_no, na->type);
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type));
if (!sle64_cmpz(a->lowest_vcn))
goto out;
@ -5568,7 +5568,7 @@ retry:
}
ntfs_log_trace("Entering for inode %llu, attr 0x%x\n",
(unsigned long long)na->ni->mft_no, na->type);
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type));
if (!NAttrNonResident(na)) {
errno = EINVAL;
@ -5997,7 +5997,7 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize)
int err;
ntfs_log_trace("Inode 0x%llx attr 0x%x new size %lld\n", (unsigned long long)
na->ni->mft_no, na->type, (long long)newsize);
na->ni->mft_no, le32_to_cpu(na->type), (long long)newsize);
vol = na->ni->vol;
@ -6155,7 +6155,7 @@ static int ntfs_non_resident_attr_expand_i(ntfs_attr *na, const s64 newsize,
int err;
ntfs_log_trace("Inode %lld, attr 0x%x, new size %lld old size %lld\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)newsize, (long long)na->data_size);
vol = na->ni->vol;
@ -6426,7 +6426,7 @@ static int ntfs_attr_truncate_i(ntfs_attr *na, const s64 newsize,
}
ntfs_log_enter("Entering for inode %lld, attr 0x%x, size %lld\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)newsize);
if (na->data_size == newsize) {
@ -6762,7 +6762,7 @@ int ntfs_attr_shrink_size(ntfs_inode *ni, ntfschar *stream_name,
if (a->non_resident
&& (sle64_to_cpu(a->initialized_size) > offset)) {
a->initialized_size = cpu_to_le64(offset);
a->initialized_size = cpu_to_sle64(offset);
a->data_size = a->initialized_size;
}
res = 0;
@ -6811,7 +6811,7 @@ int ntfs_attr_remove(ntfs_inode *ni, const ATTR_TYPES type, ntfschar *name,
/* do not log removal of non-existent stream */
if (!le32_eq(type, AT_DATA)) {
ntfs_log_perror("Failed to open attribute 0x%02x of inode "
"0x%llx", type, (unsigned long long)ni->mft_no);
"0x%llx", le32_to_cpu(type), (unsigned long long)ni->mft_no);
}
return -1;
}
@ -6819,7 +6819,7 @@ int ntfs_attr_remove(ntfs_inode *ni, const ATTR_TYPES type, ntfschar *name,
ret = ntfs_attr_rm(na);
if (ret)
ntfs_log_perror("Failed to remove attribute 0x%02x of inode "
"0x%llx", type, (unsigned long long)ni->mft_no);
"0x%llx", le32_to_cpu(type), (unsigned long long)ni->mft_no);
ntfs_attr_close(na);
return ret;

View File

@ -107,7 +107,7 @@ int ntfs_attrlist_need(ntfs_inode *ni)
int ntfs_attrlist_entry_add(ntfs_inode *ni, ATTR_RECORD *attr)
{
ATTR_LIST_ENTRY *ale;
MFT_REF mref;
leMFT_REF mref;
ntfs_attr *na = NULL;
ntfs_attr_search_ctx *ctx;
u8 *new_al;
@ -150,7 +150,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *ni, ATTR_RECORD *attr)
if (!ntfs_attr_lookup(attr->type, (attr->name_length) ? (ntfschar*)
((u8*)attr + le16_to_cpu(attr->name_offset)) :
AT_UNNAMED, attr->name_length, CASE_SENSITIVE,
(attr->non_resident) ? le64_to_cpu(attr->lowest_vcn) :
(attr->non_resident) ? sle64_to_cpu(attr->lowest_vcn) :
0, (attr->non_resident) ? NULL : ((u8*)attr +
le16_to_cpu(attr->value_offset)), (attr->non_resident) ?
0 : le32_to_cpu(attr->value_length), ctx)) {
@ -193,7 +193,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *ni, ATTR_RECORD *attr)
if (attr->non_resident)
ale->lowest_vcn = attr->lowest_vcn;
else
ale->lowest_vcn = 0;
ale->lowest_vcn = const_cpu_to_sle64(0);
ale->mft_reference = mref;
ale->instance = attr->instance;
memcpy(ale->name, (u8 *)attr + le16_to_cpu(attr->name_offset),
@ -265,7 +265,7 @@ int ntfs_attrlist_entry_rm(ntfs_attr_search_ctx *ctx)
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, lowest_vcn %lld.\n",
(long long) ctx->ntfs_ino->mft_no,
(unsigned) le32_to_cpu(ctx->al_entry->type),
(long long) le64_to_cpu(ctx->al_entry->lowest_vcn));
(long long) sle64_to_cpu(ctx->al_entry->lowest_vcn));
if (!NInoAttrList(base_ni)) {
ntfs_log_trace("Attribute list isn't present.\n");

View File

@ -719,7 +719,7 @@ s64 ntfs_compressed_attr_pread(ntfs_attr *na, s64 pos, s64 count, void *b)
unsigned int nr_cbs, cb_clusters;
ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, pos 0x%llx, count 0x%llx.\n",
(unsigned long long)na->ni->mft_no, na->type,
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)pos, (long long)count);
data_flags = na->data_flags;
compression = le32_and(na->ni->flags, FILE_ATTR_COMPRESSED);

View File

@ -384,7 +384,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
}
/* 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));
descend_into_child_node:
@ -496,7 +496,7 @@ descend_into_child_node:
goto close_err_out;
}
/* Child node present, descend into it. */
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)
goto descend_into_child_node;
ntfs_log_error("Negative child node vcn in directory inode "
@ -1531,7 +1531,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
si->last_access_time = ni->last_access_time;
if (!le32_cmpz(securid)) {
set_nino_flag(ni, v3_Extensions);
ni->owner_id = si->owner_id = 0;
ni->owner_id = si->owner_id = const_cpu_to_le32(0);
ni->security_id = si->security_id = securid;
ni->quota_charged = si->quota_charged = const_cpu_to_le64(0);
ni->usn = si->usn = const_cpu_to_le64(0);
@ -1604,7 +1604,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
ir->index.allocated_size = cpu_to_le32(index_len);
ie = (INDEX_ENTRY*)((u8*)ir + sizeof(INDEX_ROOT));
ie->length = const_cpu_to_le16(sizeof(INDEX_ENTRY_HEADER));
ie->key_length = 0;
ie->key_length = const_cpu_to_le16(0);
ie->ie_flags = INDEX_ENTRY_END;
/* Add INDEX_ROOT attribute to inode. */
if (ntfs_attr_add(ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4,
@ -1691,7 +1691,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
fn->last_mft_change_time = ni->last_mft_change_time;
fn->last_access_time = ni->last_access_time;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
fn->data_size = fn->allocated_size = const_cpu_to_le64(0);
fn->data_size = fn->allocated_size = const_cpu_to_sle64(0);
else {
fn->data_size = cpu_to_sle64(ni->data_size);
fn->allocated_size = cpu_to_sle64(ni->allocated_size);
@ -1711,7 +1711,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
goto err_out;
}
/* Set hard links count and directory flag. */
ni->mrec->link_count = cpu_to_le16(1);
ni->mrec->link_count = const_cpu_to_le16(1);
if (S_ISDIR(type))
ni->mrec->flags = le16_or(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY);
ntfs_inode_mark_dirty(ni);
@ -2186,7 +2186,7 @@ static int ntfs_link_i(ntfs_inode *ni, ntfs_inode *dir_ni, const ntfschar *name,
fn->file_attributes = ni->flags;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
fn->file_attributes = le32_or(fn->file_attributes, FILE_ATTR_I30_INDEX_PRESENT);
fn->data_size = fn->allocated_size = const_cpu_to_le64(0);
fn->data_size = fn->allocated_size = const_cpu_to_sle64(0);
} else {
fn->allocated_size = cpu_to_sle64(ni->allocated_size);
fn->data_size = cpu_to_sle64(ni->data_size);

View File

@ -420,8 +420,8 @@ int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
NInoSetDirty(ni);
NInoFileNameSetDirty(ni);
ctx->attr->data_size = cpu_to_le64(newsize);
if (le64_to_cpu(ctx->attr->initialized_size) > newsize)
ctx->attr->data_size = cpu_to_sle64(newsize);
if (sle64_to_cpu(ctx->attr->initialized_size) > newsize)
ctx->attr->initialized_size = ctx->attr->data_size;
ctx->attr->flags = le16_or(ctx->attr->flags, ATTR_IS_ENCRYPTED);
if (close_ctx)

View File

@ -191,9 +191,9 @@ void ntfs_index_ctx_reinit(ntfs_index_context *icx)
};
}
static VCN *ntfs_ie_get_vcn_addr(INDEX_ENTRY *ie)
static leVCN *ntfs_ie_get_vcn_addr(INDEX_ENTRY *ie)
{
return (VCN *)((u8 *)ie + le16_to_cpu(ie->length) - sizeof(VCN));
return (leVCN *)((u8 *)ie + le16_to_cpu(ie->length) - sizeof(leVCN));
}
/**
@ -338,7 +338,7 @@ static void ntfs_ie_delete(INDEX_HEADER *ih, INDEX_ENTRY *ie)
static void ntfs_ie_set_vcn(INDEX_ENTRY *ie, VCN vcn)
{
*ntfs_ie_get_vcn_addr(ie) = cpu_to_le64(vcn);
*ntfs_ie_get_vcn_addr(ie) = cpu_to_sle64(vcn);
}
/**
@ -811,17 +811,17 @@ static INDEX_BLOCK *ntfs_ib_alloc(VCN ib_vcn, u32 ib_size,
return NULL;
ib->magic = magic_INDX;
ib->usa_ofs = cpu_to_le16(sizeof(INDEX_BLOCK));
ib->usa_ofs = const_cpu_to_le16(sizeof(INDEX_BLOCK));
ib->usa_count = cpu_to_le16(ib_size / NTFS_BLOCK_SIZE + 1);
/* Set USN to 1 */
*(u16 *)((char *)ib + le16_to_cpu(ib->usa_ofs)) = cpu_to_le16(1);
ib->lsn = cpu_to_le64(0);
*(le16 *)((char *)ib + le16_to_cpu(ib->usa_ofs)) = const_cpu_to_le16(1);
ib->lsn = const_cpu_to_sle64(0);
ib->index_block_vcn = cpu_to_sle64(ib_vcn);
ib->index.entries_offset = cpu_to_le32((ih_size +
le16_to_cpu(ib->usa_count) * 2 + 7) & ~7);
ib->index.index_length = 0;
ib->index.index_length = const_cpu_to_le32(0);
ib->index.allocated_size = cpu_to_le32(ib_size -
(sizeof(INDEX_BLOCK) - ih_size));
ib->index.ih_flags = node_type;
@ -1160,7 +1160,7 @@ retry :
ie = ntfs_ie_get_first(&ir->index);
ie->ie_flags = le16_or(ie->ie_flags, INDEX_ENTRY_NODE);
ie->length = cpu_to_le16(sizeof(INDEX_ENTRY_HEADER) + sizeof(VCN));
ie->length = const_cpu_to_le16(sizeof(INDEX_ENTRY_HEADER) + sizeof(VCN));
ir->index.ih_flags = LARGE_INDEX;
ir->index.index_length = cpu_to_le32(le32_to_cpu(ir->index.entries_offset)
@ -2042,7 +2042,7 @@ static INDEX_ENTRY *ntfs_index_walk_up(INDEX_ENTRY *ie,
INDEX_ENTRY *ntfs_index_next(INDEX_ENTRY *ie, ntfs_index_context *ictx)
{
INDEX_ENTRY *next;
int flags;
le16 flags;
/*
* lookup() may have returned an invalid node

View File

@ -570,7 +570,7 @@ int ntfs_inode_close(ntfs_inode *ni)
* Note, extent inodes are never closed directly. They are automatically
* disposed off by the closing of the base inode.
*/
ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni, const MFT_REF mref)
ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni, const leMFT_REF mref)
{
u64 mft_no = MREF_LE(mref);
VCN extent_vcn;
@ -806,7 +806,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni)
goto err_out;
}
/* Collect the reparse tag, if any */
reparse_tag = cpu_to_le32(0);
reparse_tag = const_cpu_to_le32(0);
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!ntfs_attr_lookup(AT_REPARSE_POINT, NULL,
0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
@ -874,7 +874,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni)
le32_and(ni->flags, FILE_ATTR_VALID_FLAGS));
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
fnx->data_size = fnx->allocated_size
= const_cpu_to_le64(0);
= const_cpu_to_sle64(0);
else {
fnx->allocated_size = cpu_to_sle64(ni->allocated_size);
fnx->data_size = cpu_to_sle64(ni->data_size);
@ -1168,7 +1168,7 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni)
if (ctx->attr->non_resident)
ale->lowest_vcn = ctx->attr->lowest_vcn;
else
ale->lowest_vcn = 0;
ale->lowest_vcn = const_cpu_to_sle64(0);
ale->mft_reference = MK_LE_MREF(ni->mft_no,
le16_to_cpu(ni->mrec->sequence_number));
ale->instance = ctx->attr->instance;
@ -1206,7 +1206,7 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni)
/* Add $ATTRIBUTE_LIST to mft record. */
if (ntfs_resident_attr_record_add(ni,
AT_ATTRIBUTE_LIST, NULL, 0, NULL, 0, 0) < 0) {
AT_ATTRIBUTE_LIST, NULL, 0, NULL, 0, const_cpu_to_le16(0)) < 0) {
err = errno;
ntfs_log_perror("Couldn't add $ATTRIBUTE_LIST to MFT");
goto rollback;
@ -1477,18 +1477,18 @@ int ntfs_inode_get_times(ntfs_inode *ni, char *value, size_t size)
le16_to_cpu(ctx->attr->value_offset));
if (value && (size >= 8)) {
times = (u64*)value;
times[0] = le64_to_cpu(std_info->creation_time);
times[0] = sle64_to_cpu(std_info->creation_time);
ret = 8;
if (size >= 16) {
times[1] = le64_to_cpu(std_info->last_data_change_time);
times[1] = sle64_to_cpu(std_info->last_data_change_time);
ret = 16;
}
if (size >= 24) {
times[2] = le64_to_cpu(std_info->last_access_time);
times[2] = sle64_to_cpu(std_info->last_access_time);
ret = 24;
}
if (size >= 32) {
times[3] = le64_to_cpu(std_info->last_mft_change_time);
times[3] = sle64_to_cpu(std_info->last_mft_change_time);
ret = 32;
}
} else
@ -1551,16 +1551,16 @@ int ntfs_inode_set_times(ntfs_inode *ni, const char *value, size_t size,
* return sub-second times in getattr()
*/
set_nino_flag(ni, TimesSet);
std_info->creation_time = cpu_to_le64(times[0]);
std_info->creation_time = cpu_to_sle64(times[0]);
ni->creation_time
= std_info->creation_time;
if (size >= 16) {
std_info->last_data_change_time = cpu_to_le64(times[1]);
std_info->last_data_change_time = cpu_to_sle64(times[1]);
ni->last_data_change_time
= std_info->last_data_change_time;
}
if (size >= 24) {
std_info->last_access_time = cpu_to_le64(times[2]);
std_info->last_access_time = cpu_to_sle64(times[2]);
ni->last_access_time
= std_info->last_access_time;
}
@ -1578,13 +1578,13 @@ int ntfs_inode_set_times(ntfs_inode *ni, const char *value, size_t size,
fn = (FILE_NAME_ATTR*)((u8 *)ctx->attr +
le16_to_cpu(ctx->attr->value_offset));
fn->creation_time
= cpu_to_le64(times[0]);
= cpu_to_sle64(times[0]);
if (size >= 16)
fn->last_data_change_time
= cpu_to_le64(times[1]);
= cpu_to_sle64(times[1]);
if (size >= 24)
fn->last_access_time
= cpu_to_le64(times[2]);
= cpu_to_sle64(times[2]);
fn->last_mft_change_time = now;
cnt++;
}

View File

@ -676,7 +676,7 @@ int ntfs_cluster_free(ntfs_volume *vol, ntfs_attr *na, VCN start_vcn, s64 count)
ntfs_log_enter("Entering for inode 0x%llx, attr 0x%x, count 0x%llx, "
"vcn 0x%llx.\n", (unsigned long long)na->ni->mft_no,
na->type, (long long)count, (long long)start_vcn);
le32_to_cpu(na->type), (long long)count, (long long)start_vcn);
rl = ntfs_attr_find_vcn(na, start_vcn);
if (!rl) {

View File

@ -90,10 +90,10 @@ static BOOL ntfs_check_restart_page_header(RESTART_PAGE_HEADER *rp, s64 pos)
* Windows 8, and we will refuse to mount.
* Nevertheless, do all the relevant checks before rejecting.
*/
if ((!sle16_eq(rp->major_ver, const_cpu_to_le16(1))
|| !sle16_eq(rp->minor_ver, const_cpu_to_le16(1)))
&& (!sle16_eq(rp->major_ver, const_cpu_to_le16(2))
|| !sle16_eq(rp->minor_ver, const_cpu_to_le16(0)))) {
if ((!sle16_eq(rp->major_ver, const_cpu_to_sle16(1))
|| !sle16_eq(rp->minor_ver, const_cpu_to_sle16(1)))
&& (!sle16_eq(rp->major_ver, const_cpu_to_sle16(2))
|| !sle16_eq(rp->minor_ver, const_cpu_to_sle16(0)))) {
ntfs_log_error("$LogFile version %i.%i is not "
"supported.\n (This driver supports version "
"1.1 and 2.0 only.)\n",

View File

@ -355,7 +355,7 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref,
* Set the NTFS 3.1+ specific fields while we know that the
* volume version is 3.1+.
*/
mrec->reserved = cpu_to_le16(0);
mrec->reserved = const_cpu_to_le16(0);
mrec->mft_record_number = cpu_to_le32(MREF(mref));
}
mrec->magic = magic_FILE;
@ -363,7 +363,7 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref,
mrec->usa_count = cpu_to_le16(vol->mft_record_size /
NTFS_BLOCK_SIZE + 1);
else {
mrec->usa_count = cpu_to_le16(1);
mrec->usa_count = const_cpu_to_le16(1);
ntfs_log_error("Sector size is bigger than MFT record size. "
"Setting usa_count to 1. If Windows chkdsk "
"reports this as corruption, please email %s "
@ -372,14 +372,14 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref,
"Thank you.\n", NTFS_DEV_LIST);
}
/* Set the update sequence number to 1. */
*(u16*)((u8*)mrec + le16_to_cpu(mrec->usa_ofs)) = cpu_to_le16(1);
mrec->lsn = cpu_to_le64(0ull);
mrec->sequence_number = cpu_to_le16(1);
mrec->link_count = cpu_to_le16(0);
*(le16*)((u8*)mrec + le16_to_cpu(mrec->usa_ofs)) = const_cpu_to_le16(1);
mrec->lsn = const_cpu_to_sle64(0ll);
mrec->sequence_number = const_cpu_to_le16(1);
mrec->link_count = const_cpu_to_le16(0);
/* Aligned to 8-byte boundary. */
mrec->attrs_offset = cpu_to_le16((le16_to_cpu(mrec->usa_ofs) +
(le16_to_cpu(mrec->usa_count) << 1) + 7) & ~7);
mrec->flags = cpu_to_le16(0);
mrec->flags = const_cpu_to_le16(0);
/*
* Using attrs_offset plus eight bytes (for the termination attribute),
* aligned to 8-byte boundary.
@ -387,11 +387,11 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref,
mrec->bytes_in_use = cpu_to_le32((le16_to_cpu(mrec->attrs_offset) + 8 +
7) & ~7);
mrec->bytes_allocated = cpu_to_le32(vol->mft_record_size);
mrec->base_mft_record = cpu_to_le64((MFT_REF)0);
mrec->next_attr_instance = cpu_to_le16(0);
mrec->base_mft_record = const_cpu_to_le64((MFT_REF)0);
mrec->next_attr_instance = const_cpu_to_le16(0);
a = (ATTR_RECORD*)((u8*)mrec + le16_to_cpu(mrec->attrs_offset));
a->type = AT_END;
a->length = cpu_to_le32(0);
a->length = const_cpu_to_le32(0);
/* Finally, clear the unused part of the mft record. */
memset((u8*)a + 8, 0, vol->mft_record_size - ((u8*)a + 8 - (u8*)mrec));
return 0;
@ -1510,7 +1510,7 @@ found_free_rec:
ntfs_inode_mark_dirty(ni);
/* Initialize time, allocated and data size in ntfs_inode struct. */
ni->data_size = ni->allocated_size = 0;
ni->flags = 0;
ni->flags = const_cpu_to_le32(0);
ni->creation_time = ni->last_data_change_time =
ni->last_mft_change_time =
ni->last_access_time = ntfs_current_time();
@ -1814,7 +1814,7 @@ found_free_rec:
ntfs_inode_mark_dirty(ni);
/* Initialize time, allocated and data size in ntfs_inode struct. */
ni->data_size = ni->allocated_size = 0;
ni->flags = 0;
ni->flags = const_cpu_to_le32(0);
ni->creation_time = ni->last_data_change_time =
ni->last_mft_change_time =
ni->last_access_time = ntfs_current_time();

View File

@ -101,7 +101,7 @@ int ntfs_mst_post_read_fixup_warn(NTFS_RECORD *b, const u32 size,
errno = EIO;
ntfs_log_perror("Incomplete multi-sector transfer: "
"magic: 0x%08x size: %d usa_ofs: %d usa_count:"
" %d data: %d usn: %d", *(le32 *)b, size,
" %d data: %d usn: %d", le32_to_cpu(*(le32 *)b), size,
usa_ofs, usa_count, *data_pos, usn);
b->magic = magic_BAAD;
return -1;
@ -157,7 +157,8 @@ int ntfs_mst_post_read_fixup(NTFS_RECORD *b, const u32 size)
int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size)
{
u16 usa_ofs, usa_count, usn;
u16 *usa_pos, *data_pos;
le16 le_usn;
le16 *usa_pos, *data_pos;
ntfs_log_trace("Entering\n");
@ -181,7 +182,7 @@ int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size)
return -1;
}
/* 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
* (skipping 0 and -1, i.e. 0xffff).
@ -189,10 +190,10 @@ int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size)
usn = le16_to_cpup(usa_pos) + 1;
if (usn == 0xffff || !usn)
usn = 1;
usn = cpu_to_le16(usn);
*usa_pos = usn;
/* Position in data of first u16 that needs fixing up. */
data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1;
le_usn = cpu_to_le16(usn);
*usa_pos = le_usn;
/* Position in data of first le16 that needs fixing up. */
data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1;
/* Fixup all sectors. */
while (usa_count--) {
/*
@ -201,9 +202,9 @@ int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size)
*/
*(++usa_pos) = *data_pos;
/* Apply fixup to data. */
*data_pos = usn;
*data_pos = le_usn;
/* Increment position in data as well. */
data_pos += NTFS_BLOCK_SIZE/sizeof(u16);
data_pos += NTFS_BLOCK_SIZE/sizeof(le16);
}
return 0;
}

View File

@ -195,7 +195,7 @@ static u64 ntfs_fix_file_name(ntfs_inode *dir_ni, ntfschar *uname,
uname[i] = found->file_name[i];
} else {
for (i=0; i<found->file_name_length; i++)
uname[i] = vol->locase[found->file_name[i]];
uname[i] = vol->locase[le16_to_cpu(found->file_name[i])];
}
}
}

View File

@ -244,7 +244,7 @@ int ntfs_names_full_collate(const ntfschar *name1, const u32 name1_len,
*/
int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
{
ntfschar c1, c2;
u16 c1, c2;
size_t i;
#ifdef DEBUG
@ -360,7 +360,7 @@ ntfschar *ntfs_ucsndup(const ntfschar *s, u32 maxlen)
dst = ntfs_malloc((len + 1) * sizeof(ntfschar));
if (dst) {
memcpy(dst, s, len * sizeof(ntfschar));
dst[len] = cpu_to_le16(L'\0');
dst[len] = const_cpu_to_le16(L'\0');
}
return dst;
}
@ -1050,7 +1050,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs)
}
#endif
/* Now write the NULL character. */
ucs[o] = cpu_to_le16(L'\0');
ucs[o] = const_cpu_to_le16(L'\0');
*outs = ucs;
return o;
err_out:

View File

@ -963,13 +963,13 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
if (!le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if (ntfs_is_baad_recordp(mrec)) {
if (ntfs_is_baad_recordp(&mrec->magic)) {
ntfs_log_error("$MFT error: Incomplete multi "
"sector transfer detected in "
"'%s'.\n", s);
goto io_error_exit;
}
if (!ntfs_is_mft_recordp(mrec)) {
if (!ntfs_is_mft_recordp(&mrec->magic)) {
ntfs_log_error("$MFT error: Invalid mft "
"record for '%s'.\n", s);
goto io_error_exit;
@ -977,13 +977,13 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
}
mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
if (!le16_andz(mrec2->flags, MFT_RECORD_IN_USE)) {
if (ntfs_is_baad_recordp(mrec2)) {
if (ntfs_is_baad_recordp(&mrec2->magic)) {
ntfs_log_error("$MFTMirr error: Incomplete "
"multi sector transfer "
"detected in '%s'.\n", s);
goto io_error_exit;
}
if (!ntfs_is_mft_recordp(mrec2)) {
if (!ntfs_is_mft_recordp(&mrec2->magic)) {
ntfs_log_error("$MFTMirr error: Invalid mft "
"record for '%s'.\n", s);
goto io_error_exit;

View File

@ -1552,7 +1552,7 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
a->instance = m->next_attr_instance;
m->next_attr_instance = cpu_to_le16((le16_to_cpu(m->next_attr_instance)
+ 1) & 0xffff);
a->lowest_vcn = cpu_to_le64(0);
a->lowest_vcn = const_cpu_to_sle64(0);
a->highest_vcn = cpu_to_sle64(highest_vcn - 1LL);
a->mapping_pairs_offset = cpu_to_le16(hdr_size + ((name_len + 7) & ~7));
memset(a->reserved1, 0, sizeof(a->reserved1));
@ -1571,7 +1571,7 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
a->compression_unit = 4;
inited_size = val_len;
/* FIXME: Set the compressed size. */
a->compressed_size = cpu_to_le64(0);
a->compressed_size = const_cpu_to_sle64(0);
/* FIXME: Write out the compressed data. */
/* FIXME: err = build_mapping_pairs_compressed(); */
err = -EOPNOTSUPP;
@ -1745,7 +1745,7 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
a->instance = m->next_attr_instance;
m->next_attr_instance = cpu_to_le16((le16_to_cpu(m->next_attr_instance)
+ 1) & 0xffff);
a->lowest_vcn = cpu_to_le64(0);
a->lowest_vcn = const_cpu_to_sle64(0);
for (i = 0; rl[i].length; i++)
;
a->highest_vcn = cpu_to_sle64(rl[i].vcn - 1);
@ -1767,7 +1767,7 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
}
a->compression_unit = 4;
/* FIXME: Set the compressed size. */
a->compressed_size = cpu_to_le64(0);
a->compressed_size = const_cpu_to_sle64(0);
/* FIXME: Write out the compressed data. */
/* FIXME: err = build_mapping_pairs_compressed(); */
err = -EOPNOTSUPP;
@ -1926,17 +1926,17 @@ static int add_attr_std_info(MFT_RECORD *m, const FILE_ATTR_FLAGS flags,
si.last_mft_change_time = si.creation_time;
si.last_access_time = si.creation_time;
si.file_attributes = flags; /* already LE */
si.maximum_versions = cpu_to_le32(0);
si.version_number = cpu_to_le32(0);
si.class_id = cpu_to_le32(0);
si.maximum_versions = const_cpu_to_le32(0);
si.version_number = const_cpu_to_le32(0);
si.class_id = const_cpu_to_le32(0);
si.security_id = security_id;
if (!le32_eq(si.security_id, const_cpu_to_le32(0)))
sd_size = 72;
/* FIXME: $Quota support... */
si.owner_id = cpu_to_le32(0);
si.quota_charged = cpu_to_le64(0ULL);
si.owner_id = const_cpu_to_le32(0);
si.quota_charged = const_cpu_to_le64(0ULL);
/* FIXME: $UsnJrnl support... Not needed on fresh w2k3-volume */
si.usn = cpu_to_le64(0ULL);
si.usn = const_cpu_to_le64(0ULL);
/* NTFS 1.2: size of si = 48, NTFS 3.[01]: size of si = 72 */
err = insert_resident_attr_in_mft_record(m, AT_STANDARD_INFORMATION,
NULL, 0, CASE_SENSITIVE, const_cpu_to_le16(0),
@ -2055,7 +2055,7 @@ static int add_attr_file_name(MFT_RECORD *m, const leMFT_REF parent_dir,
}
if (packed_ea_size) {
fn->packed_ea_size = cpu_to_le16(packed_ea_size);
fn->reserved = cpu_to_le16(0);
fn->reserved = const_cpu_to_le16(0);
} else {
fn->reparse_point_tag = cpu_to_le32(reparse_point_tag);
}
@ -2481,12 +2481,12 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
}
/* Setup header. */
ia_val->magic = magic_INDX;
ia_val->usa_ofs = cpu_to_le16(sizeof(INDEX_ALLOCATION));
ia_val->usa_ofs = const_cpu_to_le16(sizeof(INDEX_ALLOCATION));
if (index_block_size >= NTFS_BLOCK_SIZE) {
ia_val->usa_count = cpu_to_le16(index_block_size /
NTFS_BLOCK_SIZE + 1);
} else {
ia_val->usa_count = cpu_to_le16(1);
ia_val->usa_count = const_cpu_to_le16(1);
ntfs_log_error("Sector size is bigger than index block size. "
"Setting usa_count to 1. If Windows chkdsk "
"reports this as corruption, please email %s "
@ -2496,9 +2496,9 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
}
/* Set USN to 1. */
*(le16*)((char*)ia_val + le16_to_cpu(ia_val->usa_ofs)) =
cpu_to_le16(1);
ia_val->lsn = cpu_to_le64(0);
ia_val->index_block_vcn = cpu_to_le64(0);
const_cpu_to_le16(1);
ia_val->lsn = const_cpu_to_sle64(0);
ia_val->index_block_vcn = const_cpu_to_sle64(0);
ia_val->index.ih_flags = LEAF_NODE;
/* Align to 8-byte boundary. */
ia_val->index.entries_offset = cpu_to_le32((sizeof(INDEX_HEADER) +
@ -2540,8 +2540,8 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
goto err_out;
}
/* Set VCN pointer to 0LL. */
*(leVCN*)((char*)re + cpu_to_le16(re->length) - sizeof(VCN)) =
cpu_to_le64(0);
*(leVCN*)((char*)re + le16_to_cpu(re->length) - sizeof(VCN)) =
const_cpu_to_sle64(0);
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)ia_val, index_block_size);
if (err) {
err = -errno;
@ -2930,9 +2930,9 @@ static int initialize_quota(MFT_RECORD *m)
idx_entry_q1_data->flags = QUOTA_FLAG_DEFAULT_LIMITS;
idx_entry_q1_data->bytes_used = const_cpu_to_le64(0x00);
idx_entry_q1_data->change_time = mkntfs_time();
idx_entry_q1_data->threshold = cpu_to_sle64(-1);
idx_entry_q1_data->limit = cpu_to_sle64(-1);
idx_entry_q1_data->exceeded_time = const_cpu_to_le64(0);
idx_entry_q1_data->threshold = const_cpu_to_sle64(-1);
idx_entry_q1_data->limit = const_cpu_to_sle64(-1);
idx_entry_q1_data->exceeded_time = const_cpu_to_sle64(0);
err = insert_index_entry_in_res_dir_index(idx_entry_q1, q1_size, m,
NTFS_INDEX_Q, 2, AT_UNUSED);
free(idx_entry_q1);
@ -2957,9 +2957,9 @@ static int initialize_quota(MFT_RECORD *m)
idx_entry_q2_data->flags = QUOTA_FLAG_DEFAULT_LIMITS;
idx_entry_q2_data->bytes_used = const_cpu_to_le64(0x00);
idx_entry_q2_data->change_time = mkntfs_time();
idx_entry_q2_data->threshold = cpu_to_sle64(-1);
idx_entry_q2_data->limit = cpu_to_sle64(-1);
idx_entry_q2_data->exceeded_time = const_cpu_to_le64(0);
idx_entry_q2_data->threshold = const_cpu_to_sle64(-1);
idx_entry_q2_data->limit = const_cpu_to_sle64(-1);
idx_entry_q2_data->exceeded_time = const_cpu_to_sle64(0);
idx_entry_q2_data->sid.revision = 1;
idx_entry_q2_data->sid.sub_authority_count = 2;
for (i = 0; i < 5; i++)
@ -3133,8 +3133,8 @@ do_next:
ie->indexed_file = file_ref;
ie->length = cpu_to_le16(i);
ie->key_length = cpu_to_le16(file_name_size);
ie->ie_flags = cpu_to_le16(0);
ie->reserved = cpu_to_le16(0);
ie->ie_flags = const_cpu_to_le16(0);
ie->reserved = const_cpu_to_le16(0);
memcpy((char*)&ie->key.file_name, (char*)file_name, file_name_size);
return 0;
}
@ -3189,7 +3189,7 @@ static int create_hardlink_res(MFT_RECORD *m_parent, const leMFT_REF ref_parent,
}
if (packed_ea_size) {
fn->packed_ea_size = cpu_to_le16(packed_ea_size);
fn->reserved = cpu_to_le16(0);
fn->reserved = const_cpu_to_le16(0);
} else {
fn->reparse_point_tag = cpu_to_le32(reparse_point_tag);
}
@ -3304,7 +3304,7 @@ static int create_hardlink(INDEX_BLOCK *idx, const leMFT_REF ref_parent,
}
if (packed_ea_size) {
fn->packed_ea_size = cpu_to_le16(packed_ea_size);
fn->reserved = cpu_to_le16(0);
fn->reserved = const_cpu_to_le16(0);
} else {
fn->reparse_point_tag = cpu_to_le32(reparse_point_tag);
}
@ -3332,7 +3332,7 @@ static int create_hardlink(INDEX_BLOCK *idx, const leMFT_REF ref_parent,
m_file->link_count = cpu_to_le16(i + 1);
/* Add the file_name to @m_file. */
i = insert_resident_attr_in_mft_record(m_file, AT_FILE_NAME, NULL, 0,
CASE_SENSITIVE, cpu_to_le16(0),
CASE_SENSITIVE, const_cpu_to_le16(0),
RESIDENT_ATTR_IS_INDEXED, (u8*)fn, fn_size);
if (i < 0) {
ntfs_log_error("create_hardlink failed adding file name attribute: "
@ -3388,9 +3388,10 @@ static int index_obj_id_insert(MFT_RECORD *m, const GUID *guid,
if (!idx_entry_new)
return -errno;
idx_entry_new->data_offset = cpu_to_le16(data_ofs);
idx_entry_new->data_length = cpu_to_le16(sizeof(OBJ_ID_INDEX_DATA));
idx_entry_new->data_length =
const_cpu_to_le16(sizeof(OBJ_ID_INDEX_DATA));
idx_entry_new->length = cpu_to_le16(idx_size);
idx_entry_new->key_length = cpu_to_le16(sizeof(GUID));
idx_entry_new->key_length = const_cpu_to_le16(sizeof(GUID));
idx_entry_new->key.object_id = *guid;
oi = (OBJ_ID_INDEX_DATA*)((u8*)idx_entry_new + data_ofs);
oi->mft_reference = ref;
@ -4406,7 +4407,7 @@ static BOOL mkntfs_create_root_structures(void)
return FALSE;
}
if (i == 0 || i > 23)
m->sequence_number = cpu_to_le16(1);
m->sequence_number = const_cpu_to_le16(1);
else
m->sequence_number = cpu_to_le16(i);
}
@ -4423,7 +4424,7 @@ static BOOL mkntfs_create_root_structures(void)
"\n");
return FALSE;
}
m->flags = cpu_to_le16(0);
m->flags = const_cpu_to_le16(0);
m->sequence_number = cpu_to_le16(i);
}
}
@ -4453,22 +4454,22 @@ static BOOL mkntfs_create_root_structures(void)
if (i == 0 || i == 1 || i == 2 || i == 6 || i == 8 ||
i == 10) {
add_attr_std_info(m, file_attrs,
cpu_to_le32(0x0100));
const_cpu_to_le32(0x0100));
} else if (i == 9) {
file_attrs = le32_or(file_attrs, FILE_ATTR_VIEW_INDEX_PRESENT);
add_attr_std_info(m, file_attrs,
cpu_to_le32(0x0101));
const_cpu_to_le32(0x0101));
} else if (i == 11) {
add_attr_std_info(m, file_attrs,
cpu_to_le32(0x0101));
const_cpu_to_le32(0x0101));
} else if (i == 24 || i == 25 || i == 26) {
file_attrs = le32_or(file_attrs, FILE_ATTR_ARCHIVE);
file_attrs = le32_or(file_attrs, FILE_ATTR_VIEW_INDEX_PRESENT);
add_attr_std_info(m, file_attrs,
cpu_to_le32(0x0101));
const_cpu_to_le32(0x0101));
} else {
add_attr_std_info(m, file_attrs,
cpu_to_le32(0x00));
const_cpu_to_le32(0x00));
}
}
/* The root directory mft reference. */
@ -4693,7 +4694,7 @@ static BOOL mkntfs_create_root_structures(void)
* Leave zero for now as NT4 leaves it zero, too. If want it later, see
* ../libntfs/bootsect.c for how to calculate it.
*/
bs->checksum = cpu_to_le32(0);
bs->checksum = const_cpu_to_le32(0);
/* Make sure the bootsector is ok. */
if (!ntfs_boot_sector_is_ntfs(bs)) {
free(bs);
@ -4964,7 +4965,7 @@ static int mkntfs_redirect(struct mkntfs_options *opts2)
goto done;
}
/* Initialize the random number generator with the current time. */
srandom(le64_to_cpu(mkntfs_time())/10000000);
srandom(sle64_to_cpu(mkntfs_time())/10000000);
/* Allocate and initialize ntfs_volume structure g_vol. */
g_vol = ntfs_volume_alloc();
if (!g_vol) {
@ -4997,7 +4998,7 @@ static int mkntfs_redirect(struct mkntfs_options *opts2)
g_vol->upcase_len * sizeof(ntfschar));
/* keep the version fields as zero */
memset(g_upcaseinfo, 0, sizeof(struct UPCASEINFO));
g_upcaseinfo->len = cpu_to_le32(sizeof(struct UPCASEINFO));
g_upcaseinfo->len = const_cpu_to_le32(sizeof(struct UPCASEINFO));
g_upcaseinfo->crc = cpu_to_le64(upcase_crc);
g_vol->attrdef = ntfs_malloc(sizeof(attrdef_ntfs3x_array));
if (!g_vol->attrdef) {

View File

@ -183,7 +183,7 @@ static int parse_options(int argc, char **argv)
opterr = 0; /* We'll handle the errors, thank you. */
opts.inode = -1;
opts.attr = cpu_to_le32(-1);
opts.attr = const_cpu_to_le32(-1);
opts.attr_name = NULL;
opts.attr_name_len = 0;
@ -201,7 +201,7 @@ static int parse_options(int argc, char **argv)
}
break;
case 'a':
if (!le32_eq(opts.attr, cpu_to_le32(-1))) {
if (!le32_eq(opts.attr, const_cpu_to_le32(-1))) {
ntfs_log_error("You must specify exactly one "
"attribute.\n");
} else if (parse_attribute(optarg, &attr) > 0) {
@ -432,7 +432,7 @@ int main(int argc, char *argv[])
}
attr = AT_DATA;
if (!le32_eq(opts.attr, cpu_to_le32(-1)))
if (!le32_eq(opts.attr, const_cpu_to_le32(-1)))
attr = opts.attr;
result = cat(vol, inode, attr, opts.attr_name, opts.attr_name_len);

View File

@ -247,7 +247,7 @@ static BOOL verify_boot_sector(struct ntfs_device *dev, ntfs_volume *rawvol)
*
* Assumes dev is open.
*/
static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, u32 attr_type, u32 size_of_file_record)
static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, ATTR_TYPES attr_type, u32 size_of_file_record)
{
u8 *buf;
u16 attrs_offset;
@ -584,7 +584,7 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
ATTR_REC *attr_rec;
// check record magic
assert_u32_equal(mft_rec->magic, magic_FILE, "FILE record magic");
assert_u32_equal(le32_to_cpu(mft_rec->magic), le32_to_cpu(magic_FILE), "FILE record magic");
// todo: records 16-23 must be filled in order.
// todo: what to do with magic_BAAD?
@ -608,9 +608,9 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
// We should know all the flags.
if (mft_rec->flags>0xf) {
if (le16_to_cpu(mft_rec->flags) > 0xf) {
check_failed("Unknown MFT record flags (0x%x).\n",
(unsigned int)mft_rec->flags);
(unsigned int)le16_to_cpu(mft_rec->flags));
}
// todo: flag in_use must be on.
@ -789,7 +789,7 @@ static void check_volume(ntfs_volume *vol)
static int reset_dirty(ntfs_volume *vol)
{
u16 flags;
le16 flags;
if (le16_cmpz(le16_or(vol->flags, VOLUME_IS_DIRTY)))
return 0;

View File

@ -898,7 +898,7 @@ static void gap_to_cluster(s64 gap)
static void image_skip_clusters(s64 count)
{
if (opt.save_image && count > 0) {
s64 count_buf;
sle64 count_buf;
char buff[1 + sizeof(count)];
buff[0] = CMD_GAP;
@ -1012,7 +1012,7 @@ static void restore_image(void)
progress_init(&progress, p_counter, opt.std_out ?
sle64_to_cpu(image_hdr.nr_clusters) + 1 :
sle64_to_cpu(image_hdr.inuse) + 1,
le64_to_cpu(image_hdr.inuse) + 1,
100);
if (opt.new_serial)
@ -1032,7 +1032,7 @@ static void restore_image(void)
if (cmd == CMD_GAP) {
if (!image_is_host_endian) {
le64 lecount;
sle64 lecount;
/* little endian image, on any computer */
if (read_all(&fd_in, &lecount,
@ -1083,7 +1083,7 @@ static void restore_image(void)
static void wipe_index_entry_timestams(INDEX_ENTRY *e)
{
static const struct timespec zero_time = { .tv_sec = 0, .tv_nsec = 0 };
le64 timestamp = timespec2ntfs(zero_time);
sle64 timestamp = timespec2ntfs(zero_time);
/* FIXME: can fall into infinite loop if corrupted */
while (le16_andz(e->ie_flags, INDEX_ENTRY_END)) {
@ -1193,7 +1193,7 @@ out_indexr:
free(indexr);
}
static void wipe_index_root_timestamps(ATTR_RECORD *attr, le64 timestamp)
static void wipe_index_root_timestamps(ATTR_RECORD *attr, sle64 timestamp)
{
INDEX_ENTRY *entry;
INDEX_ROOT *iroot;
@ -1256,7 +1256,7 @@ static void wipe_timestamps(ntfs_walk_clusters_ctx *image)
{
static const struct timespec zero_time = { .tv_sec = 0, .tv_nsec = 0 };
ATTR_RECORD *a = image->ctx->attr;
le64 timestamp = timespec2ntfs(zero_time);
sle64 timestamp = timespec2ntfs(zero_time);
if (le32_eq(a->type, AT_FILE_NAME))
WIPE_TIMESTAMPS(FILE_NAME_ATTR, a, timestamp);
@ -2097,10 +2097,10 @@ static void print_image_info(void)
sle64_to_cpu(image_hdr.nr_clusters) *
le32_to_cpu(image_hdr.cluster_size));
Printf("Image device size : %lld bytes\n",
(long long)sle64_to_cpu(image_hdr.device_size));
(long long)le64_to_cpu(image_hdr.device_size));
print_disk_usage(" ", le32_to_cpu(image_hdr.cluster_size),
sle64_to_cpu(image_hdr.nr_clusters),
sle64_to_cpu(image_hdr.inuse));
le64_to_cpu(image_hdr.inuse));
Printf("Offset to image data : %u (0x%x) bytes\n",
(unsigned)le32_to_cpu(image_hdr.offset_to_image_data),
(unsigned)le32_to_cpu(image_hdr.offset_to_image_data));
@ -2402,7 +2402,7 @@ static s64 open_image(void)
free(dummy_buf);
}
}
return sle64_to_cpu(image_hdr.device_size);
return le64_to_cpu(image_hdr.device_size);
}
static s64 open_volume(void)
@ -2432,9 +2432,9 @@ static void initialise_image_hdr(s64 device_size, s64 inuse)
image_hdr.major_ver = NTFSCLONE_IMG_VER_MAJOR;
image_hdr.minor_ver = NTFSCLONE_IMG_VER_MINOR;
image_hdr.cluster_size = cpu_to_le32(vol->cluster_size);
image_hdr.device_size = cpu_to_sle64(device_size);
image_hdr.device_size = cpu_to_le64(device_size);
image_hdr.nr_clusters = cpu_to_sle64(vol->nr_clusters);
image_hdr.inuse = cpu_to_sle64(inuse);
image_hdr.inuse = cpu_to_le64(inuse);
image_hdr.offset_to_image_data = cpu_to_le32((sizeof(image_hdr)
+ IMAGE_HDR_ALIGN - 1) & -IMAGE_HDR_ALIGN);
}

View File

@ -394,7 +394,7 @@ static void print_inode_ni(ntfs_inode *ni)
static void print_attribute_type(ATTR_TYPES atype)
{
printf("attribute 0x%x", atype);
printf("attribute 0x%x", le32_to_cpu(atype));
}
static void print_attribute_name(char *name)
@ -722,7 +722,7 @@ static void vprint_attribute(ATTR_TYPES atype, char *name)
if (!opt.verbose)
return;
printf("0x%x", atype);
printf("0x%x", le32_to_cpu(atype));
if (name)
printf(":%s", name);
printf(" ");
@ -781,7 +781,7 @@ static int new_attribute(ntfs_attr_search_ctx *ctx,
print_attribute_ctx(ctx);
printf("record %llu lowest_vcn %lld: SKIPPED\n",
(unsigned long long)ctx->ntfs_ino->mft_no,
(long long)ctx->attr->lowest_vcn);
(long long)sle64_to_cpu(ctx->attr->lowest_vcn));
}
return 0;
@ -830,7 +830,7 @@ static int cmp_attributes(ntfs_inode *ni1, ntfs_inode *ni2)
int old_ret1, ret1 = 0, ret2 = 0;
int errno1 = 0, errno2 = 0;
char *prev_name = NULL, *name1 = NULL, *name2 = NULL;
ATTR_TYPES old_atype1, prev_atype = 0, atype1, atype2;
ATTR_TYPES old_atype1, prev_atype = const_cpu_to_le32(0), atype1, atype2;
ntfs_attr_search_ctx *ctx1, *ctx2;
if (!(ctx1 = attr_get_search_ctx(ni1)))

View File

@ -609,11 +609,11 @@ static int set_sizes(struct ALLOC_CONTEXT *alctx, ntfs_attr_search_ctx *ctx)
/* Feed the sizes into the attribute */
attr = ctx->attr;
attr->non_resident = 1;
attr->data_size = cpu_to_le64(na->data_size);
attr->initialized_size = cpu_to_le64(na->initialized_size);
attr->allocated_size = cpu_to_le64(na->allocated_size);
attr->data_size = cpu_to_sle64(na->data_size);
attr->initialized_size = cpu_to_sle64(na->initialized_size);
attr->allocated_size = cpu_to_sle64(na->allocated_size);
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE))
attr->compressed_size = cpu_to_le64(na->compressed_size);
attr->compressed_size = cpu_to_sle64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if (le32_eq(opts.attribute, AT_DATA) && !na->name_len) {
ni = na->ni;
@ -806,7 +806,7 @@ static ntfs_inode *ntfs_new_file(ntfs_inode *dir_ni,
filename);
return NULL;
}
ni = ntfs_create(dir_ni, 0, ufilename, ufilename_len, S_IFREG);
ni = ntfs_create(dir_ni, const_cpu_to_le32(0), ufilename, ufilename_len, S_IFREG);
free(ufilename);
return ni;
}

View File

@ -1059,7 +1059,7 @@ static ntfs_fek *ntfs_fek_import_from_raw(u8 *fek_buf, unsigned fek_size)
gcry_error_t err;
ntfs_desx_ctx *ctx;
key_size = le32_to_cpup(fek_buf);
key_size = le32_to_cpup((le32*) fek_buf);
ntfs_log_debug("key_size 0x%x\n", key_size);
if (key_size + 16 > fek_size) {
ntfs_log_debug("Invalid FEK. It was probably decrypted with "

View File

@ -306,8 +306,8 @@ static void restart_header_sanity(RESTART_PAGE_HEADER *rstr, u8 *buf)
"size. Cannot handle this yet.\n");
}
/* Abort if the version number is not 1.1. */
if (sle16_to_cpu(rstr->major_ver != 1) ||
sle16_to_cpu(rstr->minor_ver != 1))
if (sle16_to_cpu(rstr->major_ver) != 1 ||
sle16_to_cpu(rstr->minor_ver) != 1)
log_err_exit(buf, "Unknown $LogFile version %i.%i. Only know "
"how to handle version 1.1.\n",
sle16_to_cpu(rstr->major_ver),
@ -542,11 +542,11 @@ static void dump_log_record(LOG_RECORD *lr)
{
unsigned int i;
ntfs_log_info("this lsn = 0x%llx\n",
(unsigned long long)le64_to_cpu(lr->this_lsn));
(unsigned long long)sle64_to_cpu(lr->this_lsn));
ntfs_log_info("client previous lsn = 0x%llx\n", (unsigned long long)
le64_to_cpu(lr->client_previous_lsn));
sle64_to_cpu(lr->client_previous_lsn));
ntfs_log_info("client undo next lsn = 0x%llx\n", (unsigned long long)
le64_to_cpu(lr->client_undo_next_lsn));
sle64_to_cpu(lr->client_undo_next_lsn));
ntfs_log_info("client data length = 0x%x\n",
(unsigned int)le32_to_cpu(lr->client_data_length));
ntfs_log_info("client_id.seq_number = 0x%x\n",
@ -557,7 +557,7 @@ static void dump_log_record(LOG_RECORD *lr)
(unsigned int)le32_to_cpu(lr->record_type));
ntfs_log_info("transaction_id = 0x%x\n",
(unsigned int)le32_to_cpu(lr->transaction_id));
ntfs_log_info("flags = 0x%x:", lr->flags);
ntfs_log_info("flags = 0x%x:", le16_to_cpu(lr->flags));
if (le16_cmpz(lr->flags))
ntfs_log_info(" NONE\n");
else {
@ -628,14 +628,14 @@ rcrd_pass_loc:
"CHKD");
// TODO: I am here... (AIA)
ntfs_log_info("copy.last_lsn/file_offset = 0x%llx\n", (unsigned long long)
le64_to_cpu(rcrd->copy.last_lsn));
sle64_to_cpu(rcrd->copy.last_lsn));
ntfs_log_info("flags = 0x%x\n", (unsigned int)le32_to_cpu(rcrd->flags));
ntfs_log_info("page count = %i\n", le16_to_cpu(rcrd->page_count));
ntfs_log_info("page position = %i\n", le16_to_cpu(rcrd->page_position));
ntfs_log_info("header.next_record_offset = 0x%llx\n", (unsigned long long)
le64_to_cpu(rcrd->header.packed.next_record_offset));
le16_to_cpu(rcrd->header.packed.next_record_offset));
ntfs_log_info("header.last_end_lsn = 0x%llx\n", (unsigned long long)
le64_to_cpu(rcrd->header.packed.last_end_lsn));
sle64_to_cpu(rcrd->header.packed.last_end_lsn));
/*
* Where does the 0x40 come from? Is it just usa_offset +
* usa_client * 2 + 7 & ~7 or is it derived from somewhere?
@ -648,7 +648,7 @@ rcrd_pass_loc:
client++;
lr = (LOG_RECORD*)((u8*)lr + 0x70);
} while (((u8*)lr + 0x70 <= (u8*)rcrd +
le64_to_cpu(rcrd->header.packed.next_record_offset)));
le16_to_cpu(rcrd->header.packed.next_record_offset)));
pass++;
goto rcrd_pass_loc;

View File

@ -704,14 +704,14 @@ static int ntfs_full_allocation(ntfs_attr *na, ntfs_attr_search_ctx *ctx,
} else {
/* Feed the sizes into the attribute */
attr = ctx->attr;
attr->data_size = cpu_to_le64(na->data_size);
attr->data_size = cpu_to_sle64(na->data_size);
attr->initialized_size
= cpu_to_le64(na->initialized_size);
= cpu_to_sle64(na->initialized_size);
attr->allocated_size
= cpu_to_le64(na->allocated_size);
= cpu_to_sle64(na->allocated_size);
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE))
attr->compressed_size
= cpu_to_le64(na->compressed_size);
= cpu_to_sle64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if (le32_eq(attr_type, AT_DATA) && !attr_name_len) {
ni = na->ni;

View File

@ -781,7 +781,7 @@ static BOOL short_mft_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
a = find_unnamed_attr(mft0,AT_DATA);
if (a
&& a->non_resident
&& (((le64_to_cpu(a->highest_vcn) + 1)
&& (((sle64_to_cpu(a->highest_vcn) + 1)
<< vol->cluster_size_bits)
== (SELFLOC_LIMIT*vol->mft_record_size))) {
rl = ntfs_mapping_pairs_decompress(vol, a, NULL);
@ -841,13 +841,13 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
rl = ntfs_mapping_pairs_decompress(vol, a, NULL);
if (rl
&& (rl->lcn >= 0)
&& (le64_to_cpu(a->data_size) < vol->cluster_size)
&& (sle64_to_cpu(a->data_size) < vol->cluster_size)
&& (ntfs_pread(vol->dev,
rl->lcn << vol->cluster_size_bits,
vol->cluster_size, attrlist) == vol->cluster_size)) {
selfloc->attrlist_lcn = rl->lcn;
al = attrlist;
length = le64_to_cpu(a->data_size);
length = sle64_to_cpu(a->data_size);
}
} else {
al = (ATTR_LIST_ENTRY*)
@ -858,7 +858,7 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
/* search for a data attribute defining entry 16 */
vcn = (SELFLOC_LIMIT*vol->mft_record_size)
>> vol->cluster_size_bits;
levcn = cpu_to_le64(vcn);
levcn = cpu_to_sle64(vcn);
while ((length > 0)
&& !le16_cmpz(al->length)
&& (!le32_eq(al->type, AT_DATA)
@ -921,7 +921,7 @@ static BOOL self_mapped_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
a = find_unnamed_attr(mft1,AT_DATA);
if (a
&& !le16_andz(mft1->flags, MFT_RECORD_IN_USE)
&& ((VCN)le64_to_cpu(a->lowest_vcn) == lowest_vcn)
&& ((VCN)sle64_to_cpu(a->lowest_vcn) == lowest_vcn)
&& (le64_to_cpu(mft1->base_mft_record)
== selfloc->mft_ref0)
&& ((u16)MSEQNO(selfloc->mft_ref1)
@ -1020,9 +1020,9 @@ static int fix_selfloc_conditions(struct MFT_SELF_LOCATED *selfloc)
mft1->sequence_number = const_cpu_to_le16(SELFLOC_LIMIT - 1);
a = find_unnamed_attr(mft1,AT_DATA);
if (a) {
a->allocated_size = const_cpu_to_le64(0);
a->data_size = const_cpu_to_le64(0);
a->initialized_size = const_cpu_to_le64(0);
a->allocated_size = const_cpu_to_sle64(0);
a->data_size = const_cpu_to_sle64(0);
a->initialized_size = const_cpu_to_sle64(0);
} else
res = -1; /* bug : it has been found earlier */
@ -1189,8 +1189,8 @@ static int try_fix_boot(ntfs_volume *vol, char *full_bs,
ntfs_log_perror("Error reading alternate bootsector");
} else {
bs = (NTFS_BOOT_SECTOR*)full_bs;
got_sectors = le64_to_cpu(bs->number_of_sectors);
bs->number_of_sectors = cpu_to_le64(fix_sectors);
got_sectors = sle64_to_cpu(bs->number_of_sectors);
bs->number_of_sectors = cpu_to_sle64(fix_sectors);
/* alignment problem on Sparc, even doing memcpy() */
sector_size_le = cpu_to_le16(sector_size);
if (!memcmp(&sector_size_le, &bs->bpb.bytes_per_sector,2)
@ -1325,7 +1325,7 @@ static int check_alternate_boot(ntfs_volume *vol)
br = ntfs_pread(vol->dev, 0, vol->sector_size, full_bs);
if (br == vol->sector_size) {
bs = (NTFS_BOOT_SECTOR*)full_bs;
got_sectors = le64_to_cpu(bs->number_of_sectors);
got_sectors = sle64_to_cpu(bs->number_of_sectors);
actual_sectors = ntfs_device_size_get(vol->dev,
vol->sector_size);
if (actual_sectors > got_sectors) {
@ -1453,7 +1453,7 @@ static int fix_startup(struct ntfs_device *dev, unsigned long flags)
if (!ntfs_boot_sector_is_ntfs(bs)
/* get the bootsector data, only fails when inconsistent */
|| (ntfs_boot_sector_parse(vol, bs) < 0)) {
shown_sectors = le64_to_cpu(bs->number_of_sectors);
shown_sectors = sle64_to_cpu(bs->number_of_sectors);
/* boot sector is wrong, try the alternate boot sector */
if (try_alternate_boot(vol, full_bs, sector_size,
shown_sectors)) {

View File

@ -420,7 +420,7 @@ static void ntfs_dump_volume(ntfs_volume *vol)
printf("\tDevice state: %lu\n", vol->dev->d_state);
printf("\tVolume Name: %s\n", vol->vol_name);
printf("\tVolume State: %lu\n", vol->state);
printf("\tVolume Flags: 0x%04x", (int)vol->flags);
printf("\tVolume Flags: 0x%04x", (int)le16_to_cpu(vol->flags));
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
printf(" DIRTY");
if (!le16_andz(vol->flags, VOLUME_MODIFIED_BY_CHKDSK))
@ -1695,7 +1695,7 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr,
else
/* weird, this should be illegal */
ntfs_log_error("Unknown index attribute type: 0x%0X\n",
index_root->type);
le32_to_cpu(index_root->type));
return INDEX_ATTR_UNKNOWN;
}

View File

@ -299,7 +299,7 @@ static int set_new_serial(ntfs_volume *vol)
serial_number = cpu_to_le64(sn);
}
if (!change_serial(vol, 0, serial_number, bs, oldbs)) {
number_of_sectors = le64_to_cpu(bs->number_of_sectors);
number_of_sectors = sle64_to_cpu(bs->number_of_sectors);
if (!change_serial(vol, number_of_sectors,
serial_number, bs, oldbs)) {
ntfs_log_info("New serial number : %016llx\n",
@ -389,7 +389,7 @@ static int change_label(ntfs_volume *vol, char *label)
(unsigned)(label_len -
(0x100 / sizeof(ntfschar))));
label_len = 0x100 / sizeof(ntfschar);
label[label_len] = const_cpu_to_le16(0);
label[label_len] = 0;
}
if(!opts.noaction)

View File

@ -229,7 +229,7 @@ static void dump_mft_record(MFT_RECORD *m)
ntfs_log_info("Update sequence array offset = %u (0x%x)\n", u, u);
ntfs_log_info("Update sequence array size = %u\n", le16_to_cpu(m->usa_count));
ntfs_log_info("$LogFile sequence number (lsn) = %llu\n",
(unsigned long long)le64_to_cpu(m->lsn));
(unsigned long long)sle64_to_cpu(m->lsn));
ntfs_log_info("Sequence number = %u\n", le16_to_cpu(m->sequence_number));
ntfs_log_info("Reference (hard link) count = %u\n",
le16_to_cpu(m->link_count));

View File

@ -319,10 +319,10 @@ static int resize_nonres_attr(MFT_RECORD *m, ATTR_RECORD *a, const u32 new_size)
int old_size;
u8 *ptr;
old_size = a->length;
file_size = m->bytes_in_use;
old_size = le32_to_cpu(a->length);
file_size = le32_to_cpu(m->bytes_in_use);
this_attr = p2n(a)-p2n(m);
next_attr = this_attr + a->length;
next_attr = this_attr + le32_to_cpu(a->length);
tail_size = file_size - next_attr;
ptr = (u8*) m;
@ -337,8 +337,8 @@ static int resize_nonres_attr(MFT_RECORD *m, ATTR_RECORD *a, const u32 new_size)
memmove(ptr + this_attr + new_size, ptr + next_attr, tail_size);
a->length = new_size;
m->bytes_in_use += new_size - old_size;
a->length = cpu_to_le32(new_size);
m->bytes_in_use = cpu_to_le32(le32_to_cpu(m->bytes_in_use) + (new_size - old_size));
return 0;
}
@ -355,7 +355,7 @@ static int calc_attr_length(ATTR_RECORD *rec, int runlength)
if (!rec->non_resident)
return -1;
size = rec->mapping_pairs_offset + runlength + 7;
size = le16_to_cpu(rec->mapping_pairs_offset) + runlength + 7;
size &= 0xFFF8;
return size;
}
@ -492,7 +492,7 @@ static int dont_move(ntfs_inode *ino)
return 1;
}
name = (FILE_NAME_ATTR*) ((u8*)rec + rec->value_offset);
name = (FILE_NAME_ATTR*) ((u8*)rec + le16_to_cpu(rec->value_offset));
if (ntfs_names_are_equal(ntldr, 5, name->file_name, name->file_name_length,
IGNORE_CASE, ino->vol->upcase, ino->vol->upcase_len)) {
ntfs_log_error("ntldr\n");
@ -727,10 +727,10 @@ static s64 move_datarun(ntfs_volume *vol, ntfs_inode *ino, ATTR_RECORD *rec,
}
// wipe orig runs
memset(((u8*)rec) +rec->mapping_pairs_offset, 0, need_to - rec->mapping_pairs_offset);
memset(((u8*)rec) + le16_to_cpu(rec->mapping_pairs_offset), 0, need_to - le16_to_cpu(rec->mapping_pairs_offset));
// update data runs
ntfs_mapping_pairs_build(vol, ((u8*)rec) + rec->mapping_pairs_offset,
ntfs_mapping_pairs_build(vol, ((u8*)rec) + le16_to_cpu(rec->mapping_pairs_offset),
need_to, from, 0, NULL);
// commit
@ -830,7 +830,7 @@ static s64 move_file(ntfs_volume *vol, ntfs_inode *ino, u64 loc, int flags)
while ((rec = find_attribute(AT_UNUSED, ctx))) {
utils_attr_get_name(vol, rec, buffer, MAX_PATH);
ntfs_log_info("\tAttribute 0x%02x %s is ", rec->type, buffer);
ntfs_log_info("\tAttribute 0x%02x %s is ", le32_to_cpu(rec->type), buffer);
if (rec->non_resident) {
ntfs_log_info("non-resident. Moving it.\n");

View File

@ -1412,7 +1412,7 @@ static void replace_later(ntfs_resize_t *resize, runlist *rl, runlist *head_rl)
delayed->type = a->type;
delayed->attr_name = attr_name;
delayed->name_len = name_len;
delayed->lowest_vcn = le64_to_cpu(a->lowest_vcn);
delayed->lowest_vcn = sle64_to_cpu(a->lowest_vcn);
delayed->rl = rl;
delayed->head_rl = head_rl;
delayed->next = resize->delayed_runlists;
@ -2058,7 +2058,7 @@ static void relocate_inodes(ntfs_resize_t *resize)
s64 nr_mft_records;
MFT_REF mref;
VCN highest_vcn;
u64 length;
s64 length;
printf("Relocating needed data ...\n");
@ -2103,11 +2103,11 @@ static void relocate_inodes(ntfs_resize_t *resize)
while (!ntfs_attrs_walk(resize->ctx)
&& !le32_eq(resize->ctx->attr->type, AT_DATA)) { }
if (le32_eq(resize->ctx->attr->type, AT_DATA)) {
le64 high_le;
sle64 high_le;
high_le = resize->ctx->attr->highest_vcn;
if (le64_to_cpu(high_le) < length)
length = le64_to_cpu(high_le) + 1;
if (sle64_to_cpu(high_le) < length)
length = sle64_to_cpu(high_le) + 1;
} else {
err_exit("Could not find the DATA of MFT\n");
}
@ -3064,7 +3064,7 @@ static s64 get_data_size(expand_t *expand, s64 inum)
/* get the size of unnamed $DATA */
a = get_unnamed_attr(expand, AT_DATA, inum);
if (a && a->non_resident)
size = le64_to_cpu(a->allocated_size);
size = sle64_to_cpu(a->allocated_size);
if (!size) {
err_printf("Bad record %lld, could not get its size\n",
(long long)inum);
@ -3092,7 +3092,7 @@ static u8 *get_mft_bitmap(expand_t *expand)
/* get the runlist of unnamed bitmap */
a = get_unnamed_attr(expand, AT_BITMAP, FILE_MFT);
ok = TRUE;
bitmap_size = le64_to_cpu(a->allocated_size);
bitmap_size = sle64_to_cpu(a->allocated_size);
if (a
&& a->non_resident
&& ((bitmap_size << (vol->mft_record_size_bits + 3))
@ -3615,10 +3615,10 @@ static int copy_boot(expand_t *expand)
if (buf) {
/* set the new volume parameters in the bootsector */
bs = (NTFS_BOOT_SECTOR*)expand->bootsector;
bs->number_of_sectors = cpu_to_le64(expand->new_sectors);
bs->mft_lcn = cpu_to_le64(expand->mft_lcn);
bs->number_of_sectors = cpu_to_sle64(expand->new_sectors);
bs->mft_lcn = cpu_to_sle64(expand->mft_lcn);
mftmirr_lcn = vol->mftmirr_lcn + expand->cluster_increment;
bs->mftmirr_lcn = cpu_to_le64(mftmirr_lcn);
bs->mftmirr_lcn = cpu_to_sle64(mftmirr_lcn);
/* the hidden sectors are needed to boot into windows */
memcpy(&hidden_sectors_le,&bs->bpb.hidden_sectors,4);
/* alignment messed up on the Sparc */
@ -3984,11 +3984,11 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
rl[1].length = 0;
if (set_bitmap(expand,rl))
res = -1;
a->data_size = cpu_to_le64(data_size);
a->data_size = cpu_to_sle64(data_size);
a->initialized_size = a->data_size;
a->allocated_size
= cpu_to_le64(allocated_size);
a->highest_vcn = cpu_to_le64(lth - 1);
= cpu_to_sle64(allocated_size);
a->highest_vcn = cpu_to_sle64(lth - 1);
}
/* expand the named data for $BadClus */
if (le32_eq(a->type, AT_DATA)
@ -4004,11 +4004,11 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
prl[1].vcn = lth;
} else
prl->vcn = lth;
a->data_size = cpu_to_le64(data_size);
a->data_size = cpu_to_sle64(data_size);
/* do not change the initialized size */
a->allocated_size
= cpu_to_le64(allocated_size);
a->highest_vcn = cpu_to_le64(lth - 1);
= cpu_to_sle64(allocated_size);
a->highest_vcn = cpu_to_sle64(lth - 1);
}
if (!res && update_runlist(expand,inum,a,rl))
res = -1;
@ -4212,7 +4212,7 @@ static ntfs_volume *get_volume_data(expand_t *expand, struct ntfs_device *dev,
&& ntfs_boot_sector_is_ntfs(bs)
&& !ntfs_boot_sector_parse(vol, bs)) {
expand->original_sectors
= le64_to_cpu(bs->number_of_sectors);
= sle64_to_cpu(bs->number_of_sectors);
expand->mrec = (MFT_RECORD*)
ntfs_malloc(vol->mft_record_size);
if (expand->mrec

View File

@ -75,7 +75,7 @@ BOOL success = FALSE;
char *dev_name;
s64 inode;
u32 attr_type;
ATTR_TYPES attr_type;
ntfschar *attr_name = NULL;
u32 attr_name_len;
s64 new_len;
@ -236,7 +236,7 @@ static void parse_options(int argc, char *argv[])
if (*s2 || !ul || (ul >= ULONG_MAX && errno == ERANGE))
err_exit("Invalid attribute type %s: %s\n", s,
strerror(errno));
attr_type = ul;
attr_type = cpu_to_le32(ul);
/* Get the attribute name, if specified. */
s = argv[optind++];
@ -258,7 +258,7 @@ static void parse_options(int argc, char *argv[])
attr_name_len = 0;
}
}
ntfs_log_verbose("attribute type = 0x%x\n", (unsigned int)attr_type);
ntfs_log_verbose("attribute type = 0x%x\n", (unsigned int)le32_to_cpu(attr_type));
if (attr_name == AT_UNNAMED)
ntfs_log_verbose("attribute name = \"\" (UNNAMED)\n");
else
@ -286,7 +286,7 @@ static void parse_options(int argc, char *argv[])
*/
static int ucstos(char *dest, const ntfschar *src, int maxlen)
{
ntfschar u;
u16 u;
int i;
/* Need one byte for null terminator. */
@ -314,6 +314,7 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
const char *todo = "This is still work in progress.";
char *buf;
int i, j;
VOLUME_FLAGS flags;
u32 u;
/* switch (type) { */
@ -356,54 +357,54 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
#define VOL_INF(x) ((VOLUME_INFORMATION *)(x))
printf("NTFS version %i.%i\n", VOL_INF(val)->major_ver,
VOL_INF(val)->minor_ver);
i = VOL_INF(val)->flags;
flags = VOL_INF(val)->flags;
#undef VOL_INF
printf("Volume flags = 0x%x: ", i);
if (le16_cmpz(i)) {
printf("Volume flags = 0x%x: ", le16_to_cpu(flags));
if (le16_cmpz(flags)) {
printf("NONE\n");
return;
}
j = 0;
if (!le16_andz(i, VOLUME_MODIFIED_BY_CHKDSK)) {
if (!le16_andz(flags, VOLUME_MODIFIED_BY_CHKDSK)) {
j = 1;
printf("VOLUME_MODIFIED_BY_CHKDSK");
}
if (!le16_andz(i, VOLUME_REPAIR_OBJECT_ID)) {
if (!le16_andz(flags, VOLUME_REPAIR_OBJECT_ID)) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_REPAIR_OBJECT_ID");
}
if (!le16_andz(i, VOLUME_DELETE_USN_UNDERWAY)) {
if (!le16_andz(flags, VOLUME_DELETE_USN_UNDERWAY)) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_DELETE_USN_UNDERWAY");
}
if (!le16_andz(i, VOLUME_MOUNTED_ON_NT4)) {
if (!le16_andz(flags, VOLUME_MOUNTED_ON_NT4)) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_MOUNTED_ON_NT4");
}
if (!le16_andz(i, VOLUME_UPGRADE_ON_MOUNT)) {
if (!le16_andz(flags, VOLUME_UPGRADE_ON_MOUNT)) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_UPGRADE_ON_MOUNT");
}
if (!le16_andz(i, VOLUME_RESIZE_LOG_FILE)) {
if (!le16_andz(flags, VOLUME_RESIZE_LOG_FILE)) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_RESIZE_LOG_FILE");
}
if (!le16_andz(i, VOLUME_IS_DIRTY)) {
if (!le16_andz(flags, VOLUME_IS_DIRTY)) {
if (j)
printf(" | ");
else
@ -531,6 +532,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
unsigned int u;
char s[0x200];
int i;
ATTR_FLAGS flags;
printf("-- Beginning dump of attribute record at offset 0x%x. --\n",
(unsigned)((u8*)a - (u8*)m));
@ -563,12 +565,12 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("Length of resident part = %u (0x%x)\n", u, u);
printf("Attribute is %sresident\n", a->non_resident ? "non-" : "");
printf("Name length = %u unicode characters\n", a->name_length);
printf("Name offset = %u (0x%x)\n", cpu_to_le16(a->name_offset),
cpu_to_le16(a->name_offset));
u = a->flags;
printf("Name offset = %u (0x%x)\n", le16_to_cpu(a->name_offset),
le16_to_cpu(a->name_offset));
flags = a->flags;
if (a->name_length) {
if (ucstos(s, (ntfschar*)((char*)a +
cpu_to_le16(a->name_offset)),
le16_to_cpu(a->name_offset)),
min((int)sizeof(s),
a->name_length + 1)) == -1) {
ntfs_log_error("Could not convert Unicode string to single "
@ -579,17 +581,17 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
}
printf("Name = %s\n", s);
}
printf("Attribute flags = 0x%x: ", le16_to_cpu(u));
if (le16_cmpz(u))
printf("Attribute flags = 0x%x: ", le16_to_cpu(flags));
if (le16_cmpz(flags))
printf("NONE");
else {
int first = TRUE;
if (!le16_andz(u, ATTR_COMPRESSION_MASK)) {
if (!le16_andz(u, ATTR_IS_COMPRESSED)) {
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (!le16_andz(flags, ATTR_IS_COMPRESSED)) {
printf("ATTR_IS_COMPRESSED");
first = FALSE;
}
if (!le16_andz(le16_and(u, ATTR_COMPRESSION_MASK), le16_not(ATTR_IS_COMPRESSED))) {
if (!le16_andz(le16_and(flags, ATTR_COMPRESSION_MASK), le16_not(ATTR_IS_COMPRESSED))) {
if (!first)
printf(" | ");
else
@ -597,14 +599,14 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("ATTR_UNKNOWN_COMPRESSION");
}
}
if (!le16_andz(u, ATTR_IS_ENCRYPTED)) {
if (!le16_andz(flags, ATTR_IS_ENCRYPTED)) {
if (!first)
printf(" | ");
else
first = FALSE;
printf("ATTR_IS_ENCRYPTED");
}
if (!le16_andz(u, ATTR_IS_SPARSE)) {
if (!le16_andz(flags, ATTR_IS_SPARSE)) {
if (!first)
printf(" | ");
else
@ -638,7 +640,7 @@ static void dump_mft_record(MFT_RECORD *m)
printf("Update sequence array offset = %u (0x%x)\n", u, u);
printf("Update sequence array size = %u\n", le16_to_cpu(m->usa_count));
printf("$LogFile sequence number (lsn) = %llu\n",
(unsigned long long)le64_to_cpu(m->lsn));
(unsigned long long)sle64_to_cpu(m->lsn));
printf("Sequence number = %u\n", le16_to_cpu(m->sequence_number));
printf("Reference (hard link) count = %u\n",
le16_to_cpu(m->link_count));
@ -665,7 +667,7 @@ static void dump_mft_record(MFT_RECORD *m)
a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
printf("-- Beginning dump of attributes within mft record. --\n");
while ((char*)a < (char*)m + le32_to_cpu(m->bytes_in_use)) {
if (le32_eq(a->type, cpu_to_le32(attr_type)))
if (le32_eq(a->type, attr_type))
dump_attr_record(m, a);
if (le32_eq(a->type, AT_END))
break;
@ -764,7 +766,7 @@ int main(int argc, char **argv)
na = ntfs_attr_open(ni, attr_type, attr_name, attr_name_len);
if (!na)
err_exit("Failed to open attribute 0x%x: %s\n",
(unsigned int)attr_type, strerror(errno));
(unsigned int)le32_to_cpu(attr_type), strerror(errno));
if (!opts.quiet && opts.verbose > 1) {
ntfs_log_verbose("Dumping mft record before calling "
@ -776,7 +778,7 @@ int main(int argc, char **argv)
err = ntfs_attr_truncate(na, new_len);
if (err)
err_exit("Failed to truncate attribute 0x%x: %s\n",
(unsigned int)attr_type, strerror(errno));
(unsigned int)le32_to_cpu(attr_type), strerror(errno));
if (!opts.quiet && opts.verbose > 1) {
ntfs_log_verbose("Dumping mft record after calling "

View File

@ -1011,14 +1011,14 @@ static s64 wipe_mft(ntfs_volume *vol, int byte, enum action act)
rec->magic = magic_FILE;
rec->usa_ofs = cpu_to_le16(usa_offset);
rec->usa_count = cpu_to_le16((u16) usa_size);
rec->sequence_number = cpu_to_le16(0x0001);
rec->sequence_number = const_cpu_to_le16(0x0001);
rec->attrs_offset = cpu_to_le16(attrs_offset);
rec->bytes_in_use = cpu_to_le32(bytes_in_use);
rec->bytes_allocated = cpu_to_le32(vol->mft_record_size);
rec->next_attr_instance = cpu_to_le16(0x0001);
rec->next_attr_instance = const_cpu_to_le16(0x0001);
// End marker.
*((le32*) (((u8*) rec) + attrs_offset)) = cpu_to_le32(0xFFFFFFFF);
*((le32*) (((u8*) rec) + attrs_offset)) = const_cpu_to_le32(0xFFFFFFFF);
}
result = ntfs_attr_mst_pwrite(vol->mft_na, vol->mft_record_size * i,
@ -1795,7 +1795,7 @@ static int destroy_record(ntfs_volume *nv, const s64 record,
}
}
}
ctx->attr->value_length = cpu_to_le32(0);
ctx->attr->value_length = const_cpu_to_le32(0);
if (!opts.noaction) {
if (ntfs_mft_records_write(nv, MK_MREF(record, 0),
1LL, ctx->mrec) != 0) {
@ -1863,7 +1863,7 @@ static int destroy_record(ntfs_volume *nv, const s64 record,
}
}
}
ctx->attr->value_length = cpu_to_le32(0);
ctx->attr->value_length = const_cpu_to_le32(0);
if ( !opts.noaction ) {
if (ntfs_mft_records_write(nv,
MK_MREF(record, 0),
@ -1953,12 +1953,12 @@ static int destroy_record(ntfs_volume *nv, const s64 record,
}
}
}
ctx->attr->lowest_vcn = cpu_to_le64(0);
ctx->attr->highest_vcn = cpu_to_le64(0);
ctx->attr->allocated_size = cpu_to_le64(0);
ctx->attr->data_size = cpu_to_le64(0);
ctx->attr->initialized_size = cpu_to_le64(0);
ctx->attr->compressed_size = cpu_to_le64(0);
ctx->attr->lowest_vcn = const_cpu_to_sle64(0);
ctx->attr->highest_vcn = const_cpu_to_sle64(0);
ctx->attr->allocated_size = const_cpu_to_sle64(0);
ctx->attr->data_size = const_cpu_to_sle64(0);
ctx->attr->initialized_size = const_cpu_to_sle64(0);
ctx->attr->compressed_size = const_cpu_to_sle64(0);
if (!opts.noaction) {
if (ntfs_mft_records_write(nv,
MK_MREF (record, 0),

View File

@ -187,7 +187,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
sd->control = le16_or(SE_SELF_RELATIVE, SE_DACL_PRESENT);
sd->owner = const_cpu_to_le32(0x1014);
sd->group = const_cpu_to_le32(0x1020);
sd->sacl = 0;
sd->sacl = const_cpu_to_le32(0);
sd->dacl = const_cpu_to_le32(sizeof(SECURITY_DESCRIPTOR_RELATIVE));
//acl
@ -196,7 +196,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
acl->alignment1 = 0;
acl->size = const_cpu_to_le16(0x1000);
acl->ace_count = const_cpu_to_le16(0x08);
acl->alignment2 = 0;
acl->alignment2 = const_cpu_to_le16(0);
//ace1
ace = (ACCESS_ALLOWED_ACE*)((u8*)acl + sizeof(ACL));
@ -436,7 +436,7 @@ void init_secure_sds(char *sd_val)
acl->alignment1 = 0x00;
acl->size = const_cpu_to_le16(0x34);
acl->ace_count = const_cpu_to_le16(0x02);
acl->alignment2 = 0x00;
acl->alignment2 = const_cpu_to_le16(0x00);
//ace1
ace = (ACCESS_ALLOWED_ACE*)((char*)acl + sizeof(ACL));
@ -532,7 +532,7 @@ void init_secure_sds(char *sd_val)
acl->alignment1 = 0x00;
acl->size = const_cpu_to_le16(0x34);
acl->ace_count = const_cpu_to_le16(0x02);
acl->alignment2 = 0x00;
acl->alignment2 = const_cpu_to_le16(0x00);
//ace1
ace = (ACCESS_ALLOWED_ACE*)((char*)acl + sizeof(ACL));

View File

@ -458,11 +458,11 @@ ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
}
if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
ntfs_log_debug("find_attribute didn't find an attribute of type: 0x%02x.\n", type);
ntfs_log_debug("find_attribute didn't find an attribute of type: 0x%02x.\n", le32_to_cpu(type));
return NULL; /* None / no more of that type */
}
ntfs_log_debug("find_attribute found an attribute of type: 0x%02x.\n", type);
ntfs_log_debug("find_attribute found an attribute of type: 0x%02x.\n", le32_to_cpu(type));
return ctx->attr;
}
@ -499,9 +499,9 @@ ATTR_RECORD * find_first_attribute(const ATTR_TYPES type, MFT_RECORD *mft)
rec = find_attribute(type, ctx);
ntfs_attr_put_search_ctx(ctx);
if (rec)
ntfs_log_debug("find_first_attribute: found attr of type 0x%02x.\n", type);
ntfs_log_debug("find_first_attribute: found attr of type 0x%02x.\n", le32_to_cpu(type));
else
ntfs_log_debug("find_first_attribute: didn't find attr of type 0x%02x.\n", type);
ntfs_log_debug("find_first_attribute: didn't find attr of type 0x%02x.\n", le32_to_cpu(type));
return rec;
}
@ -659,7 +659,7 @@ int utils_attr_get_name(ntfs_volume *vol, ATTR_RECORD *attr, char *buffer, int b
}
len = snprintf(buffer, bufsize, "%s", name);
} else {
ntfs_log_error("Unknown attribute type 0x%02x\n", attr->type);
ntfs_log_error("Unknown attribute type 0x%02x\n", le32_to_cpu(attr->type));
len = snprintf(buffer, bufsize, "<UNKNOWN>");
}

View File

@ -270,10 +270,10 @@ static void ntfs_fuse_update_times(ntfs_inode *ni, ntfs_time_update_flags mask)
if (ctx->atime == ATIME_DISABLED)
mask &= ~NTFS_UPDATE_ATIME;
else if (ctx->atime == ATIME_RELATIVE && mask == NTFS_UPDATE_ATIME &&
(le64_to_cpu(ni->last_access_time)
>= le64_to_cpu(ni->last_data_change_time)) &&
(le64_to_cpu(ni->last_access_time)
>= le64_to_cpu(ni->last_mft_change_time)))
(sle64_to_cpu(ni->last_access_time)
>= sle64_to_cpu(ni->last_data_change_time)) &&
(sle64_to_cpu(ni->last_access_time)
>= sle64_to_cpu(ni->last_mft_change_time)))
return;
ntfs_inode_update_times(ni, mask);
}
@ -1416,8 +1416,8 @@ static void ntfs_fuse_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
res = total;
if ((res > 0)
&& (!ctx->dmtime
|| (le64_to_cpu(ntfs_current_time())
- le64_to_cpu(ni->last_data_change_time)) > ctx->dmtime))
|| (sle64_to_cpu(ntfs_current_time())
- sle64_to_cpu(ni->last_data_change_time)) > ctx->dmtime))
ntfs_fuse_update_times(na->ni, NTFS_UPDATE_MCTIME);
exit:
if (na)

View File

@ -232,10 +232,10 @@ static void ntfs_fuse_update_times(ntfs_inode *ni, ntfs_time_update_flags mask)
if (ctx->atime == ATIME_DISABLED)
mask &= ~NTFS_UPDATE_ATIME;
else if (ctx->atime == ATIME_RELATIVE && mask == NTFS_UPDATE_ATIME &&
(le64_to_cpu(ni->last_access_time)
>= le64_to_cpu(ni->last_data_change_time)) &&
(le64_to_cpu(ni->last_access_time)
>= le64_to_cpu(ni->last_mft_change_time)))
(sle64_to_cpu(ni->last_access_time)
>= sle64_to_cpu(ni->last_data_change_time)) &&
(sle64_to_cpu(ni->last_access_time)
>= sle64_to_cpu(ni->last_mft_change_time)))
return;
ntfs_inode_update_times(ni, mask);
}
@ -568,7 +568,7 @@ static int ntfs_macfuse_getxtimes(const char *org_path,
}
/* We have no backup timestamp in NTFS. */
crtime->tv_sec = ni->creation_time;
crtime->tv_sec = sle64_to_cpu(ni->creation_time);
exit:
if (ntfs_inode_close(ni))
set_fuse_error(&res);
@ -590,7 +590,7 @@ int ntfs_macfuse_setcrtime(const char *path, const struct timespec *tv)
return -errno;
if (tv) {
ni->creation_time = tv->tv_sec;
ni->creation_time = cpu_to_sle64(tv->tv_sec);
ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME);
}
@ -632,7 +632,7 @@ int ntfs_macfuse_setchgtime(const char *path, const struct timespec *tv)
return -errno;
if (tv) {
ni->last_mft_change_time = tv->tv_sec;
ni->last_mft_change_time = cpu_to_sle64(tv->tv_sec);
ntfs_fuse_update_times(ni, 0);
}
@ -1339,8 +1339,8 @@ static int ntfs_fuse_write(const char *org_path, const char *buf, size_t size,
res = total;
if ((res > 0)
&& (!ctx->dmtime
|| (le64_to_cpu(ntfs_current_time())
- le64_to_cpu(ni->last_data_change_time)) > ctx->dmtime))
|| (sle64_to_cpu(ntfs_current_time())
- sle64_to_cpu(ni->last_data_change_time)) > ctx->dmtime))
ntfs_fuse_update_times(na->ni, NTFS_UPDATE_MCTIME);
exit:
if (na)
@ -1709,7 +1709,7 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
* have to build a security attribute later.
*/
if (!ctx->security.mapping[MAPUSERS])
securid = 0;
securid = const_cpu_to_le32(0);
else
if (ctx->inherit)
securid = ntfs_inherited_id(&security,

View File

@ -3072,15 +3072,17 @@ void tryposix(struct POSIX_SECURITY *pxdesc)
{
le32 owner_sid[] = /* S-1-5-21-3141592653-589793238-462843383-1016 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(1016)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(1016)
} ;
le32 group_sid[] = /* S-1-5-21-3141592653-589793238-462843383-513 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(513)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(513)
} ;
char *attr;
@ -3228,9 +3230,9 @@ static char *build_dummy_descr(BOOL isdir __attribute__((unused)),
pacl = (ACL*)&attr[pos];
pacl->revision = ACL_REVISION;
pacl->alignment1 = 0;
pacl->size = cpu_to_le16(0); /* fixed later */
pacl->size = const_cpu_to_le16(0); /* fixed later */
pacl->ace_count = cpu_to_le16(cnt);
pacl->alignment2 = cpu_to_le16(0);
pacl->alignment2 = const_cpu_to_le16(0);
/* enter the ACEs */
@ -3257,8 +3259,8 @@ static char *build_dummy_descr(BOOL isdir __attribute__((unused)),
/* append usid and gsid if defined */
/* positions of ACL, USID and GSID into header */
pnhead->owner = cpu_to_le32(0);
pnhead->group = cpu_to_le32(0);
pnhead->owner = const_cpu_to_le32(0);
pnhead->group = const_cpu_to_le32(0);
if (usid) {
memcpy(&attr[pos], usid, usidsz);
pnhead->owner = cpu_to_le32(pos);
@ -3268,13 +3270,14 @@ static char *build_dummy_descr(BOOL isdir __attribute__((unused)),
pnhead->group = cpu_to_le32(pos + usidsz);
}
/* positions of DACL and SACL into header */
pnhead->sacl = cpu_to_le32(0);
pnhead->sacl = const_cpu_to_le32(0);
if (cnt) {
pacl->size = cpu_to_le16(aclsz);
pnhead->dacl =
cpu_to_le32(sizeof(SECURITY_DESCRIPTOR_RELATIVE));
const_cpu_to_le32(sizeof(
SECURITY_DESCRIPTOR_RELATIVE));
} else
pnhead->dacl = cpu_to_le32(0);
pnhead->dacl = const_cpu_to_le32(0);
if (!ntfs_valid_descr(attr,pos+usidsz+gsidsz)) {
printf("** Bad sample descriptor\n");
free(attr);
@ -3309,33 +3312,38 @@ void check_samples()
#endif
le32 owner1[] = /* S-1-5-21-1833069642-4243175381-1340018762-1003 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(1833069642), cpu_to_le32(4243175381),
cpu_to_le32(1340018762), cpu_to_le32(1003)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(1833069642),
const_cpu_to_le32(4243175381), const_cpu_to_le32(1340018762),
const_cpu_to_le32(1003)
} ;
le32 group1[] = /* S-1-5-21-1833069642-4243175381-1340018762-513 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(1833069642), cpu_to_le32(4243175381),
cpu_to_le32(1340018762), cpu_to_le32(513)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(1833069642),
const_cpu_to_le32(4243175381), const_cpu_to_le32(1340018762),
const_cpu_to_le32(513)
} ;
le32 group2[] = /* S-1-5-21-1607551490-981732888-1819828000-513 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(1607551490), cpu_to_le32(981732888),
cpu_to_le32(1819828000), cpu_to_le32(513)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(1607551490),
const_cpu_to_le32(981732888), const_cpu_to_le32(1819828000),
const_cpu_to_le32(513)
} ;
le32 owner3[] = /* S-1-5-21-3141592653-589793238-462843383-1016 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(1016)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(1016)
} ;
le32 group3[] = /* S-1-5-21-3141592653-589793238-462843383-513 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(513)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(513)
} ;
#if POSIXACLS
@ -4169,15 +4177,17 @@ void selftests(void)
{
le32 owner_sid[] = /* S-1-5-21-3141592653-589793238-462843383-1016 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(1016)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(1016)
} ;
le32 group_sid[] = /* S-1-5-21-3141592653-589793238-462843383-513 */
{
cpu_to_le32(0x501), cpu_to_le32(0x05000000), cpu_to_le32(21),
cpu_to_le32(DEFSECAUTH1), cpu_to_le32(DEFSECAUTH2),
cpu_to_le32(DEFSECAUTH3), cpu_to_le32(513)
const_cpu_to_le32(0x501), const_cpu_to_le32(0x05000000),
const_cpu_to_le32(21), const_cpu_to_le32(DEFSECAUTH1),
const_cpu_to_le32(DEFSECAUTH2), const_cpu_to_le32(DEFSECAUTH3),
const_cpu_to_le32(513)
} ;
#if POSIXACLS
#ifdef STSC

View File

@ -216,8 +216,8 @@ typedef DWORD *LPDWORD;
#define SE_SACL_PROTECTED const_cpu_to_le16(0x2000)
#define SE_DACL_AUTO_INHERITED const_cpu_to_le16(0x400)
#define SE_SACL_AUTO_INHERITED const_cpu_to_le16(0x800)
#define SE_DACL_AUTO_INHERIT_REQ cpu_to_le16(0x100)
#define SE_SACL_AUTO_INHERIT_REQ cpu_to_le16(0x200)
#define SE_DACL_AUTO_INHERIT_REQ const_cpu_to_le16(0x100)
#define SE_SACL_AUTO_INHERIT_REQ const_cpu_to_le16(0x200)
typedef le16 ntfschar;
@ -326,10 +326,10 @@ typedef enum {
OWNER_SECURITY_INFORMATION = 1, // The owner identifier of the object is being referenced.
} SECURITY_INFORMATION;
#define STANDARD_RIGHTS_READ cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_WRITE cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_EXECUTE cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_REQUIRED cpu_to_le32(0xf0000)
#define STANDARD_RIGHTS_READ const_cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_WRITE const_cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_EXECUTE const_cpu_to_le32(0x20000)
#define STANDARD_RIGHTS_REQUIRED const_cpu_to_le32(0xf0000)
#endif
@ -452,39 +452,39 @@ enum {
#ifndef WIN32
#define DELETE cpu_to_le32(0x00010000L)
#define READ_CONTROL cpu_to_le32(0x00020000L)
#define WRITE_DAC cpu_to_le32(0x00040000L)
#define WRITE_OWNER cpu_to_le32(0x00080000L)
#define SYNCHRONIZE cpu_to_le32(0x00100000L)
#define DELETE const_cpu_to_le32(0x00010000L)
#define READ_CONTROL const_cpu_to_le32(0x00020000L)
#define WRITE_DAC const_cpu_to_le32(0x00040000L)
#define WRITE_OWNER const_cpu_to_le32(0x00080000L)
#define SYNCHRONIZE const_cpu_to_le32(0x00100000L)
#define FILE_READ_DATA cpu_to_le32( 0x0001 ) // file & pipe
#define FILE_LIST_DIRECTORY cpu_to_le32( 0x0001 ) // directory
#define FILE_READ_DATA const_cpu_to_le32(0x0001) // file & pipe
#define FILE_LIST_DIRECTORY const_cpu_to_le32(0x0001) // directory
#define FILE_WRITE_DATA cpu_to_le32( 0x0002 ) // file & pipe
#define FILE_ADD_FILE cpu_to_le32( 0x0002 ) // directory
#define FILE_WRITE_DATA const_cpu_to_le32(0x0002) // file & pipe
#define FILE_ADD_FILE const_cpu_to_le32(0x0002) // directory
#define FILE_APPEND_DATA cpu_to_le32( 0x0004 ) // file
#define FILE_ADD_SUBDIRECTORY cpu_to_le32( 0x0004 ) // directory
#define FILE_CREATE_PIPE_INSTANCE cpu_to_le32( 0x0004 ) // named pipe
#define FILE_APPEND_DATA const_cpu_to_le32(0x0004) // file
#define FILE_ADD_SUBDIRECTORY const_cpu_to_le32(0x0004) // directory
#define FILE_CREATE_PIPE_INSTANCE const_cpu_to_le32(0x0004) // named pipe
#define FILE_READ_EA cpu_to_le32( 0x0008 ) // file & directory
#define FILE_READ_EA const_cpu_to_le32(0x0008) // file & directory
#define FILE_WRITE_EA cpu_to_le32( 0x0010 ) // file & directory
#define FILE_WRITE_EA const_cpu_to_le32(0x0010) // file & directory
#define FILE_EXECUTE cpu_to_le32( 0x0020 ) // file
#define FILE_TRAVERSE cpu_to_le32( 0x0020 ) // directory
#define FILE_EXECUTE const_cpu_to_le32(0x0020) // file
#define FILE_TRAVERSE const_cpu_to_le32(0x0020) // directory
#define FILE_DELETE_CHILD cpu_to_le32( 0x0040 ) // directory
#define FILE_DELETE_CHILD const_cpu_to_le32(0x0040) // directory
#define FILE_READ_ATTRIBUTES cpu_to_le32( 0x0080 ) // all
#define FILE_READ_ATTRIBUTES const_cpu_to_le32(0x0080) // all
#define FILE_WRITE_ATTRIBUTES cpu_to_le32( 0x0100 ) // all
#define FILE_WRITE_ATTRIBUTES const_cpu_to_le32(0x0100) // all
#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
cpu_to_le32(0x1FF))
const_cpu_to_le32(0x1FF))
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
FILE_READ_DATA |\