Whamcloud - gitweb
ChangeLog, mke2fs.c:
[tools/e2fsprogs.git] / misc / fsck.c
index 229c750..e3f1419 100644 (file)
@@ -79,45 +79,7 @@ static const char *really_wanted[] = {
        NULL
 };
 
-#ifdef DEV_DSK_DEVICES
-static const char *base_devices[] = {
-       "/dev/dsk/hda",
-       "/dev/dsk/hdb",
-       "/dev/dsk/hdc",
-       "/dev/dsk/hdd",
-       "/dev/dsk/hd1a",
-       "/dev/dsk/hd1b",
-       "/dev/dsk/hd1c",
-       "/dev/dsk/hd1d",
-       "/dev/dsk/sda",
-       "/dev/dsk/sdb",
-       "/dev/dsk/sdc",
-       "/dev/dsk/sdd",
-       "/dev/dsk/sde",
-       "/dev/dsk/sdf",
-       "/dev/dsk/sdg",
-       NULL
-};
-#else
-static const char *base_devices[] = {
-       "/dev/hda",
-       "/dev/hdb",
-       "/dev/hdc",
-       "/dev/hdd",
-       "/dev/hd1a",
-       "/dev/hd1b",
-       "/dev/hd1c",
-       "/dev/hd1d",
-       "/dev/sda",
-       "/dev/sdb",
-       "/dev/sdc",
-       "/dev/sdd",
-       "/dev/sde",
-       "/dev/sdf",
-       "/dev/sdg",
-       NULL
-};
-#endif
+#define BASE_MD "/dev/md"
 
 /*
  * Global variables for options
@@ -144,7 +106,7 @@ const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
 char *fsck_path = 0;
 static int ignore(struct fs_info *);
 
-static char *string_copy(const char *s)
+char *string_copy(const char *s)
 {
        char    *ret;
 
@@ -203,6 +165,8 @@ static void free_instance(struct fsck_instance *i)
                free(i->prog);
        if (i->device)
                free(i->device);
+       if (i->base_device)
+               free(i->base_device);
        free(i);
        return;
 }
@@ -476,6 +440,7 @@ static int execute(const char *type, char *device, char *mntpt,
        inst->prog = string_copy(prog);
        inst->type = string_copy(type);
        inst->device = string_copy(device);
+       inst->base_device = base_device(device);
        inst->start_time = time(0);
        inst->next = NULL;
 
@@ -584,6 +549,7 @@ static struct fsck_instance *wait_one(NOARGS)
                                }
                        } else
                                kill(inst2->pid, SIGUSR1);
+                       inst2->flags |= FLAG_PROGRESS;
                        break;
                }
        }
@@ -690,7 +656,7 @@ static int ignore(struct fs_info *fs)
        
        /* Are we ignoring this type? */
        for(ip = ignored_types; *ip; ip++)
-               if (strcmp(fs->type, *ip) == 0) return(1);
+               if (strcmp(fs->type, *ip) == 0) return 1;
 
        /* Do we really really want to check this fs? */
        for(ip = really_wanted; *ip; ip++)
@@ -704,7 +670,7 @@ static int ignore(struct fs_info *fs)
                if (wanted)
                        fprintf(stderr, _("fsck: cannot check %s: fsck.%s not found\n"),
                                fs->device, fs->type);
-               return(1);
+               return 1;
        }
 
        /* We can and want to check this file system type. */
@@ -712,38 +678,35 @@ static int ignore(struct fs_info *fs)
 }
 
 /*
- * Return the "base device" given a particular device; this is used to
- * assure that we only fsck one partition on a particular drive at any
- * one time.  Otherwise, the disk heads will be seeking all over the
- * place.
- */
-static const char *base_device(char *device)
-{
-       const char **base;
-
-       for (base = base_devices; *base; base++) {
-               if (!strncmp(*base, device, strlen(*base)))
-                       return *base;
-       }
-       return device;
-}
-
-/*
  * Returns TRUE if a partition on the same disk is already being
  * checked.
  */
 static int device_already_active(char *device)
 {
        struct fsck_instance *inst;
-       const char *base = base_device(device);
+       char *base;
 
        if (force_all_parallel)
                return 0;
 
+#ifdef BASE_MD
+       /* Don't check a soft raid disk with any other disk */
+       if (instance_list &&
+           (!strncmp(instance_list->device, BASE_MD, sizeof(BASE_MD)-1) ||
+            !strncmp(device, BASE_MD, sizeof(BASE_MD)-1)))
+               return 1;
+#endif
+
+       base = base_device(device);
+       if (!base)
+               return 0;
        for (inst = instance_list; inst; inst = inst->next) {
-               if (!strcmp(base, base_device(inst->device)))
+               if (!strcmp(base, inst->base_device)) {
+                       free(base);
                        return 1;
+               }
        }
+       free(base);
        return 0;
 }
 
@@ -761,32 +724,35 @@ static int check_all(NOARGS)
                printf(_("Checking all file systems.\n"));
 
        /*
-        * Find and check the root filesystem first.
+        * Do an initial scan over the filesystem; mark filesystems
+        * which should be ignored as done, and resolve LABEL= and
+        * UUID= specifications to the real device.
+        */
+       for (fs = filesys_info; fs; fs = fs->next) {
+               if (ignore(fs))
+                       fs->flags |= FLAG_DONE;
+               fs->device = interpret_device(fs->device);
+       }
+               
+       /*
+        * Find and check the root filesystem.
         */
        if (!parallel_root) {
                for (fs = filesys_info; fs; fs = fs->next) {
                        if (!strcmp(fs->mountpt, "/"))
                                break;
                }
-               if (fs && !skip_root && !ignore(fs)) {
-                       fs->device = interpret_device(fs->device);
-                       fsck_device(fs->device, 1);
+               if (fs) {
+                       if (!skip_root && !ignore(fs)) {
+                               fsck_device(fs->device, 1);
+                               status |= wait_all();
+                               if (status > EXIT_NONDESTRUCT)
+                                       return status;
+                       }
                        fs->flags |= FLAG_DONE;
-                       status |= wait_all();
-                       if (status > EXIT_NONDESTRUCT)
-                               return status;
                }
        }
-       if (fs) fs->flags |= FLAG_DONE;
 
-       /*
-        * Mark filesystems that should be ignored as done.
-        */
-       for (fs = filesys_info; fs; fs = fs->next) {
-               if (ignore(fs))
-                       fs->flags |= FLAG_DONE;
-       }
-               
        while (not_done_yet) {
                not_done_yet = 0;
                pass_done = 1;
@@ -815,7 +781,6 @@ static int check_all(NOARGS)
                        /*
                         * Spawn off the fsck process
                         */
-                       fs->device = interpret_device(fs->device);
                        fsck_device(fs->device, serialize);
                        fs->flags |= FLAG_DONE;