Search code examples
linuxunixlinux-kernelfuse

How do I mount a directory in a remote machine using fuse?


I am wondering how to use FUSE to mount a directory from a remote machin . The tutorial given in this link mounts a local directory on to another local one. This essentially happens in the fuse_main function. Does anyone have an idea as how to do the same for a directory on a remote machine?

The function call is as follows

fuse_main(argc, argv, &bb_oper, bb_data);

Note: I cannot use sshfs

Thanks.


Solution

  • Just like any other network file system, FUSE is going to need an underlying transport layer. It can't help you unless something on the remote machine is able to handle the actual I/O for you.

    In your fuse arguments, you set up handlers for the things you want the file system to be able to handle, e.g:

    static struct fuse_operations const myfs_ops = {
            .getattr = my_getattr,
            .mknod = my_mknod,
            .mkdir = my_mkdir,
            .unlink = my_rm,
            .rmdir = my_rmdir,
            .truncate = my_truncate,
            .open = my_open,
            .read = my_read,
            .write = my_write,
            .readdir = my_readdir,
            .create = my_create,
            .destroy = my_destroy,
            .utime = my_utime,
            .symlink = my_symlink
    };
    

    That's code from one of my current FUSE implementations, re-written generically. As you can see, you'll need to at least implement open, read, write and close for a minimally functional FS.

    Those members are functions, which do those operations. They can use HTTP, SSH, FTP, a custom protocol, whatever you want. But, you have to write them, and something on the remote server needs to respond to them.

    To answer your question directly, FUSE (on it's own) isn't going to do what you want, unless you implement the functionality yourself.