diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-22 18:22:10 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-22 18:22:10 +0000 |
commit | baf55a85fc08ddad71b43a2348fd4f58338be83f (patch) | |
tree | 79f3dc09fb7bb5cfc43fc5698731bfa2906bf46f | |
parent | e3906fcd94f9ec7e58337d4241f6ffa95e4fd847 (diff) | |
download | busybox-w32-baf55a85fc08ddad71b43a2348fd4f58338be83f.tar.gz busybox-w32-baf55a85fc08ddad71b43a2348fd4f58338be83f.tar.bz2 busybox-w32-baf55a85fc08ddad71b43a2348fd4f58338be83f.zip |
Run through indent, fix comments
-rw-r--r-- | init/init.c | 265 | ||||
-rw-r--r-- | networking/ifconfig.c | 177 |
2 files changed, 230 insertions, 212 deletions
diff --git a/init/init.c b/init/init.c index 333fba5dc..569e7e460 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -55,36 +55,36 @@ | |||
55 | 55 | ||
56 | /* From <linux/vt.h> */ | 56 | /* From <linux/vt.h> */ |
57 | struct vt_stat { | 57 | struct vt_stat { |
58 | unsigned short v_active; /* active vt */ | 58 | unsigned short v_active; /* active vt */ |
59 | unsigned short v_signal; /* signal to send */ | 59 | unsigned short v_signal; /* signal to send */ |
60 | unsigned short v_state; /* vt bitmask */ | 60 | unsigned short v_state; /* vt bitmask */ |
61 | }; | 61 | }; |
62 | static const int VT_GETSTATE = 0x5603; /* get global vt state info */ | 62 | static const int VT_GETSTATE = 0x5603; /* get global vt state info */ |
63 | 63 | ||
64 | /* From <linux/serial.h> */ | 64 | /* From <linux/serial.h> */ |
65 | struct serial_struct { | 65 | struct serial_struct { |
66 | int type; | 66 | int type; |
67 | int line; | 67 | int line; |
68 | int port; | 68 | int port; |
69 | int irq; | 69 | int irq; |
70 | int flags; | 70 | int flags; |
71 | int xmit_fifo_size; | 71 | int xmit_fifo_size; |
72 | int custom_divisor; | 72 | int custom_divisor; |
73 | int baud_base; | 73 | int baud_base; |
74 | unsigned short close_delay; | 74 | unsigned short close_delay; |
75 | char reserved_char[2]; | 75 | char reserved_char[2]; |
76 | int hub6; | 76 | int hub6; |
77 | unsigned short closing_wait; /* time to wait before closing */ | 77 | unsigned short closing_wait; /* time to wait before closing */ |
78 | unsigned short closing_wait2; /* no longer used... */ | 78 | unsigned short closing_wait2; /* no longer used... */ |
79 | int reserved[4]; | 79 | int reserved[4]; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | #if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__) | 83 | #if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__) |
84 | #include <sys/reboot.h> | 84 | #include <sys/reboot.h> |
85 | #define init_reboot(magic) reboot(magic) | 85 | #define init_reboot(magic) reboot(magic) |
86 | #else | 86 | #else |
87 | #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic) | 87 | #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic) |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | #ifndef _PATH_STDPATH | 90 | #ifndef _PATH_STDPATH |
@@ -106,16 +106,16 @@ struct serial_struct { | |||
106 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) | 106 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
107 | 107 | ||
108 | #if __GNU_LIBRARY__ > 5 | 108 | #if __GNU_LIBRARY__ > 5 |
109 | #include <sys/kdaemon.h> | 109 | #include <sys/kdaemon.h> |
110 | #else | 110 | #else |
111 | extern int bdflush (int func, long int data); | 111 | extern int bdflush(int func, long int data); |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #define SHELL "/bin/sh" /* Default shell */ | 114 | #define SHELL "/bin/sh" /* Default shell */ |
115 | #define LOGIN_SHELL "-" SHELL /* Default login shell */ | 115 | #define LOGIN_SHELL "-" SHELL /* Default login shell */ |
116 | #define INITTAB "/etc/inittab" /* inittab file location */ | 116 | #define INITTAB "/etc/inittab" /* inittab file location */ |
117 | #ifndef INIT_SCRIPT | 117 | #ifndef INIT_SCRIPT |
118 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ | 118 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ |
119 | #endif | 119 | #endif |
120 | 120 | ||
121 | #define MAXENV 16 /* Number of env. vars */ | 121 | #define MAXENV 16 /* Number of env. vars */ |
@@ -159,15 +159,17 @@ struct init_action { | |||
159 | 159 | ||
160 | /* Static variables */ | 160 | /* Static variables */ |
161 | static struct init_action *init_action_list = NULL; | 161 | static struct init_action *init_action_list = NULL; |
162 | static int kernelVersion = 0; | 162 | static int kernelVersion = 0; |
163 | static char termType[32] = "TERM=linux"; | 163 | static char termType[32] = "TERM=linux"; |
164 | static char console[32] = _PATH_CONSOLE; | 164 | static char console[32] = _PATH_CONSOLE; |
165 | |||
165 | #ifndef CONFIG_SYSLOGD | 166 | #ifndef CONFIG_SYSLOGD |
166 | static char *log = VC_5; | 167 | static char *log = VC_5; |
167 | #endif | 168 | #endif |
168 | static sig_atomic_t got_cont = 0; | 169 | static sig_atomic_t got_cont = 0; |
169 | static const int LOG = 0x1; | 170 | static const int LOG = 0x1; |
170 | static const int CONSOLE = 0x2; | 171 | static const int CONSOLE = 0x2; |
172 | |||
171 | #if defined CONFIG_FEATURE_EXTRA_QUIET | 173 | #if defined CONFIG_FEATURE_EXTRA_QUIET |
172 | static const int MAYBE_CONSOLE = 0x0; | 174 | static const int MAYBE_CONSOLE = 0x0; |
173 | #else | 175 | #else |
@@ -177,6 +179,7 @@ static const int MAYBE_CONSOLE = 0x0; | |||
177 | static const int RB_HALT_SYSTEM = 0xcdef0123; | 179 | static const int RB_HALT_SYSTEM = 0xcdef0123; |
178 | static const int RB_ENABLE_CAD = 0x89abcdef; | 180 | static const int RB_ENABLE_CAD = 0x89abcdef; |
179 | static const int RB_DISABLE_CAD = 0; | 181 | static const int RB_DISABLE_CAD = 0; |
182 | |||
180 | #define RB_POWER_OFF 0x4321fedc | 183 | #define RB_POWER_OFF 0x4321fedc |
181 | static const int RB_AUTOBOOT = 0x01234567; | 184 | static const int RB_AUTOBOOT = 0x01234567; |
182 | #endif | 185 | #endif |
@@ -189,17 +192,20 @@ static int waitfor(struct init_action *a); | |||
189 | static void loop_forever(void) | 192 | static void loop_forever(void) |
190 | { | 193 | { |
191 | while (1) | 194 | while (1) |
192 | sleep (1); | 195 | sleep(1); |
193 | } | 196 | } |
194 | 197 | ||
195 | /* Print a message to the specified device. | 198 | /* Print a message to the specified device. |
196 | * Device may be bitwise-or'd from LOG | CONSOLE */ | 199 | * Device may be bitwise-or'd from LOG | CONSOLE */ |
197 | #ifdef DEBUG_INIT | 200 | #ifdef DEBUG_INIT |
198 | static inline messageND(int device, char *fmt, ...) { } | 201 | static inline messageND(int device, char *fmt, ...) |
199 | #else | 202 | { |
203 | } | ||
204 | #else | ||
200 | #define messageND message | 205 | #define messageND message |
201 | #endif | 206 | #endif |
202 | static void message(int device, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); | 207 | static void message(int device, char *fmt, ...) |
208 | __attribute__ ((format(printf, 2, 3))); | ||
203 | static void message(int device, char *fmt, ...) | 209 | static void message(int device, char *fmt, ...) |
204 | { | 210 | { |
205 | va_list arguments; | 211 | va_list arguments; |
@@ -222,7 +228,7 @@ static void message(int device, char *fmt, ...) | |||
222 | /* Take full control of the log tty, and never close it. | 228 | /* Take full control of the log tty, and never close it. |
223 | * It's mine, all mine! Muhahahaha! */ | 229 | * It's mine, all mine! Muhahahaha! */ |
224 | if (log_fd < 0) { | 230 | if (log_fd < 0) { |
225 | if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) { | 231 | if ((log_fd = device_open(log, O_RDWR | O_NDELAY)) < 0) { |
226 | log_fd = -2; | 232 | log_fd = -2; |
227 | fprintf(stderr, "Bummer, can't write to log on %s!\n", log); | 233 | fprintf(stderr, "Bummer, can't write to log on %s!\n", log); |
228 | device = CONSOLE; | 234 | device = CONSOLE; |
@@ -237,9 +243,9 @@ static void message(int device, char *fmt, ...) | |||
237 | 243 | ||
238 | if (device & CONSOLE) { | 244 | if (device & CONSOLE) { |
239 | /* Always send console messages to /dev/console so people will see them. */ | 245 | /* Always send console messages to /dev/console so people will see them. */ |
240 | if ( | 246 | if ((fd = |
241 | (fd = | 247 | device_open(_PATH_CONSOLE, |
242 | device_open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0) { | 248 | O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0) { |
243 | va_start(arguments, fmt); | 249 | va_start(arguments, fmt); |
244 | vdprintf(fd, fmt, arguments); | 250 | vdprintf(fd, fmt, arguments); |
245 | va_end(arguments); | 251 | va_end(arguments); |
@@ -261,21 +267,21 @@ static void set_term(int fd) | |||
261 | tcgetattr(fd, &tty); | 267 | tcgetattr(fd, &tty); |
262 | 268 | ||
263 | /* set control chars */ | 269 | /* set control chars */ |
264 | tty.c_cc[VINTR] = 3; /* C-c */ | 270 | tty.c_cc[VINTR] = 3; /* C-c */ |
265 | tty.c_cc[VQUIT] = 28; /* C-\ */ | 271 | tty.c_cc[VQUIT] = 28; /* C-\ */ |
266 | tty.c_cc[VERASE] = 127; /* C-? */ | 272 | tty.c_cc[VERASE] = 127; /* C-? */ |
267 | tty.c_cc[VKILL] = 21; /* C-u */ | 273 | tty.c_cc[VKILL] = 21; /* C-u */ |
268 | tty.c_cc[VEOF] = 4; /* C-d */ | 274 | tty.c_cc[VEOF] = 4; /* C-d */ |
269 | tty.c_cc[VSTART] = 17; /* C-q */ | 275 | tty.c_cc[VSTART] = 17; /* C-q */ |
270 | tty.c_cc[VSTOP] = 19; /* C-s */ | 276 | tty.c_cc[VSTOP] = 19; /* C-s */ |
271 | tty.c_cc[VSUSP] = 26; /* C-z */ | 277 | tty.c_cc[VSUSP] = 26; /* C-z */ |
272 | 278 | ||
273 | /* use line dicipline 0 */ | 279 | /* use line dicipline 0 */ |
274 | tty.c_line = 0; | 280 | tty.c_line = 0; |
275 | 281 | ||
276 | /* Make it be sane */ | 282 | /* Make it be sane */ |
277 | tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | 283 | tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD; |
278 | tty.c_cflag |= CREAD|HUPCL|CLOCAL; | 284 | tty.c_cflag |= CREAD | HUPCL | CLOCAL; |
279 | 285 | ||
280 | 286 | ||
281 | /* input modes */ | 287 | /* input modes */ |
@@ -296,7 +302,7 @@ static void set_term(int fd) | |||
296 | static int check_free_memory(void) | 302 | static int check_free_memory(void) |
297 | { | 303 | { |
298 | struct sysinfo info; | 304 | struct sysinfo info; |
299 | unsigned int result, u, s=10; | 305 | unsigned int result, u, s = 10; |
300 | 306 | ||
301 | if (sysinfo(&info) != 0) { | 307 | if (sysinfo(&info) != 0) { |
302 | perror_msg("Error checking free memory"); | 308 | perror_msg("Error checking free memory"); |
@@ -306,11 +312,16 @@ static int check_free_memory(void) | |||
306 | /* Kernels 2.0.x and 2.2.x return info.mem_unit==0 with values in bytes. | 312 | /* Kernels 2.0.x and 2.2.x return info.mem_unit==0 with values in bytes. |
307 | * Kernels 2.4.0 return info.mem_unit in bytes. */ | 313 | * Kernels 2.4.0 return info.mem_unit in bytes. */ |
308 | u = info.mem_unit; | 314 | u = info.mem_unit; |
309 | if (u==0) u=1; | 315 | if (u == 0) |
310 | while ( (u&1) == 0 && s > 0 ) { u>>=1; s--; } | 316 | u = 1; |
311 | result = (info.totalram>>s) + (info.totalswap>>s); | 317 | while ((u & 1) == 0 && s > 0) { |
312 | result = result*u; | 318 | u >>= 1; |
313 | if (result < 0) result = INT_MAX; | 319 | s--; |
320 | } | ||
321 | result = (info.totalram >> s) + (info.totalswap >> s); | ||
322 | result = result * u; | ||
323 | if (result < 0) | ||
324 | result = INT_MAX; | ||
314 | return result; | 325 | return result; |
315 | } | 326 | } |
316 | 327 | ||
@@ -378,17 +389,18 @@ static void console_init(void) | |||
378 | if (ioctl(0, TIOCGSERIAL, &sr) == 0) { | 389 | if (ioctl(0, TIOCGSERIAL, &sr) == 0) { |
379 | /* Force the TERM setting to vt102 for serial console -- | 390 | /* Force the TERM setting to vt102 for serial console -- |
380 | * if TERM is set to linux (the default) */ | 391 | * if TERM is set to linux (the default) */ |
381 | if (strcmp( termType, "TERM=linux" ) == 0) | 392 | if (strcmp(termType, "TERM=linux") == 0) |
382 | safe_strncpy(termType, "TERM=vt102", sizeof(termType)); | 393 | safe_strncpy(termType, "TERM=vt102", sizeof(termType)); |
383 | } | 394 | } |
384 | close(fd); | 395 | close(fd); |
385 | } | 396 | } |
386 | message(LOG, "console=%s\n", console); | 397 | message(LOG, "console=%s\n", console); |
387 | } | 398 | } |
388 | 399 | ||
389 | static void fixup_argv(int argc, char **argv, char *new_argv0) | 400 | static void fixup_argv(int argc, char **argv, char *new_argv0) |
390 | { | 401 | { |
391 | int len; | 402 | int len; |
403 | |||
392 | /* Fix up argv[0] to be certain we claim to be init */ | 404 | /* Fix up argv[0] to be certain we claim to be init */ |
393 | len = strlen(argv[0]); | 405 | len = strlen(argv[0]); |
394 | memset(argv[0], 0, len); | 406 | memset(argv[0], 0, len); |
@@ -425,8 +437,7 @@ static void check_memory(void) | |||
425 | #endif | 437 | #endif |
426 | 438 | ||
427 | goodnight: | 439 | goodnight: |
428 | message(CONSOLE, | 440 | message(CONSOLE, "\rSorry, your computer does not have enough memory.\n"); |
429 | "\rSorry, your computer does not have enough memory.\n"); | ||
430 | loop_forever(); | 441 | loop_forever(); |
431 | } | 442 | } |
432 | 443 | ||
@@ -436,9 +447,9 @@ static pid_t run(struct init_action *a) | |||
436 | int i, j, junk; | 447 | int i, j, junk; |
437 | pid_t pid, pgrp, tmp_pid; | 448 | pid_t pid, pgrp, tmp_pid; |
438 | char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath; | 449 | char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath; |
439 | char buf[INIT_BUFFS_SIZE+6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ | 450 | char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ |
440 | sigset_t nmask, omask; | 451 | sigset_t nmask, omask; |
441 | char *environment[MAXENV+1] = { | 452 | char *environment[MAXENV + 1] = { |
442 | termType, | 453 | termType, |
443 | "HOME=/", | 454 | "HOME=/", |
444 | "PATH=" _PATH_STDPATH, | 455 | "PATH=" _PATH_STDPATH, |
@@ -453,8 +464,8 @@ static pid_t run(struct init_action *a) | |||
453 | "\nPlease press Enter to activate this console. "; | 464 | "\nPlease press Enter to activate this console. "; |
454 | 465 | ||
455 | /* inherit environment to the child, merging our values -andy */ | 466 | /* inherit environment to the child, merging our values -andy */ |
456 | for (i=0; environ[i]; i++) { | 467 | for (i = 0; environ[i]; i++) { |
457 | for (j=0; environment[j]; j++) { | 468 | for (j = 0; environment[j]; j++) { |
458 | s = strchr(environment[j], '='); | 469 | s = strchr(environment[j], '='); |
459 | if (!strncmp(environ[i], environment[j], s - environment[j])) | 470 | if (!strncmp(environ[i], environment[j], s - environment[j])) |
460 | break; | 471 | break; |
@@ -470,8 +481,7 @@ static pid_t run(struct init_action *a) | |||
470 | sigaddset(&nmask, SIGCHLD); | 481 | sigaddset(&nmask, SIGCHLD); |
471 | sigprocmask(SIG_BLOCK, &nmask, &omask); | 482 | sigprocmask(SIG_BLOCK, &nmask, &omask); |
472 | 483 | ||
473 | if ((pid = fork()) == 0) | 484 | if ((pid = fork()) == 0) { |
474 | { | ||
475 | /* Clean up */ | 485 | /* Clean up */ |
476 | close(0); | 486 | close(0); |
477 | close(1); | 487 | close(1); |
@@ -481,20 +491,20 @@ static pid_t run(struct init_action *a) | |||
481 | /* Reset signal handlers that were set by the parent process */ | 491 | /* Reset signal handlers that were set by the parent process */ |
482 | signal(SIGUSR1, SIG_DFL); | 492 | signal(SIGUSR1, SIG_DFL); |
483 | signal(SIGUSR2, SIG_DFL); | 493 | signal(SIGUSR2, SIG_DFL); |
484 | signal(SIGINT, SIG_DFL); | 494 | signal(SIGINT, SIG_DFL); |
485 | signal(SIGTERM, SIG_DFL); | 495 | signal(SIGTERM, SIG_DFL); |
486 | signal(SIGHUP, SIG_DFL); | 496 | signal(SIGHUP, SIG_DFL); |
487 | signal(SIGCONT, SIG_DFL); | 497 | signal(SIGCONT, SIG_DFL); |
488 | signal(SIGSTOP, SIG_DFL); | 498 | signal(SIGSTOP, SIG_DFL); |
489 | signal(SIGTSTP, SIG_DFL); | 499 | signal(SIGTSTP, SIG_DFL); |
490 | 500 | ||
491 | /* Create a new session and make ourself the process | 501 | /* Create a new session and make ourself the process |
492 | * group leader for non-interactive jobs */ | 502 | * group leader for non-interactive jobs */ |
493 | if ((a->action & (RESPAWN))==0) | 503 | if ((a->action & (RESPAWN)) == 0) |
494 | setsid(); | 504 | setsid(); |
495 | 505 | ||
496 | /* Open the new terminal device */ | 506 | /* Open the new terminal device */ |
497 | if ((device_open(a->terminal, O_RDWR|O_NOCTTY)) < 0) { | 507 | if ((device_open(a->terminal, O_RDWR | O_NOCTTY)) < 0) { |
498 | if (stat(a->terminal, &sb) != 0) { | 508 | if (stat(a->terminal, &sb) != 0) { |
499 | message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n", | 509 | message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n", |
500 | a->terminal); | 510 | a->terminal); |
@@ -505,8 +515,8 @@ static pid_t run(struct init_action *a) | |||
505 | } | 515 | } |
506 | 516 | ||
507 | /* Non-interactive jobs should not get a controling tty */ | 517 | /* Non-interactive jobs should not get a controling tty */ |
508 | if ((a->action & (RESPAWN))==0) | 518 | if ((a->action & (RESPAWN)) == 0) |
509 | (void)ioctl(0, TIOCSCTTY, 0); | 519 | (void) ioctl(0, TIOCSCTTY, 0); |
510 | 520 | ||
511 | /* Make sure the terminal will act fairly normal for us */ | 521 | /* Make sure the terminal will act fairly normal for us */ |
512 | set_term(0); | 522 | set_term(0); |
@@ -522,7 +532,7 @@ static pid_t run(struct init_action *a) | |||
522 | 532 | ||
523 | /* If the init Action requires us to wait, then force the | 533 | /* If the init Action requires us to wait, then force the |
524 | * supplied terminal to be the controlling tty. */ | 534 | * supplied terminal to be the controlling tty. */ |
525 | if (a->action & (SYSINIT|WAIT|CTRLALTDEL|SHUTDOWN|RESTART)) { | 535 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { |
526 | 536 | ||
527 | /* Now fork off another process to just hang around */ | 537 | /* Now fork off another process to just hang around */ |
528 | if ((pid = fork()) < 0) { | 538 | if ((pid = fork()) < 0) { |
@@ -539,8 +549,7 @@ static pid_t run(struct init_action *a) | |||
539 | signal(SIGCHLD, SIG_DFL); | 549 | signal(SIGCHLD, SIG_DFL); |
540 | 550 | ||
541 | /* Wait for child to exit */ | 551 | /* Wait for child to exit */ |
542 | while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) | 552 | while ((tmp_pid = waitpid(pid, &junk, 0)) != pid); |
543 | ; | ||
544 | 553 | ||
545 | /* See if stealing the controlling tty back is necessary */ | 554 | /* See if stealing the controlling tty back is necessary */ |
546 | pgrp = tcgetpgrp(0); | 555 | pgrp = tcgetpgrp(0); |
@@ -551,13 +560,13 @@ static pid_t run(struct init_action *a) | |||
551 | if ((pid = fork()) < 0) { | 560 | if ((pid = fork()) < 0) { |
552 | message(LOG | CONSOLE, "\rCan't fork!\n"); | 561 | message(LOG | CONSOLE, "\rCan't fork!\n"); |
553 | _exit(1); | 562 | _exit(1); |
554 | } | 563 | } |
555 | if (pid == 0) { | 564 | if (pid == 0) { |
556 | setsid(); | 565 | setsid(); |
557 | ioctl(0, TIOCSCTTY, 1); | 566 | ioctl(0, TIOCSCTTY, 1); |
558 | _exit(0); | 567 | _exit(0); |
559 | } | 568 | } |
560 | while((tmp_pid = waitpid(pid, &junk, 0)) != pid) { | 569 | while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) { |
561 | if (tmp_pid < 0 && errno == ECHILD) | 570 | if (tmp_pid < 0 && errno == ECHILD) |
562 | break; | 571 | break; |
563 | } | 572 | } |
@@ -578,8 +587,7 @@ static pid_t run(struct init_action *a) | |||
578 | /* Convert command (char*) into cmd (char**, one word per string) */ | 587 | /* Convert command (char*) into cmd (char**, one word per string) */ |
579 | strcpy(buf, a->command); | 588 | strcpy(buf, a->command); |
580 | s = buf; | 589 | s = buf; |
581 | for (tmpCmd = buf, i = 0; | 590 | for (tmpCmd = buf, i = 0; (tmpCmd = strsep(&s, " \t")) != NULL;) { |
582 | (tmpCmd = strsep(&s, " \t")) != NULL;) { | ||
583 | if (*tmpCmd != '\0') { | 591 | if (*tmpCmd != '\0') { |
584 | cmd[i] = tmpCmd; | 592 | cmd[i] = tmpCmd; |
585 | i++; | 593 | i++; |
@@ -606,12 +614,12 @@ static pid_t run(struct init_action *a) | |||
606 | s = get_last_path_component(cmdpath); | 614 | s = get_last_path_component(cmdpath); |
607 | 615 | ||
608 | /* make a new argv[0] */ | 616 | /* make a new argv[0] */ |
609 | if ((cmd[0] = malloc(strlen(s)+2)) == NULL) { | 617 | if ((cmd[0] = malloc(strlen(s) + 2)) == NULL) { |
610 | message(LOG | CONSOLE, "malloc failed"); | 618 | message(LOG | CONSOLE, "malloc failed"); |
611 | cmd[0] = cmdpath; | 619 | cmd[0] = cmdpath; |
612 | } else { | 620 | } else { |
613 | cmd[0][0] = '-'; | 621 | cmd[0][0] = '-'; |
614 | strcpy(cmd[0]+1, s); | 622 | strcpy(cmd[0] + 1, s); |
615 | } | 623 | } |
616 | } | 624 | } |
617 | 625 | ||
@@ -624,19 +632,21 @@ static pid_t run(struct init_action *a) | |||
624 | * be allowed to start a shell or whatever an init script | 632 | * be allowed to start a shell or whatever an init script |
625 | * specifies. | 633 | * specifies. |
626 | */ | 634 | */ |
627 | messageND(LOG, "Waiting for enter to start '%s' (pid %d, terminal %s)\n", | 635 | messageND(LOG, |
628 | cmdpath, getpid(), a->terminal); | 636 | "Waiting for enter to start '%s' (pid %d, terminal %s)\n", |
637 | cmdpath, getpid(), a->terminal); | ||
629 | write(fileno(stdout), press_enter, sizeof(press_enter) - 1); | 638 | write(fileno(stdout), press_enter, sizeof(press_enter) - 1); |
630 | getc(stdin); | 639 | getc(stdin); |
631 | } | 640 | } |
632 | 641 | ||
633 | /* Log the process name and args */ | 642 | /* Log the process name and args */ |
634 | messageND(LOG, "Starting pid %d, console %s: '%s'\n", | 643 | messageND(LOG, "Starting pid %d, console %s: '%s'\n", |
635 | getpid(), a->terminal, cmdpath); | 644 | getpid(), a->terminal, cmdpath); |
636 | 645 | ||
637 | #if defined CONFIG_FEATURE_INIT_COREDUMPS | 646 | #if defined CONFIG_FEATURE_INIT_COREDUMPS |
638 | if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) { | 647 | if (stat(CORE_ENABLE_FLAG_FILE, &sb) == 0) { |
639 | struct rlimit limit; | 648 | struct rlimit limit; |
649 | |||
640 | limit.rlim_cur = RLIM_INFINITY; | 650 | limit.rlim_cur = RLIM_INFINITY; |
641 | limit.rlim_max = RLIM_INFINITY; | 651 | limit.rlim_max = RLIM_INFINITY; |
642 | setrlimit(RLIMIT_CORE, &limit); | 652 | setrlimit(RLIMIT_CORE, &limit); |
@@ -658,7 +668,7 @@ static pid_t run(struct init_action *a) | |||
658 | 668 | ||
659 | static int waitfor(struct init_action *a) | 669 | static int waitfor(struct init_action *a) |
660 | { | 670 | { |
661 | int pid; | 671 | int pid; |
662 | int status, wpid; | 672 | int status, wpid; |
663 | 673 | ||
664 | pid = run(a); | 674 | pid = run(a); |
@@ -681,13 +691,14 @@ static void run_actions(int action) | |||
681 | for (a = init_action_list; a; a = tmp) { | 691 | for (a = init_action_list; a; a = tmp) { |
682 | tmp = a->next; | 692 | tmp = a->next; |
683 | if (a->action == action) { | 693 | if (a->action == action) { |
684 | if (a->action & (SYSINIT|WAIT|CTRLALTDEL|SHUTDOWN|RESTART)) { | 694 | if (a-> |
695 | action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { | ||
685 | waitfor(a); | 696 | waitfor(a); |
686 | delete_init_action(a); | 697 | delete_init_action(a); |
687 | } else if (a->action & ONCE) { | 698 | } else if (a->action & ONCE) { |
688 | run(a); | 699 | run(a); |
689 | delete_init_action(a); | 700 | delete_init_action(a); |
690 | } else if (a->action & (RESPAWN|ASKFIRST)) { | 701 | } else if (a->action & (RESPAWN | ASKFIRST)) { |
691 | /* Only run stuff with pid==0. If they have | 702 | /* Only run stuff with pid==0. If they have |
692 | * a pid, that means it is still running */ | 703 | * a pid, that means it is still running */ |
693 | if (a->pid == 0) { | 704 | if (a->pid == 0) { |
@@ -720,16 +731,16 @@ static void shutdown_system(void) | |||
720 | /* Allow Ctrl-Alt-Del to reboot system. */ | 731 | /* Allow Ctrl-Alt-Del to reboot system. */ |
721 | init_reboot(RB_ENABLE_CAD); | 732 | init_reboot(RB_ENABLE_CAD); |
722 | 733 | ||
723 | message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n"); | 734 | message(CONSOLE | LOG, "\n\rThe system is going down NOW !!\n"); |
724 | sync(); | 735 | sync(); |
725 | 736 | ||
726 | /* Send signals to every process _except_ pid 1 */ | 737 | /* Send signals to every process _except_ pid 1 */ |
727 | message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n"); | 738 | message(CONSOLE | LOG, "\rSending SIGTERM to all processes.\n"); |
728 | kill(-1, SIGTERM); | 739 | kill(-1, SIGTERM); |
729 | sleep(1); | 740 | sleep(1); |
730 | sync(); | 741 | sync(); |
731 | 742 | ||
732 | message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n"); | 743 | message(CONSOLE | LOG, "\rSending SIGKILL to all processes.\n"); |
733 | kill(-1, SIGKILL); | 744 | kill(-1, SIGKILL); |
734 | sleep(1); | 745 | sleep(1); |
735 | 746 | ||
@@ -737,7 +748,7 @@ static void shutdown_system(void) | |||
737 | run_actions(SHUTDOWN); | 748 | run_actions(SHUTDOWN); |
738 | 749 | ||
739 | sync(); | 750 | sync(); |
740 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) { | 751 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2, 2, 11)) { |
741 | /* bdflush, kupdate not needed for kernels >2.2.11 */ | 752 | /* bdflush, kupdate not needed for kernels >2.2.11 */ |
742 | bdflush(1, 0); | 753 | bdflush(1, 0); |
743 | sync(); | 754 | sync(); |
@@ -748,7 +759,7 @@ static void exec_signal(int sig) | |||
748 | { | 759 | { |
749 | struct init_action *a, *tmp; | 760 | struct init_action *a, *tmp; |
750 | sigset_t unblock_signals; | 761 | sigset_t unblock_signals; |
751 | 762 | ||
752 | for (a = init_action_list; a; a = tmp) { | 763 | for (a = init_action_list; a; a = tmp) { |
753 | tmp = a->next; | 764 | tmp = a->next; |
754 | if (a->action & RESTART) { | 765 | if (a->action & RESTART) { |
@@ -767,11 +778,11 @@ static void exec_signal(int sig) | |||
767 | sigaddset(&unblock_signals, SIGTSTP); | 778 | sigaddset(&unblock_signals, SIGTSTP); |
768 | sigprocmask(SIG_UNBLOCK, &unblock_signals, NULL); | 779 | sigprocmask(SIG_UNBLOCK, &unblock_signals, NULL); |
769 | 780 | ||
770 | message(CONSOLE|LOG, "\rTrying to re-exec %s\n", a->command); | 781 | message(CONSOLE | LOG, "\rTrying to re-exec %s\n", a->command); |
771 | execl(a->command, a->command, NULL); | 782 | execl(a->command, a->command, NULL); |
772 | 783 | ||
773 | message(CONSOLE|LOG, "\rexec of '%s' failed: %s\n", | 784 | message(CONSOLE | LOG, "\rexec of '%s' failed: %s\n", |
774 | a->command, sys_errlist[errno]); | 785 | a->command, sys_errlist[errno]); |
775 | sync(); | 786 | sync(); |
776 | sleep(2); | 787 | sleep(2); |
777 | init_reboot(RB_HALT_SYSTEM); | 788 | init_reboot(RB_HALT_SYSTEM); |
@@ -783,20 +794,20 @@ static void exec_signal(int sig) | |||
783 | static void halt_signal(int sig) | 794 | static void halt_signal(int sig) |
784 | { | 795 | { |
785 | shutdown_system(); | 796 | shutdown_system(); |
786 | message(CONSOLE|LOG, | 797 | message(CONSOLE | LOG, |
787 | #if #cpu(s390) | 798 | #if #cpu(s390) |
788 | /* Seems the s390 console is Wierd(tm). */ | 799 | /* Seems the s390 console is Wierd(tm). */ |
789 | "\rThe system is halted. You may reboot now.\n" | 800 | "\rThe system is halted. You may reboot now.\n" |
790 | #else | 801 | #else |
791 | "\rThe system is halted. Press Reset or turn off power\n" | 802 | "\rThe system is halted. Press Reset or turn off power\n" |
792 | #endif | 803 | #endif |
793 | ); | 804 | ); |
794 | sync(); | 805 | sync(); |
795 | 806 | ||
796 | /* allow time for last message to reach serial console */ | 807 | /* allow time for last message to reach serial console */ |
797 | sleep(2); | 808 | sleep(2); |
798 | 809 | ||
799 | if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0)) | 810 | if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2, 2, 0)) |
800 | init_reboot(RB_POWER_OFF); | 811 | init_reboot(RB_POWER_OFF); |
801 | else | 812 | else |
802 | init_reboot(RB_HALT_SYSTEM); | 813 | init_reboot(RB_HALT_SYSTEM); |
@@ -807,7 +818,7 @@ static void halt_signal(int sig) | |||
807 | static void reboot_signal(int sig) | 818 | static void reboot_signal(int sig) |
808 | { | 819 | { |
809 | shutdown_system(); | 820 | shutdown_system(); |
810 | message(CONSOLE|LOG, "\rPlease stand by while rebooting the system.\n"); | 821 | message(CONSOLE | LOG, "\rPlease stand by while rebooting the system.\n"); |
811 | sync(); | 822 | sync(); |
812 | 823 | ||
813 | /* allow time for last message to reach serial console */ | 824 | /* allow time for last message to reach serial console */ |
@@ -829,12 +840,13 @@ static void stop_handler(int sig) | |||
829 | int saved_errno = errno; | 840 | int saved_errno = errno; |
830 | 841 | ||
831 | got_cont = 0; | 842 | got_cont = 0; |
832 | while(!got_cont) pause(); | 843 | while (!got_cont) |
844 | pause(); | ||
833 | got_cont = 0; | 845 | got_cont = 0; |
834 | errno = saved_errno; | 846 | errno = saved_errno; |
835 | } | 847 | } |
836 | 848 | ||
837 | /* The SIGCONT handler */ | 849 | /* The SIGCONT handler */ |
838 | static void cont_handler(int sig) | 850 | static void cont_handler(int sig) |
839 | { | 851 | { |
840 | got_cont = 1; | 852 | got_cont = 1; |
@@ -850,7 +862,7 @@ static void new_init_action(int action, char *command, char *cons) | |||
850 | cons = console; | 862 | cons = console; |
851 | 863 | ||
852 | /* do not run entries if console device is not available */ | 864 | /* do not run entries if console device is not available */ |
853 | if (access(cons, R_OK|W_OK)) | 865 | if (access(cons, R_OK | W_OK)) |
854 | return; | 866 | return; |
855 | if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST)) | 867 | if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST)) |
856 | return; | 868 | return; |
@@ -862,7 +874,7 @@ static void new_init_action(int action, char *command, char *cons) | |||
862 | } | 874 | } |
863 | 875 | ||
864 | /* Append to the end of the list */ | 876 | /* Append to the end of the list */ |
865 | for (a = init_action_list; a && a->next; a = a->next) ; | 877 | for (a = init_action_list; a && a->next; a = a->next); |
866 | if (a) { | 878 | if (a) { |
867 | a->next = new_action; | 879 | a->next = new_action; |
868 | } else { | 880 | } else { |
@@ -872,11 +884,11 @@ static void new_init_action(int action, char *command, char *cons) | |||
872 | new_action->action = action; | 884 | new_action->action = action; |
873 | strcpy(new_action->terminal, cons); | 885 | strcpy(new_action->terminal, cons); |
874 | new_action->pid = 0; | 886 | new_action->pid = 0; |
875 | // message(LOG|CONSOLE, "command='%s' action='%d' terminal='%s'\n", | 887 | /* message(LOG|CONSOLE, "command='%s' action='%d' terminal='%s'\n", |
876 | // new_action->command, new_action->action, new_action->terminal); | 888 | new_action->command, new_action->action, new_action->terminal); */ |
877 | } | 889 | } |
878 | 890 | ||
879 | static void delete_init_action(struct init_action * action) | 891 | static void delete_init_action(struct init_action *action) |
880 | { | 892 | { |
881 | struct init_action *a, *b = NULL; | 893 | struct init_action *a, *b = NULL; |
882 | 894 | ||
@@ -899,12 +911,13 @@ static void delete_init_action(struct init_action * action) | |||
899 | * of "askfirst" shells). If CONFIG_FEATURE_USE_INITTAB | 911 | * of "askfirst" shells). If CONFIG_FEATURE_USE_INITTAB |
900 | * _is_ defined, but /etc/inittab is missing, this | 912 | * _is_ defined, but /etc/inittab is missing, this |
901 | * results in the same set of default behaviors. | 913 | * results in the same set of default behaviors. |
902 | * */ | 914 | */ |
903 | static void parse_inittab(void) | 915 | static void parse_inittab(void) |
904 | { | 916 | { |
905 | #ifdef CONFIG_FEATURE_USE_INITTAB | 917 | #ifdef CONFIG_FEATURE_USE_INITTAB |
906 | FILE *file; | 918 | FILE *file; |
907 | char buf[INIT_BUFFS_SIZE], lineAsRead[INIT_BUFFS_SIZE], tmpConsole[INIT_BUFFS_SIZE]; | 919 | char buf[INIT_BUFFS_SIZE], lineAsRead[INIT_BUFFS_SIZE], |
920 | tmpConsole[INIT_BUFFS_SIZE]; | ||
908 | char *id, *runlev, *action, *command, *eol; | 921 | char *id, *runlev, *action, *command, *eol; |
909 | const struct init_action_type *a = actions; | 922 | const struct init_action_type *a = actions; |
910 | int foundIt; | 923 | int foundIt; |
@@ -989,7 +1002,7 @@ static void parse_inittab(void) | |||
989 | if (strcmp(a->name, action) == 0) { | 1002 | if (strcmp(a->name, action) == 0) { |
990 | if (*id != '\0') { | 1003 | if (*id != '\0') { |
991 | strcpy(tmpConsole, "/dev/"); | 1004 | strcpy(tmpConsole, "/dev/"); |
992 | strncat(tmpConsole, id, INIT_BUFFS_SIZE-6); | 1005 | strncat(tmpConsole, id, INIT_BUFFS_SIZE - 6); |
993 | id = tmpConsole; | 1006 | id = tmpConsole; |
994 | } | 1007 | } |
995 | new_init_action(a->action, command, id); | 1008 | new_init_action(a->action, command, id); |
@@ -1006,7 +1019,7 @@ static void parse_inittab(void) | |||
1006 | } | 1019 | } |
1007 | fclose(file); | 1020 | fclose(file); |
1008 | return; | 1021 | return; |
1009 | #endif /* CONFIG_FEATURE_USE_INITTAB */ | 1022 | #endif /* CONFIG_FEATURE_USE_INITTAB */ |
1010 | } | 1023 | } |
1011 | 1024 | ||
1012 | 1025 | ||
@@ -1020,31 +1033,30 @@ extern int init_main(int argc, char **argv) | |||
1020 | if (argc > 1 && !strcmp(argv[1], "-q")) { | 1033 | if (argc > 1 && !strcmp(argv[1], "-q")) { |
1021 | /* don't assume init's pid == 1 */ | 1034 | /* don't assume init's pid == 1 */ |
1022 | long *pid = find_pid_by_name("init"); | 1035 | long *pid = find_pid_by_name("init"); |
1023 | if (!pid || *pid<=0) { | 1036 | |
1037 | if (!pid || *pid <= 0) { | ||
1024 | pid = find_pid_by_name("linuxrc"); | 1038 | pid = find_pid_by_name("linuxrc"); |
1025 | if (!pid || *pid<=0) | 1039 | if (!pid || *pid <= 0) |
1026 | error_msg_and_die("no process killed"); | 1040 | error_msg_and_die("no process killed"); |
1027 | } | 1041 | } |
1028 | kill(*pid, SIGHUP); | 1042 | kill(*pid, SIGHUP); |
1029 | exit(0); | 1043 | exit(0); |
1030 | } | 1044 | } |
1031 | |||
1032 | #ifndef DEBUG_INIT | 1045 | #ifndef DEBUG_INIT |
1033 | /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ | 1046 | /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ |
1034 | if (getpid() != 1 | 1047 | if (getpid() != 1 |
1035 | #ifdef CONFIG_FEATURE_INITRD | 1048 | #ifdef CONFIG_FEATURE_INITRD |
1036 | && strstr(applet_name, "linuxrc") == NULL | 1049 | && strstr(applet_name, "linuxrc") == NULL |
1037 | #endif | 1050 | #endif |
1038 | ) | 1051 | ) { |
1039 | { | 1052 | show_usage(); |
1040 | show_usage(); | ||
1041 | } | 1053 | } |
1042 | /* Set up sig handlers -- be sure to | 1054 | /* Set up sig handlers -- be sure to |
1043 | * clear all of these in run() */ | 1055 | * clear all of these in run() */ |
1044 | signal(SIGHUP, exec_signal); | 1056 | signal(SIGHUP, exec_signal); |
1045 | signal(SIGUSR1, halt_signal); | 1057 | signal(SIGUSR1, halt_signal); |
1046 | signal(SIGUSR2, halt_signal); | 1058 | signal(SIGUSR2, halt_signal); |
1047 | signal(SIGINT, ctrlaltdel_signal); | 1059 | signal(SIGINT, ctrlaltdel_signal); |
1048 | signal(SIGTERM, reboot_signal); | 1060 | signal(SIGTERM, reboot_signal); |
1049 | signal(SIGCONT, cont_handler); | 1061 | signal(SIGCONT, cont_handler); |
1050 | signal(SIGSTOP, stop_handler); | 1062 | signal(SIGSTOP, stop_handler); |
@@ -1066,8 +1078,8 @@ extern int init_main(int argc, char **argv) | |||
1066 | close(1); | 1078 | close(1); |
1067 | close(2); | 1079 | close(2); |
1068 | 1080 | ||
1069 | if(device_open(console, O_RDWR|O_NOCTTY)==0) { | 1081 | if (device_open(console, O_RDWR | O_NOCTTY) == 0) { |
1070 | set_term(0); | 1082 | set_term(0); |
1071 | close(0); | 1083 | close(0); |
1072 | } | 1084 | } |
1073 | 1085 | ||
@@ -1075,10 +1087,10 @@ extern int init_main(int argc, char **argv) | |||
1075 | setsid(); | 1087 | setsid(); |
1076 | 1088 | ||
1077 | /* Make sure PATH is set to something sane */ | 1089 | /* Make sure PATH is set to something sane */ |
1078 | putenv("PATH="_PATH_STDPATH); | 1090 | putenv("PATH=" _PATH_STDPATH); |
1079 | 1091 | ||
1080 | /* Hello world */ | 1092 | /* Hello world */ |
1081 | message(MAYBE_CONSOLE|LOG, "\rinit started: %s\n", full_version); | 1093 | message(MAYBE_CONSOLE | LOG, "\rinit started: %s\n", full_version); |
1082 | 1094 | ||
1083 | /* Make sure there is enough memory to do something useful. */ | 1095 | /* Make sure there is enough memory to do something useful. */ |
1084 | check_memory(); | 1096 | check_memory(); |
@@ -1118,7 +1130,8 @@ extern int init_main(int argc, char **argv) | |||
1118 | 1130 | ||
1119 | /* If there is nothing else to do, stop */ | 1131 | /* If there is nothing else to do, stop */ |
1120 | if (init_action_list == NULL) { | 1132 | if (init_action_list == NULL) { |
1121 | message(LOG | CONSOLE, "\rNo more tasks for init -- sleeping forever.\n"); | 1133 | message(LOG | CONSOLE, |
1134 | "\rNo more tasks for init -- sleeping forever.\n"); | ||
1122 | loop_forever(); | 1135 | loop_forever(); |
1123 | } | 1136 | } |
1124 | 1137 | ||
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 3ada4f178..513f176d1 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: ifconfig.c,v 1.18 2002/07/11 11:11:52 andersen Exp $ | 18 | * $Id: ifconfig.c,v 1.19 2002/08/22 18:22:10 bug1 Exp $ |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
@@ -34,9 +34,9 @@ | |||
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | #include <string.h> // strcmp and friends | 37 | #include <string.h> /* strcmp and friends */ |
38 | #include <ctype.h> // isdigit and friends | 38 | #include <ctype.h> /* isdigit and friends */ |
39 | #include <stddef.h> /* offsetof */ | 39 | #include <stddef.h> /* offsetof */ |
40 | #include <sys/ioctl.h> | 40 | #include <sys/ioctl.h> |
41 | #include <net/if_arp.h> | 41 | #include <net/if_arp.h> |
42 | #include <netinet/in.h> | 42 | #include <netinet/in.h> |
@@ -65,14 +65,14 @@ | |||
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifndef IFF_DYNAMIC | 67 | #ifndef IFF_DYNAMIC |
68 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */ | 68 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */ |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #if CONFIG_FEATURE_IPV6 | 71 | #if CONFIG_FEATURE_IPV6 |
72 | struct in6_ifreq { | 72 | struct in6_ifreq { |
73 | struct in6_addr ifr6_addr; | 73 | struct in6_addr ifr6_addr; |
74 | uint32_t ifr6_prefixlen; | 74 | uint32_t ifr6_prefixlen; |
75 | int ifr6_ifindex; | 75 | int ifr6_ifindex; |
76 | }; | 76 | }; |
77 | #endif | 77 | #endif |
78 | 78 | ||
@@ -177,70 +177,70 @@ struct options { | |||
177 | #define ifreq_offsetof(x) offsetof(struct ifreq, x) | 177 | #define ifreq_offsetof(x) offsetof(struct ifreq, x) |
178 | 178 | ||
179 | static const struct arg1opt Arg1Opt[] = { | 179 | static const struct arg1opt Arg1Opt[] = { |
180 | {"SIOCSIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric)}, | 180 | {"SIOCSIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric)}, |
181 | {"SIOCSIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu)}, | 181 | {"SIOCSIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu)}, |
182 | {"SIOCSIFTXQLEN", SIOCSIFTXQLEN, ifreq_offsetof(ifr_qlen)}, | 182 | {"SIOCSIFTXQLEN", SIOCSIFTXQLEN, ifreq_offsetof(ifr_qlen)}, |
183 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, | 183 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
184 | {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)}, | 184 | {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)}, |
185 | {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)}, | 185 | {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)}, |
186 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 186 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
187 | {"SIOCSIFHWADDR", SIOCSIFHWADDR, ifreq_offsetof(ifr_hwaddr)}, | 187 | {"SIOCSIFHWADDR", SIOCSIFHWADDR, ifreq_offsetof(ifr_hwaddr)}, |
188 | #endif | 188 | #endif |
189 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, | 189 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
190 | #ifdef SIOCSKEEPALIVE | 190 | #ifdef SIOCSKEEPALIVE |
191 | {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)}, | 191 | {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)}, |
192 | #endif | 192 | #endif |
193 | #ifdef SIOCSOUTFILL | 193 | #ifdef SIOCSOUTFILL |
194 | {"SIOCSOUTFILL", SIOCSOUTFILL, ifreq_offsetof(ifr_data)}, | 194 | {"SIOCSOUTFILL", SIOCSOUTFILL, ifreq_offsetof(ifr_data)}, |
195 | #endif | 195 | #endif |
196 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 196 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
197 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.mem_start)}, | 197 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.mem_start)}, |
198 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr)}, | 198 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr)}, |
199 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq)}, | 199 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq)}, |
200 | #endif | 200 | #endif |
201 | /* Last entry if for unmatched (possibly hostname) arg. */ | 201 | /* Last entry if for unmatched (possibly hostname) arg. */ |
202 | #if CONFIG_FEATURE_IPV6 | 202 | #if CONFIG_FEATURE_IPV6 |
203 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ | 203 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
204 | {"SIOCDIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ | 204 | {"SIOCDIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
205 | #endif | 205 | #endif |
206 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, | 206 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static const struct options OptArray[] = { | 209 | static const struct options OptArray[] = { |
210 | {"metric", N_ARG, ARG_METRIC, 0}, | 210 | {"metric", N_ARG, ARG_METRIC, 0}, |
211 | {"mtu", N_ARG, ARG_MTU, 0}, | 211 | {"mtu", N_ARG, ARG_MTU, 0}, |
212 | {"txqueuelen", N_ARG, ARG_TXQUEUELEN, 0}, | 212 | {"txqueuelen", N_ARG, ARG_TXQUEUELEN, 0}, |
213 | {"dstaddr", N_ARG, ARG_DSTADDR, 0}, | 213 | {"dstaddr", N_ARG, ARG_DSTADDR, 0}, |
214 | {"netmask", N_ARG, ARG_NETMASK, 0}, | 214 | {"netmask", N_ARG, ARG_NETMASK, 0}, |
215 | {"broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST}, | 215 | {"broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST}, |
216 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 216 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
217 | {"hw", N_ARG, ARG_HW, 0}, | 217 | {"hw", N_ARG, ARG_HW, 0}, |
218 | #endif | 218 | #endif |
219 | {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT}, | 219 | {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT}, |
220 | #ifdef SIOCSKEEPALIVE | 220 | #ifdef SIOCSKEEPALIVE |
221 | {"keepalive", N_ARG, ARG_KEEPALIVE, 0}, | 221 | {"keepalive", N_ARG, ARG_KEEPALIVE, 0}, |
222 | #endif | 222 | #endif |
223 | #ifdef SIOCSOUTFILL | 223 | #ifdef SIOCSOUTFILL |
224 | {"outfill", N_ARG, ARG_OUTFILL, 0}, | 224 | {"outfill", N_ARG, ARG_OUTFILL, 0}, |
225 | #endif | 225 | #endif |
226 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 226 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
227 | {"mem_start", N_ARG, ARG_MEM_START, 0}, | 227 | {"mem_start", N_ARG, ARG_MEM_START, 0}, |
228 | {"io_addr", N_ARG, ARG_IO_ADDR, 0}, | 228 | {"io_addr", N_ARG, ARG_IO_ADDR, 0}, |
229 | {"irq", N_ARG, ARG_IRQ, 0}, | 229 | {"irq", N_ARG, ARG_IRQ, 0}, |
230 | #endif | 230 | #endif |
231 | #if CONFIG_FEATURE_IPV6 | 231 | #if CONFIG_FEATURE_IPV6 |
232 | {"add", N_ARG, ARG_ADD_DEL, 0}, | 232 | {"add", N_ARG, ARG_ADD_DEL, 0}, |
233 | {"del", N_ARG, ARG_ADD_DEL, 0}, | 233 | {"del", N_ARG, ARG_ADD_DEL, 0}, |
234 | #endif | 234 | #endif |
235 | {"arp", N_CLR | M_SET, 0, IFF_NOARP}, | 235 | {"arp", N_CLR | M_SET, 0, IFF_NOARP}, |
236 | {"trailers", N_CLR | M_SET, 0, IFF_NOTRAILERS}, | 236 | {"trailers", N_CLR | M_SET, 0, IFF_NOTRAILERS}, |
237 | {"promisc", N_SET | M_CLR, 0, IFF_PROMISC}, | 237 | {"promisc", N_SET | M_CLR, 0, IFF_PROMISC}, |
238 | {"multicast", N_SET | M_CLR, 0, IFF_MULTICAST}, | 238 | {"multicast", N_SET | M_CLR, 0, IFF_MULTICAST}, |
239 | {"allmulti", N_SET | M_CLR, 0, IFF_ALLMULTI}, | 239 | {"allmulti", N_SET | M_CLR, 0, IFF_ALLMULTI}, |
240 | {"dynamic", N_SET | M_CLR, 0, IFF_DYNAMIC}, | 240 | {"dynamic", N_SET | M_CLR, 0, IFF_DYNAMIC}, |
241 | {"up", N_SET , 0, (IFF_UP | IFF_RUNNING)}, | 241 | {"up", N_SET, 0, (IFF_UP | IFF_RUNNING)}, |
242 | {"down", N_CLR , 0, IFF_UP}, | 242 | {"down", N_CLR, 0, IFF_UP}, |
243 | { NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING)} | 243 | {NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING)} |
244 | }; | 244 | }; |
245 | 245 | ||
246 | /* | 246 | /* |
@@ -264,6 +264,7 @@ int ifconfig_main(int argc, char **argv) | |||
264 | { | 264 | { |
265 | struct ifreq ifr; | 265 | struct ifreq ifr; |
266 | struct sockaddr_in sai; | 266 | struct sockaddr_in sai; |
267 | |||
267 | #if CONFIG_FEATURE_IPV6 | 268 | #if CONFIG_FEATURE_IPV6 |
268 | struct sockaddr_in6 sai6; | 269 | struct sockaddr_in6 sai6; |
269 | #endif | 270 | #endif |
@@ -272,7 +273,7 @@ int ifconfig_main(int argc, char **argv) | |||
272 | #endif | 273 | #endif |
273 | const struct arg1opt *a1op; | 274 | const struct arg1opt *a1op; |
274 | const struct options *op; | 275 | const struct options *op; |
275 | int sockfd; /* socket fd we use to manipulate stuff with */ | 276 | int sockfd; /* socket fd we use to manipulate stuff with */ |
276 | int goterr; | 277 | int goterr; |
277 | int selector; | 278 | int selector; |
278 | char *p; | 279 | char *p; |
@@ -288,18 +289,19 @@ int ifconfig_main(int argc, char **argv) | |||
288 | --argc; | 289 | --argc; |
289 | 290 | ||
290 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS | 291 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
291 | if ((argc > 0) && (strcmp(*argv,"-a") == 0)) { | 292 | if ((argc > 0) && (strcmp(*argv, "-a") == 0)) { |
292 | interface_opt_a = 1; | 293 | interface_opt_a = 1; |
293 | --argc; | 294 | --argc; |
294 | ++argv; | 295 | ++argv; |
295 | } | 296 | } |
296 | #endif | 297 | #endif |
297 | 298 | ||
298 | if(argc <= 1) { | 299 | if (argc <= 1) { |
299 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS | 300 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
300 | return display_interfaces(argc ? *argv : NULL); | 301 | return display_interfaces(argc ? *argv : NULL); |
301 | #else | 302 | #else |
302 | error_msg_and_die( "ifconfig was not compiled with interface status display support."); | 303 | error_msg_and_die |
304 | ("ifconfig was not compiled with interface status display support."); | ||
303 | #endif | 305 | #endif |
304 | } | 306 | } |
305 | 307 | ||
@@ -315,14 +317,14 @@ int ifconfig_main(int argc, char **argv) | |||
315 | while (*++argv != (char *) NULL) { | 317 | while (*++argv != (char *) NULL) { |
316 | p = *argv; | 318 | p = *argv; |
317 | mask = N_MASK; | 319 | mask = N_MASK; |
318 | if (*p == '-') { /* If the arg starts with '-'... */ | 320 | if (*p == '-') { /* If the arg starts with '-'... */ |
319 | ++p; /* advance past it and */ | 321 | ++p; /* advance past it and */ |
320 | mask = M_MASK; /* set the appropriate mask. */ | 322 | mask = M_MASK; /* set the appropriate mask. */ |
321 | } | 323 | } |
322 | for (op = OptArray ; op->name ; op++) { /* Find table entry. */ | 324 | for (op = OptArray; op->name; op++) { /* Find table entry. */ |
323 | if (strcmp(p,op->name) == 0) { /* If name matches... */ | 325 | if (strcmp(p, op->name) == 0) { /* If name matches... */ |
324 | if ((mask &= op->flags)) { /* set the mask and go. */ | 326 | if ((mask &= op->flags)) { /* set the mask and go. */ |
325 | goto FOUND_ARG;; | 327 | goto FOUND_ARG;; |
326 | } | 328 | } |
327 | /* If we get here, there was a valid arg with an */ | 329 | /* If we get here, there was a valid arg with an */ |
328 | /* invalid '-' prefix. */ | 330 | /* invalid '-' prefix. */ |
@@ -330,13 +332,13 @@ int ifconfig_main(int argc, char **argv) | |||
330 | goto LOOP; | 332 | goto LOOP; |
331 | } | 333 | } |
332 | } | 334 | } |
333 | 335 | ||
334 | /* We fell through, so treat as possible hostname. */ | 336 | /* We fell through, so treat as possible hostname. */ |
335 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; | 337 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; |
336 | mask = op->arg_flags; | 338 | mask = op->arg_flags; |
337 | goto HOSTNAME; | 339 | goto HOSTNAME; |
338 | 340 | ||
339 | FOUND_ARG: | 341 | FOUND_ARG: |
340 | if (mask & ARG_MASK) { | 342 | if (mask & ARG_MASK) { |
341 | mask = op->arg_flags; | 343 | mask = op->arg_flags; |
342 | a1op = Arg1Opt + (op - OptArray); | 344 | a1op = Arg1Opt + (op - OptArray); |
@@ -348,10 +350,10 @@ int ifconfig_main(int argc, char **argv) | |||
348 | show_usage(); | 350 | show_usage(); |
349 | } else { | 351 | } else { |
350 | --argv; | 352 | --argv; |
351 | mask &= A_SET_AFTER; /* just for broadcast */ | 353 | mask &= A_SET_AFTER; /* just for broadcast */ |
352 | } | 354 | } |
353 | } else { /* got an arg so process it */ | 355 | } else { /* got an arg so process it */ |
354 | HOSTNAME: | 356 | HOSTNAME: |
355 | did_flags |= (mask & A_NETMASK); | 357 | did_flags |= (mask & A_NETMASK); |
356 | if (mask & A_CAST_HOST_COPY) { | 358 | if (mask & A_CAST_HOST_COPY) { |
357 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 359 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
@@ -359,7 +361,7 @@ int ifconfig_main(int argc, char **argv) | |||
359 | #endif | 361 | #endif |
360 | #if CONFIG_FEATURE_IPV6 | 362 | #if CONFIG_FEATURE_IPV6 |
361 | char *prefix; | 363 | char *prefix; |
362 | int prefix_len=0; | 364 | int prefix_len = 0; |
363 | #endif | 365 | #endif |
364 | 366 | ||
365 | safe_strncpy(host, *argv, (sizeof host)); | 367 | safe_strncpy(host, *argv, (sizeof host)); |
@@ -381,21 +383,24 @@ int ifconfig_main(int argc, char **argv) | |||
381 | sai.sin_addr.s_addr = INADDR_ANY; | 383 | sai.sin_addr.s_addr = INADDR_ANY; |
382 | #if CONFIG_FEATURE_IPV6 | 384 | #if CONFIG_FEATURE_IPV6 |
383 | } else | 385 | } else |
384 | if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) { | 386 | if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > |
387 | 0) { | ||
385 | int sockfd6; | 388 | int sockfd6; |
386 | struct in6_ifreq ifr6; | 389 | struct in6_ifreq ifr6; |
387 | 390 | ||
388 | memcpy((char *) &ifr6.ifr6_addr, (char *) &sai6.sin6_addr, | 391 | memcpy((char *) &ifr6.ifr6_addr, |
389 | sizeof(struct in6_addr)); | 392 | (char *) &sai6.sin6_addr, |
393 | sizeof(struct in6_addr)); | ||
390 | 394 | ||
391 | /* Create a channel to the NET kernel. */ | 395 | /* Create a channel to the NET kernel. */ |
392 | if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | 396 | if ((sockfd6 = |
397 | socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | ||
393 | perror_msg_and_die("socket6"); | 398 | perror_msg_and_die("socket6"); |
394 | } | 399 | } |
395 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { | 400 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { |
396 | perror("SIOGIFINDEX"); | 401 | perror("SIOGIFINDEX"); |
397 | ++goterr; | 402 | ++goterr; |
398 | continue; | 403 | continue; |
399 | } | 404 | } |
400 | ifr6.ifr6_ifindex = ifr.ifr_ifindex; | 405 | ifr6.ifr6_ifindex = ifr.ifr_ifindex; |
401 | ifr6.ifr6_prefixlen = prefix_len; | 406 | ifr6.ifr6_prefixlen = prefix_len; |
@@ -412,7 +417,7 @@ int ifconfig_main(int argc, char **argv) | |||
412 | } | 417 | } |
413 | p = (char *) &sai; | 418 | p = (char *) &sai; |
414 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 419 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
415 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ | 420 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ |
416 | /* This is the "hw" arg case. */ | 421 | /* This is the "hw" arg case. */ |
417 | if (strcmp("ether", *argv) || (*++argv == NULL)) { | 422 | if (strcmp("ether", *argv) || (*++argv == NULL)) { |
418 | show_usage(); | 423 | show_usage(); |
@@ -426,11 +431,12 @@ int ifconfig_main(int argc, char **argv) | |||
426 | p = (char *) &sa; | 431 | p = (char *) &sa; |
427 | } | 432 | } |
428 | #endif | 433 | #endif |
429 | memcpy((((char *)(&ifr)) + a1op->ifr_offset), | 434 | memcpy((((char *) (&ifr)) + a1op->ifr_offset), |
430 | p, sizeof(struct sockaddr)); | 435 | p, sizeof(struct sockaddr)); |
431 | } else { | 436 | } else { |
432 | unsigned int i = strtoul(*argv,NULL,0); | 437 | unsigned int i = strtoul(*argv, NULL, 0); |
433 | p = ((char *)(&ifr)) + a1op->ifr_offset; | 438 | |
439 | p = ((char *) (&ifr)) + a1op->ifr_offset; | ||
434 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 440 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
435 | if (mask & A_MAP_TYPE) { | 441 | if (mask & A_MAP_TYPE) { |
436 | if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { | 442 | if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { |
@@ -448,17 +454,16 @@ int ifconfig_main(int argc, char **argv) | |||
448 | #endif | 454 | #endif |
449 | if (mask & A_CAST_CHAR_PTR) { | 455 | if (mask & A_CAST_CHAR_PTR) { |
450 | *((caddr_t *) p) = (caddr_t) i; | 456 | *((caddr_t *) p) = (caddr_t) i; |
451 | } else { /* A_CAST_INT */ | 457 | } else { /* A_CAST_INT */ |
452 | *((int *) p) = i; | 458 | *((int *) p) = i; |
453 | } | 459 | } |
454 | } | 460 | } |
455 | 461 | ||
456 | if (ioctl(sockfd, a1op->selector, &ifr) < 0) { | 462 | if (ioctl(sockfd, a1op->selector, &ifr) < 0) { |
457 | perror(a1op->name); | 463 | perror(a1op->name); |
458 | ++goterr; | 464 | ++goterr; |
459 | continue; | 465 | continue; |
460 | } | 466 | } |
461 | |||
462 | #ifdef QUESTIONABLE_ALIAS_CASE | 467 | #ifdef QUESTIONABLE_ALIAS_CASE |
463 | if (mask & A_COLON_CHK) { | 468 | if (mask & A_COLON_CHK) { |
464 | /* | 469 | /* |
@@ -470,12 +475,13 @@ int ifconfig_main(int argc, char **argv) | |||
470 | */ | 475 | */ |
471 | char *ptr; | 476 | char *ptr; |
472 | short int found_colon = 0; | 477 | short int found_colon = 0; |
473 | for (ptr = ifr.ifr_name; *ptr; ptr++ ) { | 478 | |
479 | for (ptr = ifr.ifr_name; *ptr; ptr++) { | ||
474 | if (*ptr == ':') { | 480 | if (*ptr == ':') { |
475 | found_colon++; | 481 | found_colon++; |
476 | } | 482 | } |
477 | } | 483 | } |
478 | 484 | ||
479 | if (found_colon && *(ptr - 1) == '-') { | 485 | if (found_colon && *(ptr - 1) == '-') { |
480 | continue; | 486 | continue; |
481 | } | 487 | } |
@@ -489,7 +495,7 @@ int ifconfig_main(int argc, char **argv) | |||
489 | } | 495 | } |
490 | 496 | ||
491 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { | 497 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { |
492 | perror("SIOCGIFFLAGS"); | 498 | perror("SIOCGIFFLAGS"); |
493 | ++goterr; | 499 | ++goterr; |
494 | } else { | 500 | } else { |
495 | selector = op->selector; | 501 | selector = op->selector; |
@@ -499,31 +505,30 @@ int ifconfig_main(int argc, char **argv) | |||
499 | ifr.ifr_flags &= ~selector; | 505 | ifr.ifr_flags &= ~selector; |
500 | } | 506 | } |
501 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { | 507 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { |
502 | perror("SIOCSIFFLAGS"); | 508 | perror("SIOCSIFFLAGS"); |
503 | ++goterr; | 509 | ++goterr; |
504 | } | 510 | } |
505 | } | 511 | } |
506 | LOOP: | 512 | LOOP: |
507 | continue; | 513 | continue; |
508 | } /* end of while-loop */ | 514 | } /* end of while-loop */ |
509 | 515 | ||
510 | return goterr; | 516 | return goterr; |
511 | } | 517 | } |
512 | 518 | ||
513 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 519 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
514 | /* Input an Ethernet address and convert to binary. */ | 520 | /* Input an Ethernet address and convert to binary. */ |
515 | static int | 521 | static int in_ether(char *bufp, struct sockaddr *sap) |
516 | in_ether(char *bufp, struct sockaddr *sap) | ||
517 | { | 522 | { |
518 | unsigned char *ptr; | 523 | unsigned char *ptr; |
519 | int i, j; | 524 | int i, j; |
520 | unsigned char val; | 525 | unsigned char val; |
521 | unsigned char c; | 526 | unsigned char c; |
522 | 527 | ||
523 | sap->sa_family = ARPHRD_ETHER; | 528 | sap->sa_family = ARPHRD_ETHER; |
524 | ptr = sap->sa_data; | 529 | ptr = sap->sa_data; |
525 | 530 | ||
526 | for (i = 0 ; i < ETH_ALEN ; i++) { | 531 | for (i = 0; i < ETH_ALEN; i++) { |
527 | val = 0; | 532 | val = 0; |
528 | 533 | ||
529 | /* We might get a semicolon here - not required. */ | 534 | /* We might get a semicolon here - not required. */ |
@@ -531,7 +536,7 @@ in_ether(char *bufp, struct sockaddr *sap) | |||
531 | bufp++; | 536 | bufp++; |
532 | } | 537 | } |
533 | 538 | ||
534 | for (j=0 ; j<2 ; j++) { | 539 | for (j = 0; j < 2; j++) { |
535 | c = *bufp; | 540 | c = *bufp; |
536 | if (c >= '0' && c <= '9') { | 541 | if (c >= '0' && c <= '9') { |
537 | c -= '0'; | 542 | c -= '0'; |
@@ -551,6 +556,6 @@ in_ether(char *bufp, struct sockaddr *sap) | |||
551 | *ptr++ = val; | 556 | *ptr++ = val; |
552 | } | 557 | } |
553 | 558 | ||
554 | return (int) (*bufp); /* Error if we don't end at end of string. */ | 559 | return (int) (*bufp); /* Error if we don't end at end of string. */ |
555 | } | 560 | } |
556 | #endif | 561 | #endif |