diff options
-rw-r--r-- | daemon/ntfs.c | 29 | ||||
-rw-r--r-- | generator/generator_actions.ml | 16 | ||||
-rw-r--r-- | src/MAX_PROC_NR | 2 |
3 files changed, 46 insertions, 1 deletions
diff --git a/daemon/ntfs.c b/daemon/ntfs.c index e8be3445..235ecbcd 100644 --- a/daemon/ntfs.c +++ b/daemon/ntfs.c @@ -115,3 +115,32 @@ do_ntfsresize_size (const char *device, int64_t size) optargs_bitmask = GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK; return do_ntfsresize_opts (device, size, 0); } + +/* Takes optional arguments, consult optargs_bitmask. */ +int +do_ntfsfix (const char *device, int clearbadsectors) +{ + const char *argv[MAX_ARGS]; + size_t i = 0; + int r; + char *err; + + ADD_ARG (argv, i, "ntfsfix"); + + if ((optargs_bitmask & GUESTFS_NTFSFIX_CLEARBADSECTORS_BITMASK) && + clearbadsectors) + ADD_ARG (argv, i, "-b"); + + ADD_ARG (argv, i, device); + ADD_ARG (argv, i, NULL); + + r = commandv (NULL, &err, argv); + if (r == -1) { + reply_with_error ("%s: %s", device, err); + free (err); + return -1; + } + + free (err); + return 0; +} diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 9baf0817..9df9ea5a 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -6666,6 +6666,22 @@ C<device>. Compare with C<guestfs_zero> which zeroes the first few blocks of a device."); + ("ntfsfix", (RErr, [Device "device"], [OBool "clearbadsectors"]), 307, [Optional "ntfs3g"], + [InitPartition, IfAvailable "ntfs3g", TestRun ( + [["mkfs"; "ntfs"; "/dev/sda1"]; + ["ntfsfix"; "/dev/sda1"; "false"]])], + "fix common errors and force Windows to check NTFS", + "\ +This command repairs some fundamental NTFS inconsistencies, +resets the NTFS journal file, and schedules an NTFS consistency +check for the first boot into Windows. + +This is I<not> an equivalent of Windows C<chkdsk>. It does I<not> +scan the filesystem for inconsistencies. + +The optional C<clearbadsectors> flag clears the list of bad sectors. +This is useful after cloning a disk with bad sectors to a new disk."); + ] let all_functions = non_daemon_functions @ daemon_functions diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index cd307095..ae4cf41b 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -306 +307 |