From: covertusername967@gmail.com
To: covertusername967@gmail.com, 9front@9front.org
Subject: [9front] [patch] devshr: allow posting plain directories
Date: Wed, 10 Feb 2021 17:06:11 -0600 [thread overview]
Message-ID: <373D8A66AC0E86E835D394546F63BB20@gmail.com> (raw)
Per popular* request, I am posting this to the mailing list. This is
something I put together for personal use, so it is not quite
polished. See the BUGS section in the patch for the manpage.
Currently, devshr only allows you to post 9p channels to it. This is
fine and all, but it's handy to be able to post a directory to it.
This allows us to get around exportfs with its pseudo mountpoint limit
and access the directory tree directly.
*sirjofri's
diff -r ab517fbe257d sys/man/3/shr
--- a/sys/man/3/shr Tue Feb 09 23:11:08 2021 -0500
+++ b/sys/man/3/shr Wed Feb 10 16:11:50 2021 -0600
@@ -16,7 +16,7 @@
device provides global mountpoints in the form of share directories
where
.IR 9P
-services can be mounted.
+services can be mounted, as well as arbitrary directories.
Effectively, it is a global mountpoint registry that is separate from
private namespaces.
@@ -42,7 +42,9 @@
.IR atof (2))
giving the file descriptor number of an open
.I 9P
-service. Any process
+service. To post a directory, write the pathname. Relative pathnames are only accepted if they have a leading
+.B ./ .
+Any process
with the proper permission may then access
.B #σ/myshare
on the mount tree.
@@ -70,8 +72,17 @@
mkdir '#σc'/myshare
echo 3 > '#σc'/myshare/myserv <>[3]/srv/myserv
.EE
+To share a directory from your private namespace to the rest of the system
+.EX
+mkdir '#σc'/myshare
+echo /n/privatedir > '#σc'/myshare/mydir
+.EE
.SH SOURCE
.B /sys/src/9/port/devshr.c
.SH HISTORY
.I Shr
first appeared in 9front (July, 2011).
+.SH BUGS
+Mountpoints that exist below posted directories are not visible in the share.
+.PP
+If a union directory is posted, only the topmost directory in the union is visible. The union must be recreated manually if it is needed, and this is somewhat cumbersome.
diff -r ab517fbe257d sys/src/9/port/devshr.c
--- a/sys/src/9/port/devshr.c Tue Feb 09 23:11:08 2021 -0500
+++ b/sys/src/9/port/devshr.c Wed Feb 10 16:11:50 2021 -0600
@@ -744,23 +744,33 @@
}
memmove(buf, va, n);
buf[n] = 0;
-
- fd = strtol(buf, &p, 10);
- if(p == buf || (*p != 0 && *p != '\n'))
- error(Ebadarg);
- if(*p == '\n' && *(p+1) != 0)
- aname = p + 1;
- else
- aname = nil;
-
- bc = fdtochan(fd, ORDWR, 0, 1);
- if(waserror()) {
+
+ if(buf[0] == '/' || buf[0] == '.' || buf[0] == '#'){
+ if(buf[n-1] == '\n')
+ buf[n-1] = 0;
+ c0 = namec(buf, Abind, 0, 0);
+ if(!(c0->qid.type & QTDIR)){
+ cclose(c0);
+ error(Enotdir);
+ }
+ } else {
+ fd = strtol(buf, &p, 10);
+ if(p == buf || (*p != 0 && *p != '\n'))
+ error(Ebadarg);
+ if(*p == '\n' && *(p+1) != 0)
+ aname = p + 1;
+ else
+ aname = nil;
+
+ bc = fdtochan(fd, ORDWR, 0, 1);
+ if(waserror()){
+ cclose(bc);
+ nexterror();
+ }
+ c0 = mntattach(bc, nil, aname, 0);
+ poperror();
cclose(bc);
- nexterror();
}
- c0 = mntattach(bc, nil, aname, 0);
- poperror();
- cclose(bc);
poperror();
free(buf);
next reply other threads:[~2021-02-10 23:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 23:06 covertusername967 [this message]
2021-02-11 22:19 ` cinap_lenrek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=373D8A66AC0E86E835D394546F63BB20@gmail.com \
--to=covertusername967@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).