fs/directory: update readdir interface for all filesystem

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong
2022-07-26 06:56:41 +00:00
committed by Xiang Xiao
parent 3a70962b7a
commit 90db4daca9
30 changed files with 244 additions and 205 deletions
+6 -4
View File
@@ -225,7 +225,8 @@ static int proc_dup(FAR const struct file *oldp,
static int proc_opendir(const char *relpath,
FAR struct fs_dirent_s *dir);
static int proc_closedir(FAR struct fs_dirent_s *dir);
static int proc_readdir(FAR struct fs_dirent_s *dir);
static int proc_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int proc_rewinddir(FAR struct fs_dirent_s *dir);
static int proc_stat(FAR const char *relpath, FAR struct stat *buf);
@@ -1920,7 +1921,8 @@ static int proc_closedir(FAR struct fs_dirent_s *dir)
*
****************************************************************************/
static int proc_readdir(struct fs_dirent_s *dir)
static int proc_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{
FAR struct proc_dir_s *procdir;
FAR const struct proc_node_s *node = NULL;
@@ -1984,8 +1986,8 @@ static int proc_readdir(struct fs_dirent_s *dir)
/* Save the filename and file type */
dir->fd_dir.d_type = node->dtype;
strlcpy(dir->fd_dir.d_name, node->name, sizeof(dir->fd_dir.d_name));
entry->d_type = node->dtype;
strlcpy(entry->d_name, node->name, sizeof(entry->d_name));
/* Set up the next directory entry offset. NOTE that we could use the
* standard f_pos instead of our own private index.