diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2000-06-08 12:54:12 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2000-06-08 12:54:12 +0000 |
commit | 9500a3db906ebfde288593b16132beecea93ee50 (patch) | |
tree | ea9e106c02b962b8755515f74ce12f5fe4c6081a /winsup/utils/umount.cc | |
parent | fe73870ce5c25aec19ad16e64718ed1051f12f0d (diff) | |
download | cygnal-9500a3db906ebfde288593b16132beecea93ee50.tar.gz cygnal-9500a3db906ebfde288593b16132beecea93ee50.tar.bz2 cygnal-9500a3db906ebfde288593b16132beecea93ee50.zip |
mount.cc (error): New function to report an error and exit.
umount.cc (error): Ditto.
(remove_all_automounts): Check return status of cygwin_umount.
(remove_all_user_mounts): Ditto.
(remove_all_system_mounts): Ditto.
Diffstat (limited to 'winsup/utils/umount.cc')
-rw-r--r-- | winsup/utils/umount.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/winsup/utils/umount.cc b/winsup/utils/umount.cc index 6405ed90b..7623c5f97 100644 --- a/winsup/utils/umount.cc +++ b/winsup/utils/umount.cc @@ -13,6 +13,7 @@ details. */ #include <sys/mount.h> #include <mntent.h> #include <stdlib.h> +#include <errno.h> static void remove_all_mounts (); static void remove_all_automounts (); @@ -34,6 +35,13 @@ usage (void) exit (1); } +static void +error (char *path) +{ + fprintf (stderr, "%s: %s: %s\n", progname, path, strerror (errno)); + exit (1); +} + int main (int argc, char **argv) { @@ -81,10 +89,7 @@ main (int argc, char **argv) usage (); if (cygwin_umount (argv[i], flags) != 0) - { - perror ("umount"); - exit (1); - } + error (argv[i]); return 0; } @@ -109,14 +114,18 @@ remove_all_automounts () /* Remove the mount if it's an automount. */ if (strcmp (p->mnt_type, "user,auto") == 0) { - cygwin_umount (p->mnt_dir, 0); + if (cygwin_umount (p->mnt_dir, 0)) + error (p->mnt_dir); + /* We've modified the table so we need to start over. */ endmntent (m); m = setmntent ("/-not-used-", "r"); } else if (strcmp (p->mnt_type, "system,auto") == 0) { - cygwin_umount (p->mnt_dir, MOUNT_SYSTEM); + if (cygwin_umount (p->mnt_dir, MOUNT_SYSTEM)) + error (p->mnt_dir); + /* We've modified the table so we need to start over. */ endmntent (m); m = setmntent ("/-not-used-", "r"); @@ -132,14 +141,14 @@ remove_all_user_mounts () { FILE *m = setmntent ("/-not-used-", "r"); struct mntent *p; - int err; while ((p = getmntent (m)) != NULL) { /* Remove the mount if it's a user mount. */ if (strncmp (p->mnt_type, "user", 4) == 0) { - err = cygwin_umount (p->mnt_dir, 0); + if (cygwin_umount (p->mnt_dir, 0)) + error (p->mnt_dir); /* We've modified the table so we need to start over. */ endmntent (m); @@ -162,7 +171,8 @@ remove_all_system_mounts () /* Remove the mount if it's a system mount. */ if (strncmp (p->mnt_type, "system", 6) == 0) { - cygwin_umount (p->mnt_dir, MOUNT_SYSTEM); + if (cygwin_umount (p->mnt_dir, MOUNT_SYSTEM)) + error (p->mnt_dir); /* We've modified the table so we need to start over. */ endmntent (m); |