busybox --list option. +140 bytes. Rob wanted it.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-04-20 21:02:57 -04:00
parent f2c16edf99
commit 5a7c72015c

View File

@ -595,6 +595,17 @@ static void check_suid(int applet_no)
#if ENABLE_FEATURE_INSTALLER
static const char usr_bin [] ALIGN1 = "/usr/bin/";
static const char usr_sbin[] ALIGN1 = "/usr/sbin/";
static const char *const install_dir[] = {
&usr_bin [8], /* "/" */
&usr_bin [4], /* "/bin/" */
&usr_sbin[4], /* "/sbin/" */
usr_bin,
usr_sbin
};
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links,
char *custom_install_dir)
@ -602,16 +613,6 @@ static void install_links(const char *busybox, int use_symbolic_links,
/* directory table
* this should be consistent w/ the enum,
* busybox.h::bb_install_loc_t, or else... */
static const char usr_bin [] ALIGN1 = "/usr/bin";
static const char usr_sbin[] ALIGN1 = "/usr/sbin";
static const char *const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
};
int (*lf)(const char *, const char *);
char *fpc;
unsigned i;
@ -635,8 +636,8 @@ static void install_links(const char *busybox, int use_symbolic_links,
}
}
#else
#define install_links(x,y,z) ((void)0)
#endif /* FEATURE_INSTALLER */
# define install_links(x,y,z) ((void)0)
#endif
/* If we were called as "busybox..." */
static int busybox_main(char **argv)
@ -669,7 +670,8 @@ static int busybox_main(char **argv)
"\tlink to busybox for each function they wish to use and BusyBox\n"
"\twill act like whatever it was invoked as.\n"
"\n"
"Currently defined functions:\n");
"Currently defined functions:\n"
);
col = 0;
a = applet_names;
/* prevent last comma to be in the very last pos */
@ -694,6 +696,23 @@ static int busybox_main(char **argv)
return 0;
}
if (strncmp(argv[1], "--list", 6) == 0) {
unsigned i = 0;
const char *a = applet_names;
dup2(1, 2);
while (*a) {
#if ENABLE_FEATURE_INSTALLER
if (argv[1][6]) /* --list-path? */
full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1);
#endif
full_write2_str(a);
full_write2_str("\n");
i++;
a += strlen(a) + 1;
}
return 0;
}
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
int use_symbolic_links;
const char *busybox;