summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenis Vlasenko2006-09-14 16:40:46 +0000
committerDenis Vlasenko2006-09-14 16:40:46 +0000
commitaf9854b81a681d2eb6c12f7db2ca54f1f4c65129 (patch)
tree290406b7afe467e94425e1d5216a0f6cd24fd257 /util-linux
parentbe507170eb151ed06685e0e8de2fe1af2fedd374 (diff)
downloadbusybox-af9854b81a681d2eb6c12f7db2ca54f1f4c65129.zip
busybox-af9854b81a681d2eb6c12f7db2ca54f1f4c65129.tar.gz
umount: do not try to close FILE* which is NULL.
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/umount.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index fabc3d0..1a6b14c 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -59,15 +59,17 @@ int umount_main(int argc, char **argv)
if (!(fp = setmntent(bb_path_mtab_file, "r"))) {
if (opt & OPT_ALL)
- bb_error_msg_and_die("Cannot open %s", bb_path_mtab_file);
- } else while (getmntent_r(fp,&me,path,sizeof(path))) {
- m = xmalloc(sizeof(struct mtab_list));
- m->next = mtl;
- m->device = xstrdup(me.mnt_fsname);
- m->dir = xstrdup(me.mnt_dir);
- mtl = m;
+ bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
+ } else {
+ while (getmntent_r(fp,&me,path,sizeof(path))) {
+ m = xmalloc(sizeof(struct mtab_list));
+ m->next = mtl;
+ m->device = xstrdup(me.mnt_fsname);
+ m->dir = xstrdup(me.mnt_dir);
+ mtl = m;
+ }
+ endmntent(fp);
}
- endmntent(fp);
/* If we're not mounting all, we need at least one argument. */
if (!(opt & OPT_ALL)) {
@@ -111,13 +113,13 @@ int umount_main(int argc, char **argv)
// If still can't umount, maybe remount read-only?
if (curstat && (opt & OPT_REMOUNT) && errno == EBUSY && m) {
curstat = mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL);
- bb_error_msg(curstat ? "Cannot remount %s read-only" :
+ bb_error_msg(curstat ? "cannot remount %s read-only" :
"%s busy - remounted read-only", m->device);
}
if (curstat) {
status = EXIT_FAILURE;
- bb_perror_msg("Couldn't umount %s", zapit);
+ bb_perror_msg("cannot umount %s", zapit);
} else {
/* De-allocate the loop device. This ioctl should be ignored on
* any non-loop block devices. */
@@ -143,7 +145,7 @@ int umount_main(int argc, char **argv)
free(mtl->device);
free(mtl->dir);
free(mtl);
- mtl=m;
+ mtl = m;
}
}