Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the NTFS Boot Record backup in the cloned image #54

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ntfsclone-ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ void read_bitmap(char* device, file_system_info fs_info, unsigned long* bitmap,

}

// Include the potential Boot Record copy located after the end of the NTFS volume
pc_set_bit(fs_info.totalblock - 1, bitmap, fs_info.totalblock);
used_block++;

/// update progress
update_pui(&prog, 1, 1, 1);

Expand Down Expand Up @@ -316,6 +320,14 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->device_size = ntfs_device_size_get(ntfs->dev, 1);
fs_close();

if (fs_info->device_size > (fs_info->totalblock * fs_info->block_size)) {

// There is a copy of the Boot Record after the end of the NTFS volume.
// See http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm#BSback
fs_info->totalblock += 1;
fs_info->usedblocks += 1;
}

log_mesg(3, 0, 0, fs_opt.debug, "%s: hdr - usedblocks:\t: %llu\n", __FILE__, fs_info->usedblocks);
log_mesg(3, 0, 0, fs_opt.debug, "%s: hdr - totalblocks:\t: %llu\n", __FILE__, fs_info->totalblock);
}
Expand Down