code: drawterm

Download patch

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

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

--- a/kern/chan.c
+++ b/kern/chan.c
@@ -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
+++ b/kern/dat.h
@@ -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
+++ b/kern/dev.c
@@ -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
+++ b/kern/devfs-posix.c
@@ -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
+++ b/kern/devfs-win32.c
@@ -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
+++ b/kern/devmnt.c
@@ -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
+++ b/kern/exportfs.c
@@ -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
+++ b/kern/fns.h
@@ -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;