diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2011-01-16 22:44:12 -0800 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2011-01-16 23:07:47 -0800 |
commit | 4d155cbf37ca909daff06dd8c7119274d0861f6c (patch) | |
tree | fe9d460fb46097986fe234fddb3f9bd2935c8642 /src/bios_dev_name.c | |
parent | 9405281a9e16e55af687c98a83d327946953cc09 (diff) | |
download | vyatta-biosdevname-4d155cbf37ca909daff06dd8c7119274d0861f6c.tar.gz vyatta-biosdevname-4d155cbf37ca909daff06dd8c7119274d0861f6c.zip |
Merge upstream version 0.3.4.
(cherry picked from commit 21eb1c8d6fefa5dcd3a9a800b4add06d5c30c01f)
Diffstat (limited to 'src/bios_dev_name.c')
-rw-r--r-- | src/bios_dev_name.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/bios_dev_name.c b/src/bios_dev_name.c index ce13742..5757363 100644 --- a/src/bios_dev_name.c +++ b/src/bios_dev_name.c @@ -19,27 +19,23 @@ static void usage(void) fprintf(stderr, " Options:\n"); fprintf(stderr, " -i or --interface treat [args] as ethernet devs\n"); fprintf(stderr, " -d or --debug enable debugging\n"); - fprintf(stderr, " -n or --nosort don't sort the PCI device list breadth-first\n"); - fprintf(stderr, " --policy [kernelnames | all_ethN | all_names | embedded_ethN_slots_names]\n"); + fprintf(stderr, " --policy [physical | all_ethN ]\n"); + fprintf(stderr, " --prefix [string] string use for embedded NICs (default='em')\n"); fprintf(stderr, " Example: biosdevname -i eth0\n"); - fprintf(stderr, " returns: eth0\n"); - fprintf(stderr, " when the BIOS name and kernel name are both eth0.\n"); - fprintf(stderr, " --nosort implies --policy kernelnames.\n"); + fprintf(stderr, " returns: em1\n"); + fprintf(stderr, " when eth0 is an embedded NIC with label '1' on the chassis.\n"); fprintf(stderr, " You must be root to run this, as it must read from /dev/mem.\n"); } static int set_policy(const char *arg) { - int rc = all_ethN; - if (!strncmp("kernelnames", arg, sizeof("kernelnames"))) - rc = kernelnames; + int rc = physical; + + if (!strncmp("physical", arg, sizeof("physical"))) + rc = physical; else if (!strncmp("all_ethN", arg, sizeof("all_ethN"))) rc = all_ethN; - else if (!strncmp("all_names", arg, sizeof("all_names"))) - rc = all_names; - else if (!strncmp("embedded_ethN_slots_names", arg, sizeof("embedded_ethN_slots_names"))) - rc = embedded_ethN_slots_names; return rc; } @@ -55,8 +51,8 @@ parse_opts(int argc, char **argv) { {"debug", no_argument, 0, 'd'}, {"interface", no_argument, 0, 'i'}, - {"nosort", no_argument, 0, 'n'}, {"policy", required_argument, 0, 'p'}, + {"prefix", required_argument, 0, 'P'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, @@ -71,12 +67,12 @@ parse_opts(int argc, char **argv) case 'i': opts.interface = 1; break; - case 'n': - opts.sortroutine = nosort; - break; case 'p': opts.namingpolicy = set_policy(optarg); break; + case 'P': + opts.prefix = optarg; + break; default: usage(); exit(1); @@ -89,8 +85,8 @@ parse_opts(int argc, char **argv) opts.optind = optind; } - if (opts.sortroutine == nosort) - opts.namingpolicy = kernelnames; + if (opts.prefix == NULL) + opts.prefix = "em"; } int main(int argc, char *argv[]) @@ -100,9 +96,8 @@ int main(int argc, char *argv[]) void *cookie = NULL; parse_opts(argc, argv); - cookie = setup_bios_devices(opts.sortroutine, opts.namingpolicy); + cookie = setup_bios_devices(opts.namingpolicy, opts.prefix); if (!cookie) { - usage(); rc = 1; goto out; } |