diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-01-10 11:29:31 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-01-10 11:29:31 +0000 |
commit | 716ccb263569560777f7ff31581e1242d1cb33aa (patch) | |
tree | f97f6b1ab8e6bd9d15167f0b9a9bf96624106ce1 /modutils/modprobe.c | |
parent | 8e2f74f5a7f6222d759c32431a562ce9728f7fc9 (diff) | |
download | busybox-w32-716ccb263569560777f7ff31581e1242d1cb33aa.tar.gz busybox-w32-716ccb263569560777f7ff31581e1242d1cb33aa.tar.bz2 busybox-w32-716ccb263569560777f7ff31581e1242d1cb33aa.zip |
whitespace cleanup
Diffstat (limited to 'modutils/modprobe.c')
-rw-r--r-- | modutils/modprobe.c | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 68754696b..c6a83553f 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -40,7 +40,7 @@ struct dep_t { | |||
40 | int m_isalias : 1; | 40 | int m_isalias : 1; |
41 | int m_reserved : 15; | 41 | int m_reserved : 15; |
42 | 42 | ||
43 | int m_depcnt : 16; | 43 | int m_depcnt : 16; |
44 | char ** m_deparr; | 44 | char ** m_deparr; |
45 | 45 | ||
46 | struct dep_t * m_next; | 46 | struct dep_t * m_next; |
@@ -64,7 +64,7 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) | |||
64 | char *tag, *value; | 64 | char *tag, *value; |
65 | 65 | ||
66 | while ( isspace ( *buffer )) | 66 | while ( isspace ( *buffer )) |
67 | buffer++; | 67 | buffer++; |
68 | tag = value = buffer; | 68 | tag = value = buffer; |
69 | while ( !isspace ( *value )) | 69 | while ( !isspace ( *value )) |
70 | value++; | 70 | value++; |
@@ -80,7 +80,7 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) | |||
80 | 80 | ||
81 | /* Jump through hoops to simulate how fgets() grabs just one line at a | 81 | /* Jump through hoops to simulate how fgets() grabs just one line at a |
82 | * time... Don't use any stdio since modprobe gets called from a kernel | 82 | * time... Don't use any stdio since modprobe gets called from a kernel |
83 | * thread and stdio junk can overflow the limited stack... | 83 | * thread and stdio junk can overflow the limited stack... |
84 | */ | 84 | */ |
85 | static char *reads ( int fd, char *buffer, size_t len ) | 85 | static char *reads ( int fd, char *buffer, size_t len ) |
86 | { | 86 | { |
@@ -95,7 +95,7 @@ static char *reads ( int fd, char *buffer, size_t len ) | |||
95 | if ( p ) { | 95 | if ( p ) { |
96 | off_t offset; | 96 | off_t offset; |
97 | 97 | ||
98 | offset = lseek ( fd, 0L, SEEK_CUR ); // Get the current file descriptor offset | 98 | offset = lseek ( fd, 0L, SEEK_CUR ); // Get the current file descriptor offset |
99 | lseek ( fd, offset-n + (p-buffer) + 1, SEEK_SET ); // Set the file descriptor offset to right after the \n | 99 | lseek ( fd, offset-n + (p-buffer) + 1, SEEK_SET ); // Set the file descriptor offset to right after the \n |
100 | 100 | ||
101 | p[1] = 0; | 101 | p[1] = 0; |
@@ -155,7 +155,7 @@ static struct dep_t *build_dep ( void ) | |||
155 | continue; | 155 | continue; |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( !continuation_line ) { | 158 | if ( !continuation_line ) { |
159 | char *col = strchr ( buffer, ':' ); | 159 | char *col = strchr ( buffer, ':' ); |
160 | 160 | ||
161 | if ( col ) { | 161 | if ( col ) { |
@@ -197,7 +197,7 @@ static struct dep_t *build_dep ( void ) | |||
197 | current-> m_next = 0; | 197 | current-> m_next = 0; |
198 | 198 | ||
199 | //printf ( "%s:\n", mod ); | 199 | //printf ( "%s:\n", mod ); |
200 | p = col + 1; | 200 | p = col + 1; |
201 | } | 201 | } |
202 | else | 202 | else |
203 | p = 0; | 203 | p = 0; |
@@ -229,37 +229,38 @@ static struct dep_t *build_dep ( void ) | |||
229 | else | 229 | else |
230 | next = end; | 230 | next = end; |
231 | 231 | ||
232 | deps = strrchr ( p, '/' ); | 232 | deps = strrchr ( p, '/' ); |
233 | 233 | ||
234 | if ( !deps || ( deps < p )) { | 234 | if ( !deps || ( deps < p )) { |
235 | deps = p; | 235 | deps = p; |
236 | 236 | ||
237 | while ( isblank ( *deps )) | 237 | while ( isblank ( *deps )) |
238 | deps++; | ||
239 | } | ||
240 | else | ||
238 | deps++; | 241 | deps++; |
239 | } | ||
240 | else | ||
241 | deps++; | ||
242 | 242 | ||
243 | #if defined(CONFIG_FEATURE_2_6_MODULES) | 243 | #if defined(CONFIG_FEATURE_2_6_MODULES) |
244 | if ((k_version > 4) && ( *(next-2) == '.' ) && *(next-1) == 'k' && | 244 | if ((k_version > 4) && ( *(next-2) == '.' ) && *(next-1) == 'k' && |
245 | ( *next == 'o' )) | 245 | ( *next == 'o' )) |
246 | ext = 3; | 246 | ext = 3; |
247 | else | 247 | else |
248 | #endif | 248 | #endif |
249 | if (( *(next-1) == '.' ) && ( *next == 'o' )) | 249 | if (( *(next-1) == '.' ) && ( *next == 'o' )) |
250 | ext = 2; | 250 | ext = 2; |
251 | 251 | ||
252 | /* Cope with blank lines */ | 252 | /* Cope with blank lines */ |
253 | if ((next-deps-ext+1) <= 0) | 253 | if ((next-deps-ext+1) <= 0) |
254 | continue; | 254 | continue; |
255 | dep = bb_xstrndup ( deps, next - deps - ext + 1 ); | 255 | dep = bb_xstrndup ( deps, next - deps - ext + 1 ); |
256 | 256 | ||
257 | current-> m_depcnt++; | 257 | current-> m_depcnt++; |
258 | current-> m_deparr = (char **) xrealloc ( current-> m_deparr, sizeof ( char *) * current-> m_depcnt ); | 258 | current-> m_deparr = (char **) xrealloc ( current-> m_deparr, |
259 | current-> m_deparr [current-> m_depcnt - 1] = dep; | 259 | sizeof ( char *) * current-> m_depcnt ); |
260 | current-> m_deparr [current-> m_depcnt - 1] = dep; | ||
260 | 261 | ||
261 | //printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] ); | 262 | //printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] ); |
262 | p = next + 2; | 263 | p = next + 2; |
263 | } while (next < end); | 264 | } while (next < end); |
264 | } | 265 | } |
265 | 266 | ||
@@ -281,7 +282,7 @@ static struct dep_t *build_dep ( void ) | |||
281 | int l; | 282 | int l; |
282 | char *p; | 283 | char *p; |
283 | 284 | ||
284 | p = strchr ( buffer, '#' ); | 285 | p = strchr ( buffer, '#' ); |
285 | if ( p ) | 286 | if ( p ) |
286 | *p = 0; | 287 | *p = 0; |
287 | 288 | ||
@@ -297,7 +298,7 @@ static struct dep_t *build_dep ( void ) | |||
297 | continue; | 298 | continue; |
298 | } | 299 | } |
299 | 300 | ||
300 | if ( !continuation_line ) { | 301 | if ( !continuation_line ) { |
301 | if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) { | 302 | if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) { |
302 | char *alias, *mod; | 303 | char *alias, *mod; |
303 | 304 | ||
@@ -323,17 +324,17 @@ static struct dep_t *build_dep ( void ) | |||
323 | current-> m_deparr = xmalloc ( 1 * sizeof( char * )); | 324 | current-> m_deparr = xmalloc ( 1 * sizeof( char * )); |
324 | current-> m_deparr[0] = bb_xstrdup ( mod ); | 325 | current-> m_deparr[0] = bb_xstrdup ( mod ); |
325 | } | 326 | } |
326 | current-> m_next = 0; | 327 | current-> m_next = 0; |
327 | } | 328 | } |
328 | } | 329 | } |
329 | else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) { | 330 | else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) { |
330 | char *mod, *opt; | 331 | char *mod, *opt; |
331 | 332 | ||
332 | if ( parse_tag_value ( buffer + 8, &mod, &opt )) { | 333 | if ( parse_tag_value ( buffer + 8, &mod, &opt )) { |
333 | struct dep_t *dt; | 334 | struct dep_t *dt; |
334 | 335 | ||
335 | for ( dt = first; dt; dt = dt-> m_next ) { | 336 | for ( dt = first; dt; dt = dt-> m_next ) { |
336 | if ( strcmp ( dt-> m_module, mod ) == 0 ) | 337 | if ( strcmp ( dt-> m_module, mod ) == 0 ) |
337 | break; | 338 | break; |
338 | } | 339 | } |
339 | if ( dt ) { | 340 | if ( dt ) { |
@@ -387,10 +388,14 @@ static int mod_process ( struct mod_list_t *list, int do_insert ) | |||
387 | *lcmd = '\0'; | 388 | *lcmd = '\0'; |
388 | if ( do_insert ) { | 389 | if ( do_insert ) { |
389 | if (already_loaded (list->m_module) != 1) | 390 | if (already_loaded (list->m_module) != 1) |
390 | snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s", do_syslog ? "-s" : "", autoclean ? "-k" : "", quiet ? "-q" : "", list-> m_module, list-> m_options ? list-> m_options : "" ); | 391 | snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s", |
392 | do_syslog ? "-s" : "", autoclean ? "-k" : "", | ||
393 | quiet ? "-q" : "", list-> m_module, list-> m_options ? | ||
394 | list-> m_options : "" ); | ||
391 | } else { | 395 | } else { |
392 | if (already_loaded (list->m_module) != 0) | 396 | if (already_loaded (list->m_module) != 0) |
393 | snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", do_syslog ? "-s" : "", list-> m_module ); | 397 | snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", |
398 | do_syslog ? "-s" : "", list-> m_module ); | ||
394 | } | 399 | } |
395 | 400 | ||
396 | if ( verbose ) | 401 | if ( verbose ) |
@@ -443,7 +448,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
443 | break; | 448 | break; |
444 | } | 449 | } |
445 | if ( adt ) { | 450 | if ( adt ) { |
446 | dt = adt; | 451 | dt = adt; |
447 | mod = dt-> m_module; | 452 | mod = dt-> m_module; |
448 | if ( !opt ) | 453 | if ( !opt ) |
449 | opt = dt-> m_options; | 454 | opt = dt-> m_options; |
@@ -452,7 +457,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
452 | return; | 457 | return; |
453 | } | 458 | } |
454 | else | 459 | else |
455 | return; | 460 | return; |
456 | } | 461 | } |
457 | 462 | ||
458 | // search for duplicates | 463 | // search for duplicates |
@@ -471,16 +476,16 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
471 | *tail = find-> m_prev; | 476 | *tail = find-> m_prev; |
472 | 477 | ||
473 | break; // there can be only one duplicate | 478 | break; // there can be only one duplicate |
474 | } | 479 | } |
475 | } | 480 | } |
476 | 481 | ||
477 | if ( !find ) { // did not find a duplicate | 482 | if ( !find ) { // did not find a duplicate |
478 | find = (struct mod_list_t *) xmalloc ( sizeof(struct mod_list_t)); | 483 | find = (struct mod_list_t *) xmalloc ( sizeof(struct mod_list_t)); |
479 | find-> m_module = mod; | 484 | find-> m_module = mod; |
480 | find-> m_options = opt; | 485 | find-> m_options = opt; |
481 | } | 486 | } |
482 | 487 | ||
483 | // enqueue at tail | 488 | // enqueue at tail |
484 | if ( *tail ) | 489 | if ( *tail ) |
485 | (*tail)-> m_next = find; | 490 | (*tail)-> m_next = find; |
486 | find-> m_prev = *tail; | 491 | find-> m_prev = *tail; |
@@ -490,7 +495,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
490 | *head = find; | 495 | *head = find; |
491 | *tail = find; | 496 | *tail = find; |
492 | 497 | ||
493 | if ( dt ) { | 498 | if ( dt ) { |
494 | int i; | 499 | int i; |
495 | 500 | ||
496 | for ( i = 0; i < dt-> m_depcnt; i++ ) | 501 | for ( i = 0; i < dt-> m_depcnt; i++ ) |
@@ -503,7 +508,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
503 | static int mod_insert ( char *mod, int argc, char **argv ) | 508 | static int mod_insert ( char *mod, int argc, char **argv ) |
504 | { | 509 | { |
505 | struct mod_list_t *tail = 0; | 510 | struct mod_list_t *tail = 0; |
506 | struct mod_list_t *head = 0; | 511 | struct mod_list_t *head = 0; |
507 | int rc; | 512 | int rc; |
508 | 513 | ||
509 | // get dep list for module mod | 514 | // get dep list for module mod |
@@ -511,11 +516,11 @@ static int mod_insert ( char *mod, int argc, char **argv ) | |||
511 | 516 | ||
512 | if ( head && tail ) { | 517 | if ( head && tail ) { |
513 | if ( argc ) { | 518 | if ( argc ) { |
514 | int i; | 519 | int i; |
515 | int l = 0; | 520 | int l = 0; |
516 | 521 | ||
517 | // append module args | 522 | // append module args |
518 | for ( i = 0; i < argc; i++ ) | 523 | for ( i = 0; i < argc; i++ ) |
519 | l += ( bb_strlen ( argv [i] ) + 1 ); | 524 | l += ( bb_strlen ( argv [i] ) + 1 ); |
520 | 525 | ||
521 | head-> m_options = xrealloc ( head-> m_options, l + 1 ); | 526 | head-> m_options = xrealloc ( head-> m_options, l + 1 ); |
@@ -539,7 +544,7 @@ static int mod_insert ( char *mod, int argc, char **argv ) | |||
539 | static int mod_remove ( char *mod ) | 544 | static int mod_remove ( char *mod ) |
540 | { | 545 | { |
541 | int rc; | 546 | int rc; |
542 | static struct mod_list_t rm_a_dummy = { "-a", 0, 0 }; | 547 | static struct mod_list_t rm_a_dummy = { "-a", 0, 0 }; |
543 | 548 | ||
544 | struct mod_list_t *head = 0; | 549 | struct mod_list_t *head = 0; |
545 | struct mod_list_t *tail = 0; | 550 | struct mod_list_t *tail = 0; |
@@ -604,9 +609,9 @@ extern int modprobe_main(int argc, char** argv) | |||
604 | } | 609 | } |
605 | } | 610 | } |
606 | 611 | ||
607 | depend = build_dep ( ); | 612 | depend = build_dep ( ); |
608 | 613 | ||
609 | if ( !depend ) | 614 | if ( !depend ) |
610 | bb_error_msg_and_die ( "could not parse modules.dep\n" ); | 615 | bb_error_msg_and_die ( "could not parse modules.dep\n" ); |
611 | 616 | ||
612 | if (remove_opt) { | 617 | if (remove_opt) { |
@@ -623,10 +628,10 @@ extern int modprobe_main(int argc, char** argv) | |||
623 | return rc; | 628 | return rc; |
624 | } | 629 | } |
625 | 630 | ||
626 | if (optind >= argc) | 631 | if (optind >= argc) |
627 | bb_error_msg_and_die ( "No module or pattern provided\n" ); | 632 | bb_error_msg_and_die ( "No module or pattern provided\n" ); |
628 | 633 | ||
629 | if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 )) | 634 | if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 )) |
630 | bb_error_msg_and_die ( "failed to load module %s", argv [optind] ); | 635 | bb_error_msg_and_die ( "failed to load module %s", argv [optind] ); |
631 | 636 | ||
632 | return EXIT_SUCCESS; | 637 | return EXIT_SUCCESS; |