summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/fsck_minix.c54
-rw-r--r--util-linux/mkfs_minix.c8
-rw-r--r--util-linux/mkfs_vfat.c2
3 files changed, 25 insertions, 39 deletions
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 0c33c1b..ca0b17e 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -374,38 +374,28 @@ static int ask(const char *string, int def)
*/
static void check_mount(void)
{
- FILE *f;
- struct mntent *mnt;
- int cont;
- int fd;
-//XXX:FIXME use find_mount_point()
- f = setmntent(MOUNTED, "r");
- if (f == NULL)
- return;
- while ((mnt = getmntent(f)) != NULL)
- if (strcmp(device_name, mnt->mnt_fsname) == 0)
- break;
- endmntent(f);
- if (!mnt)
- return;
-
- /*
- * If the root is mounted read-only, then /etc/mtab is
- * probably not correct; so we won't issue a warning based on
- * it.
- */
- fd = open(MOUNTED, O_RDWR);
- if (fd < 0 && errno == EROFS)
- return;
- close(fd);
-
- printf("%s is mounted. ", device_name);
- cont = 0;
- if (isatty(0) && isatty(1))
- cont = ask("Do you really want to continue", 0);
- if (!cont) {
- printf("Check aborted\n");
- exit(EXIT_SUCCESS);
+ if (find_mount_point(device_name)) {
+ int cont;
+#if ENABLE_FEATURE_MTAB_SUPPORT
+ /*
+ * If the root is mounted read-only, then /etc/mtab is
+ * probably not correct; so we won't issue a warning based on
+ * it.
+ */
+ int fd = open(bb_path_mtab_file, O_RDWR);
+
+ if (fd < 0 && errno == EROFS)
+ return;
+ close(fd);
+#endif
+ printf("%s is mounted. ", device_name);
+ cont = 0;
+ if (isatty(0) && isatty(1))
+ cont = ask("Do you really want to continue", 0);
+ if (!cont) {
+ printf("Check aborted\n");
+ exit(EXIT_SUCCESS);
+ }
}
}
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 2666132..18512a3 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -624,7 +624,6 @@ static void setup_tables(void)
int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
{
- struct mntent *mp;
unsigned opt;
char *tmp;
struct stat statbuf;
@@ -683,11 +682,8 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
G.total_blocks = 65535;
/* Check if it is mounted */
- mp = find_mount_point(G.device_name, NULL);
- if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0)
- bb_error_msg_and_die("%s is mounted on %s; "
- "refusing to make a filesystem",
- G.device_name, mp->mnt_dir);
+ if (find_mount_point(G.device_name))
+ bb_error_msg_and_die("can't format mounted filesystem");
xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
if (fstat(dev_fd, &statbuf) < 0)
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index 98a0895..8c6078d 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -275,7 +275,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
)
bb_error_msg_and_die("will not try to make filesystem on full-disk device (use -I if wanted)");
// can't work on mounted filesystems
- if (find_mount_point(device_name, NULL))
+ if (find_mount_point(device_name))
bb_error_msg_and_die("can't format mounted filesystem");
#endif
// get true sector size