aboutsummaryrefslogtreecommitdiff
path: root/umount.c
diff options
context:
space:
mode:
Diffstat (limited to 'umount.c')
-rw-r--r--umount.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/umount.c b/umount.c
index ad7de2d20..18a5afe80 100644
--- a/umount.c
+++ b/umount.c
@@ -38,8 +38,11 @@ static const char umount_usage[] =
38 "\n" 38 "\n"
39#endif 39#endif
40 "\t-r:\tTry to remount devices as read-only if mount is busy\n" 40 "\t-r:\tTry to remount devices as read-only if mount is busy\n"
41#if defined BB_FEATURE_MOUNT_FORCE
42 "\t-f:\tForce filesystem umount (i.e. unreachable NFS server)\n"
43#endif
41#if defined BB_FEATURE_MOUNT_LOOP 44#if defined BB_FEATURE_MOUNT_LOOP
42 "\t-f:\tDo not free loop device (if a loop device has been used)\n" 45 "\t-l:\tDo not free loop device (if a loop device has been used)\n"
43#endif 46#endif
44; 47;
45 48
@@ -53,6 +56,9 @@ static struct _mtab_entry_t *mtab_cache = NULL;
53 56
54 57
55 58
59#if defined BB_FEATURE_MOUNT_FORCE
60static int doForce = FALSE;
61#endif
56#if defined BB_FEATURE_MOUNT_LOOP 62#if defined BB_FEATURE_MOUNT_LOOP
57static int freeLoop = TRUE; 63static int freeLoop = TRUE;
58#endif 64#endif
@@ -176,13 +182,20 @@ static int do_umount(const char *name, int useMtab)
176 /* this was a loop device, delete it */ 182 /* this was a loop device, delete it */
177 del_loop(blockDevice); 183 del_loop(blockDevice);
178#endif 184#endif
185#if defined BB_FEATURE_MOUNT_FORCE
186 if (status != 0 && doForce == TRUE) {
187 status = umount2(blockDevice, MNT_FORCE);
188 if (status != 0) {
189 fatalError("umount: forced umount of %s failed!\n", blockDevice);
190 }
191 }
192#endif
179 if (status != 0 && doRemount == TRUE && errno == EBUSY) { 193 if (status != 0 && doRemount == TRUE && errno == EBUSY) {
180 status = mount(blockDevice, name, NULL, 194 status = mount(blockDevice, name, NULL,
181 MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); 195 MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
182 if (status == 0) { 196 if (status == 0) {
183 fprintf(stderr, "umount: %s busy - remounted read-only\n", 197 fprintf(stderr, "umount: %s busy - remounted read-only\n",
184 blockDevice); 198 blockDevice);
185 /* TODO: update mtab if BB_MTAB is defined */
186 } else { 199 } else {
187 fprintf(stderr, "umount: Cannot remount %s read-only\n", 200 fprintf(stderr, "umount: Cannot remount %s read-only\n",
188 blockDevice); 201 blockDevice);
@@ -240,7 +253,7 @@ extern int umount_main(int argc, char **argv)
240 umountAll = TRUE; 253 umountAll = TRUE;
241 break; 254 break;
242#if defined BB_FEATURE_MOUNT_LOOP 255#if defined BB_FEATURE_MOUNT_LOOP
243 case 'f': 256 case 'l':
244 freeLoop = FALSE; 257 freeLoop = FALSE;
245 break; 258 break;
246#endif 259#endif
@@ -249,6 +262,11 @@ extern int umount_main(int argc, char **argv)
249 useMtab = FALSE; 262 useMtab = FALSE;
250 break; 263 break;
251#endif 264#endif
265#ifdef BB_FEATURE_MOUNT_FORCE
266 case 'f':
267 doForce = TRUE;
268 break;
269#endif
252 case 'r': 270 case 'r':
253 doRemount = TRUE; 271 doRemount = TRUE;
254 break; 272 break;