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);
units = (s64)spec.tv_sec * 10000000
+ NTFS_TIME_OFFSET + spec.tv_nsec/100;
- return (cpu_to_le64(units));
+ return (cpu_to_sle64(units));
}
/*
* 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)) {
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
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;
}
/* 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;
}
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;
/* 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);
/*
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;
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;
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)) {
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),
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");
}
/* 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:
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 "
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);
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,
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);
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);
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)
};
}
-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));
}
/**
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);
}
/**
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;
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
* 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;
(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);
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;
/* 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;
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
* 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;
}
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++;
}
* 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",
"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. */
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();
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();
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");
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).
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--) {
/*
/* 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;
}
*/
int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
{
- ntfschar c1, c2;
+ u16 c1, c2;
size_t i;
#ifdef DEBUG
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));
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;
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);
}
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;
/* 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) +
}
/* 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;
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);
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++)
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) {
*
* 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;
static int reset_dirty(ntfs_volume *vol)
{
- u16 flags;
+ le16 flags;
if (!(vol->flags | VOLUME_IS_DIRTY))
return 0;
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;
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)
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,
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)) {
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;
{
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);
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));
free(dummy_buf);
}
}
- return sle64_to_cpu(image_hdr.device_size);
+ return le64_to_cpu(image_hdr.device_size);
}
static s64 open_volume(void)
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);
}
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)))
/* 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;
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;
}
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 "
{
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",
"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?
} 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;
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);
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*)
/* 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)
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)
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 */
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)
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) {
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)) {
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",
(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)
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));
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;
s64 nr_mft_records;
MFT_REF mref;
VCN highest_vcn;
- u64 length;
+ s64 length;
printf("Relocating needed data ...\n");
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");
}
/* 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);
/* 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))
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 */
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)
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;
&& 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
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));
}
}
}
- 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),
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
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));
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));
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));
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);
}
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)
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);
}
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)
* 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,