Whamcloud - gitweb
debugfs: add better error checking when printing extended attributes
[tools/e2fsprogs.git] / misc / fsck.c
index ea8f0e2..826aaeb 100644 (file)
@@ -27,9 +27,9 @@
 
 #define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */
 
+#include "config.h"
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/signal.h>
 #include <sys/stat.h>
 #include <limits.h>
 #include <stdio.h>
@@ -97,32 +97,32 @@ static const char *really_wanted[] = {
 /*
  * Global variables for options
  */
-char *devices[MAX_DEVICES];
-char *args[MAX_ARGS];
-int num_devices, num_args;
-
-int verbose = 0;
-int doall = 0;
-int noexecute = 0;
-int serialize = 0;
-int skip_root = 0;
-int ignore_mounted = 0;
-int notitle = 0;
-int parallel_root = 0;
-int progress = 0;
-int progress_fd = 0;
-int force_all_parallel = 0;
-int num_running = 0;
-int max_running = 0;
-volatile int cancel_requested = 0;
-int kill_sent = 0;
-char *progname;
-char *fstype = NULL;
-struct fs_info *filesys_info = NULL, *filesys_last = NULL;
-struct fsck_instance *instance_list;
-const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
-char *fsck_path = 0;
-blkid_cache cache = NULL;
+static char *devices[MAX_DEVICES];
+static char *args[MAX_ARGS];
+static int num_devices, num_args;
+
+static int verbose = 0;
+static int doall = 0;
+static int noexecute = 0;
+static int serialize = 0;
+static int skip_root = 0;
+static int ignore_mounted = 0;
+static int notitle = 0;
+static int parallel_root = 0;
+static int progress = 0;
+static int progress_fd = 0;
+static int force_all_parallel = 0;
+static int num_running = 0;
+static int max_running = 0;
+static volatile int cancel_requested = 0;
+static int kill_sent = 0;
+static char *progname;
+static char *fstype = NULL;
+static struct fs_info *filesys_info = NULL, *filesys_last = NULL;
+static struct fsck_instance *instance_list;
+static const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
+static char *fsck_path = 0;
+static blkid_cache cache = NULL;
 
 static char *string_copy(const char *s)
 {
@@ -233,12 +233,9 @@ static void parse_escape(char *word)
 
 static void free_instance(struct fsck_instance *i)
 {
-       if (i->prog)
-               free(i->prog);
-       if (i->device)
-               free(i->device);
-       if (i->base_device)
-               free(i->base_device);
+       free(i->prog);
+       free(i->device);
+       free(i->base_device);
        free(i);
        return;
 }
@@ -310,8 +307,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs)
        fs = create_fs_device(device, mntpnt, type ? type : "auto", opts,
                              freq ? atoi(freq) : -1,
                              passno ? atoi(passno) : -1);
-       if (dev)
-               free(dev);
+       free(dev);
 
        if (!fs)
                return -1;
@@ -369,7 +365,8 @@ static void load_fs_info(const char *filename)
        fclose(f);
 
        if (old_fstab && filesys_info) {
-               fputs(_("\007\007\007"
+               fputs("\007\007\007", stderr);
+               fputs(_(
                "WARNING: Your /etc/fstab does not contain the fsck passno\n"
                "       field.  I will kludge around things for you, but you\n"
                "       should fix your /etc/fstab file as soon as you can.\n\n"), stderr);
@@ -731,7 +728,7 @@ static void fsck_device(struct fs_info *fs, int interactive)
 /*
  * Deal with the fsck -t argument.
  */
-struct fs_type_compile {
+static struct fs_type_compile {
        char **list;
        int *type;
        int  negate;
@@ -1183,8 +1180,8 @@ static void PRS(int argc, char *argv[])
                                        if (progress_fd < 0)
                                                progress_fd = 0;
                                        else {
+                                               ++i;
                                                goto next_arg;
-                                               i++;
                                        }
                                }
                                break;