summaryrefslogtreecommitdiff
path: root/modutils/modprobe.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-12-24 20:30:45 +0000
committerEric Andersen <andersen@codepoet.org>2003-12-24 20:30:45 +0000
commit3b1a74467a0909a62f26f6f27ac63ea922939c4d (patch)
tree982459b4484a823360ec90628a18d72e26902fbf /modutils/modprobe.c
parentd242e49c894cd0a8b6b016e8f1865651c1c5fef7 (diff)
downloadbusybox-w32-3b1a74467a0909a62f26f6f27ac63ea922939c4d.tar.gz
busybox-w32-3b1a74467a0909a62f26f6f27ac63ea922939c4d.tar.bz2
busybox-w32-3b1a74467a0909a62f26f6f27ac63ea922939c4d.zip
re-indent
Diffstat (limited to 'modutils/modprobe.c')
-rw-r--r--modutils/modprobe.c230
1 files changed, 115 insertions, 115 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 6b4405a44..e300c0d2b 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -36,20 +36,20 @@
36struct dep_t { 36struct dep_t {
37 char * m_module; 37 char * m_module;
38 char * m_options; 38 char * m_options;
39 39
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;
47}; 47};
48 48
49struct mod_list_t { 49struct mod_list_t {
50 char * m_module; 50 char * m_module;
51 char * m_options; 51 char * m_options;
52 52
53 struct mod_list_t * m_prev; 53 struct mod_list_t * m_prev;
54 struct mod_list_t * m_next; 54 struct mod_list_t * m_next;
55}; 55};
@@ -74,7 +74,7 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
74 74
75 *ptag = tag; 75 *ptag = tag;
76 *pvalue = value; 76 *pvalue = value;
77 77
78 return bb_strlen( tag ) && bb_strlen( value ); 78 return bb_strlen( tag ) && bb_strlen( value );
79} 79}
80 80
@@ -85,16 +85,16 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
85static char *reads ( int fd, char *buffer, size_t len ) 85static char *reads ( int fd, char *buffer, size_t len )
86{ 86{
87 int n = read ( fd, buffer, len ); 87 int n = read ( fd, buffer, len );
88 88
89 if ( n > 0 ) { 89 if ( n > 0 ) {
90 char *p; 90 char *p;
91 91
92 buffer [len-1] = 0; 92 buffer [len-1] = 0;
93 p = strchr ( buffer, '\n' ); 93 p = strchr ( buffer, '\n' );
94 94
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
@@ -102,7 +102,7 @@ static char *reads ( int fd, char *buffer, size_t len )
102 } 102 }
103 return buffer; 103 return buffer;
104 } 104 }
105 105
106 else 106 else
107 return 0; 107 return 0;
108} 108}
@@ -116,11 +116,11 @@ static struct dep_t *build_dep ( void )
116 char buffer[256]; 116 char buffer[256];
117 char *filename = buffer; 117 char *filename = buffer;
118 int continuation_line = 0; 118 int continuation_line = 0;
119 119
120 k_version = 0; 120 k_version = 0;
121 if ( uname ( &un )) 121 if ( uname ( &un ))
122 return 0; 122 return 0;
123 123
124 // check for buffer overflow in following code 124 // check for buffer overflow in following code
125 if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) { 125 if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) {
126 return 0; 126 return 0;
@@ -128,7 +128,7 @@ static struct dep_t *build_dep ( void )
128 if (un.release[0] == '2') { 128 if (un.release[0] == '2') {
129 k_version = un.release[2] - '0'; 129 k_version = un.release[2] - '0';
130 } 130 }
131 131
132 strcpy ( filename, "/lib/modules/" ); 132 strcpy ( filename, "/lib/modules/" );
133 strcat ( filename, un.release ); 133 strcat ( filename, un.release );
134 strcat ( filename, "/modules.dep" ); 134 strcat ( filename, "/modules.dep" );
@@ -144,44 +144,44 @@ static struct dep_t *build_dep ( void )
144 while ( reads ( fd, buffer, sizeof( buffer ))) { 144 while ( reads ( fd, buffer, sizeof( buffer ))) {
145 int l = bb_strlen ( buffer ); 145 int l = bb_strlen ( buffer );
146 char *p = 0; 146 char *p = 0;
147 147
148 while ( isspace ( buffer [l-1] )) { 148 while ( isspace ( buffer [l-1] )) {
149 buffer [l-1] = 0; 149 buffer [l-1] = 0;
150 l--; 150 l--;
151 } 151 }
152 152
153 if ( l == 0 ) { 153 if ( l == 0 ) {
154 continuation_line = 0; 154 continuation_line = 0;
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 ) {
162 char *mods; 162 char *mods;
163 char *mod; 163 char *mod;
164 int ext = 0; 164 int ext = 0;
165 165
166 *col = 0; 166 *col = 0;
167 mods = strrchr ( buffer, '/' ); 167 mods = strrchr ( buffer, '/' );
168 168
169 if ( !mods ) 169 if ( !mods )
170 mods = buffer; 170 mods = buffer;
171 else 171 else
172 mods++; 172 mods++;
173 173
174#if defined(CONFIG_FEATURE_2_6_MODULES) 174#if defined(CONFIG_FEATURE_2_6_MODULES)
175 if ((k_version > 4) && ( *(col-3) == '.' ) && 175 if ((k_version > 4) && ( *(col-3) == '.' ) &&
176 ( *(col-2) == 'k' ) && ( *(col-1) == 'o' )) 176 ( *(col-2) == 'k' ) && ( *(col-1) == 'o' ))
177 ext = 3; 177 ext = 3;
178 else 178 else
179#endif 179#endif
180 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' )) 180 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
181 ext = 2; 181 ext = 2;
182 182
183 mod = bb_xstrndup ( mods, col - mods - ext ); 183 mod = bb_xstrndup ( mods, col - mods - ext );
184 184
185 if ( !current ) { 185 if ( !current ) {
186 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t )); 186 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
187 } 187 }
@@ -195,9 +195,9 @@ static struct dep_t *build_dep ( void )
195 current-> m_depcnt = 0; 195 current-> m_depcnt = 0;
196 current-> m_deparr = 0; 196 current-> m_deparr = 0;
197 current-> m_next = 0; 197 current-> m_next = 0;
198 198
199 //printf ( "%s:\n", mod ); 199 //printf ( "%s:\n", mod );
200 200
201 p = col + 1; 201 p = col + 1;
202 } 202 }
203 else 203 else
@@ -205,49 +205,49 @@ static struct dep_t *build_dep ( void )
205 } 205 }
206 else 206 else
207 p = buffer; 207 p = buffer;
208 208
209 if ( p && *p ) { 209 if ( p && *p ) {
210 char *end = &buffer [l-1]; 210 char *end = &buffer [l-1];
211 char *deps = strrchr ( end, '/' ); 211 char *deps = strrchr ( end, '/' );
212 char *dep; 212 char *dep;
213 int ext = 0; 213 int ext = 0;
214 214
215 while ( isblank ( *end ) || ( *end == '\\' )) 215 while ( isblank ( *end ) || ( *end == '\\' ))
216 end--; 216 end--;
217 217
218 deps = strrchr ( p, '/' ); 218 deps = strrchr ( p, '/' );
219 219
220 if ( !deps || ( deps < p )) { 220 if ( !deps || ( deps < p )) {
221 deps = p; 221 deps = p;
222 222
223 while ( isblank ( *deps )) 223 while ( isblank ( *deps ))
224 deps++; 224 deps++;
225 } 225 }
226 else 226 else
227 deps++; 227 deps++;
228 228
229#if defined(CONFIG_FEATURE_2_6_MODULES) 229#if defined(CONFIG_FEATURE_2_6_MODULES)
230 if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' && 230 if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' &&
231 ( *end == 'o' )) 231 ( *end == 'o' ))
232 ext = 3; 232 ext = 3;
233 else 233 else
234#endif 234#endif
235 if (( *(end-1) == '.' ) && ( *end == 'o' )) 235 if (( *(end-1) == '.' ) && ( *end == 'o' ))
236 ext = 2; 236 ext = 2;
237 237
238 /* Cope with blank lines */ 238 /* Cope with blank lines */
239 if ((end-deps-ext+1) <= 0) 239 if ((end-deps-ext+1) <= 0)
240 continue; 240 continue;
241 241
242 dep = bb_xstrndup ( deps, end - deps - ext + 1 ); 242 dep = bb_xstrndup ( deps, end - deps - ext + 1 );
243 243
244 current-> m_depcnt++; 244 current-> m_depcnt++;
245 current-> m_deparr = (char **) xrealloc ( current-> m_deparr, sizeof ( char *) * current-> m_depcnt ); 245 current-> m_deparr = (char **) xrealloc ( current-> m_deparr, sizeof ( char *) * current-> m_depcnt );
246 current-> m_deparr [current-> m_depcnt - 1] = dep; 246 current-> m_deparr [current-> m_depcnt - 1] = dep;
247 247
248 //printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] ); 248 //printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] );
249 } 249 }
250 250
251 if ( buffer [l-1] == '\\' ) 251 if ( buffer [l-1] == '\\' )
252 continuation_line = 1; 252 continuation_line = 1;
253 else 253 else
@@ -260,35 +260,35 @@ static struct dep_t *build_dep ( void )
260 if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 ) 260 if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 )
261 if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 ) 261 if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 )
262 return first; 262 return first;
263 263
264 continuation_line = 0; 264 continuation_line = 0;
265 while ( reads ( fd, buffer, sizeof( buffer ))) { 265 while ( reads ( fd, buffer, sizeof( buffer ))) {
266 int l; 266 int l;
267 char *p; 267 char *p;
268 268
269 p = strchr ( buffer, '#' ); 269 p = strchr ( buffer, '#' );
270 if ( p ) 270 if ( p )
271 *p = 0; 271 *p = 0;
272 272
273 l = bb_strlen ( buffer ); 273 l = bb_strlen ( buffer );
274 274
275 while ( l && isspace ( buffer [l-1] )) { 275 while ( l && isspace ( buffer [l-1] )) {
276 buffer [l-1] = 0; 276 buffer [l-1] = 0;
277 l--; 277 l--;
278 } 278 }
279 279
280 if ( l == 0 ) { 280 if ( l == 0 ) {
281 continuation_line = 0; 281 continuation_line = 0;
282 continue; 282 continue;
283 } 283 }
284 284
285 if ( !continuation_line ) { 285 if ( !continuation_line ) {
286 if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) { 286 if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) {
287 char *alias, *mod; 287 char *alias, *mod;
288 288
289 if ( parse_tag_value ( buffer + 6, &alias, &mod )) { 289 if ( parse_tag_value ( buffer + 6, &alias, &mod )) {
290 // fprintf ( stderr, "ALIAS: '%s' -> '%s'\n", alias, mod ); 290 // fprintf ( stderr, "ALIAS: '%s' -> '%s'\n", alias, mod );
291 291
292 if ( !current ) { 292 if ( !current ) {
293 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t )); 293 first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
294 } 294 }
@@ -298,7 +298,7 @@ static struct dep_t *build_dep ( void )
298 } 298 }
299 current-> m_module = bb_xstrdup ( alias ); 299 current-> m_module = bb_xstrdup ( alias );
300 current-> m_isalias = 1; 300 current-> m_isalias = 1;
301 301
302 if (( strcmp ( alias, "off" ) == 0 ) || ( strcmp ( alias, "null" ) == 0 )) { 302 if (( strcmp ( alias, "off" ) == 0 ) || ( strcmp ( alias, "null" ) == 0 )) {
303 current-> m_depcnt = 0; 303 current-> m_depcnt = 0;
304 current-> m_deparr = 0; 304 current-> m_deparr = 0;
@@ -313,10 +313,10 @@ static struct dep_t *build_dep ( void )
313 } 313 }
314 else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) { 314 else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) {
315 char *mod, *opt; 315 char *mod, *opt;
316 316
317 if ( parse_tag_value ( buffer + 8, &mod, &opt )) { 317 if ( parse_tag_value ( buffer + 8, &mod, &opt )) {
318 struct dep_t *dt; 318 struct dep_t *dt;
319 319
320 for ( dt = first; dt; dt = dt-> m_next ) { 320 for ( dt = first; dt; dt = dt-> m_next ) {
321 if ( strcmp ( dt-> m_module, mod ) == 0 ) 321 if ( strcmp ( dt-> m_module, mod ) == 0 )
322 break; 322 break;
@@ -324,7 +324,7 @@ static struct dep_t *build_dep ( void )
324 if ( dt ) { 324 if ( dt ) {
325 dt-> m_options = xrealloc ( dt-> m_options, bb_strlen( opt ) + 1 ); 325 dt-> m_options = xrealloc ( dt-> m_options, bb_strlen( opt ) + 1 );
326 strcpy ( dt-> m_options, opt ); 326 strcpy ( dt-> m_options, opt );
327 327
328 // fprintf ( stderr, "OPTION: '%s' -> '%s'\n", dt-> m_module, dt-> m_options ); 328 // fprintf ( stderr, "OPTION: '%s' -> '%s'\n", dt-> m_module, dt-> m_options );
329 } 329 }
330 } 330 }
@@ -332,7 +332,7 @@ static struct dep_t *build_dep ( void )
332 } 332 }
333 } 333 }
334 close ( fd ); 334 close ( fd );
335 335
336 return first; 336 return first;
337} 337}
338 338
@@ -377,7 +377,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
377 if (already_loaded (list->m_module) != 0) 377 if (already_loaded (list->m_module) != 0)
378 snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", do_syslog ? "-s" : "", list-> m_module ); 378 snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", do_syslog ? "-s" : "", list-> m_module );
379 } 379 }
380 380
381 if ( verbose ) 381 if ( verbose )
382 printf ( "%s\n", lcmd ); 382 printf ( "%s\n", lcmd );
383 if ( !show_only && *lcmd) { 383 if ( !show_only && *lcmd) {
@@ -385,7 +385,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
385 if (do_insert) rc = rc2; /* only last module matters */ 385 if (do_insert) rc = rc2; /* only last module matters */
386 else if (!rc2) rc = 0; /* success if remove any mod */ 386 else if (!rc2) rc = 0; /* success if remove any mod */
387 } 387 }
388 388
389 list = do_insert ? list-> m_prev : list-> m_next; 389 list = do_insert ? list-> m_prev : list-> m_next;
390 } 390 }
391 return (show_only) ? 0 : rc; 391 return (show_only) ? 0 : rc;
@@ -403,12 +403,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
403 403
404#if defined(CONFIG_FEATURE_2_6_MODULES) 404#if defined(CONFIG_FEATURE_2_6_MODULES)
405 if ((k_version > 4) && ( mod [lm-3] == '.' ) && 405 if ((k_version > 4) && ( mod [lm-3] == '.' ) &&
406 ( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' )) 406 ( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' ))
407 mod [lm-3] = 0; 407 mod [lm-3] = 0;
408 else 408 else
409#endif 409#endif
410 if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' )) 410 if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
411 mod [lm-2] = 0; 411 mod [lm-2] = 0;
412 412
413 // check dependencies 413 // check dependencies
414 for ( dt = depend; dt; dt = dt-> m_next ) { 414 for ( dt = depend; dt; dt = dt-> m_next ) {
@@ -417,12 +417,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
417 break; 417 break;
418 } 418 }
419 } 419 }
420 420
421 // resolve alias names 421 // resolve alias names
422 while ( dt && dt-> m_isalias ) { 422 while ( dt && dt-> m_isalias ) {
423 if ( dt-> m_depcnt == 1 ) { 423 if ( dt-> m_depcnt == 1 ) {
424 struct dep_t *adt; 424 struct dep_t *adt;
425 425
426 for ( adt = depend; adt; adt = adt-> m_next ) { 426 for ( adt = depend; adt; adt = adt-> m_next ) {
427 if ( strcmp ( adt-> m_module, dt-> m_deparr [0] ) == 0 ) 427 if ( strcmp ( adt-> m_module, dt-> m_deparr [0] ) == 0 )
428 break; 428 break;
@@ -439,7 +439,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
439 else 439 else
440 return; 440 return;
441 } 441 }
442 442
443 // search for duplicates 443 // search for duplicates
444 for ( find = *head; find; find = find-> m_next ) { 444 for ( find = *head; find; find = find-> m_next ) {
445 if ( !strcmp ( mod, find-> m_module )) { 445 if ( !strcmp ( mod, find-> m_module )) {
@@ -449,12 +449,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
449 find-> m_prev-> m_next = find-> m_next; 449 find-> m_prev-> m_next = find-> m_next;
450 else 450 else
451 *head = find-> m_next; 451 *head = find-> m_next;
452 452
453 if ( find-> m_next ) 453 if ( find-> m_next )
454 find-> m_next-> m_prev = find-> m_prev; 454 find-> m_next-> m_prev = find-> m_prev;
455 else 455 else
456 *tail = find-> m_prev; 456 *tail = find-> m_prev;
457 457
458 break; // there can be only one duplicate 458 break; // there can be only one duplicate
459 } 459 }
460 } 460 }
@@ -474,10 +474,10 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
474 if ( !*head ) 474 if ( !*head )
475 *head = find; 475 *head = find;
476 *tail = find; 476 *tail = find;
477 477
478 if ( dt ) { 478 if ( dt ) {
479 int i; 479 int i;
480 480
481 for ( i = 0; i < dt-> m_depcnt; i++ ) 481 for ( i = 0; i < dt-> m_depcnt; i++ )
482 check_dep ( dt-> m_deparr [i], head, tail ); 482 check_dep ( dt-> m_deparr [i], head, tail );
483 } 483 }
@@ -490,34 +490,34 @@ static int mod_insert ( char *mod, int argc, char **argv )
490 struct mod_list_t *tail = 0; 490 struct mod_list_t *tail = 0;
491 struct mod_list_t *head = 0; 491 struct mod_list_t *head = 0;
492 int rc; 492 int rc;
493 493
494 // get dep list for module mod 494 // get dep list for module mod
495 check_dep ( mod, &head, &tail ); 495 check_dep ( mod, &head, &tail );
496 496
497 if ( head && tail ) { 497 if ( head && tail ) {
498 if ( argc ) { 498 if ( argc ) {
499 int i; 499 int i;
500 int l = 0; 500 int l = 0;
501 501
502 // append module args 502 // append module args
503 for ( i = 0; i < argc; i++ ) 503 for ( i = 0; i < argc; i++ )
504 l += ( bb_strlen ( argv [i] ) + 1 ); 504 l += ( bb_strlen ( argv [i] ) + 1 );
505 505
506 head-> m_options = xrealloc ( head-> m_options, l + 1 ); 506 head-> m_options = xrealloc ( head-> m_options, l + 1 );
507 head-> m_options [0] = 0; 507 head-> m_options [0] = 0;
508 508
509 for ( i = 0; i < argc; i++ ) { 509 for ( i = 0; i < argc; i++ ) {
510 strcat ( head-> m_options, argv [i] ); 510 strcat ( head-> m_options, argv [i] );
511 strcat ( head-> m_options, " " ); 511 strcat ( head-> m_options, " " );
512 } 512 }
513 } 513 }
514 514
515 // process tail ---> head 515 // process tail ---> head
516 rc = mod_process ( tail, 1 ); 516 rc = mod_process ( tail, 1 );
517 } 517 }
518 else 518 else
519 rc = 1; 519 rc = 1;
520 520
521 return rc; 521 return rc;
522} 522}
523 523
@@ -525,21 +525,21 @@ static int mod_remove ( char *mod )
525{ 525{
526 int rc; 526 int rc;
527 static struct mod_list_t rm_a_dummy = { "-a", 0, 0 }; 527 static struct mod_list_t rm_a_dummy = { "-a", 0, 0 };
528 528
529 struct mod_list_t *head = 0; 529 struct mod_list_t *head = 0;
530 struct mod_list_t *tail = 0; 530 struct mod_list_t *tail = 0;
531 531
532 if ( mod ) 532 if ( mod )
533 check_dep ( mod, &head, &tail ); 533 check_dep ( mod, &head, &tail );
534 else // autoclean 534 else // autoclean
535 head = tail = &rm_a_dummy; 535 head = tail = &rm_a_dummy;
536 536
537 if ( head && tail ) 537 if ( head && tail )
538 rc = mod_process ( head, 0 ); // process head ---> tail 538 rc = mod_process ( head, 0 ); // process head ---> tail
539 else 539 else
540 rc = 1; 540 rc = 1;
541 return rc; 541 return rc;
542 542
543} 543}
544 544
545 545
@@ -553,67 +553,67 @@ extern int modprobe_main(int argc, char** argv)
553 553
554 while ((opt = getopt(argc, argv, "acdklnqrst:vVC:")) != -1) { 554 while ((opt = getopt(argc, argv, "acdklnqrst:vVC:")) != -1) {
555 switch(opt) { 555 switch(opt) {
556 case 'c': // no config used 556 case 'c': // no config used
557 case 'l': // no pattern matching 557 case 'l': // no pattern matching
558 return EXIT_SUCCESS; 558 return EXIT_SUCCESS;
559 break; 559 break;
560 case 'C': // no config used 560 case 'C': // no config used
561 case 't': // no pattern matching 561 case 't': // no pattern matching
562 bb_error_msg_and_die("-t and -C not supported"); 562 bb_error_msg_and_die("-t and -C not supported");
563 563
564 case 'a': // ignore 564 case 'a': // ignore
565 case 'd': // ignore 565 case 'd': // ignore
566 break; 566 break;
567 case 'k': 567 case 'k':
568 autoclean++; 568 autoclean++;
569 break; 569 break;
570 case 'n': 570 case 'n':
571 show_only++; 571 show_only++;
572 break; 572 break;
573 case 'q': 573 case 'q':
574 quiet++; 574 quiet++;
575 break; 575 break;
576 case 'r': 576 case 'r':
577 remove_opt++; 577 remove_opt++;
578 break; 578 break;
579 case 's': 579 case 's':
580 do_syslog++; 580 do_syslog++;
581 break; 581 break;
582 case 'v': 582 case 'v':
583 verbose++; 583 verbose++;
584 break; 584 break;
585 case 'V': 585 case 'V':
586 default: 586 default:
587 bb_show_usage(); 587 bb_show_usage();
588 break; 588 break;
589 } 589 }
590 } 590 }
591 591
592 depend = build_dep ( ); 592 depend = build_dep ( );
593 593
594 if ( !depend ) 594 if ( !depend )
595 bb_error_msg_and_die ( "could not parse modules.dep\n" ); 595 bb_error_msg_and_die ( "could not parse modules.dep\n" );
596 596
597 if (remove_opt) { 597 if (remove_opt) {
598 int rc = EXIT_SUCCESS; 598 int rc = EXIT_SUCCESS;
599 do { 599 do {
600 if (mod_remove ( optind < argc ? 600 if (mod_remove ( optind < argc ?
601 bb_xstrdup (argv [optind]) : NULL )) { 601 bb_xstrdup (argv [optind]) : NULL )) {
602 bb_error_msg ("failed to remove module %s", 602 bb_error_msg ("failed to remove module %s",
603 argv [optind] ); 603 argv [optind] );
604 rc = EXIT_FAILURE; 604 rc = EXIT_FAILURE;
605 } 605 }
606 } while ( ++optind < argc ); 606 } while ( ++optind < argc );
607 607
608 return rc; 608 return rc;
609 } 609 }
610 610
611 if (optind >= argc) 611 if (optind >= argc)
612 bb_error_msg_and_die ( "No module or pattern provided\n" ); 612 bb_error_msg_and_die ( "No module or pattern provided\n" );
613 613
614 if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 )) 614 if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 ))
615 bb_error_msg_and_die ( "failed to load module %s", argv [optind] ); 615 bb_error_msg_and_die ( "failed to load module %s", argv [optind] );
616 616
617 return EXIT_SUCCESS; 617 return EXIT_SUCCESS;
618} 618}
619 619