Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-ntfs-3g: 提交

external/ntfs-3g


Commit MetaInfo

修订版f06672a02cb334497abd69eadedb3379268c8129 (tree)
时间2017-10-26 17:40:17
作者Jean-Pierre André <jpandre@user...>
CommiterJean-Pierre André

Log Message

Checked log file blocks more recent than temporary ones

Under some circumstances, the temporary log file blocks are not the
latest ones, so check whether there are more recent ones.
Only done for log version 1.x, as log version 2.x follow a different
logic.

更改概述

差异

--- a/ntfsprogs/ntfsrecover.c
+++ b/ntfsprogs/ntfsrecover.c
@@ -3687,6 +3687,60 @@ static int walkback(CONTEXT *ctx, const struct BUFFER *buf, u32 blk,
36873687 }
36883688
36893689 /*
3690+ * Find the latest log block
3691+ *
3692+ * Usually, the latest block is either block 2 or 3 which act as
3693+ * temporary block before being copied to target location.
3694+ * However under some unknown condition the block are written
3695+ * immediately to target location, and we have to scan for the
3696+ * latest one.
3697+ * Currently this is not checked for logfile version 2.x which
3698+ * use a different layout of temporary blocks.
3699+ */
3700+
3701+const struct BUFFER *find_latest_block(CONTEXT *ctx, u32 baseblk,
3702+ const struct BUFFER *basebuf)
3703+{
3704+ le64 offset;
3705+ leLSN prevlsn;
3706+ leLSN curlsn;
3707+ u32 curblk;
3708+ u32 prevblk;
3709+ const struct BUFFER *prevbuf;
3710+ const struct BUFFER *curbuf;
3711+
3712+ offset = basebuf->block.record.copy.file_offset;
3713+ curblk = baseblk;
3714+ do {
3715+ if (curblk < BASEBLKS) {
3716+ prevbuf = basebuf;
3717+ prevlsn = basebuf->block.record.last_end_lsn;
3718+ prevblk = baseblk;
3719+ curblk = le64_to_cpu(offset) >> blockbits;
3720+ } else {
3721+ if (optv)
3722+ printf("block %d is more recent than block %d\n",
3723+ (int)curblk, (int)prevblk);
3724+ prevbuf = curbuf;
3725+ prevlsn = curlsn;
3726+ prevblk = curblk;
3727+ curblk++;
3728+ if (curblk >= (logfilesz >> blockbits))
3729+ curblk = (log_major < 2 ? BASEBLKS : BASEBLKS2);
3730+ }
3731+ curbuf = read_buffer(ctx, curblk);
3732+ if (curbuf && (curbuf->block.record.magic == magic_RCRD)) {
3733+ curlsn = curbuf->block.record.copy.last_lsn;
3734+ }
3735+ } while (curbuf
3736+ && (curbuf->block.record.magic == magic_RCRD)
3737+ && (le64_to_cpu(curlsn) > le64_to_cpu(prevlsn)));
3738+ if (optv)
3739+ printf("Block %d is the latest one\n",(int)prevblk);
3740+ return (prevbuf);
3741+}
3742+
3743+/*
36903744 * Determine the sequencing of blocks (when version >= 2.0)
36913745 *
36923746 * Blocks 2..17 and 18..33 are temporary blocks being filled until
@@ -3982,6 +4036,12 @@ static int walk(CONTEXT *ctx)
39824036 &nextbuf->block.record);
39834037 }
39844038 }
4039+ if (startbuf && opts) {
4040+ buf = startbuf = find_latest_block(ctx,
4041+ blk, startbuf);
4042+ latest_lsn = le64_to_cpu(
4043+ buf->block.record.last_end_lsn);
4044+ }
39854045 } else {
39864046 buf = startbuf = read_buffer(ctx, blk);
39874047 nextbuf = (const struct BUFFER*)NULL;
@@ -4043,7 +4103,7 @@ static void version(void)
40434103 {
40444104 printf("\n%s v%s (libntfs-3g) - Recover updates committed by Windows"
40454105 " on an NTFS Volume.\n\n", "ntfsrecover", VERSION);
4046- printf("Copyright (c) 2012-2016 Jean-Pierre Andre\n");
4106+ printf("Copyright (c) 2012-2017 Jean-Pierre Andre\n");
40474107 printf("\n%s\n%s%s\n", ntfs_gpl, ntfs_bugs, ntfs_home);
40484108 }
40494109
Show on old repository browser