How to Register Fuse Filesystem Type with Mount(8) and Fstab

How to register FUSE filesystem type with mount(8) and fstab?

In general, one "registers" a new mount filesystem type by creating an executable mount.fstype.


$ ln -s /usr/bin/vdbfs.py /usr/sbin/mount.vdbfs

If vdbfs.py takes mount-ish arguments (i.e. dev path [-o opts]), then mount -t vdbfs and using vdbfs as the 3rd field in fstab will work. If it doesn't, you can create a wrapper which does take arguments of that form and maps them to whatever your vdbfs.py takes.

FUSE should also install a mount.fuse executable; mount.fuse 'vdbfs.py#dev' path -o opts will go on and call vdbfs.py dev path -o opts. In that case, you can use fuse as your filesystem type and prefix your device with vdbfs.py#.

Linux: fstab with additional mount options?

As per my comment:

gluster1:/gv0 /var/www/html/ glusterfs defaults,_netdev,aux-gfid-mount,fetch-attempts=5 0 0

How to tell fuse3 that you need a device and a mount point in command-line arguments

so for this you will have to restrict the user on the order of the cmd arguments(all fuse/mount options come before the devicepath and mountpoint). To make it simple, ensure that the path to the device and mount point are provided last:

So in your main function, this statement will check that there is a correct number of arguments and the mount point and device do not start with hyphens as with options.

    if ((argc < 3) || (argv[argc-2][0] == '-') || (argv[argc-1][0] == '-'))
{
fprintf(stderr, "usage: ./myfuse [FUSE and mount options] devicepath mountPoint\n");
abort();
}

Then extract the device path and store it in a struct:

struct my_state *my_data;
my_data = malloc(sizeof(struct mi_state));
if (mi_data == NULL) {
perror("main calloc");
abort();
}

my_data->devicepath = realpath(argv[argc - 2], NULL);
argv[argc-2] = argv[argc-1];
argv[argc-1] = NULL;
argc--;

Notice that I remove the device paths from argv and decrement argc by 1 before passing hem to the fuse_main function
Then while calling the fuse_main function make sure to pass the my_data struct:

fuse_main(argc, argv, &my_fuse_operations, mi_data);

Here is the defination of the my_state struct which you can put in a header file:

struct my_state{
char *devicepath;
};

You should also add this definition in the header file below the struct definition:

#define BB_DATA ((struct mi_state *) fuse_get_context()->private_data)

And also in your init function call fuse_get_context and return BB_DATA:

void *my_init()
{
fuse_get_context();
return BB_DATA;
}

The return value will be passed in the private_data field of fuse_context to all file operations and as a parameter to the destroy() method.
The fuse_context is set up before this function is called, and fuse_get_context()->private_data returns the user_data passed to fuse_main().

Fstab mount error mount: unknown filesystem type 'gid=33'

You've neglected to include the file system type in the fstab line. You should use

sshfs#computer2@24.97.20.3:/Volumes/1TB\040Extra/MoodleMount /mnt/CampusServer fuse.sshfs allow_other,uid=33,gid=33

Mount using offline file system (OFS+FUSE)

You're using it incorrectly, you must have two forward slashes in the URI that is specified as the mount device i.e. file://.

As an e.g.

$ sudo mount -t ofs file://usr /tmp/mnt
$ ls /tmp/mnt
bin/ etc/ games/ include/ lib/ lib32/ libx32/ local/ sbin/ share/ src/
$ sudo umount /tmp/mnt

with a single file:/ we have:

$ sudo mount -t ofs file:/usr /tmp/mnt
$ ls /tmp/mnt
ls: cannot access /tmp/mnt: Transport endpoint is not connected
$ sudo umount /tmp/mnt

Now if you're intending to use a remote filesystem with OFS, which is the primary use-case, you have to first install the relevant remote filesystem packages on the OS you're using, then use, for example, if we've got cifs, which is the newer name for smb/samba:

sudo mount -t ofs cifs://127.0.0.1/Music /tmp/music

Now, if you need to pass options to cifs, such as the password/username/a config file, you can use the remoteoptions parameter, so for example for guest account access:

sudo mount -t ofs -o remoteoptions=guest cifs://127.0.0.1/Music /tmp/music

or, if you're using a credentials file (see mount.cifs manual page), you can use:

sudo mount -t ofs -o remoteoptions=credentials=/etc/remotecreds.conf cifs://127.0.0.1/Music /tmp/music

for remote options, you use a : as the separator (it gets swapped for a , when passed into the underlying mount command), so to mount as an explicit user/password:

sudo mount -t ofs -o remoteoptions=username=mike:password=mike1 cifs://127.0.0.1/Music /tmp/music

Mount local partition via fuse

I don't know how Android handles /data/media permissions and my solution does not involve FUSE, but if you create a group and add all users in it and set setgid bit on the root of the secondary file system and change it's group to group with all users then owner of each file will still be user that created the file but group of the file will contain all user and therefore they can access it if you set permissions on that file right (something like 660).



Related Topics



Leave a reply



Submit