Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Mini umount implementation for busybox |
| 4 | * |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen |
| 6 | * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
Matt Kraai | adcbc12 | 2001-05-02 21:24:51 +0000 | [diff] [blame] | 24 | #include <limits.h> |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 25 | #include <stdio.h> |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 26 | #include <mntent.h> |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 27 | #include <errno.h> |
Eric Andersen | ed3ef50 | 2001-01-27 08:24:39 +0000 | [diff] [blame] | 28 | #include <string.h> |
| 29 | #include <stdlib.h> |
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 30 | #include "busybox.h" |
Eric Andersen | e1e23ee | 2000-06-19 18:38:51 +0000 | [diff] [blame] | 31 | |
Eric Andersen | 8a91588 | 2001-08-02 09:55:58 +0000 | [diff] [blame] | 32 | /* Teach libc5 about realpath -- it includes it but the |
| 33 | * prototype is missing... */ |
| 34 | #if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1) |
| 35 | extern char *realpath(const char *path, char *resolved_path); |
| 36 | #endif |
Eric Andersen | e1e23ee | 2000-06-19 18:38:51 +0000 | [diff] [blame] | 37 | |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 38 | static const int MNT_FORCE = 1; |
| 39 | static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */ |
| 40 | static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS. */ |
| 41 | static const int MS_RDONLY = 1; /* Mount read-only. */ |
Eric Andersen | 2cd439f | 2000-07-08 19:10:29 +0000 | [diff] [blame] | 42 | |
Eric Andersen | a57ba4d | 2000-07-08 19:20:49 +0000 | [diff] [blame] | 43 | extern int mount (__const char *__special_file, __const char *__dir, |
| 44 | __const char *__fstype, unsigned long int __rwflag, |
| 45 | __const void *__data); |
| 46 | extern int umount (__const char *__special_file); |
| 47 | extern int umount2 (__const char *__special_file, int __flags); |
Eric Andersen | 2cd439f | 2000-07-08 19:10:29 +0000 | [diff] [blame] | 48 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 49 | struct _mtab_entry_t { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 50 | char *device; |
| 51 | char *mountpt; |
| 52 | struct _mtab_entry_t *next; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static struct _mtab_entry_t *mtab_cache = NULL; |
| 56 | |
| 57 | |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 58 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 59 | #if defined CONFIG_FEATURE_MOUNT_FORCE |
Erik Andersen | 6c5f2c6 | 2000-05-05 19:49:33 +0000 | [diff] [blame] | 60 | static int doForce = FALSE; |
| 61 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 62 | #if defined CONFIG_FEATURE_MOUNT_LOOP |
Erik Andersen | ce91732 | 2000-03-13 04:07:02 +0000 | [diff] [blame] | 63 | static int freeLoop = TRUE; |
| 64 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 65 | #if defined CONFIG_FEATURE_MTAB_SUPPORT |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 66 | static int useMtab = TRUE; |
Eric Andersen | 1ca20a7 | 2001-03-21 07:34:27 +0000 | [diff] [blame] | 67 | #endif |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 68 | static int umountAll = FALSE; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 69 | static int doRemount = FALSE; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 70 | extern const char mtab_file[]; /* Defined in utility.c */ |
Eric Andersen | d0246fb | 1999-11-04 21:18:07 +0000 | [diff] [blame] | 71 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 72 | |
Erik Andersen | 5b911dd | 2000-02-23 22:49:58 +0000 | [diff] [blame] | 73 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 74 | /* These functions are here because the getmntent functions do not appear |
| 75 | * to be re-entrant, which leads to all sorts of problems when we try to |
| 76 | * use them recursively - randolph |
Erik Andersen | 5b911dd | 2000-02-23 22:49:58 +0000 | [diff] [blame] | 77 | * |
| 78 | * TODO: Perhaps switch to using Glibc's getmntent_r |
| 79 | * -Erik |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 80 | */ |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 81 | static void mtab_read(void) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 82 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 83 | struct _mtab_entry_t *entry = NULL; |
| 84 | struct mntent *e; |
| 85 | FILE *fp; |
| 86 | |
| 87 | if (mtab_cache != NULL) |
| 88 | return; |
| 89 | |
| 90 | if ((fp = setmntent(mtab_file, "r")) == NULL) { |
Matt Kraai | dd19c69 | 2001-01-31 19:00:21 +0000 | [diff] [blame] | 91 | error_msg("Cannot open %s", mtab_file); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 92 | return; |
| 93 | } |
| 94 | while ((e = getmntent(fp))) { |
Erik Andersen | 0d068a2 | 2000-03-21 22:32:57 +0000 | [diff] [blame] | 95 | entry = xmalloc(sizeof(struct _mtab_entry_t)); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 96 | entry->device = strdup(e->mnt_fsname); |
| 97 | entry->mountpt = strdup(e->mnt_dir); |
| 98 | entry->next = mtab_cache; |
| 99 | mtab_cache = entry; |
| 100 | } |
| 101 | endmntent(fp); |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 104 | static char *mtab_getinfo(const char *match, const char which) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 105 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 106 | struct _mtab_entry_t *cur = mtab_cache; |
| 107 | |
| 108 | while (cur) { |
| 109 | if (strcmp(cur->mountpt, match) == 0 || |
| 110 | strcmp(cur->device, match) == 0) { |
| 111 | if (which == MTAB_GETMOUNTPT) { |
| 112 | return cur->mountpt; |
| 113 | } else { |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 114 | #if !defined CONFIG_FEATURE_MTAB_SUPPORT |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 115 | if (strcmp(cur->device, "/dev/root") == 0) { |
Erik Andersen | ec5bd90 | 2000-03-22 07:12:05 +0000 | [diff] [blame] | 116 | /* Adjusts device to be the real root device, |
| 117 | * or leaves device alone if it can't find it */ |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 118 | cur->device = find_real_root_device_name(cur->device); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 119 | } |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 120 | #endif |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 121 | return cur->device; |
| 122 | } |
| 123 | } |
| 124 | cur = cur->next; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 125 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 126 | return NULL; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 129 | static char *mtab_next(void **iter) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 130 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 131 | char *mp; |
| 132 | |
| 133 | if (iter == NULL || *iter == NULL) |
| 134 | return NULL; |
| 135 | mp = ((struct _mtab_entry_t *) (*iter))->mountpt; |
| 136 | *iter = (void *) ((struct _mtab_entry_t *) (*iter))->next; |
| 137 | return mp; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 140 | static char *mtab_first(void **iter) |
| 141 | { |
| 142 | struct _mtab_entry_t *mtab_iter; |
| 143 | |
| 144 | if (!iter) |
| 145 | return NULL; |
| 146 | mtab_iter = mtab_cache; |
| 147 | *iter = (void *) mtab_iter; |
| 148 | return mtab_next(iter); |
| 149 | } |
| 150 | |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 151 | /* Don't bother to clean up, since exit() does that |
| 152 | * automagically, so we can save a few bytes */ |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 153 | #ifdef CONFIG_FEATURE_CLEAN_UP |
Eric Andersen | c911a43 | 2001-05-15 17:42:16 +0000 | [diff] [blame] | 154 | static void mtab_free(void) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 155 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 156 | struct _mtab_entry_t *this, *next; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 157 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 158 | this = mtab_cache; |
| 159 | while (this) { |
| 160 | next = this->next; |
Aaron Lehmann | a170e1c | 2002-11-28 11:27:31 +0000 | [diff] [blame] | 161 | free(this->device); |
| 162 | free(this->mountpt); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 163 | free(this); |
| 164 | this = next; |
| 165 | } |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 166 | } |
Erik Andersen | 298854f | 2000-03-23 01:09:18 +0000 | [diff] [blame] | 167 | #endif |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 168 | |
Eric Andersen | 1ca20a7 | 2001-03-21 07:34:27 +0000 | [diff] [blame] | 169 | static int do_umount(const char *name) |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 170 | { |
| 171 | int status; |
| 172 | char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE); |
| 173 | |
| 174 | if (blockDevice && strcmp(blockDevice, name) == 0) |
| 175 | name = mtab_getinfo(blockDevice, MTAB_GETMOUNTPT); |
| 176 | |
| 177 | status = umount(name); |
| 178 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 179 | #if defined CONFIG_FEATURE_MOUNT_LOOP |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 180 | if (freeLoop && blockDevice != NULL && !strncmp("/dev/loop", blockDevice, 9)) |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 181 | /* this was a loop device, delete it */ |
| 182 | del_loop(blockDevice); |
| 183 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 184 | #if defined CONFIG_FEATURE_MOUNT_FORCE |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 185 | if (status != 0 && doForce) { |
Erik Andersen | 6c5f2c6 | 2000-05-05 19:49:33 +0000 | [diff] [blame] | 186 | status = umount2(blockDevice, MNT_FORCE); |
| 187 | if (status != 0) { |
Matt Kraai | dd19c69 | 2001-01-31 19:00:21 +0000 | [diff] [blame] | 188 | error_msg_and_die("forced umount of %s failed!", blockDevice); |
Erik Andersen | 6c5f2c6 | 2000-05-05 19:49:33 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | #endif |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 192 | if (status != 0 && doRemount && errno == EBUSY) { |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 193 | status = mount(blockDevice, name, NULL, |
| 194 | MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); |
| 195 | if (status == 0) { |
Matt Kraai | dd19c69 | 2001-01-31 19:00:21 +0000 | [diff] [blame] | 196 | error_msg("%s busy - remounted read-only", blockDevice); |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 197 | } else { |
Matt Kraai | dd19c69 | 2001-01-31 19:00:21 +0000 | [diff] [blame] | 198 | error_msg("Cannot remount %s read-only", blockDevice); |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 199 | } |
| 200 | } |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 201 | if (status == 0) { |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 202 | #if defined CONFIG_FEATURE_MTAB_SUPPORT |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 203 | if (useMtab) |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 204 | erase_mtab(name); |
| 205 | #endif |
| 206 | return (TRUE); |
| 207 | } |
| 208 | return (FALSE); |
| 209 | } |
| 210 | |
Eric Andersen | 1ca20a7 | 2001-03-21 07:34:27 +0000 | [diff] [blame] | 211 | static int umount_all(void) |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 212 | { |
| 213 | int status = TRUE; |
| 214 | char *mountpt; |
| 215 | void *iter; |
| 216 | |
| 217 | for (mountpt = mtab_first(&iter); mountpt; mountpt = mtab_next(&iter)) { |
| 218 | /* Never umount /proc on a umount -a */ |
| 219 | if (strstr(mountpt, "proc")!= NULL) |
| 220 | continue; |
Eric Andersen | 1ca20a7 | 2001-03-21 07:34:27 +0000 | [diff] [blame] | 221 | if (!do_umount(mountpt)) { |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 222 | /* Don't bother retrying the umount on busy devices */ |
| 223 | if (errno == EBUSY) { |
Matt Kraai | a9819b2 | 2000-12-22 01:48:07 +0000 | [diff] [blame] | 224 | perror_msg("%s", mountpt); |
Matt Kraai | fd4c58d | 2001-01-17 00:12:11 +0000 | [diff] [blame] | 225 | status = FALSE; |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 226 | continue; |
| 227 | } |
Eric Andersen | 1ca20a7 | 2001-03-21 07:34:27 +0000 | [diff] [blame] | 228 | if (!do_umount(mountpt)) { |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 229 | printf("Couldn't umount %s on %s: %s\n", |
| 230 | mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE), |
| 231 | strerror(errno)); |
Matt Kraai | fd4c58d | 2001-01-17 00:12:11 +0000 | [diff] [blame] | 232 | status = FALSE; |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | } |
| 236 | return (status); |
| 237 | } |
| 238 | |
| 239 | extern int umount_main(int argc, char **argv) |
| 240 | { |
Matt Kraai | adcbc12 | 2001-05-02 21:24:51 +0000 | [diff] [blame] | 241 | char path[PATH_MAX]; |
| 242 | |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 243 | if (argc < 2) { |
Eric Andersen | 67991cf | 2001-02-14 21:23:06 +0000 | [diff] [blame] | 244 | show_usage(); |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 245 | } |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 246 | #ifdef CONFIG_FEATURE_CLEAN_UP |
Eric Andersen | b040d4f | 2000-07-25 18:01:20 +0000 | [diff] [blame] | 247 | atexit(mtab_free); |
| 248 | #endif |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 249 | |
| 250 | /* Parse any options */ |
| 251 | while (--argc > 0 && **(++argv) == '-') { |
| 252 | while (*++(*argv)) |
| 253 | switch (**argv) { |
| 254 | case 'a': |
| 255 | umountAll = TRUE; |
| 256 | break; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 257 | #if defined CONFIG_FEATURE_MOUNT_LOOP |
Erik Andersen | 6c5f2c6 | 2000-05-05 19:49:33 +0000 | [diff] [blame] | 258 | case 'l': |
Erik Andersen | ce91732 | 2000-03-13 04:07:02 +0000 | [diff] [blame] | 259 | freeLoop = FALSE; |
| 260 | break; |
| 261 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 262 | #ifdef CONFIG_FEATURE_MTAB_SUPPORT |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 263 | case 'n': |
| 264 | useMtab = FALSE; |
| 265 | break; |
| 266 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 267 | #ifdef CONFIG_FEATURE_MOUNT_FORCE |
Erik Andersen | 6c5f2c6 | 2000-05-05 19:49:33 +0000 | [diff] [blame] | 268 | case 'f': |
| 269 | doForce = TRUE; |
| 270 | break; |
| 271 | #endif |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 272 | case 'r': |
| 273 | doRemount = TRUE; |
| 274 | break; |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 275 | case 'v': |
| 276 | break; /* ignore -v */ |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 277 | default: |
Eric Andersen | 67991cf | 2001-02-14 21:23:06 +0000 | [diff] [blame] | 278 | show_usage(); |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
| 282 | mtab_read(); |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 283 | if (umountAll) { |
| 284 | if (umount_all()) |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 285 | return EXIT_SUCCESS; |
| 286 | else |
| 287 | return EXIT_FAILURE; |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 288 | } |
Matt Kraai | adcbc12 | 2001-05-02 21:24:51 +0000 | [diff] [blame] | 289 | if (realpath(*argv, path) == NULL) |
| 290 | perror_msg_and_die("%s", path); |
Matt Kraai | 1f0c436 | 2001-12-20 23:13:26 +0000 | [diff] [blame] | 291 | if (do_umount(path)) |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 292 | return EXIT_SUCCESS; |
Matt Kraai | a9819b2 | 2000-12-22 01:48:07 +0000 | [diff] [blame] | 293 | perror_msg_and_die("%s", *argv); |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 294 | } |
| 295 | |