int serialize = 0;
int skip_root = 0;
int like_mount = 0;
+int ignore_mounted = 0;
int notitle = 0;
int parallel_root = 0;
int progress = 0;
#if 0
printf("Adding %s to list (type %d).\n", s, cmp->type[num]);
#endif
- cmp->list[num++] = string_copy(s);
+ cmp->list[num++] = string_copy(s);
s = strtok(NULL, ",");
}
free(list);
}
s = strtok(NULL, ",");
}
- free(list);
+ free(list);
return 0;
}
return (cmp->negate ? !ret : ret);
}
+/* Check to see whether a filesystem is already mounted */
+static int is_mounted(struct fs_info *fs)
+{
+ struct stat st_buf;
+ dev_t fs_rdev;
+ char *testdir;
+ int retval = 0;
+
+ if (!fs->mountpt) {
+ /*
+ * We have already read /proc/mounts
+ * so any device without a mountpoint
+ * is indeed not mounted.
+ */
+ return 0;
+ }
+
+ if (!strcmp(fs->mountpt,"/")) {
+ /* Root should be always mounted */
+ return 1;
+ }
+
+ if (stat(fs->mountpt, &st_buf) < 0)
+ return 0;
+
+ if (!S_ISDIR(st_buf.st_mode)) {
+ /* This is not a directory, cannot be mounted */
+ return 0;
+ }
+
+ fs_rdev = st_buf.st_dev;
+
+ /* Compare with the upper directory */
+ testdir = malloc(strlen(fs->mountpt) + 4);
+ strcpy(testdir,fs->mountpt);
+ if (fs->mountpt[strlen(fs->mountpt) - 1] == '/')
+ strcat(testdir,"..");
+ else
+ strcat(testdir,"/..");
+
+ if (stat(testdir, &st_buf) == 0) {
+ if (st_buf.st_dev != fs_rdev) {
+ retval = 1;
+ }
+ }
+ free(testdir);
+
+ return retval;
+}
+
/* Check if we should ignore this filesystem. */
static int ignore(struct fs_info *fs)
{
not_done_yet++;
continue;
}
+ if (ignore_mounted) {
+ /*
+ * Ignore mounted devices.
+ */
+ if (is_mounted(fs)) {
+ fs->flags |= FLAG_DONE;
+ continue;
+ }
+ }
/*
* If a filesystem on a particular device has
* already been spawned, then we need to defer
case 'P':
parallel_root++;
break;
+ case 'm':
+ ignore_mounted++;
+ break;
case 's':
serialize++;
break;
fstab = _PATH_MNTTAB;
load_fs_info(fstab);
+ /* Load info from /proc/mounts, too */
+ if (ignore_mounted)
+ load_fs_info("/proc/mounts");
+
/* Update our search path to include uncommon directories. */
if (oldpath) {
fsck_path = malloc (strlen (fsck_prefix_path) + 1 +
if (!fs)
continue;
}
+ if (ignore_mounted) {
+ /*
+ * Ignore mounted devices.
+ */
+ if (is_mounted(fs)) {
+ continue;
+ }
+ }
fsck_device(fs, interactive);
if (serialize ||
(max_running && (num_running >= max_running))) {