2013-01-08 21:05:02 +08:00
|
|
|
/*
|
2021-03-07 08:34:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
2020-04-13 06:56:43 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2011-06-02 Bernard first version
|
2020-04-13 06:56:43 +08:00
|
|
|
* 2020-04-12 Jianjia Ma add msh cmd
|
2013-01-08 21:05:02 +08:00
|
|
|
*/
|
2022-01-11 15:20:14 +08:00
|
|
|
#include <dfs_file.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statfs.h>
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
void seekdir_test(void)
|
|
|
|
{
|
2021-03-07 08:34:04 +08:00
|
|
|
DIR * dirp;
|
|
|
|
long save3 = 0;
|
|
|
|
int i = 0;
|
|
|
|
struct dirent *dp;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2021-03-07 08:34:04 +08:00
|
|
|
dirp = opendir ("/");
|
|
|
|
save3 = telldir(dirp);
|
|
|
|
for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
|
|
|
|
{
|
|
|
|
rt_kprintf("direntry: %s\n", dp->d_name);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2021-03-07 08:34:04 +08:00
|
|
|
/* save the pointer of the third directory */
|
|
|
|
if (i++ == 3)
|
|
|
|
{
|
|
|
|
save3 = telldir(dirp);
|
|
|
|
}
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2021-03-07 08:34:04 +08:00
|
|
|
/* get back to the third directory */
|
|
|
|
seekdir (dirp, save3);
|
|
|
|
rt_kprintf("seek dientry to: %d\n", save3);
|
|
|
|
for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
|
|
|
|
{
|
|
|
|
rt_kprintf("direntry: %s\n", dp->d_name);
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2021-03-07 08:34:04 +08:00
|
|
|
/* close the directory */
|
|
|
|
closedir (dirp);
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2020-04-13 06:56:43 +08:00
|
|
|
#ifdef RT_USING_FINSH
|
2013-01-08 21:05:02 +08:00
|
|
|
#include <finsh.h>
|
|
|
|
FINSH_FUNCTION_EXPORT(seekdir_test, perform directory seek test);
|
2020-04-13 06:56:43 +08:00
|
|
|
MSH_CMD_EXPORT(seekdir_test, perform directory seek test);
|
|
|
|
#endif /* RT_USING_FINSH */
|