From ff55ecb5130e17ac97b1a5bd087d4632a20a0976 Mon Sep 17 00:00:00 2001 From: uvman Date: Fri, 27 Oct 2006 12:24:29 +0000 Subject: [PATCH] Whitespace cleanup --- include/ntfs/layout.h | 12 +- include/ntfs/list.h | 2 +- include/ntfs/support.h | 6 +- libntfs/attrib.c | 18 +- libntfs/dir.c | 4 +- libntfs/index.c | 452 ++++++++++++++++++++--------------------- libntfs/inode.c | 4 +- libntfs/runlist.c | 12 +- libntfs/unistr.c | 4 +- libntfs/unix_io.c | 2 +- libntfs/volume.c | 4 +- ntfsprogs/mkntfs.c | 20 +- ntfsprogs/ntfsclone.c | 26 +-- ntfsprogs/ntfscmp.c | 28 +-- ntfsprogs/ntfsinfo.c | 98 +++++---- ntfsprogs/ntfsresize.c | 2 +- 16 files changed, 346 insertions(+), 348 deletions(-) diff --git a/include/ntfs/layout.h b/include/ntfs/layout.h index 68ebca72..39e4c934 100644 --- a/include/ntfs/layout.h +++ b/include/ntfs/layout.h @@ -244,7 +244,7 @@ typedef enum { * * These are the so far known MFT_RECORD_* flags (16-bit) which contain * information about the mft record in which they are present. - * + * * MFT_RECORD_IS_4 exists on all $Extend sub-files. * It seems that it marks it is a metadata file with MFT record >24, however, * it is unknown if it is limited to metadata files only. @@ -480,7 +480,7 @@ typedef struct { * Each attribute type has a corresponding attribute name (Unicode string of * maximum 64 character length) as described by the attribute definitions * present in the data attribute of the $AttrDef system file. - * + * * On NTFS 3.0 volumes the names are just as the types are named in the below * enum exchanging AT_ for the dollar sign ($). If that isn't a revealing * choice of symbol... (-; @@ -867,15 +867,15 @@ typedef enum { * This is a copy of the MFT_RECORD_IS_DIRECTORY bit from the mft * record, telling us whether this is a directory or not, i.e. whether * it has an index root attribute named "$I30" or not. - * - * This flag is only present in the FILE_NAME attribute (in the + * + * This flag is only present in the FILE_NAME attribute (in the * file_attributes field). */ FILE_ATTR_I30_INDEX_PRESENT = const_cpu_to_le32(0x10000000), - + /** * FILE_ATTR_VIEW_INDEX_PRESENT - Does have a non-directory index? - * + * * This is a copy of the MFT_RECORD_IS_VIEW_INDEX bit from the mft * record, telling us whether this file has a view index present (eg. * object id index, quota index, one of the security indexes and the diff --git a/include/ntfs/list.h b/include/ntfs/list.h index 9af28aa5..e3c77442 100644 --- a/include/ntfs/list.h +++ b/include/ntfs/list.h @@ -24,7 +24,7 @@ /** * struct list_head - Simple doubly linked list implementation. - * + * * Copied from Linux kernel 2.4.2-ac18 into Linux-NTFS (with minor * modifications). - AIA * diff --git a/include/ntfs/support.h b/include/ntfs/support.h index 7b9aa351..10eab345 100644 --- a/include/ntfs/support.h +++ b/include/ntfs/support.h @@ -98,13 +98,13 @@ /** * ntfs_calloc, ntfs_malloc - * + * * Return a pointer to the allocated memory or NULL if the request fails. */ static inline void *ntfs_calloc(size_t size) { void *p; - + p = calloc(1, size); if (!p) ntfs_log_perror("Failed to calloc %lld bytes", (long long)size); @@ -114,7 +114,7 @@ static inline void *ntfs_calloc(size_t size) static inline void *ntfs_malloc(size_t size) { void *p; - + p = malloc(size); if (!p) ntfs_log_perror("Failed to malloc %lld bytes", (long long)size); diff --git a/libntfs/attrib.c b/libntfs/attrib.c index eb57bfee..e6b8f48f 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -3861,7 +3861,7 @@ static int ntfs_resident_attr_resize(ntfs_attr *na, const s64 newsize) goto put_err_out; } - /* + /* * Force index allocation creation instead of moving out index root * from the base MFT record. */ @@ -4988,21 +4988,21 @@ int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize) ntfs_inode_update_time(na->ni); return ret; } - + /** * ntfs_attr_readall - read the entire data from an ntfs attribute * @ni: open ntfs inode in which the ntfs attribute resides * @type: attribute type * @name: attribute name in little endian Unicode or AT_UNNAMED or NULL * @name_len: length of attribute @name in Unicode characters (if @name given) - * @data_size: if non-NULL then store here the data size + * @data_size: if non-NULL then store here the data size * * This function will read the entire content of an ntfs attribute. * If @name is AT_UNNAMED then look specifically for an unnamed attribute. - * If @name is NULL then the attribute could be either named or not. + * If @name is NULL then the attribute could be either named or not. * In both those cases @name_len is not used at all. * - * On success a buffer is allocated with the content of the attribute + * On success a buffer is allocated with the content of the attribute * and which needs to be freed when it's not needed anymore. If the * @data_size parameter is non-NULL then the data size is set there. * @@ -5014,7 +5014,7 @@ void *ntfs_attr_readall(ntfs_inode *ni, const ATTR_TYPES type, ntfs_attr *na; void *data, *ret = NULL; s64 size; - + na = ntfs_attr_open(ni, type, name, name_len); if (!na) { ntfs_log_perror("ntfs_attr_open failed"); @@ -5047,13 +5047,13 @@ int ntfs_attr_exist(ntfs_inode *ni, const ATTR_TYPES type, ntfschar *name, { ntfs_attr_search_ctx *ctx; int ret; - + ntfs_log_trace("Entering.\n"); - + ctx = ntfs_attr_get_search_ctx(ni, NULL); if (!ctx) return 0; - + ret = ntfs_attr_lookup(type, name, name_len, CASE_SENSITIVE, 0, NULL, 0, ctx); diff --git a/libntfs/dir.c b/libntfs/dir.c index b1c3110e..87b60684 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -1175,7 +1175,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, * 4 bytes to every SID. */ sd_len = sizeof(SECURITY_DESCRIPTOR_ATTR) + 2 * (sizeof(SID) + 4) + - sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE); + sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE); sd = calloc(1, sd_len); if (!sd) { err = errno; @@ -1191,7 +1191,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, sid->sub_authority[0] = cpu_to_le32(32); sid->sub_authority[1] = cpu_to_le32(544); sid->identifier_authority.value[5] = 5; - sid = (SID*)((u8*)sid + sizeof(SID) + 4); + sid = (SID*)((u8*)sid + sizeof(SID) + 4); sd->group = cpu_to_le32((u8*)sid - (u8*)sd); sid->revision = 1; sid->sub_authority_count = 2; diff --git a/libntfs/index.c b/libntfs/index.c index dde8763b..0a5712f1 100644 --- a/libntfs/index.c +++ b/libntfs/index.c @@ -59,9 +59,9 @@ static VCN ntfs_ib_pos_to_vcn(ntfs_index_context *icx, s64 pos) static int ntfs_ib_write(ntfs_index_context *icx, VCN vcn, void *buf) { s64 ret; - + ntfs_log_trace("vcn: %lld\n", vcn); - + ret = ntfs_attr_mst_pwrite(icx->ia_na, ntfs_ib_vcn_to_pos(icx, vcn), 1, icx->block_size, buf); if (ret != 1) { @@ -76,9 +76,9 @@ static int ntfs_icx_ib_write(ntfs_index_context *icx) { if (ntfs_ib_write(icx, icx->ib_vcn, icx->ib)) return STATUS_ERROR; - + icx->ib_dirty = FALSE; - + return STATUS_OK; } @@ -97,7 +97,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *ni, ntfs_index_context *icx; ntfs_log_trace("Entering.\n"); - + if (!ni) { errno = EINVAL; return NULL; @@ -117,7 +117,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *ni, static void ntfs_index_ctx_free(ntfs_index_context *icx) { ntfs_log_trace("Entering.\n"); - + if (!icx->entry) return; @@ -134,7 +134,7 @@ static void ntfs_index_ctx_free(ntfs_index_context *icx) /* FIXME: Error handling!!! */ ntfs_ib_write(icx, icx->ib_vcn, icx->ib); } - + free(icx->ib); ntfs_attr_close(icx->ia_na); } @@ -160,9 +160,9 @@ void ntfs_index_ctx_put(ntfs_index_context *icx) void ntfs_index_ctx_reinit(ntfs_index_context *icx) { ntfs_log_trace("Entering.\n"); - + ntfs_index_ctx_free(icx); - + *icx = (ntfs_index_context) { .ni = icx->ni, .name = icx->name, @@ -204,13 +204,13 @@ static int ntfs_ie_end(INDEX_ENTRY *ie) return ie->flags & INDEX_ENTRY_END; } -/** +/** * Find the last entry in the index block */ static INDEX_ENTRY *ntfs_ie_get_last(INDEX_ENTRY *ie, char *ies_end) { ntfs_log_trace("Entering.\n"); - + while ((char *)ie < ies_end && !ntfs_ie_end(ie)) ie = ntfs_ie_get_next(ie); return ie; @@ -219,9 +219,9 @@ static INDEX_ENTRY *ntfs_ie_get_last(INDEX_ENTRY *ie, char *ies_end) static INDEX_ENTRY *ntfs_ie_get_by_pos(INDEX_HEADER *ih, int pos) { ntfs_log_trace("pos: %d\n", pos); - + INDEX_ENTRY *ie = ntfs_ie_get_first(ih); - + while (pos-- > 0) ie = ntfs_ie_get_next(ie); return ie; @@ -230,10 +230,10 @@ static INDEX_ENTRY *ntfs_ie_get_by_pos(INDEX_HEADER *ih, int pos) static INDEX_ENTRY *ntfs_ie_prev(INDEX_HEADER *ih, INDEX_ENTRY *ie) { ntfs_log_trace("Entering.\n"); - + INDEX_ENTRY *ie_prev = NULL; INDEX_ENTRY *tmp = ntfs_ie_get_first(ih); - + while (tmp != ie) { ie_prev = tmp; tmp = ntfs_ie_get_next(tmp); @@ -270,9 +270,9 @@ void ntfs_ie_filename_dump(INDEX_ENTRY *ie) void ntfs_ih_filename_dump(INDEX_HEADER *ih) { INDEX_ENTRY *ie; - + ntfs_log_trace("Entering.\n"); - + ie = ntfs_ie_get_first(ih); while (!ntfs_ie_end(ie)) { ntfs_ie_filename_dump(ie); @@ -284,9 +284,9 @@ static int ntfs_ih_numof_entries(INDEX_HEADER *ih) { int n; INDEX_ENTRY *ie; - + ntfs_log_trace("Entering.\n"); - + ie = ntfs_ie_get_first(ih); for (n = 0; !ntfs_ie_end(ie); n++) ie = ntfs_ie_get_next(ie); @@ -306,9 +306,9 @@ static int ntfs_ih_zero_entry(INDEX_HEADER *ih) static void ntfs_ie_delete(INDEX_HEADER *ih, INDEX_ENTRY *ie) { u32 new_size; - + ntfs_log_trace("Entering.\n"); - + new_size = le32_to_cpu(ih->index_length) - le16_to_cpu(ie->length); ih->index_length = cpu_to_le32(new_size); memmove(ie, (u8 *)ie + le16_to_cpu(ie->length), @@ -326,9 +326,9 @@ static void ntfs_ie_set_vcn(INDEX_ENTRY *ie, VCN vcn) static void ntfs_ie_insert(INDEX_HEADER *ih, INDEX_ENTRY *ie, INDEX_ENTRY *pos) { int ie_size = le16_to_cpu(ie->length); - + ntfs_log_trace("Entering.\n"); - + ih->index_length = cpu_to_le32(le32_to_cpu(ih->index_length) + ie_size); memmove((u8 *)pos + ie_size, pos, le32_to_cpu(ih->index_length) - ((u8 *)pos - (u8 *)ih) - @@ -339,9 +339,9 @@ static void ntfs_ie_insert(INDEX_HEADER *ih, INDEX_ENTRY *ie, INDEX_ENTRY *pos) static INDEX_ENTRY *ntfs_ie_dup(INDEX_ENTRY *ie) { INDEX_ENTRY *dup; - + ntfs_log_trace("Entering.\n"); - + dup = ntfs_malloc(ie->length); if (dup) memcpy(dup, ie, ie->length); @@ -352,16 +352,16 @@ static INDEX_ENTRY *ntfs_ie_dup_novcn(INDEX_ENTRY *ie) { INDEX_ENTRY *dup; int size = ie->length; - + ntfs_log_trace("Entering.\n"); - + if (ie->flags & INDEX_ENTRY_NODE) size -= sizeof(VCN); - + dup = ntfs_malloc(size); if (dup) memcpy(dup, ie, size); - + dup->flags &= ~INDEX_ENTRY_NODE; dup->length = size; return dup; @@ -370,30 +370,30 @@ static INDEX_ENTRY *ntfs_ie_dup_novcn(INDEX_ENTRY *ie) static int ntfs_ia_check(ntfs_index_context *icx, INDEX_BLOCK *ib, VCN vcn) { u32 ib_size = (unsigned)le32_to_cpu(ib->index.allocated_size) + 0x18; - + ntfs_log_trace("Entering.\n"); - + if (!ntfs_is_indx_record(ib->magic)) { - + ntfs_log_error("Corrupt index block signature: vcn %lld inode " "%llu\n", (long long)vcn, icx->ni->mft_no); return -1; } - + if (sle64_to_cpu(ib->index_block_vcn) != vcn) { - + ntfs_log_error("Corrupt index block: VCN (%lld) is different " "from expected VCN (%lld) in inode %llu\n", (long long) sle64_to_cpu(ib->index_block_vcn), (long long)vcn, icx->ni->mft_no); return -1; } - + if (ib_size != icx->block_size) { - + ntfs_log_error("Corrupt index block : VCN (%lld) of inode %llu " "has a size (%u) differing from the index " - "specified size (%u)\n", (long long)vcn, + "specified size (%u)\n", (long long)vcn, icx->ni->mft_no, ib_size, icx->block_size); return -1; } @@ -407,26 +407,26 @@ static INDEX_ROOT *ntfs_ir_lookup(ntfs_inode *ni, ntfschar *name, INDEX_ROOT *ir = NULL; ntfs_log_trace("Entering.\n"); - + *ctx = ntfs_attr_get_search_ctx(ni, NULL); if (!*ctx) { ntfs_log_perror("Failed to get $INDEX_ROOT search context"); return NULL; } - - if (ntfs_attr_lookup(AT_INDEX_ROOT, name, name_len, CASE_SENSITIVE, + + if (ntfs_attr_lookup(AT_INDEX_ROOT, name, name_len, CASE_SENSITIVE, 0, NULL, 0, *ctx)) { ntfs_log_perror("Failed to lookup $INDEX_ROOT"); goto err_out; } - + a = (*ctx)->attr; if (a->non_resident) { errno = EINVAL; ntfs_log_perror("Non-resident $INDEX_ROOT detected"); goto err_out; } - + ir = (INDEX_ROOT *)((char *)a + le16_to_cpu(a->value_offset)); err_out: if (!ir) @@ -434,11 +434,11 @@ err_out: return ir; } -/** +/** * Find a key in the index block. - * + * * Return values: - * STATUS_OK with errno set to ESUCCESS if we know for sure that the + * STATUS_OK with errno set to ESUCCESS if we know for sure that the * entry exists and @ie_out points to this entry. * STATUS_NOT_FOUND with errno set to ENOENT if we know for sure the * entry doesn't exist and @ie_out is the insertion point. @@ -453,11 +453,11 @@ static int ntfs_ie_lookup(const void *key, const int key_len, INDEX_ENTRY *ie; u8 *index_end; int rc, item = 0; - + ntfs_log_trace("Entering.\n"); - + index_end = ntfs_ie_get_end(ih); - + /* * Loop until we exceed valid memory (corruption case) or until we * reach the last entry. @@ -496,14 +496,14 @@ static int ntfs_ie_lookup(const void *key, const int key_len, */ if (rc == -1) break; - + if (!rc) { *ie_out = ie; errno = 0; icx->parent_pos[icx->pindex] = item; return STATUS_OK; } - + item++; } /* @@ -517,7 +517,7 @@ static int ntfs_ie_lookup(const void *key, const int key_len, errno = ENOENT; return STATUS_NOT_FOUND; } - + /* Get the starting vcn of the index_block holding the child node. */ *vcn = ntfs_ie_get_vcn(ie); if (*vcn < 0) { @@ -535,7 +535,7 @@ static int ntfs_ie_lookup(const void *key, const int key_len, static ntfs_attr *ntfs_ia_open(ntfs_index_context *icx, ntfs_inode *ni) { ntfs_attr *na; - + na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, icx->name, icx->name_len); if (!na) { ntfs_log_perror("Failed to open index allocation of inode " @@ -550,7 +550,7 @@ static int ntfs_ib_read(ntfs_index_context *icx, VCN vcn, INDEX_BLOCK *dst) s64 pos, ret; ntfs_log_trace("vcn: %lld\n", vcn); - + pos = ntfs_ib_vcn_to_pos(icx, vcn); ret = ntfs_attr_mst_pread(icx->ia_na, pos, 1, icx->block_size, @@ -558,12 +558,12 @@ static int ntfs_ib_read(ntfs_index_context *icx, VCN vcn, INDEX_BLOCK *dst) if (ret != 1) { if (ret == -1) ntfs_log_perror("Failed to read index block"); - else + else ntfs_log_error("Failed to read full index block at " "%lld\n", pos); return -1; } - + if (ntfs_ia_check(icx, dst, vcn)) return -1; return 0; @@ -590,7 +590,7 @@ static int ntfs_icx_parent_dec(ntfs_index_context *icx) } return STATUS_OK; } - + /** * ntfs_index_lookup - find a key in an index and return its index entry * @key: [IN] key for which to search in the index @@ -635,7 +635,7 @@ int ntfs_index_lookup(const void *key, const int key_len, int ret, err = 0; ntfs_log_trace("Entering.\n"); - + if (!key || key_len <= 0) { errno = EINVAL; ntfs_log_perror("key: %p key_len: %d", key, key_len); @@ -648,7 +648,7 @@ int ntfs_index_lookup(const void *key, const int key_len, errno = EIO; return -1; } - + icx->block_size = le32_to_cpu(ir->index_block_size); if (icx->block_size < NTFS_BLOCK_SIZE) { errno = EINVAL; @@ -662,17 +662,17 @@ int ntfs_index_lookup(const void *key, const int key_len, icx->vcn_size_bits = ni->vol->cluster_size_bits; else icx->vcn_size_bits = ni->vol->sector_size_bits; - + icx->cr = ir->collation_rule; if (!ntfs_is_collation_rule_supported(icx->cr)) { err = errno = EOPNOTSUPP; - ntfs_log_perror("Unknown collation rule 0x%x", + ntfs_log_perror("Unknown collation rule 0x%x", (unsigned)le32_to_cpu(icx->cr)); goto err_out; } - + old_vcn = VCN_INDEX_ROOT_PARENT; - /* + /* * FIXME: check for both ir and ib that the first index entry is * within the index block. */ @@ -681,10 +681,10 @@ int ntfs_index_lookup(const void *key, const int key_len, err = errno; goto err_out; } - + icx->actx = actx; icx->ir = ir; - + if (ret != STATUS_KEEP_SEARCHING) { /* STATUS_OK or STATUS_NOT_FOUND */ err = errno; @@ -692,18 +692,18 @@ int ntfs_index_lookup(const void *key, const int key_len, icx->parent_vcn[icx->pindex] = old_vcn; goto done; } - + /* Child node present, descend into it. */ icx->ia_na = ntfs_ia_open(icx, ni); if (!icx->ia_na) goto err_out; - + ib = ntfs_malloc(icx->block_size); if (!ib) { err = errno; goto err_out; } - + descend_into_child_node: icx->parent_vcn[icx->pindex] = old_vcn; if (ntfs_icx_parent_inc(icx)) { @@ -713,16 +713,16 @@ descend_into_child_node: old_vcn = vcn; ntfs_log_debug("Descend into node with VCN %lld.\n", vcn); - + if (ntfs_ib_read(icx, vcn, ib)) goto err_out; - + ret = ntfs_ie_lookup(key, key_len, icx, &ib->index, &vcn, &ie); if (ret != STATUS_KEEP_SEARCHING) { err = errno; if (ret == STATUS_ERROR) goto err_out; - + /* STATUS_OK or STATUS_NOT_FOUND */ icx->is_in_root = FALSE; icx->ib = ib; @@ -735,7 +735,7 @@ descend_into_child_node: "node in inode 0x%llx.\n", ni->mft_no); goto err_out; } - + goto descend_into_child_node; err_out: if (icx->ia_na) { @@ -762,38 +762,38 @@ done: return 0; } -static INDEX_BLOCK *ntfs_ib_alloc(VCN ib_vcn, int ib_size, +static INDEX_BLOCK *ntfs_ib_alloc(VCN ib_vcn, int ib_size, INDEX_HEADER_FLAGS node_type) { INDEX_BLOCK *ib; int ih_size = sizeof(INDEX_HEADER); - + ntfs_log_trace("Entering ib_vcn = %lld ib_size = %d\n", ib_vcn, ib_size); - + ib = ntfs_calloc(ib_size); if (!ib) return NULL; - + ib->magic = magic_INDX; ib->usa_ofs = 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); - + 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.allocated_size = cpu_to_le32(ib_size - + ib->index.allocated_size = cpu_to_le32(ib_size - (sizeof(INDEX_BLOCK) - ih_size)); ib->index.flags = node_type; return ib; -} +} -/** +/** * Find the median by going through all the entries */ static INDEX_ENTRY *ntfs_ie_get_median(INDEX_HEADER *ih) @@ -801,12 +801,12 @@ static INDEX_ENTRY *ntfs_ie_get_median(INDEX_HEADER *ih) INDEX_ENTRY *ie, *ie_start; u8 *ie_end; int i = 0, median; - + ntfs_log_trace("Entering.\n"); - + ie = ie_start = ntfs_ie_get_first(ih); ie_end = (u8 *)ntfs_ie_get_end(ih); - + while ((u8 *)ie < ie_end && !ntfs_ie_end(ie)) { ie = ntfs_ie_get_next(ie); i++; @@ -815,12 +815,12 @@ static INDEX_ENTRY *ntfs_ie_get_median(INDEX_HEADER *ih) * NOTE: this could be also the entry at the half of the index block. */ median = i / 2 - 1; - + ntfs_log_trace("Entries: %d median: %d\n", i, median); - + for (i = 0, ie = ie_start; i <= median; i++) ie = ntfs_ie_get_next(ie); - + return ie; } @@ -839,7 +839,7 @@ static int ntfs_ibm_add(ntfs_index_context *icx) u8 bmp[8]; ntfs_log_trace("Entering.\n"); - + if (ntfs_attr_exist(icx->ni, AT_BITMAP, icx->name, icx->name_len)) return STATUS_OK; /* @@ -864,7 +864,7 @@ static int ntfs_ibm_modify(ntfs_index_context *icx, VCN vcn, int set) int ret = STATUS_ERROR; ntfs_log_trace("%s vcn: %lld\n", set ? "set" : "clear", vcn); - + na = ntfs_attr_open(icx->ni, AT_BITMAP, icx->name, icx->name_len); if (!na) { ntfs_log_perror("Failed to open $BITMAP attribute"); @@ -879,17 +879,17 @@ static int ntfs_ibm_modify(ntfs_index_context *icx, VCN vcn, int set) } } } - + if (ntfs_attr_pread(na, bpos, 1, &byte) != 1) { ntfs_log_perror("Failed to read $BITMAP"); goto err_na; } - if (set) + if (set) byte |= bit; else byte &= ~bit; - + if (ntfs_attr_pwrite(na, bpos, 1, &byte) != 1) { ntfs_log_perror("Failed to write $Bitmap"); goto err_na; @@ -919,17 +919,17 @@ static VCN ntfs_ibm_get_free(ntfs_index_context *icx) s64 vcn, byte, size; ntfs_log_trace("Entering.\n"); - + bm = ntfs_attr_readall(icx->ni, AT_BITMAP, icx->name, icx->name_len, &size); if (!bm) return (VCN)-1; - + for (byte = 0; byte < size; byte++) { - + if (bm[byte] == 255) continue; - + for (bit = 0; bit < 8; bit++) { if (!(bm[byte] & (1 << bit))) { vcn = ntfs_ibm_pos_to_vcn(icx, byte * 8 + bit); @@ -937,14 +937,14 @@ static VCN ntfs_ibm_get_free(ntfs_index_context *icx) } } } - + vcn = ntfs_ibm_pos_to_vcn(icx, size * 8); -out: +out: ntfs_log_trace("allocated vcn: %lld\n", vcn); if (ntfs_ibm_set(icx, vcn)) vcn = (VCN)-1; - + free(bm); return vcn; } @@ -955,28 +955,28 @@ static INDEX_BLOCK *ntfs_ir_to_ia(INDEX_ROOT *ir, VCN ib_vcn) INDEX_ENTRY *ie_last; char *ies_start, *ies_end; int i; - + ntfs_log_trace("Entering.\n"); - + ib = ntfs_ib_alloc(ib_vcn, ir->index_block_size, LEAF_NODE); if (!ib) return NULL; - + ies_start = (char *)ntfs_ie_get_first(&ir->index); ies_end = (char *)ntfs_ie_get_end(&ir->index); - + ie_last = ntfs_ie_get_last((INDEX_ENTRY *)ies_start, ies_end); - /* + /* * Copy all entries, including the termination entry * as well, which can never have any data. */ i = (char *)ie_last - ies_start + le16_to_cpu(ie_last->length); memcpy(ntfs_ie_get_first(&ib->index), ies_start, i); - + ib->index.flags = ir->index.flags; ib->index.index_length = cpu_to_le32(i + le32_to_cpu(ib->index.entries_offset)); - /* + /* * Move the index root termination entry forward */ if ((char *)ie_last > ies_start) { @@ -987,27 +987,27 @@ static INDEX_BLOCK *ntfs_ir_to_ia(INDEX_ROOT *ir, VCN ib_vcn) return ib; } -static int ntfs_ib_copy_tail(ntfs_index_context *icx, INDEX_BLOCK *src, +static int ntfs_ib_copy_tail(ntfs_index_context *icx, INDEX_BLOCK *src, INDEX_BLOCK *dst, INDEX_ENTRY *median, VCN new_vcn) { u8 *ies_end; INDEX_ENTRY *ie_head; /* first entry after the median */ int tail_size; - + ntfs_log_trace("Entering.\n"); - + ie_head = ntfs_ie_get_next(median); - + ies_end = (u8 *)ntfs_ie_get_end(&src->index); tail_size = ies_end - (u8 *)ie_head; memcpy(ntfs_ie_get_first(&dst->index), ie_head, tail_size); - + dst->index.index_length = cpu_to_le32(tail_size + le32_to_cpu(dst->index.entries_offset)); - + if (ntfs_ib_write(icx, new_vcn, dst)) return STATUS_ERROR; - + return STATUS_OK; } @@ -1016,34 +1016,34 @@ static int ntfs_ib_cut_tail(ntfs_index_context *icx, INDEX_BLOCK *src, { char *ies_start, *ies_end; INDEX_ENTRY *ie_last; - + ntfs_log_trace("Entering.\n"); - + ies_start = (char *)ntfs_ie_get_first(&src->index); ies_end = (char *)ntfs_ie_get_end(&src->index); - + ie_last = ntfs_ie_get_last((INDEX_ENTRY *)ies_start, ies_end); if (ie_last->flags & INDEX_ENTRY_NODE) ntfs_ie_set_vcn(ie_last, ntfs_ie_get_vcn(ie)); - + memcpy(ie, ie_last, ie_last->length); - - src->index.index_length = cpu_to_le32(((char *)ie - ies_start) + + + src->index.index_length = cpu_to_le32(((char *)ie - ies_start) + ie->length + le32_to_cpu(src->index.entries_offset)); - + if (ntfs_ib_write(icx, icx->parent_vcn[icx->pindex + 1], src)) return STATUS_ERROR; - + return STATUS_OK; } - + static int ntfs_ia_add(ntfs_index_context *icx) { ntfs_log_trace("Entering.\n"); if (ntfs_ibm_add(icx)) return -1; - + if (!ntfs_attr_exist(icx->ni, AT_INDEX_ALLOCATION, icx->name, icx->name_len)) { if (ntfs_attr_add(icx->ni, AT_INDEX_ALLOCATION, icx->name, @@ -1052,7 +1052,7 @@ static int ntfs_ia_add(ntfs_index_context *icx) return -1; } } - + icx->ia_na = ntfs_ia_open(icx, icx->ni); if (!icx->ia_na) return -1; @@ -1117,23 +1117,23 @@ err_out: /** * ntfs_ir_truncate - Truncate index root attribute - * + * * Returns STATUS_OK, STATUS_RESIDENT_ATTRIBUTE_FILLED_MFT or STATUS_ERROR. */ static int ntfs_ir_truncate(ntfs_index_context *icx, int data_size) -{ +{ ntfs_attr *na; int ret; ntfs_log_trace("Entering.\n"); - + na = ntfs_attr_open(icx->ni, AT_INDEX_ROOT, icx->name, icx->name_len); if (!na) { ntfs_log_perror("Failed to open INDEX_ROOT"); return STATUS_ERROR; } /* - * INDEX_ROOT must be resident and its entries can be moved to + * INDEX_ROOT must be resident and its entries can be moved to * INDEX_BLOCK, so ENOSPC isn't a real error. */ ret = ntfs_attr_truncate(na, data_size + offsetof(INDEX_ROOT, index)); @@ -1144,7 +1144,7 @@ static int ntfs_ir_truncate(ntfs_index_context *icx, int data_size) &ctx); if (!icx->ir) return STATUS_ERROR; - + icx->ir->index.allocated_size = cpu_to_le32(data_size); ntfs_attr_put_search_ctx(ctx); @@ -1158,19 +1158,19 @@ static int ntfs_ir_truncate(ntfs_index_context *icx, int data_size) ntfs_attr_close(na); return ret; } - + /** * ntfs_ir_make_space - Make more space for the index root attribute - * + * * On success return STATUS_OK or STATUS_KEEP_SEARCHING. * On error return STATUS_ERROR. */ static int ntfs_ir_make_space(ntfs_index_context *icx, int data_size) -{ +{ int ret; ntfs_log_trace("Entering.\n"); - + ret = ntfs_ir_truncate(icx, data_size); if (ret == STATUS_RESIDENT_ATTRIBUTE_FILLED_MFT) { ret = ntfs_ir_reparent(icx); @@ -1178,7 +1178,7 @@ static int ntfs_ir_make_space(ntfs_index_context *icx, int data_size) ret = STATUS_KEEP_SEARCHING; else ntfs_log_perror("Failed to nodify INDEX_ROOT"); - } + } return ret; } @@ -1188,30 +1188,30 @@ static int ntfs_ir_make_space(ntfs_index_context *icx, int data_size) static int ntfs_ie_add_vcn(INDEX_ENTRY **ie) { INDEX_ENTRY *p, *old = *ie; - + old->length += sizeof(VCN); p = realloc(old, old->length); if (!p) return STATUS_ERROR; - + p->flags |= INDEX_ENTRY_NODE; *ie = p; return STATUS_OK; } -static int ntfs_ih_insert(INDEX_HEADER *ih, INDEX_ENTRY *orig_ie, VCN new_vcn, +static int ntfs_ih_insert(INDEX_HEADER *ih, INDEX_ENTRY *orig_ie, VCN new_vcn, int pos) { INDEX_ENTRY *ie_node, *ie; int ret = STATUS_ERROR; VCN old_vcn; - + ntfs_log_trace("Entering.\n"); - + ie = ntfs_ie_dup(orig_ie); if (!ie) return STATUS_ERROR; - + if (!(ie->flags & INDEX_ENTRY_NODE)) if (ntfs_ie_add_vcn(&ie)) goto out; @@ -1219,11 +1219,11 @@ static int ntfs_ih_insert(INDEX_HEADER *ih, INDEX_ENTRY *orig_ie, VCN new_vcn, ie_node = ntfs_ie_get_by_pos(ih, pos); old_vcn = ntfs_ie_get_vcn(ie_node); ntfs_ie_set_vcn(ie_node, new_vcn); - + ntfs_ie_insert(ih, ie, ie_node); ntfs_ie_set_vcn(ie_node, old_vcn); ret = STATUS_OK; -out: +out: free(ie); return ret; } @@ -1243,9 +1243,9 @@ static int ntfs_ir_insert_median(ntfs_index_context *icx, INDEX_ENTRY *median, { u32 new_size; int ret; - + ntfs_log_trace("Entering.\n"); - + new_size = le32_to_cpu(icx->ir->index.index_length) + median->length; if (!(median->flags & INDEX_ENTRY_NODE)) new_size += sizeof(VCN); @@ -1254,7 +1254,7 @@ static int ntfs_ir_insert_median(ntfs_index_context *icx, INDEX_ENTRY *median, if (ret != STATUS_OK) return ret; - return ntfs_ih_insert(&icx->ir->index, median, new_vcn, + return ntfs_ih_insert(&icx->ir->index, median, new_vcn, ntfs_icx_parent_pos(icx)); } @@ -1267,20 +1267,20 @@ static int ntfs_ib_split(ntfs_index_context *icx, INDEX_BLOCK *ib); * On error return STATUS_ERROR. */ static int ntfs_ib_insert(ntfs_index_context *icx, INDEX_ENTRY *ie, VCN new_vcn) -{ +{ INDEX_BLOCK *ib; u32 idx_size, allocated_size; int err = STATUS_ERROR; VCN old_vcn; ntfs_log_trace("Entering.\n"); - + ib = ntfs_malloc(icx->block_size); if (!ib) return -1; - + old_vcn = ntfs_icx_parent_vcn(icx); - + if (ntfs_ib_read(icx, old_vcn, ib)) goto err_out; @@ -1293,65 +1293,65 @@ static int ntfs_ib_insert(ntfs_index_context *icx, INDEX_ENTRY *ie, VCN new_vcn) err = STATUS_KEEP_SEARCHING; goto err_out; } - + if (ntfs_ih_insert(&ib->index, ie, new_vcn, ntfs_icx_parent_pos(icx))) goto err_out; - + if (ntfs_ib_write(icx, old_vcn, ib)) goto err_out; - + err = STATUS_OK; -err_out: +err_out: free(ib); return err; } /** * ntfs_ib_split - Split index allocation attribute - * + * * On success return STATUS_OK or STATUS_KEEP_SEARCHING. * On error return is STATUS_ERROR. */ static int ntfs_ib_split(ntfs_index_context *icx, INDEX_BLOCK *ib) -{ +{ INDEX_BLOCK *ib_new; INDEX_ENTRY *median; VCN new_vcn; int ret, err = STATUS_ERROR; ntfs_log_trace("Entering.\n"); - + if (ntfs_icx_parent_dec(icx)) return STATUS_ERROR; - + median = ntfs_ie_get_median(&ib->index); new_vcn = ntfs_ibm_get_free(icx); if (new_vcn == -1) return STATUS_ERROR; - + if (ntfs_icx_parent_vcn(icx) == VCN_INDEX_ROOT_PARENT) ret = ntfs_ir_insert_median(icx, median, new_vcn); else ret = ntfs_ib_insert(icx, median, new_vcn); - + ntfs_inode_mark_dirty(icx->actx->ntfs_ino); - + if (ret != STATUS_OK) { ntfs_ibm_clear(icx, new_vcn); return ret; } - - ib_new = ntfs_ib_alloc(new_vcn, icx->block_size, + + ib_new = ntfs_ib_alloc(new_vcn, icx->block_size, ib->index.flags & NODE_MASK); if (!ib_new) return STATUS_ERROR; - + if (ntfs_ib_copy_tail(icx, ib, ib_new, median, new_vcn)) goto free_ib_new; - + if (ntfs_ib_cut_tail(icx, ib, median)) goto free_ib_new; - + err = STATUS_OK; free_ib_new: free(ib_new); @@ -1364,10 +1364,10 @@ static int ntfs_ie_add(ntfs_index_context *icx, INDEX_ENTRY *ie) INDEX_HEADER *ih; int allocated_size, new_size; int ret = STATUS_ERROR; - + fn = ntfs_ie_filename_get(ie); ntfs_log_trace("file: '%s'\n", fn); - + while (1) { if (!ntfs_index_lookup(&ie->key, le16_to_cpu(ie->key_length), icx)) { @@ -1379,22 +1379,22 @@ static int ntfs_ie_add(ntfs_index_context *icx, INDEX_ENTRY *ie) ntfs_log_perror("Failed to find place for new entry"); goto err_out; } - + if (icx->is_in_root) ih = &icx->ir->index; else ih = &icx->ib->index; - + allocated_size = le32_to_cpu(ih->allocated_size); new_size = le32_to_cpu(ih->index_length) + le16_to_cpu(ie->length); - + if (new_size <= allocated_size) break; - + ntfs_log_trace("index block sizes: allocated: %d needed: %d\n", allocated_size, new_size); - + if (icx->is_in_root) { if (ntfs_ir_make_space(icx, new_size) == STATUS_ERROR) goto err_out; @@ -1405,10 +1405,10 @@ static int ntfs_ie_add(ntfs_index_context *icx, INDEX_ENTRY *ie) ntfs_inode_mark_dirty(icx->actx->ntfs_ino); ntfs_index_ctx_reinit(icx); } - + ntfs_ie_insert(ih, ie, icx->entry); ntfs_index_entry_mark_dirty(icx); - + ret = STATUS_OK; err_out: free(fn); @@ -1431,17 +1431,17 @@ int ntfs_index_add_filename(ntfs_inode *ni, FILE_NAME_ATTR *fn, MFT_REF mref) int fn_size, ie_size, ret = -1; ntfs_log_trace("Entering.\n"); - + if (!ni || !fn) { ntfs_log_error("Invalid arguments.\n"); errno = EINVAL; return -1; } - + fn_size = (fn->file_name_length * sizeof(ntfschar)) + sizeof(FILE_NAME_ATTR); ie_size = (sizeof(INDEX_ENTRY_HEADER) + fn_size + 7) & ~7; - + ie = ntfs_calloc(ie_size); if (!ie) return -1; @@ -1450,13 +1450,13 @@ int ntfs_index_add_filename(ntfs_inode *ni, FILE_NAME_ATTR *fn, MFT_REF mref) ie->length = cpu_to_le16(ie_size); ie->key_length = cpu_to_le16(fn_size); memcpy(&ie->key, fn, fn_size); - + icx = ntfs_index_ctx_get(ni, NTFS_INDEX_I30, 4); if (!icx) goto out; - + ret = ntfs_ie_add(icx, ie); - + ntfs_index_ctx_put(icx); out: free(ie); @@ -1468,9 +1468,9 @@ static int ntfs_ih_takeout(ntfs_index_context *icx, INDEX_HEADER *ih, { INDEX_ENTRY *ie_roam; int ret = STATUS_ERROR; - + ntfs_log_trace("Entering.\n"); - + ie_roam = ntfs_ie_dup_novcn(ie); if (!ie_roam) return STATUS_ERROR; @@ -1482,7 +1482,7 @@ static int ntfs_ih_takeout(ntfs_index_context *icx, INDEX_HEADER *ih, else if (ntfs_ib_write(icx, ntfs_icx_parent_vcn(icx), ib)) goto out; - + ntfs_index_ctx_reinit(icx); ret = ntfs_ie_add(icx, ie_roam); @@ -1493,26 +1493,26 @@ out: /** * ntfs_ir_leafify - - * + * * Used if an empty index block to be deleted has END entry as the parent * in the INDEX_ROOT which is the only one there. */ static void ntfs_ir_leafify(ntfs_index_context *icx, INDEX_HEADER *ih) { INDEX_ENTRY *ie; - + ntfs_log_trace("Entering.\n"); - + ie = ntfs_ie_get_first(ih); ie->flags &= ~INDEX_ENTRY_NODE; ie->length -= sizeof(VCN); - + ih->index_length -= sizeof(VCN); ih->flags &= ~LARGE_INDEX; - + /* Not fatal error */ ntfs_ir_truncate(icx, le32_to_cpu(ih->index_length)); - + ntfs_inode_mark_dirty(icx->actx->ntfs_ino); ntfs_index_ctx_reinit(icx); } @@ -1520,19 +1520,19 @@ static void ntfs_ir_leafify(ntfs_index_context *icx, INDEX_HEADER *ih) /** * ntfs_ih_reparent_end - * - * Used if an empty index block to be deleted has END entry as the parent + * Used if an empty index block to be deleted has END entry as the parent * in the INDEX_ROOT which is not the only one there. */ static int ntfs_ih_reparent_end(ntfs_index_context *icx, INDEX_HEADER *ih, INDEX_BLOCK *ib) { INDEX_ENTRY *ie, *ie_prev; - + ntfs_log_trace("Entering.\n"); - + ie = ntfs_ie_get_by_pos(ih, ntfs_icx_parent_pos(icx)); ie_prev = ntfs_ie_prev(ih, ie); - + ntfs_ie_set_vcn(ie, ntfs_ie_get_vcn(ie_prev)); return ntfs_ih_takeout(icx, ih, ie_prev, ib); } @@ -1543,48 +1543,48 @@ static int ntfs_index_rm_leaf(ntfs_index_context *icx) INDEX_HEADER *parent_ih; INDEX_ENTRY *ie; int ret = STATUS_ERROR; - + ntfs_log_trace("pindex: %d\n", icx->pindex); - + if (ntfs_icx_parent_dec(icx)) return STATUS_ERROR; if (ntfs_ibm_clear(icx, icx->parent_vcn[icx->pindex + 1])) return STATUS_ERROR; - + if (ntfs_icx_parent_vcn(icx) == VCN_INDEX_ROOT_PARENT) parent_ih = &icx->ir->index; else { ib = ntfs_malloc(icx->block_size); if (!ib) return STATUS_ERROR; - + if (ntfs_ib_read(icx, ntfs_icx_parent_vcn(icx), ib)) goto out; - + parent_ih = &ib->index; } - + ie = ntfs_ie_get_by_pos(parent_ih, ntfs_icx_parent_pos(icx)); if (!ntfs_ie_end(ie)) { ret = ntfs_ih_takeout(icx, parent_ih, ie, ib); goto out; } - + if (ntfs_ih_zero_entry(parent_ih)) { - + if (ntfs_icx_parent_vcn(icx) == VCN_INDEX_ROOT_PARENT) { ntfs_ir_leafify(icx, parent_ih); goto ok; } - + ret = ntfs_index_rm_leaf(icx); goto out; } - + if (ntfs_ih_reparent_end(icx, parent_ih, ib)) goto out; -ok: +ok: ret = STATUS_OK; out: free(ib); @@ -1602,7 +1602,7 @@ static int ntfs_index_rm_node(ntfs_index_context *icx) int delta, ret = STATUS_ERROR; ntfs_log_trace("Entering.\n"); - + if (!icx->ia_na) { icx->ia_na = ntfs_ia_open(icx, icx->ni); if (!icx->ia_na) @@ -1612,19 +1612,19 @@ static int ntfs_index_rm_node(ntfs_index_context *icx) ib = ntfs_malloc(icx->block_size); if (!ib) return STATUS_ERROR; - + ie_succ = ntfs_ie_get_next(icx->entry); entry_pos = icx->parent_pos[icx->pindex]++; descend: vcn = ntfs_ie_get_vcn(ie_succ); if (ntfs_ib_read(icx, vcn, ib)) goto out; - + ie_succ = ntfs_ie_get_first(&ib->index); if (ntfs_icx_parent_inc(icx)) goto out; - + icx->parent_vcn[icx->pindex] = vcn; icx->parent_pos[icx->pindex] = 0; @@ -1641,7 +1641,7 @@ descend: ie = ntfs_ie_dup(ie_succ); if (!ie) goto out; - + if (ntfs_ie_add_vcn(&ie)) goto out2; @@ -1662,10 +1662,10 @@ descend: " during entry removal"); goto out2; } - + ih = &icx->ir->index; entry = ntfs_ie_get_by_pos(ih, entry_pos); - + } else if (new_size > ih->allocated_size) { errno = EOPNOTSUPP; ntfs_log_perror("Denied to split INDEX_BLOCK during " @@ -1676,7 +1676,7 @@ descend: ntfs_ie_delete(ih, entry); ntfs_ie_insert(ih, ie, entry); - + if (icx->is_in_root) { if (ntfs_ir_truncate(icx, new_size)) goto out2; @@ -1684,13 +1684,13 @@ descend: } else if (ntfs_icx_ib_write(icx)) goto out2; - + ntfs_ie_delete(&ib->index, ie_succ); - + if (ntfs_ih_zero_entry(&ib->index)) { if (ntfs_index_rm_leaf(icx)) goto out2; - } else + } else if (ntfs_ib_write(icx, vcn, ib)) goto out2; @@ -1706,8 +1706,8 @@ out: * ntfs_index_rm - remove entry from the index * @icx: index context describing entry to delete * - * Delete entry described by @icx from the index. Index context is always - * reinitialized after use of this function, so it can be used for index + * Delete entry described by @icx from the index. Index context is always + * reinitialized after use of this function, so it can be used for index * lookup once again. * * Return 0 on success or -1 on error with errno set to the error code. @@ -1718,7 +1718,7 @@ int ntfs_index_rm(ntfs_index_context *icx) int err; ntfs_log_trace("Entering.\n"); - + if (!icx || (!icx->ib && !icx->ir) || ntfs_ie_end(icx->entry)) { ntfs_log_error("Invalid arguments.\n"); errno = EINVAL; @@ -1728,16 +1728,16 @@ int ntfs_index_rm(ntfs_index_context *icx) ih = &icx->ir->index; else ih = &icx->ib->index; - + if (icx->entry->flags & INDEX_ENTRY_NODE) { - + if (ntfs_index_rm_node(icx)) goto err_out; } else if (icx->is_in_root || !ntfs_ih_one_entry(ih)) { - + ntfs_ie_delete(ih, icx->entry); - + if (icx->is_in_root) { err = ntfs_ir_truncate(icx, le32_to_cpu(ih->index_length)); @@ -1750,7 +1750,7 @@ int ntfs_index_rm(ntfs_index_context *icx) if (ntfs_index_rm_leaf(icx)) goto err_out; } - + ntfs_index_ctx_reinit(icx); ntfs_log_trace("Done.\n"); return 0; @@ -1765,7 +1765,7 @@ err_out: /** * ntfs_index_root_get - read the index root of an attribute * @ni: open ntfs inode in which the ntfs attribute resides - * @attr: attribute for which we want its index root + * @attr: attribute for which we want its index root * * This function will read the related index root an ntfs attribute. * @@ -1784,14 +1784,14 @@ INDEX_ROOT *ntfs_index_root_get(ntfs_inode *ni, ATTR_RECORD *attr) if (!ntfs_ir_lookup(ni, name, attr->name_length, &ctx)) return NULL; - + root = ntfs_malloc(sizeof(INDEX_ROOT)); if (!root) goto out; - + *root = *((INDEX_ROOT *)((u8 *)ctx->attr + le16_to_cpu(ctx->attr->value_offset))); -out: +out: ntfs_attr_put_search_ctx(ctx); return root; } diff --git a/libntfs/inode.c b/libntfs/inode.c index 2b1b9336..020cf1f2 100644 --- a/libntfs/inode.c +++ b/libntfs/inode.c @@ -1111,7 +1111,7 @@ void ntfs_inode_update_time(ntfs_inode *ni) * Check if the mft record given by @mft_no and @attr contains the bad sector * list. Please note that mft record numbers describing $Badclus extent inodes * will not match the current $Badclus:$Bad check. - * + * * On success return 1 if the file is $Badclus:$Bad, otherwise return 0. * On error return -1 with errno set to the error code. */ @@ -1125,7 +1125,7 @@ int ntfs_inode_badclus_bad(u64 mft_no, ATTR_RECORD *attr) errno = EINVAL; return -1; } - + if (mft_no != FILE_BadClus) return 0; diff --git a/libntfs/runlist.c b/libntfs/runlist.c index 6c9ccf0d..31a21aea 100644 --- a/libntfs/runlist.c +++ b/libntfs/runlist.c @@ -1586,31 +1586,31 @@ int ntfs_rl_truncate(runlist **arl, const VCN start_vcn) ntfs_log_perror("rl_truncate error: arl: %p *arl: %p", arl, *arl); return -1; } - + rl = *arl; - + if (start_vcn < rl->vcn) { errno = EINVAL; ntfs_log_perror("Start_vcn lies outside front of runlist"); return -1; } - + /* Find the starting vcn in the run list. */ while (rl->length) { if (start_vcn < rl[1].vcn) break; rl++; } - + if (!rl->length) { errno = EIO; ntfs_log_trace("Truncating already truncated runlist?\n"); return -1; } - + /* Truncate the run. */ rl->length = start_vcn - rl->vcn; - + /* * If a run was partially truncated, make the following runlist * element a terminator instead of the truncated runlist diff --git a/libntfs/unistr.c b/libntfs/unistr.c index db91b785..0660351d 100644 --- a/libntfs/unistr.c +++ b/libntfs/unistr.c @@ -708,12 +708,12 @@ void ntfs_upcase_table_build(ntfschar *uc, u32 uc_len) * @len: length of output buffer in Unicode characters * * Convert the input @s string into the corresponding little endian, - * 2-byte Unicode string. The length of the converted string is less + * 2-byte Unicode string. The length of the converted string is less * or equal to the maximum length allowed by the NTFS format (255). * * If @s is NULL then return AT_UNNAMED. * - * On success the function returns the Unicode string in an allocated + * On success the function returns the Unicode string in an allocated * buffer and the caller is responsible to free it when it's not needed * anymore. * diff --git a/libntfs/unix_io.c b/libntfs/unix_io.c index ee8d35db..028b3779 100644 --- a/libntfs/unix_io.c +++ b/libntfs/unix_io.c @@ -91,7 +91,7 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) /* * Open the device/file obtaining the file descriptor for exclusive * access (but only if mounting r/w). - */ + */ if ((flags & O_RDWR) == O_RDWR) flags |= O_EXCL; *(int*)dev->d_private = open(dev->d_name, flags); diff --git a/libntfs/volume.c b/libntfs/volume.c index a2fc9d98..3658016f 100644 --- a/libntfs/volume.c +++ b/libntfs/volume.c @@ -217,7 +217,7 @@ static int ntfs_mft_load(ntfs_volume *vol) } mft_has_no_attr_list: /* Receive attributes from STANDARD_INFORMATION. */ - std_info = ntfs_attr_readall(vol->mft_ni, AT_STANDARD_INFORMATION, + std_info = ntfs_attr_readall(vol->mft_ni, AT_STANDARD_INFORMATION, AT_UNNAMED, 0, NULL); vol->mft_ni->flags = std_info->file_attributes; @@ -815,7 +815,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags) ntfs_log_perror("Failed to read $MFTMirr"); else { ntfs_log_debug("Failed to read $MFTMirr, unexpected " - "length (%d != %lld).\n", + "length (%d != %lld).\n", vol->mftmirr_size, l); errno = EIO; } diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 14b0f7cb..8212c27c 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -2861,7 +2861,7 @@ static int initialize_quota(MFT_RECORD *m) INDEX_ENTRY *idx_entry_o, *idx_entry_q1, *idx_entry_q2; QUOTA_O_INDEX_DATA *idx_entry_o_data; QUOTA_CONTROL_ENTRY *idx_entry_q1_data, *idx_entry_q2_data; - + err = 0; /* q index entry num 1 */ q1_size = 0x48; @@ -3790,7 +3790,7 @@ static BOOL mkntfs_initialize_bitmaps(void) g_rl_mft_bmp = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_mft_bmp) return FALSE; - + g_rl_mft_bmp[0].vcn = 0LL; /* Mft bitmap is right after $Boot's data. */ i = (8192 + g_vol->cluster_size - 1) / g_vol->cluster_size; @@ -3855,7 +3855,7 @@ static BOOL mkntfs_initialize_rl_mft(void) g_rl_mft = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_mft) return FALSE; - + g_rl_mft[0].vcn = 0LL; g_rl_mft[0].lcn = g_mft_lcn; /* rounded up division by cluster size */ @@ -3876,7 +3876,7 @@ static BOOL mkntfs_initialize_rl_mft(void) g_rl_mftmirr = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_mftmirr) return FALSE; - + g_rl_mftmirr[0].vcn = 0LL; g_rl_mftmirr[0].lcn = g_mftmirr_lcn; /* @@ -3912,7 +3912,7 @@ static BOOL mkntfs_initialize_rl_logfile(void) g_rl_logfile = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_logfile) return FALSE; - + volume_size = g_vol->nr_clusters << g_vol->cluster_size_bits; @@ -3935,7 +3935,7 @@ static BOOL mkntfs_initialize_rl_logfile(void) g_logfile_size = (volume_size / 100) & ~(g_vol->cluster_size - 1); } else { - /* + /* * FIXME: The $LogFile size is 64 MiB upwards from 12GiB but * the "200" divider below apparently approximates "100" or * some other value as the volume size decreases. For example: @@ -3996,7 +3996,7 @@ static BOOL mkntfs_initialize_rl_boot(void) g_rl_boot = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_boot) return FALSE; - + g_rl_boot[0].vcn = 0LL; g_rl_boot[0].lcn = 0LL; /* @@ -4023,7 +4023,7 @@ static BOOL mkntfs_initialize_rl_bad(void) g_rl_bad = ntfs_malloc(2 * sizeof(runlist)); if (!g_rl_bad) return FALSE; - + g_rl_bad[0].vcn = 0LL; g_rl_bad[0].lcn = -1LL; /* @@ -4498,7 +4498,7 @@ static BOOL mkntfs_create_root_structures(void) buf_log = ntfs_malloc(g_logfile_size); if (!buf_log) return FALSE; - + memset(buf_log, -1, g_logfile_size); err = add_attr_data_positioned(m, NULL, 0, 0, 0, g_rl_logfile, buf_log, g_logfile_size); @@ -4969,7 +4969,7 @@ static int mkntfs_redirect(struct mkntfs_options *opts2) g_vol->upcase = ntfs_malloc(g_vol->upcase_len * sizeof(ntfschar)); if (!g_vol->upcase) goto done; - + init_upcase_table(g_vol->upcase, g_vol->upcase_len * sizeof(ntfschar)); if (g_vol->major_ver < 3) { g_vol->attrdef = ntfs_calloc(36000); diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 9bf498c9..715915f0 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -755,9 +755,9 @@ static void wipe_index_entry_timestams(INDEX_ENTRY *e) e->key.file_name.last_data_change_time = timestamp; e->key.file_name.last_mft_change_time = timestamp; e->key.file_name.last_access_time = timestamp; - + wiped_timestamp_data += 32; - + e = (INDEX_ENTRY *)((u8 *)e + le16_to_cpu(e->length)); } } @@ -785,7 +785,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr) name = (ntfschar *)((u8 *)attr + le16_to_cpu(attr->name_offset)); name_len = attr->name_length; - + byte = bitmap = ntfs_attr_readall(ni, AT_BITMAP, name, name_len, NULL); if (!byte) { perr_printf("Failed to read $BITMAP attribute"); @@ -812,7 +812,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr) bit = 0; while ((u8 *)tmp_indexa < (u8 *)indexa + na->data_size) { - if (*byte & (1 << bit)) { + if (*byte & (1 << bit)) { if (ntfs_mst_post_read_fixup((NTFS_RECORD *)tmp_indexa, le32_to_cpu( indexr->index_block_size))) { @@ -834,7 +834,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr) goto out_indexa; } } - tmp_indexa = (INDEX_ALLOCATION *)((u8 *)tmp_indexa + + tmp_indexa = (INDEX_ALLOCATION *)((u8 *)tmp_indexa + le32_to_cpu(indexr->index_block_size)); bit++; if (bit > 7) { @@ -842,7 +842,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr) byte++; } } - + if (ntfs_rl_pwrite(vol, na->rl, 0, na->data_size, indexa) != na->data_size) perr_printf("ntfs_rl_pwrite failed for inode %lld", ni->mft_no); out_indexa: @@ -924,7 +924,7 @@ static void wipe_timestamps(ntfs_walk_clusters_ctx *image) else if (a->type == AT_STANDARD_INFORMATION) WIPE_TIMESTAMPS(STANDARD_INFORMATION, a, timestamp); - + else if (a->type == AT_INDEX_ROOT) wipe_index_root_timestamps(a, timestamp); } @@ -1168,7 +1168,7 @@ static void mft_record_write_with_same_usn(ntfs_volume *volume, ntfs_inode *ni) { if (ntfs_mft_usn_dec(ni->mrec)) perr_exit("ntfs_mft_usn_dec"); - + if (ntfs_mft_record_write(volume, ni->mft_no, ni->mrec)) perr_exit("ntfs_mft_record_write"); } @@ -1176,12 +1176,12 @@ static void mft_record_write_with_same_usn(ntfs_volume *volume, ntfs_inode *ni) static void mft_inode_write_with_same_usn(ntfs_volume *volume, ntfs_inode *ni) { s32 i; - + mft_record_write_with_same_usn(volume, ni); - + if (ni->nr_extents <= 0) return; - + for (i = 0; i < ni->nr_extents; ++i) { ntfs_inode *eni = ni->extent_nis[i]; mft_record_write_with_same_usn(volume, eni); @@ -1719,7 +1719,7 @@ static void check_dest_free_space(u64 src_bytes) if (opt.metadata || opt.blkdev_out || opt.std_out) return; - /* + /* * TODO: save_image needs a bit more space than src_bytes * due to the free space encoding overhead. */ @@ -1732,7 +1732,7 @@ static void check_dest_free_space(u64 src_bytes) dest_bytes = (u64)stvfs.f_frsize * stvfs.f_bfree; if (!dest_bytes) dest_bytes = (u64)stvfs.f_bsize * stvfs.f_bfree; - + if (dest_bytes < src_bytes) err_exit("Destination doesn't have enough free space: " "%llu MB < %llu MB\n", diff --git a/ntfsprogs/ntfscmp.c b/ntfsprogs/ntfscmp.c index ae9fc548..6b8cd1f2 100644 --- a/ntfsprogs/ntfscmp.c +++ b/ntfsprogs/ntfscmp.c @@ -496,7 +496,7 @@ static int setup_cmp_ia(ntfs_attr *na, struct cmp_ia *cia) perr_println("Failed to readall BITMAP"); return -1; } - cia->byte = cia->bitmap; + cia->byte = cia->bitmap; cia->tmp_ia = cia->ia = ntfs_malloc(na->data_size); if (!cia->tmp_ia) @@ -506,7 +506,7 @@ static int setup_cmp_ia(ntfs_attr *na, struct cmp_ia *cia) perr_println("Failed to pread INDEX_ALLOCATION"); goto free_ia; } - + return 0; free_ia: free(cia->ia); @@ -520,28 +520,28 @@ static void cmp_index_allocation(ntfs_attr *na1, ntfs_attr *na2) struct cmp_ia cia1, cia2; int bit, ret1, ret2; u32 ib_size; - + if (setup_cmp_ia(na1, &cia1)) return; if (setup_cmp_ia(na2, &cia2)) return; - /* + /* * FIXME: ia can be the same even if the bitmap sizes are different. */ if (cia1.bm_size != cia1.bm_size) goto out; - + if (cmp_buffer(cia1.bitmap, cia2.bitmap, cia1.bm_size, na1)) goto out; - + if (cmp_buffer((u8 *)cia1.ia, (u8 *)cia2.ia, 0x18, na1)) goto out; ib_size = cia1.ia->index.allocated_size + 0x18; - + bit = 0; while ((u8 *)cia1.tmp_ia < (u8 *)cia1.ia + na1->data_size) { - if (*cia1.byte & (1 << bit)) { + if (*cia1.byte & (1 << bit)) { ret1 = ntfs_mst_post_read_fixup((NTFS_RECORD *)cia1.tmp_ia, ib_size); ret2 = ntfs_mst_post_read_fixup((NTFS_RECORD *)cia2.tmp_ia, @@ -550,19 +550,19 @@ static void cmp_index_allocation(ntfs_attr *na1, ntfs_attr *na2) print_differ(na1); goto out; } - + if (ret1 == -1) continue; - - if (cmp_buffer(((u8 *)cia1.tmp_ia) + 0x18, + + if (cmp_buffer(((u8 *)cia1.tmp_ia) + 0x18, ((u8 *)cia2.tmp_ia) + 0x18, cia1.ia->index.index_length, na1)) goto out; } - + cia1.tmp_ia = (INDEX_ALLOCATION *)((u8 *)cia1.tmp_ia + ib_size); cia2.tmp_ia = (INDEX_ALLOCATION *)((u8 *)cia2.tmp_ia + ib_size); - + bit++; if (bit > 7) { bit = 0; @@ -615,7 +615,7 @@ static void cmp_attribute_data(ntfs_attr *na1, ntfs_attr *na2) printf("%lld != %lld\n", pos + count1, na1->data_size); exit(1); } - + if (cmp_buffer(buf1, buf2, count1, na1)) return; } diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index f95f919a..58fdc473 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -617,7 +617,7 @@ static void ntfs_dump_attr_standard_information(ATTR_RECORD *attr) (unsigned)value_length); } } - + static void ntfs_dump_bytes(u8 *buf, int start, int stop) { int i; @@ -647,7 +647,7 @@ static void ntfs_dump_attr_list(ATTR_RECORD *attr, ntfs_volume *vol) value = ntfs_malloc(l); if (!value) return; - + l = ntfs_get_attribute_value(vol, attr, value); if (!l) { ntfs_log_perror("ntfs_get_attribute_value failed"); @@ -698,7 +698,7 @@ static void ntfs_dump_attr_list(ATTR_RECORD *attr, ntfs_volume *vol) } else printf("unnamed\n"); printf("\t\tPadding:\t"); - ntfs_dump_bytes((u8 *)entry, entry->name_offset + + ntfs_dump_bytes((u8 *)entry, entry->name_offset + sizeof(ntfschar) * entry->name_length, le16_to_cpu(entry->length)); printf("\n"); @@ -864,7 +864,7 @@ static void ntfs_dump_acl(const char *prefix, ACL *acl) printf("%sRevision\t %u\n", prefix, acl->revision); - /* + /* * Do not recalculate le16_to_cpu every iteration (minor speedup on * big-endian machines. */ @@ -913,7 +913,7 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc, const char *indent) { char *sid; - + printf("%s\tRevision:\t\t %u\n", indent, sec_desc->revision); /* TODO: parse the flags */ @@ -921,17 +921,16 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc, le16_to_cpu(sec_desc->control)); if (~sec_desc->control & SE_SELF_RELATIVE) { - SECURITY_DESCRIPTOR *sd = (SECURITY_DESCRIPTOR *)sec_desc; - + printf("%s\tOwner SID pointer:\t %p\n", indent, sd->owner); printf("%s\tGroup SID pointer:\t %p\n", indent, sd->group); printf("%s\tSACL pointer:\t\t %p\n", indent, sd->sacl); printf("%s\tDACL pointer:\t\t %p\n", indent, sd->dacl); - + return; } - + if (sec_desc->owner) { sid = ntfs_sid_to_mbs((SID *)((char *)sec_desc + le32_to_cpu(sec_desc->owner)), NULL, 0); @@ -1017,8 +1016,8 @@ static void ntfs_dump_attr_security_descriptor(ATTR_RECORD *attr, ntfs_volume *v } ntfs_dump_security_descriptor(sec_desc_attr, ""); - - if (attr->non_resident) + + if (attr->non_resident) free(sec_desc_attr); } @@ -1099,7 +1098,7 @@ static void ntfs_dump_attr_volume_information(ATTR_RECORD *attr) } static ntfschar NTFS_DATA_SDS[5] = { const_cpu_to_le16('$'), - const_cpu_to_le16('S'), const_cpu_to_le16('D'), + const_cpu_to_le16('S'), const_cpu_to_le16('D'), const_cpu_to_le16('S'), const_cpu_to_le16('\0') }; static void ntfs_dump_sds_entry(SECURITY_DESCRIPTOR_HEADER *sds) @@ -1117,10 +1116,10 @@ static void ntfs_dump_sds_entry(SECURITY_DESCRIPTOR_HEADER *sds) ntfs_log_verbose("\t\tLength:\t\t\t %u (0x%x)\n", (unsigned)le32_to_cpu(sds->length), (unsigned)le32_to_cpu(sds->length)); - + sd = (SECURITY_DESCRIPTOR_RELATIVE *)((char *)sds + sizeof(SECURITY_DESCRIPTOR_HEADER)); - + ntfs_dump_security_descriptor(sd, "\t"); } @@ -1131,22 +1130,22 @@ static void ntfs_dump_sds(ATTR_RECORD *attr, ntfs_inode *ni) int name_len; s64 data_size; u64 inode; - + inode = ni->mft_no; if (ni->nr_extents < 0) inode = ni->base_ni->mft_no; if (FILE_Secure != inode) return; - + name_len = attr->name_length; if (!name_len) return; - + name = (ntfschar *)((u8 *)attr + le16_to_cpu(attr->name_offset)); if (!ntfs_names_are_equal(NTFS_DATA_SDS, sizeof(NTFS_DATA_SDS) / 2 - 1, name, name_len, 0, NULL, 0)) return; - + sd = sds = ntfs_attr_readall(ni, AT_DATA, name, name_len, &data_size); if (!sd) { ntfs_log_perror("Failed to read $SDS attribute"); @@ -1156,10 +1155,10 @@ static void ntfs_dump_sds(ATTR_RECORD *attr, ntfs_inode *ni) * FIXME: The right way is based on the indexes, so we couldn't * miss real entries. For now, dump until it makes sense. */ - while (sd->length && sd->hash && + while (sd->length && sd->hash && le64_to_cpu(sd->offset) < (u64)data_size && le32_to_cpu(sd->length) < (u64)data_size && - le64_to_cpu(sd->offset) + + le64_to_cpu(sd->offset) + le32_to_cpu(sd->length) < (u64)data_size) { ntfs_dump_sds_entry(sd); sd = (SECURITY_DESCRIPTOR_HEADER *)((char*)sd + @@ -1193,10 +1192,10 @@ static const char *get_attribute_type_name(u32 type) return "$UNKNOWN"; } - + static void ntfs_dump_attribute_header(ATTR_RECORD *a, ntfs_volume *vol) { - printf("Dumping attribute %s (0x%x)\n", + printf("Dumping attribute %s (0x%x)\n", get_attribute_type_name(a->type), (unsigned)le32_to_cpu(a->type)); @@ -1274,7 +1273,7 @@ static void ntfs_dump_attribute_header(ATTR_RECORD *a, ntfs_volume *vol) sle64_to_cpu(a->initialized_size)); if (a->compression_unit || a->flags & ATTR_IS_COMPRESSED || a->flags & ATTR_IS_SPARSE) - printf("\tCompressed size:\t %llu (0x%llx)\n", + printf("\tCompressed size:\t %llu (0x%llx)\n", (signed long long) sle64_to_cpu(a->compressed_size), (signed long long) @@ -1324,7 +1323,7 @@ static void ntfs_dump_index_key(INDEX_ENTRY *entry, INDEX_ATTR_TYPE type) { char *sid; char printable_GUID[37]; - + switch (type) { case INDEX_ATTR_SECURE_SII: ntfs_log_verbose("\t\tKey security id:\t %u (0x%x)\n", @@ -1382,9 +1381,9 @@ typedef union { static void ntfs_dump_index_data(INDEX_ENTRY *entry, INDEX_ATTR_TYPE type) { INDEX_ENTRY_DATA *data; - + data = (INDEX_ENTRY_DATA *)((u8 *)entry + entry->data_offset); - + switch (type) { case INDEX_ATTR_SECURE_SII: ntfs_log_verbose("\t\tHash:\t\t\t 0x%08x\n", @@ -1580,7 +1579,7 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr, if (!attr->name_length) return INDEX_ATTR_UNKNOWN; - + if (index_root->type) { if (index_root->type == AT_FILE_NAME) return INDEX_ATTR_DIRECTORY_I30; @@ -1590,12 +1589,12 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr, index_root->type); return INDEX_ATTR_UNKNOWN; } - + if (utils_is_metadata(ni) <= 0) return INDEX_ATTR_UNKNOWN; if (utils_inode_get_name(ni, file_name, sizeof(file_name)) <= 0) return INDEX_ATTR_UNKNOWN; - + if (COMPARE_INDEX_NAMES(attr, NTFS_INDEX_SDH)) return INDEX_ATTR_SECURE_SDH; else if (COMPARE_INDEX_NAMES(attr, NTFS_INDEX_SII)) @@ -1612,7 +1611,7 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr, else if (!strcmp(file_name, "/$Extend/$ObjId")) return INDEX_ATTR_OBJID_O; } - + return INDEX_ATTR_UNKNOWN; } @@ -1649,7 +1648,7 @@ static void ntfs_dump_index_header(const char *indent, INDEX_HEADER *idx) (unsigned)le32_to_cpu(idx->allocated_size), (unsigned)le32_to_cpu(idx->allocated_size)); printf("%sIndex header flags:\t 0x%02x\n", indent, idx->flags); - + /* FIXME: there are 3 reserved bytes here */ } @@ -1670,7 +1669,7 @@ static void ntfs_dump_attr_index_root(ATTR_RECORD *attr, ntfs_inode *ni) type = get_index_attr_type(ni, attr, index_root); printf("\tIndexed Attr Type:\t "); ntfs_dump_index_attr_type(type); - + /* collation rule dumping */ printf("\tCollation Rule:\t\t %u (0x%x)\n", (unsigned)le32_to_cpu(index_root->collation_rule), @@ -1717,7 +1716,7 @@ static s32 ntfs_dump_index_block(INDEX_BLOCK *ib, INDEX_ATTR_TYPE type, u32 ib_size) { INDEX_ENTRY *entry; - + if (ntfs_mst_post_read_fixup((NTFS_RECORD*)ib, ib_size)) { ntfs_log_perror("Damaged INDX record"); return -1; @@ -1729,15 +1728,15 @@ static s32 ntfs_dump_index_block(INDEX_BLOCK *ib, INDEX_ATTR_TYPE type, ntfs_log_verbose("\t\tNode VCN:\t\t %lld (0x%llx)\n", (unsigned long long)sle64_to_cpu(ib->index_block_vcn), (unsigned long long)sle64_to_cpu(ib->index_block_vcn)); - - entry = (INDEX_ENTRY*)((u8*)ib + + + entry = (INDEX_ENTRY*)((u8*)ib + le32_to_cpu(ib->index.entries_offset) + 0x18); - + if (opts.verbose) { ntfs_dump_index_header("\t\t", &ib->index); printf("\n"); } - + return ntfs_dump_index_entries(entry, type); } @@ -1764,19 +1763,19 @@ static void ntfs_dump_attr_index_allocation(ATTR_RECORD *attr, ntfs_inode *ni) ntfs_log_perror("Failed to read $INDEX_ROOT attribute"); return; } - + type = get_index_attr_type(ni, attr, ir); - + name = (ntfschar *)((u8 *)attr + le16_to_cpu(attr->name_offset)); name_len = attr->name_length; - + byte = bitmap = ntfs_attr_readall(ni, AT_BITMAP, name, name_len, NULL); if (!byte) { ntfs_log_perror("Failed to read $BITMAP attribute"); goto out_index_root; } - tmp_alloc = allocation = ntfs_attr_readall(ni, AT_INDEX_ALLOCATION, + tmp_alloc = allocation = ntfs_attr_readall(ni, AT_INDEX_ALLOCATION, name, name_len, &data_size); if (!tmp_alloc) { ntfs_log_perror("Failed to read $INDEX_ALLOCATION attribute"); @@ -1787,7 +1786,7 @@ static void ntfs_dump_attr_index_allocation(ATTR_RECORD *attr, ntfs_inode *ni) while ((u8 *)tmp_alloc < (u8 *)allocation + data_size) { if (*byte & (1 << bit)) { int entries; - + entries = ntfs_dump_index_block(tmp_alloc, type, le32_to_cpu( ir->index_block_size)); @@ -1797,7 +1796,7 @@ static void ntfs_dump_attr_index_allocation(ATTR_RECORD *attr, ntfs_inode *ni) printf("\tIndex entries:\t\t %d\n", entries); } } - tmp_alloc = (INDEX_ALLOCATION *)((u8 *)tmp_alloc + + tmp_alloc = (INDEX_ALLOCATION *)((u8 *)tmp_alloc + le32_to_cpu( ir->index_block_size)); bit++; @@ -1809,7 +1808,7 @@ static void ntfs_dump_attr_index_allocation(ATTR_RECORD *attr, ntfs_inode *ni) printf("\tIndex entries total:\t %d\n", total_entries); printf("\tINDX blocks total:\t %d\n", total_indx_blocks); - + free(allocation); out_bitmap: free(bitmap); @@ -2083,9 +2082,9 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode) printf("Next Attribute Instance: %u (0x%x)\n", (unsigned)le16_to_cpu(mrec->next_attr_instance), (unsigned)le16_to_cpu(mrec->next_attr_instance)); - + printf("MFT Padding:\t"); - ntfs_dump_bytes((u8 *)mrec, le16_to_cpu(mrec->usa_ofs) + + ntfs_dump_bytes((u8 *)mrec, le16_to_cpu(mrec->usa_ofs) + 2 * le16_to_cpu(mrec->usa_count), le16_to_cpu(mrec->attrs_offset)); printf("\n"); @@ -2102,7 +2101,6 @@ static void ntfs_dump_file_attributes(ntfs_inode *inode) see ntfs_attr_lookup documentation for detailed explanation */ ctx = ntfs_attr_get_search_ctx(inode, NULL); while (!ntfs_attr_lookup(AT_UNUSED, NULL, 0, 0, 0, NULL, 0, ctx)) { - if (ctx->attr->type == AT_END || ctx->attr->type == AT_UNUSED) { printf("Weird: %s attribute type was found, please " "report this.\n", @@ -2110,9 +2108,9 @@ static void ntfs_dump_file_attributes(ntfs_inode *inode) ctx->attr->type)); continue; } - + ntfs_dump_attribute_header(ctx->attr, inode->vol); - + switch (ctx->attr->type) { case AT_STANDARD_INFORMATION: ntfs_dump_attr_standard_information(ctx->attr); @@ -2194,7 +2192,7 @@ int main(int argc, char **argv) ntfs_volume *vol; setlinebuf(stdout); - + ntfs_log_set_handler(ntfs_log_handler_outerr); if (!parse_options(argc, argv)) { diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index 9f6a0367..1c592ab2 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -2028,7 +2028,7 @@ static int check_bad_sectors(ntfs_volume *vol) if (!ctx->attr->non_resident) err_exit("Resident attribute in $BadClust! Please report to " "%s\n", NTFS_DEV_LIST); - /* + /* * FIXME: The below would be partial for non-base records in the * not yet supported multi-record case. Alternatively use audited * ntfs_attr_truncate after an umount & mount.