9front - general discussion about 9front
 help / color / mirror / Atom feed
From: sirjofri+ml-9front@sirjofri.de
To: 9front@9front.org
Subject: [9front] mycroftiv's zrv and rfork V, patch for current 9front
Date: Wed, 06 Jan 2021 11:17:04 +0100	[thread overview]
Message-ID: <A8A041D340B90243B3E3F309BCD9A084@sirjofri.de> (raw)

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

Hello all,

since some people asked mycroftiv about rfork V (and zrv) here's a
patch for current (yesterday) 9front.

Some things changed since the last official ants diffs, so manual
adjustments were needed.  Also don't forget backups!

The patch should apply cleanly.  Rebuilding libc, rc and kernel is
needed (libc before rc!).

This patch does _not_ include the changes to postmountsrv, which make
it possible to srv directly to /zrv (`application -s name` vs
`application -s /zrv/name`).


All credits go to mycroftiv for this.


sirjofri

.

[-- Attachment #2: Type: text/plain, Size: 7461 bytes --]

diff -r d1a5cac82bd7 sys/include/libc.h
--- a/sys/include/libc.h	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/include/libc.h	Tue Jan 05 17:22:13 2021 +0100
@@ -624,6 +624,7 @@
 	RFPROC		= (1<<4),
 	RFMEM		= (1<<5),
 	RFNOWAIT	= (1<<6),
+	RFCSRVG		= (1<<9),
 	RFCNAMEG	= (1<<10),
 	RFCENVG		= (1<<11),
 	RFCFDG		= (1<<12),
diff -r d1a5cac82bd7 sys/lib/dist/cfg/plan9.ini
--- a/sys/lib/dist/cfg/plan9.ini	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/lib/dist/cfg/plan9.ini	Tue Jan 05 17:22:13 2021 +0100
@@ -3,3 +3,4 @@
 mouseport=ask
 monitor=ask
 vgasize=ask
+bootfile=/amd64/9pc64
diff -r d1a5cac82bd7 sys/src/9/pc64/pc64
--- a/sys/src/9/pc64/pc64	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/pc64/pc64	Tue Jan 05 17:22:13 2021 +0100
@@ -10,6 +10,7 @@
 	proc
 	mnt
 	srv
+	zrv
 	shr
 	dup
 	rtc
diff -r d1a5cac82bd7 sys/src/9/port/auth.c
--- a/sys/src/9/port/auth.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/auth.c	Tue Jan 05 17:22:13 2021 +0100
@@ -141,6 +141,7 @@
 
 	renameuser(eve, buf);
 	srvrenameuser(eve, buf);
+	zrvrenameuser(eve, buf);
 	shrrenameuser(eve, buf);
 	kstrdup(&eve, buf);
 	procsetuser(buf);
diff -r d1a5cac82bd7 sys/src/9/port/devroot.c
--- a/sys/src/9/port/devroot.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/devroot.c	Tue Jan 05 17:22:13 2021 +0100
@@ -108,6 +108,7 @@
 	addrootdir("root");
 	addrootdir("srv");
 	addrootdir("shr");
+	addrootdir("zrv");
 }
 
 static Chan*
diff -r d1a5cac82bd7 sys/src/9/port/devsrv.c
--- a/sys/src/9/port/devsrv.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/devsrv.c	Tue Jan 05 17:22:13 2021 +0100
@@ -6,19 +6,7 @@
 #include	"../port/error.h"
 
 
-typedef struct Srv Srv;
-struct Srv
-{
-	char	*name;
-	char	*owner;
-	ulong	perm;
-	Chan	*chan;
-	Srv	*link;
-	ulong	path;
-};
-
 static QLock	srvlk;
-static Srv	*srv;
 static int	qidpath;
 
 static Srv*
@@ -26,7 +14,7 @@
 {
 	Srv *sp;
 
-	for(sp = srv; sp != nil; sp = sp->link) {
+	for(sp = up->sgrp->srvgrp; sp != nil; sp = sp->link) {
 		if(sp->path == qidpath || (name != nil && strcmp(sp->name, name) == 0))
 			return sp;
 	}
@@ -48,7 +36,7 @@
 	if(name != nil)
 		sp = srvlookup(name, -1);
 	else {
-		for(sp = srv; sp != nil && s > 0; sp = sp->link)
+		for(sp = up->sgrp->srvgrp; sp != nil && s > 0; sp = sp->link)
 			s--;
 	}
 	if(sp == nil || (name != nil && (strlen(sp->name) >= sizeof(up->genbuf)))) {
@@ -95,7 +83,7 @@
 
 	s = nil;
 	qlock(&srvlk);
-	for(sp = srv; sp != nil; sp = sp->link) {
+	for(sp = up->sgrp->srvgrp; sp != nil; sp = sp->link) {
 		if(sp->chan == c){
 			s = malloc(3+strlen(sp->name)+1);
 			if(s != nil)
@@ -183,8 +171,8 @@
 	c->qid.path = sp->path;
 	c->qid.type = QTFILE;
 
-	sp->link = srv;
-	srv = sp;
+	sp->link = up->sgrp->srvgrp;
+	up->sgrp->srvgrp = sp;
 
 	qunlock(&srvlk);
 	poperror();
@@ -208,7 +196,7 @@
 		qunlock(&srvlk);
 		nexterror();
 	}
-	l = &srv;
+	l = &up->sgrp->srvgrp;
 	for(sp = *l; sp != nil; sp = *l) {
 		if(sp->path == c->qid.path)
 			break;
@@ -378,12 +366,30 @@
 };
 
 void
+closesgrp(Sgrp *sg)
+{
+	Srv *sp;
+	Srv *tsp;
+
+	if(decref(sg) == 0){
+		sp = sg->srvgrp;
+		while(sp!=nil){
+			tsp=sp;
+			sp=sp->link;
+			free(tsp);
+		}
+		free(sg);
+	}
+	return;
+}
+
+void
 srvrenameuser(char *old, char *new)
 {
 	Srv *sp;
 
 	qlock(&srvlk);
-	for(sp = srv; sp != nil; sp = sp->link) {
+	for(sp = up->sgrp->srvgrp; sp != nil; sp = sp->link) {
 		if(sp->owner != nil && strcmp(old, sp->owner) == 0)
 			kstrdup(&sp->owner, new);
 	}
diff -r d1a5cac82bd7 sys/src/9/port/portdat.h
--- a/sys/src/9/port/portdat.h	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/portdat.h	Tue Jan 05 17:22:13 2021 +0100
@@ -44,6 +44,8 @@
 typedef struct Segment	Segment;
 typedef struct Segio	Segio;
 typedef struct Sema	Sema;
+typedef struct Sgrp Sgrp;
+typedef struct Srv Srv;
 typedef struct Timer	Timer;
 typedef struct Timers	Timers;
 typedef struct Uart	Uart;
@@ -468,6 +470,21 @@
 	Page	*pghash[PGHSIZE];	/* page cache */
 };
 
+struct Srv
+{
+	char	*name;
+	char	*owner;
+	ulong	perm;
+	Chan	*chan;
+	Srv	*link;
+	ulong	path;
+};
+
+struct Sgrp
+{
+	Ref;
+	Srv	*srvgrp;
+};
 
 struct Pgrp
 {
@@ -576,6 +593,7 @@
 	RFPROC		= (1<<4),
 	RFMEM		= (1<<5),
 	RFNOWAIT	= (1<<6),
+	RFCSRVG		= (1<<9),
 	RFCNAMEG	= (1<<10),
 	RFCENVG		= (1<<11),
 	RFCFDG		= (1<<12),
@@ -678,6 +696,7 @@
 	Egrp 	*egrp;		/* Environment group */
 	Fgrp	*fgrp;		/* File descriptor group */
 	Rgrp	*rgrp;		/* Rendez group */
+	Sgrp	*sgrp;		/* Srv group */
 
 	Fgrp	*closingfgrp;	/* used during teardown */
 
diff -r d1a5cac82bd7 sys/src/9/port/portfns.h
--- a/sys/src/9/port/portfns.h	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/portfns.h	Tue Jan 05 17:22:13 2021 +0100
@@ -34,6 +34,7 @@
 void		closefgrp(Fgrp*);
 void		closepgrp(Pgrp*);
 void		closergrp(Rgrp*);
+void		closesgrp(Sgrp*);
 long		clrfpintr(void);
 void		cmderror(Cmdbuf*, char*);
 int		cmount(Chan**, Chan*, int, char*);
@@ -340,6 +341,8 @@
 void		splxpc(int);
 char*		srvname(Chan*);
 void		srvrenameuser(char*, char*);
+char*		zrvname(Chan*);
+void		zrvrenameuser(char*, char*);
 void		shrrenameuser(char*, char*);
 int		swapcount(uintptr);
 int		swapfull(void);
diff -r d1a5cac82bd7 sys/src/9/port/proc.c
--- a/sys/src/9/port/proc.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/proc.c	Tue Jan 05 17:22:13 2021 +0100
@@ -1092,6 +1092,7 @@
 	Egrp *egrp;
 	Rgrp *rgrp;
 	Pgrp *pgrp;
+	Sgrp *sgrp;
 	Chan *dot;
 	void (*pt)(Proc*, int, vlong);
 
@@ -1122,6 +1123,13 @@
 		closeegrp(egrp);
 	if(rgrp != nil)
 		closergrp(rgrp);
+	/* sgrp is nilled out here because closefgrp may need srvclose */
+	qlock(&up->debug);
+	sgrp = up->sgrp;
+	up->sgrp = nil;
+	qunlock(&up->debug);
+	if(sgrp != nil)
+		closesgrp(sgrp);
 	if(dot != nil)
 		cclose(dot);
 	if(pgrp != nil)
diff -r d1a5cac82bd7 sys/src/9/port/sysproc.c
--- a/sys/src/9/port/sysproc.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/sysproc.c	Tue Jan 05 17:22:13 2021 +0100
@@ -32,6 +32,7 @@
 	Pgrp *opg;
 	Rgrp *org;
 	Egrp *oeg;
+	Sgrp *osg;
 	ulong pid, flag;
 	Mach *wm;
 
@@ -71,6 +72,12 @@
 			up->rgrp = newrgrp();
 			closergrp(org);
 		}
+		if(flag & RFCSRVG) {
+			osg = up->sgrp;
+			up->sgrp = smalloc(sizeof(Sgrp));
+			up->sgrp->ref = 1;
+			closesgrp(osg);
+		}
 		if(flag & (RFENVG|RFCENVG)) {
 			oeg = up->egrp;
 			up->egrp = smalloc(sizeof(Egrp));
@@ -187,6 +194,15 @@
 		p->rgrp = up->rgrp;
 	}
 
+	/* Srv group */
+	if(flag & RFCSRVG) {
+		p->sgrp = smalloc(sizeof(Sgrp));
+		p->sgrp->ref = 1;
+	} else {
+		p->sgrp = up->sgrp;
+		incref(p->sgrp);
+	}
+
 	/* Environment group */
 	if(flag & (RFENVG|RFCENVG)) {
 		p->egrp = smalloc(sizeof(Egrp));
diff -r d1a5cac82bd7 sys/src/9/port/userinit.c
--- a/sys/src/9/port/userinit.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/9/port/userinit.c	Tue Jan 05 17:22:13 2021 +0100
@@ -31,6 +31,8 @@
 	up->pgrp = newpgrp();
 	up->egrp = smalloc(sizeof(Egrp));
 	up->egrp->ref = 1;
+	up->sgrp = smalloc(sizeof(Sgrp));
+	up->sgrp->ref = 1;
 	up->fgrp = dupfgrp(nil);
 	up->rgrp = newrgrp();
 
diff -r d1a5cac82bd7 sys/src/cmd/rc/plan9.c
--- a/sys/src/cmd/rc/plan9.c	Tue Jan 05 22:36:03 2021 +1030
+++ b/sys/src/cmd/rc/plan9.c	Tue Jan 05 17:22:13 2021 +0100
@@ -81,11 +81,13 @@
 			arg|=RFFDG;    break;
 		case 'F':
 			arg|=RFCFDG;   break;
+		case 'V':
+			arg|=RFCSRVG;  break;
 		}
 		break;
 	default:
 	Usage:
-		pfmt(err, "Usage: %s [fnesFNEm]\n", runq->argv->words->word);
+		pfmt(err, "Usage: %s [fnesFNEmV]\n", runq->argv->words->word);
 		setstatus("rfork usage");
 		poplist();
 		return;

             reply	other threads:[~2021-01-06 10:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 10:17 sirjofri+ml-9front [this message]
2021-01-06 19:05 ` cinap_lenrek
2021-01-06 19:11   ` ori
2021-01-06 20:02     ` sirjofri
2021-01-06 22:28       ` cinap_lenrek
2021-01-07 20:55         ` Stuart Morrow
2021-01-07 14:04       ` sirjofri+ml-9front
2021-01-07  1:12     ` [9front] happy new year 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=A8A041D340B90243B3E3F309BCD9A084@sirjofri.de \
    --to=sirjofri+ml-9front@sirjofri.de \
    --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).