diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-05 04:50:36 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-05 04:50:36 +0200 |
commit | 09e63bb81f12707d31c8c4570931af0196b53a46 (patch) | |
tree | 1b550ca677e6cd4fdd70eabda1fd402684b8ec7d /util-linux | |
parent | 9b1b62adc4e4c1e80d9f72180c6b7b1eaef9f95a (diff) | |
download | busybox-w32-09e63bb81f12707d31c8c4570931af0196b53a46.tar.gz busybox-w32-09e63bb81f12707d31c8c4570931af0196b53a46.tar.bz2 busybox-w32-09e63bb81f12707d31c8c4570931af0196b53a46.zip |
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 <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/fsck_minix.c | 54 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 8 | ||||
-rw-r--r-- | util-linux/mkfs_vfat.c | 2 |
3 files changed, 25 insertions, 39 deletions
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) | |||
374 | */ | 374 | */ |
375 | static void check_mount(void) | 375 | static void check_mount(void) |
376 | { | 376 | { |
377 | FILE *f; | 377 | if (find_mount_point(device_name)) { |
378 | struct mntent *mnt; | 378 | int cont; |
379 | int cont; | 379 | #if ENABLE_FEATURE_MTAB_SUPPORT |
380 | int fd; | 380 | /* |
381 | //XXX:FIXME use find_mount_point() | 381 | * If the root is mounted read-only, then /etc/mtab is |
382 | f = setmntent(MOUNTED, "r"); | 382 | * probably not correct; so we won't issue a warning based on |
383 | if (f == NULL) | 383 | * it. |
384 | return; | 384 | */ |
385 | while ((mnt = getmntent(f)) != NULL) | 385 | int fd = open(bb_path_mtab_file, O_RDWR); |
386 | if (strcmp(device_name, mnt->mnt_fsname) == 0) | 386 | |
387 | break; | 387 | if (fd < 0 && errno == EROFS) |
388 | endmntent(f); | 388 | return; |
389 | if (!mnt) | 389 | close(fd); |
390 | return; | 390 | #endif |
391 | 391 | printf("%s is mounted. ", device_name); | |
392 | /* | 392 | cont = 0; |
393 | * If the root is mounted read-only, then /etc/mtab is | 393 | if (isatty(0) && isatty(1)) |
394 | * probably not correct; so we won't issue a warning based on | 394 | cont = ask("Do you really want to continue", 0); |
395 | * it. | 395 | if (!cont) { |
396 | */ | 396 | printf("Check aborted\n"); |
397 | fd = open(MOUNTED, O_RDWR); | 397 | exit(EXIT_SUCCESS); |
398 | if (fd < 0 && errno == EROFS) | 398 | } |
399 | return; | ||
400 | close(fd); | ||
401 | |||
402 | printf("%s is mounted. ", device_name); | ||
403 | cont = 0; | ||
404 | if (isatty(0) && isatty(1)) | ||
405 | cont = ask("Do you really want to continue", 0); | ||
406 | if (!cont) { | ||
407 | printf("Check aborted\n"); | ||
408 | exit(EXIT_SUCCESS); | ||
409 | } | 399 | } |
410 | } | 400 | } |
411 | 401 | ||
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 2666132f9..18512a395 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -624,7 +624,6 @@ static void setup_tables(void) | |||
624 | int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 624 | int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
625 | int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) | 625 | int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) |
626 | { | 626 | { |
627 | struct mntent *mp; | ||
628 | unsigned opt; | 627 | unsigned opt; |
629 | char *tmp; | 628 | char *tmp; |
630 | struct stat statbuf; | 629 | struct stat statbuf; |
@@ -683,11 +682,8 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) | |||
683 | G.total_blocks = 65535; | 682 | G.total_blocks = 65535; |
684 | 683 | ||
685 | /* Check if it is mounted */ | 684 | /* Check if it is mounted */ |
686 | mp = find_mount_point(G.device_name, NULL); | 685 | if (find_mount_point(G.device_name)) |
687 | if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0) | 686 | bb_error_msg_and_die("can't format mounted filesystem"); |
688 | bb_error_msg_and_die("%s is mounted on %s; " | ||
689 | "refusing to make a filesystem", | ||
690 | G.device_name, mp->mnt_dir); | ||
691 | 687 | ||
692 | xmove_fd(xopen(G.device_name, O_RDWR), dev_fd); | 688 | xmove_fd(xopen(G.device_name, O_RDWR), dev_fd); |
693 | if (fstat(dev_fd, &statbuf) < 0) | 689 | if (fstat(dev_fd, &statbuf) < 0) |
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 98a089502..8c6078d7b 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) | |||
275 | ) | 275 | ) |
276 | bb_error_msg_and_die("will not try to make filesystem on full-disk device (use -I if wanted)"); | 276 | bb_error_msg_and_die("will not try to make filesystem on full-disk device (use -I if wanted)"); |
277 | // can't work on mounted filesystems | 277 | // can't work on mounted filesystems |
278 | if (find_mount_point(device_name, NULL)) | 278 | if (find_mount_point(device_name)) |
279 | bb_error_msg_and_die("can't format mounted filesystem"); | 279 | bb_error_msg_and_die("can't format mounted filesystem"); |
280 | #endif | 280 | #endif |
281 | // get true sector size | 281 | // get true sector size |