Date: Tue, 29 May 2012 18:26:45 +0000 From: vbotton@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r236675 - soc2012/vbotton/ntfs_apple Message-ID: <20120529182645.779B61065678@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vbotton Date: Tue May 29 18:26:44 2012 New Revision: 236675 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236675 Log: replace some endianness functions Modified: soc2012/vbotton/ntfs_apple/ntfs_attr.c soc2012/vbotton/ntfs_apple/ntfs_attr.h soc2012/vbotton/ntfs_apple/ntfs_inode.h soc2012/vbotton/ntfs_apple/ntfs_time.h soc2012/vbotton/ntfs_apple/ntfs_types.h Modified: soc2012/vbotton/ntfs_apple/ntfs_attr.c ============================================================================== --- soc2012/vbotton/ntfs_apple/ntfs_attr.c Tue May 29 17:53:11 2012 (r236674) +++ soc2012/vbotton/ntfs_apple/ntfs_attr.c Tue May 29 18:26:44 2012 (r236675) @@ -94,7 +94,7 @@ ntfs_debug("Entering for mft_no 0x%llx, type 0x%x.", (unsigned long long)ni->mft_no, - (unsigned)le32_to_cpu(ni->type)); + (unsigned)le32toh(ni->type)); /* If the attribute is resident there is nothing to do. */ if (!NInoNonResident(ni)) { ntfs_debug("Done (resident, nothing to do)."); @@ -140,9 +140,9 @@ * allocated size is correct. */ if (!a->lowest_vcn) - if (sle64_to_cpu(a->allocated_size) != + if (le64toh(a->allocated_size) != ni->allocated_size) - panic("%s(): sle64_to_cpu(a->allocated_size) " + panic("%s(): le64toh(a->allocated_size) " "!= ni->allocated_size\n", __FUNCTION__); /* @@ -150,11 +150,11 @@ * vcn we looked up and that the highest_vcn of the attribute * is above the current vcn. */ - if (sle64_to_cpu(a->lowest_vcn) != vcn || (vcn && - sle64_to_cpu(a->highest_vcn) < vcn)) + if (le64toh(a->lowest_vcn) != vcn || (vcn && + le64toh(a->highest_vcn) < vcn)) goto corrupt_err; /* Determine the next vcn. */ - vcn = sle64_to_cpu(a->highest_vcn) + 1; + vcn = le64toh(a->highest_vcn) + 1; /* * Finally, map the runlist fragment contained in this * attribute extent. @@ -259,7 +259,7 @@ if (!a->non_resident) panic("%s(): !a->non_resident\n", __FUNCTION__); ctx_is_temporary = FALSE; - end_vcn = sle64_to_cpu(a->highest_vcn); + end_vcn = le64toh(a->highest_vcn); lck_spin_lock(&ni->size_lock); allocated_size_vcn = ni->allocated_size >> ni->vol->cluster_size_shift; @@ -273,9 +273,9 @@ */ if (vcn >= allocated_size_vcn || (a->type == ni->type && a->name_length == ni->name_len && - !bcmp((u8*)a + le16_to_cpu(a->name_offset), + !bcmp((u8*)a + le16toh(a->name_offset), ni->name, ni->name_len) && - sle64_to_cpu(a->lowest_vcn) <= vcn && + le64toh(a->lowest_vcn) <= vcn && end_vcn >= vcn)) ctx_needs_reset = FALSE; else { @@ -307,7 +307,7 @@ * we then try to map the already mapped runlist fragment and * ntfs_mapping_pairs_decompress() fails. */ - end_vcn = sle64_to_cpu(a->highest_vcn) + 1; + end_vcn = le64toh(a->highest_vcn) + 1; if (vcn && vcn >= end_vcn) { err = ENOENT; goto err; @@ -366,8 +366,8 @@ */ if (err2) { if (err2 == ENOMEM) { - (void)thread_block( - THREAD_CONTINUE_NULL); + /* (void)thread_block( + THREAD_CONTINUE_NULL);*/ goto retry_map; } ctx->is_error = 1; @@ -676,7 +676,7 @@ ctx->is_iteration = 0; /* Sanity checks are performed elsewhere. */ ctx->a = (ATTR_RECORD*)((u8*)ctx->m + - le16_to_cpu(ctx->m->attrs_offset)); + le16toh(ctx->m->attrs_offset)); /* * This needs resetting due to * ntfs_attr_find_in_attribute_list() which can leave it set @@ -808,14 +808,14 @@ a = ctx->a; ctx->is_first = 0; } else - a = (ATTR_RECORD*)((u8*)ctx->a + le32_to_cpu(ctx->a->length)); - for (;; a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length))) { + a = (ATTR_RECORD*)((u8*)ctx->a + le32toh(ctx->a->length)); + for (;; a = (ATTR_RECORD*)((u8*)a + le32toh(a->length))) { if ((u8*)a < (u8*)ctx->m || (u8*)a > (u8*)ctx->m + - le32_to_cpu(ctx->m->bytes_allocated)) + le32toh(ctx->m->bytes_allocated)) break; ctx->a = a; if (((!is_iteration || type != AT_UNUSED) && - le32_to_cpu(a->type) > le32_to_cpu(type)) || + le32toh(a->type) > le32toh(type)) || a->type == AT_END) return ENOENT; if (!a->length) @@ -839,9 +839,9 @@ unsigned len, ofs; len = a->name_length; - ofs = le16_to_cpu(a->name_offset); + ofs = le16toh(a->name_offset); if (ofs + (len * sizeof(ntfschar)) > - le32_to_cpu(a->length)) + le32toh(a->length)) break; if (!ntfs_are_names_equal(name, name_len, (ntfschar*)((u8*)a + ofs), len, @@ -884,9 +884,9 @@ unsigned len, ofs; int rc; - len = le32_to_cpu(a->value_length); - ofs = le16_to_cpu(a->value_offset); - if (ofs + len > le32_to_cpu(a->length)) + len = le32toh(a->value_length); + ofs = le16toh(a->value_offset); + if (ofs + len > le32toh(a->length)) break; rc = memcmp(val, (u8*)a + ofs, len <= val_len ? len : val_len); @@ -992,7 +992,7 @@ panic("%s(): ctx->is_iteration\n", __FUNCTION__); base_ni = ctx->base_ni; ntfs_debug("Entering for mft_no 0x%llx, type 0x%x.", - (unsigned long long)ni->mft_no, le32_to_cpu(type)); + (unsigned long long)ni->mft_no, le32toh(type)); if (!base_ni) { /* First call happens with the base mft record. */ base_ni = ctx->base_ni = ctx->ni; @@ -1016,7 +1016,7 @@ ctx->is_first = 0; } else al_entry = (ATTR_LIST_ENTRY*)((u8*)ctx->al_entry + - le16_to_cpu(ctx->al_entry->length)); + le16toh(ctx->al_entry->length)); for (;; al_entry = next_al_entry) { /* Out of bounds check. */ if ((u8*)al_entry < base_ni->attr_list || @@ -1029,12 +1029,12 @@ if (!al_entry->length) break; if ((u8*)al_entry + 6 > al_end || (u8*)al_entry + - le16_to_cpu(al_entry->length) > al_end) + le16toh(al_entry->length) > al_end) break; next_al_entry = (ATTR_LIST_ENTRY*)((u8*)al_entry + - le16_to_cpu(al_entry->length)); + le16toh(al_entry->length)); if (al_entry->type != type) { - if (le32_to_cpu(al_entry->type) < le32_to_cpu(type)) + if (le32toh(al_entry->type) < le32toh(type)) continue; goto not_found; } @@ -1089,9 +1089,9 @@ */ if (lowest_vcn && (u8*)next_al_entry >= al_start && (u8*)next_al_entry + 6 < al_end && - (u8*)next_al_entry + le16_to_cpu( + (u8*)next_al_entry + le16toh( next_al_entry->length) <= al_end && - sle64_to_cpu(next_al_entry->lowest_vcn) <= + le64toh(next_al_entry->lowest_vcn) <= lowest_vcn && next_al_entry->type == al_entry->type && next_al_entry->name_length == al_name_len && @@ -1147,7 +1147,7 @@ } } a = ctx->a = (ATTR_RECORD*)((u8*)ctx->m + - le16_to_cpu(ctx->m->attrs_offset)); + le16toh(ctx->m->attrs_offset)); /* * ctx->ni, ctx->m, and ctx->a now point to the mft record * containing the attribute represented by the current @@ -1168,7 +1168,7 @@ */ do_next_attr_loop: if ((u8*)a < (u8*)ctx->m || (u8*)a > (u8*)ctx->m + - le32_to_cpu(ctx->m->bytes_allocated)) + le32toh(ctx->m->bytes_allocated)) break; if (a->type == AT_END) continue; @@ -1184,7 +1184,7 @@ if (al_entry->type != a->type) break; if (!ntfs_are_names_equal((ntfschar*)((u8*)a + - le16_to_cpu(a->name_offset)), a->name_length, + le16toh(a->name_offset)), a->name_length, al_name, al_name_len, case_sensitive, vol->upcase, vol->upcase_len)) break; @@ -1194,15 +1194,15 @@ * have found it! */ if (!val || (!a->non_resident && - le32_to_cpu(a->value_length) == val_len && - !bcmp((u8*)a + le16_to_cpu(a->value_offset), + le32toh(a->value_length) == val_len && + !bcmp((u8*)a + le16toh(a->value_offset), val, val_len))) { ntfs_debug("Done, found."); return 0; } do_next_attr: /* Proceed to the next attribute in the current mft record. */ - a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length)); + a = (ATTR_RECORD*)((u8*)a + le32toh(a->length)); goto do_next_attr_loop; } if (!err) { @@ -1247,7 +1247,7 @@ ntfs_extent_mft_record_unmap(ni); ctx->m = ctx->base_m; ctx->a = (ATTR_RECORD*)((u8*)ctx->m + - le16_to_cpu(ctx->m->attrs_offset)); + le16toh(ctx->m->attrs_offset)); ctx->is_first = 1; ctx->ni = base_ni; /* @@ -1352,7 +1352,7 @@ for (ad = vol->attrdef; (u8*)ad - (u8*)vol->attrdef < vol->attrdef_size && ad->type; ++ad) { /* If we have not found it yet, carry on searching. */ - if (le32_to_cpu(type) > le32_to_cpu(ad->type)) + if (le32toh(type) > le32toh(ad->type)) continue; /* If we have found the attribute, return it. */ if (type == ad->type) @@ -1362,7 +1362,7 @@ } /* Attribute not found. */ ntfs_debug("Attribute type 0x%x not found in $AttrDef.", - le32_to_cpu(type)); + le32toh(type)); return NULL; } @@ -1396,10 +1396,10 @@ if (!ad) return ENOENT; /* Do the bounds check. */ - if ((sle64_to_cpu(ad->min_size) > 0 && - size < sle64_to_cpu(ad->min_size)) || - (sle64_to_cpu(ad->max_size) > 0 && - size > sle64_to_cpu(ad->max_size)) || + if ((le64toh(ad->min_size) > 0 && + size < le64toh(ad->min_size)) || + (le64toh(ad->max_size) > 0 && + size > le64toh(ad->max_size)) || (u64)size > NTFS_MAX_ATTRIBUTE_SIZE) return ERANGE; return 0; @@ -1470,8 +1470,8 @@ { ATTR_RECORD *first_a, *next_a; - first_a = (ATTR_RECORD*)((u8*)m + le16_to_cpu(m->attrs_offset)); - next_a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length)); + first_a = (ATTR_RECORD*)((u8*)m + le16toh(m->attrs_offset)); + next_a = (ATTR_RECORD*)((u8*)a + le32toh(a->length)); return (first_a == a && next_a->type == AT_END); } @@ -1490,10 +1490,10 @@ */ void ntfs_attr_record_delete_internal(MFT_RECORD *m, ATTR_RECORD *a) { - const u32 new_muse = le32_to_cpu(m->bytes_in_use) - - le32_to_cpu(a->length); + const u32 new_muse = le32toh(m->bytes_in_use) - + le32toh(a->length); /* Move attributes following @a into the position of @a. */ - memmove(a, (u8*)a + le32_to_cpu(a->length), + memmove(a, (u8*)a + le32toh(a->length), new_muse - ((u8*)a - (u8*)m)); /* Adjust @m to reflect the change in used space. */ m->bytes_in_use = cpu_to_le32(new_muse); @@ -1545,7 +1545,7 @@ a = ctx->a; ntfs_debug("Entering for attribute type 0x%x located in %s mft " "record 0x%llx. Attribute list attribute is " - "%spresent.", (unsigned)le32_to_cpu(a->type), + "%spresent.", (unsigned)le32toh(a->type), (base_ni == ni) ? "base" : "extent", (unsigned long long)ni->mft_no, NInoAttrList(base_ni) ? "" : "not "); @@ -1577,9 +1577,9 @@ * it is the only attribute in the extent mft record thus we need to * free the extent mft record instead of deleting the attribute record. */ - if (base_ni == ni || (u8*)m + le16_to_cpu(m->attrs_offset) != (u8*)a || + if (base_ni == ni || (u8*)m + le16toh(m->attrs_offset) != (u8*)a || ((ATTR_RECORD*)((u8*)a + - le32_to_cpu(a->length)))->type != AT_END) { + le32toh(a->length)))->type != AT_END) { ntfs_attr_record_delete_internal(m, a); /* * If the attribute was not in the base mft record mark the @@ -1718,13 +1718,13 @@ errno_t ntfs_attr_record_make_space(MFT_RECORD *m, ATTR_RECORD *a, u32 size) { u32 new_muse; - const u32 muse = le32_to_cpu(m->bytes_in_use); + const u32 muse = le32toh(m->bytes_in_use); /* Align to 8 bytes if it is not already done. */ if (size & 7) size = (size + 7) & ~7; new_muse = muse + size; /* Not enough space in this mft record. */ - if (new_muse > le32_to_cpu(m->bytes_allocated)) + if (new_muse > le32toh(m->bytes_allocated)) return ENOSPC; /* Move attributes starting with @a to make space of @size bytes. */ memmove((u8*)a + size, a, muse - ((u8*)a - (u8*)m)); @@ -1761,7 +1761,7 @@ */ errno_t ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size) { - const u32 old_size = le32_to_cpu(a->length); + const u32 old_size = le32toh(a->length); ntfs_debug("Entering for new_size %u.", new_size); /* Align to 8 bytes if it is not already done. */ @@ -1769,10 +1769,10 @@ new_size = (new_size + 7) & ~7; /* If the actual attribute length has changed, move things around. */ if (new_size != old_size) { - const u32 muse = le32_to_cpu(m->bytes_in_use); + const u32 muse = le32toh(m->bytes_in_use); const u32 new_muse = muse - old_size + new_size; /* Not enough space in this mft record. */ - if (new_muse > le32_to_cpu(m->bytes_allocated)) + if (new_muse > le32toh(m->bytes_allocated)) return ENOSPC; /* Move attributes following @a to their new location. */ memmove((u8*)a + new_size, (u8*)a + old_size, @@ -1855,7 +1855,7 @@ "name len 0x%x, first_vcn 0x%llx, last_vcn 0x%llx, " "ctx is %spresent.", (unsigned long long)base_ni->mft_no, - (unsigned)le32_to_cpu(ni->type), ni->name_len, + (unsigned)le32toh(ni->type), ni->name_len, (unsigned long long)first_vcn, (unsigned long long)last_vcn, ctx ? "" : "not "); @@ -1943,9 +1943,9 @@ if (vol->major_ver <= 1) a->compression_unit = NTFS_COMPRESSION_UNIT; restart_compressed_size_add: - if ((first_vcn > sle64_to_cpu(a->highest_vcn) + 1) && + if ((first_vcn > le64toh(a->highest_vcn) + 1) && !(err = ntfs_attr_record_resize(ctx->m, a, - le32_to_cpu(a->length) + + le32toh(a->length) + sizeof(a->compressed_size)))) { /* * Move everything at the offset of the compressed size @@ -1955,7 +1955,7 @@ compressed_size) + sizeof(a->compressed_size), (u8*)a + offsetof(ATTR_RECORD, compressed_size), - le32_to_cpu(a->length) - offsetof( + le32toh(a->length) - offsetof( ATTR_RECORD, compressed_size)); /* * Update the name offset to match the moved data. If @@ -1964,7 +1964,7 @@ * incorrect value. */ if (a->name_length) - a->name_offset = htole16(le16_to_cpu( + a->name_offset = htole16(le16toh( a->name_offset) + sizeof(a->compressed_size)); else @@ -1972,7 +1972,7 @@ ATTR_RECORD, compressed_size) + sizeof(a->compressed_size)); /* Update the mapping pairs offset. */ - mp_ofs = le16_to_cpu(a->mapping_pairs_offset) + + mp_ofs = le16toh(a->mapping_pairs_offset) + sizeof(a->compressed_size); goto sparse_done; } @@ -1995,7 +1995,7 @@ * the needed alignment padding. */ if (((sizeof(ATTR_RECORD) + a->name_length * sizeof(ntfschar) + - 7) & ~7) + 8 <= le32_to_cpu(a->length)) { + 7) & ~7) + 8 <= le32toh(a->length)) { add_compressed_size: /* * Move the name back to the new end of the attribute @@ -2003,7 +2003,7 @@ */ if (a->name_length) memmove((u8*)a + sizeof(ATTR_RECORD), (u8*)a + - le16_to_cpu(a->name_offset), + le16toh(a->name_offset), a->name_length * sizeof(ntfschar)); /* @@ -2123,13 +2123,13 @@ * record. */ err = ntfs_attr_record_resize(ctx->m, a, - le32_to_cpu(m->bytes_allocated) - - le32_to_cpu(m->bytes_in_use) + - le32_to_cpu(a->length)); + le32toh(m->bytes_allocated) - + le32toh(m->bytes_in_use) + + le32toh(a->length)); if (err) panic("%s(): err - resize failed\n", __FUNCTION__); if (((sizeof(ATTR_RECORD) + a->name_length * sizeof(ntfschar) + - 7) & ~7) + 8 > le32_to_cpu(a->length)) + 7) & ~7) + 8 > le32toh(a->length)) panic("%s(): attribute record is still too small\n", __FUNCTION__); goto add_compressed_size; @@ -2153,7 +2153,7 @@ * preserve it or we would lose the data. */ a->compression_unit = 0; - if (first_vcn > sle64_to_cpu(a->highest_vcn) + 1) { + if (first_vcn > le64toh(a->highest_vcn) + 1) { /* * Move everything after the compressed size forward to the * offset of the compressed size thus deleting the compressed @@ -2162,7 +2162,7 @@ memmove((u8*)a + offsetof(ATTR_RECORD, compressed_size), (u8*)a + offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size), - le32_to_cpu(a->length) - (offsetof(ATTR_RECORD, + le32toh(a->length) - (offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size))); /* * Update the name offset and the mapping pairs offset to match @@ -2175,10 +2175,10 @@ compressed_size)); else a->name_offset = htole16( - le16_to_cpu(a->name_offset) - + le16toh(a->name_offset) - sizeof(a->compressed_size)); a->mapping_pairs_offset = htole16( - le16_to_cpu(a->mapping_pairs_offset) - + le16toh(a->mapping_pairs_offset) - sizeof(a->compressed_size)); /* * Shrink the attribute record to reflect the removal of the @@ -2186,7 +2186,7 @@ * the attribute smaller thus by definition there there is * enough space to do so. */ - err = ntfs_attr_record_resize(ctx->m, a, le32_to_cpu( + err = ntfs_attr_record_resize(ctx->m, a, le32toh( a->length) - sizeof(a->compressed_size)); if (err) panic("%s(): err\n", __FUNCTION__); @@ -2209,7 +2209,7 @@ */ if (a->name_length) memmove((u8*)a + offsetof(ATTR_RECORD, compressed_size), - (u8*)a + le16_to_cpu(a->name_offset), + (u8*)a + le16toh(a->name_offset), a->name_length * sizeof(ntfschar)); /* * Update the name offset and the mapping pairs offset to match the @@ -2242,7 +2242,7 @@ * attribute extent, look up the attribute extent containing the first * vcn. */ - if (mpa_is_valid && first_vcn > sle64_to_cpu(a->highest_vcn) + 1) { + if (mpa_is_valid && first_vcn > le64toh(a->highest_vcn) + 1) { err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, first_vcn, NULL, 0, ctx); if (err) { @@ -2370,7 +2370,7 @@ * consumed the old one. */ m->next_attr_instance = htole16( - (le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); + (le16toh(m->next_attr_instance) + 1) & 0xffff); a->value_length = cpu_to_le32(val_len); a->value_offset = htole16(val_ofs); if (type == AT_FILENAME) @@ -2431,7 +2431,7 @@ ntfs_debug("Entering for mft_no 0x%llx, attribute type 0x%x, name_len " "0x%x, val_len 0x%x.", (unsigned long long)ni->mft_no, - (unsigned)le32_to_cpu(type), name_len, val_len); + (unsigned)le32toh(type), name_len, val_len); vol = ni->vol; /* * Calculate the offset into the new attribute at which the attribute @@ -2531,7 +2531,7 @@ ntfs_error(vol->mp, "Failed to add attribute type " "0x%x to mft_no 0x%llx because looking " "up the attribute failed (error %d).", - (unsigned)le32_to_cpu(type), + (unsigned)le32toh(type), (unsigned long long)ni->mft_no, -err); return err; } @@ -2546,7 +2546,7 @@ "0x%x to mft_no 0x%llx because " "allocating a new extent mft record " "failed (error %d).", - (unsigned)le32_to_cpu(type), + (unsigned)le32toh(type), (unsigned long long)ni->mft_no, err); /* * If we added the attribute list attribute above we @@ -2592,7 +2592,7 @@ * consumed the old one. */ m->next_attr_instance = htole16( - (le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); + (le16toh(m->next_attr_instance) + 1) & 0xffff); a->value_length = cpu_to_le32(val_len); a->value_offset = htole16(val_ofs); if (type == AT_FILENAME) @@ -2603,7 +2603,7 @@ name_len << NTFSCHAR_SIZE_SHIFT); /* If a value is specified, copy it into place. */ if (val) { - memcpy((u8*)a + le16_to_cpu(a->value_offset), val, val_len); + memcpy((u8*)a + le16toh(a->value_offset), val, val_len); /* * Ensure the mft record containing the new filename attribute * gets written out. @@ -2884,10 +2884,10 @@ errno_t ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, const u32 new_size) { - const u32 old_size = le32_to_cpu(a->value_length); + const u32 old_size = le32toh(a->value_length); /* Resize the resident part of the attribute record. */ - if (ntfs_attr_record_resize(m, a, le16_to_cpu(a->value_offset) + + if (ntfs_attr_record_resize(m, a, le16toh(a->value_offset) + new_size)) return ENOSPC; /* @@ -2895,7 +2895,7 @@ * the area between the old size and @new_size. */ if (new_size > old_size) - bzero((u8*)a + le16_to_cpu(a->value_offset) + old_size, + bzero((u8*)a + le16toh(a->value_offset) + old_size, new_size - old_size); /* Finally update the length of the attribute value. */ a->value_length = cpu_to_le32(new_size); @@ -3039,11 +3039,11 @@ * If the page is not uptodate bring it uptodate by copying from the * attribute value. */ - attr_size = le32_to_cpu(a->value_length); + attr_size = le32toh(a->value_length); if (attr_size != data_size) panic("%s(): attr_size != data_size\n", __FUNCTION__); if (upl && !upl_valid_page(pl, 0)) { - memcpy(kaddr, (u8*)a + le16_to_cpu(a->value_offset), + memcpy(kaddr, (u8*)a + le16toh(a->value_offset), attr_size); bzero(kaddr + attr_size, PAGE_SIZE - attr_size); } @@ -3062,10 +3062,10 @@ * The attribute record size required cannot be larger than the amount * of space in an mft record. */ - if (arec_size > le32_to_cpu(m->bytes_allocated) - - le16_to_cpu(m->attrs_offset)) - panic("%s(): arec_size > le32_to_cpu(m->bytes_allocated) - " - "le16_to_cpu(m->attrs_offset)\n", + if (arec_size > le32toh(m->bytes_allocated) - + le16toh(m->attrs_offset)) + panic("%s(): arec_size > le32toh(m->bytes_allocated) - " + "le16toh(m->attrs_offset)\n", __FUNCTION__); /* * To make space in the mft record we would like to try to make other @@ -3181,7 +3181,7 @@ } ntfs_error(vol->mp, "Failed to move attribute type 0x%x out " "of base mft_no 0x%llx into an extent mft " - "record (error %d).", le32_to_cpu(type), + "record (error %d).", le32toh(type), base_ni->mft_no, err); goto unm_err; } @@ -3190,7 +3190,7 @@ * The number of free bytes needed in the mft record so the resize can * succeed. */ - bytes_needed = arec_size - le32_to_cpu(a->length); + bytes_needed = arec_size - le32toh(a->length); /* * The MFT reference of the mft record in which the attribute to be * made non-resident is located. @@ -3283,7 +3283,7 @@ * But first find the attribute list entry matching the * attribute record so it can be updated. */ - a_name = (ntfschar*)((u8*)a + le16_to_cpu(a->name_offset)); + a_name = (ntfschar*)((u8*)a + le16toh(a->name_offset)); al_entry = (ATTR_LIST_ENTRY*)base_ni->attr_list; do { /* @@ -3295,7 +3295,7 @@ "found in attribute list " "attribute of base mft record " "0x%llx. Run chkdsk.", - (unsigned)le32_to_cpu(a->type), + (unsigned)le32toh(a->type), (unsigned long long) base_ni->mft_no); NVolSetErrors(vol); @@ -3323,7 +3323,7 @@ "attribute list attribute of " "base mft record 0x%llx. Run " "chkdsk.", - (unsigned)le32_to_cpu(a->type), + (unsigned)le32toh(a->type), (unsigned long long) base_ni->mft_no); NVolSetErrors(vol); @@ -3332,7 +3332,7 @@ } /* Go to the next attribute list entry. */ al_entry = (ATTR_LIST_ENTRY*)((u8*)al_entry + - le16_to_cpu(al_entry->length)); + le16toh(al_entry->length)); } while (1); /* Finally, move the attribute to an extent record. */ err = ntfs_attr_record_move_for_attr_list_attribute(&actx, @@ -3342,7 +3342,7 @@ "0x%x out of base mft record 0x%llx " "and into an extent mft record (error " "%d). Run chkdsk.", - (unsigned)le32_to_cpu(a->type), + (unsigned)le32toh(a->type), (unsigned long long)base_ni->mft_no, err); NVolSetErrors(vol); @@ -3398,8 +3398,8 @@ goto retry_resize; } /* If we now have enough space retry the resize. */ - if (bytes_needed > le32_to_cpu(m->bytes_allocated) - - le32_to_cpu(m->bytes_in_use)) { + if (bytes_needed > le32toh(m->bytes_allocated) - + le32toh(m->bytes_in_use)) { a = ctx.a; goto retry_resize; } @@ -3413,7 +3413,7 @@ /* Move the attribute name if it exists and update the offset. */ if (a->name_length) memmove((u8*)a + name_ofs, - (u8*)a + le16_to_cpu(a->name_offset), + (u8*)a + le16toh(a->name_offset), a->name_length * sizeof(ntfschar)); a->name_offset = htole16(name_ofs); /* Setup the fields specific to non-resident attributes. */ @@ -3582,7 +3582,7 @@ base_ni = al_ctx->ni; ntfs_debug("Entering for mft_no 0x%llx, attribute type 0x%x.", (unsigned long long)base_ni->mft_no, - (unsigned)le32_to_cpu(al_entry->type)); + (unsigned)le32toh(al_entry->type)); /* * Allocate a new extent mft record, attach it to the base ntfs inode * and set up the search context to point to it. @@ -3601,7 +3601,7 @@ "mft record failed (error %d).", err); return err; } - attr_len = le32_to_cpu(al_ctx->a->length); + attr_len = le32toh(al_ctx->a->length); /* Make space for the attribute extent and copy it into place. */ err = ntfs_attr_record_make_space(m, a, attr_len); /* @@ -3633,7 +3633,7 @@ * consumed the old one. */ m->next_attr_instance = htole16( - (le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); + (le16toh(m->next_attr_instance) + 1) & 0xffff); /* * Ensure the changes make it to disk later and unmap the mft record as * we do not need it any more right now. @@ -3706,8 +3706,8 @@ "attribute type 0x%x.", (unsigned long long)base_ni->mft_no, (unsigned long long)ni->mft_no, - (unsigned)le32_to_cpu(a->type)); - attr_len = le32_to_cpu(a->length); + (unsigned)le32toh(a->type)); + attr_len = le32toh(a->length); /* Allocate a temporary buffer to hold the attribute to be moved. */ a_copy = OSMalloc(attr_len, ntfs_malloc_tag); if (!a_copy) { @@ -3726,7 +3726,7 @@ * attribute in the mft record as this would not gain anything thus * report a bug in this case. */ - if (((ATTR_RECORD*)((u8*)m + le16_to_cpu(m->attrs_offset)))->type == + if (((ATTR_RECORD*)((u8*)m + le16toh(m->attrs_offset)))->type == AT_END) panic("%s(): Is only attribute in mft record!\n", __FUNCTION__); /* Ensure the changes make it to disk later. */ @@ -3791,7 +3791,7 @@ * consumed the old one. */ m->next_attr_instance = htole16( - (le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); + (le16toh(m->next_attr_instance) + 1) & 0xffff); /* Ensure the changes make it to disk later. */ NInoSetMrecNeedsDirtying(ni); /* @@ -3806,7 +3806,7 @@ err = ntfs_rl_write(base_ni->vol, base_ni->attr_list, base_ni->attr_list_size, &base_ni->attr_list_rl, ofs, - le16_to_cpu(ctx->al_entry->length)); + le16toh(ctx->al_entry->length)); if (err) { ntfs_error(base_ni->vol->mp, "Failed to update " "on-disk attribute list attribute of " @@ -3819,7 +3819,7 @@ ATTR_LIST_ENTRY *al_entry; al_entry = (ATTR_LIST_ENTRY*)((u8*)a + - le16_to_cpu(a->value_offset) + + le16toh(a->value_offset) + ((u8*)ctx->al_entry - base_ni->attr_list)); al_entry->mft_reference = ctx->al_entry->mft_reference; al_entry->instance = ctx->al_entry->instance; @@ -3927,7 +3927,7 @@ "size 0x%llx, old initialized size 0x%llx, new " "initialized size 0x%llx.", (unsigned long long)ni->mft_no, - (unsigned)le32_to_cpu(ni->type), + (unsigned)le32toh(ni->type), (unsigned long long)ni->data_size, (unsigned long long)ni->initialized_size, (unsigned long long)new_init_size); @@ -3973,12 +3973,12 @@ if (new_init_size >> 32) panic("%s(): new_init_size >> 32\n", __FUNCTION__); - if (new_init_size > le32_to_cpu(a->length) - - le16_to_cpu(a->value_offset)) + if (new_init_size > le32toh(a->length) - + le16toh(a->value_offset)) panic("%s(): new_init_size > " - "le32_to_cpu(" + "le32toh(" "a->length) - " - "le16_to_cpu(" + "le16toh(" "a->value_offset)\n", __FUNCTION__); a->value_length = cpu_to_le32(new_init_size); @@ -4129,14 +4129,14 @@ if (a->non_resident) panic("%s(): a->non_resident\n", __FUNCTION__); /* The total length of the attribute value. */ - attr_len = le32_to_cpu(a->value_length); + attr_len = le32toh(a->value_length); if (size != attr_len) panic("%s(): size != attr_len\n", __FUNCTION__); /* * Do the zeroing in the mft record and update the attribute size in * the mft record. */ - kattr = (u8*)a + le16_to_cpu(a->value_offset); + kattr = (u8*)a + le16toh(a->value_offset); bzero(kattr + attr_len, new_init_size - attr_len); a->value_length = cpu_to_le32((u32)new_init_size); /* Update the sizes in the ntfs inode as well as the ubc size. */ @@ -4175,8 +4175,8 @@ a = ctx->a; if (!a->non_resident) panic("%s(): !a->non_resident\n", __FUNCTION__); - if (size != sle64_to_cpu(a->data_size)) - panic("%s(): size != sle64_to_cpu(a->data_size)\n", + if (size != le64toh(a->data_size)) + panic("%s(): size != le64toh(a->data_size)\n", __FUNCTION__); size = new_init_size; lck_spin_lock(&ni->size_lock); @@ -4537,7 +4537,7 @@ ntfs_debug("Entering for mft_no 0x%llx, type 0x%x, name_len 0x%x.", (unsigned long long)base_ni->mft_no, - (unsigned)le32_to_cpu(ni->type), ni->name_len); + (unsigned)le32toh(ni->type), ni->name_len); return ENOTSUP; #if 0 vol = base_ni->vol; @@ -4564,7 +4564,7 @@ if (a->flags & ATTR_IS_COMPRESSED) panic("%s(): a->flags & ATTR_IS_COMPRESSED)\n", __FUNCTION__); retry_attr_rec_resize: - err = ntfs_attr_record_resize(m, a, le32_to_cpu(a->length) + + err = ntfs_attr_record_resize(m, a, le32toh(a->length) + sizeof(a->compressed_size)); if (!err) { /* @@ -4574,7 +4574,7 @@ memmove((u8*)a + offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size), (u8*)a + offsetof(ATTR_RECORD, compressed_size), - le32_to_cpu(a->length) - offsetof(ATTR_RECORD, + le32toh(a->length) - offsetof(ATTR_RECORD, compressed_size)); /* * Update the name offset to match the moved data. If there is @@ -4583,7 +4583,7 @@ */ if (a->name_length) a->name_offset = htole16( - le16_to_cpu(a->name_offset) + + le16toh(a->name_offset) + sizeof(a->compressed_size)); else a->name_offset = htole16( @@ -4591,7 +4591,7 @@ compressed_size) + sizeof(a->compressed_size)); /* Update the mapping pairs offset to its new location. */ - mp_ofs = le16_to_cpu(a->mapping_pairs_offset) + + mp_ofs = le16toh(a->mapping_pairs_offset) + sizeof(a->compressed_size); goto set_compressed_size; } @@ -4712,7 +4712,7 @@ if (name_size) memmove((u8*)a + offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size), (u8*)a + - le16_to_cpu(a->name_offset), name_size); + le16toh(a->name_offset), name_size); a->name_offset = htole16(offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size)); /* Update the mapping pairs offset to its new location. */ @@ -4763,7 +4763,7 @@ * runlist elements that were stored in the base attribute extent * before we added the compressed size to the attribute record. */ - highest_vcn = sle64_to_cpu(a->highest_vcn); + highest_vcn = le64toh(a->highest_vcn); err = ntfs_get_size_for_mapping_pairs(vol, ni->rl.elements ? ni->rl.rl : NULL, 0, highest_vcn, &mp_size); if (err) { @@ -4773,7 +4773,7 @@ } /* Write the mapping pairs array. */ err = ntfs_mapping_pairs_build(vol, (s8*)a + mp_ofs, - le32_to_cpu(a->length) - mp_ofs, ni->rl.elements ? + le32toh(a->length) - mp_ofs, ni->rl.elements ? ni->rl.rl : NULL, 0, highest_vcn, &stop_vcn); if (err && err != ENOSPC) { ntfs_error(vol->mp, "Failed to rebuild mapping pairs array " @@ -4864,7 +4864,7 @@ * list attribute entry for the created attribute extent. */ al_entry = ctx->al_entry = (ATTR_LIST_ENTRY*)((u8*)ctx->al_entry + - le16_to_cpu(ctx->al_entry->length)); + le16toh(ctx->al_entry->length)); al_entry_len = (offsetof(ATTR_LIST_ENTRY, name) + name_size + 7) & ~7; new_al_size = base_ni->attr_list_size + al_entry_len; /* Out of bounds checks. */ @@ -4945,7 +4945,7 @@ * consumed the old one. */ m->next_attr_instance = htole16( - (le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); + (le16toh(m->next_attr_instance) + 1) & 0xffff); al_entry->lowest_vcn = a->lowest_vcn = cpu_to_sle64(stop_vcn); a->highest_vcn = cpu_to_sle64(highest_vcn); al_entry->mft_reference = MK_LE_MREF(eni->mft_no, eni->seq_no); @@ -4993,7 +4993,7 @@ * attribute record. */ err = ntfs_mapping_pairs_build(vol, (s8*)a + mp_ofs, - le32_to_cpu(a->length) - mp_ofs, rl, stop_vcn, + le32toh(a->length) - mp_ofs, rl, stop_vcn, highest_vcn, &stop_vcn); if (err && err != ENOSPC) { ntfs_error(vol->mp, "Failed to rebuild mapping pairs array " @@ -5091,7 +5091,7 @@ memmove((u8*)a + offsetof(ATTR_RECORD, compressed_size), (u8*)a + offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size), - le32_to_cpu(a->length) - (offsetof(ATTR_RECORD, + le32toh(a->length) - (offsetof(ATTR_RECORD, compressed_size) + sizeof(a->compressed_size))); /* * Update the name offset and the mapping pairs offset to match @@ -5104,10 +5104,10 @@ compressed_size)); else a->name_offset = htole16( - le16_to_cpu(a->name_offset) - + le16toh(a->name_offset) - sizeof(a->compressed_size)); a->mapping_pairs_offset = htole16( - le16_to_cpu(a->mapping_pairs_offset) - + le16toh(a->mapping_pairs_offset) - sizeof(a->compressed_size)); /* Set the compression unit to 0. */ a->compression_unit = 0; @@ -5125,7 +5125,7 @@ * enough space to do so. */ err = ntfs_attr_record_resize(ctx->m, a, - le32_to_cpu(a->length) - + le32toh(a->length) - sizeof(a->compressed_size)); if (err) panic("%s(): err\n", __FUNCTION__); @@ -5526,7 +5526,7 @@ * attribute record get the attribute record containing it so * we can update the mapping pairs array. */ - if (vcn > sle64_to_cpu(a->highest_vcn)) { + if (vcn > le64toh(a->highest_vcn)) { /* Ensure the modified mft record is written out. */ NInoSetMrecNeedsDirtying(ctx->ni); err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, @@ -5546,7 +5546,7 @@ * Get the size for the new mapping pairs array for this * attribute extent. */ - lowest_vcn = sle64_to_cpu(a->lowest_vcn); + lowest_vcn = le64toh(a->lowest_vcn); /* * Get the runlist element containing the lowest vcn. * @@ -5564,7 +5564,7 @@ "pairs array (error %d).", err); goto undo_sparse; } - mp_ofs = le16_to_cpu(a->mapping_pairs_offset); + mp_ofs = le16toh(a->mapping_pairs_offset); retry_attr_rec_resize: /* * Extend the attribute record to fit the bigger mapping pairs @@ -5655,9 +5655,9 @@ */ goto retry_attr_rec_resize; } - max_size = (le32_to_cpu(m->bytes_allocated) - - le32_to_cpu(m->bytes_in_use)) & ~7; - max_size += le32_to_cpu(a->length) - mp_ofs; + max_size = (le32toh(m->bytes_allocated) - + le32toh(m->bytes_in_use)) & ~7; + max_size += le32toh(a->length) - mp_ofs; err = ntfs_attr_record_resize(m, a, max_size + mp_ofs); /* * We worked out the exact size we can extend to so the resize @@ -5677,7 +5677,7 @@ * to build the mapping pairs array. */ err = ntfs_mapping_pairs_build(vol, (s8*)a + mp_ofs, - le32_to_cpu(a->length) - mp_ofs, rl2, + le32toh(a->length) - mp_ofs, rl2, lowest_vcn, highest_vcn, &stop_vcn); if (err && err != ENOSPC) { ntfs_error(vol->mp, "Cannot fill hole of mft_no " @@ -5685,7 +5685,7 @@ "building the mapping pairs array " "failed (error %d).", (unsigned long long)ni->mft_no, - (unsigned)le32_to_cpu(ni->type), err); + (unsigned)le32toh(ni->type), err); err = EIO; /* * Need to set @a->highest_vcn to enable correct error @@ -5693,7 +5693,7 @@ */ // TODO: HERE... if (!is_first) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120529182645.779B61065678>