diff options
| author | John Beppu <beppu@lbox.org> | 2000-06-28 00:41:26 +0000 |
|---|---|---|
| committer | John Beppu <beppu@lbox.org> | 2000-06-28 00:41:26 +0000 |
| commit | 7cdc76dfbf3eb294ada708d79865ea582eb074af (patch) | |
| tree | 9f8ac9f08e4078ced0a62b071bdb7d9fd8a062fc /applets | |
| parent | d0edef3cbe37880b0dd402614413eb490b39c9e1 (diff) | |
| download | busybox-w32-7cdc76dfbf3eb294ada708d79865ea582eb074af.tar.gz busybox-w32-7cdc76dfbf3eb294ada708d79865ea582eb074af.tar.bz2 busybox-w32-7cdc76dfbf3eb294ada708d79865ea582eb074af.zip | |
+ busybox --install [-s]
is functional (but disabled in busybox.def.h by default)
Someone email the guy who originally wanted this.
Diffstat (limited to 'applets')
| -rw-r--r-- | applets/busybox.c | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/applets/busybox.c b/applets/busybox.c index e454bb6ec..2a686041a 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
| @@ -376,6 +376,31 @@ static char* install_dir[] = { | |||
| 376 | /* abstract link() */ | 376 | /* abstract link() */ |
| 377 | typedef int (*__link_f)(const char *, const char *); | 377 | typedef int (*__link_f)(const char *, const char *); |
| 378 | 378 | ||
| 379 | /* | ||
| 380 | * Where in the filesystem is this busybox? | ||
| 381 | * [return] | ||
| 382 | * malloc'd string w/ full pathname of busybox's location | ||
| 383 | * NULL on failure | ||
| 384 | */ | ||
| 385 | static char *busybox_fullpath() | ||
| 386 | { | ||
| 387 | pid_t pid; | ||
| 388 | char path[256]; | ||
| 389 | char proc[256]; | ||
| 390 | int len; | ||
| 391 | |||
| 392 | pid = getpid(); | ||
| 393 | sprintf(proc, "/proc/%d/exe", pid); | ||
| 394 | len = readlink(proc, path, 256); | ||
| 395 | if (len != -1) { | ||
| 396 | path[len] = 0; | ||
| 397 | } else { | ||
| 398 | fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno)); | ||
| 399 | return NULL; | ||
| 400 | } | ||
| 401 | return strdup(path); | ||
| 402 | } | ||
| 403 | |||
| 379 | /* create (sym)links for each applet */ | 404 | /* create (sym)links for each applet */ |
| 380 | static int install_links(const char *busybox, int use_symbolic_links) | 405 | static int install_links(const char *busybox, int use_symbolic_links) |
| 381 | { | 406 | { |
| @@ -394,14 +419,13 @@ static int install_links(const char *busybox, int use_symbolic_links) | |||
| 394 | install_dir[applets[i].location], | 419 | install_dir[applets[i].location], |
| 395 | applets[i].name | 420 | applets[i].name |
| 396 | ); | 421 | ); |
| 397 | #if 0 | 422 | #if 1 |
| 398 | rc |= Link(busybox, command); | 423 | rc |= Link(busybox, command); |
| 399 | #else | 424 | #else |
| 400 | puts(command); | 425 | puts(command); |
| 401 | #endif | 426 | #endif |
| 402 | if (rc) { | 427 | if (rc) { |
| 403 | fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); | 428 | fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); |
| 404 | break; | ||
| 405 | } | 429 | } |
| 406 | } | 430 | } |
| 407 | return rc; | 431 | return rc; |
| @@ -427,6 +451,8 @@ int main(int argc, char **argv) | |||
| 427 | */ | 451 | */ |
| 428 | if (argc > 1 && (strcmp(argv[1], "--install") == 0)) { | 452 | if (argc > 1 && (strcmp(argv[1], "--install") == 0)) { |
| 429 | int use_symbolic_links = 0; | 453 | int use_symbolic_links = 0; |
| 454 | int rc = 0; | ||
| 455 | char *busybox; | ||
| 430 | 456 | ||
| 431 | /* to use symlinks, or not to use symlinks... */ | 457 | /* to use symlinks, or not to use symlinks... */ |
| 432 | if (argc > 2) { | 458 | if (argc > 2) { |
| @@ -434,13 +460,16 @@ int main(int argc, char **argv) | |||
| 434 | use_symbolic_links = 1; | 460 | use_symbolic_links = 1; |
| 435 | } | 461 | } |
| 436 | } | 462 | } |
| 437 | /* | 463 | |
| 438 | * FIXME : | 464 | /* link */ |
| 439 | * I need a clever unix trick that'll tell | 465 | busybox = busybox_fullpath(); |
| 440 | * me where to find the currently running | 466 | if (busybox) { |
| 441 | * busybox binary | 467 | install_links(busybox, use_symbolic_links); |
| 442 | */ | 468 | free(busybox); |
| 443 | return install_links("/bin/busybox", use_symbolic_links); | 469 | } else { |
| 470 | rc = 1; | ||
| 471 | } | ||
| 472 | return rc; | ||
| 444 | } | 473 | } |
| 445 | #endif /* BB_FEATURE_INSTALLER */ | 474 | #endif /* BB_FEATURE_INSTALLER */ |
| 446 | 475 | ||
