Rename scpu_to_le{16,32,64}() to cpu_to_sle{16,32,64}() to match the kernel.

(Logical change 1.586)
edge.strict_endians
cantab.net!aia21 2004-09-30 15:00:31 +00:00
parent 67ca77c25c
commit 8b3c03e173
7 changed files with 45 additions and 43 deletions

View File

@ -66,6 +66,8 @@ xx/xx/2004 - 2.0.0-WIP
does clear ctx->base_ntfs_ino which in turn means that
ntfs_attr_reinit_search_ctx() does not clear ctx->al_entry. Now,
ntfs_attr_reinit_search_ctx() always clears ctx->al_entry.
- Rename scpu_to_le{16,32,64}() to cpu_to_sle{16,32,64}() to match the
kernel.
04/09/2004 - 1.9.4 - Urgent bug fixes.

View File

@ -180,13 +180,13 @@
/* Signed from CPU to LE conversion. */
#define scpu_to_le16(x) (s16)__cpu_to_le16((s16)(x))
#define scpu_to_le32(x) (s32)__cpu_to_le32((s32)(x))
#define scpu_to_le64(x) (s64)__cpu_to_le64((s64)(x))
#define cpu_to_sle16(x) (s16)__cpu_to_le16((s16)(x))
#define cpu_to_sle32(x) (s32)__cpu_to_le32((s32)(x))
#define cpu_to_sle64(x) (s64)__cpu_to_le64((s64)(x))
#define scpu_to_le16p(x) (s16)__cpu_to_le16(*(s16*)(x))
#define scpu_to_le32p(x) (s32)__cpu_to_le32(*(s32*)(x))
#define scpu_to_le64p(x) (s64)__cpu_to_le64(*(s64*)(x))
#define cpu_to_sle16p(x) (s16)__cpu_to_le16(*(s16*)(x))
#define cpu_to_sle32p(x) (s32)__cpu_to_le32(*(s32*)(x))
#define cpu_to_sle64p(x) (s64)__cpu_to_le64(*(s64*)(x))
/* Constant endianness conversion defines. */

View File

@ -997,7 +997,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
errno = ENOTSUP;
goto err_out;
}
ctx->attr->initialized_size = scpu_to_le64(pos + count);
ctx->attr->initialized_size = cpu_to_sle64(pos + count);
if (ntfs_mft_record_write(vol, ctx->ntfs_ino->mft_no,
ctx->mrec)) {
/*
@ -1005,7 +1005,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
* back for writing.
*/
ctx->attr->initialized_size =
scpu_to_le64(old_initialized_size);
cpu_to_sle64(old_initialized_size);
ntfs_mft_record_write(vol, ctx->ntfs_ino->mft_no,
ctx->mrec);
goto err_out;
@ -1147,7 +1147,7 @@ err_out:
na->name_len, 0, 0, NULL, 0, ctx);
if (!err) {
na->initialized_size = old_initialized_size;
ctx->attr->initialized_size = scpu_to_le64(
ctx->attr->initialized_size = cpu_to_sle64(
old_initialized_size);
err = ntfs_mft_record_write(vol,
ctx->ntfs_ino->mft_no,
@ -2486,7 +2486,7 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
sizeof(ntfschar) * name_len);
a->flags = flags;
a->instance = m->next_attr_instance;
a->lowest_vcn = scpu_to_le64(lowest_vcn);
a->lowest_vcn = cpu_to_sle64(lowest_vcn);
a->mapping_pairs_offset = cpu_to_le16(length - dataruns_size);
a->compression_unit = (flags & ATTR_COMPRESSION_MASK) ? 4 : 0;
if (name_len)
@ -2912,8 +2912,8 @@ static int ntfs_attr_make_non_resident(ntfs_attr *na,
ATTR_COMPRESSION_MASK);
/* Setup the fields specific to non-resident attributes. */
a->lowest_vcn = scpu_to_le64(0);
a->highest_vcn = scpu_to_le64((new_allocated_size - 1) >>
a->lowest_vcn = cpu_to_sle64(0);
a->highest_vcn = cpu_to_sle64((new_allocated_size - 1) >>
vol->cluster_size_bits);
a->mapping_pairs_offset = cpu_to_le16(mp_ofs);
@ -2922,8 +2922,8 @@ static int ntfs_attr_make_non_resident(ntfs_attr *na,
memset(&a->reserved1, 0, sizeof(a->reserved1));
a->allocated_size = scpu_to_le64(new_allocated_size);
a->data_size = a->initialized_size = scpu_to_le64(na->data_size);
a->allocated_size = cpu_to_sle64(new_allocated_size);
a->data_size = a->initialized_size = cpu_to_sle64(na->data_size);
/* Generate the mapping pairs array in the attribute record. */
if (ntfs_mapping_pairs_build(vol, (u8*)a + mp_ofs, arec_size - mp_ofs,
@ -3335,7 +3335,7 @@ int ntfs_attr_update_mapping_pairs(ntfs_attr *na)
Dprintf("%s(): Marked attr 0x%x for delete in inode "
"0x%llx.\n", __FUNCTION__, le32_to_cpu(a->type),
ctx->ntfs_ino->mft_no);
a->highest_vcn = scpu_to_le64(NTFS_VCN_DELETE_MARK);
a->highest_vcn = cpu_to_sle64(NTFS_VCN_DELETE_MARK);
ntfs_inode_mark_dirty(ctx->ntfs_ino);
continue;
}
@ -3429,12 +3429,12 @@ int ntfs_attr_update_mapping_pairs(ntfs_attr *na)
}
/* Update lowest vcn. */
a->lowest_vcn = scpu_to_le64(stop_vcn);
a->lowest_vcn = cpu_to_sle64(stop_vcn);
ntfs_inode_mark_dirty(ctx->ntfs_ino);
if ((ctx->ntfs_ino->nr_extents == -1 ||
NInoAttrList(ctx->ntfs_ino)) &&
ctx->attr->type != AT_ATTRIBUTE_LIST) {
ctx->al_entry->lowest_vcn = scpu_to_le64(stop_vcn);
ctx->al_entry->lowest_vcn = cpu_to_sle64(stop_vcn);
ntfs_attrlist_mark_dirty(ctx->ntfs_ino);
}
@ -3455,7 +3455,7 @@ int ntfs_attr_update_mapping_pairs(ntfs_attr *na)
__FUNCTION__);
goto put_err_out;
}
a->highest_vcn = scpu_to_le64(stop_vcn - 1);
a->highest_vcn = cpu_to_sle64(stop_vcn - 1);
}
/* Check wether error occured. */
if (errno != ENOENT) {
@ -3558,7 +3558,7 @@ int ntfs_attr_update_mapping_pairs(ntfs_attr *na)
__FUNCTION__);
goto put_err_out;
}
a->highest_vcn = scpu_to_le64(stop_vcn - 1);
a->highest_vcn = cpu_to_sle64(stop_vcn - 1);
ntfs_inode_mark_dirty(ni);
/* All mapping pairs are writed. */
if (!err)
@ -3691,15 +3691,15 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize)
/* Update allocated size only if it is changed. */
if ((na->allocated_size >> vol->cluster_size_bits) != first_free_vcn) {
na->allocated_size = first_free_vcn << vol->cluster_size_bits;
a->allocated_size = scpu_to_le64(na->allocated_size);
a->allocated_size = cpu_to_sle64(na->allocated_size);
}
/* Update data and initialized size. */
na->data_size = newsize;
a->data_size = scpu_to_le64(newsize);
a->data_size = cpu_to_sle64(newsize);
if (newsize < na->initialized_size) {
na->initialized_size = newsize;
a->initialized_size = scpu_to_le64(newsize);
a->initialized_size = cpu_to_sle64(newsize);
}
/* If the attribute now has zero size, make it resident. */
@ -3868,11 +3868,11 @@ static int ntfs_non_resident_attr_expand(ntfs_attr *na, const s64 newsize)
/* Update allocated size only if it is changed. */
if ((na->allocated_size >> vol->cluster_size_bits) != first_free_vcn) {
na->allocated_size = first_free_vcn << vol->cluster_size_bits;
a->allocated_size = scpu_to_le64(na->allocated_size);
a->allocated_size = cpu_to_sle64(na->allocated_size);
}
/* Update data size. */
na->data_size = newsize;
a->data_size = scpu_to_le64(newsize);
a->data_size = cpu_to_sle64(newsize);
/* Set the inode dirty so it is written out later. */
ntfs_inode_mark_dirty(ctx->ntfs_ino);
/* Done! */

View File

@ -679,7 +679,7 @@ static int ntfs_mft_bitmap_extend_allocation(ntfs_volume *vol)
goto undo_alloc;
}
/* Update the highest_vcn. */
a->highest_vcn = scpu_to_le64(rl[1].vcn - 1);
a->highest_vcn = cpu_to_sle64(rl[1].vcn - 1);
/*
* We now have extended the mft bitmap allocated_size by one cluster.
* Reflect this in the ntfs_attr structure and the attribute record.
@ -700,7 +700,7 @@ static int ntfs_mft_bitmap_extend_allocation(ntfs_volume *vol)
a = ctx->attr;
}
mftbmp_na->allocated_size += vol->cluster_size;
a->allocated_size = scpu_to_le64(mftbmp_na->allocated_size);
a->allocated_size = cpu_to_sle64(mftbmp_na->allocated_size);
/* Ensure the changes make it to disk. */
ntfs_inode_mark_dirty(ctx->ntfs_ino);
ntfs_attr_put_search_ctx(ctx);
@ -723,7 +723,7 @@ restore_undo_alloc:
}
m = ctx->mrec;
a = ctx->attr;
a->highest_vcn = scpu_to_le64(rl[1].vcn - 2);
a->highest_vcn = cpu_to_sle64(rl[1].vcn - 2);
errno = ret;
undo_alloc:
ret = errno;
@ -796,10 +796,10 @@ static int ntfs_mft_bitmap_extend_initialized(ntfs_volume *vol)
old_data_size = mftbmp_na->data_size;
old_initialized_size = mftbmp_na->initialized_size;
mftbmp_na->initialized_size += 8;
a->initialized_size = scpu_to_le64(mftbmp_na->initialized_size);
a->initialized_size = cpu_to_sle64(mftbmp_na->initialized_size);
if (mftbmp_na->initialized_size > mftbmp_na->data_size) {
mftbmp_na->data_size = mftbmp_na->initialized_size;
a->data_size = scpu_to_le64(mftbmp_na->data_size);
a->data_size = cpu_to_sle64(mftbmp_na->data_size);
}
/* Ensure the changes make it to disk. */
ntfs_inode_mark_dirty(ctx->ntfs_ino);
@ -831,10 +831,10 @@ put_err_out:
}
a = ctx->attr;
mftbmp_na->initialized_size = old_initialized_size;
a->initialized_size = scpu_to_le64(old_initialized_size);
a->initialized_size = cpu_to_sle64(old_initialized_size);
if (mftbmp_na->data_size != old_data_size) {
mftbmp_na->data_size = old_data_size;
a->data_size = scpu_to_le64(old_data_size);
a->data_size = cpu_to_sle64(old_data_size);
}
ntfs_inode_mark_dirty(ctx->ntfs_ino);
ntfs_attr_put_search_ctx(ctx);
@ -1003,7 +1003,7 @@ static int ntfs_mft_data_extend_allocation(ntfs_volume *vol)
goto undo_alloc;
}
/* Update the highest_vcn. */
a->highest_vcn = scpu_to_le64(rl[1].vcn - 1);
a->highest_vcn = cpu_to_sle64(rl[1].vcn - 1);
/*
* We now have extended the mft data allocated_size by nr clusters.
* Reflect this in the ntfs_attr structure and the attribute record.
@ -1026,7 +1026,7 @@ static int ntfs_mft_data_extend_allocation(ntfs_volume *vol)
a = ctx->attr;
}
mft_na->allocated_size += nr << vol->cluster_size_bits;
a->allocated_size = scpu_to_le64(mft_na->allocated_size);
a->allocated_size = cpu_to_sle64(mft_na->allocated_size);
/* Ensure the changes make it to disk. */
ntfs_inode_mark_dirty(ctx->ntfs_ino);
ntfs_attr_put_search_ctx(ctx);
@ -1049,7 +1049,7 @@ restore_undo_alloc:
}
m = ctx->mrec;
a = ctx->attr;
a->highest_vcn = scpu_to_le64(old_last_vcn - 1);
a->highest_vcn = cpu_to_sle64(old_last_vcn - 1);
errno = err;
undo_alloc:
err = errno;
@ -1318,8 +1318,8 @@ found_free_rec:
goto undo_data_init;
}
a = ctx->attr;
a->initialized_size = scpu_to_le64(mft_na->initialized_size);
a->data_size = scpu_to_le64(mft_na->data_size);
a->initialized_size = cpu_to_sle64(mft_na->initialized_size);
a->data_size = cpu_to_sle64(mft_na->data_size);
/* Ensure the changes make it to disk. */
ntfs_inode_mark_dirty(ctx->ntfs_ino);
ntfs_attr_put_search_ctx(ctx);

View File

@ -3464,9 +3464,9 @@ static void mkntfs_create_root_structures(void)
* If there are problems go back to bs->unused[0-3] and set them. See
* ../include/layout.h for details.
*/
bs->number_of_sectors = scpu_to_le64(opts.nr_sectors);
bs->mft_lcn = scpu_to_le64(opts.mft_lcn);
bs->mftmirr_lcn = scpu_to_le64(opts.mftmirr_lcn);
bs->number_of_sectors = cpu_to_sle64(opts.nr_sectors);
bs->mft_lcn = cpu_to_sle64(opts.mft_lcn);
bs->mftmirr_lcn = cpu_to_sle64(opts.mftmirr_lcn);
if (vol->mft_record_size >= vol->cluster_size)
bs->clusters_per_mft_record = vol->mft_record_size /
vol->cluster_size;
@ -3496,7 +3496,7 @@ static void mkntfs_create_root_structures(void)
bs->clusters_per_index_record,
bs->clusters_per_index_record);
/* Generate a 64-bit random number for the serial number. */
bs->volume_serial_number = scpu_to_le64(((s64)random() << 32) |
bs->volume_serial_number = cpu_to_sle64(((s64)random() << 32) |
((s64)random() & 0xffffffff));
/*
* Leave zero for now as NT4 leaves it zero, too. If want it later, see

View File

@ -284,9 +284,9 @@ int main (int argc, char *argv[])
le16_to_cpu(ctx->attr->value_offset));
if (sle64_to_cpu(fna->allocated_size) ||
sle64_to_cpu(fna->data_size)) {
fna->allocated_size = scpu_to_le64(
fna->allocated_size = cpu_to_sle64(
na->allocated_size);
fna->data_size = scpu_to_le64(na->data_size);
fna->data_size = cpu_to_sle64(na->data_size);
ntfs_inode_mark_dirty(ctx->ntfs_ino);
}
}

View File

@ -1947,7 +1947,7 @@ static void update_bootsector(ntfs_resize_t *r)
if (vol->dev->d_ops->read(vol->dev, &bs, bs_size) == -1)
perr_exit("read() error");
bs.number_of_sectors = scpu_to_le64(r->new_volume_size *
bs.number_of_sectors = cpu_to_sle64(r->new_volume_size *
bs.bpb.sectors_per_cluster);
if (r->mftmir_old) {