diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-05-01 10:01:56 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-05-02 09:33:29 -0400 |
commit | 0c737d3b2e4728347cf4d52025f9fc2ebbee6e90 (patch) | |
tree | 52d09ce760fb38e4f8f4752556a94a5f478cbc2f /firmware/common | |
parent | f2f5543856b91b664bb124b3e9fcfb519f53cb33 (diff) | |
download | rockbox-0c737d3b2e4728347cf4d52025f9fc2ebbee6e90.tar.gz rockbox-0c737d3b2e4728347cf4d52025f9fc2ebbee6e90.zip |
readdir_r use in tagcache.check_dir, ft_load
Change-Id: Ibcde39ed247e100dd47ae877fb2a3625bbb38d8b
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dir.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 9a78d910a7..27af5f7fca 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c | |||
@@ -159,6 +159,7 @@ file_error: | |||
159 | return rc; | 159 | return rc; |
160 | } | 160 | } |
161 | 161 | ||
162 | #if 0 | ||
162 | /* read a directory */ | 163 | /* read a directory */ |
163 | struct dirent * readdir(DIR *dirp) | 164 | struct dirent * readdir(DIR *dirp) |
164 | { | 165 | { |
@@ -182,23 +183,19 @@ file_error: | |||
182 | 183 | ||
183 | return res; | 184 | return res; |
184 | } | 185 | } |
186 | #endif | ||
185 | 187 | ||
186 | #if 0 /* not included now but probably should be */ | 188 | /* readdir, readdir_r common fn */ |
187 | /* read a directory (reentrant) */ | 189 | static int readdir_common(DIR *dirp, struct dirent *entry, struct dirent **result) |
188 | int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) | ||
189 | { | 190 | { |
190 | if (!result) | 191 | *result = NULL; /* we checked for validity before calling, yes? */ |
191 | FILE_ERROR_RETURN(EFAULT, -2); | ||
192 | |||
193 | *result = NULL; | ||
194 | |||
195 | if (!entry) | ||
196 | FILE_ERROR_RETURN(EFAULT, -3); | ||
197 | |||
198 | struct dirstr_desc * const dir = GET_DIRSTR(READER, dirp); | 192 | struct dirstr_desc * const dir = GET_DIRSTR(READER, dirp); |
199 | if (!dir) | 193 | if (!dir) |
200 | FILE_ERROR_RETURN(ERRNO, -1); | 194 | FILE_ERROR_RETURN(ERRNO, -1); |
201 | 195 | ||
196 | if (!entry) | ||
197 | entry = &dir->entry; | ||
198 | |||
202 | int rc = ns_readdir_dirent(&dir->stream, &dir->scan, entry); | 199 | int rc = ns_readdir_dirent(&dir->stream, &dir->scan, entry); |
203 | if (rc < 0) | 200 | if (rc < 0) |
204 | FILE_ERROR(EIO, rc * 10 - 4); | 201 | FILE_ERROR(EIO, rc * 10 - 4); |
@@ -218,6 +215,27 @@ file_error: | |||
218 | return rc; | 215 | return rc; |
219 | } | 216 | } |
220 | 217 | ||
218 | /* read a directory */ | ||
219 | struct dirent * readdir(DIR *dirp) | ||
220 | { | ||
221 | struct dirent *entry; | ||
222 | readdir_common(dirp, NULL, &entry); | ||
223 | return entry; | ||
224 | } | ||
225 | |||
226 | /* read a directory (reentrant) */ | ||
227 | int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) | ||
228 | { | ||
229 | if (!result) | ||
230 | FILE_ERROR_RETURN(EFAULT, -2); | ||
231 | *result = NULL; | ||
232 | if (!entry) | ||
233 | FILE_ERROR_RETURN(EFAULT, -3); | ||
234 | return readdir_common(dirp, entry, result); | ||
235 | } | ||
236 | |||
237 | |||
238 | #if 0 /* not included now but probably should be */ | ||
221 | /* reset the position of a directory stream to the beginning of a directory */ | 239 | /* reset the position of a directory stream to the beginning of a directory */ |
222 | void rewinddir(DIR *dirp) | 240 | void rewinddir(DIR *dirp) |
223 | { | 241 | { |