diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-05-03 13:48:51 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-05-12 07:59:59 +0200 |
commit | ff40047b3b6300015a8cc2c6a3e0989676250dbd (patch) | |
tree | 3d72f5c86f9be264098d1fcf2452abd8e7369a35 /include | |
parent | 15e26bb72b334da1830c26917e28ffcac64e8e4c (diff) | |
download | barebox-ff40047b3b6300015a8cc2c6a3e0989676250dbd.tar.gz barebox-ff40047b3b6300015a8cc2c6a3e0989676250dbd.tar.xz |
common: add generic system partitions interface
Both Fastboot and DFU have their own global variables that allow
specifying the partitions that can be flashed via the environment.
With the upcoming addition of the USB mass storage gadget, we will need
some way to define the partitions there as well.
Instead of adding yet another way download method-specific variable,
add a generic global.system.partitions variable that can be specified on a
per-board basis and can be used for all methods.
Existing variables will still remain for backwards-compatibility, but
when unset, it should fall back to this new parameter. This is done
in the follow-up patches.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210503114901.13095-7-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/file-list.h | 2 | ||||
-rw-r--r-- | include/system-partitions.h | 40 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/file-list.h b/include/file-list.h index 7264a3e2c6..2538883c36 100644 --- a/include/file-list.h +++ b/include/file-list.h @@ -28,6 +28,8 @@ void file_list_free(struct file_list *); int file_list_add_entry(struct file_list *files, const char *name, const char *filename, unsigned long flags); +struct file_list *file_list_dup(struct file_list *old); + struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name); #define file_list_for_each_entry(files, entry) \ diff --git a/include/system-partitions.h b/include/system-partitions.h new file mode 100644 index 0000000000..86de3612cc --- /dev/null +++ b/include/system-partitions.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef SYSTEM_PARTITIONS_H_ +#define SYSTEM_PARTITIONS_H_ + +#include <file-list.h> + +#ifdef CONFIG_SYSTEM_PARTITIONS + +/* duplicates current system_partitions and returns it */ +struct file_list *system_partitions_get(void); + +/* takes ownership of files and store it internally */ +void system_partitions_set(struct file_list *files); + +/* + * check whether system_partitions_get would return an empty + * file_list without doing an allocation + */ +bool system_partitions_empty(void); + +#else + +static inline struct file_list *system_partitions_get(void) +{ + return file_list_parse(""); +} + +static inline bool system_partitions_empty(void) +{ + return true; +} + +/* + * system_partitions_set() intentionally left unimplemented. + * select CONFIG_SYSTEM_PARTITIONS if you want to set it + */ + +#endif + +#endif |