"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ntfsprogs/ntfsclone.c" between
ntfs-3g_ntfsprogs-2016.2.22.tgz and ntfs-3g_ntfsprogs-2017.3.23.tgz

About: NTFS-3G is a read-write NTFS driver for Linux and other operating systems. It provides safe handling of the Windows XP, Windows Server 2003, Windows 2000, Windows Vista, Windows Server 2008, Windows 7 and Windows 8 NTFS file systems.

ntfsclone.c  (ntfs-3g_ntfsprogs-2016.2.22.tgz):ntfsclone.c  (ntfs-3g_ntfsprogs-2017.3.23.tgz)
/** /**
* ntfsclone - Part of the Linux-NTFS project. * ntfsclone - Part of the Linux-NTFS project.
* *
* Copyright (c) 2003-2006 Szabolcs Szakacsits * Copyright (c) 2003-2006 Szabolcs Szakacsits
* Copyright (c) 2004-2006 Anton Altaparmakov * Copyright (c) 2004-2006 Anton Altaparmakov
* Copyright (c) 2010-2015 Jean-Pierre Andre * Copyright (c) 2010-2016 Jean-Pierre Andre
* Special image format support copyright (c) 2004 Per Olofsson * Special image format support copyright (c) 2004 Per Olofsson
* *
* Clone NTFS data and/or metadata to a sparse file, image, device or stdout. * Clone NTFS data and/or metadata to a sparse file, image, device or stdout.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
*/ */
skipping to change at line 163 skipping to change at line 163
int std_out; int std_out;
int blkdev_out; /* output file is block device */ int blkdev_out; /* output file is block device */
int metadata; /* metadata only cloning */ int metadata; /* metadata only cloning */
int no_action; /* do not really restore */ int no_action; /* do not really restore */
int ignore_fs_check; int ignore_fs_check;
int rescue; int rescue;
int save_image; int save_image;
int new_serial; int new_serial;
int metadata_image; int metadata_image;
int preserve_timestamps; int preserve_timestamps;
int full_logfile;
int restore_image; int restore_image;
char *output; char *output;
char *volume; char *volume;
#ifndef NO_STATFS #ifndef NO_STATFS
struct statfs stfs; struct statfs stfs;
#endif #endif
} opt; } opt;
struct bitmap { struct bitmap {
s64 size; s64 size;
skipping to change at line 369 skipping to change at line 370
" -r, --restore-image Restore from the special image format \n" " -r, --restore-image Restore from the special image format \n"
" --rescue Continue after disk read errors\n" " --rescue Continue after disk read errors\n"
" -m, --metadata Clone *only* metadata (for NTFS exper ts)\n" " -m, --metadata Clone *only* metadata (for NTFS exper ts)\n"
" -n, --no-action Test restoring, without outputting an ything\n" " -n, --no-action Test restoring, without outputting an ything\n"
" --ignore-fs-check Ignore the filesystem check result\n" " --ignore-fs-check Ignore the filesystem check result\n"
" --new-serial Set a new serial number\n" " --new-serial Set a new serial number\n"
" --new-half-serial Set a partial new serial number\n" " --new-half-serial Set a partial new serial number\n"
" -t, --preserve-timestamps Do not clear the timestamps\n" " -t, --preserve-timestamps Do not clear the timestamps\n"
" -q, --quiet Do not display any progress bars\n" " -q, --quiet Do not display any progress bars\n"
" -f, --force Force to progress (DANGEROUS)\n" " -f, --force Force to progress (DANGEROUS)\n"
" --full-logfile Include the full logfile in metadata output\n"
" -h, --help Display this help\n" " -h, --help Display this help\n"
#ifdef DEBUG #ifdef DEBUG
" -d, --debug Show debug information\n" " -d, --debug Show debug information\n"
#endif #endif
" -V, --version Display version information\n" " -V, --version Display version information\n"
"\n" "\n"
" If FILE is '-' then send the image to the standard output. I f SOURCE is '-'\n" " If FILE is '-' then send the image to the standard output. I f SOURCE is '-'\n"
" and --restore-image is used then read the image from the sta ndard input.\n" " and --restore-image is used then read the image from the sta ndard input.\n"
"\n", EXEC_NAME); "\n", EXEC_NAME);
fprintf(stderr, "%s%s", ntfs_bugs, ntfs_home); fprintf(stderr, "%s%s", ntfs_bugs, ntfs_home);
exit(ret); exit(ret);
} }
/** /**
* version * version
*/ */
__attribute__((noreturn)) __attribute__((noreturn))
static void version(void) static void version(void)
{ {
fprintf(stderr, fprintf(stderr,
"Efficiently clone, image, restore or rescue an NTFS Volume.\n \n" "Efficiently clone, image, restore or rescue an NTFS Volume.\n \n"
"Copyright (c) 2003-2006 Szabolcs Szakacsits\n" "Copyright (c) 2003-2006 Szabolcs Szakacsits\n"
"Copyright (c) 2004-2006 Anton Altaparmakov\n" "Copyright (c) 2004-2006 Anton Altaparmakov\n"
"Copyright (c) 2010-2015 Jean-Pierre Andre\n\n"); "Copyright (c) 2010-2016 Jean-Pierre Andre\n\n");
fprintf(stderr, "%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home); fprintf(stderr, "%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home);
exit(0); exit(0);
} }
static void parse_options(int argc, char **argv) static void parse_options(int argc, char **argv)
{ {
static const char *sopt = "-dfhmno:O:qrstV"; static const char *sopt = "-dfhmno:O:qrstV";
static const struct option lopt[] = { static const struct option lopt[] = {
#ifdef DEBUG #ifdef DEBUG
{ "debug", no_argument, NULL, 'd' }, { "debug", no_argument, NULL, 'd' },
skipping to change at line 416 skipping to change at line 418
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "metadata", no_argument, NULL, 'm' }, { "metadata", no_argument, NULL, 'm' },
{ "no-action", no_argument, NULL, 'n' }, { "no-action", no_argument, NULL, 'n' },
{ "output", required_argument, NULL, 'o' }, { "output", required_argument, NULL, 'o' },
{ "overwrite", required_argument, NULL, 'O' }, { "overwrite", required_argument, NULL, 'O' },
{ "restore-image", no_argument, NULL, 'r' }, { "restore-image", no_argument, NULL, 'r' },
{ "ignore-fs-check", no_argument, NULL, 'C' }, { "ignore-fs-check", no_argument, NULL, 'C' },
{ "rescue", no_argument, NULL, 'R' }, { "rescue", no_argument, NULL, 'R' },
{ "new-serial", no_argument, NULL, 'I' }, { "new-serial", no_argument, NULL, 'I' },
{ "new-half-serial", no_argument, NULL, 'i' }, { "new-half-serial", no_argument, NULL, 'i' },
{ "full-logfile", no_argument, NULL, 'l' },
{ "save-image", no_argument, NULL, 's' }, { "save-image", no_argument, NULL, 's' },
{ "preserve-timestamps", no_argument, NULL, 't' }, { "preserve-timestamps", no_argument, NULL, 't' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
int c; int c;
memset(&opt, 0, sizeof(opt)); memset(&opt, 0, sizeof(opt));
skipping to change at line 452 skipping to change at line 455
case 'h': case 'h':
usage(0); usage(0);
case '?': case '?':
usage(1); usage(1);
case 'i': /* not proposed as a short option */ case 'i': /* not proposed as a short option */
opt.new_serial |= 1; opt.new_serial |= 1;
break; break;
case 'I': /* not proposed as a short option */ case 'I': /* not proposed as a short option */
opt.new_serial |= 2; opt.new_serial |= 2;
break; break;
case 'l':
opt.full_logfile++;
break;
case 'm': case 'm':
opt.metadata++; opt.metadata++;
break; break;
case 'n': case 'n':
opt.no_action++; opt.no_action++;
break; break;
case 'O': case 'O':
opt.overwrite++; opt.overwrite++;
case 'o': case 'o':
if (opt.output) if (opt.output)
skipping to change at line 633 skipping to change at line 639
static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl) static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
{ {
s64 inode = image->ni->mft_no; s64 inode = image->ni->mft_no;
if (inode <= LAST_METADATA_INODE) { if (inode <= LAST_METADATA_INODE) {
/* Don't save bad sectors (both $Bad and unnamed are ignored */ /* Don't save bad sectors (both $Bad and unnamed are ignored */
if (inode == FILE_BadClus && image->ctx->attr->type == AT_DATA) if (inode == FILE_BadClus && image->ctx->attr->type == AT_DATA)
return 0; return 0;
if (inode != FILE_LogFile) if ((inode != FILE_LogFile) || opt.full_logfile)
return rl->length; return rl->length;
if (image->ctx->attr->type == AT_DATA) { if (image->ctx->attr->type == AT_DATA) {
/* Save at least the first 16 KiB of FILE_LogFile */ /* Save at least the first 16 KiB of FILE_LogFile */
s64 s = (s64)16384 - rl->vcn * vol->cluster_size; s64 s = (s64)16384 - rl->vcn * vol->cluster_size;
if (s > 0) { if (s > 0) {
s = rounded_up_division(s, vol->cluster_size); s = rounded_up_division(s, vol->cluster_size);
if (rl->length < s) if (rl->length < s)
s = rl->length; s = rl->length;
skipping to change at line 2142 skipping to change at line 2148
Printf("Apparently device '%s' doesn't have a " Printf("Apparently device '%s' doesn't have a "
"valid NTFS. Maybe you selected\nthe whole " "valid NTFS. Maybe you selected\nthe whole "
"disk instead of a partition (e.g. /dev/hda, " "disk instead of a partition (e.g. /dev/hda, "
"not /dev/hda1)?\n", opt.volume); "not /dev/hda1)?\n", opt.volume);
} }
/* /*
* Retry with recovering the log file enabled. * Retry with recovering the log file enabled.
* Normally avoided in order to get the original log file * Normally avoided in order to get the original log file
* data, but needed when remounting the metadata of a * data, but needed when remounting the metadata of a
* volume improperly unmounted from Windows. * volume improperly unmounted from Windows.
* If the full log file was requested, it must be kept
* as is, so we just remount read-only.
*/ */
if (!(new_mntflag & (NTFS_MNT_RDONLY | NTFS_MNT_RECOVER))) { if (!(new_mntflag & (NTFS_MNT_RDONLY | NTFS_MNT_RECOVER))) {
Printf("Trying to recover...\n"); if (opt.full_logfile) {
vol = ntfs_mount(opt.volume, Printf("Retrying read-only to ignore"
" the log file...\n");
vol = ntfs_mount(opt.volume,
new_mntflag | NTFS_MNT_RDONLY);
} else {
Printf("Trying to recover...\n");
vol = ntfs_mount(opt.volume,
new_mntflag | NTFS_MNT_RECOVER); new_mntflag | NTFS_MNT_RECOVER);
}
Printf("... %s\n",(vol ? "Successful" : "Failed")); Printf("... %s\n",(vol ? "Successful" : "Failed"));
} }
if (!vol) if (!vol)
exit(1); exit(1);
} }
if (vol->flags & VOLUME_IS_DIRTY) if (vol->flags & VOLUME_IS_DIRTY)
if (opt.force-- <= 0) if (opt.force-- <= 0)
err_exit(dirty_volume_msg, opt.volume); err_exit(dirty_volume_msg, opt.volume);
 End of changes. 11 change blocks. 
6 lines changed or deleted 21 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS