Userlandfs + libsmb2 + fuse_libsmb2: how?

I’ve updated my fuse_libsmb2 wrapper to build under Haiku. It produces an executable (not a library) that doesn’t run:

~/fuse/build> ./fuse_libsmb2
runtime_loader: Cannot open file _APP_ (needed by /boot/system/lib/libuserlandfs_fuse.so): No such file or directory

It seems that other userlandfs file systems are something called a “kernel addon” as opposed to a self contained executable. fuse_libsmb2 works in Linux and Windows. But I don’t know how to make it compatible with userlandfs.

Is there an existing example of a userlandfs file system that uses fuse_main to run? Or should I rewrite it to be a kernel addon? (How? More specifically how do I do that in cmake?)

FYI libsmb2 supports SMB 2+3… so if we (I) get this working we could have support for that. Ok ok yeah I know no support for browsing (yet) but I believe that could be added along with a GUI of some sort.

Context for this setup is:

pkgman install userland_fs
git clone https://github.com/memecode/fuse_libsmb2.git
git clone https://github.com/sahlberg/libsmb2.git sahlberg-libsmb2
mkdir build
cd build
cmake ../fuse_libsmb2

Or close enough.

The binaries are typically loaded by the userlandfs_server and not executed directly. For some add-ons you can use the proper mount command as shown at the bottom of the userlandfs guide. In my experience it is sometimes necessary to start the userlandfs_server process manually. This also allows you to see any output from the loaded add-on. Typically you would start it with something like /system/servers/userlandfs_server fuse_libsmb2 (assuming you have installed it to the proper directory) and then use the mount command from above. You can see an example for sshfs from @jessicah’s wiki page.

Edit: You can see similar commands in the description for the fuse_nfs recipe at HaikuPorts.

So fuse_nfs is basically doing the same thing I am in the .cpp code… it fills out the fuse_operations structure with callbacks and then calls fuse_main from it’s main. I’m still unsure of the binary should be an executable or a shared object. I mean having a shared object with a main function is a bit weird but ok.

Is the right install location ~/config/non-packaged/add-ons/userlandfs?
I.e. should I be linking it like:

ln -s ~/fuse/build/libfuse_libsmb2.so ~/config/non-packaged/add-ons/userlandfs/fuse_libsmb2

When I do that and try to load it via this command:

mount -t userlandfs -o 'fuse_libsmb2 -f --uri=smb://myuser:mypass@192.168.0.203/Users' ~/mnt

It just hangs without printing anything.

And if I call userlandfs_server directly I can’t pass any arguments to my addon because userlandfs_server just prints it’s usage. If I run it without arguments I get:

~/fuse/build> /system/servers/userlandfs_server fuse_libsmb2
resolve symbol "connect" returned: -2147478780

And after that userlandfs_server is stuck and can’t be exited. It’s hard hung and you have to reboot the whole OS to unstick it.

Ooo, so adding network library fixes the connect symbol issue. And now it seems to print the same sort of info as sshfs when you invoke it with userlandfs_server. And indeed the mount command also completes. It doesn’t actually WORK but it seems a bunch better than before.

What I’m trying to figure out now is how to pass parameters to the file system when calling it with userlandfs_server. Cause I’d like to see the stdout logging for debug purposes…

If you run /system/servers/userlandfs_server fuse_libsmb2 then it should also print out any messages from the loaded executable as it handles mount requests.

It’s a shared object (an add-on for the userlandfs_server). The entry function is called main() to keep the code as similar as possible to how FUSE is used in Linux, allowing to port Linux FUSE filesystems without changing the code.

The options to the filesystem can be passed, not at the time of launching userlandfs, but through the mount command line (I don’t remember if it’s the -o or the -p option). These options are passed to the userlandfs_server which then calls the filesystem’s main function.

Ok, so I’ve got it building as a library now. But I can’t work out how to see the stdout logging when I instantiate the add on with something like this:

mount -t userlandfs -o 'fuse_libsmb2 --uri=smb://myuser:mypass@host/share' ~/mnt

Or do I have to redirect all the logging to my file of my choice?

You can start the userlandfs_server manually before you run the mount command. Then, your already running userlandfs_server will be used, and if it runs in a terminal, you can see the output there. Otherwise, the mount command starts the server in the background, and you can’t see the stdout output.

1 Like

Omg it works… I’ve just mounted my first folder.

I ran userlandfs_server in one shelll and the mount command in another…

One thing tho:

~/fuse/fuse_libsmb2> unmount ~/mnt/
unmount: unmounting failed: Device/File/Resource busy

Is there anyway of seeing what is accessing the mount point and blocking it from being unmounted?

1 Like
fdinfo -d <mountpoint>

should do the trick.

2 Likes