9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] 9P and Linux experiment
@ 2025-02-14  2:09 Alyssa M via 9fans
  2025-02-14  2:54 ` Nicola Girardi via 9fans
  2025-02-14  7:58 ` Edouard Klein
  0 siblings, 2 replies; 9+ messages in thread
From: Alyssa M via 9fans @ 2025-02-14  2:09 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 13232 bytes --]

I have a complicated relationship with 9P2000.L. On the one hand it's been a useful way to build file systems for Linux, and I've gotten some mileage out of that. On the other hand, I'm not crazy about having a different protocol to 9P (I've read through a lot of what's been said on 9fans about this, going back many years).

I've been trying an experiment over the last few weeks to see if I can pass the extra Linux file system features over 9P (9P2000) as an application of 9P rather than using a separate protocol. I want to be able to connect two Linux machines using 9P, but have the full Linux file system semantics available across the connection: symbolic links, moving files and directories around, nanosecond time stamps, open modes, record locking, the whole bit. I also want that to work properly with a Plan 9 machine between them.
Linux programs should see a Linux file system, Plan 9 programs should see a Plan 9 file system.

I think it's easiest to explain by walking through an end-to-end example.

First, I altered my Linux 9P (9P2000) file server to offer an encoding of the linuxiness (is that a word??) For example, here's a test directory on my Linux machine. 

lyssa@pibysix:~/t $ *ls -l*
total 28
-rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
-rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
-rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three
lyssa@pibysix:~/t $

If I mount it on Plan 9 with my 9P server, it looks like this:

term% *pwd*
/usr/glenda/mnt/home/lyssa/t
term% *ls -lp*
--rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
d-rwxr-xr-x M 1061 glenda glenda  0 Feb  6 23:51 bin
--rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
--rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
--rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
--rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello
--rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello6
--rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
--rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi2
----------- M 1061 '(0)'  glenda  0 Jan  1  1970 somenewlinkname
term%

These files all behave as you might expect from a vanilla 9P server.
(the symbolic links are followed - the bottom one is a broken link. A long and involved conversation could be had about this, but can we not do that right now?)

I've added an invisible virtual extension to the namespace my Linux 9P server offers:
For any given file "/a/b/c/foo", there is a control file, "/a/b/c/,ctl/foo" which gives access to all its linuxy gloriousness:

term% *cat ,ctl/foo*
dev 45831
inode 265868
mode 0100644
nlink 1
uid 1001
gid 1001
rdev 0
size 6
blksize 4096
blocks 8
atime 1739199962
mtime 1739199962
ctime 1739466812
atimensec 460383798
mtimensec 470383712
ctimensec 926076796
name foo
term%

You can also write commands into these files to change some of the properties - as you might expect.
Here are the control files in the (unlisted) virtual directory ",ctl":

term% *ls -lp ,ctl*
--rw-r--r-- M 1061 glenda glenda 0 Feb  8 11:41 bar
--rw-r--r-- M 1061 glenda glenda 0 Feb  6 23:51 bin
--rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 foo
--rw-r--r-- M 1061 glenda glenda 0 Feb  9 15:31 foop
--rw-r--r-- M 1061 glenda glenda 0 Feb  9 18:33 foop2
--rw-r--r-- M 1061 glenda glenda 0 Feb  7 00:54 foot
--rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello
--rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello6
--rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi
--rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi2
--rw-r--r-- M 1061 '(0)'  glenda 0 Jan  1  1970 somenewlinkname
term%

",ctl" is a simple example of a means to pass parameters down a Twalk to later requests by using weird file names.
You can pass other parameters...

term% *ls -lp ,nofollow*
--rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
a-r--r--r-- M 1061 glenda glenda  6 Feb  7 22:17 bin
--rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
--rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
--rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
a-r--r--r-- M 1061 glenda glenda  3 Feb  7 01:06 hello
a-r--r--r-- M 1061 glenda glenda  5 Feb 11 02:08 hello6
--rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
a-r--r--r-- M 1061 glenda glenda  2 Feb  9 01:28 hi2
a---------- M 1061 glenda glenda 13 Feb 11 03:20 somenewlinkname
term%

This provides a way to avoid following the symbolic links.
Symlinks show up as append-only, read-only files, which is a bit of a hack, I suppose, but perhaps okay for now.
When you don't follow symlinks, they present their link target.

term% *cat ,nofollow/bin; echo*
../bin
term%

And you can access the control file of a link:

term% *cat ,ctl,nofollow/bin*
dev 45831
inode 263367
mode 0120777
nlink 1
uid 1001
gid 1001
rdev 0
size 6
blksize 4096
blocks 0
atime 1738966670
mtime 1738966670
ctime 1738966670
atimensec 484184178
mtimensec 484184178
ctimensec 484184178
name bin
symlink ..%2Fbin
term%

You can make new symbolic links from plan 9.
(where's that Linux ls(1) program?)

term% *ls -l ../../../bin/ls*
--rwxr-xr-x M 1061 '(0)' glenda 108752 Feb 28  2019 ../../../bin/ls
term%

Let's link to it:

term% *echo symlink ../../../bin/ls another >,ctl/,*
term% *ls -lp*
--rwxr-xr-x M 1061 '(0)'  glenda 108752 Feb 28  2019 another
--rw-r--r-- M 1061 glenda glenda      6 Feb  8 11:41 bar
d-rwxr-xr-x M 1061 glenda glenda      0 Feb  6 23:51 bin
--rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 foo
--rw-r--r-- M 1061 glenda glenda      1 Feb  9 15:31 foop
--rw-r--r-- M 1061 glenda glenda      1 Feb  9 18:33 foop2
d-rwxr-xr-x M 1061 glenda glenda      0 Feb  7 00:54 foot
--rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello
--rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello6
--rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi
--rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi2
----------- M 1061 '(0)'  glenda      0 Jan  1  1970 somenewlinkname
term%

",ctl/," is a name for the control file for the directory itself.
Commands written there can be used to make symlinks, move files, etc.
It has an alias in the parent directory's ,ctl directory.


So that's the general idea. Linux extras are hidden from Plan 9, but accessible.


Second, I built an client adapter for Linux that uses these extra mechanisms. It serves 9P2000.L, which it mounts locally using v9fs - the Linux 9P client, but speaks "9P-with-benefits" across the network as a client. I have it in mind to do a version for FUSE one day, instead of using v9fs.

Exportfs on my plan 9 machine is serving the namespace above that included a mount of my Linux 9P server, above.
I've mounted that on Linux in /mnt/mnt. So now Linux is looking at Plan 9, which is looking at Linux:

lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t *$ ls -l*
total 24
lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
-rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
-rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
-rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three

All that linuxy goodness is passed through Plan 9 as shown above. Linux does not expect file systems to follow
symbolic links themselves, so the adapter uses ",nofollow". Here's the same directory with the links resolved by Linux:

lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ *ls -lL*
total 24
-rwxr-xr-x 1 root  root  108752 Feb 28  2019 another
-rw-r--r-- 1 lyssa lyssa      6 Feb  8 11:41 bar
drwxr-xr-x 2 lyssa lyssa   4096 Feb  6 23:51 bin
-rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 foo
-rw-r--r-- 1 lyssa lyssa      1 Feb  9 15:31 foop
-rw-r--r-- 1 lyssa lyssa      1 Feb  9 18:33 foop2
drwxr-xr-x 2 lyssa lyssa   4096 Feb  7 00:54 foot
-rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello
-rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello6
-rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi
-rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi2
?????????? ? ?     ?          ?            ? somenewlinkname
lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $

Lets make a link on Linux, by passing the request through plan 9 and back to Linux:

lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ *ln -s ../../../bin/ls another2*

* The "ln" command makes a symlinkat(2) system call into the Linux kernel.
* The v9fs driver in the kernel fields the call and issues a Tsymlink 9P2000.L message to my mounted adapter through a pipe.
* My adapter receives that and translates it into a 9P Twalk to the control file for the containing directory, Topens the file and issues a 9P Twrite with the "symlink" command in it, which goes over the network to Plan 9
* exportfs running on Plan 9 receives the Twalk, Topen and Twrite, and makes open(2) and pwrite(2) calls to the Plan 9 kernel.
* devmnt in the Plan 9 kernel - I think... - issues the same Twalk, Topen and Twrite requests over the network to my Linux 9P server.
* My 9P server receives the Twrite command and issues a symlinkat(2) system call.
* The Linux server kernel makes the symbolic link.

(there were some clunks and closes as well).

lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ *ls -l*
total 24
lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:03 another2 -> ../../../bin/ls
-rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
-rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
-rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
-rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three
lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $

So now Linux can mount file systems over 9P, and still see all the nanosecond timestamps and other stuff:

lyssa@pibysix:~/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ *stat foo*
  File: foo
  Size: 6               Blocks: 8          IO Block: 4096   regular file
Device: 36h/54d Inode: 265870      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/   lyssa)   Gid: ( 1001/   lyssa)
Access: 2025-02-10 15:06:02.460383798 +0000
Modify: 2025-02-10 15:06:02.470383712 +0000
Change: 2025-02-10 18:32:05.271025091 +0000
Birth: -
lyssa@pibysix:~

(I suppose nanosecond resolution timestamps must be important to some people...)
My adapter is operating in a heterogeneous file system in this example, where part of it has this extended behaviour, and part of it does not. There's no mode switch or barriers - it just looks for the virtual files, and if they're not there it does the standard thing. If I'd bound some other part of the Plan 9 space over part of the the mounted Linux space before I exported it, the adapter would just fall back to vanilla behaviour when file accesses are in that subtree.
It's a work in progress.
Linux is not actually my platform of choice, and symbolic links are not exactly my spirit animal, but it's a familiar context for exploring the ideas.

I don't know what people think?
This is about my third iteration of this idea. I'm not sure I'm done with it yet.
I wondering whether it would be better to have a single control file per directory and some kind of sub-protocol going through it. It would possibly be a less chatty alternative. But somehow not very appealing.
I'm open to suggestions.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M9edffaa3ab33367c91c650f8
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 56922 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  2:09 [9fans] 9P and Linux experiment Alyssa M via 9fans
@ 2025-02-14  2:54 ` Nicola Girardi via 9fans
  2025-02-14  4:45   ` David Leimbach via 9fans
  2025-02-14  7:58 ` Edouard Klein
  1 sibling, 1 reply; 9+ messages in thread
From: Nicola Girardi via 9fans @ 2025-02-14  2:54 UTC (permalink / raw)
  To: 9fans

Quoth Alyssa M via 9fans <9fans@9fans.net>:
> I wondering whether it would be better to have a single control
> file per directory and some kind of sub-protocol going through it.

It's nice to see I'm not the only one doing something of the kind. I
went with something that seems simpler to me, but it's subjective. I
use a single control file at the root (/ctl) and a helper rc script
(m) to implement non-9P commands that I use both in Linux and Plan
9. (I don't use .L but I think the approach would still work.) For
example, I say

        % pwd
        /mnt/weirdfs/src
        % m mv foo bar/baz/

This will detect if I'm within the mounted weird fs and output other
commands that I can pipe to rc, e.g.,

        % echo rename src/foo src/bar/baz/foo >/weird/fs/ctl

which when does the rename just using links and not copying and
removing data (as would be the case with dircp and rm).

(Obviously if you use mv on Linux it would still achieve the same
result but copying and removing all the data.) These “advanced”
commands I use very little often so I don't mind not implementing .L
in my case.

Possibly a better way would be to use another side channel to talk
to the fs instead of the control file, like when you use con(1) with
/srv/cwfs.cmd but I haven't had reason to invest time in this since
the ctl works.


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M582a426fecaa24801244706e
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  2:54 ` Nicola Girardi via 9fans
@ 2025-02-14  4:45   ` David Leimbach via 9fans
  0 siblings, 0 replies; 9+ messages in thread
From: David Leimbach via 9fans @ 2025-02-14  4:45 UTC (permalink / raw)
  To: 9fans; +Cc: 9fans

Forgive the top post and short replay but …. Applause!

That’s a very creative and somewhat intuitive way to build a bridge!

Nicely done! (But you already knew that!)
Sent from my iPhone

> On Feb 13, 2025, at 8:21 PM, Nicola Girardi via 9fans <9fans@9fans.net> wrote:
> 
> Quoth Alyssa M via 9fans <9fans@9fans.net>:
>> I wondering whether it would be better to have a single control
>> file per directory and some kind of sub-protocol going through it.
> 
> It's nice to see I'm not the only one doing something of the kind. I
> went with something that seems simpler to me, but it's subjective. I
> use a single control file at the root (/ctl) and a helper rc script
> (m) to implement non-9P commands that I use both in Linux and Plan
> 9. (I don't use .L but I think the approach would still work.) For
> example, I say
> 
>        % pwd
>        /mnt/weirdfs/src
>        % m mv foo bar/baz/
> 
> This will detect if I'm within the mounted weird fs and output other
> commands that I can pipe to rc, e.g.,
> 
>        % echo rename src/foo src/bar/baz/foo >/weird/fs/ctl
> 
> which when does the rename just using links and not copying and
> removing data (as would be the case with dircp and rm).
> 
> (Obviously if you use mv on Linux it would still achieve the same
> result but copying and removing all the data.) These “advanced”
> commands I use very little often so I don't mind not implementing .L
> in my case.
> 
> Possibly a better way would be to use another side channel to talk
> to the fs instead of the control file, like when you use con(1) with
> /srv/cwfs.cmd but I haven't had reason to invest time in this since
> the ctl works.
> 

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M684d26f2ab53947877c3244a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  2:09 [9fans] 9P and Linux experiment Alyssa M via 9fans
  2025-02-14  2:54 ` Nicola Girardi via 9fans
@ 2025-02-14  7:58 ` Edouard Klein
  2025-02-14 14:41   ` Alyssa M via 9fans
                     ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Edouard Klein @ 2025-02-14  7:58 UTC (permalink / raw)
  To: 9fans

This is cool :)

Can you pass xattrs through the ,ctl file ?


If you can find the time to write it up in thee pages, that would be a
nice WiP for iwp9 ! The deadline has just been extended !

Cheers,

Edouard.

"Alyssa M via 9fans" <9fans@9fans.net> writes:

> I have a complicated relationship with 9P2000.L. On the one hand it's been a useful way to build file systems for Linux, and I've gotten some mileage out of that. On the
> other hand, I'm not crazy about having a different protocol to 9P (I've read through a lot of what's been said on 9fans about this, going back many years).
>
> I've been trying an experiment over the last few weeks to see if I can pass the extra Linux file system features over 9P (9P2000) as an application of 9P rather than using a
> separate protocol. I want to be able to connect two Linux machines using 9P, but have the full Linux file system semantics available across the connection: symbolic links,
> moving files and directories around, nanosecond time stamps, open modes, record locking, the whole bit. I also want that to work properly with a Plan 9 machine between
> them.
> Linux programs should see a Linux file system, Plan 9 programs should see a Plan 9 file system.
>
> I think it's easiest to explain by walking through an end-to-end example.
>
> First, I altered my Linux 9P (9P2000) file server to offer an encoding of the linuxiness (is that a word??) For example, here's a test directory on my Linux machine.
>
> lyssa@pibysix:~/t $ ls -l
> total 28
> -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three
> lyssa@pibysix:~/t $
>
> If I mount it on Plan 9 with my 9P server, it looks like this:
>
> term% pwd
> /usr/glenda/mnt/home/lyssa/t
> term% ls -lp
> --rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
> d-rwxr-xr-x M 1061 glenda glenda  0 Feb  6 23:51 bin
> --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
> --rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
> --rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
> d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
> --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello
> --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello6
> --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
> --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi2
> ----------- M 1061 '(0)'  glenda  0 Jan  1  1970 somenewlinkname
> term%
>
> These files all behave as you might expect from a vanilla 9P server.
> (the symbolic links are followed - the bottom one is a broken link. A long and involved conversation could be had about this, but can we not do that right now?)
>
> I've added an invisible virtual extension to the namespace my Linux 9P server offers:
> For any given file "/a/b/c/foo", there is a control file, "/a/b/c/,ctl/foo" which gives access to all its linuxy gloriousness:
>
> term% cat ,ctl/foo
> dev 45831
> inode 265868
> mode 0100644
> nlink 1
> uid 1001
> gid 1001
> rdev 0
> size 6
> blksize 4096
> blocks 8
> atime 1739199962
> mtime 1739199962
> ctime 1739466812
> atimensec 460383798
> mtimensec 470383712
> ctimensec 926076796
> name foo
> term%
>
> You can also write commands into these files to change some of the properties - as you might expect.
> Here are the control files in the (unlisted) virtual directory ",ctl":
>
> term% ls -lp ,ctl
> --rw-r--r-- M 1061 glenda glenda 0 Feb  8 11:41 bar
> --rw-r--r-- M 1061 glenda glenda 0 Feb  6 23:51 bin
> --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 foo
> --rw-r--r-- M 1061 glenda glenda 0 Feb  9 15:31 foop
> --rw-r--r-- M 1061 glenda glenda 0 Feb  9 18:33 foop2
> --rw-r--r-- M 1061 glenda glenda 0 Feb  7 00:54 foot
> --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello
> --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello6
> --rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi
> --rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi2
> --rw-r--r-- M 1061 '(0)'  glenda 0 Jan  1  1970 somenewlinkname
> term%
>
> ",ctl" is a simple example of a means to pass parameters down a Twalk to later requests by using weird file names.
> You can pass other parameters...
>
> term% ls -lp ,nofollow
> --rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
> a-r--r--r-- M 1061 glenda glenda  6 Feb  7 22:17 bin
> --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
> --rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
> --rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
> d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
> a-r--r--r-- M 1061 glenda glenda  3 Feb  7 01:06 hello
> a-r--r--r-- M 1061 glenda glenda  5 Feb 11 02:08 hello6
> --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
> a-r--r--r-- M 1061 glenda glenda  2 Feb  9 01:28 hi2
> a---------- M 1061 glenda glenda 13 Feb 11 03:20 somenewlinkname
> term%
>
> This provides a way to avoid following the symbolic links.
> Symlinks show up as append-only, read-only files, which is a bit of a hack, I suppose, but perhaps okay for now.
> When you don't follow symlinks, they present their link target.
>
> term% cat ,nofollow/bin; echo
> ../bin
> term%
>
> And you can access the control file of a link:
>
> term% cat ,ctl,nofollow/bin
> dev 45831
> inode 263367
> mode 0120777
> nlink 1
> uid 1001
> gid 1001
> rdev 0
> size 6
> blksize 4096
> blocks 0
> atime 1738966670
> mtime 1738966670
> ctime 1738966670
> atimensec 484184178
> mtimensec 484184178
> ctimensec 484184178
> name bin
> symlink ..%2Fbin
> term%
>
> You can make new symbolic links from plan 9.
> (where's that Linux ls(1) program?)
>
> term% ls -l ../../../bin/ls
> --rwxr-xr-x M 1061 '(0)' glenda 108752 Feb 28  2019 ../../../bin/ls
> term%
>
> Let's link to it:
>
> term% echo symlink ../../../bin/ls another >,ctl/,
> term% ls -lp
> --rwxr-xr-x M 1061 '(0)'  glenda 108752 Feb 28  2019 another
> --rw-r--r-- M 1061 glenda glenda      6 Feb  8 11:41 bar
> d-rwxr-xr-x M 1061 glenda glenda      0 Feb  6 23:51 bin
> --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 foo
> --rw-r--r-- M 1061 glenda glenda      1 Feb  9 15:31 foop
> --rw-r--r-- M 1061 glenda glenda      1 Feb  9 18:33 foop2
> d-rwxr-xr-x M 1061 glenda glenda      0 Feb  7 00:54 foot
> --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello
> --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello6
> --rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi
> --rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi2
> ----------- M 1061 '(0)'  glenda      0 Jan  1  1970 somenewlinkname
> term%
>
> ",ctl/," is a name for the control file for the directory itself.
> Commands written there can be used to make symlinks, move files, etc.
> It has an alias in the parent directory's ,ctl directory.
>
> So that's the general idea. Linux extras are hidden from Plan 9, but accessible.
>
> Second, I built an client adapter for Linux that uses these extra mechanisms. It serves 9P2000.L, which it mounts locally using v9fs - the Linux 9P client, but speaks
> "9P-with-benefits" across the network as a client. I have it in mind to do a version for FUSE one day, instead of using v9fs.
>
> Exportfs on my plan 9 machine is serving the namespace above that included a mount of my Linux 9P server, above.
> I've mounted that on Linux in /mnt/mnt. So now Linux is looking at Plan 9, which is looking at Linux:
>
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -l
> total 24
> lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
> -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three
>
> All that linuxy goodness is passed through Plan 9 as shown above. Linux does not expect file systems to follow
> symbolic links themselves, so the adapter uses ",nofollow". Here's the same directory with the links resolved by Linux:
>
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -lL
> total 24
> -rwxr-xr-x 1 root  root  108752 Feb 28  2019 another
> -rw-r--r-- 1 lyssa lyssa      6 Feb  8 11:41 bar
> drwxr-xr-x 2 lyssa lyssa   4096 Feb  6 23:51 bin
> -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 foo
> -rw-r--r-- 1 lyssa lyssa      1 Feb  9 15:31 foop
> -rw-r--r-- 1 lyssa lyssa      1 Feb  9 18:33 foop2
> drwxr-xr-x 2 lyssa lyssa   4096 Feb  7 00:54 foot
> -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello
> -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello6
> -rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi
> -rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi2
> ?????????? ? ?     ?          ?            ? somenewlinkname
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $
>
> Lets make a link on Linux, by passing the request through plan 9 and back to Linux:
>
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ln -s ../../../bin/ls another2
>
> * The "ln" command makes a symlinkat(2) system call into the Linux kernel.
> * The v9fs driver in the kernel fields the call and issues a Tsymlink 9P2000.L message to my mounted adapter through a pipe.
> * My adapter receives that and translates it into a 9P Twalk to the control file for the containing directory, Topens the file and issues a 9P Twrite with the "symlink"
> command in it, which goes over the network to Plan 9
> * exportfs running on Plan 9 receives the Twalk, Topen and Twrite, and makes open(2) and pwrite(2) calls to the Plan 9 kernel.
> * devmnt in the Plan 9 kernel - I think... - issues the same Twalk, Topen and Twrite requests over the network to my Linux 9P server.
> * My 9P server receives the Twrite command and issues a symlinkat(2) system call.
> * The Linux server kernel makes the symbolic link.
>
> (there were some clunks and closes as well).
>
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -l
> total 24
> lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
> lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:03 another2 -> ../../../bin/ls
> -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname -> one/two/three
> lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $
>
> So now Linux can mount file systems over 9P, and still see all the nanosecond timestamps and other stuff:
>
> lyssa@pibysix:~/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ stat foo
>   File: foo
>   Size: 6               Blocks: 8          IO Block: 4096   regular file
> Device: 36h/54d Inode: 265870      Links: 1
> Access: (0644/-rw-r--r--)  Uid: ( 1001/   lyssa)   Gid: ( 1001/   lyssa)
> Access: 2025-02-10 15:06:02.460383798 +0000
> Modify: 2025-02-10 15:06:02.470383712 +0000
> Change: 2025-02-10 18:32:05.271025091 +0000
> Birth: -
> lyssa@pibysix:~
>
> (I suppose nanosecond resolution timestamps must be important to some people...)
> My adapter is operating in a heterogeneous file system in this example, where part of it has this extended behaviour, and part of it does not. There's no mode switch or
> barriers - it just looks for the virtual files, and if they're not there it does the standard thing. If I'd bound some other part of the Plan 9 space over part of the the mounted
> Linux space before I exported it, the adapter would just fall back to vanilla behaviour when file accesses are in that subtree.
> It's a work in progress.
> Linux is not actually my platform of choice, and symbolic links are not exactly my spirit animal, but it's a familiar context for exploring the ideas.
>
> I don't know what people think?
> This is about my third iteration of this idea. I'm not sure I'm done with it yet.
> I wondering whether it would be better to have a single control file per directory and some kind of sub-protocol going through it. It would possibly be a less chatty
> alternative. But somehow not very appealing.
> I'm open to suggestions.
> 9fans / 9fans / see discussions + participants + delivery options Permalink

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-Mf1907334a2888ce3b233343c
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  7:58 ` Edouard Klein
@ 2025-02-14 14:41   ` Alyssa M via 9fans
  2025-02-14 16:12     ` ron minnich
  2025-02-14 15:48   ` ron minnich
  2025-02-14 17:45   ` Alyssa M via 9fans
  2 siblings, 1 reply; 9+ messages in thread
From: Alyssa M via 9fans @ 2025-02-14 14:41 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]

I've planned to pass xattrs through the ,ctl files, but haven't written the code yet - I've only recently installed the xattr package on RPi debian and read the man pages. It looks reasonably straightforward. It's been bottom of the list, as I don't see a lot of things using them.

I've written the code for the POSIX record locking, but haven't tested that yet either, and I'd like to do something about Linux open file description locks, as they're better designed. I can probably write the server part of that (I'm not sure how yet), but I don't think I can use them through v9fs/9P2000.L? So that might have to wait for a FUSE version.

I can write something up, but I'm not sure if I can attend iwp9, which would be a shame, because I'm in the UK, and Paris is quite close... perhaps I can submit a WiP anyway? Do people do that?


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M272f5d7c97e3c04aa526975d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 1729 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  7:58 ` Edouard Klein
  2025-02-14 14:41   ` Alyssa M via 9fans
@ 2025-02-14 15:48   ` ron minnich
  2025-02-14 17:45   ` Alyssa M via 9fans
  2 siblings, 0 replies; 9+ messages in thread
From: ron minnich @ 2025-02-14 15:48 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 16299 bytes --]

This is very interesting, but I think the two problems you will hit are (1)
the proliferation of these "," names everywhere and what they mean (do you
include them in readdir? If you do, that's going to at least triple
its length; if you do not, readdir is not showing directory contents, since
each file comes with "benefits"), and (2) you will eventually run into a
large installed system that already uses those names -- that kind of thing
happens; it will get messy.

For that reason I kind of fear the way you are overloading path names.

One very good thing about the 9p stat is that it is not intended to be
processed by the kernel. In most cases it gets passed up to userspace.

I kind of wonder about putting this stuff in stat and wstat. In my Linux 9p
from 1998, I extended stat such that, for symlinks, the string for the
symlink and the target were returned (at that point, on 100mbit ethernet,
that was far cheaper than a stat / readlink combo) and I set a bit in the
mode to indicate it was a symlink. The kernel was none the wiser, and user
mode had both names at its disposal, with the option of using or ignoring
the second.

Same for wstat.

As for timestamps and other things, you could pull an x86_64-like hack: if
there is an "extended 9p" bit in the header somewhere, then you can look
further in the stat packet, beyond the length of a standard packet, for the
nanosecond data, to match the second data in the standard stat. That way,
code that only uses the standard stat works, but code looking for more can
find it.

So, I think your ",name" ideas are interesting, but I personally prefer to
extend stat/wstat, because I've found plan9 overall is pretty flexible to
that kind of thing.

Thanks, hope to see your paper at iwp9.

ron


On Fri, Feb 14, 2025 at 5:20 AM Edouard Klein <edou@rdklein.fr> wrote:

> This is cool :)
>
> Can you pass xattrs through the ,ctl file ?
>
>
> If you can find the time to write it up in thee pages, that would be a
> nice WiP for iwp9 ! The deadline has just been extended !
>
> Cheers,
>
> Edouard.
>
> "Alyssa M via 9fans" <9fans@9fans.net> writes:
>
> > I have a complicated relationship with 9P2000.L. On the one hand it's
> been a useful way to build file systems for Linux, and I've gotten some
> mileage out of that. On the
> > other hand, I'm not crazy about having a different protocol to 9P (I've
> read through a lot of what's been said on 9fans about this, going back many
> years).
> >
> > I've been trying an experiment over the last few weeks to see if I can
> pass the extra Linux file system features over 9P (9P2000) as an
> application of 9P rather than using a
> > separate protocol. I want to be able to connect two Linux machines using
> 9P, but have the full Linux file system semantics available across the
> connection: symbolic links,
> > moving files and directories around, nanosecond time stamps, open modes,
> record locking, the whole bit. I also want that to work properly with a
> Plan 9 machine between
> > them.
> > Linux programs should see a Linux file system, Plan 9 programs should
> see a Plan 9 file system.
> >
> > I think it's easiest to explain by walking through an end-to-end example.
> >
> > First, I altered my Linux 9P (9P2000) file server to offer an encoding
> of the linuxiness (is that a word??) For example, here's a test directory
> on my Linux machine.
> >
> > lyssa@pibysix:~/t $ ls -l
> > total 28
> > -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> > lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> > -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> > drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> > lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> > lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> > -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> > lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> > lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname ->
> one/two/three
> > lyssa@pibysix:~/t $
> >
> > If I mount it on Plan 9 with my 9P server, it looks like this:
> >
> > term% pwd
> > /usr/glenda/mnt/home/lyssa/t
> > term% ls -lp
> > --rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
> > d-rwxr-xr-x M 1061 glenda glenda  0 Feb  6 23:51 bin
> > --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
> > --rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
> > --rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
> > d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
> > --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello
> > --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 hello6
> > --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
> > --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi2
> > ----------- M 1061 '(0)'  glenda  0 Jan  1  1970 somenewlinkname
> > term%
> >
> > These files all behave as you might expect from a vanilla 9P server.
> > (the symbolic links are followed - the bottom one is a broken link. A
> long and involved conversation could be had about this, but can we not do
> that right now?)
> >
> > I've added an invisible virtual extension to the namespace my Linux 9P
> server offers:
> > For any given file "/a/b/c/foo", there is a control file,
> "/a/b/c/,ctl/foo" which gives access to all its linuxy gloriousness:
> >
> > term% cat ,ctl/foo
> > dev 45831
> > inode 265868
> > mode 0100644
> > nlink 1
> > uid 1001
> > gid 1001
> > rdev 0
> > size 6
> > blksize 4096
> > blocks 8
> > atime 1739199962
> > mtime 1739199962
> > ctime 1739466812
> > atimensec 460383798
> > mtimensec 470383712
> > ctimensec 926076796
> > name foo
> > term%
> >
> > You can also write commands into these files to change some of the
> properties - as you might expect.
> > Here are the control files in the (unlisted) virtual directory ",ctl":
> >
> > term% ls -lp ,ctl
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  8 11:41 bar
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  6 23:51 bin
> > --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 foo
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  9 15:31 foop
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  9 18:33 foop2
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  7 00:54 foot
> > --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello
> > --rw-r--r-- M 1061 glenda glenda 0 Feb 10 15:06 hello6
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi
> > --rw-r--r-- M 1061 glenda glenda 0 Feb  8 00:58 hi2
> > --rw-r--r-- M 1061 '(0)'  glenda 0 Jan  1  1970 somenewlinkname
> > term%
> >
> > ",ctl" is a simple example of a means to pass parameters down a Twalk to
> later requests by using weird file names.
> > You can pass other parameters...
> >
> > term% ls -lp ,nofollow
> > --rw-r--r-- M 1061 glenda glenda  6 Feb  8 11:41 bar
> > a-r--r--r-- M 1061 glenda glenda  6 Feb  7 22:17 bin
> > --rw-r--r-- M 1061 glenda glenda  6 Feb 10 15:06 foo
> > --rw-r--r-- M 1061 glenda glenda  1 Feb  9 15:31 foop
> > --rw-r--r-- M 1061 glenda glenda  1 Feb  9 18:33 foop2
> > d-rwxr-xr-x M 1061 glenda glenda  0 Feb  7 00:54 foot
> > a-r--r--r-- M 1061 glenda glenda  3 Feb  7 01:06 hello
> > a-r--r--r-- M 1061 glenda glenda  5 Feb 11 02:08 hello6
> > --rw-r--r-- M 1061 glenda glenda 38 Feb  8 00:58 hi
> > a-r--r--r-- M 1061 glenda glenda  2 Feb  9 01:28 hi2
> > a---------- M 1061 glenda glenda 13 Feb 11 03:20 somenewlinkname
> > term%
> >
> > This provides a way to avoid following the symbolic links.
> > Symlinks show up as append-only, read-only files, which is a bit of a
> hack, I suppose, but perhaps okay for now.
> > When you don't follow symlinks, they present their link target.
> >
> > term% cat ,nofollow/bin; echo
> > ../bin
> > term%
> >
> > And you can access the control file of a link:
> >
> > term% cat ,ctl,nofollow/bin
> > dev 45831
> > inode 263367
> > mode 0120777
> > nlink 1
> > uid 1001
> > gid 1001
> > rdev 0
> > size 6
> > blksize 4096
> > blocks 0
> > atime 1738966670
> > mtime 1738966670
> > ctime 1738966670
> > atimensec 484184178
> > mtimensec 484184178
> > ctimensec 484184178
> > name bin
> > symlink ..%2Fbin
> > term%
> >
> > You can make new symbolic links from plan 9.
> > (where's that Linux ls(1) program?)
> >
> > term% ls -l ../../../bin/ls
> > --rwxr-xr-x M 1061 '(0)' glenda 108752 Feb 28  2019 ../../../bin/ls
> > term%
> >
> > Let's link to it:
> >
> > term% echo symlink ../../../bin/ls another >,ctl/,
> > term% ls -lp
> > --rwxr-xr-x M 1061 '(0)'  glenda 108752 Feb 28  2019 another
> > --rw-r--r-- M 1061 glenda glenda      6 Feb  8 11:41 bar
> > d-rwxr-xr-x M 1061 glenda glenda      0 Feb  6 23:51 bin
> > --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 foo
> > --rw-r--r-- M 1061 glenda glenda      1 Feb  9 15:31 foop
> > --rw-r--r-- M 1061 glenda glenda      1 Feb  9 18:33 foop2
> > d-rwxr-xr-x M 1061 glenda glenda      0 Feb  7 00:54 foot
> > --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello
> > --rw-r--r-- M 1061 glenda glenda      6 Feb 10 15:06 hello6
> > --rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi
> > --rw-r--r-- M 1061 glenda glenda     38 Feb  8 00:58 hi2
> > ----------- M 1061 '(0)'  glenda      0 Jan  1  1970 somenewlinkname
> > term%
> >
> > ",ctl/," is a name for the control file for the directory itself.
> > Commands written there can be used to make symlinks, move files, etc.
> > It has an alias in the parent directory's ,ctl directory.
> >
> > So that's the general idea. Linux extras are hidden from Plan 9, but
> accessible.
> >
> > Second, I built an client adapter for Linux that uses these extra
> mechanisms. It serves 9P2000.L, which it mounts locally using v9fs - the
> Linux 9P client, but speaks
> > "9P-with-benefits" across the network as a client. I have it in mind to
> do a version for FUSE one day, instead of using v9fs.
> >
> > Exportfs on my plan 9 machine is serving the namespace above that
> included a mount of my Linux 9P server, above.
> > I've mounted that on Linux in /mnt/mnt. So now Linux is looking at Plan
> 9, which is looking at Linux:
> >
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -l
> > total 24
> > lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
> > -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> > lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> > -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> > drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> > lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> > lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> > -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> > lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> > lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname ->
> one/two/three
> >
> > All that linuxy goodness is passed through Plan 9 as shown above. Linux
> does not expect file systems to follow
> > symbolic links themselves, so the adapter uses ",nofollow". Here's the
> same directory with the links resolved by Linux:
> >
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -lL
> > total 24
> > -rwxr-xr-x 1 root  root  108752 Feb 28  2019 another
> > -rw-r--r-- 1 lyssa lyssa      6 Feb  8 11:41 bar
> > drwxr-xr-x 2 lyssa lyssa   4096 Feb  6 23:51 bin
> > -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 foo
> > -rw-r--r-- 1 lyssa lyssa      1 Feb  9 15:31 foop
> > -rw-r--r-- 1 lyssa lyssa      1 Feb  9 18:33 foop2
> > drwxr-xr-x 2 lyssa lyssa   4096 Feb  7 00:54 foot
> > -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello
> > -rw-r--r-- 1 lyssa lyssa      6 Feb 10 15:06 hello6
> > -rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi
> > -rw-r--r-- 1 lyssa lyssa     38 Feb  8 00:58 hi2
> > ?????????? ? ?     ?          ?            ? somenewlinkname
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $
> >
> > Lets make a link on Linux, by passing the request through plan 9 and
> back to Linux:
> >
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ln -s
> ../../../bin/ls another2
> >
> > * The "ln" command makes a symlinkat(2) system call into the Linux
> kernel.
> > * The v9fs driver in the kernel fields the call and issues a Tsymlink
> 9P2000.L message to my mounted adapter through a pipe.
> > * My adapter receives that and translates it into a 9P Twalk to the
> control file for the containing directory, Topens the file and issues a 9P
> Twrite with the "symlink"
> > command in it, which goes over the network to Plan 9
> > * exportfs running on Plan 9 receives the Twalk, Topen and Twrite, and
> makes open(2) and pwrite(2) calls to the Plan 9 kernel.
> > * devmnt in the Plan 9 kernel - I think... - issues the same Twalk,
> Topen and Twrite requests over the network to my Linux 9P server.
> > * My 9P server receives the Twrite command and issues a symlinkat(2)
> system call.
> > * The Linux server kernel makes the symbolic link.
> >
> > (there were some clunks and closes as well).
> >
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ ls -l
> > total 24
> > lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:00 another -> ../../../bin/ls
> > lrwxrwxrwx 1 lyssa lyssa   15 Feb 13 18:03 another2 -> ../../../bin/ls
> > -rw-r--r-- 1 lyssa lyssa    6 Feb  8 11:41 bar
> > lrwxrwxrwx 1 lyssa lyssa    6 Feb  7 22:17 bin -> ../bin
> > -rw-r--r-- 1 lyssa lyssa    6 Feb 10 15:06 foo
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 15:31 foop
> > -rw-r--r-- 1 lyssa lyssa    1 Feb  9 18:33 foop2
> > drwxr-xr-x 2 lyssa lyssa 4096 Feb  7 00:54 foot
> > lrwxrwxrwx 1 lyssa lyssa    3 Feb  7 01:06 hello -> foo
> > lrwxrwxrwx 1 lyssa lyssa    5 Feb 11 02:08 hello6 -> hello
> > -rw-r--r-- 1 lyssa lyssa   38 Feb  8 00:58 hi
> > lrwxrwxrwx 1 lyssa lyssa    2 Feb  9 01:28 hi2 -> hi
> > lrwxrwxrwx 1 lyssa lyssa   13 Feb 11 03:20 somenewlinkname ->
> one/two/three
> > lyssa@pibysix:/mnt/mnt/usr/glenda/mnt/home/lyssa/t $
> >
> > So now Linux can mount file systems over 9P, and still see all the
> nanosecond timestamps and other stuff:
> >
> > lyssa@pibysix:~/mnt/mnt/usr/glenda/mnt/home/lyssa/t $ stat foo
> >   File: foo
> >   Size: 6               Blocks: 8          IO Block: 4096   regular file
> > Device: 36h/54d Inode: 265870      Links: 1
> > Access: (0644/-rw-r--r--)  Uid: ( 1001/   lyssa)   Gid: ( 1001/   lyssa)
> > Access: 2025-02-10 15:06:02.460383798 +0000
> > Modify: 2025-02-10 15:06:02.470383712 +0000
> > Change: 2025-02-10 18:32:05.271025091 +0000
> > Birth: -
> > lyssa@pibysix:~
> >
> > (I suppose nanosecond resolution timestamps must be important to some
> people...)
> > My adapter is operating in a heterogeneous file system in this example,
> where part of it has this extended behaviour, and part of it does not.
> There's no mode switch or
> > barriers - it just looks for the virtual files, and if they're not there
> it does the standard thing. If I'd bound some other part of the Plan 9
> space over part of the the mounted
> > Linux space before I exported it, the adapter would just fall back to
> vanilla behaviour when file accesses are in that subtree.
> > It's a work in progress.
> > Linux is not actually my platform of choice, and symbolic links are not
> exactly my spirit animal, but it's a familiar context for exploring the
> ideas.
> >
> > I don't know what people think?
> > This is about my third iteration of this idea. I'm not sure I'm done
> with it yet.
> > I wondering whether it would be better to have a single control file per
> directory and some kind of sub-protocol going through it. It would possibly
> be a less chatty
> > alternative. But somehow not very appealing.
> > I'm open to suggestions.
> > 9fans / 9fans / see discussions + participants + delivery options
> Permalink

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M7c26a395364c129143739c65
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 21257 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14 14:41   ` Alyssa M via 9fans
@ 2025-02-14 16:12     ` ron minnich
  0 siblings, 0 replies; 9+ messages in thread
From: ron minnich @ 2025-02-14 16:12 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2091 bytes --]

I was remembering why your file name approach made me nervous. in Windows
NT, you could open files that you did not see via readdir. This is kind of
crazy making, after a while.

So in your server, you're either going to see all those files on a readdir,
which will confuse users and scripts; or, if you don't return them as part
of a readdir, there are invisible files, which can be hard.

I tend to favor finding a way to cleanly extend 9p stat and wstat messages,
in a reverse compatible way. Just my preference.

ron

On Fri, Feb 14, 2025 at 8:04 AM Alyssa M via 9fans <9fans@9fans.net> wrote:

> I've planned to pass xattrs through the ,ctl files, but haven't written
> the code yet - I've only recently installed the xattr package on RPi debian
> and read the man pages. It looks reasonably straightforward. It's been
> bottom of the list, as I don't see a lot of things using them.
>
> I've written the code for the POSIX record locking, but haven't tested
> that yet either, and I'd like to do something about Linux open file
> description locks, as they're better designed. I can probably write the
> server part of that (I'm not sure how yet), but I don't think I can use
> them through v9fs/9P2000.L? So that might have to wait for a FUSE version.
>
> I can write something up, but I'm not sure if I can attend iwp9, which
> would be a shame, because I'm in the UK, and Paris is quite close...
> perhaps I can submit a WiP anyway? Do people do that?
>
>
> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions
> <https://9fans.topicbox.com/groups/9fans> + participants
> <https://9fans.topicbox.com/groups/9fans/members> + delivery options
> <https://9fans.topicbox.com/groups/9fans/subscription> Permalink
> <https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M272f5d7c97e3c04aa526975d>
>

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-Mb9ff45e48ab553c52a7a117f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 2754 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14  7:58 ` Edouard Klein
  2025-02-14 14:41   ` Alyssa M via 9fans
  2025-02-14 15:48   ` ron minnich
@ 2025-02-14 17:45   ` Alyssa M via 9fans
  2025-02-20 16:22     ` Alyssa M via 9fans
  2 siblings, 1 reply; 9+ messages in thread
From: Alyssa M via 9fans @ 2025-02-14 17:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 4244 bytes --]

On Friday, February 14, 2025, at 3:48 PM, ron minnich wrote:
> This is very interesting, but I think the two problems you will hit are (1) the proliferation of these "," names everywhere and what they mean (do you include them in readdir? If you do, that's going to at least triple its length; if you do not, readdir is not showing directory contents, since each file comes with "benefits")
The ,ctl names are never listed in the directory contents. You have to know they are there. Effectively they introduce parameters and operations into the namespace, but not content. Not listing them means that they don't clutter things up, and will not get accidentally copied. (It's not used often, but it's always been possible generally to access files you can't actually see in a directory.)

On Friday, February 14, 2025, at 3:48 PM, ron minnich wrote:
> and (2) you will eventually run into a large installed system that already uses those names -- that kind of thing happens; it will get messy.
> 
> For that reason I kind of fear the way you are overloading path names.

It's an important issue.
I didn't talk about it above, but the adapter and server encode and decode some characters using %-encoding. I had some examples I removed to keep the post to a reasonable length, but I missed one. :)

On Friday, February 14, 2025, at 2:09 AM, Alyssa M wrote:
> mtimensec 484184178
> ctimensec 484184178
> name bin
> symlink ..%2Fbin
> term%
> 

The symlink at the end of the ,ctl file includes a link which is %-encoded to protect the '/' (unnecessarily here actually - that's a bug).
The Linux filename:
a,b
shows up on 9P as
a%2Cb
and the server translates it back again. It also translates 0x01-0x1F, 0x7F and sometimes %2F, depending on the context, but no others. The mapping is 1:1 so each character has exactly one representation whether encoded or not. So you can use any valid filename on Linux  - they just sometimes look different on Plan 9. 
This means that a Linux filename with an accidental newline on the end (which someone mentioned recently here)  e.g.
'foo
'
will show up as 
'foo%0A'
on plan 9.
So the Linux namespace is completely unaffected. This only shows up on the wire, or on Plan 9.
If someone types 
$ echo 'dsjfkhdshfsd' >,ctl
on Linux it will pass through the adapter and server and create a file called ,ctl on Linux, as you might expect.
(actually I just tried this and, embarrassingly, I have a bug! This is a WiP after all. It's supposed to work).

It would be possible to build a Plan 9 version of the adapter that hides the ctl file syntax, though of course that would also hide the Linux features.
This could be used by Plan 9 software that would be disturbed by the encoding.

My intent for this is to not extend the 9P protocol at all - and not make any assumptions about how it might be used in the future - so not borrowing mode bits, for example. I think this is best thought of as a conventional use *of* 9P rather than an extension of it.

On Friday, February 14, 2025, at 3:48 PM, ron minnich wrote:
> One very good thing about the 9p stat is that it is not intended to be processed by the kernel. In most cases it gets passed up to userspace. 
The second version of my experiment packed all the extra Linux metadata into the name field in the Tstat and Twstat, and I had a working implementation between my adapter and server. Unfortunately I found when I tried putting Plan 9 between them that the kernel stomps on the name field! sysstat calls dirsetname. I think this was probably done so that after a bind() you see the new name rather than the old name, and I altered exportfs on my system to use dirfstat, which wasn't doing that, as a work-around. This was on Miller Plan 9. When I found that 9front has fixed fstat the same way I abandoned the second version.
I looked into putting the info in the group id field of the Tstat request, but dirstat only allows 64 bytes for the various strings, which is not enough.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M9ab622f573a9c3514f3597a6
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 6482 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] 9P and Linux experiment
  2025-02-14 17:45   ` Alyssa M via 9fans
@ 2025-02-20 16:22     ` Alyssa M via 9fans
  0 siblings, 0 replies; 9+ messages in thread
From: Alyssa M via 9fans @ 2025-02-20 16:22 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]

I implemented extended attributes in my Linux 9P server:
term% echo Xuser.wow abcd >,ctl/foo
term% cat ,ctl/foo
dev 45831
inode 265868
umode 0100644
nlink 1
uid 1001
gid 1001
rdev 0
size 6
blksize 4096
blocks 16
atime 1739199962
mtime 1739199962
ctime 1740003632
atimensec 460383798
mtimensec 470383712
ctimensec 621853327
name foo
Xuser.wow abcd
term%
Apparently on Linux your attribute names have to start with "user."
I think this is the first time I've ever created an extended attribute on Linux.
And I did it from Plan 9 over 9P!

Xuser.wow abcd
makes an attribute with a UTF-8 value
Yuser.wow2 12 3a 08 b5
(hex-encoding) makes an attribute with a binary value
Xuser.wow
deletes the attribute
Yuser.wow2
makes an empty (0-length) attribute

My server presents attributes as UTF-8 if the value is valid UTF-8 with no frogs,
and presents as hex-encoded binary if not.

And from Linux via my adapter:
lyssa@pibysix:~/mnt/mnt/home/lyssa/t $ xattr -l foo
user.wow: abcd
lyssa@pibysix:~/mnt/mnt/home/lyssa/t $

All I have to do now is find a use for them. ;)

The Linux xattr program that comes with the extended attributes package seems strangely slow.
There's a half-second pause before it does what should be a trivial operation.
When I did an strace to find out what system call it makes to delete an attribute, I found out why:
7275 system calls.
2384 of them contain the string "python".
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T0f2c2342a05a3d6e-M7168e49cb8a5cb39723b399b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 3609 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-20 16:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14  2:09 [9fans] 9P and Linux experiment Alyssa M via 9fans
2025-02-14  2:54 ` Nicola Girardi via 9fans
2025-02-14  4:45   ` David Leimbach via 9fans
2025-02-14  7:58 ` Edouard Klein
2025-02-14 14:41   ` Alyssa M via 9fans
2025-02-14 16:12     ` ron minnich
2025-02-14 15:48   ` ron minnich
2025-02-14 17:45   ` Alyssa M via 9fans
2025-02-20 16:22     ` Alyssa M via 9fans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).