shithub: drawterm

Download patch

ref: 3f419d1cd08268c49a442a85d9286441b620fcb4
parent: df77799e3a82eb05bb5b8d11fedf34f8fd9e8167
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 27 21:25:48 EST 2016

kern: allow Dev.create() to return a Chan* to bring it in line with 9front kernel

--- a/kern/chan.c	Sat Feb 27 21:09:06 2016
+++ b/kern/chan.c	Sat Feb 27 21:25:48 2016
@@ -1328,7 +1328,7 @@
 			cnew->name = c->name;
 			incref(&cnew->name->ref);
 
-			devtab[cnew->type]->create(cnew, e.elems[e.nelems-1], omode&~(OEXCL|OCEXEC), perm);
+			cnew = devtab[cnew->type]->create(cnew, e.elems[e.nelems-1], omode&~(OEXCL|OCEXEC), perm);
 			poperror();
 			if(omode & OCEXEC)
 				cnew->flag |= CCEXEC;
--- a/kern/dat.h	Sat Feb 27 21:09:06 2016
+++ b/kern/dat.h	Sat Feb 27 21:25:48 2016
@@ -219,7 +219,7 @@
 	Walkqid*	(*walk)(Chan*, Chan*, char**, int);
 	int	(*stat)(Chan*, uchar*, int);
 	Chan*	(*open)(Chan*, int);
-	void	(*create)(Chan*, char*, int, ulong);
+	Chan*	(*create)(Chan*, char*, int, ulong);
 	void	(*close)(Chan*);
 	long	(*read)(Chan*, void*, long, vlong);
 	Block*	(*bread)(Chan*, long, ulong);
--- a/kern/dev.c	Sat Feb 27 21:09:06 2016
+++ b/kern/dev.c	Sat Feb 27 21:25:48 2016
@@ -388,7 +388,7 @@
 	return c;
 }
 
-void
+Chan*
 devcreate(Chan *c, char *name, int mode, ulong perm)
 {
 	USED(c);
@@ -397,6 +397,7 @@
 	USED(perm);
 
 	error(Eperm);
+	return nil;
 }
 
 Block*
--- a/kern/devfs-posix.c	Sat Feb 27 21:09:06 2016
+++ b/kern/devfs-posix.c	Sat Feb 27 21:25:48 2016
@@ -215,7 +215,7 @@
 	return c;
 }
 
-static void
+static Chan*
 fscreate(Chan *c, char *name, int mode, ulong perm)
 {
 	int fd, m;
@@ -274,6 +274,7 @@
 	c->offset = 0;
 	c->flag |= COPEN;
 	c->mode = openmode(mode);
+	return c;
 }
 
 static void
--- a/kern/devfs-win32.c	Sat Feb 27 21:09:06 2016
+++ b/kern/devfs-win32.c	Sat Feb 27 21:25:48 2016
@@ -392,7 +392,7 @@
 	return c;
 }
 
-static void
+static Chan*
 fscreate(Chan *c, char *name, int mode, ulong perm)
 {
 	int m;
@@ -444,6 +444,7 @@
 	c->offset = 0;
 	c->flag |= COPEN;
 	c->mode = openmode(mode);
+	return c;
 }
 
 
--- a/kern/devmnt.c	Sat Feb 27 21:09:06 2016
+++ b/kern/devmnt.c	Sat Feb 27 21:25:48 2016
@@ -553,10 +553,10 @@
 	return mntopencreate(Topen, c, nil, omode, 0);
 }
 
-static void
+static Chan*
 mntcreate(Chan *c, char *name, int omode, ulong perm)
 {
-	mntopencreate(Tcreate, c, name, omode, perm);
+	return mntopencreate(Tcreate, c, name, omode, perm);
 }
 
 static void
--- a/kern/exportfs.c	Sat Feb 27 21:09:06 2016
+++ b/kern/exportfs.c	Sat Feb 27 21:25:48 2016
@@ -661,7 +661,7 @@
 	c = f->chan;
 	if(c->mnt && !(c->flag&CCREATE))
 		c = createdir(c);
-	(*devtab[c->type].create)(c, rpc->name, rpc->mode, rpc->perm);
+	c = (*devtab[c->type].create)(c, rpc->name, rpc->mode, rpc->perm);
 	poperror();
 
 	f->chan = c;
--- a/kern/fns.h	Sat Feb 27 21:09:06 2016
+++ b/kern/fns.h	Sat Feb 27 21:25:48 2016
@@ -62,7 +62,7 @@
 long		devbwrite(Chan*, Block*, ulong);
 Chan*		devclone(Chan*);
 int		devconfig(int, char *, DevConf *);
-void		devcreate(Chan*, char*, int, ulong);
+Chan*		devcreate(Chan*, char*, int, ulong);
 void		devdir(Chan*, Qid, char*, vlong, char*, long, Dir*);
 long		devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
 Devgen		devgen;