diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-05-03 13:48:50 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-05-12 07:59:59 +0200 |
commit | 15e26bb72b334da1830c26917e28ffcac64e8e4c (patch) | |
tree | c2d334fe86fb95e1b963172e349ea00a6249ad4f /include | |
parent | fab1f406fdb82f2876f48c3c9e33672c963809e2 (diff) | |
download | barebox-15e26bb72b334da1830c26917e28ffcac64e8e4c.tar.gz barebox-15e26bb72b334da1830c26917e28ffcac64e8e4c.tar.xz |
param: introduce file-list parameter type
DFU, fastboot and incoming mass storage support all use file lists as
input, but individually check syntax correctness only on use.
A dedicated file list parameter would improve the user experience
and makes the code using it easier to handle: the struct file_list
can be passed around directly instead of having to parse it first
on use.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210503114901.13095-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/file-list.h | 3 | ||||
-rw-r--r-- | include/param.h | 15 | ||||
-rw-r--r-- | include/stringlist.h | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/include/file-list.h b/include/file-list.h index 9a9edfa378..7264a3e2c6 100644 --- a/include/file-list.h +++ b/include/file-list.h @@ -2,6 +2,8 @@ #ifndef __FILE_LIST #define __FILE_LIST +#include <linux/list.h> + #define FILE_LIST_FLAG_SAFE (1 << 0) #define FILE_LIST_FLAG_READBACK (1 << 1) #define FILE_LIST_FLAG_CREATE (1 << 2) @@ -20,6 +22,7 @@ struct file_list { }; struct file_list *file_list_parse(const char *str); +char *file_list_to_str(const struct file_list *files); void file_list_free(struct file_list *); int file_list_add_entry(struct file_list *files, const char *name, const char *filename, diff --git a/include/param.h b/include/param.h index 6aca1b481d..4835be4d25 100644 --- a/include/param.h +++ b/include/param.h @@ -10,6 +10,7 @@ #define PARAM_GLOBALVAR_UNQUALIFIED (1 << 1) struct device_d; +struct file_list; typedef uint32_t IPaddr_t; enum param_type { @@ -23,6 +24,7 @@ enum param_type { PARAM_TYPE_BITMASK, PARAM_TYPE_IPV4, PARAM_TYPE_MAC, + PARAM_TYPE_FILE_LIST, }; struct param_d { @@ -89,6 +91,11 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, int (*get)(struct param_d *p, void *priv), u8 *mac, void *priv); +struct param_d *dev_add_param_file_list(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + struct file_list **file_list, void *priv); + struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, const char *value); void dev_remove_param(struct param_d *p); @@ -185,6 +192,14 @@ static inline struct param_d *dev_add_param_mac(struct device_d *dev, const char return NULL; } +static inline struct param_d *dev_add_param_file_list(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + struct file_list **file_list, void *priv) +{ + return NULL; +} + static inline struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, const char *value) { diff --git a/include/stringlist.h b/include/stringlist.h index c5d6e70a36..01491082ea 100644 --- a/include/stringlist.h +++ b/include/stringlist.h @@ -14,6 +14,7 @@ int string_list_add_asprintf(struct string_list *sl, const char *fmt, ...); int string_list_add_sorted(struct string_list *sl, const char *str); int string_list_add_sort_uniq(struct string_list *sl, const char *str); int string_list_contains(struct string_list *sl, const char *str); +char *string_list_join(const struct string_list *sl, const char *joinstr); void string_list_print_by_column(struct string_list *sl); static inline void string_list_init(struct string_list *sl) |