diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 13:13:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 20:34:28 +0200 |
commit | 7782c08047fc44874caf1c03c153a070f9ac557a (patch) | |
tree | 54ef13545a93221b2b4598822c3f3b830c2c82d4 /common | |
parent | 038be0fbb5e983a498752b283319ba926f994a4b (diff) | |
parent | 46ff98b011c86511a8585a01fa3c4fbb774c9c54 (diff) | |
download | barebox-7782c08047fc44874caf1c03c153a070f9ac557a.tar.gz barebox-7782c08047fc44874caf1c03c153a070f9ac557a.tar.xz |
Merge branch 'for-next/usb-gadget'
Conflicts:
commands/Makefile
common/Kconfig
common/Makefile
drivers/usb/gadget/dfu.c
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 3 | ||||
-rw-r--r-- | common/Makefile | 1 | ||||
-rw-r--r-- | common/file-list.c | 113 | ||||
-rw-r--r-- | common/version.c | 4 |
4 files changed, 121 insertions, 0 deletions
diff --git a/common/Kconfig b/common/Kconfig index d3d9b884cf..9cc96b776d 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -88,6 +88,9 @@ config EFI_GUID config EFI_DEVICEPATH bool +config FILE_LIST + bool + menu "General Settings" config LOCALVERSION diff --git a/common/Makefile b/common/Makefile index ddd7db2578..51b7d4ea85 100644 --- a/common/Makefile +++ b/common/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_EFI_GUID) += efi-guid.o obj-$(CONFIG_EFI_DEVICEPATH) += efi-devicepath.o lwl-$(CONFIG_IMD) += imd-barebox.o obj-$(CONFIG_IMD) += imd.o +obj-$(CONFIG_FILE_LIST) += file-list.o quiet_cmd_pwd_h = PWDH $@ ifdef CONFIG_PASSWORD diff --git a/common/file-list.c b/common/file-list.c new file mode 100644 index 0000000000..90c0f429c5 --- /dev/null +++ b/common/file-list.c @@ -0,0 +1,113 @@ +#include <common.h> +#include <malloc.h> +#include <fs.h> +#include <file-list.h> +#include <linux/err.h> + +#define PARSE_DEVICE 0 +#define PARSE_NAME 1 +#define PARSE_FLAGS 2 + +static int file_list_parse_one(struct file_list *files, const char *partstr, const char **endstr) +{ + int i = 0, state = PARSE_DEVICE; + char filename[PATH_MAX]; + char name[PATH_MAX]; + struct file_list_entry *entry = xzalloc(sizeof(*entry)); + + memset(filename, 0, sizeof(filename)); + memset(name, 0, sizeof(name)); + + while (*partstr && *partstr != ',') { + switch (state) { + case PARSE_DEVICE: + if (*partstr == '(') { + state = PARSE_NAME; + i = 0; + } else { + filename[i++] = *partstr; + } + break; + case PARSE_NAME: + if (*partstr == ')') { + state = PARSE_FLAGS; + i = 0; + } else { + name[i++] = *partstr; + } + break; + case PARSE_FLAGS: + switch (*partstr) { + case 's': + entry->flags |= FILE_LIST_FLAG_SAFE; + break; + case 'r': + entry->flags |= FILE_LIST_FLAG_READBACK; + break; + case 'c': + entry->flags |= FILE_LIST_FLAG_CREATE; + break; + default: + return -EINVAL; + } + break; + default: + return -EINVAL; + } + partstr++; + } + + if (state != PARSE_FLAGS) + return -EINVAL; + + entry->name = xstrdup(name); + entry->filename = xstrdup(filename); + if (*partstr == ',') + partstr++; + *endstr = partstr; + + list_add_tail(&entry->list, &files->list); + + return 0; +} + +struct file_list *file_list_parse(const char *str) +{ + struct file_list *files; + int ret; + const char *endptr; + + files = xzalloc(sizeof(*files)); + + INIT_LIST_HEAD(&files->list); + + while (*str) { + if (file_list_parse_one(files, str, &endptr)) { + printf("parse error\n"); + ret = -EINVAL; + goto out; + } + str = endptr; + + files->num_entries++; + } + + return files; +out: + free(files); + + return ERR_PTR(ret); +} + +void file_list_free(struct file_list *files) +{ + struct file_list_entry *entry, *tmp; + + list_for_each_entry_safe(entry, tmp, &files->list, list) { + free(entry->name); + free(entry->filename); + free(entry); + } + + free(files); +} diff --git a/common/version.c b/common/version.c index 79b2a54b97..51d4d48b52 100644 --- a/common/version.c +++ b/common/version.c @@ -6,6 +6,10 @@ const char version_string[] = "barebox " UTS_RELEASE " " UTS_VERSION "\n"; EXPORT_SYMBOL(version_string); +const char release_string[] = + "barebox-" UTS_RELEASE; +EXPORT_SYMBOL(release_string); + void barebox_banner (void) { pr_info("\n\n%s\n\n", version_string); |