diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-10-10 08:14:37 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-10-11 17:00:50 +0200 |
commit | 7876018f73330338c029fa0ec32e59367354a123 (patch) | |
tree | 638ab6b8ef94512ae8d08cbcd983aaef219ea173 /fs | |
parent | 299d87b7ac8a3bb6bbd43d8d5ce07c4fb7bc12a4 (diff) | |
download | barebox-7876018f73330338c029fa0ec32e59367354a123.tar.gz |
fs: implement unreaddir
When iterating over a directory, it can be useful to put back the just
read directory entry, so it can be retried at a later time. This will be
needed for the EFI loader variable support.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20221010061437.2085412-4-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -890,6 +890,21 @@ static int fillonedir(struct dir_context *ctx, const char *name, int namlen, return 0; } +int unreaddir(DIR *dir, const struct dirent *d) +{ + struct readdir_entry *entry; + + if (d != &dir->d) + return -EINVAL; + + entry = xzalloc(sizeof(*entry)); + entry->d = *d; + list_add_tail(&entry->list, &dir->entries); + + return 0; +} +EXPORT_SYMBOL(unreaddir); + struct dirent *readdir(DIR *dir) { struct readdir_entry *entry; |