hugelgupf / p9

Idiomatic Go 9P2000.L client and server, extracted from gVisor for general use
Apache License 2.0
87 stars 19 forks source link

p9: handlers: support extended attributes #67

Closed Lencerf closed 1 year ago

Lencerf commented 1 year ago

This commit adds 2 methods to the File interface:

These 2 methods can be used to implement the handlers for txattrwalk and txattrcreate.

This PR is an alternative implementation for https://github.com/hugelgupf/p9/pull/66 since I feel that #66 may not be idiomatic. An actual implementation of the 2 methods above is in https://github.com/Lencerf/cpu/commit/1849ded7d7d14a5dae1963da5e6ba834daf53983 . Suggestions are much appreciated!

cc @rminnich @brho

brho commented 1 year ago

my initial thought is that xattrs are like stat, and maybe this should be done with extensions to Stat and Wstat (write-stat). so you walk to a file like normal, then stat it (with some new extension) to getxattrs and wstat it to setxattr.

IIRC there are all sorts of 9p extensions out there. i pinged ron who knows a lot more about it. i mucked around with extending stat a few years back, so that we could support statx(). so it might be doable.

the downside to squeezing xattrs into stat is that xattrs can be big, bloating the stat packet even if people don't want them. (another possibility is to otherwise flag the chan/Fid to say "yeah, give me the xattrs).

hugelgupf commented 1 year ago

Users of this library implementing a p9.File should have to worry as little as possible about the underlying protocol and be able to implement xattrs the same way they could in the kernel -- i.e. as listxattr, setxattr, getxattr, removexattr. I think the abstraction of #66 is preferred (we'll have to check out the implementation, I haven't gotten that far).