Are you saying that you mounted the file system over a non-empty directory, and you can see the previous contents of the directory? (In which case, the answer is "don't mount to a non-empty mount point". Usually it throws an error to tell you not to do that.)
If what you're seeing is the directories and files in the directory that you are using as your base directory, that's the normal behavior for a loopback file system, which is what fusexmp_fh.c
is. The example file system takes a mount point, and passes all commands on that mount point through to a backing directory. If you use a backing directory that has files in it, you will now see those files in two places, the original location and the mounted fuse directory.
If you want to understand how the directory filling works, start by taking a look at readdir
, and see how the stat
items that it returns are constructed. Each of those is a single directory entry.
Yes, you can use fusexmp_fh.c
as the basis for a basic file system, it's got all the necessary pieces, although extended metadata isn't supported. (But adding it is fairly trivial for a loopback.)