mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
New API: ntfsfix for fixing problems on NTFS.
Note this is not a "chkdsk" equivalent tool.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1 @@
|
||||
306
|
||||
307
|
||||
|
||||
Reference in New Issue
Block a user