1
0
Fork 0
forked from nuttx/nuttx-update

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

View file

@ -99,7 +99,8 @@ static int cxd56_powermgr_procfs_dup(const struct file *oldp,
static int cxd56_powermgr_procfs_opendir(const char *relpath, static int cxd56_powermgr_procfs_opendir(const char *relpath,
struct fs_dirent_s *dir); struct fs_dirent_s *dir);
static int cxd56_powermgr_procfs_closedir(struct fs_dirent_s *dir); static int cxd56_powermgr_procfs_closedir(struct fs_dirent_s *dir);
static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir); static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir,
struct dirent *entry);
static int cxd56_powermgr_procfs_rewinddir(struct fs_dirent_s *dir); static int cxd56_powermgr_procfs_rewinddir(struct fs_dirent_s *dir);
static int cxd56_powermgr_procfs_stat(const char *relpath, static int cxd56_powermgr_procfs_stat(const char *relpath,
struct stat *buf); struct stat *buf);
@ -749,7 +750,8 @@ static int cxd56_powermgr_procfs_closedir(struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir) static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir,
struct dirent *entry)
{ {
struct cxd56_powermgr_procfs_dir_s *procfs; struct cxd56_powermgr_procfs_dir_s *procfs;
@ -765,9 +767,9 @@ static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir)
return -ENOENT; return -ENOENT;
} }
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, g_powermg_procfs_dir[procfs->index], strncpy(entry->d_name, g_powermg_procfs_dir[procfs->index],
strlen(g_powermg_procfs_dir[procfs->index])+1); strlen(g_powermg_procfs_dir[procfs->index])+1);
procfs->index++; procfs->index++;
return OK; return OK;

View file

@ -133,7 +133,8 @@ static int part_procfs_dup(FAR const struct file *oldp,
static int part_procfs_opendir(const char *relpath, static int part_procfs_opendir(const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int part_procfs_closedir(FAR struct fs_dirent_s *dir); static int part_procfs_closedir(FAR struct fs_dirent_s *dir);
static int part_procfs_readdir(FAR struct fs_dirent_s *dir); static int part_procfs_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int part_procfs_rewinddir(FAR struct fs_dirent_s *dir); static int part_procfs_rewinddir(FAR struct fs_dirent_s *dir);
#endif #endif

View file

@ -106,7 +106,8 @@ static int pm_dup(FAR const struct file *oldp,
static int pm_opendir(FAR const char *relpath, static int pm_opendir(FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int pm_closedir(FAR struct fs_dirent_s *dir); static int pm_closedir(FAR struct fs_dirent_s *dir);
static int pm_readdir(FAR struct fs_dirent_s *dir); static int pm_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int pm_rewinddir(FAR struct fs_dirent_s *dir); static int pm_rewinddir(FAR struct fs_dirent_s *dir);
static int pm_stat(FAR const char *relpath, FAR struct stat *buf); static int pm_stat(FAR const char *relpath, FAR struct stat *buf);
@ -490,7 +491,8 @@ static int pm_closedir(FAR struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int pm_readdir(FAR struct fs_dirent_s *dir) static int pm_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct procfs_dir_priv_s *level1; FAR struct procfs_dir_priv_s *level1;
int index; int index;
@ -514,8 +516,8 @@ static int pm_readdir(FAR struct fs_dirent_s *dir)
domain = index / ARRAY_SIZE(g_pm_files); domain = index / ARRAY_SIZE(g_pm_files);
fpos = index % ARRAY_SIZE(g_pm_files); fpos = index % ARRAY_SIZE(g_pm_files);
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
snprintf(dir->fd_dir.d_name, NAME_MAX + 1, "%s%d", snprintf(entry->d_name, NAME_MAX + 1, "%s%d",
g_pm_files[fpos].name, domain); g_pm_files[fpos].name, domain);
level1->index++; level1->index++;

View file

@ -65,7 +65,8 @@ static int binfs_fstat(FAR const struct file *filep,
static int binfs_opendir(struct inode *mountpt, const char *relpath, static int binfs_opendir(struct inode *mountpt, const char *relpath,
struct fs_dirent_s *dir); struct fs_dirent_s *dir);
static int binfs_readdir(FAR struct inode *mountpt, static int binfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int binfs_rewinddir(FAR struct inode *mountpt, static int binfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -301,7 +302,9 @@ static int binfs_opendir(struct inode *mountpt, const char *relpath,
* *
****************************************************************************/ ****************************************************************************/
static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int binfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR const char *name; FAR const char *name;
unsigned int index; unsigned int index;
@ -325,8 +328,8 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
/* Save the filename and file type */ /* Save the filename and file type */
finfo("Entry %d: \"%s\"\n", index, name); finfo("Entry %d: \"%s\"\n", index, name);
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strlcpy(dir->fd_dir.d_name, name, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, name, sizeof(entry->d_name));
/* The application list is terminated by an entry with a NULL name. /* The application list is terminated by an entry with a NULL name.
* Therefore, there is at least one more entry in the list. * Therefore, there is at least one more entry in the list.

View file

@ -144,7 +144,8 @@ static int cromfs_fstat(FAR const struct file *filep,
static int cromfs_opendir(FAR struct inode *mountpt, static int cromfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR struct fs_dirent_s *dir); FAR const char *relpath, FAR struct fs_dirent_s *dir);
static int cromfs_readdir(FAR struct inode *mountpt, static int cromfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int cromfs_rewinddir(FAR struct inode *mountpt, static int cromfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -1230,7 +1231,9 @@ static int cromfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
* *
****************************************************************************/ ****************************************************************************/
static int cromfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int cromfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR const struct cromfs_volume_s *fs; FAR const struct cromfs_volume_s *fs;
FAR const struct cromfs_node_s *node; FAR const struct cromfs_node_s *node;
@ -1289,53 +1292,53 @@ static int cromfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
name = (FAR char *)cromfs_offset2addr(fs, node->cn_name); name = (FAR char *)cromfs_offset2addr(fs, node->cn_name);
finfo("Entry %" PRIu32 ": %s\n", offset, name); finfo("Entry %" PRIu32 ": %s\n", offset, name);
strlcpy(dir->fd_dir.d_name, name, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, name, sizeof(entry->d_name));
switch (node->cn_mode & S_IFMT) switch (node->cn_mode & S_IFMT)
{ {
case S_IFDIR: /* Directory */ case S_IFDIR: /* Directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
break; break;
case S_IFREG: /* Regular file */ case S_IFREG: /* Regular file */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
break; break;
case S_IFIFO: /* FIFO */ case S_IFIFO: /* FIFO */
dir->fd_dir.d_type = DTYPE_FIFO; entry->d_type = DTYPE_FIFO;
break; break;
case S_IFCHR: /* Character driver */ case S_IFCHR: /* Character driver */
dir->fd_dir.d_type = DTYPE_CHR; entry->d_type = DTYPE_CHR;
break; break;
case S_IFBLK: /* Block driver */ case S_IFBLK: /* Block driver */
dir->fd_dir.d_type = DTYPE_BLK; entry->d_type = DTYPE_BLK;
break; break;
case S_IFMQ: /* Message queue */ case S_IFMQ: /* Message queue */
dir->fd_dir.d_type = DTYPE_MQ; entry->d_type = DTYPE_MQ;
break; break;
case S_IFSEM: /* Semaphore */ case S_IFSEM: /* Semaphore */
dir->fd_dir.d_type = DTYPE_SEM; entry->d_type = DTYPE_SEM;
break; break;
case S_IFSHM: /* Shared memory */ case S_IFSHM: /* Shared memory */
dir->fd_dir.d_type = DTYPE_SHM; entry->d_type = DTYPE_SHM;
break; break;
case S_IFMTD: /* MTD driver */ case S_IFMTD: /* MTD driver */
dir->fd_dir.d_type = DTYPE_MTD; entry->d_type = DTYPE_MTD;
break; break;
case S_IFSOCK: /* Socket */ case S_IFSOCK: /* Socket */
dir->fd_dir.d_type = DTYPE_SOCK; entry->d_type = DTYPE_SOCK;
break; break;
default: default:
DEBUGPANIC(); DEBUGPANIC();
dir->fd_dir.d_type = DTYPE_UNKNOWN; entry->d_type = DTYPE_UNKNOWN;
break; break;
} }

View file

@ -69,7 +69,8 @@ static int fat_truncate(FAR struct file *filep, off_t length);
static int fat_opendir(FAR struct inode *mountpt, static int fat_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR struct fs_dirent_s *dir); FAR const char *relpath, FAR struct fs_dirent_s *dir);
static int fat_readdir(FAR struct inode *mountpt, static int fat_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int fat_rewinddir(FAR struct inode *mountpt, static int fat_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -1878,7 +1879,8 @@ errout_with_semaphore:
****************************************************************************/ ****************************************************************************/
static int fat_readdir(FAR struct inode *mountpt, static int fat_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct fat_mountpt_s *fs; FAR struct fat_mountpt_s *fs;
unsigned int dirindex; unsigned int dirindex;
@ -1914,7 +1916,7 @@ static int fat_readdir(FAR struct inode *mountpt,
/* Read the next directory entry */ /* Read the next directory entry */
dir->fd_dir.d_name[0] = '\0'; entry->d_name[0] = '\0';
found = false; found = false;
while (dir->u.fat.fd_currsector && !found) while (dir->u.fat.fd_currsector && !found)
@ -1960,7 +1962,7 @@ static int fat_readdir(FAR struct inode *mountpt,
* several directory entries. * several directory entries.
*/ */
ret = fat_dirname2path(fs, dir); ret = fat_dirname2path(fs, dir, entry);
if (ret == OK) if (ret == OK)
{ {
/* The name was successfully extracted. Re-read the /* The name was successfully extracted. Re-read the
@ -1991,11 +1993,11 @@ static int fat_readdir(FAR struct inode *mountpt,
if ((attribute & FATATTR_DIRECTORY) == 0) if ((attribute & FATATTR_DIRECTORY) == 0)
{ {
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
} }
else else
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
/* Mark the entry found. We will set up the next directory /* Mark the entry found. We will set up the next directory

View file

@ -1054,8 +1054,9 @@ EXTERN int fat_allocatedirentry(struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo); struct fat_dirinfo_s *dirinfo);
EXTERN int fat_freedirentry(struct fat_mountpt_s *fs, EXTERN int fat_freedirentry(struct fat_mountpt_s *fs,
struct fat_dirseq_s *seq); struct fat_dirseq_s *seq);
EXTERN int fat_dirname2path(struct fat_mountpt_s *fs, EXTERN int fat_dirname2path(FAR struct fat_mountpt_s *fs,
struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
/* File creation and removal helpers */ /* File creation and removal helpers */

View file

@ -136,7 +136,8 @@ static inline int fat_getsfname(FAR uint8_t *direntry, FAR char *buffer,
static void fat_getlfnchunk(FAR uint8_t *chunk, FAR lfnchar *dest, static void fat_getlfnchunk(FAR uint8_t *chunk, FAR lfnchar *dest,
int nchunk); int nchunk);
static inline int fat_getlfname(FAR struct fat_mountpt_s *fs, static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
#endif #endif
static int fat_putsfname(FAR struct fat_mountpt_s *fs, static int fat_putsfname(FAR struct fat_mountpt_s *fs,
FAR struct fat_dirinfo_s *dirinfo); FAR struct fat_dirinfo_s *dirinfo);
@ -1960,7 +1961,8 @@ static void fat_getlfnchunk(FAR uint8_t *chunk, FAR lfnchar *dest,
#ifdef CONFIG_FAT_LFN #ifdef CONFIG_FAT_LFN
static inline int fat_getlfname(FAR struct fat_mountpt_s *fs, static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR uint8_t *direntry; FAR uint8_t *direntry;
lfnchar lfname[LDIR_MAXLFNCHARS]; lfnchar lfname[LDIR_MAXLFNCHARS];
@ -2030,7 +2032,7 @@ static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
* terminator will fit). * terminator will fit).
*/ */
dir->fd_dir.d_name[NAME_MAX] = '\0'; entry->d_name[NAME_MAX] = '\0';
offset = NAME_MAX; offset = NAME_MAX;
} }
@ -2038,7 +2040,7 @@ static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
for (i = nsrc - 1; i >= 0; i--) for (i = nsrc - 1; i >= 0; i--)
{ {
offset = fat_ucstoutf8((FAR uint8_t *)dir->fd_dir.d_name, offset = fat_ucstoutf8((FAR uint8_t *)entry->d_name,
offset, lfname[i]); offset, lfname[i]);
} }
# else # else
@ -2087,14 +2089,14 @@ static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
* terminator will fit). * terminator will fit).
*/ */
dir->fd_dir.d_name[offset + nsrc] = '\0'; entry->d_name[offset + nsrc] = '\0';
} }
/* Then transfer the characters */ /* Then transfer the characters */
for (i = 0; i < nsrc && offset + i < NAME_MAX; i++) for (i = 0; i < nsrc && offset + i < NAME_MAX; i++)
{ {
dir->fd_dir.d_name[offset + i] = lfname[i]; entry->d_name[offset + i] = lfname[i];
} }
} }
#endif #endif
@ -2129,7 +2131,7 @@ static inline int fat_getlfname(FAR struct fat_mountpt_s *fs,
if (offset > 0) if (offset > 0)
{ {
memmove(dir->fd_dir.d_name, &dir->fd_dir.d_name[offset], memmove(entry->d_name, &entry->d_name[offset],
(NAME_MAX + 1) - offset); (NAME_MAX + 1) - offset);
} }
# endif # endif
@ -2938,7 +2940,8 @@ int fat_freedirentry(FAR struct fat_mountpt_s *fs, struct fat_dirseq_s *seq)
****************************************************************************/ ****************************************************************************/
int fat_dirname2path(FAR struct fat_mountpt_s *fs, int fat_dirname2path(FAR struct fat_mountpt_s *fs,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
uint16_t diroffset; uint16_t diroffset;
FAR uint8_t *direntry; FAR uint8_t *direntry;
@ -2961,14 +2964,14 @@ int fat_dirname2path(FAR struct fat_mountpt_s *fs,
* entries. * entries.
*/ */
return fat_getlfname(fs, dir); return fat_getlfname(fs, dir, entry);
} }
else else
#endif #endif
{ {
/* No.. Get the name from a short file name directory entries */ /* No.. Get the name from a short file name directory entries */
return fat_getsfname(direntry, dir->fd_dir.d_name, NAME_MAX + 1); return fat_getsfname(direntry, entry->d_name, NAME_MAX + 1);
} }
} }

View file

@ -83,7 +83,8 @@ static int hostfs_opendir(FAR struct inode *mountpt,
static int hostfs_closedir(FAR struct inode *mountpt, static int hostfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int hostfs_readdir(FAR struct inode *mountpt, static int hostfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int hostfs_rewinddir(FAR struct inode *mountpt, static int hostfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -917,7 +918,8 @@ static int hostfs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int hostfs_readdir(FAR struct inode *mountpt, static int hostfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct hostfs_mountpt_s *fs; FAR struct hostfs_mountpt_s *fs;
int ret; int ret;
@ -940,7 +942,7 @@ static int hostfs_readdir(FAR struct inode *mountpt,
/* Call the host OS's readdir function */ /* Call the host OS's readdir function */
ret = host_readdir(dir->u.hostfs.fs_dir, &dir->fd_dir); ret = host_readdir(dir->u.hostfs.fs_dir, entry);
hostfs_semgive(fs); hostfs_semgive(fs);
return ret; return ret;

View file

@ -97,7 +97,8 @@ static int littlefs_opendir(FAR struct inode *mountpt,
static int littlefs_closedir(FAR struct inode *mountpt, static int littlefs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int littlefs_readdir(FAR struct inode *mountpt, static int littlefs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int littlefs_rewinddir(FAR struct inode *mountpt, static int littlefs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -820,7 +821,8 @@ static int littlefs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int littlefs_readdir(FAR struct inode *mountpt, static int littlefs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct littlefs_mountpt_s *fs; FAR struct littlefs_mountpt_s *fs;
FAR struct lfs_dir *priv; FAR struct lfs_dir *priv;
@ -845,14 +847,14 @@ static int littlefs_readdir(FAR struct inode *mountpt,
{ {
if (info.type == LFS_TYPE_REG) if (info.type == LFS_TYPE_REG)
{ {
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
} }
else else
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
strlcpy(dir->fd_dir.d_name, info.name, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, info.name, sizeof(entry->d_name));
} }
else if (ret == 0) else if (ret == 0)
{ {

View file

@ -140,7 +140,8 @@ static int nfs_truncate(FAR struct file *filep, off_t length);
static int nfs_opendir(FAR struct inode *mountpt, static int nfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR struct fs_dirent_s *dir); FAR const char *relpath, FAR struct fs_dirent_s *dir);
static int nfs_readdir(FAR struct inode *mountpt, static int nfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int nfs_rewinddir(FAR struct inode *mountpt, static int nfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt, static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt,
@ -1478,7 +1479,8 @@ errout_with_semaphore:
****************************************************************************/ ****************************************************************************/
static int nfs_readdir(FAR struct inode *mountpt, static int nfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct nfsmount *nmp; FAR struct nfsmount *nmp;
struct file_handle fhandle; struct file_handle fhandle;
@ -1658,12 +1660,12 @@ next_entry:
length = NAME_MAX; length = NAME_MAX;
} }
memcpy(dir->fd_dir.d_name, name, length); memcpy(entry->d_name, name, length);
dir->fd_dir.d_name[length] = '\0'; entry->d_name[length] = '\0';
finfo("name: \"%s\"\n", dir->fd_dir.d_name); finfo("name: \"%s\"\n", entry->d_name);
if (strcmp(dir->fd_dir.d_name, ".") == 0 || if (strcmp(entry->d_name, ".") == 0 ||
strcmp(dir->fd_dir.d_name, "..") == 0) strcmp(entry->d_name, "..") == 0)
{ {
goto next_entry; /* Skip . and .. */ goto next_entry; /* Skip . and .. */
} }
@ -1675,7 +1677,7 @@ next_entry:
fhandle.length = (uint32_t)dir->u.nfs.nfs_fhsize; fhandle.length = (uint32_t)dir->u.nfs.nfs_fhsize;
memcpy(&fhandle.handle, dir->u.nfs.nfs_fhandle, fhandle.length); memcpy(&fhandle.handle, dir->u.nfs.nfs_fhandle, fhandle.length);
ret = nfs_lookup(nmp, dir->fd_dir.d_name, &fhandle, &obj_attributes, NULL); ret = nfs_lookup(nmp, entry->d_name, &fhandle, &obj_attributes, NULL);
if (ret != OK) if (ret != OK)
{ {
ferr("ERROR: nfs_lookup failed: %d\n", ret); ferr("ERROR: nfs_lookup failed: %d\n", ret);
@ -1692,35 +1694,35 @@ next_entry:
break; break;
case NFSOCK: /* Socket */ case NFSOCK: /* Socket */
dir->fd_dir.d_type = DTYPE_SOCK; entry->d_type = DTYPE_SOCK;
break; break;
case NFLNK: /* Symbolic link */ case NFLNK: /* Symbolic link */
dir->fd_dir.d_type = DTYPE_LINK; entry->d_type = DTYPE_LINK;
break; break;
case NFREG: /* Regular file */ case NFREG: /* Regular file */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
break; break;
case NFDIR: /* Directory */ case NFDIR: /* Directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
break; break;
case NFBLK: /* Block special device file */ case NFBLK: /* Block special device file */
dir->fd_dir.d_type = DTYPE_BLK; entry->d_type = DTYPE_BLK;
break; break;
case NFFIFO: /* Named FIFO */ case NFFIFO: /* Named FIFO */
dir->fd_dir.d_type = DTYPE_FIFO; entry->d_type = DTYPE_FIFO;
break; break;
case NFCHR: /* Character special device file */ case NFCHR: /* Character special device file */
dir->fd_dir.d_type = DTYPE_CHR; entry->d_type = DTYPE_CHR;
break; break;
} }
finfo("type: %d->%d\n", (int)tmp, dir->fd_dir.d_type); finfo("type: %d->%d\n", (int)tmp, entry->d_type);
errout_with_semaphore: errout_with_semaphore:
nfs_semgive(nmp); nfs_semgive(nmp);

View file

@ -1109,7 +1109,9 @@ int nxffs_truncate(FAR struct file *filep, off_t length);
int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath, int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); int nxffs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
int nxffs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); int nxffs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data, int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data,

View file

@ -26,7 +26,6 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <dirent.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
@ -97,10 +96,12 @@ errout:
* *
****************************************************************************/ ****************************************************************************/
int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) int nxffs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *dentry)
{ {
FAR struct nxffs_volume_s *volume; FAR struct nxffs_volume_s *volume;
FAR struct nxffs_entry_s entry; struct nxffs_entry_s entry;
off_t offset; off_t offset;
int ret; int ret;
@ -132,8 +133,8 @@ int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir)
/* Return the filename and file type */ /* Return the filename and file type */
finfo("Offset %jd: \"%s\"\n", (intmax_t)entry.hoffset, entry.name); finfo("Offset %jd: \"%s\"\n", (intmax_t)entry.hoffset, entry.name);
dir->fd_dir.d_type = DTYPE_FILE; dentry->d_type = DTYPE_FILE;
strlcpy(dir->fd_dir.d_name, entry.name, sizeof(dir->fd_dir.d_name)); strlcpy(dentry->d_name, entry.name, sizeof(dentry->d_name));
/* Discard this entry and set the next offset. */ /* Discard this entry and set the next offset. */

View file

@ -228,7 +228,7 @@ static int procfs_opendir(FAR struct inode *mountpt, const char *relpath,
static int procfs_closedir(FAR struct inode *mountpt, static int procfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int procfs_readdir(FAR struct inode *mountpt, static int procfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir, FAR struct dirent *entry);
static int procfs_rewinddir(FAR struct inode *mountpt, static int procfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -717,9 +717,11 @@ static int procfs_closedir(FAR struct inode *mountpt,
* *
****************************************************************************/ ****************************************************************************/
static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int procfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR const struct procfs_entry_s *entry = NULL; FAR const struct procfs_entry_s *pentry = NULL;
FAR struct procfs_dir_priv_s *priv; FAR struct procfs_dir_priv_s *priv;
FAR struct procfs_level0_s *level0; FAR struct procfs_level0_s *level0;
FAR struct tcb_s *tcb; FAR struct tcb_s *tcb;
@ -751,8 +753,8 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
while (index < priv->nentries + g_procfs_entrycount) while (index < priv->nentries + g_procfs_entrycount)
{ {
entry = &g_procfs_entries[index - priv->nentries]; pentry = &g_procfs_entries[index - priv->nentries];
name = entry->pathpattern; name = pentry->pathpattern;
while (*name != '/' && *name != '\0') while (*name != '/' && *name != '\0')
{ {
@ -820,21 +822,21 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
level0->lastlen = strcspn(name, "/"); level0->lastlen = strcspn(name, "/");
level0->lastread = name; level0->lastread = name;
strlcpy(dir->fd_dir.d_name, name, level0->lastlen + 1); strlcpy(entry->d_name, name, level0->lastlen + 1);
/* If the entry is a directory type OR if the reported name is /* If the entry is a directory type OR if the reported name is
* only a sub-string of the entry (meaning that it contains * only a sub-string of the entry (meaning that it contains
* '/'), then report this entry as a directory. * '/'), then report this entry as a directory.
*/ */
if (entry->type == PROCFS_DIR_TYPE || if (pentry->type == PROCFS_DIR_TYPE ||
level0->lastlen != strlen(name)) level0->lastlen != strlen(name))
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
else else
{ {
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
} }
/* Advance to next entry for the next read */ /* Advance to next entry for the next read */
@ -859,8 +861,8 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
/* Save the filename=pid and file type=directory */ /* Save the filename=pid and file type=directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
procfs_snprintf(dir->fd_dir.d_name, NAME_MAX + 1, "%d", (int)pid); procfs_snprintf(entry->d_name, NAME_MAX + 1, "%d", (int)pid);
/* Set up the next directory entry offset. NOTE that we could use /* Set up the next directory entry offset. NOTE that we could use
* the standard f_pos instead of our own private index. * the standard f_pos instead of our own private index.
@ -894,27 +896,27 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
level1->subdirlen + 1]; level1->subdirlen + 1];
level1->lastlen = strcspn(name, "/"); level1->lastlen = strcspn(name, "/");
level1->lastread = name; level1->lastread = name;
strncpy(dir->fd_dir.d_name, name, level1->lastlen); strncpy(entry->d_name, name, level1->lastlen);
/* Some of the search entries contain '**' wildcards. When we /* Some of the search entries contain '**' wildcards. When we
* report the entry name, we must remove this wildcard search * report the entry name, we must remove this wildcard search
* specifier. * specifier.
*/ */
while (dir->fd_dir.d_name[level1->lastlen - 1] == '*') while (entry->d_name[level1->lastlen - 1] == '*')
{ {
level1->lastlen--; level1->lastlen--;
} }
dir->fd_dir.d_name[level1->lastlen] = '\0'; entry->d_name[level1->lastlen] = '\0';
if (name[level1->lastlen] == '/') if (name[level1->lastlen] == '/')
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
else else
{ {
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
} }
level1->base.index++; level1->base.index++;
@ -934,7 +936,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
*/ */
DEBUGASSERT(priv->procfsentry && priv->procfsentry->ops->readdir); DEBUGASSERT(priv->procfsentry && priv->procfsentry->ops->readdir);
ret = priv->procfsentry->ops->readdir(dir); ret = priv->procfsentry->ops->readdir(dir, entry);
} }
return ret; return ret;

View file

@ -225,7 +225,8 @@ static int proc_dup(FAR const struct file *oldp,
static int proc_opendir(const char *relpath, static int proc_opendir(const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int proc_closedir(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_rewinddir(FAR struct fs_dirent_s *dir);
static int proc_stat(FAR const char *relpath, FAR struct stat *buf); 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 struct proc_dir_s *procdir;
FAR const struct proc_node_s *node = NULL; 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 */ /* Save the filename and file type */
dir->fd_dir.d_type = node->dtype; entry->d_type = node->dtype;
strlcpy(dir->fd_dir.d_name, node->name, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, node->name, sizeof(entry->d_name));
/* Set up the next directory entry offset. NOTE that we could use the /* Set up the next directory entry offset. NOTE that we could use the
* standard f_pos instead of our own private index. * standard f_pos instead of our own private index.

View file

@ -102,7 +102,8 @@ static int skel_dup(FAR const struct file *oldp,
static int skel_opendir(FAR const char *relpath, static int skel_opendir(FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int skel_closedir(FAR struct fs_dirent_s *dir); static int skel_closedir(FAR struct fs_dirent_s *dir);
static int skel_readdir(FAR struct fs_dirent_s *dir); static int skel_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int skel_rewinddir(FAR struct fs_dirent_s *dir); static int skel_rewinddir(FAR struct fs_dirent_s *dir);
static int skel_stat(FAR const char *relpath, FAR struct stat *buf); static int skel_stat(FAR const char *relpath, FAR struct stat *buf);
@ -399,7 +400,8 @@ static int skel_closedir(FAR struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int skel_readdir(FAR struct fs_dirent_s *dir) static int skel_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct skel_level1_s *level1; FAR struct skel_level1_s *level1;
char filename[16]; char filename[16];
@ -439,8 +441,8 @@ static int skel_readdir(FAR struct fs_dirent_s *dir)
/* TODO: Specify the type of entry */ /* TODO: Specify the type of entry */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strlcpy(dir->fd_dir.d_name, filename, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, filename, sizeof(entry->d_name));
/* Set up the next directory entry offset. NOTE that we could use the /* Set up the next directory entry offset. NOTE that we could use the
* standard f_pos instead of our own private index. * standard f_pos instead of our own private index.

View file

@ -66,7 +66,8 @@ static int romfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int romfs_readdir(FAR struct inode *mountpt, static int romfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int romfs_rewinddir(FAR struct inode *mountpt, static int romfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -811,7 +812,8 @@ errout_with_semaphore:
****************************************************************************/ ****************************************************************************/
static int romfs_readdir(FAR struct inode *mountpt, static int romfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct romfs_mountpt_s *rm; FAR struct romfs_mountpt_s *rm;
#ifndef CONFIG_FS_ROMFS_CACHE_NODE #ifndef CONFIG_FS_ROMFS_CACHE_NODE
@ -870,8 +872,8 @@ static int romfs_readdir(FAR struct inode *mountpt,
#ifdef CONFIG_FS_ROMFS_CACHE_NODE #ifdef CONFIG_FS_ROMFS_CACHE_NODE
next = (*dir->u.romfs.fr_currnode)->rn_next; next = (*dir->u.romfs.fr_currnode)->rn_next;
strlcpy(dir->fd_dir.d_name, (*dir->u.romfs.fr_currnode)->rn_name, strlcpy(entry->d_name, (*dir->u.romfs.fr_currnode)->rn_name,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
dir->u.romfs.fr_currnode++; dir->u.romfs.fr_currnode++;
#else #else
/* Parse the directory entry */ /* Parse the directory entry */
@ -887,7 +889,7 @@ static int romfs_readdir(FAR struct inode *mountpt,
/* Save the filename */ /* Save the filename */
ret = romfs_parsefilename(rm, dir->u.romfs.fr_curroffset, ret = romfs_parsefilename(rm, dir->u.romfs.fr_curroffset,
dir->fd_dir.d_name); entry->d_name);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: romfs_parsefilename failed: %d\n", ret); ferr("ERROR: romfs_parsefilename failed: %d\n", ret);
@ -903,17 +905,17 @@ static int romfs_readdir(FAR struct inode *mountpt,
if (IS_DIRECTORY(next)) if (IS_DIRECTORY(next))
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
break; break;
} }
else if (IS_FILE(next)) else if (IS_FILE(next))
{ {
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
break; break;
} }
else if (IS_SOFTLINK(next)) else if (IS_SOFTLINK(next))
{ {
dir->fd_dir.d_type = DTYPE_LINK; entry->d_type = DTYPE_LINK;
break; break;
} }
} }

View file

@ -113,7 +113,8 @@ static int rpmsgfs_opendir(FAR struct inode *mountpt,
static int rpmsgfs_closedir(FAR struct inode *mountpt, static int rpmsgfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int rpmsgfs_readdir(FAR struct inode *mountpt, static int rpmsgfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int rpmsgfs_rewinddir(FAR struct inode *mountpt, static int rpmsgfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -956,7 +957,8 @@ static int rpmsgfs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int rpmsgfs_readdir(FAR struct inode *mountpt, static int rpmsgfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct rpmsgfs_mountpt_s *fs; FAR struct rpmsgfs_mountpt_s *fs;
int ret; int ret;
@ -980,7 +982,7 @@ static int rpmsgfs_readdir(FAR struct inode *mountpt,
/* Call the host OS's readdir function */ /* Call the host OS's readdir function */
ret = rpmsgfs_client_readdir(fs->handle, ret = rpmsgfs_client_readdir(fs->handle,
dir->u.rpmsgfs.fs_dir, &dir->fd_dir); dir->u.rpmsgfs.fs_dir, entry);
rpmsgfs_semgive(fs); rpmsgfs_semgive(fs);
return ret; return ret;

View file

@ -118,7 +118,8 @@ static int smartfs_dup(FAR const struct file *oldp,
static int smartfs_opendir(const char *relpath, static int smartfs_opendir(const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int smartfs_closedir(FAR struct fs_dirent_s *dir); static int smartfs_closedir(FAR struct fs_dirent_s *dir);
static int smartfs_readdir(FAR struct fs_dirent_s *dir); static int smartfs_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int smartfs_rewinddir(FAR struct fs_dirent_s *dir); static int smartfs_rewinddir(FAR struct fs_dirent_s *dir);
static int smartfs_stat(FAR const char *relpath, FAR struct stat *buf); static int smartfs_stat(FAR const char *relpath, FAR struct stat *buf);
@ -601,7 +602,8 @@ static int smartfs_closedir(FAR struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_readdir(struct fs_dirent_s *dir) static int smartfs_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct smartfs_level1_s *level1; FAR struct smartfs_level1_s *level1;
int ret; int ret;
@ -640,9 +642,9 @@ static int smartfs_readdir(struct fs_dirent_s *dir)
return -ENOENT; return -ENOENT;
} }
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
strlcpy(dir->fd_dir.d_name, level1->mount->fs_blkdriver->i_name, strlcpy(entry->d_name, level1->mount->fs_blkdriver->i_name,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
/* Advance to next entry */ /* Advance to next entry */
@ -653,17 +655,17 @@ static int smartfs_readdir(struct fs_dirent_s *dir)
{ {
/* Listing the contents of a specific mount */ /* Listing the contents of a specific mount */
dir->fd_dir.d_type = g_direntry[level1->base.index].type; entry->d_type = g_direntry[level1->base.index].type;
strlcpy(dir->fd_dir.d_name, g_direntry[level1->base.index++].name, strlcpy(entry->d_name, g_direntry[level1->base.index++].name,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
} }
else if (level1->base.level == 3) else if (level1->base.level == 3)
{ {
/* Listing the contents of a specific entry */ /* Listing the contents of a specific entry */
dir->fd_dir.d_type = g_direntry[level1->base.index].type; entry->d_type = g_direntry[level1->base.index].type;
strlcpy(dir->fd_dir.d_name, g_direntry[level1->direntry].name, strlcpy(entry->d_name, g_direntry[level1->direntry].name,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
level1->base.index++; level1->base.index++;
} }

View file

@ -73,7 +73,8 @@ static int smartfs_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int smartfs_readdir(FAR struct inode *mountpt, static int smartfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *dentry);
static int smartfs_rewinddir(FAR struct inode *mountpt, static int smartfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -1252,7 +1253,9 @@ errout_with_semaphore:
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int smartfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *dentry)
{ {
struct smartfs_mountpt_s *fs; struct smartfs_mountpt_s *fs;
int ret; int ret;
@ -1325,17 +1328,16 @@ static int smartfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
if ((entry->flags & SMARTFS_DIRENT_TYPE) == if ((entry->flags & SMARTFS_DIRENT_TYPE) ==
SMARTFS_DIRENT_TYPE_DIR) SMARTFS_DIRENT_TYPE_DIR)
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; dentry->d_type = DTYPE_DIRECTORY;
} }
else else
{ {
dir->fd_dir.d_type = DTYPE_FILE; dentry->d_type = DTYPE_FILE;
} }
/* Copy the entry name to dirent */ /* Copy the entry name to dirent */
strlcpy(dir->fd_dir.d_name, entry->name, strlcpy(dentry->d_name, entry->name, sizeof(dentry->d_name));
sizeof(dir->fd_dir.d_name));
/* Now advance to the next entry */ /* Now advance to the next entry */

View file

@ -99,9 +99,11 @@ static int spiffs_truncate(FAR struct file *filep, off_t length);
static int spiffs_opendir(FAR struct inode *mountpt, static int spiffs_opendir(FAR struct inode *mountpt,
FAR const char *relpath, FAR struct fs_dirent_s *dir); FAR const char *relpath, FAR struct fs_dirent_s *dir);
static int spiffs_closedir(FAR struct inode *mountpt, static int spiffs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int spiffs_readdir(FAR struct inode *mountpt, static int spiffs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *dentry);
static int spiffs_rewinddir(FAR struct inode *mountpt, static int spiffs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data, static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
@ -258,11 +260,7 @@ static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
SPIFFS_PH_FLAG_NDXDELE)) == SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE)) (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE))
{ {
FAR struct fs_dirent_s *dir = (FAR struct fs_dirent_s *)user_var; FAR struct dirent *entryp = user_var;
FAR struct dirent *entryp;
DEBUGASSERT(dir != NULL);
entryp = &dir->fd_dir;
#ifdef CONFIG_SPIFFS_LEADING_SLASH #ifdef CONFIG_SPIFFS_LEADING_SLASH
/* Skip the leading '/'. */ /* Skip the leading '/'. */
@ -1280,7 +1278,8 @@ static int spiffs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int spiffs_readdir(FAR struct inode *mountpt, static int spiffs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *dentry)
{ {
FAR struct spiffs_s *fs; FAR struct spiffs_s *fs;
int16_t blkndx; int16_t blkndx;
@ -1303,7 +1302,7 @@ static int spiffs_readdir(FAR struct inode *mountpt,
ret = spiffs_foreach_objlu(fs, dir->u.spiffs.block, dir->u.spiffs.entry, ret = spiffs_foreach_objlu(fs, dir->u.spiffs.block, dir->u.spiffs.entry,
SPIFFS_VIS_NO_WRAP, 0, spiffs_readdir_callback, SPIFFS_VIS_NO_WRAP, 0, spiffs_readdir_callback,
NULL, dir, &blkndx, &entry); NULL, dentry, &blkndx, &entry);
if (ret >= 0) if (ret >= 0)
{ {
dir->u.spiffs.block = blkndx; dir->u.spiffs.block = blkndx;

View file

@ -136,7 +136,8 @@ static int tmpfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
static int tmpfs_closedir(FAR struct inode *mountpt, static int tmpfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int tmpfs_readdir(FAR struct inode *mountpt, static int tmpfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int tmpfs_rewinddir(FAR struct inode *mountpt, static int tmpfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int tmpfs_bind(FAR struct inode *blkdriver, FAR const void *data, static int tmpfs_bind(FAR struct inode *blkdriver, FAR const void *data,
@ -1880,7 +1881,8 @@ static int tmpfs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int tmpfs_readdir(FAR struct inode *mountpt, static int tmpfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct tmpfs_directory_s *tdo; FAR struct tmpfs_directory_s *tdo;
unsigned int index; unsigned int index;
@ -1923,18 +1925,18 @@ static int tmpfs_readdir(FAR struct inode *mountpt,
{ {
/* A directory */ /* A directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
else /* to->to_type == TMPFS_REGULAR) */ else /* to->to_type == TMPFS_REGULAR) */
{ {
/* A regular file */ /* A regular file */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
} }
/* Copy the entry name */ /* Copy the entry name */
strlcpy(dir->fd_dir.d_name, tde->tde_name, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, tde->tde_name, sizeof(entry->d_name));
/* Save the index for next time */ /* Save the index for next time */

View file

@ -163,7 +163,8 @@ static int unionfs_opendir(struct inode *mountpt, const char *relpath,
static int unionfs_closedir(FAR struct inode *mountpt, static int unionfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int unionfs_readdir(FAR struct inode *mountpt, static int unionfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int unionfs_rewinddir(FAR struct inode *mountpt, static int unionfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -1669,7 +1670,9 @@ static int unionfs_closedir(FAR struct inode *mountpt,
* Name: unionfs_readdir * Name: unionfs_readdir
****************************************************************************/ ****************************************************************************/
static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) static int unionfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct unionfs_inode_s *ui; FAR struct unionfs_inode_s *ui;
FAR struct unionfs_mountpt_s *um; FAR struct unionfs_mountpt_s *um;
@ -1718,11 +1721,11 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
* directories. * directories.
*/ */
strlcpy(dir->fd_dir.d_name, um->um_prefix, sizeof(dir->fd_dir.d_name)); strlcpy(entry->d_name, um->um_prefix, sizeof(entry->d_name));
/* Describe this as a read only directory */ /* Describe this as a read only directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
/* Increment the index to file system 2 (maybe) */ /* Increment the index to file system 2 (maybe) */
@ -1760,7 +1763,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{ {
/* Read the directory entry */ /* Read the directory entry */
ret = ops->readdir(um->um_node, fu->fu_lower[fu->fu_ndx]); ret = ops->readdir(um->um_node, fu->fu_lower[fu->fu_ndx], entry);
/* Did the read operation fail because we reached the end of the /* Did the read operation fail because we reached the end of the
* directory? In that case, the error would be -ENOENT. If we * directory? In that case, the error would be -ENOENT. If we
@ -1792,12 +1795,12 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
* be multiple directories. * be multiple directories.
*/ */
strlcpy(dir->fd_dir.d_name, um->um_prefix, strlcpy(entry->d_name, um->um_prefix,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
/* Describe this as a read only directory */ /* Describe this as a read only directory */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
/* Mark the end of the directory listing */ /* Mark the end of the directory listing */
@ -1869,7 +1872,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
/* Then try the read operation again */ /* Then try the read operation again */
ret = ops->readdir(um->um_node, fu->fu_lower[1]); ret = ops->readdir(um->um_node, fu->fu_lower[1], entry);
} }
} }
@ -1887,8 +1890,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
* is not a duplicate. * is not a duplicate.
*/ */
relpath = unionfs_relpath(fu->fu_relpath, relpath = unionfs_relpath(fu->fu_relpath, entry->d_name);
fu->fu_lower[1]->fd_dir.d_name);
if (relpath) if (relpath)
{ {
int tmp; int tmp;
@ -1915,13 +1917,6 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
} }
} }
while (duplicate); while (duplicate);
/* Copy the return information into the dirent structure that the
* application will see.
*/
memcpy(&dir->fd_dir, &fu->fu_lower[fu->fu_ndx]->fd_dir,
sizeof(struct dirent));
} }
return ret; return ret;

View file

@ -110,7 +110,8 @@ static int userfs_opendir(FAR struct inode *mountpt,
static int userfs_closedir(FAR struct inode *mountpt, static int userfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int userfs_readdir(FAR struct inode *mountpt, static int userfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int userfs_rewinddir(FAR struct inode *mountpt, static int userfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
@ -1236,7 +1237,8 @@ static int userfs_closedir(FAR struct inode *mountpt,
****************************************************************************/ ****************************************************************************/
static int userfs_readdir(FAR struct inode *mountpt, static int userfs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir) FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct userfs_state_s *priv; FAR struct userfs_state_s *priv;
FAR struct userfs_readdir_request_s *req; FAR struct userfs_readdir_request_s *req;
@ -1302,7 +1304,7 @@ static int userfs_readdir(FAR struct inode *mountpt,
/* Return the dirent */ /* Return the dirent */
DEBUGASSERT(dir != NULL); DEBUGASSERT(dir != NULL);
memcpy(&dir->fd_dir, &resp->entry, sizeof(struct dirent)); memcpy(entry, &resp->entry, sizeof(struct dirent));
return resp->ret; return resp->ret;
} }

View file

@ -207,6 +207,7 @@ static off_t seek_mountptdir(FAR struct file *filep, off_t offset)
{ {
FAR struct fs_dirent_s *dir = filep->f_priv; FAR struct fs_dirent_s *dir = filep->f_priv;
FAR struct inode *inode = dir->fd_root; FAR struct inode *inode = dir->fd_root;
struct dirent entry;
off_t pos; off_t pos;
/* Determine a starting point for the seek. If the seek /* Determine a starting point for the seek. If the seek
@ -240,7 +241,7 @@ static off_t seek_mountptdir(FAR struct file *filep, off_t offset)
{ {
int ret; int ret;
ret = inode->u.i_mops->readdir(inode, dir); ret = inode->u.i_mops->readdir(inode, dir, &entry);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@ -259,7 +260,8 @@ static off_t seek_mountptdir(FAR struct file *filep, off_t offset)
* Name: read_pseudodir * Name: read_pseudodir
****************************************************************************/ ****************************************************************************/
static int read_pseudodir(FAR struct fs_dirent_s *dir) static int read_pseudodir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct inode *prev; FAR struct inode *prev;
@ -276,51 +278,51 @@ static int read_pseudodir(FAR struct fs_dirent_s *dir)
/* Copy the inode name into the dirent structure */ /* Copy the inode name into the dirent structure */
strlcpy(dir->fd_dir.d_name, dir->u.pseudo.fd_next->i_name, strlcpy(entry->d_name, dir->u.pseudo.fd_next->i_name,
sizeof(dir->fd_dir.d_name)); sizeof(entry->d_name));
/* If the node has file operations, we will say that it is a file. */ /* If the node has file operations, we will say that it is a file. */
dir->fd_dir.d_type = DTYPE_UNKNOWN; entry->d_type = DTYPE_UNKNOWN;
if (dir->u.pseudo.fd_next->u.i_ops != NULL) if (dir->u.pseudo.fd_next->u.i_ops != NULL)
{ {
#ifndef CONFIG_DISABLE_MOUNTPOINT #ifndef CONFIG_DISABLE_MOUNTPOINT
if (INODE_IS_BLOCK(dir->u.pseudo.fd_next)) if (INODE_IS_BLOCK(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_BLK; entry->d_type = DTYPE_BLK;
} }
else if (INODE_IS_MTD(dir->u.pseudo.fd_next)) else if (INODE_IS_MTD(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_MTD; entry->d_type = DTYPE_MTD;
} }
else if (INODE_IS_MOUNTPT(dir->u.pseudo.fd_next)) else if (INODE_IS_MOUNTPT(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
else else
#endif #endif
#ifdef CONFIG_PSEUDOFS_SOFTLINKS #ifdef CONFIG_PSEUDOFS_SOFTLINKS
if (INODE_IS_SOFTLINK(dir->u.pseudo.fd_next)) if (INODE_IS_SOFTLINK(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_LINK; entry->d_type = DTYPE_LINK;
} }
else else
#endif #endif
if (INODE_IS_DRIVER(dir->u.pseudo.fd_next)) if (INODE_IS_DRIVER(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_CHR; entry->d_type = DTYPE_CHR;
} }
else if (INODE_IS_NAMEDSEM(dir->u.pseudo.fd_next)) else if (INODE_IS_NAMEDSEM(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_SEM; entry->d_type = DTYPE_SEM;
} }
else if (INODE_IS_MQUEUE(dir->u.pseudo.fd_next)) else if (INODE_IS_MQUEUE(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_MQ; entry->d_type = DTYPE_MQ;
} }
else if (INODE_IS_SHM(dir->u.pseudo.fd_next)) else if (INODE_IS_SHM(dir->u.pseudo.fd_next))
{ {
dir->fd_dir.d_type = DTYPE_SHM; entry->d_type = DTYPE_SHM;
} }
} }
@ -332,7 +334,7 @@ static int read_pseudodir(FAR struct fs_dirent_s *dir)
if (dir->u.pseudo.fd_next->i_child != NULL || if (dir->u.pseudo.fd_next->i_child != NULL ||
dir->u.pseudo.fd_next->u.i_ops == NULL) dir->u.pseudo.fd_next->u.i_ops == NULL)
{ {
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
} }
/* Now get the inode to visit next time that readdir() is called */ /* Now get the inode to visit next time that readdir() is called */
@ -432,14 +434,15 @@ static ssize_t dir_read(FAR struct file *filep, FAR char *buffer,
#ifndef CONFIG_DISABLE_MOUNTPOINT #ifndef CONFIG_DISABLE_MOUNTPOINT
if (INODE_IS_MOUNTPT(inode)) if (INODE_IS_MOUNTPT(inode))
{ {
ret = inode->u.i_mops->readdir(inode, dir); ret = inode->u.i_mops->readdir(inode, dir,
(FAR struct dirent *)buffer);
} }
else else
#endif #endif
{ {
/* The node is part of the root pseudo file system */ /* The node is part of the root pseudo file system */
ret = read_pseudodir(dir); ret = read_pseudodir(dir, (FAR struct dirent *)buffer);
} }
/* ret < 0 is an error. Special case: ret = -ENOENT is end of file */ /* ret < 0 is an error. Special case: ret = -ENOENT is end of file */
@ -455,8 +458,7 @@ static ssize_t dir_read(FAR struct file *filep, FAR char *buffer,
} }
filep->f_pos++; filep->f_pos++;
memcpy(buffer, &dir->fd_dir, sizeof(dir->fd_dir)); return sizeof(struct dirent);
return sizeof(dir->fd_dir);
} }
static off_t dir_seek(FAR struct file *filep, off_t offset, int whence) static off_t dir_seek(FAR struct file *filep, off_t offset, int whence)

View file

@ -321,12 +321,6 @@ struct fs_dirent_s
#endif #endif
#endif /* !CONFIG_DISABLE_MOUNTPOINT */ #endif /* !CONFIG_DISABLE_MOUNTPOINT */
} u; } u;
/* In any event, this the actual struct dirent that is returned by
* readdir
*/
struct dirent fd_dir; /* Populated when readdir is called */
}; };
/**************************************************************************** /****************************************************************************

View file

@ -33,6 +33,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#include <dirent.h>
#include <nuttx/mutex.h> #include <nuttx/mutex.h>
#include <nuttx/semaphore.h> #include <nuttx/semaphore.h>
@ -305,7 +306,7 @@ struct mountpt_operations
int (*closedir)(FAR struct inode *mountpt, int (*closedir)(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
int (*readdir)(FAR struct inode *mountpt, int (*readdir)(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir, FAR struct dirent *entry);
int (*rewinddir)(FAR struct inode *mountpt, int (*rewinddir)(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);

View file

@ -75,7 +75,7 @@ struct procfs_operations
int (*opendir)(FAR const char *relpath, int (*opendir)(FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
int (*closedir)(FAR struct fs_dirent_s *dir); int (*closedir)(FAR struct fs_dirent_s *dir);
int (*readdir)(FAR struct fs_dirent_s *dir); int (*readdir)(FAR struct fs_dirent_s *dir, FAR struct dirent *entry);
int (*rewinddir)(FAR struct fs_dirent_s *dir); int (*rewinddir)(FAR struct fs_dirent_s *dir);
/* Operations on paths */ /* Operations on paths */

View file

@ -93,7 +93,8 @@ static int netprocfs_dup(FAR const struct file *oldp,
static int netprocfs_opendir(FAR const char *relpath, static int netprocfs_opendir(FAR const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int netprocfs_closedir(FAR struct fs_dirent_s *dir); static int netprocfs_closedir(FAR struct fs_dirent_s *dir);
static int netprocfs_readdir(FAR struct fs_dirent_s *dir); static int netprocfs_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int netprocfs_rewinddir(FAR struct fs_dirent_s *dir); static int netprocfs_rewinddir(FAR struct fs_dirent_s *dir);
static int netprocfs_stat(FAR const char *relpath, FAR struct stat *buf); static int netprocfs_stat(FAR const char *relpath, FAR struct stat *buf);
@ -486,7 +487,8 @@ static int netprocfs_closedir(FAR struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int netprocfs_readdir(FAR struct fs_dirent_s *dir) static int netprocfs_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct netprocfs_level1_s *level1; FAR struct netprocfs_level1_s *level1;
FAR struct net_driver_s *dev; FAR struct net_driver_s *dev;
@ -523,8 +525,8 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
{ {
/* Copy the network statistics directory entry */ /* Copy the network statistics directory entry */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, "stat", NAME_MAX + 1); strncpy(entry->d_name, "stat", NAME_MAX + 1);
} }
else else
#ifdef CONFIG_NET_MLD #ifdef CONFIG_NET_MLD
@ -532,8 +534,8 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
{ {
/* Copy the MLD directory entry */ /* Copy the MLD directory entry */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, "mld", NAME_MAX + 1); strncpy(entry->d_name, "mld", NAME_MAX + 1);
} }
else else
#endif #endif
@ -543,8 +545,8 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
{ {
/* Copy the network statistics directory entry */ /* Copy the network statistics directory entry */
dir->fd_dir.d_type = DTYPE_DIRECTORY; entry->d_type = DTYPE_DIRECTORY;
strncpy(dir->fd_dir.d_name, "route", NAME_MAX + 1); strncpy(entry->d_name, "route", NAME_MAX + 1);
} }
else else
#endif #endif
@ -591,8 +593,8 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
/* Copy the device statistics file entry */ /* Copy the device statistics file entry */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, dev->d_ifname, NAME_MAX + 1); strncpy(entry->d_name, dev->d_ifname, NAME_MAX + 1);
} }
/* Set up the next directory entry offset. NOTE that we could use the /* Set up the next directory entry offset. NOTE that we could use the
@ -611,7 +613,7 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
DEBUGASSERT(level1->base.procfsentry != NULL && DEBUGASSERT(level1->base.procfsentry != NULL &&
level1->base.procfsentry->ops->readdir != NULL); level1->base.procfsentry->ops->readdir != NULL);
ret = level1->base.procfsentry->ops->readdir(dir); ret = level1->base.procfsentry->ops->readdir(dir, entry);
} }
return ret; return ret;

View file

@ -161,7 +161,8 @@ static int route_dup(FAR const struct file *oldp,
static int route_opendir(const char *relpath, static int route_opendir(const char *relpath,
FAR struct fs_dirent_s *dir); FAR struct fs_dirent_s *dir);
static int route_closedir(FAR struct fs_dirent_s *dir); static int route_closedir(FAR struct fs_dirent_s *dir);
static int route_readdir(FAR struct fs_dirent_s *dir); static int route_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry);
static int route_rewinddir(FAR struct fs_dirent_s *dir); static int route_rewinddir(FAR struct fs_dirent_s *dir);
static int route_stat(FAR const char *relpath, FAR struct stat *buf); static int route_stat(FAR const char *relpath, FAR struct stat *buf);
@ -685,7 +686,8 @@ static int route_closedir(FAR struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int route_readdir(struct fs_dirent_s *dir) static int route_readdir(FAR struct fs_dirent_s *dir,
FAR struct dirent *entry)
{ {
FAR struct route_dir_s *level2; FAR struct route_dir_s *level2;
FAR const char *dname; FAR const char *dname;
@ -722,8 +724,8 @@ static int route_readdir(struct fs_dirent_s *dir)
/* Save the filename and file type */ /* Save the filename and file type */
dir->fd_dir.d_type = DTYPE_FILE; entry->d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, dname, NAME_MAX + 1); strncpy(entry->d_name, dname, NAME_MAX + 1);
/* Set up the next directory entry offset. NOTE that we could use the /* Set up the next directory entry offset. NOTE that we could use the
* standard f_pos instead of our own private index. * standard f_pos instead of our own private index.