diff --git a/include/ntfs/attrib.h b/include/ntfs/attrib.h index 7f9182b8..7f7a27ed 100644 --- a/include/ntfs/attrib.h +++ b/include/ntfs/attrib.h @@ -304,7 +304,7 @@ extern int ntfs_attr_rm(ntfs_attr *na); extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size); extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, - const u32 newsize); + const u32 new_size); extern int ntfs_attr_record_move_to(ntfs_attr_search_ctx *ctx, ntfs_inode *ni); extern int ntfs_attr_record_move_away(ntfs_attr_search_ctx *ctx, int extra); diff --git a/include/ntfs/bootsect.h b/include/ntfs/bootsect.h index 345f48d9..af0da7a9 100644 --- a/include/ntfs/bootsect.h +++ b/include/ntfs/bootsect.h @@ -40,7 +40,8 @@ * --enable-debug). */ extern BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b, BOOL silent); -extern int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b); +extern int ntfs_boot_sector_parse(ntfs_volume *vol, + const NTFS_BOOT_SECTOR *bs); #endif /* defined _NTFS_BOOTSECT_H */ diff --git a/include/ntfs/runlist.h b/include/ntfs/runlist.h index d821f311..26c4a565 100644 --- a/include/ntfs/runlist.h +++ b/include/ntfs/runlist.h @@ -74,7 +74,7 @@ extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, u8 *dst, const int dst_len, const runlist_element *rl, const VCN start_vcn, VCN *const stop_vcn); -extern int ntfs_rl_truncate(runlist **rl, const VCN start_vcn); +extern int ntfs_rl_truncate(runlist **arl, const VCN start_vcn); extern int ntfs_rl_sparse(runlist *rl); extern s64 ntfs_rl_get_compressed_size(ntfs_volume *vol, runlist *rl); diff --git a/include/ntfs/volume.h b/include/ntfs/volume.h index fd1ae4ea..715c0320 100644 --- a/include/ntfs/volume.h +++ b/include/ntfs/volume.h @@ -205,7 +205,7 @@ extern int ntfs_umount(ntfs_volume *vol, const BOOL force); extern int ntfs_version_is_supported(ntfs_volume *vol); extern int ntfs_logfile_reset(ntfs_volume *vol); -extern int ntfs_volume_write_flags(ntfs_volume *v, const u16 flags); +extern int ntfs_volume_write_flags(ntfs_volume *vol, const u16 flags); #ifdef NTFS_RICH diff --git a/libntfs/attrib.c b/libntfs/attrib.c index ee09fc03..cf1a61d3 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -1358,7 +1358,7 @@ err_out: * @pos: byte position in the attribute to begin reading from * @bk_cnt: number of mst protected blocks to read * @bk_size: size of each mst protected block in bytes - * @b: output data buffer + * @dst: output data buffer * * This function will read @bk_cnt blocks of size @bk_size bytes each starting * at offset @pos from the ntfs attribute @na into the data buffer @b. @@ -1382,7 +1382,7 @@ err_out: * errors can be repaired. */ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, - const u32 bk_size, void *b) + const u32 bk_size, void *dst) { s64 br; u8 *end; @@ -1394,12 +1394,13 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, errno = EINVAL; return -1; } - br = ntfs_attr_pread(na, pos, bk_cnt * bk_size, b); + br = ntfs_attr_pread(na, pos, bk_cnt * bk_size, dst); if (br <= 0) return br; br /= bk_size; - for (end = (u8*)b + br * bk_size; (u8*)b < end; b = (u8*)b + bk_size) - ntfs_mst_post_read_fixup((NTFS_RECORD*)b, bk_size); + for (end = (u8*)dst + br * bk_size; (u8*)dst < end; dst = (u8*)dst + + bk_size) + ntfs_mst_post_read_fixup((NTFS_RECORD*)dst, bk_size); /* Finally, return the number of blocks read. */ return br; } @@ -1410,7 +1411,7 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, * @pos: position in the attribute to write to * @bk_cnt: number of mst protected blocks to write * @bk_size: size of each mst protected block in bytes - * @b: data buffer to write to disk + * @src: data buffer to write to disk * * This function will write @bk_cnt blocks of size @bk_size bytes each from * data buffer @b to multi sector transfer (mst) protected ntfs attribute @na @@ -1435,7 +1436,7 @@ s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt, * achieved. */ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt, - const u32 bk_size, void *b) + const u32 bk_size, void *src) { s64 written, i; @@ -1453,7 +1454,7 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt, int err; err = ntfs_mst_pre_write_fixup((NTFS_RECORD*) - ((u8*)b + i * bk_size), bk_size); + ((u8*)src + i * bk_size), bk_size); if (err < 0) { /* Abort write at this position. */ if (!i) @@ -1463,10 +1464,11 @@ s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt, } } /* Write the prepared data. */ - written = ntfs_attr_pwrite(na, pos, bk_cnt * bk_size, b); + written = ntfs_attr_pwrite(na, pos, bk_cnt * bk_size, src); /* Quickly deprotect the data again. */ for (i = 0; i < bk_cnt; ++i) - ntfs_mst_post_write_fixup((NTFS_RECORD*)((u8*)b + i * bk_size)); + ntfs_mst_post_write_fixup((NTFS_RECORD*)((u8*)src + i * + bk_size)); if (written <= 0) return written; /* Finally, return the number of complete blocks written. */ diff --git a/libntfs/mft.c b/libntfs/mft.c index 63fffeea..715f67a6 100644 --- a/libntfs/mft.c +++ b/libntfs/mft.c @@ -273,7 +273,7 @@ read_failed: * ntfs_mft_record_layout - layout an mft record into a memory buffer * @vol: volume to which the mft record will belong * @mref: mft reference specifying the mft record number - * @m: destination buffer of size >= @vol->mft_record_size bytes + * @mrec: destination buffer of size >= @vol->mft_record_size bytes * * Layout an empty, unused mft record with the mft reference @mref into the * buffer @m. The volume @vol is needed because the mft record structure was @@ -283,17 +283,17 @@ read_failed: * On success return 0 and on error return -1 with errno set to the error code. */ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref, - MFT_RECORD *m) + MFT_RECORD *mrec) { ATTR_RECORD *a; - if (!vol || !m) { + if (!vol || !mrec) { errno = EINVAL; return -1; } /* Aligned to 2-byte boundary. */ if (vol->major_ver < 3 || (vol->major_ver == 3 && !vol->minor_ver)) - m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD_OLD) + 1) & ~1); + mrec->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD_OLD) + 1) & ~1); else { /* Abort if mref is > 32 bits. */ if (MREF(mref) & 0x0000ffff00000000ull) { @@ -301,20 +301,20 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref, errno = ERANGE; return -1; } - m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1); + mrec->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1); /* * Set the NTFS 3.1+ specific fields while we know that the * volume version is 3.1+. */ - m->reserved = cpu_to_le16(0); - m->mft_record_number = cpu_to_le32(MREF(mref)); + mrec->reserved = cpu_to_le16(0); + mrec->mft_record_number = cpu_to_le32(MREF(mref)); } - m->magic = magic_FILE; + mrec->magic = magic_FILE; if (vol->mft_record_size >= NTFS_BLOCK_SIZE) - m->usa_count = cpu_to_le16(vol->mft_record_size / + mrec->usa_count = cpu_to_le16(vol->mft_record_size / NTFS_BLOCK_SIZE + 1); else { - m->usa_count = cpu_to_le16(1); + mrec->usa_count = cpu_to_le16(1); ntfs_log_debug("Sector size is bigger than MFT record size. " "Setting usa_count to 1. If Windows\n"); ntfs_log_debug("chkdsk reports this as corruption, please email " @@ -324,28 +324,28 @@ int ntfs_mft_record_layout(const ntfs_volume *vol, const MFT_REF mref, ntfs_log_debug("Thank you.\n"); } /* Set the update sequence number to 1. */ - *(u16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = cpu_to_le16(1); - m->lsn = cpu_to_le64(0ull); - m->sequence_number = cpu_to_le16(1); - m->link_count = cpu_to_le16(0); + *(u16*)((u8*)mrec + le16_to_cpu(mrec->usa_ofs)) = cpu_to_le16(1); + mrec->lsn = cpu_to_le64(0ull); + mrec->sequence_number = cpu_to_le16(1); + mrec->link_count = cpu_to_le16(0); /* Aligned to 8-byte boundary. */ - m->attrs_offset = cpu_to_le16((le16_to_cpu(m->usa_ofs) + - (le16_to_cpu(m->usa_count) << 1) + 7) & ~7); - m->flags = cpu_to_le16(0); + mrec->attrs_offset = cpu_to_le16((le16_to_cpu(mrec->usa_ofs) + + (le16_to_cpu(mrec->usa_count) << 1) + 7) & ~7); + mrec->flags = cpu_to_le16(0); /* * Using attrs_offset plus eight bytes (for the termination attribute), * aligned to 8-byte boundary. */ - m->bytes_in_use = cpu_to_le32((le16_to_cpu(m->attrs_offset) + 8 + 7) & - ~7); - m->bytes_allocated = cpu_to_le32(vol->mft_record_size); - m->base_mft_record = cpu_to_le64((MFT_REF)0); - m->next_attr_instance = cpu_to_le16(0); - a = (ATTR_RECORD*)((u8*)m + le16_to_cpu(m->attrs_offset)); + mrec->bytes_in_use = cpu_to_le32((le16_to_cpu(mrec->attrs_offset) + 8 + + 7) & ~7); + mrec->bytes_allocated = cpu_to_le32(vol->mft_record_size); + mrec->base_mft_record = cpu_to_le64((MFT_REF)0); + mrec->next_attr_instance = cpu_to_le16(0); + a = (ATTR_RECORD*)((u8*)mrec + le16_to_cpu(mrec->attrs_offset)); a->type = AT_END; a->length = cpu_to_le32(0); /* Finally, clear the unused part of the mft record. */ - memset((u8*)a + 8, 0, vol->mft_record_size - ((u8*)a + 8 - (u8*)m)); + memset((u8*)a + 8, 0, vol->mft_record_size - ((u8*)a + 8 - (u8*)mrec)); return 0; } diff --git a/ntfsprogs/utils.h b/ntfsprogs/utils.h index b58432cb..d9e451f2 100644 --- a/ntfsprogs/utils.h +++ b/ntfsprogs/utils.h @@ -85,7 +85,7 @@ int utils_attr_get_name(ntfs_volume *vol, ATTR_RECORD *attr, char *buffer, int b int utils_cluster_in_use(ntfs_volume *vol, long long lcn); int utils_mftrec_in_use(ntfs_volume *vol, MFT_REF mref); int utils_is_metadata(ntfs_inode *inode); -void utils_dump_mem(void *buf, int start, int length, int ascii); +void utils_dump_mem(void *buf, int start, int length, int flags); #ifndef _NTFS_RICH_H_ ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx);