How to make symbolic links in FUSE?

I am developing a FUSE application that accepts a directory with mp3 and mounts the file system in another directory with the following structure (according to their tag):

    Artist1
       |
       -----> Album11
                 |
                 -----> Track01
                 -----> Track02
                 -----> Track03
                 -----> Track04
                 -----> Track05
       -----> Album12
       ....
    Artist2
       |
       -----> Album21
       -----> Album22
       ....
    Artist3
    .....

I am using sqlite3 database to link links to real files. Elements of artists and albums are folders, and elements of tracks are links to real ones.

I created folders for artists and albums. But now I have a problem.

I have it:

  static int getattr(...) {

      ....
      else if ( level == 0  || level == 1 || level == 2 )
      {
          // Estamos en el primer nivel. Son artistas, y por lo tanto, carpetas.
          stbuf->st_mode = S_IFDIR | 0755;
          stbuf->st_nlink = 2;
          lstat(path, stbuf);
      }
      else if (level == 3) {
      // Estamos en el tercer nivel. Son canciones, por lo que son enlaces
      stbuf->st_mode = S_IFLNK | 0755;
      stbuf->st_nlink = 2;
      lstat(path, stbuf);
      }

      .....
  }

And now, when I get a message in the tracks directory y that tells me that the function is not implemented (link functions). What function do I need to implement to find out where the link is? Or where do I need to fill in the direction of the pointer?

Thank!

+5
3

, :

  • int my_readlink(const char *path, char *buf, size_t size), struct fuse_operations .readlink. buf , . , size . . - :

    strncpy(buf, "/target/path", size);
    
  • my_getattr() ( struct fuse_operations member .getattr ), , (struct stat * stbuf):

    • stbuf->st_mod to S_IFLNK | 0777
    • stbuf->st_nlink to 1
    • stbuf->st_size ( )
+3

, readlink() - , .

+1

All Articles