]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fsck: Make -Cn work correctly where n != 0
authorTheodore Ts'o <tytso@mit.edu>
Wed, 26 Mar 2008 12:53:13 +0000 (08:53 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 26 Mar 2008 12:53:13 +0000 (08:53 -0400)
Previously, fsck was only passing in -Cn to the first e2fsck process
to start up, and enabling the progress information by sending a
SIGUSR1 signal.  This didn't work if the progress information was
intended to go to file descriptor, since the information was never
passed to e2fsck.

So we now pass the progress fd in as a negative number if the progress
information is intended to be initially suppressed.

Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/fsck.c

index 14d7a954aa2ff3a6c3ae4b43375a0e6282254221..e44829ab20c04d585e856348b36f83c7b7e9d364 100644 (file)
@@ -451,13 +451,19 @@ static int execute(const char *type, const char *device, const char *mntpt,
        for (i=0; i <num_args; i++)
                argv[argc++] = string_copy(args[i]);
 
-       if (progress && !progress_active()) {
+       if (progress) {
                if ((strcmp(type, "ext2") == 0) ||
                    (strcmp(type, "ext3") == 0)) {
                        char tmp[80];
-                       snprintf(tmp, 80, "-C%d", progress_fd);
-                       argv[argc++] = string_copy(tmp);
-                       inst->flags |= FLAG_PROGRESS;
+
+                       tmp[0] = 0;
+                       if (!progress_active()) {
+                               snprintf(tmp, 80, "-C%d", progress_fd);
+                               inst->flags |= FLAG_PROGRESS;
+                       } else if (progress_fd)
+                               snprintf(tmp, 80, "-C%d", progress_fd * -1);
+                       if (tmp[0])
+                               argv[argc++] = string_copy(tmp);
                }
        }