
Writing a 9P server from scratch (2016) - miduil
https://blog.aqwari.net/9p/
======
pmoriarty
9P2000 is available on Linux with the CONFIG_9P_FS and related kernel compile
options, which say things like:

 _" If you say Y here, you will get experimental support for Plan 9 resource
sharing via the 9P2000 protocol. See [http://v9fs.sf.net](http://v9fs.sf.net)
for more information."_

~~~
voltagex_
That's been experimental for a long time -
[https://github.com/torvalds/linux/tree/master/fs/9p](https://github.com/torvalds/linux/tree/master/fs/9p)

I guess file systems don't go into staging/?

~~~
thisrod
Maybe, once FUSE came along, 9pfuse made more sense than putting 9p in the
kernel?

[https://9fans.github.io/plan9port/man/man4/9pfuse.html](https://9fans.github.io/plan9port/man/man4/9pfuse.html)

~~~
exikyut
I was just wondering, as I began to read the article: which would perform
better - in-kernel 9P, or FUSE?

Intuitively I get the idea that FUSE is going to be the better performer
overall because of lack of network overhead.

But I wonder how much worse 9P would be.

------
jakeogh
I'm having a hard time finding any kind of feature comparison or list. What
makes v9fs stand out?

~~~
FullyFunctional
9p or v9fs?

9p is really easy to implement. That is a key feature as it makes it easy to
create new clients and servers (and presumedly makes bugs rarer). Much like
FUSE has been adapted to countless things. I don't know how implementing a
FUSE server or client compares to this though.

Unfortunately, the simplicity also means giving up something. Where quite-
complicated NFSv4 can be very efficient over slow links (leases makes it a bit
like a cache coherency protocol), 9p requires all writes to be committed to
the server (for coherency).

~~~
jakeogh
I was wondering how v9fs compares to vanilla filesystems like ext2... I
suspect I'm comparing the wrong thing and it's a just a NFS-like protocol and
not a on disk format? If so, what is the plan9 on-disk format?

I feel like I'm missing the point and should be asking "what's cool about 9p?"
to which you provided a very helpful response. Thanks!

~~~
ori_b
> If so, what is the plan9 on-disk format?

Which one? For most user storage, there's kenfs, fossil, venti, hjfs, cwfs,
and a few others. But 9p is disjoint from where data is stored, it's just a
protocol for doing RPCs on endpoints in a heirarchical namespace.

As a result, everything is served up over 9p on plan 9. iso9660, the device
tree, the network subsystem, ftpfs, sshfs, hgwebfs, the vt100 emulator, the
keyboard, the mouse, the CD burner commands, and so on. To a good
approximation, the only things you can do without going over 9p is starting
processes.

This has interesting implications; For example, the Plan 9 equivalent of ssh
simply opens a connection to the remote system, and mounts the local /dev
before the remote one. That means that remote programs simply open the local
devices, such as the mouse and keyboard, and use them in preference to the
devices that are connected to the remote machine.

The equivalent to VNC on Plan 9 is simply namespace management to redirect
which devices programs use. Here's the full implementation:
[http://code.9front.org/hg/plan9front/file/fd023f8fd074/rc/bi...](http://code.9front.org/hg/plan9front/file/fd023f8fd074/rc/bin/rcpu)

Yes, it is just a shell script.

~~~
jakeogh
Cool. Is that sh? I'm not familiar with the [1=2] stuff... looks like it's
remapping file descriptors, is there something special about 10, 11 and 12? I
can feel my weekend slipping away...

~~~
ori_b
It's rc ([http://man.9front.org/1/rc](http://man.9front.org/1/rc)).

------
amelius
> Everything really was a file

I wonder how that would change if the system was designed today.

Everything a stream of JSON objects?

~~~
protomyth
If you were going to build a JSON based file system today, then I would study
the Newton’s Soup which was based on frames. It was pretty cool and had some
interesting capabilities (remove half the storage from a running system, ok
what’s next). I would imagine queries would make a reappearance in a much
nicer form.

~~~
soapdog
Thats exactly what I thought. Newton Soups and NewtonScript were both awesome.
I miss that kind of system these days, it still amazes me how it was all
integrated.

------
jtchang
I wish 9P was named differently. Would actually speed adoption with a bit of
"marketing".

~~~
TazeTSchnitzel
9P from Bell Labs? :p

------
shpx
How is Upspin related to 9P?

~~~
ori_b
It's not.

~~~
dullgiulio
It's not so simple. The API is a simplified version of 9P and directly
inspired by it.

