#include "nls.h"
#include "pathnames.h"
-#include "ismounted.h"
#include "exitcodes.h"
#include "c.h"
#include "fsck.h"
char *fsck_path = 0;
/* parsed fstab */
-static struct libmnt_table *fstab;
+static struct libmnt_table *fstab, *mtab;
static struct libmnt_cache *mntcache;
static int count_slaves(dev_t disk);
return (int) l;
}
+static int is_mounted(struct libmnt_fs *fs)
+{
+ int rc;
+
+ if (!mtab) {
+ mtab = mnt_new_table();
+ if (!mtab)
+ err(FSCK_EX_ERROR, ("failed to initialize libmount table"));
+ if (!mntcache)
+ mntcache = mnt_new_cache();
+ mnt_table_set_cache(mtab, mntcache);
+ mnt_table_parse_mtab(mtab, NULL);
+ }
+
+ rc = mnt_table_is_fs_mounted(mtab, fs);
+ if (verbose) {
+ if (rc)
+ printf(_("%s is mounted\n"), mnt_fs_get_target(fs));
+ else
+ printf(_("%s is not mounted\n"), mnt_fs_get_target(fs));
+ }
+ return rc;
+}
+
static int ignore(struct libmnt_fs *);
static struct fsck_fs_data *fs_create_data(struct libmnt_fs *fs)
if (fs) {
if (!skip_root &&
!fs_is_done(fs) &&
- !(ignore_mounted && is_mounted(fs_get_device(fs)))) {
+ !(ignore_mounted && is_mounted(fs))) {
status |= fsck_device(fs, 1);
status |= wait_many(FLAG_WAIT_ALL);
if (status > FSCK_EX_NONDESTRUCT) {
not_done_yet++;
continue;
}
- if (ignore_mounted && is_mounted(fs_get_device(fs))) {
+ if (ignore_mounted && is_mounted(fs)) {
fs_set_done(fs);
continue;
}
else if (fs_ignored_type(fs))
continue;
- if (ignore_mounted && is_mounted(fs_get_device(fs)))
+ if (ignore_mounted && is_mounted(fs))
continue;
status |= fsck_device(fs, interactive);
if (serialize ||
free(fsck_path);
mnt_free_cache(mntcache);
mnt_free_table(fstab);
+ mnt_free_table(mtab);
return status;
}