diff options
author | Rob Landley <rob@landley.net> | 2006-08-08 01:39:49 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-08-08 01:39:49 +0000 |
commit | e3781b731215d826585fe37720eebe147705f340 (patch) | |
tree | b146c666feca3c4908bc5bb90842a2c0d707385b /util-linux/mount.c | |
parent | 47b16a6fe98e1b18f269a2bd34471231553ebb94 (diff) | |
download | busybox-w32-e3781b731215d826585fe37720eebe147705f340.tar.gz busybox-w32-e3781b731215d826585fe37720eebe147705f340.tar.bz2 busybox-w32-e3781b731215d826585fe37720eebe147705f340.zip |
Add shared subtree support, suggested by Vladimir Dronnikov. Also break out a
few new (unfinished) config options, which I intend to make hidden (but
enabled) when CONFIG_NITPICK is disabled. Getting the .config infrastructure
to do that is non-obvious, it seems...
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r-- | util-linux/mount.c | 107 |
1 files changed, 57 insertions, 50 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index d5d3eae17..5d5f487c2 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -25,17 +25,6 @@ | |||
25 | #include "busybox.h" | 25 | #include "busybox.h" |
26 | #include <mntent.h> | 26 | #include <mntent.h> |
27 | 27 | ||
28 | // These two aren't always defined in old headers | ||
29 | #ifndef MS_BIND | ||
30 | #define MS_BIND 4096 | ||
31 | #endif | ||
32 | #ifndef MS_MOVE | ||
33 | #define MS_MOVE 8192 | ||
34 | #endif | ||
35 | #ifndef MS_SILENT | ||
36 | #define MS_SILENT 32768 | ||
37 | #endif | ||
38 | |||
39 | // Not real flags, but we want to be able to check for this. | 28 | // Not real flags, but we want to be able to check for this. |
40 | #define MOUNT_NOAUTO (1<<29) | 29 | #define MOUNT_NOAUTO (1<<29) |
41 | #define MOUNT_SWAP (1<<30) | 30 | #define MOUNT_SWAP (1<<30) |
@@ -43,40 +32,59 @@ | |||
43 | * flags */ | 32 | * flags */ |
44 | 33 | ||
45 | struct { | 34 | struct { |
46 | const char *name; | 35 | char *name; |
47 | long flags; | 36 | long flags; |
48 | } static const mount_options[] = { | 37 | } static mount_options[] = { |
49 | // NOP flags. | 38 | // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs. |
50 | 39 | ||
51 | {"loop", 0}, | 40 | USE_FEATURE_MOUNT_LOOP( |
52 | {"defaults", 0}, | 41 | {"loop", 0}, |
53 | {"quiet", 0}, | 42 | ) |
54 | 43 | ||
55 | // vfs flags | 44 | USE_FEATURE_MOUNT_FSTAB( |
56 | 45 | {"defaults", 0}, | |
57 | {"ro", MS_RDONLY}, | 46 | {"quiet", 0}, |
58 | {"rw", ~MS_RDONLY}, | 47 | {"noauto",MOUNT_NOAUTO}, |
59 | {"nosuid", MS_NOSUID}, | 48 | {"swap",MOUNT_SWAP}, |
60 | {"suid", ~MS_NOSUID}, | 49 | ) |
61 | {"dev", ~MS_NODEV}, | 50 | |
62 | {"nodev", MS_NODEV}, | 51 | USE_FEATURE_MOUNT_FLAGS( |
63 | {"exec", ~MS_NOEXEC}, | 52 | // vfs flags |
64 | {"noexec", MS_NOEXEC}, | 53 | {"nosuid", MS_NOSUID}, |
65 | {"sync", MS_SYNCHRONOUS}, | 54 | {"suid", ~MS_NOSUID}, |
66 | {"async", ~MS_SYNCHRONOUS}, | 55 | {"dev", ~MS_NODEV}, |
67 | {"atime", ~MS_NOATIME}, | 56 | {"nodev", MS_NODEV}, |
68 | {"noatime", MS_NOATIME}, | 57 | {"exec", ~MS_NOEXEC}, |
69 | {"diratime", ~MS_NODIRATIME}, | 58 | {"noexec", MS_NOEXEC}, |
70 | {"nodiratime", MS_NODIRATIME}, | 59 | {"sync", MS_SYNCHRONOUS}, |
71 | {"loud", ~MS_SILENT}, | 60 | {"async", ~MS_SYNCHRONOUS}, |
72 | 61 | {"atime", ~MS_NOATIME}, | |
73 | // action flags | 62 | {"noatime", MS_NOATIME}, |
74 | 63 | {"diratime", ~MS_NODIRATIME}, | |
75 | {"remount", MS_REMOUNT}, | 64 | {"nodiratime", MS_NODIRATIME}, |
76 | {"bind", MS_BIND}, | 65 | {"loud", ~MS_SILENT}, |
77 | {"move", MS_MOVE}, | 66 | |
78 | {"noauto",MOUNT_NOAUTO}, | 67 | // action flags |
79 | {"swap",MOUNT_SWAP} | 68 | |
69 | {"bind", MS_BIND}, | ||
70 | {"move", MS_MOVE}, | ||
71 | {"shared", MS_SHARED}, | ||
72 | {"slave", MS_SLAVE}, | ||
73 | {"private", MS_PRIVATE}, | ||
74 | {"unbindable", MS_UNBINDABLE}, | ||
75 | {"rshared", MS_SHARED|MS_RECURSIVE}, | ||
76 | {"rslave", MS_SLAVE|MS_RECURSIVE}, | ||
77 | {"rprivate", MS_SLAVE|MS_RECURSIVE}, | ||
78 | {"runbindable", MS_UNBINDABLE|MS_RECURSIVE}, | ||
79 | ) | ||
80 | |||
81 | // Always understood. | ||
82 | |||
83 | {"ro", MS_RDONLY}, // vfs flag | ||
84 | {"rw", ~MS_RDONLY}, // vfs flag | ||
85 | {"remount", MS_REMOUNT}, // action flag | ||
86 | |||
87 | |||
80 | }; | 88 | }; |
81 | 89 | ||
82 | /* Append mount options to string */ | 90 | /* Append mount options to string */ |
@@ -225,9 +233,8 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) | |||
225 | 233 | ||
226 | for(i=0; mount_options[i].flags != MS_REMOUNT; i++) | 234 | for(i=0; mount_options[i].flags != MS_REMOUNT; i++) |
227 | if (mount_options[i].flags > 0) | 235 | if (mount_options[i].flags > 0) |
228 | append_mount_options(&(mp->mnt_opts), | 236 | // Shut up about the darn const. It's not important. I don't care. (char *) |
229 | // Shut up about the darn const. It's not important. I don't care. | 237 | append_mount_options(&(mp->mnt_opts), mount_options[i].name); |
230 | (char *)mount_options[i].name); | ||
231 | 238 | ||
232 | // Remove trailing / (if any) from directory we mounted on | 239 | // Remove trailing / (if any) from directory we mounted on |
233 | 240 | ||
@@ -285,8 +292,8 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
285 | // Look at the file. (Not found isn't a failure for remount, or for | 292 | // Look at the file. (Not found isn't a failure for remount, or for |
286 | // a synthetic filesystem like proc or sysfs.) | 293 | // a synthetic filesystem like proc or sysfs.) |
287 | 294 | ||
288 | if (stat(mp->mnt_fsname, &st)); | 295 | if (!lstat(mp->mnt_fsname, &st) && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE | MS_SHARED | MS_PRIVATE || MS_SLAVE | MS_UNBINDABLE))) |
289 | else if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { | 296 | { |
290 | // Do we need to allocate a loopback device for it? | 297 | // Do we need to allocate a loopback device for it? |
291 | 298 | ||
292 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { | 299 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { |
@@ -456,7 +463,7 @@ int mount_main(int argc, char **argv) | |||
456 | // Open either fstab or mtab | 463 | // Open either fstab or mtab |
457 | 464 | ||
458 | if (parse_mount_options(cmdopts,0) & MS_REMOUNT) | 465 | if (parse_mount_options(cmdopts,0) & MS_REMOUNT) |
459 | fstabname = (char *)bb_path_mtab_file; // Again with the evil const. | 466 | fstabname = bb_path_mtab_file; // Again with the evil const (char *). |
460 | else fstabname="/etc/fstab"; | 467 | else fstabname="/etc/fstab"; |
461 | 468 | ||
462 | if (!(fstab=setmntent(fstabname,"r"))) | 469 | if (!(fstab=setmntent(fstabname,"r"))) |