MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_file_getdents

Function dfs_file_getdents

components/dfs/dfs_v2/src/dfs_file.c:2316–2345  ·  view source on GitHub ↗

* @brief Read directory entries * * This function reads directory entries from the directory file descriptor into * the buffer provided. Each entry is stored as a struct dirent. * * @param[in] file Pointer to the directory file structure * @param[out] dirp Buffer to store directory entries * @param[in] nbytes Size of the buffer in bytes * * @return int Number of bytes read on success, or

Source from the content-addressed store, hash-verified

2314 * -RT_ERROR for general errors
2315 */
2316int dfs_file_getdents(struct dfs_file *file, struct dirent *dirp, size_t nbytes)
2317{
2318 int ret = -RT_ERROR;
2319
2320 if (file)
2321 {
2322 if (file->vnode && S_ISDIR(file->vnode->mode))
2323 {
2324 if (file->fops && file->fops->getdents)
2325 {
2326 DLOG(msg, "dfs_file", file->dentry->mnt->fs_ops->name, DLOG_MSG, "fops->getdents()");
2327
2328 if (dfs_is_mounted(file->vnode->mnt) == 0)
2329 {
2330 ret = file->fops->getdents(file, dirp, nbytes);
2331 }
2332 else
2333 {
2334 ret = -EINVAL;
2335 }
2336 }
2337 }
2338 }
2339 else
2340 {
2341 ret = -EBADF;
2342 }
2343
2344 return ret;
2345}
2346
2347/**
2348 * @brief Check if a path refers to a directory

Callers 3

readdirFunction · 0.70
lsFunction · 0.70
copydirFunction · 0.70

Calls 1

dfs_is_mountedFunction · 0.85

Tested by

no test coverage detected