Redefined target_vcn on 64 bits in ntfsrecover.h

In a log record, the target vcn has to be stored on 64 bits
This commit is contained in:
Jean-Pierre André 2016-04-06 10:45:30 +02:00
parent 044f2104f9
commit ad59ecec3f
3 changed files with 15 additions and 18 deletions

View File

@ -1320,7 +1320,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
}
printf(" new base MFT record, attr 0x%x (%s)\n",attr,attrname(attr));
printf(" inode %lld\n",
(((long long)le32_to_cpu(logr->target_vcn)
(((long long)le64_to_cpu(logr->target_vcn)
<< clusterbits)
+ (le16_to_cpu(logr->cluster_index) << 9))
>> mftrecbits);
@ -1369,7 +1369,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
printf(" free base MFT record, attr 0x%x (%s)\n",
attr,attrname(attr));
printf(" inode %lld\n",
(((long long)le32_to_cpu(logr->target_vcn) << clusterbits)
(((long long)le64_to_cpu(logr->target_vcn) << clusterbits)
+ (le16_to_cpu(logr->cluster_index) << 9)) >> mftrecbits);
break;
case CreateAttribute : /* 5 */
@ -1877,20 +1877,18 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
printf("attribute_flags %04x\n",
(int)le16_to_cpu(logr->attribute_flags));
if (mftrecbits && onmft)
printf("target_vcn %08lx (inode %lld)\n",
(long)le32_to_cpu(logr->target_vcn),
(((long long)le32_to_cpu(logr->target_vcn)
printf("target_vcn %016llx (inode %lld)\n",
(long long)le64_to_cpu(logr->target_vcn),
(((long long)le64_to_cpu(logr->target_vcn)
<< clusterbits)
+ (le16_to_cpu(logr->cluster_index) << 9))
>> mftrecbits);
else
printf("target_vcn %08lx\n",
(long)le32_to_cpu(logr->target_vcn));
printf("reserved3 %08lx\n",
(long)le32_to_cpu(logr->reserved3));
printf("target_vcn %016llx\n",
(long long)le64_to_cpu(logr->target_vcn));
/* Compute a base for the current run of mft */
baselcn = le64_to_cpu(logr->lcn_list[0])
- le32_to_cpu(logr->target_vcn);
- le64_to_cpu(logr->target_vcn);
for (i=0; i<le16_to_cpu(logr->lcns_to_follow)
&& (i<SHOWLISTS); i++) {
lcn = le64_to_cpu(logr->lcn_list[i]);

View File

@ -243,8 +243,7 @@ typedef struct { /* size 80 */
le16 attribute_offset;
le16 cluster_index;
ATTRIBUTE_FLAGS attribute_flags;
le32 target_vcn;
le32 reserved3;
leVCN target_vcn;
le64 lcn_list[0];
} __attribute__((__packed__));
struct {

View File

@ -121,7 +121,7 @@ static u64 inode_number(const LOG_RECORD *logr)
{
u64 offset;
offset = ((u64)le32_to_cpu(logr->target_vcn)
offset = ((u64)le64_to_cpu(logr->target_vcn)
<< clusterbits)
+ ((u32)le16_to_cpu(logr->cluster_index)
<< NTFS_BLOCK_SIZE_BITS);
@ -548,7 +548,7 @@ static int write_mirr(ntfs_volume *vol, const LOG_RECORD *logr,
if (!optn) {
for (i=0; (i<count) && !err; i++) {
lcn = ntfs_attr_vcn_to_lcn(vol->mftmirr_na,
le32_to_cpu(logr->target_vcn) + i);
le64_to_cpu(logr->target_vcn) + i);
source = buffer + clustersz*i;
if ((lcn < 0)
|| (ntfs_pwrite(vol->dev, lcn << clusterbits,
@ -640,15 +640,15 @@ static int write_protected(ntfs_volume *vol, const LOG_RECORD *logr,
"older" : "newer"),
(long long)sle64_to_cpu(logr->this_lsn));
if (optv > 1)
printf("mft vcn %ld index %d\n",
(long)le32_to_cpu(logr->target_vcn),
printf("mft vcn %lld index %d\n",
(long long)le64_to_cpu(logr->target_vcn),
(int)le16_to_cpu(logr->cluster_index));
err = sanity_mft(buffer);
/* Should set to some previous lsn for undos */
if (opts)
record->lsn = logr->this_lsn;
/* Duplicate on mftmirr if not overflowing its size */
mftmirr = (((u64)le32_to_cpu(logr->target_vcn)
mftmirr = (((u64)le64_to_cpu(logr->target_vcn)
+ le16_to_cpu(logr->lcns_to_follow))
<< clusterbits)
<= (((u64)vol->mftmirr_size) << mftrecbits);
@ -1786,7 +1786,7 @@ static int create_indx(ntfs_volume *vol, const struct ACTION_RECORD *action,
indx->usa_ofs = const_cpu_to_le16(0x28);
indx->usa_count = const_cpu_to_le16(9);
indx->lsn = action->record.this_lsn;
vcn = le32_to_cpu(action->record.target_vcn);
vcn = le64_to_cpu(action->record.target_vcn);
/* beware of size change on big-endian cpus */
indx->index_block_vcn = cpu_to_sle64(vcn);
/* INDEX_HEADER */