mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
Revert "readdir_r use in tagcache.check_dir, ft_load"
This reverts commit 0c737d3b2e
.
Reason for revert: Not really a concern as open_stream returns an independent buffer since g#566
Change-Id: Idbd2f4a7cc2ea6362b7714629469eeb7b3d19b3b
This commit is contained in:
parent
0c737d3b2e
commit
efcea66280
7 changed files with 24 additions and 129 deletions
|
@ -292,7 +292,6 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
|
||||
int files_in_dir = 0;
|
||||
int name_buffer_used = 0;
|
||||
struct dirent direntry;
|
||||
struct dirent *entry;
|
||||
bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
|
||||
DIR *dir;
|
||||
|
@ -314,7 +313,7 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
c->dirfull = false;
|
||||
|
||||
tree_lock_cache(c);
|
||||
while (readdir_r(dir, &direntry, &entry) == 0 && entry) {
|
||||
while ((entry = readdir(dir))) {
|
||||
int len;
|
||||
struct dirinfo info;
|
||||
struct entry* dptr = tree_get_entry_at(c, files_in_dir);
|
||||
|
@ -327,18 +326,18 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
info = dir_get_info(dir, entry);
|
||||
len = strlen((char *)entry->d_name);
|
||||
|
||||
/* skip directories . and .. */
|
||||
if ((info.attribute & ATTR_DIRECTORY) &&
|
||||
(((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
|
||||
((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip FAT volume ID */
|
||||
if (info.attribute & ATTR_VOLUME_ID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dptr->attr = info.attribute;
|
||||
int dir_attr = (dptr->attr & ATTR_DIRECTORY);
|
||||
|
||||
/* skip directories . and .. */
|
||||
if (dir_attr && is_dotdir_name(entry->d_name))
|
||||
continue;
|
||||
|
||||
/* filter out dotfiles and hidden files */
|
||||
if (*c->dirfilter != SHOW_ALL &&
|
||||
((entry->d_name[0]=='.') ||
|
||||
|
@ -346,6 +345,9 @@ int ft_load(struct tree_context* c, const char* tempdir)
|
|||
continue;
|
||||
}
|
||||
|
||||
dptr->attr = info.attribute;
|
||||
int dir_attr = (dptr->attr & ATTR_DIRECTORY);
|
||||
|
||||
/* check for known file types */
|
||||
if ( !(dir_attr) )
|
||||
dptr->attr |= filetype_get_attr((char *)entry->d_name);
|
||||
|
|
|
@ -4863,8 +4863,8 @@ static int free_search_roots(struct search_roots_ll * start)
|
|||
|
||||
static bool check_dir(const char *dirname, int add_files)
|
||||
{
|
||||
static struct dirent direntry; /* function is recursive, static uses less stack */
|
||||
int success = false;
|
||||
|
||||
DIR *dir = opendir(dirname);
|
||||
if (!dir)
|
||||
{
|
||||
|
@ -4883,9 +4883,7 @@ static bool check_dir(const char *dirname, int add_files)
|
|||
/* Recursively scan the dir. */
|
||||
while (!check_event_queue())
|
||||
{
|
||||
struct dirent *entry;
|
||||
readdir_r(dir, &direntry, &entry);
|
||||
|
||||
struct dirent *entry = readdir(dir);
|
||||
if (entry == NULL)
|
||||
{
|
||||
success = true;
|
||||
|
|
|
@ -159,7 +159,6 @@ file_error:
|
|||
return rc;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* read a directory */
|
||||
struct dirent * readdir(DIR *dirp)
|
||||
{
|
||||
|
@ -183,19 +182,23 @@ file_error:
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* readdir, readdir_r common fn */
|
||||
static int readdir_common(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
#if 0 /* not included now but probably should be */
|
||||
/* read a directory (reentrant) */
|
||||
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
{
|
||||
*result = NULL; /* we checked for validity before calling, yes? */
|
||||
if (!result)
|
||||
FILE_ERROR_RETURN(EFAULT, -2);
|
||||
|
||||
*result = NULL;
|
||||
|
||||
if (!entry)
|
||||
FILE_ERROR_RETURN(EFAULT, -3);
|
||||
|
||||
struct dirstr_desc * const dir = GET_DIRSTR(READER, dirp);
|
||||
if (!dir)
|
||||
FILE_ERROR_RETURN(ERRNO, -1);
|
||||
|
||||
if (!entry)
|
||||
entry = &dir->entry;
|
||||
|
||||
int rc = ns_readdir_dirent(&dir->stream, &dir->scan, entry);
|
||||
if (rc < 0)
|
||||
FILE_ERROR(EIO, rc * 10 - 4);
|
||||
|
@ -215,27 +218,6 @@ file_error:
|
|||
return rc;
|
||||
}
|
||||
|
||||
/* read a directory */
|
||||
struct dirent * readdir(DIR *dirp)
|
||||
{
|
||||
struct dirent *entry;
|
||||
readdir_common(dirp, NULL, &entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/* read a directory (reentrant) */
|
||||
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
{
|
||||
if (!result)
|
||||
FILE_ERROR_RETURN(EFAULT, -2);
|
||||
*result = NULL;
|
||||
if (!entry)
|
||||
FILE_ERROR_RETURN(EFAULT, -3);
|
||||
return readdir_common(dirp, entry, result);
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* not included now but probably should be */
|
||||
/* reset the position of a directory stream to the beginning of a directory */
|
||||
void rewinddir(DIR *dirp)
|
||||
{
|
||||
|
|
|
@ -453,56 +453,6 @@ struct dirent * app_readdir(DIR *dirp)
|
|||
return (struct dirent *)osdirent;
|
||||
}
|
||||
|
||||
/* read a directory (reentrant) */
|
||||
int app_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
{
|
||||
struct __dir *this = (struct __dir *)dirp;
|
||||
if (!this)
|
||||
FILE_ERROR_RETURN(EBADF, -6);
|
||||
|
||||
if (!result)
|
||||
FILE_ERROR_RETURN(EFAULT, -2);
|
||||
|
||||
*result = NULL;
|
||||
|
||||
if (!entry)
|
||||
FILE_ERROR_RETURN(EFAULT, -3);
|
||||
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
if (this->volumes_returned < NUM_VOLUMES)
|
||||
{
|
||||
while (++this->volumes_returned < NUM_VOLUMES)
|
||||
{
|
||||
if (!volume_present(this->volumes_returned))
|
||||
continue;
|
||||
|
||||
get_volume_name(this->volumes_returned, entry->d_name);
|
||||
*result = entry;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* do normal directory reads */
|
||||
#endif /* HAVE_MULTIDRIVE */
|
||||
|
||||
OS_DIRENT_T *osdirent = os_readdir(this->osdirp);
|
||||
if (!osdirent)
|
||||
FILE_ERROR_RETURN(ERRNO, -4);
|
||||
#ifdef OS_DIRENT_CONVERT
|
||||
size_t name_size = sizeof (entry->d_name);
|
||||
if (strlcpy_from_os(entry->d_name, osdirent->d_name,
|
||||
name_size) >= name_size)
|
||||
{
|
||||
entry->d_name[0] = '\0';
|
||||
errno = EOVERFLOW;
|
||||
FILE_ERROR_RETURN(ENAMETOOLONG, -5);
|
||||
}
|
||||
|
||||
*result = entry;
|
||||
#endif /* OS_DIRENT_CONVERT */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_mkdir(const char *path)
|
||||
{
|
||||
char realpath[MAX_PATH];
|
||||
|
|
|
@ -107,7 +107,6 @@ ssize_t app_readlink(const char *path, char *buf, size_t bufsize);
|
|||
#ifndef DIRFUNCTIONS_DECLARED
|
||||
DIR * app_opendir(const char *dirname);
|
||||
struct dirent * app_readdir(DIR *dirp);
|
||||
int app_readdir_r(DIR *dirp, struct dirent* entry, struct dirent **result);
|
||||
int app_closedir(DIR *dirp);
|
||||
int app_mkdir(const char *path);
|
||||
int app_rmdir(const char *path);
|
||||
|
|
|
@ -704,41 +704,6 @@ struct sim_dirent * sim_readdir(DIR *dirp)
|
|||
return entry;
|
||||
}
|
||||
|
||||
/* read a directory (reentrant) */
|
||||
int sim_readdir_r(DIR *dirp, struct sim_dirent *entry, struct sim_dirent **result)
|
||||
{
|
||||
if (!result)
|
||||
FILE_ERROR_RETURN(EFAULT, -2);
|
||||
|
||||
*result = NULL;
|
||||
|
||||
if (!entry)
|
||||
FILE_ERROR_RETURN(EFAULT, -3);
|
||||
|
||||
struct dirstr_desc *dirstr = get_dirstr(dirp);
|
||||
if (!dirstr)
|
||||
FILE_ERROR_RETURN(ERRNO, -1);
|
||||
|
||||
entry->info.osdirent = NULL;
|
||||
|
||||
if (readdir_volume(dirstr, entry))
|
||||
{
|
||||
*result = entry;
|
||||
return 0;
|
||||
}
|
||||
OS_DIRENT_T *osdirent = os_readdir(dirstr->osdirp);
|
||||
if (!osdirent)
|
||||
FILE_ERROR_RETURN(ERRNO, -4);
|
||||
|
||||
size_t size = sizeof (entry->d_name);
|
||||
if (strlcpy_from_os(entry->d_name, osdirent->d_name, size) >= size)
|
||||
FILE_ERROR_RETURN(ENAMETOOLONG, -5);
|
||||
|
||||
entry->info.osdirent = osdirent;
|
||||
*result = entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sim_mkdir(const char *path)
|
||||
{
|
||||
char ospath[SIM_TMPBUF_MAX_PATH];
|
||||
|
|
|
@ -98,7 +98,6 @@ struct dirinfo_native
|
|||
#ifndef DIRFUNCTIONS_DECLARED
|
||||
DIR * sim_opendir(const char *dirname);
|
||||
struct sim_dirent * sim_readdir(DIR *dirp);
|
||||
int sim_readdir_r(DIR *dirp, struct sim_dirent* entry, struct sim_dirent **result);
|
||||
int sim_closedir(DIR *dirp);
|
||||
int sim_mkdir(const char *path);
|
||||
int sim_rmdir(const char *path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue