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 /uisimulator/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 'uisimulator/common')
-rw-r--r-- | uisimulator/common/filesystem-sim.c | 35 | ||||
-rw-r--r-- | uisimulator/common/filesystem-sim.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/uisimulator/common/filesystem-sim.c b/uisimulator/common/filesystem-sim.c index f4f6321b7d..54e703ff40 100644 --- a/uisimulator/common/filesystem-sim.c +++ b/uisimulator/common/filesystem-sim.c | |||
@@ -704,6 +704,41 @@ struct sim_dirent * sim_readdir(DIR *dirp) | |||
704 | return entry; | 704 | return entry; |
705 | } | 705 | } |
706 | 706 | ||
707 | /* read a directory (reentrant) */ | ||
708 | int sim_readdir_r(DIR *dirp, struct sim_dirent *entry, struct sim_dirent **result) | ||
709 | { | ||
710 | if (!result) | ||
711 | FILE_ERROR_RETURN(EFAULT, -2); | ||
712 | |||
713 | *result = NULL; | ||
714 | |||
715 | if (!entry) | ||
716 | FILE_ERROR_RETURN(EFAULT, -3); | ||
717 | |||
718 | struct dirstr_desc *dirstr = get_dirstr(dirp); | ||
719 | if (!dirstr) | ||
720 | FILE_ERROR_RETURN(ERRNO, -1); | ||
721 | |||
722 | entry->info.osdirent = NULL; | ||
723 | |||
724 | if (readdir_volume(dirstr, entry)) | ||
725 | { | ||
726 | *result = entry; | ||
727 | return 0; | ||
728 | } | ||
729 | OS_DIRENT_T *osdirent = os_readdir(dirstr->osdirp); | ||
730 | if (!osdirent) | ||
731 | FILE_ERROR_RETURN(ERRNO, -4); | ||
732 | |||
733 | size_t size = sizeof (entry->d_name); | ||
734 | if (strlcpy_from_os(entry->d_name, osdirent->d_name, size) >= size) | ||
735 | FILE_ERROR_RETURN(ENAMETOOLONG, -5); | ||
736 | |||
737 | entry->info.osdirent = osdirent; | ||
738 | *result = entry; | ||
739 | return 0; | ||
740 | } | ||
741 | |||
707 | int sim_mkdir(const char *path) | 742 | int sim_mkdir(const char *path) |
708 | { | 743 | { |
709 | char ospath[SIM_TMPBUF_MAX_PATH]; | 744 | char ospath[SIM_TMPBUF_MAX_PATH]; |
diff --git a/uisimulator/common/filesystem-sim.h b/uisimulator/common/filesystem-sim.h index 346d6fa74e..1b6c6dfe69 100644 --- a/uisimulator/common/filesystem-sim.h +++ b/uisimulator/common/filesystem-sim.h | |||
@@ -98,6 +98,7 @@ struct dirinfo_native | |||
98 | #ifndef DIRFUNCTIONS_DECLARED | 98 | #ifndef DIRFUNCTIONS_DECLARED |
99 | DIR * sim_opendir(const char *dirname); | 99 | DIR * sim_opendir(const char *dirname); |
100 | struct sim_dirent * sim_readdir(DIR *dirp); | 100 | struct sim_dirent * sim_readdir(DIR *dirp); |
101 | int sim_readdir_r(DIR *dirp, struct sim_dirent* entry, struct sim_dirent **result); | ||
101 | int sim_closedir(DIR *dirp); | 102 | int sim_closedir(DIR *dirp); |
102 | int sim_mkdir(const char *path); | 103 | int sim_mkdir(const char *path); |
103 | int sim_rmdir(const char *path); | 104 | int sim_rmdir(const char *path); |