Fix code to use const_cpu_to_X/const_X_to_cpu macros for constants.

This enables the compiler to optimize this code in cases where compiler
support for endianness swapping is not present.
edge.strict_endians
Erik Larsson 2015-12-21 23:21:00 +01:00
parent 58bb59487c
commit dfa4a6647f
14 changed files with 154 additions and 143 deletions

View File

@ -836,7 +836,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

@ -790,7 +790,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
| FILE_READ
| FILE_WRITE
| FILE_EXEC
| cpu_to_le32(0x40);
| const_cpu_to_le32(0x40);
}
/* reencode GENERIC_READ (+ EXECUTE) */
if (pnewace->mask & GENERIC_READ) {

View File

@ -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;
@ -3974,7 +3974,7 @@ 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->highest_vcn = const_cpu_to_sle64(-1);
a->allocated_size = 0;
a->data_size = 0;
a->initialized_size = 0;
@ -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);

View File

@ -65,7 +65,7 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
ntfs_log_debug("Beginning bootsector check.\n");
ntfs_log_debug("Checking OEMid, NTFS signature.\n");
if (b->oem_id != cpu_to_le64(0x202020205346544eULL)) { /* "NTFS " */
if (b->oem_id != const_cpu_to_le64(0x202020205346544eULL)) { /* "NTFS " */
ntfs_log_error("NTFS signature is missing.\n");
goto not_ntfs;
}
@ -140,7 +140,7 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
}
}
if (b->end_of_sector_marker != cpu_to_le16(0xaa55))
if (b->end_of_sector_marker != const_cpu_to_le16(0xaa55))
ntfs_log_debug("Warning: Bootsector has invalid end of sector "
"marker.\n");

View File

@ -1599,11 +1599,11 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
ir->clusters_per_index_block =
ni->vol->indx_record_size >>
NTFS_BLOCK_SIZE_BITS;
ir->index.entries_offset = cpu_to_le32(sizeof(INDEX_HEADER));
ir->index.entries_offset = const_cpu_to_le32(sizeof(INDEX_HEADER));
ir->index.index_length = cpu_to_le32(index_len);
ir->index.allocated_size = cpu_to_le32(index_len);
ie = (INDEX_ENTRY*)((u8*)ir + sizeof(INDEX_ROOT));
ie->length = cpu_to_le16(sizeof(INDEX_ENTRY_HEADER));
ie->length = const_cpu_to_le16(sizeof(INDEX_ENTRY_HEADER));
ie->key_length = 0;
ie->ie_flags = INDEX_ENTRY_END;
/* Add INDEX_ROOT attribute to inode. */
@ -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 |= MFT_RECORD_IS_DIRECTORY;
ntfs_inode_mark_dirty(ni);
@ -1970,7 +1970,7 @@ search:
* (Windows also does so), however delete the name if it were
* in an extent, to avoid leaving an attribute list.
*/
if ((ni->mrec->link_count == cpu_to_le16(1)) && !actx->base_ntfs_ino) {
if ((ni->mrec->link_count == const_cpu_to_le16(1)) && !actx->base_ntfs_ino) {
/* make sure to not loop to another search */
looking_for_dos_name = FALSE;
} else {

View File

@ -811,11 +811,11 @@ 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);
*(u16 *)((char *)ib + le16_to_cpu(ib->usa_ofs)) = const_cpu_to_le16(1);
ib->lsn = const_cpu_to_le64(0);
ib->index_block_vcn = cpu_to_sle64(ib_vcn);
@ -1160,7 +1160,7 @@ retry :
ie = ntfs_ie_get_first(&ir->index);
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)

View File

@ -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 (ni->flags & FILE_ATTR_REPARSE_POINT) {
if (!ntfs_attr_lookup(AT_REPARSE_POINT, NULL,
0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {

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);
*(u16*)((u8*)mrec + le16_to_cpu(mrec->usa_ofs)) = const_cpu_to_le16(1);
mrec->lsn = const_cpu_to_le64(0ull);
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;

View File

@ -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

@ -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_le64(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_le64(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_le64(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_le64(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 (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_le64(0);
ia_val->index_block_vcn = const_cpu_to_le64(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)) =
cpu_to_le64(0);
const_cpu_to_le64(0);
err = ntfs_mst_pre_write_fixup((NTFS_RECORD*)ia_val, index_block_size);
if (err) {
err = -errno;
@ -2930,8 +2930,8 @@ 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->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);
err = insert_index_entry_in_res_dir_index(idx_entry_q1, q1_size, m,
NTFS_INDEX_Q, 2, AT_UNUSED);
@ -2957,8 +2957,8 @@ 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->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->sid.revision = 1;
idx_entry_q2_data->sid.sub_authority_count = 2;
@ -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 |= 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 |= FILE_ATTR_ARCHIVE;
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);
@ -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 (opts.attr != cpu_to_le32(-1)) {
if (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 (opts.attr != cpu_to_le32(-1))
if (opts.attr != const_cpu_to_le32(-1))
attr = opts.attr;
result = cat(vol, inode, attr, opts.attr_name, opts.attr_name_len);

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_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);
if (!opts.noaction) {
if (ntfs_mft_records_write(nv,
MK_MREF (record, 0),

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 |\
@ -506,10 +506,10 @@ enum {
FILE_EXECUTE |\
SYNCHRONIZE)
#define GENERIC_READ cpu_to_le32(0x80000000L)
#define GENERIC_WRITE cpu_to_le32(0x40000000L)
#define GENERIC_EXECUTE cpu_to_le32(0x20000000L)
#define GENERIC_ALL cpu_to_le32(0x10000000L)
#define GENERIC_READ const_cpu_to_le32(0x80000000L)
#define GENERIC_WRITE const_cpu_to_le32(0x40000000L)
#define GENERIC_EXECUTE const_cpu_to_le32(0x20000000L)
#define GENERIC_ALL const_cpu_to_le32(0x10000000L)
#define OBJECT_INHERIT_ACE (0x1)