aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-05-05 19:49:33 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-05-05 19:49:33 +0000
commitd8bffd1f53dbbb714a874d12b80a821adb0e72a6 (patch)
treee5b0d03dee3ca473422d617ce6985d60f0985c04
parent936daf4b36f2cd527138294c9d56f6781f1a2b5b (diff)
downloadbusybox-w32-d8bffd1f53dbbb714a874d12b80a821adb0e72a6.tar.gz
busybox-w32-d8bffd1f53dbbb714a874d12b80a821adb0e72a6.tar.bz2
busybox-w32-d8bffd1f53dbbb714a874d12b80a821adb0e72a6.zip
Add support for "noatime" and "nodiratime" mount flags to mount.
Change umount "-f" to mean force, and actually use umount2. Change umount "-l" to mean "Do not free loop device". Updates docs accordingly. -Erik git-svn-id: svn://busybox.net/trunk/busybox@522 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--busybox.def.h4
-rw-r--r--docs/busybox.pod38
-rw-r--r--mount.c32
-rw-r--r--umount.c24
-rw-r--r--util-linux/mount.c32
-rw-r--r--util-linux/umount.c24
6 files changed, 104 insertions, 50 deletions
diff --git a/busybox.def.h b/busybox.def.h
index c5b7de900..a2d216ff7 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -181,6 +181,10 @@
181// Enable support for a real /etc/mtab file instead of /proc/mounts 181// Enable support for a real /etc/mtab file instead of /proc/mounts
182//#define BB_FEATURE_MOUNT_MTAB_SUPPORT 182//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
183// 183//
184// Enable support forced filesystem unmounting
185// (i.e. in case of an unreachable NFS system).
186#define BB_FEATURE_MOUNT_FORCE
187//
184// Enable support for mounting remote NFS volumes 188// Enable support for mounting remote NFS volumes
185//#define BB_FEATURE_NFSMOUNT 189//#define BB_FEATURE_NFSMOUNT
186// 190//
diff --git a/docs/busybox.pod b/docs/busybox.pod
index ac492ab15..6a18a0499 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -1111,21 +1111,22 @@ Usage: mount [flags]
1111 1111
1112Flags: 1112Flags:
1113 1113
1114 -a: Mount all file systems in fstab. 1114 -a: Mount all file systems in fstab.
1115 -o option: One of many filesystem options, listed below. 1115 -o option: One of many filesystem options, listed below.
1116 -r: Mount the filesystem read-only. 1116 -r: Mount the filesystem read-only.
1117 -t filesystem-type: Specify the filesystem type. 1117 -t fs-type: Specify the filesystem type.
1118 -w: Mount for reading and writing (default). 1118 -w: Mount for reading and writing (default).
1119 1119
1120Options for use with the "B<-o>" flag: 1120Options for use with the "-o" flag:
1121 1121
1122 async / sync: Writes are asynchronous / synchronous. 1122 async/sync: Writes are asynchronous / synchronous.
1123 dev / nodev: Allow use of special device files / disallow them. 1123 atime/noatime: Enable / disable updates to inode access times.
1124 exec / noexec: Allow use of executable files / disallow them. 1124 dev/nodev: Allow use of special device files / disallow them.
1125 loop: Mounts a file via loop device. 1125 exec/noexec: Allow use of executable files / disallow them.
1126 suid / nosuid: Allow set-user-id-root programs / disallow them. 1126 loop: Mounts a file via loop device.
1127 remount: Re-mount a currently-mounted filesystem, changing its flags. 1127 suid/nosuid: Allow set-user-id-root programs / disallow them.
1128 ro / rw: Mount for read-only / read-write. 1128 remount: Re-mount a currently-mounted filesystem, changing its flags.
1129 ro/rw: Mount for read-only / read-write.
1129 There are EVEN MORE flags that are specific to each filesystem. 1130 There are EVEN MORE flags that are specific to each filesystem.
1130 You'll have to see the written documentation for those. 1131 You'll have to see the written documentation for those.
1131 1132
@@ -1663,9 +1664,10 @@ Usage: umount [flags] filesystem|directory
1663 1664
1664Flags: 1665Flags:
1665 1666
1666 -a: Unmount all file systems 1667 -a: Unmount all file systems
1667 -r: Try to remount devices as read-only if mount is busy 1668 -r: Try to remount devices as read-only if mount is busy
1668 -f: Do not free loop device (if a loop device has been used) 1669 -f: Force filesystem umount (i.e. unreachable NFS server)
1670 -l: Do not free loop device (if a loop device has been used)
1669 1671
1670Example: 1672Example:
1671 1673
@@ -1876,4 +1878,4 @@ Enrique Zanardi <ezanardi@ull.es>
1876 1878
1877=cut 1879=cut
1878 1880
1879# $Id: busybox.pod,v 1.27 2000/05/02 06:40:02 erik Exp $ 1881# $Id: busybox.pod,v 1.28 2000/05/05 19:49:33 erik Exp $
diff --git a/mount.c b/mount.c
index 456e45235..00a774a53 100644
--- a/mount.c
+++ b/mount.c
@@ -66,26 +66,28 @@ extern const char mtab_file[]; /* Defined in utility.c */
66 66
67static const char mount_usage[] = "\tmount [flags]\n" 67static const char mount_usage[] = "\tmount [flags]\n"
68 "\tmount [flags] device directory [-o options,more-options]\n" 68 "\tmount [flags] device directory [-o options,more-options]\n"
69 "\n" "Flags:\n" "\t-a:\tMount all file systems in fstab.\n" 69 "\n" "Flags:\n"
70 "\t-a:\t\tMount all file systems in fstab.\n"
70#ifdef BB_MTAB 71#ifdef BB_MTAB
71 "\t-f:\t\"Fake\" mount. Add entry to mount table but don't mount it.\n" 72 "\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
72 "\t-n:\tDon't write a mount table entry.\n" 73 "\t-n:\t\tDon't write a mount table entry.\n"
73#endif 74#endif
74 "\t-o option:\tOne of many filesystem options, listed below.\n" 75 "\t-o option:\tOne of many filesystem options, listed below.\n"
75 "\t-r:\tMount the filesystem read-only.\n" 76 "\t-r:\t\tMount the filesystem read-only.\n"
76 "\t-t filesystem-type:\tSpecify the filesystem type.\n" 77 "\t-t fs-type:\tSpecify the filesystem type.\n"
77 "\t-w:\tMount for reading and writing (default).\n" 78 "\t-w:\t\tMount for reading and writing (default).\n"
78 "\n" 79 "\n"
79 "Options for use with the \"-o\" flag:\n" 80 "Options for use with the \"-o\" flag:\n"
80 "\tasync / sync:\tWrites are asynchronous / synchronous.\n" 81 "\tasync/sync:\tWrites are asynchronous / synchronous.\n"
81 "\tdev / nodev:\tAllow use of special device files / disallow them.\n" 82 "\tatime/noatime:\tEnable / disable updates to inode access times.\n"
82 "\texec / noexec:\tAllow use of executable files / disallow them.\n" 83 "\tdev/nodev:\tAllow use of special device files / disallow them.\n"
84 "\texec/noexec:\tAllow use of executable files / disallow them.\n"
83#if defined BB_FEATURE_MOUNT_LOOP 85#if defined BB_FEATURE_MOUNT_LOOP
84 "\tloop: Mounts a file via loop device.\n" 86 "\tloop:\t\tMounts a file via loop device.\n"
85#endif 87#endif
86 "\tsuid / nosuid:\tAllow set-user-id-root programs / disallow them.\n" 88 "\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
87 "\tremount: Re-mount a currently-mounted filesystem, changing its flags.\n" 89 "\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
88 "\tro / rw: Mount for read-only / read-write.\n" 90 "\tro/rw:\t\tMount for read-only / read-write.\n"
89 "There are EVEN MORE flags that are specific to each filesystem.\n" 91 "There are EVEN MORE flags that are specific to each filesystem.\n"
90 "You'll have to see the written documentation for those.\n"; 92 "You'll have to see the written documentation for those.\n";
91 93
@@ -98,10 +100,14 @@ struct mount_options {
98 100
99static const struct mount_options mount_options[] = { 101static const struct mount_options mount_options[] = {
100 {"async", ~MS_SYNCHRONOUS, 0}, 102 {"async", ~MS_SYNCHRONOUS, 0},
103 {"atime", ~0, ~MS_NOATIME},
101 {"defaults", ~0, 0}, 104 {"defaults", ~0, 0},
102 {"dev", ~MS_NODEV, 0}, 105 {"dev", ~MS_NODEV, 0},
106 {"diratime", ~0, ~MS_NODIRATIME},
103 {"exec", ~MS_NOEXEC, 0}, 107 {"exec", ~MS_NOEXEC, 0},
108 {"noatime", ~0, MS_NOATIME},
104 {"nodev", ~0, MS_NODEV}, 109 {"nodev", ~0, MS_NODEV},
110 {"nodiratime", ~0, MS_NODIRATIME},
105 {"noexec", ~0, MS_NOEXEC}, 111 {"noexec", ~0, MS_NOEXEC},
106 {"nosuid", ~0, MS_NOSUID}, 112 {"nosuid", ~0, MS_NOSUID},
107 {"remount", ~0, MS_REMOUNT}, 113 {"remount", ~0, MS_REMOUNT},
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;
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 456e45235..00a774a53 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -66,26 +66,28 @@ extern const char mtab_file[]; /* Defined in utility.c */
66 66
67static const char mount_usage[] = "\tmount [flags]\n" 67static const char mount_usage[] = "\tmount [flags]\n"
68 "\tmount [flags] device directory [-o options,more-options]\n" 68 "\tmount [flags] device directory [-o options,more-options]\n"
69 "\n" "Flags:\n" "\t-a:\tMount all file systems in fstab.\n" 69 "\n" "Flags:\n"
70 "\t-a:\t\tMount all file systems in fstab.\n"
70#ifdef BB_MTAB 71#ifdef BB_MTAB
71 "\t-f:\t\"Fake\" mount. Add entry to mount table but don't mount it.\n" 72 "\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
72 "\t-n:\tDon't write a mount table entry.\n" 73 "\t-n:\t\tDon't write a mount table entry.\n"
73#endif 74#endif
74 "\t-o option:\tOne of many filesystem options, listed below.\n" 75 "\t-o option:\tOne of many filesystem options, listed below.\n"
75 "\t-r:\tMount the filesystem read-only.\n" 76 "\t-r:\t\tMount the filesystem read-only.\n"
76 "\t-t filesystem-type:\tSpecify the filesystem type.\n" 77 "\t-t fs-type:\tSpecify the filesystem type.\n"
77 "\t-w:\tMount for reading and writing (default).\n" 78 "\t-w:\t\tMount for reading and writing (default).\n"
78 "\n" 79 "\n"
79 "Options for use with the \"-o\" flag:\n" 80 "Options for use with the \"-o\" flag:\n"
80 "\tasync / sync:\tWrites are asynchronous / synchronous.\n" 81 "\tasync/sync:\tWrites are asynchronous / synchronous.\n"
81 "\tdev / nodev:\tAllow use of special device files / disallow them.\n" 82 "\tatime/noatime:\tEnable / disable updates to inode access times.\n"
82 "\texec / noexec:\tAllow use of executable files / disallow them.\n" 83 "\tdev/nodev:\tAllow use of special device files / disallow them.\n"
84 "\texec/noexec:\tAllow use of executable files / disallow them.\n"
83#if defined BB_FEATURE_MOUNT_LOOP 85#if defined BB_FEATURE_MOUNT_LOOP
84 "\tloop: Mounts a file via loop device.\n" 86 "\tloop:\t\tMounts a file via loop device.\n"
85#endif 87#endif
86 "\tsuid / nosuid:\tAllow set-user-id-root programs / disallow them.\n" 88 "\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
87 "\tremount: Re-mount a currently-mounted filesystem, changing its flags.\n" 89 "\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
88 "\tro / rw: Mount for read-only / read-write.\n" 90 "\tro/rw:\t\tMount for read-only / read-write.\n"
89 "There are EVEN MORE flags that are specific to each filesystem.\n" 91 "There are EVEN MORE flags that are specific to each filesystem.\n"
90 "You'll have to see the written documentation for those.\n"; 92 "You'll have to see the written documentation for those.\n";
91 93
@@ -98,10 +100,14 @@ struct mount_options {
98 100
99static const struct mount_options mount_options[] = { 101static const struct mount_options mount_options[] = {
100 {"async", ~MS_SYNCHRONOUS, 0}, 102 {"async", ~MS_SYNCHRONOUS, 0},
103 {"atime", ~0, ~MS_NOATIME},
101 {"defaults", ~0, 0}, 104 {"defaults", ~0, 0},
102 {"dev", ~MS_NODEV, 0}, 105 {"dev", ~MS_NODEV, 0},
106 {"diratime", ~0, ~MS_NODIRATIME},
103 {"exec", ~MS_NOEXEC, 0}, 107 {"exec", ~MS_NOEXEC, 0},
108 {"noatime", ~0, MS_NOATIME},
104 {"nodev", ~0, MS_NODEV}, 109 {"nodev", ~0, MS_NODEV},
110 {"nodiratime", ~0, MS_NODIRATIME},
105 {"noexec", ~0, MS_NOEXEC}, 111 {"noexec", ~0, MS_NOEXEC},
106 {"nosuid", ~0, MS_NOSUID}, 112 {"nosuid", ~0, MS_NOSUID},
107 {"remount", ~0, MS_REMOUNT}, 113 {"remount", ~0, MS_REMOUNT},
diff --git a/util-linux/umount.c b/util-linux/umount.c
index ad7de2d20..18a5afe80 100644
--- a/util-linux/umount.c
+++ b/util-linux/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;