aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorTim Riker <tim@rikers.org>2006-01-25 00:08:53 +0000
committerTim Riker <tim@rikers.org>2006-01-25 00:08:53 +0000
commitc1ef7bdd8d002ae0889efcf883d0e1b7faa938d4 (patch)
tree5f329b7d0c7f20ecced0dc7581a9ba6dc720d965 /util-linux
parentf64ff682a3d58dbb627e760e6fe1ec21d9ccdf61 (diff)
downloadbusybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.gz
busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.bz2
busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.zip
just whitespace
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/Config.in4
-rw-r--r--util-linux/fbset.c136
-rw-r--r--util-linux/fdformat.c8
-rw-r--r--util-linux/getopt.c456
-rw-r--r--util-linux/hwclock.c10
-rw-r--r--util-linux/ipcrm.c10
-rw-r--r--util-linux/ipcs.c44
-rw-r--r--util-linux/losetup.c16
-rw-r--r--util-linux/mdev.c32
-rw-r--r--util-linux/mount.c16
-rw-r--r--util-linux/nfsmount.c10
-rw-r--r--util-linux/pivot_root.c2
-rw-r--r--util-linux/rdate.c10
-rw-r--r--util-linux/readprofile.c4
-rw-r--r--util-linux/switch_root.c18
15 files changed, 388 insertions, 388 deletions
diff --git a/util-linux/Config.in b/util-linux/Config.in
index bf3e13b2a..27410bf10 100644
--- a/util-linux/Config.in
+++ b/util-linux/Config.in
@@ -214,7 +214,7 @@ config CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS
214 depends on CONFIG_HWCLOCK 214 depends on CONFIG_HWCLOCK
215 help 215 help
216 Starting with FHS 2.3, the adjtime state file is supposed to exist 216 Starting with FHS 2.3, the adjtime state file is supposed to exist
217 at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish 217 at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish
218 to use the FHS behavior, answer Y here, otherwise answer N for the 218 to use the FHS behavior, answer Y here, otherwise answer N for the
219 classic /etc/adjtime path. 219 classic /etc/adjtime path.
220 220
@@ -406,7 +406,7 @@ config CONFIG_FEATURE_MOUNT_LOOP
406 command will detect you are trying to mount a file instead of a block 406 command will detect you are trying to mount a file instead of a block
407 device, and transparently associate the file with a loopback device. 407 device, and transparently associate the file with a loopback device.
408 The umount command will also free that loopback device. 408 The umount command will also free that loopback device.
409 409
410 You can still use the 'losetup' utility (to manually associate files 410 You can still use the 'losetup' utility (to manually associate files
411 with loop devices) if you need to do something advanced, such as 411 with loop devices) if you need to do something advanced, such as
412 specify an offset or cryptographic options to the loopback device. 412 specify an offset or cryptographic options to the loopback device.
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 83bf309a3..b1118311f 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -52,7 +52,7 @@ enum {
52 CMD_VSYNC = 7, 52 CMD_VSYNC = 7,
53 CMD_LACED = 8, 53 CMD_LACED = 8,
54 CMD_DOUBLE = 9, 54 CMD_DOUBLE = 9,
55/* CMD_XCOMPAT = 10, */ 55/* CMD_XCOMPAT = 10, */
56 CMD_ALL = 11, 56 CMD_ALL = 11,
57 CMD_INFO = 12, 57 CMD_INFO = 12,
58 CMD_CHANGE = 13, 58 CMD_CHANGE = 13,
@@ -207,70 +207,70 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
207 while (!feof(f)) { 207 while (!feof(f)) {
208 fgets(buf, sizeof(buf), f); 208 fgets(buf, sizeof(buf), f);
209 209
210 if ((p = strstr(buf, "geometry "))) { 210 if ((p = strstr(buf, "geometry "))) {
211 p += 9; 211 p += 9;
212 212
213 sscanf(p, "%d %d %d %d %d", 213 sscanf(p, "%d %d %d %d %d",
214 &(base->xres), &(base->yres), 214 &(base->xres), &(base->yres),
215 &(base->xres_virtual), &(base->yres_virtual), 215 &(base->xres_virtual), &(base->yres_virtual),
216 &(base->bits_per_pixel)); 216 &(base->bits_per_pixel));
217 } else if ((p = strstr(buf, "timings "))) { 217 } else if ((p = strstr(buf, "timings "))) {
218 p += 8; 218 p += 8;
219 219
220 sscanf(p, "%d %d %d %d %d %d %d", 220 sscanf(p, "%d %d %d %d %d %d %d",
221 &(base->pixclock), 221 &(base->pixclock),
222 &(base->left_margin), &(base->right_margin), 222 &(base->left_margin), &(base->right_margin),
223 &(base->upper_margin), &(base->lower_margin), 223 &(base->upper_margin), &(base->lower_margin),
224 &(base->hsync_len), &(base->vsync_len)); 224 &(base->hsync_len), &(base->vsync_len));
225 } else if ((p = strstr(buf, "laced "))) { 225 } else if ((p = strstr(buf, "laced "))) {
226 p += 6; 226 p += 6;
227 227
228 if (strstr(buf, "false")) { 228 if (strstr(buf, "false")) {
229 base->vmode &= ~FB_VMODE_INTERLACED; 229 base->vmode &= ~FB_VMODE_INTERLACED;
230 } else { 230 } else {
231 base->vmode |= FB_VMODE_INTERLACED; 231 base->vmode |= FB_VMODE_INTERLACED;
232 } 232 }
233 } else if ((p = strstr(buf, "double "))) { 233 } else if ((p = strstr(buf, "double "))) {
234 p += 7; 234 p += 7;
235 235
236 if (strstr(buf, "false")) { 236 if (strstr(buf, "false")) {
237 base->vmode &= ~FB_VMODE_DOUBLE; 237 base->vmode &= ~FB_VMODE_DOUBLE;
238 } else { 238 } else {
239 base->vmode |= FB_VMODE_DOUBLE; 239 base->vmode |= FB_VMODE_DOUBLE;
240 } 240 }
241 } else if ((p = strstr(buf, "vsync "))) { 241 } else if ((p = strstr(buf, "vsync "))) {
242 p += 6; 242 p += 6;
243 243
244 if (strstr(buf, "low")) { 244 if (strstr(buf, "low")) {
245 base->sync &= ~FB_SYNC_VERT_HIGH_ACT; 245 base->sync &= ~FB_SYNC_VERT_HIGH_ACT;
246 } else { 246 } else {
247 base->sync |= FB_SYNC_VERT_HIGH_ACT; 247 base->sync |= FB_SYNC_VERT_HIGH_ACT;
248 } 248 }
249 } else if ((p = strstr(buf, "hsync "))) { 249 } else if ((p = strstr(buf, "hsync "))) {
250 p += 6; 250 p += 6;
251 251
252 if (strstr(buf, "low")) { 252 if (strstr(buf, "low")) {
253 base->sync &= ~FB_SYNC_HOR_HIGH_ACT; 253 base->sync &= ~FB_SYNC_HOR_HIGH_ACT;
254 } else { 254 } else {
255 base->sync |= FB_SYNC_HOR_HIGH_ACT; 255 base->sync |= FB_SYNC_HOR_HIGH_ACT;
256 } 256 }
257 } else if ((p = strstr(buf, "csync "))) { 257 } else if ((p = strstr(buf, "csync "))) {
258 p += 6; 258 p += 6;
259 259
260 if (strstr(buf, "low")) { 260 if (strstr(buf, "low")) {
261 base->sync &= ~FB_SYNC_COMP_HIGH_ACT; 261 base->sync &= ~FB_SYNC_COMP_HIGH_ACT;
262 } else { 262 } else {
263 base->sync |= FB_SYNC_COMP_HIGH_ACT; 263 base->sync |= FB_SYNC_COMP_HIGH_ACT;
264 } 264 }
265 } else if ((p = strstr(buf, "extsync "))) { 265 } else if ((p = strstr(buf, "extsync "))) {
266 p += 8; 266 p += 8;
267 267
268 if (strstr(buf, "false")) { 268 if (strstr(buf, "false")) {
269 base->sync &= ~FB_SYNC_EXT; 269 base->sync &= ~FB_SYNC_EXT;
270 } else { 270 } else {
271 base->sync |= FB_SYNC_EXT; 271 base->sync |= FB_SYNC_EXT;
272 } 272 }
273 } 273 }
274 274
275 if (strstr(buf, "endmode")) 275 if (strstr(buf, "endmode"))
276 return 1; 276 return 1;
@@ -374,9 +374,9 @@ extern int fbset_main(int argc, char **argv)
374 varset.hsync_len = strtoul(argv[6], 0, 0); 374 varset.hsync_len = strtoul(argv[6], 0, 0);
375 varset.vsync_len = strtoul(argv[7], 0, 0); 375 varset.vsync_len = strtoul(argv[7], 0, 0);
376 break; 376 break;
377 case CMD_CHANGE: 377 case CMD_CHANGE:
378 g_options |= OPT_CHANGE; 378 g_options |= OPT_CHANGE;
379 break; 379 break;
380#ifdef CONFIG_FEATURE_FBSET_FANCY 380#ifdef CONFIG_FEATURE_FBSET_FANCY
381 case CMD_XRES: 381 case CMD_XRES:
382 varset.xres = strtoul(argv[1], 0, 0); 382 varset.xres = strtoul(argv[1], 0, 0);
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c
index 768105159..e7dd943bb 100644
--- a/util-linux/fdformat.c
+++ b/util-linux/fdformat.c
@@ -134,7 +134,7 @@ int fdformat_main(int argc,char **argv)
134 if((read_bytes = safe_read(fd,data,n))!= n ) { 134 if((read_bytes = safe_read(fd,data,n))!= n ) {
135 if(read_bytes < 0) { 135 if(read_bytes < 0) {
136 bb_perror_msg("Read: "); 136 bb_perror_msg("Read: ");
137 } 137 }
138 bb_error_msg_and_die("Problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes); 138 bb_error_msg_and_die("Problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes);
139 } 139 }
140 /* Check backwards so we don't need a counter */ 140 /* Check backwards so we don't need a counter */
@@ -147,14 +147,14 @@ int fdformat_main(int argc,char **argv)
147 /* There is no point in freeing blocks at the end of a program, because 147 /* There is no point in freeing blocks at the end of a program, because
148 all of the program's space is given back to the system when the process 148 all of the program's space is given back to the system when the process
149 terminates.*/ 149 terminates.*/
150 150
151 if (ENABLE_FEATURE_CLEAN_UP) free(data); 151 if (ENABLE_FEATURE_CLEAN_UP) free(data);
152 152
153 print_and_flush("done\n", NULL); 153 print_and_flush("done\n", NULL);
154 } 154 }
155 155
156 if (ENABLE_FEATURE_CLEAN_UP) close(fd); 156 if (ENABLE_FEATURE_CLEAN_UP) close(fd);
157 157
158 /* Don't bother closing. Exit does 158 /* Don't bother closing. Exit does
159 * that, so we can save a few bytes */ 159 * that, so we can save a few bytes */
160 return EXIT_SUCCESS; 160 return EXIT_SUCCESS;
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index fc3b9f97e..16dcbbca0 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -71,7 +71,7 @@ static int alternative; /* 0 is getopt_long, 1 is getopt_long_only */
71/* Function prototypes */ 71/* Function prototypes */
72static const char *normalize(const char *arg); 72static const char *normalize(const char *arg);
73static int generate_output(char * argv[],int argc,const char *optstr, 73static int generate_output(char * argv[],int argc,const char *optstr,
74 const struct option *longopts); 74 const struct option *longopts);
75static void add_long_options(char *options); 75static void add_long_options(char *options);
76static void add_longopt(const char *name,int has_arg); 76static void add_longopt(const char *name,int has_arg);
77static void set_shell(const char *new_shell); 77static void set_shell(const char *new_shell);
@@ -88,57 +88,57 @@ static void set_shell(const char *new_shell);
88 */ 88 */
89const char *normalize(const char *arg) 89const char *normalize(const char *arg)
90{ 90{
91 static char *BUFFER=NULL; 91 static char *BUFFER=NULL;
92 const char *argptr=arg; 92 const char *argptr=arg;
93 char *bufptr; 93 char *bufptr;
94 94
95 free(BUFFER); 95 free(BUFFER);
96 96
97 if (!quote) { /* Just copy arg */ 97 if (!quote) { /* Just copy arg */
98 BUFFER=bb_xstrdup(arg); 98 BUFFER=bb_xstrdup(arg);
99 return BUFFER; 99 return BUFFER;
100 } 100 }
101 101
102 /* Each character in arg may take up to four characters in the result: 102 /* Each character in arg may take up to four characters in the result:
103 For a quote we need a closing quote, a backslash, a quote and an 103 For a quote we need a closing quote, a backslash, a quote and an
104 opening quote! We need also the global opening and closing quote, 104 opening quote! We need also the global opening and closing quote,
105 and one extra character for '\0'. */ 105 and one extra character for '\0'. */
106 BUFFER=xmalloc(strlen(arg)*4+3); 106 BUFFER=xmalloc(strlen(arg)*4+3);
107 107
108 bufptr=BUFFER; 108 bufptr=BUFFER;
109 *bufptr++='\''; 109 *bufptr++='\'';
110 110
111 while (*argptr) { 111 while (*argptr) {
112 if (*argptr == '\'') { 112 if (*argptr == '\'') {
113 /* Quote: replace it with: '\'' */ 113 /* Quote: replace it with: '\'' */
114 *bufptr++='\''; 114 *bufptr++='\'';
115 *bufptr++='\\'; 115 *bufptr++='\\';
116 *bufptr++='\''; 116 *bufptr++='\'';
117 *bufptr++='\''; 117 *bufptr++='\'';
118 } else if (shell==TCSH && *argptr=='!') { 118 } else if (shell==TCSH && *argptr=='!') {
119 /* Exclamation mark: replace it with: \! */ 119 /* Exclamation mark: replace it with: \! */
120 *bufptr++='\''; 120 *bufptr++='\'';
121 *bufptr++='\\'; 121 *bufptr++='\\';
122 *bufptr++='!'; 122 *bufptr++='!';
123 *bufptr++='\''; 123 *bufptr++='\'';
124 } else if (shell==TCSH && *argptr=='\n') { 124 } else if (shell==TCSH && *argptr=='\n') {
125 /* Newline: replace it with: \n */ 125 /* Newline: replace it with: \n */
126 *bufptr++='\\'; 126 *bufptr++='\\';
127 *bufptr++='n'; 127 *bufptr++='n';
128 } else if (shell==TCSH && isspace(*argptr)) { 128 } else if (shell==TCSH && isspace(*argptr)) {
129 /* Non-newline whitespace: replace it with \<ws> */ 129 /* Non-newline whitespace: replace it with \<ws> */
130 *bufptr++='\''; 130 *bufptr++='\'';
131 *bufptr++='\\'; 131 *bufptr++='\\';
132 *bufptr++=*argptr; 132 *bufptr++=*argptr;
133 *bufptr++='\''; 133 *bufptr++='\'';
134 } else 134 } else
135 /* Just copy */ 135 /* Just copy */
136 *bufptr++=*argptr; 136 *bufptr++=*argptr;
137 argptr++; 137 argptr++;
138 } 138 }
139 *bufptr++='\''; 139 *bufptr++='\'';
140 *bufptr++='\0'; 140 *bufptr++='\0';
141 return BUFFER; 141 return BUFFER;
142} 142}
143 143
144/* 144/*
@@ -149,47 +149,47 @@ const char *normalize(const char *arg)
149 * Other settings are found in global variables. 149 * Other settings are found in global variables.
150 */ 150 */
151int generate_output(char * argv[],int argc,const char *optstr, 151int generate_output(char * argv[],int argc,const char *optstr,
152 const struct option *longopts) 152 const struct option *longopts)
153{ 153{
154 int exit_code = 0; /* We assume everything will be OK */ 154 int exit_code = 0; /* We assume everything will be OK */
155 int opt; 155 int opt;
156 int longindex; 156 int longindex;
157 const char *charptr; 157 const char *charptr;
158 158
159 if (quiet_errors) /* No error reporting from getopt(3) */ 159 if (quiet_errors) /* No error reporting from getopt(3) */
160 opterr=0; 160 opterr=0;
161 optind=0; /* Reset getopt(3) */ 161 optind=0; /* Reset getopt(3) */
162 162
163 while ((opt = (alternative? 163 while ((opt = (alternative?
164 getopt_long_only(argc,argv,optstr,longopts,&longindex): 164 getopt_long_only(argc,argv,optstr,longopts,&longindex):
165 getopt_long(argc,argv,optstr,longopts,&longindex))) 165 getopt_long(argc,argv,optstr,longopts,&longindex)))
166 != EOF) 166 != EOF)
167 if (opt == '?' || opt == ':' ) 167 if (opt == '?' || opt == ':' )
168 exit_code = 1; 168 exit_code = 1;
169 else if (!quiet_output) { 169 else if (!quiet_output) {
170 if (opt == LONG_OPT) { 170 if (opt == LONG_OPT) {
171 printf(" --%s",longopts[longindex].name); 171 printf(" --%s",longopts[longindex].name);
172 if (longopts[longindex].has_arg) 172 if (longopts[longindex].has_arg)
173 printf(" %s", 173 printf(" %s",
174 normalize(optarg?optarg:"")); 174 normalize(optarg?optarg:""));
175 } else if (opt == NON_OPT) 175 } else if (opt == NON_OPT)
176 printf(" %s",normalize(optarg)); 176 printf(" %s",normalize(optarg));
177 else { 177 else {
178 printf(" -%c",opt); 178 printf(" -%c",opt);
179 charptr = strchr(optstr,opt); 179 charptr = strchr(optstr,opt);
180 if (charptr != NULL && *++charptr == ':') 180 if (charptr != NULL && *++charptr == ':')
181 printf(" %s", 181 printf(" %s",
182 normalize(optarg?optarg:"")); 182 normalize(optarg?optarg:""));
183 } 183 }
184 } 184 }
185 185
186 if (! quiet_output) { 186 if (! quiet_output) {
187 printf(" --"); 187 printf(" --");
188 while (optind < argc) 188 while (optind < argc)
189 printf(" %s",normalize(argv[optind++])); 189 printf(" %s",normalize(argv[optind++]));
190 printf("\n"); 190 printf("\n");
191 } 191 }
192 return exit_code; 192 return exit_code;
193} 193}
194 194
195static struct option *long_options; 195static struct option *long_options;
@@ -201,32 +201,32 @@ static const int LONG_OPTIONS_INCR = 10;
201/* Register a long option. The contents of name is copied. */ 201/* Register a long option. The contents of name is copied. */
202void add_longopt(const char *name,int has_arg) 202void add_longopt(const char *name,int has_arg)
203{ 203{
204 if (!name) { /* init */ 204 if (!name) { /* init */
205 free(long_options); 205 free(long_options);
206 long_options=NULL; 206 long_options=NULL;
207 long_options_length=0; 207 long_options_length=0;
208 long_options_nr=0; 208 long_options_nr=0;
209 } 209 }
210 210
211 if (long_options_nr == long_options_length) { 211 if (long_options_nr == long_options_length) {
212 long_options_length += LONG_OPTIONS_INCR; 212 long_options_length += LONG_OPTIONS_INCR;
213 long_options=xrealloc(long_options, 213 long_options=xrealloc(long_options,
214 sizeof(struct option) * 214 sizeof(struct option) *
215 long_options_length); 215 long_options_length);
216 } 216 }
217 217
218 long_options[long_options_nr].name=NULL; 218 long_options[long_options_nr].name=NULL;
219 long_options[long_options_nr].has_arg=0; 219 long_options[long_options_nr].has_arg=0;
220 long_options[long_options_nr].flag=NULL; 220 long_options[long_options_nr].flag=NULL;
221 long_options[long_options_nr].val=0; 221 long_options[long_options_nr].val=0;
222 222
223 if (long_options_nr) { /* Not for init! */ 223 if (long_options_nr) { /* Not for init! */
224 long_options[long_options_nr-1].has_arg=has_arg; 224 long_options[long_options_nr-1].has_arg=has_arg;
225 long_options[long_options_nr-1].flag=NULL; 225 long_options[long_options_nr-1].flag=NULL;
226 long_options[long_options_nr-1].val=LONG_OPT; 226 long_options[long_options_nr-1].val=LONG_OPT;
227 long_options[long_options_nr-1].name=bb_xstrdup(name); 227 long_options[long_options_nr-1].name=bb_xstrdup(name);
228 } 228 }
229 long_options_nr++; 229 long_options_nr++;
230} 230}
231 231
232 232
@@ -237,43 +237,43 @@ void add_longopt(const char *name,int has_arg)
237 */ 237 */
238void add_long_options(char *options) 238void add_long_options(char *options)
239{ 239{
240 int arg_opt, tlen; 240 int arg_opt, tlen;
241 char *tokptr=strtok(options,", \t\n"); 241 char *tokptr=strtok(options,", \t\n");
242 while (tokptr) { 242 while (tokptr) {
243 arg_opt=no_argument; 243 arg_opt=no_argument;
244 tlen=strlen(tokptr); 244 tlen=strlen(tokptr);
245 if (tlen > 0) { 245 if (tlen > 0) {
246 if (tokptr[tlen-1] == ':') { 246 if (tokptr[tlen-1] == ':') {
247 if (tlen > 1 && tokptr[tlen-2] == ':') { 247 if (tlen > 1 && tokptr[tlen-2] == ':') {
248 tokptr[tlen-2]='\0'; 248 tokptr[tlen-2]='\0';
249 tlen -= 2; 249 tlen -= 2;
250 arg_opt=optional_argument; 250 arg_opt=optional_argument;
251 } else { 251 } else {
252 tokptr[tlen-1]='\0'; 252 tokptr[tlen-1]='\0';
253 tlen -= 1; 253 tlen -= 1;
254 arg_opt=required_argument; 254 arg_opt=required_argument;
255 } 255 }
256 if (tlen == 0) 256 if (tlen == 0)
257 bb_error_msg("empty long option after -l or --long argument"); 257 bb_error_msg("empty long option after -l or --long argument");
258 } 258 }
259 add_longopt(tokptr,arg_opt); 259 add_longopt(tokptr,arg_opt);
260 } 260 }
261 tokptr=strtok(NULL,", \t\n"); 261 tokptr=strtok(NULL,", \t\n");
262 } 262 }
263} 263}
264 264
265void set_shell(const char *new_shell) 265void set_shell(const char *new_shell)
266{ 266{
267 if (!strcmp(new_shell,"bash")) 267 if (!strcmp(new_shell,"bash"))
268 shell=BASH; 268 shell=BASH;
269 else if (!strcmp(new_shell,"tcsh")) 269 else if (!strcmp(new_shell,"tcsh"))
270 shell=TCSH; 270 shell=TCSH;
271 else if (!strcmp(new_shell,"sh")) 271 else if (!strcmp(new_shell,"sh"))
272 shell=BASH; 272 shell=BASH;
273 else if (!strcmp(new_shell,"csh")) 273 else if (!strcmp(new_shell,"csh"))
274 shell=TCSH; 274 shell=TCSH;
275 else 275 else
276 bb_error_msg("unknown shell after -s or --shell argument"); 276 bb_error_msg("unknown shell after -s or --shell argument");
277} 277}
278 278
279 279
@@ -287,16 +287,16 @@ void set_shell(const char *new_shell)
287 287
288static const struct option longopts[]= 288static const struct option longopts[]=
289{ 289{
290 {"options",required_argument,NULL,'o'}, 290 {"options",required_argument,NULL,'o'},
291 {"longoptions",required_argument,NULL,'l'}, 291 {"longoptions",required_argument,NULL,'l'},
292 {"quiet",no_argument,NULL,'q'}, 292 {"quiet",no_argument,NULL,'q'},
293 {"quiet-output",no_argument,NULL,'Q'}, 293 {"quiet-output",no_argument,NULL,'Q'},
294 {"shell",required_argument,NULL,'s'}, 294 {"shell",required_argument,NULL,'s'},
295 {"test",no_argument,NULL,'T'}, 295 {"test",no_argument,NULL,'T'},
296 {"unquoted",no_argument,NULL,'u'}, 296 {"unquoted",no_argument,NULL,'u'},
297 {"alternative",no_argument,NULL,'a'}, 297 {"alternative",no_argument,NULL,'a'},
298 {"name",required_argument,NULL,'n'}, 298 {"name",required_argument,NULL,'n'},
299 {NULL,0,NULL,0} 299 {NULL,0,NULL,0}
300}; 300};
301 301
302/* Stop scanning as soon as a non-option argument is found! */ 302/* Stop scanning as soon as a non-option argument is found! */
@@ -305,77 +305,77 @@ static const char shortopts[]="+ao:l:n:qQs:Tu";
305 305
306int getopt_main(int argc, char *argv[]) 306int getopt_main(int argc, char *argv[])
307{ 307{
308 const char *optstr = NULL; 308 const char *optstr = NULL;
309 char *name = NULL; 309 char *name = NULL;
310 int opt; 310 int opt;
311 int compatible=0; 311 int compatible=0;
312 312
313 init_longopt(); 313 init_longopt();
314 314
315 if (getenv("GETOPT_COMPATIBLE")) 315 if (getenv("GETOPT_COMPATIBLE"))
316 compatible=1; 316 compatible=1;
317 317
318 if (argc == 1) { 318 if (argc == 1) {
319 if (compatible) { 319 if (compatible) {
320 /* For some reason, the original getopt gave no error 320 /* For some reason, the original getopt gave no error
321 when there were no arguments. */ 321 when there were no arguments. */
322 printf(" --\n"); 322 printf(" --\n");
323 return 0; 323 return 0;
324 } else 324 } else
325 bb_error_msg_and_die("missing optstring argument"); 325 bb_error_msg_and_die("missing optstring argument");
326 } 326 }
327 327
328 if (argv[1][0] != '-' || compatible) { 328 if (argv[1][0] != '-' || compatible) {
329 char *s; 329 char *s;
330 330
331 quote=0; 331 quote=0;
332 s=xmalloc(strlen(argv[1])+1); 332 s=xmalloc(strlen(argv[1])+1);
333 strcpy(s,argv[1]+strspn(argv[1],"-+")); 333 strcpy(s,argv[1]+strspn(argv[1],"-+"));
334 argv[1]=argv[0]; 334 argv[1]=argv[0];
335 return (generate_output(argv+1,argc-1,s,long_options)); 335 return (generate_output(argv+1,argc-1,s,long_options));
336 } 336 }
337 337
338 while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF) 338 while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF)
339 switch (opt) { 339 switch (opt) {
340 case 'a': 340 case 'a':
341 alternative=1; 341 alternative=1;
342 break; 342 break;
343 case 'o': 343 case 'o':
344 optstr = optarg; 344 optstr = optarg;
345 break; 345 break;
346 case 'l': 346 case 'l':
347 add_long_options(optarg); 347 add_long_options(optarg);
348 break; 348 break;
349 case 'n': 349 case 'n':
350 name = optarg; 350 name = optarg;
351 break; 351 break;
352 case 'q': 352 case 'q':
353 quiet_errors=1; 353 quiet_errors=1;
354 break; 354 break;
355 case 'Q': 355 case 'Q':
356 quiet_output=1; 356 quiet_output=1;
357 break; 357 break;
358 case 's': 358 case 's':
359 set_shell(optarg); 359 set_shell(optarg);
360 break; 360 break;
361 case 'T': 361 case 'T':
362 return 4; 362 return 4;
363 case 'u': 363 case 'u':
364 quote=0; 364 quote=0;
365 break; 365 break;
366 default: 366 default:
367 bb_show_usage(); 367 bb_show_usage();
368 } 368 }
369 369
370 if (!optstr) { 370 if (!optstr) {
371 if (optind >= argc) 371 if (optind >= argc)
372 bb_error_msg_and_die("missing optstring argument"); 372 bb_error_msg_and_die("missing optstring argument");
373 else optstr=argv[optind++]; 373 else optstr=argv[optind++];
374 } 374 }
375 if (name) 375 if (name)
376 argv[optind-1]=name; 376 argv[optind-1]=name;
377 else 377 else
378 argv[optind-1]=argv[0]; 378 argv[optind-1]=argv[0];
379 return (generate_output(argv+optind-1,argc-optind+1,optstr,long_options)); 379 return (generate_output(argv+optind-1,argc-optind+1,optstr,long_options));
380} 380}
381 381
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 5b990df0c..00abe10a6 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -67,7 +67,7 @@ static time_t read_rtc(int utc)
67 if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 ) 67 if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 )
68 bb_perror_msg_and_die ( "Could not access RTC" ); 68 bb_perror_msg_and_die ( "Could not access RTC" );
69 } 69 }
70 memset ( &tm, 0, sizeof( struct tm )); 70 memset ( &tm, 0, sizeof( struct tm ));
71 if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 ) 71 if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 )
72 bb_perror_msg_and_die ( "Could not read time from RTC" ); 72 bb_perror_msg_and_die ( "Could not read time from RTC" );
73 tm. tm_isdst = -1; // not known 73 tm. tm_isdst = -1; // not known
@@ -187,10 +187,10 @@ static int check_utc(void)
187} 187}
188 188
189#define HWCLOCK_OPT_LOCALTIME 0x01 189#define HWCLOCK_OPT_LOCALTIME 0x01
190#define HWCLOCK_OPT_UTC 0x02 190#define HWCLOCK_OPT_UTC 0x02
191#define HWCLOCK_OPT_SHOW 0x04 191#define HWCLOCK_OPT_SHOW 0x04
192#define HWCLOCK_OPT_HCTOSYS 0x08 192#define HWCLOCK_OPT_HCTOSYS 0x08
193#define HWCLOCK_OPT_SYSTOHC 0x10 193#define HWCLOCK_OPT_SYSTOHC 0x10
194 194
195extern int hwclock_main ( int argc, char **argv ) 195extern int hwclock_main ( int argc, char **argv )
196{ 196{
diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c
index 9e18752a3..f4abf6839 100644
--- a/util-linux/ipcrm.c
+++ b/util-linux/ipcrm.c
@@ -94,7 +94,7 @@ remove_ids(type_id type, int argc, char **argv) {
94 case MSG: 94 case MSG:
95 ret = msgctl (id, IPC_RMID, NULL); 95 ret = msgctl (id, IPC_RMID, NULL);
96 break; 96 break;
97 97
98 case SHM: 98 case SHM:
99 ret = shmctl (id, IPC_RMID, NULL); 99 ret = shmctl (id, IPC_RMID, NULL);
100 break; 100 break;
@@ -109,7 +109,7 @@ remove_ids(type_id type, int argc, char **argv) {
109 argc--; 109 argc--;
110 argv++; 110 argv++;
111 } 111 }
112 112
113 return(nb_errors); 113 return(nb_errors);
114} 114}
115 115
@@ -119,7 +119,7 @@ static int deprecated_main(int argc, char **argv)
119 bb_show_usage(); 119 bb_show_usage();
120 bb_fflush_stdout_and_exit(1); 120 bb_fflush_stdout_and_exit(1);
121 } 121 }
122 122
123 if (!strcmp(argv[1], "shm")) { 123 if (!strcmp(argv[1], "shm")) {
124 if (remove_ids(SHM, argc-2, &argv[2])) 124 if (remove_ids(SHM, argc-2, &argv[2]))
125 bb_fflush_stdout_and_exit(1); 125 bb_fflush_stdout_and_exit(1);
@@ -127,7 +127,7 @@ static int deprecated_main(int argc, char **argv)
127 else if (!strcmp(argv[1], "msg")) { 127 else if (!strcmp(argv[1], "msg")) {
128 if (remove_ids(MSG, argc-2, &argv[2])) 128 if (remove_ids(MSG, argc-2, &argv[2]))
129 bb_fflush_stdout_and_exit(1); 129 bb_fflush_stdout_and_exit(1);
130 } 130 }
131 else if (!strcmp(argv[1], "sem")) { 131 else if (!strcmp(argv[1], "sem")) {
132 if (remove_ids(SEM, argc-2, &argv[2])) 132 if (remove_ids(SEM, argc-2, &argv[2]))
133 bb_fflush_stdout_and_exit(1); 133 bb_fflush_stdout_and_exit(1);
@@ -228,7 +228,7 @@ int ipcrm_main(int argc, char **argv)
228 } 228 }
229 229
230 result = ((c == 'q') ? msgctl(id, IPC_RMID, NULL) : 230 result = ((c == 'q') ? msgctl(id, IPC_RMID, NULL) :
231 (c == 'm') ? shmctl(id, IPC_RMID, NULL) : 231 (c == 'm') ? shmctl(id, IPC_RMID, NULL) :
232 semctl(id, 0, IPC_RMID, arg)); 232 semctl(id, 0, IPC_RMID, arg));
233 233
234 if (result < 0) { 234 if (result < 0) {
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index ea5e412ea..f1463a8e3 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -29,12 +29,12 @@
29 * 19:30:41 1996 by janl@math.uio.no to add code missing in case PID: 29 * 19:30:41 1996 by janl@math.uio.no to add code missing in case PID:
30 * clauses. 30 * clauses.
31 * 31 *
32 * Patches from Mike Jagdis (jaggy@purplet.demon.co.uk) applied 32 * Patches from Mike Jagdis (jaggy@purplet.demon.co.uk) applied
33 * Wed Feb 8 12:12:21 1995 by faith@cs.unc.edu to print numeric uids 33 * Wed Feb 8 12:12:21 1995 by faith@cs.unc.edu to print numeric uids
34 * if no passwd file entry. 34 * if no passwd file entry.
35 * 35 *
36 * Modified Sat Oct 9 10:55:28 1993 for 0.99.13 36 * Modified Sat Oct 9 10:55:28 1993 for 0.99.13
37 * Original author unknown, may be "krishna balasub@cis.ohio-state.edu" 37 * Original author unknown, may be "krishna balasub@cis.ohio-state.edu"
38 * 38 *
39 */ 39 */
40 40
@@ -136,7 +136,7 @@ static void print_msg (int id);
136static void print_sem (int id); 136static void print_sem (int id);
137 137
138int ipcs_main (int argc, char **argv) { 138int ipcs_main (int argc, char **argv) {
139 int opt, msg = 0, sem = 0, shm = 0, id=0, print=0; 139 int opt, msg = 0, sem = 0, shm = 0, id=0, print=0;
140 char format = 0; 140 char format = 0;
141 char options[] = "atclupsmqi:ih?"; 141 char options[] = "atclupsmqi:ih?";
142 142
@@ -173,7 +173,7 @@ int ipcs_main (int argc, char **argv) {
173 case 'u': 173 case 'u':
174 format = STATUS; 174 format = STATUS;
175 break; 175 break;
176 case 'h': 176 case 'h':
177 case '?': 177 case '?':
178 bb_show_usage(); 178 bb_show_usage();
179 bb_fflush_stdout_and_exit (0); 179 bb_fflush_stdout_and_exit (0);
@@ -181,11 +181,11 @@ int ipcs_main (int argc, char **argv) {
181 } 181 }
182 182
183 if (print) { 183 if (print) {
184 if (shm) { 184 if (shm) {
185 print_shm (id); 185 print_shm (id);
186 bb_fflush_stdout_and_exit (0); 186 bb_fflush_stdout_and_exit (0);
187 } 187 }
188 if (sem) { 188 if (sem) {
189 print_sem (id); 189 print_sem (id);
190 bb_fflush_stdout_and_exit (0); 190 bb_fflush_stdout_and_exit (0);
191 } 191 }
@@ -201,15 +201,15 @@ int ipcs_main (int argc, char **argv) {
201 msg = sem = shm = 1; 201 msg = sem = shm = 1;
202 bb_printf ("\n"); 202 bb_printf ("\n");
203 203
204 if (shm) { 204 if (shm) {
205 do_shm (format); 205 do_shm (format);
206 bb_printf ("\n"); 206 bb_printf ("\n");
207 } 207 }
208 if (sem) { 208 if (sem) {
209 do_sem (format); 209 do_sem (format);
210 bb_printf ("\n"); 210 bb_printf ("\n");
211 } 211 }
212 if (msg) { 212 if (msg) {
213 do_msg (format); 213 do_msg (format);
214 bb_printf ("\n"); 214 bb_printf ("\n");
215 } 215 }
@@ -258,7 +258,7 @@ void do_shm (char format)
258 bb_printf ("kernel not configured for shared memory\n"); 258 bb_printf ("kernel not configured for shared memory\n");
259 return; 259 return;
260 } 260 }
261 261
262 switch (format) { 262 switch (format) {
263 case LIMITS: 263 case LIMITS:
264 bb_printf ("------ Shared Memory Limits --------\n"); 264 bb_printf ("------ Shared Memory Limits --------\n");
@@ -282,7 +282,7 @@ void do_shm (char format)
282 bb_printf ("pages allocated %ld\n", shm_info.shm_tot); 282 bb_printf ("pages allocated %ld\n", shm_info.shm_tot);
283 bb_printf ("pages resident %ld\n", shm_info.shm_rss); 283 bb_printf ("pages resident %ld\n", shm_info.shm_rss);
284 bb_printf ("pages swapped %ld\n", shm_info.shm_swp); 284 bb_printf ("pages swapped %ld\n", shm_info.shm_swp);
285 bb_printf ("Swap performance: %ld attempts\t %ld successes\n", 285 bb_printf ("Swap performance: %ld attempts\t %ld successes\n",
286 shm_info.swap_attempts, shm_info.swap_successes); 286 shm_info.swap_attempts, shm_info.swap_successes);
287 return; 287 return;
288 288
@@ -313,7 +313,7 @@ void do_shm (char format)
313 313
314 for (id = 0; id <= maxid; id++) { 314 for (id = 0; id <= maxid; id++) {
315 shmid = shmctl (id, SHM_STAT, &shmseg); 315 shmid = shmctl (id, SHM_STAT, &shmseg);
316 if (shmid < 0) 316 if (shmid < 0)
317 continue; 317 continue;
318 if (format == CREATOR) { 318 if (format == CREATOR) {
319 print_perms (shmid, ipcp); 319 print_perms (shmid, ipcp);
@@ -321,7 +321,7 @@ void do_shm (char format)
321 } 321 }
322 pw = getpwuid(ipcp->uid); 322 pw = getpwuid(ipcp->uid);
323 switch (format) { 323 switch (format) {
324 case TIME: 324 case TIME:
325 if (pw) 325 if (pw)
326 bb_printf ("%-10d %-10.10s", shmid, pw->pw_name); 326 bb_printf ("%-10d %-10.10s", shmid, pw->pw_name);
327 else 327 else
@@ -342,14 +342,14 @@ void do_shm (char format)
342 bb_printf (" %-10d %-10d\n", 342 bb_printf (" %-10d %-10d\n",
343 shmseg.shm_cpid, shmseg.shm_lpid); 343 shmseg.shm_cpid, shmseg.shm_lpid);
344 break; 344 break;
345 345
346 default: 346 default:
347 bb_printf("0x%08x ",ipcp->KEY ); 347 bb_printf("0x%08x ",ipcp->KEY );
348 if (pw) 348 if (pw)
349 bb_printf ("%-10d %-10.10s", shmid, pw->pw_name); 349 bb_printf ("%-10d %-10.10s", shmid, pw->pw_name);
350 else 350 else
351 bb_printf ("%-10d %-10d", shmid, ipcp->uid); 351 bb_printf ("%-10d %-10d", shmid, ipcp->uid);
352 bb_printf ("%-10o %-10lu %-10ld %-6s %-6s\n", 352 bb_printf ("%-10o %-10lu %-10ld %-6s %-6s\n",
353 ipcp->mode & 0777, 353 ipcp->mode & 0777,
354 /* 354 /*
355 * earlier: int, Austin has size_t 355 * earlier: int, Austin has size_t
@@ -384,7 +384,7 @@ void do_sem (char format)
384 bb_printf ("kernel not configured for semaphores\n"); 384 bb_printf ("kernel not configured for semaphores\n");
385 return; 385 return;
386 } 386 }
387 387
388 switch (format) { 388 switch (format) {
389 case LIMITS: 389 case LIMITS:
390 bb_printf ("------ Semaphore Limits --------\n"); 390 bb_printf ("------ Semaphore Limits --------\n");
@@ -421,7 +421,7 @@ void do_sem (char format)
421 421
422 default: 422 default:
423 bb_printf ("------ Semaphore Arrays --------\n"); 423 bb_printf ("------ Semaphore Arrays --------\n");
424 bb_printf ("%-10s %-10s %-10s %-10s %-10s\n", 424 bb_printf ("%-10s %-10s %-10s %-10s %-10s\n",
425 "key","semid","owner","perms","nsems"); 425 "key","semid","owner","perms","nsems");
426 break; 426 break;
427 } 427 }
@@ -437,7 +437,7 @@ void do_sem (char format)
437 } 437 }
438 pw = getpwuid(ipcp->uid); 438 pw = getpwuid(ipcp->uid);
439 switch (format) { 439 switch (format) {
440 case TIME: 440 case TIME:
441 if (pw) 441 if (pw)
442 bb_printf ("%-8d %-10.10s", semid, pw->pw_name); 442 bb_printf ("%-8d %-10.10s", semid, pw->pw_name);
443 else 443 else
@@ -449,7 +449,7 @@ void do_sem (char format)
449 break; 449 break;
450 case PID: 450 case PID:
451 break; 451 break;
452 452
453 default: 453 default:
454 bb_printf("0x%08x ", ipcp->KEY); 454 bb_printf("0x%08x ", ipcp->KEY);
455 if (pw) 455 if (pw)
@@ -484,7 +484,7 @@ void do_msg (char format)
484 bb_printf ("kernel not configured for message queues\n"); 484 bb_printf ("kernel not configured for message queues\n");
485 return; 485 return;
486 } 486 }
487 487
488 switch (format) { 488 switch (format) {
489 case LIMITS: 489 case LIMITS:
490 if ((msgctl (0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0 ) 490 if ((msgctl (0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0 )
@@ -662,7 +662,7 @@ void print_sem (int semid)
662 bb_printf ("nsems = %ld\n", (long) semds.sem_nsems); 662 bb_printf ("nsems = %ld\n", (long) semds.sem_nsems);
663 bb_printf ("otime = %-26.24s\n", 663 bb_printf ("otime = %-26.24s\n",
664 semds.sem_otime ? ctime (&semds.sem_otime) : "Not set"); 664 semds.sem_otime ? ctime (&semds.sem_otime) : "Not set");
665 bb_printf ("ctime = %-26.24s\n", ctime (&semds.sem_ctime)); 665 bb_printf ("ctime = %-26.24s\n", ctime (&semds.sem_ctime));
666 666
667 bb_printf ("%-10s %-10s %-10s %-10s %-10s\n", 667 bb_printf ("%-10s %-10s %-10s %-10s %-10s\n",
668 "semnum","value","ncount","zcount","pid"); 668 "semnum","value","ncount","zcount","pid");
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index f03889663..c2d3339e0 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -31,16 +31,16 @@ die_failed:
31 case -1: 31 case -1:
32 /* losetup takes two argument:, loop_device and file */ 32 /* losetup takes two argument:, loop_device and file */
33 if(optind+2==argc) { 33 if(optind+2==argc) {
34 if(set_loop(&argv[optind], argv[optind + 1], offset)>=0) 34 if(set_loop(&argv[optind], argv[optind + 1], offset)>=0)
35 return EXIT_SUCCESS; 35 return EXIT_SUCCESS;
36 else goto die_failed; 36 else goto die_failed;
37 } 37 }
38 if(optind+1==argc) { 38 if(optind+1==argc) {
39 char *s=query_loop(argv[optind]); 39 char *s=query_loop(argv[optind]);
40 if (!s) goto die_failed; 40 if (!s) goto die_failed;
41 printf("%s: %s\n",argv[optind],s); 41 printf("%s: %s\n",argv[optind],s);
42 if(ENABLE_FEATURE_CLEAN_UP) free(s); 42 if(ENABLE_FEATURE_CLEAN_UP) free(s);
43 return EXIT_SUCCESS; 43 return EXIT_SUCCESS;
44 } 44 }
45 break; 45 break;
46 } 46 }
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index a18e44835..b8c0090fa 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1,7 +1,7 @@
1/* vi:set ts=4: 1/* vi:set ts=4:
2 * 2 *
3 * mdev - Mini udev for busybox 3 * mdev - Mini udev for busybox
4 * 4 *
5 * Copyright 2005 Rob Landley <rob@landley.net> 5 * Copyright 2005 Rob Landley <rob@landley.net>
6 * Copyright 2005 Frank Sorenson <frank@tuxrocks.com> 6 * Copyright 2005 Frank Sorenson <frank@tuxrocks.com>
7 * 7 *
@@ -38,21 +38,21 @@ static void make_device(char *path)
38 RESERVE_CONFIG_BUFFER(temp,PATH_MAX); 38 RESERVE_CONFIG_BUFFER(temp,PATH_MAX);
39 39
40 /* Try to read major/minor string */ 40 /* Try to read major/minor string */
41 41
42 snprintf(temp, PATH_MAX, "%s/dev", path); 42 snprintf(temp, PATH_MAX, "%s/dev", path);
43 fd = open(temp, O_RDONLY); 43 fd = open(temp, O_RDONLY);
44 len = read(fd, temp, PATH_MAX-1); 44 len = read(fd, temp, PATH_MAX-1);
45 if (len<1) goto end; 45 if (len<1) goto end;
46 close(fd); 46 close(fd);
47 47
48 /* Determine device name, type, major and minor */ 48 /* Determine device name, type, major and minor */
49 49
50 device_name = strrchr(path, '/') + 1; 50 device_name = strrchr(path, '/') + 1;
51 type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK; 51 type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK;
52 if(sscanf(temp, "%d:%d", &major, &minor) != 2) goto end; 52 if(sscanf(temp, "%d:%d", &major, &minor) != 2) goto end;
53 53
54 /* If we have a config file, look up permissions for this device */ 54 /* If we have a config file, look up permissions for this device */
55 55
56 if (ENABLE_FEATURE_MDEV_CONF) { 56 if (ENABLE_FEATURE_MDEV_CONF) {
57 char *conf,*pos,*end; 57 char *conf,*pos,*end;
58 58
@@ -67,7 +67,7 @@ static void make_device(char *path)
67 for (pos=conf;pos-conf<len;) { 67 for (pos=conf;pos-conf<len;) {
68 int field; 68 int field;
69 char *end2; 69 char *end2;
70 70
71 line++; 71 line++;
72 /* find end of this line */ 72 /* find end of this line */
73 for(end=pos;end-conf<len && *end!='\n';end++); 73 for(end=pos;end-conf<len && *end!='\n';end++);
@@ -88,11 +88,11 @@ static void make_device(char *path)
88 regmatch_t off; 88 regmatch_t off;
89 int result; 89 int result;
90 90
91 /* Is this it? */ 91 /* Is this it? */
92 xregcomp(&match,regex,REG_EXTENDED); 92 xregcomp(&match,regex,REG_EXTENDED);
93 result=regexec(&match,device_name,1,&off,0); 93 result=regexec(&match,device_name,1,&off,0);
94 regfree(&match); 94 regfree(&match);
95 95
96 /* If not this device, skip rest of line */ 96 /* If not this device, skip rest of line */
97 if(result || off.rm_so 97 if(result || off.rm_so
98 || off.rm_eo!=strlen(device_name)) 98 || off.rm_eo!=strlen(device_name))
@@ -159,7 +159,7 @@ found_device:
159 bb_perror_msg_and_die("mknod %s failed", temp); 159 bb_perror_msg_and_die("mknod %s failed", temp);
160 160
161 if (ENABLE_FEATURE_MDEV_CONF) chown(temp,uid,gid); 161 if (ENABLE_FEATURE_MDEV_CONF) chown(temp,uid,gid);
162 162
163end: 163end:
164 RELEASE_CONFIG_BUFFER(temp); 164 RELEASE_CONFIG_BUFFER(temp);
165} 165}
@@ -177,7 +177,7 @@ static void find_dev(char *path)
177 177
178 for (;;) { 178 for (;;) {
179 struct dirent *entry = readdir(dir); 179 struct dirent *entry = readdir(dir);
180 180
181 if (!entry) break; 181 if (!entry) break;
182 182
183 /* Skip "." and ".." (also skips hidden files, which is ok) */ 183 /* Skip "." and ".." (also skips hidden files, which is ok) */
@@ -189,12 +189,12 @@ static void find_dev(char *path)
189 find_dev(path); 189 find_dev(path);
190 path[len] = 0; 190 path[len] = 0;
191 } 191 }
192 192
193 /* If there's a dev entry, mknod it */ 193 /* If there's a dev entry, mknod it */
194 194
195 if (!strcmp(entry->d_name, "dev")) make_device(path); 195 if (!strcmp(entry->d_name, "dev")) make_device(path);
196 } 196 }
197 197
198 closedir(dir); 198 closedir(dir);
199} 199}
200 200
@@ -205,7 +205,7 @@ int mdev_main(int argc, char *argv[])
205 RESERVE_CONFIG_BUFFER(temp,PATH_MAX); 205 RESERVE_CONFIG_BUFFER(temp,PATH_MAX);
206 206
207 /* Scan */ 207 /* Scan */
208 208
209 if (argc == 2 && !strcmp(argv[1],"-s")) { 209 if (argc == 2 && !strcmp(argv[1],"-s")) {
210 strcpy(temp,"/sys/block"); 210 strcpy(temp,"/sys/block");
211 find_dev(temp); 211 find_dev(temp);
@@ -218,7 +218,7 @@ int mdev_main(int argc, char *argv[])
218 action = getenv("ACTION"); 218 action = getenv("ACTION");
219 env_path = getenv("DEVPATH"); 219 env_path = getenv("DEVPATH");
220 if (!action || !env_path) bb_show_usage(); 220 if (!action || !env_path) bb_show_usage();
221 221
222 if (!strcmp(action, "add")) { 222 if (!strcmp(action, "add")) {
223 sprintf(temp, "/sys%s", env_path); 223 sprintf(temp, "/sys%s", env_path);
224 make_device(temp); 224 make_device(temp);
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 4777e470b..68542f9bc 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -32,7 +32,7 @@
32 32
33/* Consume standard mount options (from -o options or --options). 33/* Consume standard mount options (from -o options or --options).
34 * Set appropriate flags and collect unrecognized ones as a comma separated 34 * Set appropriate flags and collect unrecognized ones as a comma separated
35 * string to pass to kernel */ 35 * string to pass to kernel */
36 36
37struct { 37struct {
38 const char *name; 38 const char *name;
@@ -104,7 +104,7 @@ extern int mount_main(int argc, char **argv)
104 *loopFile = 0, *buf = 0, 104 *loopFile = 0, *buf = 0,
105 *files[] = {"/etc/filesystems", "/proc/filesystems", 0}; 105 *files[] = {"/etc/filesystems", "/proc/filesystems", 0};
106 int i, opt, all = FALSE, fakeIt = FALSE, allowWrite = FALSE, 106 int i, opt, all = FALSE, fakeIt = FALSE, allowWrite = FALSE,
107 rc = 1, useMtab = ENABLE_FEATURE_MTAB_SUPPORT; 107 rc = 1, useMtab = ENABLE_FEATURE_MTAB_SUPPORT;
108 int flags=0xc0ed0000; // Needed for linux 2.2, ignored by 2.4 and 2.6. 108 int flags=0xc0ed0000; // Needed for linux 2.2, ignored by 2.4 and 2.6.
109 FILE *file = 0,*f = 0; 109 FILE *file = 0,*f = 0;
110 char path[PATH_MAX*2]; 110 char path[PATH_MAX*2];
@@ -185,7 +185,7 @@ extern int mount_main(int argc, char **argv)
185 statbuf.st_mode=0; 185 statbuf.st_mode=0;
186 if(optind < argc) 186 if(optind < argc)
187 blockDevice = !stat(argv[optind], &statbuf) ? 187 blockDevice = !stat(argv[optind], &statbuf) ?
188 bb_simplify_path(argv[optind]) : 188 bb_simplify_path(argv[optind]) :
189 (ENABLE_FEATURE_CLEAN_UP ? strdup(argv[optind]) : argv[optind]); 189 (ENABLE_FEATURE_CLEAN_UP ? strdup(argv[optind]) : argv[optind]);
190 if(optind+1 < argc) directory = bb_simplify_path(argv[optind+1]); 190 if(optind+1 < argc) directory = bb_simplify_path(argv[optind+1]);
191 191
@@ -206,7 +206,7 @@ extern int mount_main(int argc, char **argv)
206 bb_perror_msg("Can't find %s in /etc/fstab\n", blockDevice); 206 bb_perror_msg("Can't find %s in /etc/fstab\n", blockDevice);
207 break; 207 break;
208 } 208 }
209 209
210 // If we're mounting all and all doesn't mount this one, skip it. 210 // If we're mounting all and all doesn't mount this one, skip it.
211 211
212 if(all) { 212 if(all) {
@@ -271,7 +271,7 @@ singlemount:
271 goto mount_it_now; 271 goto mount_it_now;
272 } 272 }
273 } else { 273 } else {
274 274
275 // Do we need to allocate a loopback device? 275 // Do we need to allocate a loopback device?
276 276
277 if(ENABLE_FEATURE_MOUNT_LOOP && !fakeIt && S_ISREG(statbuf.st_mode)) 277 if(ENABLE_FEATURE_MOUNT_LOOP && !fakeIt && S_ISREG(statbuf.st_mode))
@@ -297,7 +297,7 @@ singlemount:
297 if(fsType || (flags & (MS_REMOUNT | MS_BIND | MS_MOVE))) 297 if(fsType || (flags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
298 goto mount_it_now; 298 goto mount_it_now;
299 } 299 }
300 300
301 // Loop through filesystem types until mount succeeds or we run out 301 // Loop through filesystem types until mount succeeds or we run out
302 302
303 for(i = 0; files[i] && rc; i++) { 303 for(i = 0; files[i] && rc; i++) {
@@ -305,11 +305,11 @@ singlemount:
305 if(!f) continue; 305 if(!f) continue;
306 // Get next block device backed filesystem 306 // Get next block device backed filesystem
307 for(buf = 0; (buf = fsType = bb_get_chomped_line_from_file(f)); 307 for(buf = 0; (buf = fsType = bb_get_chomped_line_from_file(f));
308 free(buf)) 308 free(buf))
309 { 309 {
310 // Skip funky entries in /proc 310 // Skip funky entries in /proc
311 if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue; 311 if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
312 312
313 while(isspace(*fsType)) fsType++; 313 while(isspace(*fsType)) fsType++;
314 if(*buf=='#' || *buf=='*') continue; 314 if(*buf=='#' || *buf=='*') continue;
315 if(!*fsType) continue; 315 if(!*fsType) continue;
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c
index 75f341a92..e9d6dc635 100644
--- a/util-linux/nfsmount.c
+++ b/util-linux/nfsmount.c
@@ -151,11 +151,11 @@ static const int MS_NODIRATIME = 2048; /* Do not update directory access time
151#define NFS_MOUNT_VERSION 4 151#define NFS_MOUNT_VERSION 4
152 152
153struct nfs2_fh { 153struct nfs2_fh {
154 char data[32]; 154 char data[32];
155}; 155};
156struct nfs3_fh { 156struct nfs3_fh {
157 unsigned short size; 157 unsigned short size;
158 unsigned char data[64]; 158 unsigned char data[64];
159}; 159};
160 160
161struct nfs_mount_data { 161struct nfs_mount_data {
@@ -687,7 +687,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
687 mountprog, 687 mountprog,
688 mountvers, 688 mountvers,
689 proto, 689 proto,
690 mountport); 690 mountport);
691 691
692 /* contact the mount daemon via TCP */ 692 /* contact the mount daemon via TCP */
693 mount_server_addr.sin_port = htons(pm_mnt->pm_port); 693 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
@@ -810,7 +810,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
810 810
811 if (tcp) { 811 if (tcp) {
812 if (nfs_mount_version < 3) { 812 if (nfs_mount_version < 3) {
813 printf(_("NFS over TCP is not supported.\n")); 813 printf(_("NFS over TCP is not supported.\n"));
814 goto fail; 814 goto fail;
815 } 815 }
816 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 816 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c
index 85e180c46..c86e73cc1 100644
--- a/util-linux/pivot_root.c
+++ b/util-linux/pivot_root.c
@@ -16,7 +16,7 @@ extern int pivot_root(const char * new_root,const char * put_old);
16int pivot_root_main(int argc, char **argv) 16int pivot_root_main(int argc, char **argv)
17{ 17{
18 if (argc != 3) 18 if (argc != 3)
19 bb_show_usage(); 19 bb_show_usage();
20 20
21 if (pivot_root(argv[1],argv[2]) < 0) 21 if (pivot_root(argv[1],argv[2]) < 0)
22 bb_perror_msg_and_die("pivot_root"); 22 bb_perror_msg_and_die("pivot_root");
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index cabcc7dbe..2b011ebb0 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -55,7 +55,7 @@ static time_t askremotedate(const char *host)
55 * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT 55 * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT
56 * Subtract the RFC 868 time to get Linux epoch 56 * Subtract the RFC 868 time to get Linux epoch
57 */ 57 */
58 58
59 return(ntohl(nett) - RFC_868_BIAS); 59 return(ntohl(nett) - RFC_868_BIAS);
60} 60}
61 61
@@ -63,10 +63,10 @@ int rdate_main(int argc, char **argv)
63{ 63{
64 time_t remote_time; 64 time_t remote_time;
65 unsigned long flags; 65 unsigned long flags;
66 66
67 bb_opt_complementally = "-1"; 67 bb_opt_complementally = "-1";
68 flags = bb_getopt_ulflags(argc, argv, "sp"); 68 flags = bb_getopt_ulflags(argc, argv, "sp");
69 69
70 remote_time = askremotedate(argv[optind]); 70 remote_time = askremotedate(argv[optind]);
71 71
72 if (flags & 1) { 72 if (flags & 1) {
@@ -78,9 +78,9 @@ int rdate_main(int argc, char **argv)
78 else 78 else
79 if (stime(&remote_time) < 0) 79 if (stime(&remote_time) < 0)
80 bb_perror_msg_and_die("Could not set time of day"); 80 bb_perror_msg_and_die("Could not set time of day");
81 81
82 /* No need to check for the -p flag as it's the only option left */ 82 /* No need to check for the -p flag as it's the only option left */
83 83
84 } else printf("%s", ctime(&remote_time)); 84 } else printf("%s", ctime(&remote_time));
85 85
86 return EXIT_SUCCESS; 86 return EXIT_SUCCESS;
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index 80716d9f0..1612d7147 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -149,9 +149,9 @@ int readprofile_main(int argc, char **argv)
149 /* 149 /*
150 * Use an fd for the profiling buffer, to skip stdio overhead 150 * Use an fd for the profiling buffer, to skip stdio overhead
151 */ 151 */
152 152
153 proFd = bb_xopen(proFile,O_RDONLY); 153 proFd = bb_xopen(proFile,O_RDONLY);
154 154
155 if (((int)(len=lseek(proFd,0,SEEK_END)) < 0) 155 if (((int)(len=lseek(proFd,0,SEEK_END)) < 0)
156 || (lseek(proFd,0,SEEK_SET) < 0)) 156 || (lseek(proFd,0,SEEK_SET) < 0))
157 bb_perror_msg_and_die(proFile); 157 bb_perror_msg_and_die(proFile);
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 0c86eec08..bcc4443ab 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -47,20 +47,20 @@ static void delete_contents(char *directory)
47 // Skip . and .. 47 // Skip . and ..
48 if(*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2]))) 48 if(*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2])))
49 continue; 49 continue;
50 50
51 // Recurse to delete contents 51 // Recurse to delete contents
52 newdir = alloca(strlen(directory) + strlen(d->d_name) + 2); 52 newdir = alloca(strlen(directory) + strlen(d->d_name) + 2);
53 sprintf(newdir, "%s/%s", directory, d->d_name); 53 sprintf(newdir, "%s/%s", directory, d->d_name);
54 delete_contents(newdir); 54 delete_contents(newdir);
55 } 55 }
56 closedir(dir); 56 closedir(dir);
57 57
58 // Directory should now be empty. Zap it. 58 // Directory should now be empty. Zap it.
59 rmdir(directory); 59 rmdir(directory);
60 } 60 }
61 61
62 // It wasn't a directory. Zap it. 62 // It wasn't a directory. Zap it.
63 63
64 } else unlink(directory); 64 } else unlink(directory);
65} 65}
66 66
@@ -74,18 +74,18 @@ int switch_root_main(int argc, char *argv[])
74 74
75 bb_opt_complementally="-2"; 75 bb_opt_complementally="-2";
76 bb_getopt_ulflags(argc,argv,"c:",&console); 76 bb_getopt_ulflags(argc,argv,"c:",&console);
77 77
78 // Change to new root directory and verify it's a different fs. 78 // Change to new root directory and verify it's a different fs.
79 79
80 newroot=argv[optind++]; 80 newroot=argv[optind++];
81 81
82 if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) || 82 if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) ||
83 st1.st_dev == st2.st_dev) 83 st1.st_dev == st2.st_dev)
84 { 84 {
85 bb_error_msg_and_die("bad newroot %s",newroot); 85 bb_error_msg_and_die("bad newroot %s",newroot);
86 } 86 }
87 rootdev=st2.st_dev; 87 rootdev=st2.st_dev;
88 88
89 // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE 89 // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE
90 // we mean it. (I could make this a CONFIG option, but I would get email 90 // we mean it. (I could make this a CONFIG option, but I would get email
91 // from all the people who WILL eat their filesystemss.) 91 // from all the people who WILL eat their filesystemss.)
@@ -100,13 +100,13 @@ int switch_root_main(int argc, char *argv[])
100 // Zap everything out of rootdev 100 // Zap everything out of rootdev
101 101
102 delete_contents("/"); 102 delete_contents("/");
103 103
104 // Overmount / with newdir and chroot into it. The chdir is needed to 104 // Overmount / with newdir and chroot into it. The chdir is needed to
105 // recalculate "." and ".." links. 105 // recalculate "." and ".." links.
106 106
107 if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/")) 107 if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/"))
108 bb_error_msg_and_die("moving root"); 108 bb_error_msg_and_die("moving root");
109 109
110 // If a new console specified, redirect stdin/stdout/stderr to that. 110 // If a new console specified, redirect stdin/stdout/stderr to that.
111 111
112 if (console) { 112 if (console) {