9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [patch] devshr: allow posting plain directories
@ 2021-02-10 23:06 covertusername967
  2021-02-11 22:19 ` cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: covertusername967 @ 2021-02-10 23:06 UTC (permalink / raw)
  To: covertusername967, 9front

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);
 


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

* Re: [9front] [patch] devshr: allow posting plain directories
  2021-02-10 23:06 [9front] [patch] devshr: allow posting plain directories covertusername967
@ 2021-02-11 22:19 ` cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2021-02-11 22:19 UTC (permalink / raw)
  To: 9front

noooo.... what if you have a union mount on it? theres a reason we only
allow 9p channels. its sane and contained. these union mount directorys,
you have to explain them to the coca cola company.

--
cinap

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

end of thread, other threads:[~2021-02-11 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 23:06 [9front] [patch] devshr: allow posting plain directories covertusername967
2021-02-11 22:19 ` cinap_lenrek

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git