Annotation of /trunk/busybox/patches/busybox-1.20.2-set-up-RO-loop-device.patch
Parent Directory | Revision Log
Revision 1856 -
(hide annotations)
(download)
Thu Jul 26 09:16:24 2012 UTC (12 years, 2 months ago) by niro
File size: 5127 byte(s)
Thu Jul 26 09:16:24 2012 UTC (12 years, 2 months ago) by niro
File size: 5127 byte(s)
-more upstream patches
1 | niro | 1856 | From 9ee426649006c4a0db7b4784f2ebb96865d4c705 Mon Sep 17 00:00:00 2001 |
2 | From: Denys Vlasenko <vda.linux@googlemail.com> | ||
3 | Date: Thu, 21 Jun 2012 10:08:56 +0000 | ||
4 | Subject: mount: set up RO loop device if mount -o ro. Closes 4784 | ||
5 | |||
6 | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> | ||
7 | --- | ||
8 | diff --git a/util-linux/mount.c b/util-linux/mount.c | ||
9 | index f1da30f..220a4e6 100644 | ||
10 | --- a/util-linux/mount.c | ||
11 | +++ b/util-linux/mount.c | ||
12 | @@ -450,9 +450,9 @@ static void append_mount_options(char **oldopts, const char *newopts) | ||
13 | |||
14 | // Use the mount_options list to parse options into flags. | ||
15 | // Also update list of unrecognized options if unrecognized != NULL | ||
16 | -static long parse_mount_options(char *options, char **unrecognized) | ||
17 | +static unsigned long parse_mount_options(char *options, char **unrecognized) | ||
18 | { | ||
19 | - long flags = MS_SILENT; | ||
20 | + unsigned long flags = MS_SILENT; | ||
21 | |||
22 | // Loop through options | ||
23 | for (;;) { | ||
24 | @@ -466,7 +466,7 @@ static long parse_mount_options(char *options, char **unrecognized) | ||
25 | // Find this option in mount_options | ||
26 | for (i = 0; i < ARRAY_SIZE(mount_options); i++) { | ||
27 | if (strcasecmp(option_str, options) == 0) { | ||
28 | - long fl = mount_options[i]; | ||
29 | + unsigned long fl = mount_options[i]; | ||
30 | if (fl < 0) | ||
31 | flags &= fl; | ||
32 | else | ||
33 | @@ -548,7 +548,7 @@ void delete_block_backed_filesystems(void); | ||
34 | |||
35 | // Perform actual mount of specific filesystem at specific location. | ||
36 | // NB: mp->xxx fields may be trashed on exit | ||
37 | -static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts) | ||
38 | +static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filteropts) | ||
39 | { | ||
40 | int rc = 0; | ||
41 | |||
42 | @@ -1080,7 +1080,7 @@ static void error_msg_rpc(const char *msg) | ||
43 | } | ||
44 | |||
45 | /* NB: mp->xxx fields may be trashed on exit */ | ||
46 | -static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) | ||
47 | +static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts) | ||
48 | { | ||
49 | CLIENT *mclient; | ||
50 | char *hostname; | ||
51 | @@ -1711,7 +1711,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) | ||
52 | * For older kernels, you must build busybox with ENABLE_FEATURE_MOUNT_NFS. | ||
53 | * (However, note that then you lose any chances that NFS over IPv6 would work). | ||
54 | */ | ||
55 | -static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) | ||
56 | +static int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts) | ||
57 | { | ||
58 | len_and_sockaddr *lsa; | ||
59 | char *opts; | ||
60 | @@ -1753,7 +1753,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) | ||
61 | static int singlemount(struct mntent *mp, int ignore_busy) | ||
62 | { | ||
63 | int rc = -1; | ||
64 | - long vfsflags; | ||
65 | + unsigned long vfsflags; | ||
66 | char *loopFile = NULL, *filteropts = NULL; | ||
67 | llist_t *fl = NULL; | ||
68 | struct stat st; | ||
69 | @@ -1854,7 +1854,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | ||
70 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { | ||
71 | loopFile = bb_simplify_path(mp->mnt_fsname); | ||
72 | mp->mnt_fsname = NULL; // will receive malloced loop dev name | ||
73 | - if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ 0) < 0) { | ||
74 | + if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ (vfsflags & MS_RDONLY)) < 0) { | ||
75 | if (errno == EPERM || errno == EACCES) | ||
76 | bb_error_msg(bb_msg_perm_denied_are_you_root); | ||
77 | else | ||
78 | @@ -1992,6 +1992,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
79 | FILE *fstab; | ||
80 | int i, j; | ||
81 | int rc = EXIT_SUCCESS; | ||
82 | + unsigned long cmdopt_flags; | ||
83 | unsigned opt; | ||
84 | struct mntent mtpair[2], *mtcur = mtpair; | ||
85 | IF_NOT_DESKTOP(const int nonroot = 0;) | ||
86 | @@ -2066,16 +2067,16 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
87 | // Past this point, we are handling either "mount -a [opts]" | ||
88 | // or "mount [opts] single_param" | ||
89 | |||
90 | - i = parse_mount_options(cmdopts, NULL); // FIXME: should be "long", not "int" | ||
91 | - if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags | ||
92 | + cmdopt_flags = parse_mount_options(cmdopts, NULL); | ||
93 | + if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags | ||
94 | bb_error_msg_and_die(bb_msg_you_must_be_root); | ||
95 | |||
96 | // If we have a shared subtree flag, don't worry about fstab or mtab. | ||
97 | if (ENABLE_FEATURE_MOUNT_FLAGS | ||
98 | - && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) | ||
99 | + && (cmdopt_flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) | ||
100 | ) { | ||
101 | // verbose_mount(source, target, type, flags, data) | ||
102 | - rc = verbose_mount("", argv[0], "", i, ""); | ||
103 | + rc = verbose_mount("", argv[0], "", cmdopt_flags, ""); | ||
104 | if (rc) | ||
105 | bb_simple_perror_msg_and_die(argv[0]); | ||
106 | return rc; | ||
107 | @@ -2083,7 +2084,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
108 | |||
109 | // Open either fstab or mtab | ||
110 | fstabname = "/etc/fstab"; | ||
111 | - if (i & MS_REMOUNT) { | ||
112 | + if (cmdopt_flags & MS_REMOUNT) { | ||
113 | // WARNING. I am not sure this matches util-linux's | ||
114 | // behavior. It's possible util-linux does not | ||
115 | // take -o opts from mtab (takes only mount source). | ||
116 | @@ -2182,7 +2183,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | ||
117 | // End of fstab/mtab is reached. | ||
118 | // Were we looking for something specific? | ||
119 | if (argv[0]) { // yes | ||
120 | - long l; | ||
121 | + unsigned long l; | ||
122 | |||
123 | // If we didn't find anything, complain | ||
124 | if (!mtcur->mnt_fsname) | ||
125 | -- | ||
126 | cgit v0.9.0.1-2-gef13 |