In the implemention of xxx_readdir()
in FUSE, I use the codes below:
static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
DIR *dp;
struct dirent *de;
(void) offset;
(void) fi;
dp = opendir(path);
if (dp == NULL)
return -errno;
while ((de = readdir(dp)) != NULL) {
struct stat st;
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
if (filler(buf, de->d_name, &st, 0))
break;
}
closedir(dp);
return 0;
}
Then, compile and execute on a foler:
./hello /tmp/hello/
When I use ls /tmp/hello/
command, the results are as below:
bin dev home lib64 media opt root sbin sys usr
boot etc lib lost+found mnt proc run srv tmp var
However, I have not created any file or directory in /tmp/hello/
. So, why are these direcoties reside on it when I use the ls
command?