mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: Implement e2fsck -n flag (as FORCENO option)
Fixes: https://issues.redhat.com/browse/RHEL-92599
This commit is contained in:
committed by
rwmjones
parent
b9f75ca5b8
commit
b98cc96129
@@ -192,7 +192,7 @@ if_not_mounted_run_e2fsck (const char *device)
|
||||
|
||||
if (!mounted) {
|
||||
optargs_bitmask = GUESTFS_E2FSCK_FORCEALL_BITMASK;
|
||||
r = do_e2fsck (device, 0, 1);
|
||||
r = do_e2fsck (device, 0, 1, 0);
|
||||
}
|
||||
|
||||
return r;
|
||||
@@ -350,7 +350,8 @@ ext_minimum_size (const char *device)
|
||||
int
|
||||
do_e2fsck (const char *device,
|
||||
int correct,
|
||||
int forceall)
|
||||
int forceall,
|
||||
int forceno)
|
||||
{
|
||||
const char *argv[MAX_ARGS];
|
||||
CLEANUP_FREE char *err = NULL;
|
||||
@@ -362,9 +363,12 @@ do_e2fsck (const char *device,
|
||||
correct = 0;
|
||||
if (!(optargs_bitmask & GUESTFS_E2FSCK_FORCEALL_BITMASK))
|
||||
forceall = 0;
|
||||
if (!(optargs_bitmask & GUESTFS_E2FSCK_FORCENO_BITMASK))
|
||||
forceno = 0;
|
||||
|
||||
if (correct && forceall) {
|
||||
reply_with_error ("only one of the options 'correct', 'forceall' may be specified");
|
||||
if (correct + forceall + forceno > 1) {
|
||||
reply_with_error ("only one of the options 'correct', 'forceall' "
|
||||
"or 'forceno' may be specified");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -377,6 +381,9 @@ do_e2fsck (const char *device,
|
||||
if (forceall)
|
||||
ADD_ARG (argv, i, "-y");
|
||||
|
||||
if (forceno)
|
||||
ADD_ARG (argv, i, "-n");
|
||||
|
||||
ADD_ARG (argv, i, device);
|
||||
ADD_ARG (argv, i, NULL);
|
||||
|
||||
@@ -402,7 +409,7 @@ int
|
||||
do_e2fsck_f (const char *device)
|
||||
{
|
||||
optargs_bitmask = GUESTFS_E2FSCK_CORRECT_BITMASK;
|
||||
return do_e2fsck (device, 1, 0);
|
||||
return do_e2fsck (device, 1, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -33,6 +33,9 @@ The C<fstrim> API has been modified to work around several issues in
|
||||
upstream and RHEL 9 kernels related to XFS support (Eric Sandeen, Dave
|
||||
Chinner).
|
||||
|
||||
The existing C<e2fsck> API has a new C<FORCENO> option enabling use of
|
||||
the command line I<-n> flag.
|
||||
|
||||
=begin comment
|
||||
|
||||
=head2 Tools
|
||||
|
||||
@@ -3409,8 +3409,8 @@ are activated or deactivated." };
|
||||
["umount"; "/"; "false"; "false"];
|
||||
["lvresize"; "/dev/VG/LV"; "20"];
|
||||
["e2fsck_f"; "/dev/VG/LV"];
|
||||
["e2fsck"; "/dev/VG/LV"; "true"; "false"];
|
||||
["e2fsck"; "/dev/VG/LV"; "false"; "true"];
|
||||
["e2fsck"; "/dev/VG/LV"; "true"; "false"; "false"];
|
||||
["e2fsck"; "/dev/VG/LV"; "false"; "true"; "false"];
|
||||
["resize2fs"; "/dev/VG/LV"];
|
||||
["mount"; "/dev/VG/LV"; "/"];
|
||||
["cat"; "/new"]], "test content"), [];
|
||||
@@ -6683,7 +6683,7 @@ The usage of this device, for example C<filesystem> or C<raid>.
|
||||
|
||||
{ defaults with
|
||||
name = "e2fsck"; added = (1, 15, 17);
|
||||
style = RErr, [String (Device, "device")], [OBool "correct"; OBool "forceall"];
|
||||
style = RErr, [String (Device, "device")], [OBool "correct"; OBool "forceall"; OBool "forceno"];
|
||||
shortdesc = "check an ext2/ext3 filesystem";
|
||||
longdesc = "\
|
||||
This runs the ext2/ext3 filesystem checker on C<device>.
|
||||
@@ -6697,14 +6697,24 @@ Automatically repair the file system. This option will cause e2fsck
|
||||
to automatically fix any filesystem problems that can be safely
|
||||
fixed without human intervention.
|
||||
|
||||
This option may not be specified at the same time as the C<forceall> option.
|
||||
This option may not be specified at the same time as the C<forceall>
|
||||
or C<forceno> options.
|
||||
|
||||
=item C<forceall>
|
||||
|
||||
Assume an answer of ‘yes’ to all questions; allows e2fsck to be used
|
||||
non-interactively.
|
||||
|
||||
This option may not be specified at the same time as the C<correct> option.
|
||||
This option may not be specified at the same time as the C<correct>
|
||||
or C<forceno> options.
|
||||
|
||||
=item C<forceno>
|
||||
|
||||
Open the filesystem readonly and assume an answer of ‘no’ to all
|
||||
questions; allows e2fsck to be used non-interactively.
|
||||
|
||||
This option may not be specified at the same time as the C<correct>
|
||||
or C<forceall> options.
|
||||
|
||||
=back" };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user