diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 09:33:45 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 09:33:45 +0000 |
commit | d0a071a5281f8ba4b291f0c3beb74bee1f8df6a3 (patch) | |
tree | 37e443b155eb66fed37e889828fa60023c84010f | |
parent | b44c790e41e281965955a83408f35ea53ecdb3d2 (diff) | |
download | busybox-w32-d0a071a5281f8ba4b291f0c3beb74bee1f8df6a3.tar.gz busybox-w32-d0a071a5281f8ba4b291f0c3beb74bee1f8df6a3.tar.bz2 busybox-w32-d0a071a5281f8ba4b291f0c3beb74bee1f8df6a3.zip |
brctl: eliminate stray data object
brctl: use constant fd to reduce parameter passing
runsvdir: do not use data/bss
od: reuse bb_argv_dash
last: do not go into endless loop on read error
mount: make it not fail scripts/find_bad_common_bufsiz check
dc: add INIT_G() (no-op for dc, but we want uniform usage of "G trick")
function old new delta
runsvdir_main 1646 1672 +26
set_pgrp 1 - -1
exitsoon 1 - -1
check 679 678 -1
svnum 4 - -4
svdir 4 - -4
sv 4 - -4
stamplog 4 - -4
rploglen 4 - -4
rplog 4 - -4
mount_main 995 988 -7
static.default_file_list 8 - -8
pfd 8 - -8
logpipe 8 - -8
static.info 20 - -20
brctl_main 767 739 -28
------------------------------------------------------------------------------
(add/remove: 0/12 grow/shrink: 1/3 up/down: 26/-106) Total: -80 bytes
text data bss dec hex filename
793327 662 7412 801401 c3a79 busybox_old
793329 641 7372 801342 c3a3e busybox_unstripped
-rw-r--r-- | coreutils/od_bloaty.c | 3 | ||||
-rw-r--r-- | miscutils/dc.c | 4 | ||||
-rw-r--r-- | miscutils/last.c | 17 | ||||
-rw-r--r-- | networking/brctl.c | 69 | ||||
-rw-r--r-- | runit/runsvdir.c | 41 | ||||
-rw-r--r-- | util-linux/mount.c | 9 |
6 files changed, 85 insertions, 58 deletions
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index 4526f0ede..dce2349a3 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -1177,7 +1177,6 @@ dump_strings(off_t address, off_t end_offset) | |||
1177 | int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1177 | int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1178 | int od_main(int argc, char **argv) | 1178 | int od_main(int argc, char **argv) |
1179 | { | 1179 | { |
1180 | static char const *const default_file_list[] = { "-", NULL }; | ||
1181 | static const struct suffix_mult bkm[] = { | 1180 | static const struct suffix_mult bkm[] = { |
1182 | { "b", 512 }, | 1181 | { "b", 512 }, |
1183 | { "k", 1024 }, | 1182 | { "k", 1024 }, |
@@ -1383,7 +1382,7 @@ int od_main(int argc, char **argv) | |||
1383 | /* If no files were listed on the command line, | 1382 | /* If no files were listed on the command line, |
1384 | set the global pointer FILE_LIST so that it | 1383 | set the global pointer FILE_LIST so that it |
1385 | references the null-terminated list of one name: "-". */ | 1384 | references the null-terminated list of one name: "-". */ |
1386 | file_list = default_file_list; | 1385 | file_list = bb_argv_dash; |
1387 | if (argc > 0) { | 1386 | if (argc > 0) { |
1388 | /* Set the global pointer FILE_LIST so that it | 1387 | /* Set the global pointer FILE_LIST so that it |
1389 | references the first file-argument on the command-line. */ | 1388 | references the first file-argument on the command-line. */ |
diff --git a/miscutils/dc.c b/miscutils/dc.c index 68ecd8a3f..612937556 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -19,6 +19,8 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof( | |||
19 | #define pointer (G.pointer ) | 19 | #define pointer (G.pointer ) |
20 | #define base (G.base ) | 20 | #define base (G.base ) |
21 | #define stack (G.stack ) | 21 | #define stack (G.stack ) |
22 | #define INIT_G() do { \ | ||
23 | } while (0) | ||
22 | 24 | ||
23 | 25 | ||
24 | static void push(double a) | 26 | static void push(double a) |
@@ -194,6 +196,8 @@ static char *get_token(char **buffer) | |||
194 | int dc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 196 | int dc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
195 | int dc_main(int argc ATTRIBUTE_UNUSED, char **argv) | 197 | int dc_main(int argc ATTRIBUTE_UNUSED, char **argv) |
196 | { | 198 | { |
199 | INIT_G(); | ||
200 | |||
197 | argv++; | 201 | argv++; |
198 | if (!argv[0]) { | 202 | if (!argv[0]) { |
199 | /* take stuff from stdin if no args are given */ | 203 | /* take stuff from stdin if no args are given */ |
diff --git a/miscutils/last.c b/miscutils/last.c index f46d4ca0c..f823a1385 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
@@ -39,9 +39,8 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) | |||
39 | file = xopen(bb_path_wtmp_file, O_RDONLY); | 39 | file = xopen(bb_path_wtmp_file, O_RDONLY); |
40 | 40 | ||
41 | printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME"); | 41 | printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME"); |
42 | while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) { | 42 | while ((n = full_read(file, &ut, sizeof(ut))) > 0) { |
43 | 43 | if (n != sizeof(ut)) { | |
44 | if (n != sizeof(struct utmp)) { | ||
45 | bb_perror_msg_and_die("short read"); | 44 | bb_perror_msg_and_die("short read"); |
46 | } | 45 | } |
47 | 46 | ||
@@ -53,16 +52,14 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) | |||
53 | else if (strncmp(ut.ut_user, "runlevel", 7) == 0) | 52 | else if (strncmp(ut.ut_user, "runlevel", 7) == 0) |
54 | ut.ut_type = RUN_LVL; | 53 | ut.ut_type = RUN_LVL; |
55 | } else { | 54 | } else { |
56 | if (!ut.ut_name[0] || strcmp(ut.ut_name, "LOGIN") == 0 || | 55 | if (ut.ut_name[0] == '\0' || strcmp(ut.ut_name, "LOGIN") == 0) { |
57 | ut.ut_name[0] == 0) | ||
58 | { | ||
59 | /* Don't bother. This means we can't find how long | 56 | /* Don't bother. This means we can't find how long |
60 | * someone was logged in for. Oh well. */ | 57 | * someone was logged in for. Oh well. */ |
61 | continue; | 58 | continue; |
62 | } | 59 | } |
63 | if (ut.ut_type != DEAD_PROCESS && | 60 | if (ut.ut_type != DEAD_PROCESS |
64 | ut.ut_name[0] && ut.ut_line[0]) | 61 | && ut.ut_name[0] && ut.ut_line[0] |
65 | { | 62 | ) { |
66 | ut.ut_type = USER_PROCESS; | 63 | ut.ut_type = USER_PROCESS; |
67 | } | 64 | } |
68 | if (strcmp(ut.ut_name, "date") == 0) { | 65 | if (strcmp(ut.ut_name, "date") == 0) { |
@@ -71,7 +68,7 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) | |||
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 | ||
74 | if (ut.ut_type!=USER_PROCESS) { | 71 | if (ut.ut_type != USER_PROCESS) { |
75 | switch (ut.ut_type) { | 72 | switch (ut.ut_type) { |
76 | case OLD_TIME: | 73 | case OLD_TIME: |
77 | case NEW_TIME: | 74 | case NEW_TIME: |
diff --git a/networking/brctl.c b/networking/brctl.c index bbd14c471..2bb03dd82 100644 --- a/networking/brctl.c +++ b/networking/brctl.c | |||
@@ -33,13 +33,15 @@ | |||
33 | 33 | ||
34 | #if ENABLE_FEATURE_BRCTL_FANCY | 34 | #if ENABLE_FEATURE_BRCTL_FANCY |
35 | #include <linux/if_bridge.h> | 35 | #include <linux/if_bridge.h> |
36 | |||
36 | /* FIXME: These 4 funcs are not really clean and could be improved */ | 37 | /* FIXME: These 4 funcs are not really clean and could be improved */ |
37 | static inline ALWAYS_INLINE void strtotimeval(struct timeval *tv, | 38 | static ALWAYS_INLINE void strtotimeval(struct timeval *tv, |
38 | const char *time_str) | 39 | const char *time_str) |
39 | { | 40 | { |
40 | double secs; | 41 | double secs; |
41 | #if BRCTL_USE_INTERNAL | 42 | #if BRCTL_USE_INTERNAL |
42 | if (!(secs = /*bb_*/strtod(time_str, NULL))) | 43 | secs = /*bb_*/strtod(time_str, NULL); |
44 | if (!secs) | ||
43 | #else | 45 | #else |
44 | if (sscanf(time_str, "%lf", &secs) != 1) | 46 | if (sscanf(time_str, "%lf", &secs) != 1) |
45 | #endif | 47 | #endif |
@@ -48,7 +50,7 @@ static inline ALWAYS_INLINE void strtotimeval(struct timeval *tv, | |||
48 | tv->tv_usec = 1000000 * (secs - tv->tv_sec); | 50 | tv->tv_usec = 1000000 * (secs - tv->tv_sec); |
49 | } | 51 | } |
50 | 52 | ||
51 | static inline ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv) | 53 | static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv) |
52 | { | 54 | { |
53 | unsigned long long jif; | 55 | unsigned long long jif; |
54 | 56 | ||
@@ -56,7 +58,7 @@ static inline ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval * | |||
56 | 58 | ||
57 | return jif/10000; | 59 | return jif/10000; |
58 | } | 60 | } |
59 | # if 00 | 61 | # if 0 |
60 | static void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies) | 62 | static void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies) |
61 | { | 63 | { |
62 | unsigned long long tvusec; | 64 | unsigned long long tvusec; |
@@ -74,7 +76,7 @@ static unsigned long str_to_jiffies(const char *time_str) | |||
74 | } | 76 | } |
75 | 77 | ||
76 | static void arm_ioctl(unsigned long *args, | 78 | static void arm_ioctl(unsigned long *args, |
77 | unsigned long arg0, unsigned long arg1, unsigned long arg2) | 79 | unsigned long arg0, unsigned long arg1, unsigned long arg2) |
78 | { | 80 | { |
79 | args[0] = arg0; | 81 | args[0] = arg0; |
80 | args[1] = arg1; | 82 | args[1] = arg1; |
@@ -84,10 +86,9 @@ static void arm_ioctl(unsigned long *args, | |||
84 | #endif | 86 | #endif |
85 | 87 | ||
86 | 88 | ||
87 | int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) MAIN_EXTERNALLY_VISIBLE; | 89 | int brctl_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
88 | int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | 90 | int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) |
89 | { | 91 | { |
90 | int fd; | ||
91 | static const char keywords[] ALIGN1 = | 92 | static const char keywords[] ALIGN1 = |
92 | "addbr\0" "delbr\0" "addif\0" "delif\0" | 93 | "addbr\0" "delbr\0" "addif\0" "delif\0" |
93 | USE_FEATURE_BRCTL_FANCY( | 94 | USE_FEATURE_BRCTL_FANCY( |
@@ -96,16 +97,19 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
96 | "setpathcost\0" "setportprio\0" "setbridgeprio\0" | 97 | "setpathcost\0" "setportprio\0" "setbridgeprio\0" |
97 | ) | 98 | ) |
98 | USE_FEATURE_BRCTL_SHOW("showmacs\0" "show\0"); | 99 | USE_FEATURE_BRCTL_SHOW("showmacs\0" "show\0"); |
100 | |||
99 | enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif | 101 | enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif |
100 | USE_FEATURE_BRCTL_FANCY(, | 102 | USE_FEATURE_BRCTL_FANCY(, |
101 | ARG_stp, | 103 | ARG_stp, |
102 | ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage, | 104 | ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage, |
103 | ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio | 105 | ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio |
104 | ) | 106 | ) |
105 | USE_FEATURE_BRCTL_SHOW(, ARG_showmacs, ARG_show) }; | 107 | USE_FEATURE_BRCTL_SHOW(, ARG_showmacs, ARG_show) |
108 | }; | ||
109 | |||
110 | int fd; | ||
106 | smallint key; | 111 | smallint key; |
107 | struct ifreq ifr; | 112 | struct ifreq ifr; |
108 | static char info[] = "bridge %s\0 iface %s"; | ||
109 | char *br, *brif; | 113 | char *br, *brif; |
110 | #if ENABLE_FEATURE_BRCTL_FANCY | 114 | #if ENABLE_FEATURE_BRCTL_FANCY |
111 | unsigned long args[4] = {0, 0, 0, 0}; | 115 | unsigned long args[4] = {0, 0, 0, 0}; |
@@ -125,25 +129,26 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
125 | } | 129 | } |
126 | #endif | 130 | #endif |
127 | fd = xsocket(AF_INET, SOCK_STREAM, 0); | 131 | fd = xsocket(AF_INET, SOCK_STREAM, 0); |
128 | br = *(argv++); | 132 | br = *argv++; |
129 | 133 | ||
130 | if (key == ARG_addbr || key == ARG_delbr) { /* addbr or delbr */ | 134 | if (key == ARG_addbr || key == ARG_delbr) { /* addbr or delbr */ |
131 | ioctl_or_perror_and_die(fd, | 135 | ioctl_or_perror_and_die(fd, |
132 | key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR, | 136 | key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR, |
133 | br, info, br); | 137 | br, "bridge %s", br); |
134 | goto done; | 138 | goto done; |
135 | } | 139 | } |
136 | if (!*argv) /* all but 'show' need at least one argument */ | 140 | if (!*argv) /* all but 'show' need at least one argument */ |
137 | bb_show_usage(); | 141 | bb_show_usage(); |
138 | safe_strncpy(ifr.ifr_name, br, IFNAMSIZ); | 142 | safe_strncpy(ifr.ifr_name, br, IFNAMSIZ); |
139 | if (key == ARG_addif || key == ARG_delif) { /* addif or delif */ | 143 | if (key == ARG_addif || key == ARG_delif) { /* addif or delif */ |
140 | brif = *(argv++); | 144 | brif = *argv++; |
141 | if (!(ifr.ifr_ifindex = if_nametoindex(brif))) { | 145 | ifr.ifr_ifindex = if_nametoindex(brif); |
142 | bb_perror_msg_and_die(info+11, brif); | 146 | if (!ifr.ifr_ifindex) { |
147 | bb_perror_msg_and_die("iface %s", brif); | ||
143 | } | 148 | } |
144 | ioctl_or_perror_and_die(fd, | 149 | ioctl_or_perror_and_die(fd, |
145 | key == ARG_addif ? SIOCBRADDIF : SIOCBRDELIF, | 150 | key == ARG_addif ? SIOCBRADDIF : SIOCBRDELIF, |
146 | &ifr, info, br); | 151 | &ifr, "bridge %s", br); |
147 | goto done; | 152 | goto done; |
148 | } | 153 | } |
149 | #if ENABLE_FEATURE_BRCTL_FANCY | 154 | #if ENABLE_FEATURE_BRCTL_FANCY |
@@ -156,11 +161,10 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
156 | } | 161 | } |
157 | if ((unsigned)(key - ARG_stp) < 5) { /* time related ops */ | 162 | if ((unsigned)(key - ARG_stp) < 5) { /* time related ops */ |
158 | unsigned long op = (key == ARG_setageing) ? BRCTL_SET_AGEING_TIME : | 163 | unsigned long op = (key == ARG_setageing) ? BRCTL_SET_AGEING_TIME : |
159 | (key == ARG_setfd) ? BRCTL_SET_BRIDGE_FORWARD_DELAY: | 164 | (key == ARG_setfd) ? BRCTL_SET_BRIDGE_FORWARD_DELAY : |
160 | (key == ARG_sethello) ? BRCTL_SET_BRIDGE_HELLO_TIME: | 165 | (key == ARG_sethello) ? BRCTL_SET_BRIDGE_HELLO_TIME : |
161 | (key == ARG_setmaxage) ? BRCTL_SET_BRIDGE_MAX_AGE : | 166 | /*key == ARG_setmaxage*/ BRCTL_SET_BRIDGE_MAX_AGE; |
162 | -1/* will never be used */; | 167 | arm_ioctl(args, op, str_to_jiffies(*argv), 0); |
163 | arm_ioctl(args, op, str_to_jiffies (*argv), 0); | ||
164 | goto fire; | 168 | goto fire; |
165 | } | 169 | } |
166 | port = -1; | 170 | port = -1; |
@@ -168,25 +172,28 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
168 | int ifidx[MAX_PORTS]; | 172 | int ifidx[MAX_PORTS]; |
169 | unsigned i; | 173 | unsigned i; |
170 | 174 | ||
171 | if (!(port = if_nametoindex(*argv))) | 175 | port = if_nametoindex(*argv); |
176 | if (!port) | ||
172 | bb_error_msg_and_die(bb_msg_invalid_arg, *argv, "port"); | 177 | bb_error_msg_and_die(bb_msg_invalid_arg, *argv, "port"); |
173 | argv++; | 178 | argv++; |
174 | memset(ifidx, 0, sizeof ifidx); | 179 | memset(ifidx, 0, sizeof ifidx); |
175 | arm_ioctl(args, BRCTL_GET_PORT_LIST, (unsigned long)ifidx, | 180 | arm_ioctl(args, BRCTL_GET_PORT_LIST, (unsigned long)ifidx, |
176 | MAX_PORTS); | 181 | MAX_PORTS); |
177 | xioctl(fd, SIOCDEVPRIVATE, &ifr); | 182 | xioctl(fd, SIOCDEVPRIVATE, &ifr); |
178 | for (i = 0; i < MAX_PORTS; i++) | 183 | for (i = 0; i < MAX_PORTS; i++) { |
179 | if (ifidx[i] == port) { | 184 | if (ifidx[i] == port) { |
180 | port = i; | 185 | port = i; |
181 | break; | 186 | break; |
182 | } | 187 | } |
188 | } | ||
183 | } | 189 | } |
184 | if (key == ARG_setpathcost | 190 | if (key == ARG_setpathcost |
185 | || key == ARG_setportprio || key == ARG_setbridgeprio) { | 191 | || key == ARG_setportprio |
192 | || key == ARG_setbridgeprio | ||
193 | ) { | ||
186 | unsigned long op = (key == ARG_setpathcost) ? BRCTL_SET_PATH_COST : | 194 | unsigned long op = (key == ARG_setpathcost) ? BRCTL_SET_PATH_COST : |
187 | (key == ARG_setportprio) ? BRCTL_SET_PORT_PRIORITY : | 195 | (key == ARG_setportprio) ? BRCTL_SET_PORT_PRIORITY : |
188 | (key == ARG_setbridgeprio) ? BRCTL_SET_BRIDGE_PRIORITY : | 196 | /*key == ARG_setbridgeprio*/ BRCTL_SET_BRIDGE_PRIORITY; |
189 | -1/* will never be used */; | ||
190 | unsigned long arg1 = port; | 197 | unsigned long arg1 = port; |
191 | unsigned long arg2; | 198 | unsigned long arg2; |
192 | # if BRCTL_USE_INTERNAL | 199 | # if BRCTL_USE_INTERNAL |
@@ -194,7 +201,7 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
194 | # else | 201 | # else |
195 | if (sscanf(*argv, "%i", &tmp) != 1) | 202 | if (sscanf(*argv, "%i", &tmp) != 1) |
196 | bb_error_msg_and_die(bb_msg_invalid_arg, *argv, | 203 | bb_error_msg_and_die(bb_msg_invalid_arg, *argv, |
197 | key == ARG_setpathcost ? "cost" : "prio"); | 204 | key == ARG_setpathcost ? "cost" : "prio"); |
198 | # endif | 205 | # endif |
199 | if (key == ARG_setbridgeprio) { | 206 | if (key == ARG_setbridgeprio) { |
200 | arg1 = tmp; | 207 | arg1 = tmp; |
@@ -212,6 +219,6 @@ int brctl_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
212 | if (ENABLE_FEATURE_CLEAN_UP) | 219 | if (ENABLE_FEATURE_CLEAN_UP) |
213 | close(fd); | 220 | close(fd); |
214 | } | 221 | } |
215 | USE_FEATURE_BRCTL_SHOW(out:) | 222 | USE_FEATURE_BRCTL_SHOW(out:) |
216 | return EXIT_SUCCESS; | 223 | return EXIT_SUCCESS; |
217 | } | 224 | } |
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index bca5c901c..32e4764d1 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -42,17 +42,34 @@ struct service { | |||
42 | smallint isgone; | 42 | smallint isgone; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | static struct service *sv; | 45 | struct globals { |
46 | static char *svdir; | 46 | struct service *sv; |
47 | static int svnum; | 47 | char *svdir; |
48 | static char *rplog; | 48 | char *rplog; |
49 | static int rploglen; | 49 | int svnum; |
50 | static struct fd_pair logpipe; | 50 | int rploglen; |
51 | static struct pollfd pfd[1]; | 51 | struct fd_pair logpipe; |
52 | static unsigned stamplog; | 52 | struct pollfd pfd[1]; |
53 | static smallint check = 1; | 53 | unsigned stamplog; |
54 | static smallint exitsoon; | 54 | smallint check; /* = 1; */ |
55 | static smallint set_pgrp; | 55 | smallint exitsoon; |
56 | smallint set_pgrp; | ||
57 | }; | ||
58 | #define G (*(struct globals*)&bb_common_bufsiz1) | ||
59 | #define sv (G.sv ) | ||
60 | #define svdir (G.svdir ) | ||
61 | #define rplog (G.rplog ) | ||
62 | #define svnum (G.svnum ) | ||
63 | #define rploglen (G.rploglen ) | ||
64 | #define logpipe (G.logpipe ) | ||
65 | #define pfd (G.pfd ) | ||
66 | #define stamplog (G.stamplog ) | ||
67 | #define check (G.check ) | ||
68 | #define exitsoon (G.exitsoon ) | ||
69 | #define set_pgrp (G.set_pgrp ) | ||
70 | #define INIT_G() do { \ | ||
71 | check = 1; \ | ||
72 | } while (0) | ||
56 | 73 | ||
57 | static void fatal2_cannot(const char *m1, const char *m2) | 74 | static void fatal2_cannot(const char *m1, const char *m2) |
58 | { | 75 | { |
@@ -222,6 +239,8 @@ int runsvdir_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
222 | char ch; | 239 | char ch; |
223 | int i; | 240 | int i; |
224 | 241 | ||
242 | INIT_G(); | ||
243 | |||
225 | argv++; | 244 | argv++; |
226 | if (!*argv) | 245 | if (!*argv) |
227 | bb_show_usage(); | 246 | bb_show_usage(); |
diff --git a/util-linux/mount.c b/util-linux/mount.c index a0e6cda73..d4a320756 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -214,9 +214,10 @@ struct globals { | |||
214 | unsigned verbose; | 214 | unsigned verbose; |
215 | #endif | 215 | #endif |
216 | llist_t *fslist; | 216 | llist_t *fslist; |
217 | char getmntent_buf[sizeof(bb_common_bufsiz1) - 8*3]; | 217 | char getmntent_buf[1]; |
218 | 218 | ||
219 | }; | 219 | }; |
220 | enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) }; | ||
220 | #define G (*(struct globals*)&bb_common_bufsiz1) | 221 | #define G (*(struct globals*)&bb_common_bufsiz1) |
221 | #define nfs_mount_version (G.nfs_mount_version) | 222 | #define nfs_mount_version (G.nfs_mount_version) |
222 | #if ENABLE_FEATURE_MOUNT_VERBOSE | 223 | #if ENABLE_FEATURE_MOUNT_VERBOSE |
@@ -1775,7 +1776,7 @@ int mount_main(int argc, char **argv) | |||
1775 | if (!mountTable) bb_error_msg_and_die("no %s", bb_path_mtab_file); | 1776 | if (!mountTable) bb_error_msg_and_die("no %s", bb_path_mtab_file); |
1776 | 1777 | ||
1777 | while (getmntent_r(mountTable, &mtpair[0], getmntent_buf, | 1778 | while (getmntent_r(mountTable, &mtpair[0], getmntent_buf, |
1778 | sizeof(getmntent_buf))) | 1779 | GETMNTENT_BUFSIZE)) |
1779 | { | 1780 | { |
1780 | // Don't show rootfs. FIXME: why?? | 1781 | // Don't show rootfs. FIXME: why?? |
1781 | // util-linux 2.12a happily shows rootfs... | 1782 | // util-linux 2.12a happily shows rootfs... |
@@ -1842,8 +1843,8 @@ int mount_main(int argc, char **argv) | |||
1842 | // Get next fstab entry | 1843 | // Get next fstab entry |
1843 | 1844 | ||
1844 | if (!getmntent_r(fstab, mtcur, getmntent_buf | 1845 | if (!getmntent_r(fstab, mtcur, getmntent_buf |
1845 | + (mtcur==mtpair ? sizeof(getmntent_buf)/2 : 0), | 1846 | + (mtcur==mtpair ? GETMNTENT_BUFSIZE/2 : 0), |
1846 | sizeof(getmntent_buf)/2)) | 1847 | GETMNTENT_BUFSIZE/2)) |
1847 | { | 1848 | { |
1848 | // Were we looking for something specific? | 1849 | // Were we looking for something specific? |
1849 | 1850 | ||