9
0
Fork 0

Merge branch 'for-next/nfs'

Conflicts:
	defaultenv/defaultenv-2-base/bin/ifup
This commit is contained in:
Sascha Hauer 2014-03-07 09:25:44 +01:00
commit 144358e0aa
31 changed files with 1088 additions and 429 deletions

View File

@ -126,7 +126,7 @@ static int rpi_env_init(void)
}
mkdir("/boot", 0666);
ret = mount(diskdev, "fat", "/boot");
ret = mount(diskdev, "fat", "/boot", NULL);
if (ret) {
printf("failed to mount %s\n", diskdev);
return 0;

View File

@ -136,7 +136,7 @@ static int omap_env_init(void)
}
mkdir("/boot", 0666);
ret = mount(diskdev, "fat", "/boot");
ret = mount(diskdev, "fat", "/boot", NULL);
if (ret) {
printf("failed to mount %s\n", diskdev);
return 0;

View File

@ -110,7 +110,7 @@ static void *omap_xload_boot_mmc(void)
partname = asprintf("%s.0", diskdev);
ret = mount(partname, "fat", "/");
ret = mount(partname, "fat", "/", NULL);
free(partname);
@ -170,7 +170,7 @@ static void *omap4_xload_boot_usb(void){
void *buf;
int len;
ret = mount("omap4_usbboot", "omap4_usbbootfs", "/");
ret = mount("omap4_usbboot", "omap4_usbbootfs", "/", NULL);
if (ret) {
printf("Unable to mount omap4_usbbootfs (%d)\n", ret);
return NULL;

View File

@ -97,7 +97,7 @@ static int socfpga_env_init(void)
}
mkdir("/boot", 0666);
ret = mount(partname, "fat", "/boot");
ret = mount(partname, "fat", "/boot", NULL);
if (ret) {
printf("failed to mount %s\n", diskdev);
goto out_free;

View File

@ -47,7 +47,7 @@ static int boot_script(char *path)
globalvar_set_match("linux.bootargs.dyn.", "");
globalvar_set_match("bootm.", "");
ret = run_command(path, 0);
ret = run_command(path);
if (ret) {
printf("Running %s failed\n", path);
goto out;

View File

@ -39,7 +39,7 @@ static int do_exec(int argc, char *argv[])
if (!script)
return 1;
if (run_command (script, 0) == -1)
if (run_command(script) == -1)
goto out;
free(script);
}

View File

@ -68,7 +68,7 @@ static int do_login(int argc, char *argv[])
if (passwd_len < 0) {
console_allow_input(false);
run_command(timeout_cmd, 0);
run_command(timeout_cmd);
}
if (check_passwd(passwd, passwd_len))

View File

@ -33,26 +33,31 @@ static int do_mount(int argc, char *argv[])
{
int opt;
int ret = 0, verbose = 0;
struct fs_device_d *fsdev;
struct driver_d *drv;
const char *type = NULL;
const char *mountpoint, *dev;
const char *fsoptions = NULL;
while ((opt = getopt(argc, argv, "t:va")) > 0) {
while ((opt = getopt(argc, argv, "ao:t:v")) > 0) {
switch (opt) {
case 'a':
mount_all();
break;
case 't':
type = optarg;
break;
case 'o':
fsoptions = optarg;
break;
case 'v':
verbose++;
break;
case 'a':
mount_all();
break;
}
}
if (argc == optind) {
struct fs_device_d *fsdev;
for_each_fs_device(fsdev) {
printf("%s on %s type %s\n",
fsdev->backingstore ? fsdev->backingstore : "none",
@ -84,7 +89,7 @@ static int do_mount(int argc, char *argv[])
if (!cdev)
return -ENOENT;
path = cdev_mount_default(cdev);
path = cdev_mount_default(cdev, fsoptions);
if (IS_ERR(path))
return PTR_ERR(path);
@ -108,7 +113,7 @@ static int do_mount(int argc, char *argv[])
mountpoint = argv[optind + 1];
}
if ((ret = mount(dev, type, mountpoint))) {
if ((ret = mount(dev, type, mountpoint, fsoptions))) {
perror("mount");
return 1;
}

View File

@ -72,7 +72,7 @@ static int do_tftpb(int argc, char *argv[])
goto err_free;
ip = net_get_serverip();
ret = mount(ip_to_string(ip), "tftp", TFTP_MOUNT_PATH);
ret = mount(ip_to_string(ip), "tftp", TFTP_MOUNT_PATH, NULL);
if (ret)
goto err_rmdir;

View File

@ -27,7 +27,7 @@ static int do_time(int argc, char *argv[])
start = get_time_ns();
run_command(buf, 0);
run_command(buf);
end = get_time_ns();

View File

@ -596,6 +596,7 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
select CMD_DIRNAME
select FLEXIBLE_BOOTARGS
select CMD_BOOT
select NET_CMD_IFUP if NET
prompt "Generic environment template"
config DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU

View File

@ -10,6 +10,8 @@
* GNU General Public License for more details.
*
*/
#define pr_fmt(fmt) "blspec: " fmt
#include <environment.h>
#include <globalvar.h>
#include <readkey.h>
@ -22,6 +24,7 @@
#include <libbb.h>
#include <init.h>
#include <boot.h>
#include <net.h>
#include <fs.h>
#include <of.h>
#include <linux/stat.h>
@ -130,6 +133,107 @@ static int blspec_have_entry(struct blspec *blspec, const char *path)
return 0;
}
/*
* nfs_find_mountpath - Check if a given url is already mounted
*/
static const char *nfs_find_mountpath(const char *nfshostpath)
{
struct fs_device_d *fsdev;
for_each_fs_device(fsdev) {
if (fsdev->backingstore && !strcmp(fsdev->backingstore, nfshostpath))
return fsdev->path;
}
return NULL;
}
/*
* parse_nfs_url - check for nfs:// style url
*
* Check if the passed string is a NFS url and if yes, mount the
* NFS and return the path we have mounted to.
*/
static char *parse_nfs_url(const char *url)
{
char *sep, *str, *host, *port, *path;
char *mountpath = NULL, *hostpath = NULL, *options = NULL;
const char *prevpath;
IPaddr_t ip;
int ret;
if (!IS_ENABLED(CONFIG_FS_NFS))
return ERR_PTR(-ENOSYS);
if (strncmp(url, "nfs://", 6))
return ERR_PTR(-EINVAL);
url += 6;
str = xstrdup(url);
host = str;
sep = strchr(str, '/');
if (!sep) {
ret = -EINVAL;
goto out;
}
*sep++ = 0;
path = sep;
port = strchr(host, ':');
if (port)
*port++ = 0;
ret = ifup_all(0);
if (ret) {
pr_err("Failed to bring up networking\n");
goto out;
}
ip = resolv(host);
if (ip == 0)
goto out;
hostpath = asprintf("%s:%s", ip_to_string(ip), path);
prevpath = nfs_find_mountpath(hostpath);
if (prevpath) {
mountpath = xstrdup(prevpath);
} else {
mountpath = asprintf("/mnt/nfs-%s-blspec-%08x", host, rand());
if (port)
options = asprintf("mountport=%s,port=%s", port, port);
ret = make_directory(mountpath);
if (ret)
goto out;
pr_debug("host: %s port: %s path: %s\n", host, port, path);
pr_debug("hostpath: %s mountpath: %s options: %s\n", hostpath, mountpath, options);
ret = mount(hostpath, "nfs", mountpath, options);
if (ret)
goto out;
}
ret = 0;
out:
free(str);
free(hostpath);
free(options);
if (ret)
free(mountpath);
return ret ? ERR_PTR(ret) : mountpath;
}
/*
* blspec_scan_directory - scan over a directory
*
@ -145,9 +249,13 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
char *abspath;
int ret, found = 0;
const char *dirname = "loader/entries";
char *entry_default = NULL, *entry_once = NULL, *name;
char *entry_default = NULL, *entry_once = NULL, *name, *nfspath = NULL;
pr_debug("%s: %s %s\n", __func__, root, dirname);
nfspath = parse_nfs_url(root);
if (!IS_ERR(nfspath))
root = nfspath;
pr_info("%s: %s %s\n", __func__, root, dirname);
entry_default = read_file_line("%s/default", root);
entry_once = read_file_line("%s/once", root);
@ -239,6 +347,8 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
closedir(dir);
err_out:
if (!IS_ERR(nfspath))
free(nfspath);
free(abspath);
free(entry_default);
free(entry_once);
@ -276,7 +386,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
if (type == filetype_mbr || type == filetype_gpt)
return -EINVAL;
rootpath = cdev_mount_default(cdev);
rootpath = cdev_mount_default(cdev, NULL);
if (IS_ERR(rootpath))
return PTR_ERR(rootpath);

View File

@ -1824,7 +1824,7 @@ static char * make_string(char ** inp)
return str;
}
int run_command (const char *cmd, int flag)
int run_command(const char *cmd)
{
struct p_context ctx;
int ret;

View File

@ -468,7 +468,7 @@ static void menu_action_command(struct menu *m, struct menu_entry *me)
if (!s)
s = e->command;
ret = run_command (s, 0);
ret = run_command(s);
if (ret < 0)
udelay(1000000);

View File

@ -176,7 +176,7 @@ static void process_macros (const char *input, char *output)
* creates or modifies environment variables (like "bootp" does).
*/
int run_command (const char *cmd, int flag)
int run_command(const char *cmd)
{
char cmdbuf[CONFIG_CBSIZE]; /* working copy of cmd */
char *token; /* start of token in cmdbuf */
@ -265,18 +265,17 @@ int run_shell(void)
static char lastcommand[CONFIG_CBSIZE] = { 0, };
int len;
int rc = 1;
int flag;
for (;;) {
len = readline (CONFIG_PROMPT, console_buffer, CONFIG_CBSIZE);
flag = 0; /* assume no special flags for now */
if (len > 0)
strcpy (lastcommand, console_buffer);
if (len == -1)
puts ("<INTERRUPT>\n");
else
rc = run_command (lastcommand, flag);
rc = run_command(lastcommand);
if (rc <= 0) {
/* invalid command or not repeatable, forget it */

View File

@ -47,9 +47,9 @@ extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
#if defined CONFIG_FS_RAMFS && defined CONFIG_FS_DEVFS
static int mount_root(void)
{
mount("none", "ramfs", "/");
mount("none", "ramfs", "/", NULL);
mkdir("/dev", 0);
mount("none", "devfs", "/dev");
mount("none", "devfs", "/dev", NULL);
return 0;
}
fs_initcall(mount_root);
@ -95,11 +95,11 @@ void __noreturn start_barebox(void)
pr_info("running /env/bin/init...\n");
if (!stat("/env/bin/init", &s)) {
run_command("source /env/bin/init", 0);
run_command("source /env/bin/init");
} else {
pr_err("/env/bin/init not found\n");
if (IS_ENABLED(CONFIG_CMD_LOGIN))
while(run_command("login -t 0", 0));
while(run_command("login -t 0"));
}
}

View File

@ -1,67 +0,0 @@
#!/bin/sh
mkdir -p /tmp/network
if [ $# != 1 ]; then
echo "usage: ifup <interface>"
exit 1
fi
interface="$1"
if [ -f /tmp/network/$interface ]; then
exit 0
fi
cmd=/env/network/$interface
if [ ! -e $cmd ]; then
echo "$f: no such file"
exit 1
fi
ip=
ipaddr=
netmask=
gateway=
serverip=
ethaddr=
. $cmd
if [ $? != 0 ]; then
echo "failed to bring up $interface"
exit 1
fi
if [ -f /env/network/${interface}-discover ]; then
/env/network/${interface}-discover
if [ $? != 0 ]; then
echo "failed to discover eth0"
exit 1
fi
fi
if [ -n "$ethaddr" ]; then
${interface}.ethaddr=$ethaddr
fi
if [ "$ip" = static ]; then
${interface}.ipaddr=$ipaddr
${interface}.netmask=$netmask
${interface}.serverip=$serverip
${interface}.gateway=$gateway
ret=0
elif [ "$ip" = dhcp ]; then
dhcp
ret=$?
if [ $ret = 0 -a -n "$serverip" ]; then
${interface}.serverip=$serverip
fi
fi
if [ $ret = 0 ]; then
echo -o /tmp/network/$interface up
fi
exit $ret

View File

@ -8,6 +8,6 @@ obj-y += fs.o
obj-$(CONFIG_FS_UBIFS) += ubifs/
obj-$(CONFIG_FS_TFTP) += tftp.o
obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o
obj-$(CONFIG_FS_NFS) += nfs.o
obj-$(CONFIG_FS_NFS) += nfs.o parseopt.o
obj-$(CONFIG_FS_BPKFS) += bpkfs.o
obj-$(CONFIG_FS_UIMAGEFS) += uimagefs.o

21
fs/fs.c
View File

@ -435,7 +435,7 @@ static void automount_mount(const char *path, int instat)
setenv("automount_path", am->path);
export("automount_path");
ret = run_command(am->cmd, 0);
ret = run_command(am->cmd);
setenv("automount_path", NULL);
if (ret)
@ -1243,6 +1243,7 @@ static void fs_remove(struct device_d *dev)
}
free(fsdev->path);
free(fsdev->options);
if (fsdev == fs_dev_root)
fs_dev_root = NULL;
@ -1317,13 +1318,18 @@ int fsdev_open_cdev(struct fs_device_d *fsdev)
* We do this by registering a new device on which the filesystem
* driver will match.
*/
int mount(const char *device, const char *fsname, const char *_path)
int mount(const char *device, const char *fsname, const char *_path,
const char *fsoptions)
{
struct fs_device_d *fsdev;
int ret;
char *path = normalise_path(_path);
debug("mount: %s on %s type %s\n", device, path, fsname);
if (!fsoptions)
fsoptions = "";
debug("mount: %s on %s type %s, options=%s\n",
device, path, fsname, fsoptions);
if (fs_dev_root) {
fsdev = get_fsdevice_by_path(path);
@ -1355,6 +1361,7 @@ int mount(const char *device, const char *fsname, const char *_path)
fsdev->dev.id = get_free_deviceid(fsdev->dev.name);
fsdev->path = xstrdup(path);
fsdev->dev.bus = &fs_bus;
fsdev->options = xstrdup(fsoptions);
ret = register_device(&fsdev->dev);
if (ret)
@ -1712,7 +1719,7 @@ const char *cdev_get_mount_path(struct cdev *cdev)
* mount it to /mnt/<cdevname> and return the path. Returns an error pointer
* on failure.
*/
const char *cdev_mount_default(struct cdev *cdev)
const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions)
{
const char *path;
char *newpath, *devpath;
@ -1721,7 +1728,7 @@ const char *cdev_mount_default(struct cdev *cdev)
/*
* If this cdev is already mounted somewhere use this path
* instead of mounting it again to avoid corruption on the
* filesystem.
* filesystem. Note this ignores eventual fsoptions though.
*/
path = cdev_get_mount_path(cdev);
if (path)
@ -1732,7 +1739,7 @@ const char *cdev_mount_default(struct cdev *cdev)
devpath = asprintf("/dev/%s", cdev->name);
ret = mount(devpath, NULL, newpath);
ret = mount(devpath, NULL, newpath, fsoptions);
free(devpath);
@ -1762,6 +1769,6 @@ void mount_all(void)
struct cdev *cdev = &bdev->cdev;
list_for_each_entry(cdev, &bdev->dev->cdevs, devices_list)
cdev_mount_default(cdev);
cdev_mount_default(cdev, NULL);
}
}

967
fs/nfs.c

File diff suppressed because it is too large Load Diff

34
fs/parseopt.c Normal file
View File

@ -0,0 +1,34 @@
#include <common.h>
#include "parseopt.h"
void parseopt_hu(const char *options, const char *opt, unsigned short *val)
{
const char *start;
size_t optlen = strlen(opt);
ulong v;
char *endp;
again:
start = strstr(options, opt);
if (!start)
return;
if (start > options && start[-1] != ',') {
options = start;
goto again;
}
if (start[optlen] != '=') {
options = start;
goto again;
}
v = simple_strtoul(start + optlen + 1, &endp, 0);
if (v > USHORT_MAX)
return;
if (*endp == ',' || *endp == '\0')
*val = v;
}

1
fs/parseopt.h Normal file
View File

@ -0,0 +1 @@
void parseopt_hu(const char *options, const char *opt, unsigned short *val);

24
include/byteorder.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef __BYTEORDER_H__
#define __BYTEORDER_H__
/*
* The standard macros for converting between host and network byte order are
* badly named. So ntohl converts 32 bits even on architectures where a long is
* 64 bit wide although the 'l' suffix suggests that it's working on longs.
*
* So this file introduces variants that use the bitcount as suffix instead of
* 's' or 'l'.
*/
#include <asm/byteorder.h>
#define ntoh16(x) __be16_to_cpu(x)
#define hton16(x) __cpu_to_be16(x)
#define ntoh32(x) __be32_to_cpu(x)
#define hton32(x) __cpu_to_be32(x)
#define ntoh64(x) __be64_to_cpu(x)
#define hton64(x) __cpu_to_be64(x)
#endif /* __BYTEORDER_H__ */

View File

@ -92,8 +92,7 @@ void __noreturn panic(const char *fmt, ...);
char *size_human_readable(unsigned long long size);
/* common/main.c */
int run_command (const char *cmd, int flag);
int run_command(const char *cmd);
int readline (const char *prompt, char *buf, int len);
/* common/memsize.c */

View File

@ -99,6 +99,7 @@ struct fs_device_d {
char *path;
struct device_d *parent_device;
struct list_head list;
char *options;
};
#define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
@ -140,7 +141,8 @@ int closedir(DIR *dir);
int symlink(const char *pathname, const char *newpath);
int readlink(const char *path, char *buf, size_t bufsiz);
int mount (const char *device, const char *fsname, const char *path);
int mount (const char *device, const char *fsname, const char *path,
const char *fsoptions);
int umount(const char *pathname);
/* not-so-standard functions */
@ -197,7 +199,7 @@ int unlink_recursive(const char *path, char **failedpath);
int fsdev_open_cdev(struct fs_device_d *fsdev);
const char *cdev_get_mount_path(struct cdev *cdev);
const char *cdev_mount_default(struct cdev *cdev);
const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
void mount_all(void);
#endif /* __FS_H */

View File

@ -269,11 +269,18 @@ static inline IPaddr_t net_read_ip(void *from)
}
/* return uint32 *in network byteorder* */
static inline uint32_t net_read_uint32(uint32_t *from)
static inline uint32_t net_read_uint32(void *from)
{
ulong l;
memcpy((void*)&l, (void*)from, sizeof(l));
return l;
uint32_t tmp;
memcpy(&tmp, from, sizeof(tmp));
return tmp;
}
static inline uint64_t net_read_uint64(void *from)
{
uint64_t tmp;
memcpy(&tmp, from, sizeof(tmp));
return tmp;
}
/* write IP *in network byteorder* */
@ -397,7 +404,7 @@ typedef void rx_handler_f(void *ctx, char *packet, unsigned int len);
void eth_set_current(struct eth_device *eth);
struct eth_device *eth_get_current(void);
struct eth_device *eth_get_byname(char *name);
struct eth_device *eth_get_byname(const char *name);
/**
* net_receive - Pass a received packet from an ethernet driver to the protocol stack
@ -450,4 +457,9 @@ int net_icmp_send(struct net_connection *con, int len);
void led_trigger_network(enum led_trigger trigger);
#define IFUP_FLAG_FORCE (1 << 0)
int ifup(const char *name, unsigned flags);
int ifup_all(unsigned flags);
#endif /* __NET_H__ */

View File

@ -20,7 +20,7 @@ void* bootstrap_read_disk(char *dev, char *fstype)
int len;
char *path = "/";
ret = mount(dev, fstype, path);
ret = mount(dev, fstype, path, NULL);
if (ret) {
bootstrap_err("mounting %s failed with %d\n", dev, ret);
return NULL;

View File

@ -26,4 +26,15 @@ config NET_RESOLV
bool
prompt "dns support"
config NET_IFUP
default y
bool
config NET_CMD_IFUP
bool
prompt "ifup support"
help
This enables the 'ifup' command which is used to bring up network
interfaces based on config files under /env/network/<ethname>
endif

View File

@ -5,3 +5,4 @@ obj-$(CONFIG_NET_NFS) += nfs.o
obj-$(CONFIG_NET_PING) += ping.o
obj-$(CONFIG_NET_RESOLV)+= dns.o
obj-$(CONFIG_NET_NETCONSOLE) += netconsole.o
obj-$(CONFIG_NET_IFUP) += ifup.o

View File

@ -144,7 +144,7 @@ struct eth_device * eth_get_current(void)
return eth_current;
}
struct eth_device *eth_get_byname(char *ethname)
struct eth_device *eth_get_byname(const char *ethname)
{
struct eth_device *edev;

179
net/ifup.c Normal file
View File

@ -0,0 +1,179 @@
/*
* ifup.c - bring up network interfaces
*
* Copyright (c) 2014 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more detaiifup.
*
*/
#define pr_fmt(fmt) "ifup: " fmt
#include <environment.h>
#include <command.h>
#include <common.h>
#include <getopt.h>
#include <net.h>
#include <fs.h>
#include <linux/stat.h>
static char *vars[] = {
"ipaddr",
"netmask",
"gateway",
"serverip",
"ethaddr",
};
static int eth_set_param(struct device_d *dev, const char *param)
{
const char *value = getenv(param);
if (!value)
return 0;
if (!*value)
return 0;
return dev_set_param(dev, param, value);
}
int ifup(const char *name, unsigned flags)
{
int ret;
char *cmd, *cmd_discover;
const char *ip;
struct stat s;
int i;
struct device_d *dev;
struct eth_device *edev = eth_get_byname(name);
if (edev && edev->ipaddr && !(flags & IFUP_FLAG_FORCE))
return 0;
env_push_context();
setenv("ip", "");
for (i = 0; i < ARRAY_SIZE(vars); i++)
setenv(vars[i], "");
cmd = asprintf("source /env/network/%s", name);
cmd_discover = asprintf("/env/network/%s-discover", name);
ret = run_command(cmd);
if (ret)
goto out;
ret = stat(cmd_discover, &s);
if (!ret) {
ret = run_command(cmd_discover);
if (ret)
goto out;
}
dev = get_device_by_name(name);
if (!dev) {
pr_err("Cannot find device %s\n", name);
goto out;
}
ret = eth_set_param(dev, "ethaddr");
if (ret)
goto out;
ip = getenv("ip");
if (!strcmp(ip, "dhcp")) {
ret = run_command("dhcp");
if (ret)
goto out;
} else if (!strcmp(ip, "static")) {
for (i = 0; i < ARRAY_SIZE(vars); i++) {
ret = eth_set_param(dev, vars[i]);
if (ret)
goto out;
}
} else {
pr_err("unknown ip type: %s\n", ip);
ret = -EINVAL;
goto out;
}
ret = 0;
out:
env_pop_context();
free(cmd);
free(cmd_discover);
return ret;
}
int ifup_all(unsigned flags)
{
DIR *dir;
struct dirent *d;
dir = opendir("/env/network");
if (!dir)
return -ENOENT;
while ((d = readdir(dir))) {
if (*d->d_name == '.')
continue;
ifup(d->d_name, flags);
}
closedir(dir);
return 0;
}
#if IS_ENABLED(CONFIG_NET_CMD_IFUP)
static int do_ifup(int argc, char *argv[])
{
int opt;
unsigned flags = 0;
int all = 0;
while ((opt = getopt(argc, argv, "af")) > 0) {
switch (opt) {
case 'f':
flags |= IFUP_FLAG_FORCE;
break;
case 'a':
all = 1;
break;
}
}
if (all)
return ifup_all(flags);
if (argc == optind)
return COMMAND_ERROR_USAGE;
return ifup(argv[optind], flags);
}
BAREBOX_CMD_HELP_START(ifup)
BAREBOX_CMD_HELP_USAGE("ifup [OPTIONS] <interface>\n")
BAREBOX_CMD_HELP_OPT ("-a", "bring up all interfaces\n")
BAREBOX_CMD_HELP_OPT ("-f", "Force. Configure even if ip already set\n")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(ifup)
.cmd = do_ifup,
.usage = "Bring up network interfaces",
BAREBOX_CMD_HELP(cmd_ifup_help)
BAREBOX_CMD_END
#endif