News for hackers. Stuff that matters.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ylow on Tuesday September 19, 2023 @02:29PM (#37574100)
Hi! Author here. Happy to answer any questions!
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ReactiveJelly on Tuesday September 19, 2023 @03:35PM (#37575214)
> You simply need to implement the vfs::NFSFileSystem trait.

Wait, what......

.. So not only is it an easy-to-run Rust NFS server and client (I gave up on NFS some years ago because I couldn't figure out how to run Samba) but it's also meant to use as a _substitute_ for FUSE in stacks like SSHFS or an app wanting to serve debug data as files?

Awesome!

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by eqvinox on Tuesday September 19, 2023 @03:39PM (#37575288)
I don't think this includes a client, in fact the post argues that not having to implement the client because it already exists in the kernel was a major benefit of the approach…
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ylow on Tuesday September 19, 2023 @03:49PM (#37575469)
Exactly. You build the server-side (as a FUSE alternative), and just use the OS's NFS client to mount it.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by inferiorhuman on Tuesday September 19, 2023 @06:53PM (#37578174)
Sweet! I've been monkeying around with writing an HFS interpreter (in rust ofc). Unfortunately 'fuser' is less than ideal on a Mac. This could be an interesting alternative.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ReactiveJelly on Thursday September 28, 2023 @04:54PM (#37695692)
You can interoperate async and threads, but yes you have to tolerate having Tokio or similar as a dep
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by lukax on Tuesday September 19, 2023 @03:35PM (#37575223)
This library is amazing. Also very happy to see such a permissive license.

Btw, why did you decide to use NFS instead of WebDAV? WebDAV should be easier to implement and is also supported on all platforms.

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ylow on Tuesday September 19, 2023 @03:46PM (#37575422)
I have not looked at WebDAV closely. I was looking for something that is already supported in all the major operating systems without additional libraries. I don't believe WebDAV is commonly supported out of the box?
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by lukax on Tuesday September 19, 2023 @03:52PM (#37575522)
WebDAV is supported by Windows, MacOS and Linux. On all platforms you can mount it without admin/sudo (`net use` on Windows, `mount_webdav` on macOS and `gio mount` on Linux). Here is official Go package[1] using which you can implement your own WebDAV server (you only need to implement your FS interface).

[1] https://pkg.go.dev/golang.org/x/net/webdav

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ylow on Tuesday September 19, 2023 @03:59PM (#37575629)
Interesting. I do not know much about webdav. Great to learn something new! Will take a look.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by eqvinox on Tuesday September 19, 2023 @03:49PM (#37575477)
WebDAV on Linux works over drumrull FUSE :D
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by eqvinox on Tuesday September 19, 2023 @03:38PM (#37575270)
Have you run any POSIX compliance checks against it? In particular, how are you handling assignment of inode numbers (fileid in NFS speak) to "virtual" files and making sure those stay reasonably consistent? (I vaguely remember this being a bit of a tripwire)

Also did you look at NFSv4 / what made you decide to go with NFSv3? My (superficial) impression was that NFSv4 did a lot of simplifying and throwing out legacy stuff (e.g. rpcbind), but I don't know too many details on this…

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ylow on Tuesday September 19, 2023 @03:44PM (#37575363)
I tested by uh... building a "mirrorfs" and compiling this project in it :-) (cargo does stress it pretty hard). I have not looked for POSIX compliance testers. Is there one you can point me to?

NFSv4 did throw out a lot of the legacy stuff, but also added a bunch of other state information like locks and delegation which is quite a bit more annoying to implement. Technically cos this is meant for "localhost-mounting-only", delegation should be easy to build (since we are expecting only exactly 1 mount). But v3 had far fewer APIs to implement, and so is a good starting point.

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by EdSchouten on Tuesday September 19, 2023 @04:14PM (#37575864)
Note that there’s absolutely no requirement to support more advanced features such as locking and delegations. Even if a client offers to accept a delegation, a server may just deny/ignore it as part of OPEN.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by eqvinox on Tuesday September 19, 2023 @03:48PM (#37575450)
There's https://github.com/google/file-system-stress-testing but in this case I believe it would mostly stress-test the NFS client rather than your code… and I have never tried to use it, no idea if it even does anything useful.

I know from lore that there are compliance-test suites for the POSIX file system API, but I believe those are commercial products :(

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by ianlevesque on Tuesday September 19, 2023 @04:03PM (#37575713)
xfstests is very thorough and reusable beyond xfs.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by zeotroph on Tuesday September 19, 2023 @05:58PM (#37577453)
If I may ask, is this mirrorfs available somewhere? The demofs from nfsserve seems to create and server a pure in-memory fs tree if I read the sources correctly.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by mprovost on Tuesday September 19, 2023 @03:56PM (#37575581)
NFSv4 is a completely different protocol and basically doesn't share anything with v2/v3. While technically it's still implemented using Sun RPC, it only has two procedures: NULL and COMPOUND. Version 3 is actually an RPC protocol, with a different procedure for each filesystem operation (READ, WRITE, CREATE, ...). One of the genius moves that Sun made with NFS was to distribute the protocol files (rpcgen) which autogenerate stubs (in C) making it easy to implement servers and clients. Nothing like that exists for v4.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by EdSchouten on Tuesday September 19, 2023 @04:11PM (#37575832)
Look at RFC 7531. XDR definitions for NFSv4 exists, and they can also be used to generate C bindings if you want.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by mprovost on Tuesday September 19, 2023 @05:19PM (#37576875)
Sure, running it through rpcgen generates bindings for both RPCs, NULL and COMPOUND:

    /// /*
    ///  * Remote file service routines
    ///  */
    /// program NFS4_PROGRAM {
    ///         version NFS_V4 {
    ///                 void
    ///                         NFSPROC4_NULL(void) = 0;
    ///
    ///                 COMPOUND4res
    ///                         NFSPROC4_COMPOUND(COMPOUND4args) = 1;
    ///
    ///         } = 4;
    /// } = 100003;
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by EdSchouten on Tuesday September 19, 2023 @10:42PM (#37579846)
Which is also what you want, right? The issue is that with compound calls there is some state that’s carried over between operations (current/saved file handle), so you’d need to implement that yourself anyway.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by mprovost on Wednesday September 20, 2023 @02:38AM (#37581105)
Well yeah that's the difference, it doesn't generate the state machine for you so you "just" need to implement it yourself. For v3, rpcgen spits out a working function that you link into your program and you're done (on the client side anyway). Much easier.
Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by hn92726819 on Wednesday September 20, 2023 @12:13AM (#37580310)
I believe you can install an NFS client on windows home if you just go to programs and features > add a feature > NFS client, but I don't have a way to check.

The fact you just need to impl one trait is amazing. I will definitely be testing this out

Re:NFS > FUSE: Why We Built Our Own NFS Server in Rust by hn92726819 on Wednesday September 20, 2023 @11:25AM (#37585392)
You're right, there is no way to do it in windows home edition