From 09e63bb81f12707d31c8c4570931af0196b53a46 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 5 Jul 2009 04:50:36 +0200 Subject: df: fix "df /" also, clean up mount checks in mkfs/fsck. function old new delta find_mount_point 243 261 +18 sha1_process_block64 497 510 +13 find_main 436 444 +8 display_speed 85 90 +5 df_main 795 793 -2 parse_command 1463 1460 -3 static.ignored_mounts 8 - -8 mkfs_minix_main 2962 2937 -25 fsck_minix_main 3065 2970 -95 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 4/4 up/down: 44/-133) Total: -89 bytes Signed-off-by: Denys Vlasenko --- util-linux/fsck_minix.c | 54 ++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'util-linux/fsck_minix.c') diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 0c33c1b02..ca0b17efe 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); + } } } -- cgit v1.2.3