FUSE: virtual directories

I'm trying to make a FUSE that organizes files based on extension (.png, .c, ...). I want to display a set of folders in the FUSE root directory, each one representing a file extension. When someone is cd

in this folder, it should display all files with this extension (the user will indicate which directory should be organized during installation). For example, the output should look like this:

mount/$ ls
+c +cpp +png +py
mount/$ cd +c
mount/+c/$ ls
hello.c xyz.c

      

I am using +

to replace the .

extension.

I use the set implementation and scan through the desired directory and its subdirectories to find all file extensions, and then just display the contents of the set in readdir.

int my_readdir(const char* path, void* buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi)
{
   filler(buffer,".",NULL,0);
   filler(buffer,"..",NULL,0);
   if(strcmp("/",path)==0)
   {
     int i;
     for(i=0;i<ext_set.length;i++)
     {
       filler(buffer,ext_set.get(i),NULL,0);
     }
   }
}

      

I get output as shown above, however they are not listed as directories. cd +c

throws +c: Not a directory

(which obviously isn't).

How do I make them virtual directories?

+3


source to share





All Articles