summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-05-03 13:48:59 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-05-12 08:00:00 +0200
commit00e5e596df0b6db478bad982fd38867bd5582e76 (patch)
tree68b5df02138483a3e54b01b69532d9576c3e7841 /common
parent49697b065a04d5a5713ba90626dc4259fd007232 (diff)
downloadbarebox-00e5e596df0b6db478bad982fd38867bd5582e76.tar.gz
barebox-00e5e596df0b6db478bad982fd38867bd5582e76.tar.xz
file_list: add file_list_detect_all()
This is a common theme along the code that uses file_lists. Add a function that abstracts it. This could later be used to simplify this operation in the fastboot code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-15-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/file-list.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/file-list.c b/common/file-list.c
index 55e6f0e6b6..05f44514fb 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -8,6 +8,7 @@
#include <file-list.h>
#include <stringlist.h>
#include <linux/err.h>
+#include <driver.h>
#define PARSE_DEVICE 0
#define PARSE_NAME 1
@@ -217,3 +218,19 @@ out:
return str;
}
+
+int file_list_detect_all(const struct file_list *files)
+{
+ struct file_list_entry *fentry;
+ struct stat s;
+ int i = 0;
+
+ list_for_each_entry(fentry, &files->list, list) {
+ if (stat(fentry->filename, &s))
+ continue;
+ if (device_detect_by_name(devpath_to_name(fentry->filename)) == 0)
+ i++;
+ }
+
+ return i;
+}