From efcea6628024c5f6796c3850c3779801db4b6874 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 2 May 2024 13:38:32 -0400 Subject: Revert "readdir_r use in tagcache.check_dir, ft_load" This reverts commit 0c737d3b2e4728347cf4d52025f9fc2ebbee6e90. Reason for revert: Not really a concern as open_stream returns an independent buffer since g#566 Change-Id: Idbd2f4a7cc2ea6362b7714629469eeb7b3d19b3b --- firmware/common/dir.c | 40 ++++++++------------------ firmware/target/hosted/filesystem-app.c | 50 --------------------------------- firmware/target/hosted/filesystem-app.h | 1 - 3 files changed, 11 insertions(+), 80 deletions(-) (limited to 'firmware') diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 27af5f7fca..9a78d910a7 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c @@ -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) { diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c index fc4fff0eb5..7d59a174dc 100644 --- a/firmware/target/hosted/filesystem-app.c +++ b/firmware/target/hosted/filesystem-app.c @@ -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]; diff --git a/firmware/target/hosted/filesystem-app.h b/firmware/target/hosted/filesystem-app.h index 2d7d6e817d..b35b63e95f 100644 --- a/firmware/target/hosted/filesystem-app.h +++ b/firmware/target/hosted/filesystem-app.h @@ -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); -- cgit v1.2.3