Open eu41 opened 8 years ago
This is probably an issue with how fstab is parsed and how many times the options are passed through shell. You may need 4 escapes :)
Can you please attach a strace -f of the mount command?
@cemeyer can you please take a look? I am not familiar with FreeBSD and Linux has a different way of handling fstab / mount (using external helpers) which makes it hard for me to debug it.
I'll look. I don't have a lot of familiarity with this part of the system either. If I had to guess, I'd guess that whatever parses fstab is ignoring your escapes entirely and just splitting on commas.
Edit: I can't even get mount to attempt to mount a fuse filesystem. It prints:
fstab: /etc/fstab:9: Inappropriate file type or format
fstab: /etc/fstab:9: Inappropriate file type or format
Any idea, @eu41?
@opurdila, by the way, the FreeBSD equivalent of strace
is called truss
.
Conrad, try a fstab entry simlar to mine. Alternatively, send your fstab line so I can have a look.
Conrad, try a fstab entry simlar to mine. Alternatively, send your fstab line so I can have a look.
I used a very similar line:
/dev/da0 /mnt/USB fuse mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache\,compress=no\,discard 0 0
Your line has the proper format, but ext4 does not support space_cache and compress=no, which are specific to btrfs. Fort ext 4 you could try "nodealloc,auto_da_alloc,discard" on an ext4 formatted partition. Remove discard if it's not on a SSD.
The output of truss -f mount /dev/ada5p5 is attached in a text file. truss.txt
Your line has the proper format, but ext4 does not support space_cache and compress=no, which are specific to btrfs. Fort ext 4 you could try "nodealloc,auto_da_alloc,discard" on an ext4 formatted partition. Remove discard if it's not on a SSD.
mount hasn't gotten to where opts
gets parsed, so this doesn't matter at all. Removing those options gives the same result.
The output of truss -f mount /dev/ada5p5 is attached in a text file.
Thanks!
Would it be useful to send you the output of truss command that mounts successfully from command line?
Hmm, looks like the output does not help much because the lklfuse execve arguments are not show. Quickly googling freebsd, truss and execve shows that using -a might help.
@eu41 could you please rerun truss with -a and post the result here? Thanks!
Octavian, I don't know much about tracing/debugging, but I did what you asked and applied some logic. The output of truss -a is attached for two commands and I'm also attaching an extract from my fstab.
The second command fails with the message:
fuse: unknown option `discard'
As you see, the message indicates that the parsing of fstab seems to work properly, the option 'discard' is correctly detected, but somehow is unknown to fuse. Note that even if I add one escape or two escapes in fstab for "opts= ...", I get the same error message, which indicates again that parsing works fine.
Note that the first line in my fstab, which is using ntfs-3g to mount a Windows partition works perfectly when doing "mount /dev/ada5p1". So there seems to be a difference on the way ntfs3g, lklfuse or mount deal with fstab lines.
One more thing: the command that fails is "mount /dev/ada5p4". However, at the end of the output of truss you can see that actually mount is not trying to work with ada5p4 (btrfs partition), but ada5p5, which is my Freebsd native ufs root partition. No ideea why it does that. I have a feeling that FreeBSD mount does not know anything other than ufs partitions, but I cannot explain why "mount /dev/ada5p1" properly mounts the ntfs windows partition, while "mount /dev/ada5p4" fails to mount the btrfs partition.
I don't know which one, mount or lklfuse, is the problem, but the fact that the parsing works, leans towards an lklfuse issue.
Maybe Conrad has some ideas here.
@eu41 please run with -f as well, i.e. truss -f -a, otherwise we can't see the arguments passed to fuse.
See attached the output of truss -f -a for three versions of fstab: no escapes, 1 escape, 2 escapes.
Looking at the parameters passed to lklfuse in execve, I think that the fstab should not include any escapes and it's up to lklfuse to assemble into one string all the "-o" options that follow "opts=..." and then use that string to do the mount.
truss-no_excapes.txt truss-one_escape.txt truss-two_escapes.txt
Thanks! It seems that the fstab parser ignores the comma escapes. Also please note that -o rw, -o noatime, etc. are only passed to the fuse module and does not reach LKL.
Right now lklfuse follows the libfuse's conventions and options to be passed to the mount system call should be passed as -o opts=... with , and = escaped.
I am not sure if it is wise to pass all -o options to LKL since there may be collisions with fuse options. A safe way to solve this is to use a separate mount script as a wrapper for lklfuse.
I'll have to think about this more, hope to have something in a couple of days.
Why not trying to pass to LKL only its own specific options, including filesystem specific options, like
-o type=btrfs,opts=space_cache,compress=no,discard ... etc.
and leave the others like "rw,noatime ... etc." to be dealt with by OS specific mount command?
After you think about it and do the necessary modifications, please let Conrad know, so he can update the FreeBSD port.
crazy idea: why don't we just use the original mount command(from busybox or core-utils) and either change the source or use LD_PRELOAD to change the 'mount' syscall to a lklfuse function call? This way you could use all the features that come with that command including fs detection.
Check attached FreeBSD /etc/fstab:
"mount /mnt/windows" works, while "mount /mnt/gentoo" fails
Puzzling why ntfs-3g works fine and has no problems processing all the mounting options, one of them specific to that filesystem, while lklfuse cannot do the same and fails.
The previous update #205 fixed the mounting with filesystem specific options when mounting with lklfuse from command line, but not from /etc/fstab.
The following happens:
lklfuse -o type=btrfs,opts=space_cache\,compress\=no\,discard
works perfectly fine from command line.
When adding this line in /etc/fstab:
/dev/ada2p2 /mnt/data fuse mountprog=/usr/local/bin/lklfuse,type=btrfs,opts=space_cache 0 0
it also works.
But when I add a second or third, fourth filesystem specific option:
/dev/ada2p2 /mnt/data fuse mountprog=/usr/local/bin/lklfuse,type=btrfs,opts=space_cache\,compress\=no\,discard 0 0
it fails with message "Unknown option compress=no".
Tried with one escape, two escapes and no escape, same result.
From fstab it only works with one option, it seems that it cannot deal with subsequent options after the first one.