diff --git a/include/ntfs-3g/inode.h b/include/ntfs-3g/inode.h index 5a6f7da6..8d58d245 100644 --- a/include/ntfs-3g/inode.h +++ b/include/ntfs-3g/inode.h @@ -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); diff --git a/include/ntfs-3g/ntfstime.h b/include/ntfs-3g/ntfstime.h index 236c0fb4..f3a89dd8 100644 --- a/include/ntfs-3g/ntfstime.h +++ b/include/ntfs-3g/ntfstime.h @@ -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)); } /* diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 63212062..82e50210 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -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 (type == AT_ATTRIBUTE_LIST) - a->flags = 0; + a->flags = const_cpu_to_le16(0); if ((type == AT_DATA) && (a->non_resident ? !a->initialized_size : !a->value_length)) { @@ -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 @@ -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; } @@ -3975,9 +3975,9 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type, /* If @lowest_vcn == 0, than setup empty attribute. */ if (!lowest_vcn) { a->highest_vcn = const_cpu_to_sle64(-1); - a->allocated_size = 0; - a->data_size = 0; - a->initialized_size = 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); /* Set empty mapping pairs. */ *((u8*)a + le16_to_cpu(a->mapping_pairs_offset)) = 0; } @@ -4891,7 +4891,7 @@ int ntfs_attr_make_non_resident(ntfs_attr *na, if ((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 &= ~ATTR_COMPRESSION_MASK; @@ -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); /* @@ -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; diff --git a/libntfs-3g/attrlist.c b/libntfs-3g/attrlist.c index 9c62f316..29d40859 100644 --- a/libntfs-3g/attrlist.c +++ b/libntfs-3g/attrlist.c @@ -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"); diff --git a/libntfs-3g/dir.c b/libntfs-3g/dir.c index a3500aab..9041eec2 100644 --- a/libntfs-3g/dir.c +++ b/libntfs-3g/dir.c @@ -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 (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 (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); @@ -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 (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) { 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); diff --git a/libntfs-3g/efs.c b/libntfs-3g/efs.c index 7957005b..14a2cb51 100644 --- a/libntfs-3g/efs.c +++ b/libntfs-3g/efs.c @@ -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 |= ATTR_IS_ENCRYPTED; if (close_ctx) diff --git a/libntfs-3g/index.c b/libntfs-3g/index.c index 0b6538e3..0ca91de0 100644 --- a/libntfs-3g/index.c +++ b/libntfs-3g/index.c @@ -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); } /** @@ -814,14 +814,14 @@ static INDEX_BLOCK *ntfs_ib_alloc(VCN ib_vcn, u32 ib_size, 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)) = const_cpu_to_le16(1); - ib->lsn = const_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; @@ -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 diff --git a/libntfs-3g/inode.c b/libntfs-3g/inode.c index c4da274c..a43714cc 100644 --- a/libntfs-3g/inode.c +++ b/libntfs-3g/inode.c @@ -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; @@ -874,7 +874,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni) (ni->flags & FILE_ATTR_VALID_FLAGS); if (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++; } diff --git a/libntfs-3g/logfile.c b/libntfs-3g/logfile.c index 336bdd28..dfe5b7d4 100644 --- a/libntfs-3g/logfile.c +++ b/libntfs-3g/logfile.c @@ -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 (((rp->major_ver != const_cpu_to_le16(1)) - || (rp->minor_ver != const_cpu_to_le16(1))) - && ((rp->major_ver != const_cpu_to_le16(2)) - || (rp->minor_ver != const_cpu_to_le16(0)))) { + if (((rp->major_ver != const_cpu_to_sle16(1)) + || (rp->minor_ver != const_cpu_to_sle16(1))) + && ((rp->major_ver != const_cpu_to_sle16(2)) + || (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", diff --git a/libntfs-3g/mft.c b/libntfs-3g/mft.c index 761c2b9d..a88391fb 100644 --- a/libntfs-3g/mft.c +++ b/libntfs-3g/mft.c @@ -372,8 +372,8 @@ 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)) = const_cpu_to_le16(1); - mrec->lsn = const_cpu_to_le64(0ull); + *(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. */ @@ -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(); diff --git a/libntfs-3g/mst.c b/libntfs-3g/mst.c index 88d5e7e6..9a164390 100644 --- a/libntfs-3g/mst.c +++ b/libntfs-3g/mst.c @@ -157,7 +157,7 @@ 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 *usa_pos, *data_pos; ntfs_log_trace("Entering\n"); @@ -181,7 +181,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). @@ -191,8 +191,8 @@ int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size) 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; + /* 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--) { /* @@ -203,7 +203,7 @@ int ntfs_mst_pre_write_fixup(NTFS_RECORD *b, const u32 size) /* Apply fixup to data. */ *data_pos = usn; /* Increment position in data as well. */ - data_pos += NTFS_BLOCK_SIZE/sizeof(u16); + data_pos += NTFS_BLOCK_SIZE/sizeof(le16); } return 0; } diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c index bfcfc672..a56c0b8c 100644 --- a/libntfs-3g/unistr.c +++ b/libntfs-3g/unistr.c @@ -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 diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 7d942a27..8fec2dfd 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -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 = const_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 = const_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 = const_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 = const_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; @@ -2497,8 +2497,8 @@ 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)) = const_cpu_to_le16(1); - ia_val->lsn = const_cpu_to_le64(0); - ia_val->index_block_vcn = const_cpu_to_le64(0); + 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) + @@ -2541,7 +2541,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name, } /* Set VCN pointer to 0LL. */ *(leVCN*)((char*)re + cpu_to_le16(re->length) - sizeof(VCN)) = - const_cpu_to_le64(0); + const_cpu_to_sle64(0); err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)ia_val, index_block_size); if (err) { err = -errno; @@ -2932,7 +2932,7 @@ static int initialize_quota(MFT_RECORD *m) idx_entry_q1_data->change_time = mkntfs_time(); 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_le64(0); + 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); @@ -2959,7 +2959,7 @@ static int initialize_quota(MFT_RECORD *m) idx_entry_q2_data->change_time = mkntfs_time(); 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_le64(0); + 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++) @@ -4965,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) { diff --git a/ntfsprogs/ntfsck.c b/ntfsprogs/ntfsck.c index ead2e9c8..fee0dc3a 100644 --- a/ntfsprogs/ntfsck.c +++ b/ntfsprogs/ntfsck.c @@ -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; @@ -789,7 +789,7 @@ static void check_volume(ntfs_volume *vol) static int reset_dirty(ntfs_volume *vol) { - u16 flags; + le16 flags; if (!(vol->flags | VOLUME_IS_DIRTY)) return 0; diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 1504c252..2ed9b8e4 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -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 (!(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 (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); } diff --git a/ntfsprogs/ntfscmp.c b/ntfsprogs/ntfscmp.c index 97aa17dd..3ac73365 100644 --- a/ntfsprogs/ntfscmp.c +++ b/ntfsprogs/ntfscmp.c @@ -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))) diff --git a/ntfsprogs/ntfscp.c b/ntfsprogs/ntfscp.c index 87a7da30..feee4061 100644 --- a/ntfsprogs/ntfscp.c +++ b/ntfsprogs/ntfscp.c @@ -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 (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 ((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; } diff --git a/ntfsprogs/ntfsdecrypt.c b/ntfsprogs/ntfsdecrypt.c index ab58cbd9..cbde912a 100644 --- a/ntfsprogs/ntfsdecrypt.c +++ b/ntfsprogs/ntfsdecrypt.c @@ -1049,7 +1049,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 " diff --git a/ntfsprogs/ntfsdump_logfile.c b/ntfsprogs/ntfsdump_logfile.c index b5b73f40..7fe22b3d 100644 --- a/ntfsprogs/ntfsdump_logfile.c +++ b/ntfsprogs/ntfsdump_logfile.c @@ -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", @@ -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)); 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? diff --git a/ntfsprogs/ntfsfallocate.c b/ntfsprogs/ntfsfallocate.c index 1b243ae6..83c68234 100644 --- a/ntfsprogs/ntfsfallocate.c +++ b/ntfsprogs/ntfsfallocate.c @@ -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 (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 ((attr_type == AT_DATA) && !attr_name_len) { ni = na->ni; diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index 59b8a98f..568fd9ae 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -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) && al->length && ((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 && (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(§or_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)) { diff --git a/ntfsprogs/ntfslabel.c b/ntfsprogs/ntfslabel.c index c0494ab5..77a34f08 100644 --- a/ntfsprogs/ntfslabel.c +++ b/ntfsprogs/ntfslabel.c @@ -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) diff --git a/ntfsprogs/ntfsmftalloc.c b/ntfsprogs/ntfsmftalloc.c index 246ab54a..96f7f79d 100644 --- a/ntfsprogs/ntfsmftalloc.c +++ b/ntfsprogs/ntfsmftalloc.c @@ -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)); diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index ce3b9f54..1c1bff5f 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -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) && (resize->ctx->attr->type != AT_DATA)) { } if (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 ((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 diff --git a/ntfsprogs/ntfstruncate.c b/ntfsprogs/ntfstruncate.c index 886a8c37..90b88998 100644 --- a/ntfsprogs/ntfstruncate.c +++ b/ntfsprogs/ntfstruncate.c @@ -638,7 +638,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)); diff --git a/ntfsprogs/ntfswipe.c b/ntfsprogs/ntfswipe.c index 55803057..ad794172 100644 --- a/ntfsprogs/ntfswipe.c +++ b/ntfsprogs/ntfswipe.c @@ -1953,12 +1953,12 @@ static int destroy_record(ntfs_volume *nv, const s64 record, } } } - ctx->attr->lowest_vcn = const_cpu_to_le64(0); - ctx->attr->highest_vcn = const_cpu_to_le64(0); - ctx->attr->allocated_size = const_cpu_to_le64(0); - ctx->attr->data_size = const_cpu_to_le64(0); - ctx->attr->initialized_size = const_cpu_to_le64(0); - ctx->attr->compressed_size = const_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), diff --git a/ntfsprogs/sd.c b/ntfsprogs/sd.c index 4e3af978..a60a8288 100644 --- a/ntfsprogs/sd.c +++ b/ntfsprogs/sd.c @@ -187,7 +187,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len) sd->control = 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)); diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index 3ff8b9de..8ce3d9f6 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -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) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index de0f920e..dc2d4454 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -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); } @@ -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,