Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/port/devXXX.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname port/devXXX.c 1991/0111
## diff -e /dev/null /n/bootesdump/1991/0111/sys/src/9/port/devXXX.c
0a
/*
 *  template for making a new device
 */

#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"errno.h"

#include	"devtab.h"

enum{
	XXXdirqid,
	XXXdataqid,
};
Dirtab XXXtab[]={
	"data",		XXXdataqid,		0,	0600,
};
#define NXXXtab (sizeof(XXXTab)/sizeof(Dirtab))

void
XXXreset(void)
{
}

void
XXXinit(void)
{
}

Chan *
XXXattach(char *spec)
{
	return devattach('X', spec);
}

Chan *
XXXclone(Chan *c, Chan *nc)
{
	return devclone(c, nc);
}

int
XXXwalk(Chan *c, char *name)
{
	return devwalk(c, name, XXXtab, (long)NXXXtab, devgen);
}

void
XXXstat(Chan *c, char *db)
{
	devstat(c, db, XXXtab, (long)NXXXtab, devgen);
}

Chan *
XXXopen(Chan *c, int omode)
{
	if(c->qid == CHDIR){
		if(omode != OREAD)
			error(0, Eperm);
	}
	c->mode = openmode(omode);
	c->flag |= COPEN;
	c->offset = 0;
	return c;
}

void
XXXcreate(Chan *c, char *name, int omode, ulong perm)
{
	error(0, Eperm);
}

void
XXXremove(Chan *c)
{
	error(0, Eperm);
}

void
XXXwstat(Chan *c, char *dp)
{
	error(0, Eperm);
}

void
XXXclose(Chan *c)
{
}

long
XXXread(Chan *c, void *a, long n)
{
	switch((int)(c->qid&~CHDIR)){
	case XXXdirqid:
		return devdirread(c, a, n, XXXtab, NXXXtab, devgen);
	case XXXdataqid:
		break;
	default:
		n=0;
		break;
	}
	return n;
}

long
XXXwrite(Chan *c, char *a, long n)
{
	switch((int)(c->qid&~CHDIR)){
	case XXXdataqid:
		break;
	default:
		error(0, Ebadusefd);
	}
	return n;
}
.
## diffname port/devXXX.c 1991/0115
## diff -e /n/bootesdump/1991/0111/sys/src/9/port/devXXX.c /n/bootesdump/1991/0115/sys/src/9/port/devXXX.c
115c
		error(Ebadusefd);
.
111c
	switch((int)(c->qid.path&~CHDIR)){
.
96c
	switch((int)(c->qid.path&~CHDIR)){
.
85c
	error(Eperm);
.
79c
	error(Eperm);
.
73c
	error(Eperm);
.
62c
			error(Eperm);
.
60c
	if(c->qid.path == CHDIR){
.
## diffname port/devXXX.c 1991/1106
## diff -e /n/bootesdump/1991/0115/sys/src/9/port/devXXX.c /n/bootesdump/1991/1106/sys/src/9/port/devXXX.c
109c
XXXwrite(Chan *c, char *a, long n, ulong offset)
.
94c
XXXread(Chan *c, void *a, long n, ulong offset)
.
## diffname port/devXXX.c 1992/0111
## diff -e /n/bootesdump/1991/1106/sys/src/9/port/devXXX.c /n/bootesdump/1992/0111/sys/src/9/port/devXXX.c
10c
#include	"../port/error.h"
.
## diffname port/devXXX.c 1992/0321
## diff -e /n/bootesdump/1992/0111/sys/src/9/port/devXXX.c /n/bootesdump/1992/0321/sys/src/9/port/devXXX.c
6c
#include	"../port/lib.h"
.
## diffname port/devXXX.c 1995/0110
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/devXXX.c /n/fornaxdump/1995/0110/sys/src/brazil/port/devXXX.c
117a
}

long
XXXbwrite(Chan *c, Block *bp, ulong offset)
{
	return devbwrite(c, bp, offset);
.
111,112c
	switch(c->qid.path & ~CHDIR){
	case Qdata:
.
107a
Block*
XXXbread(Chan *c, long n, ulong offset)
{
	return devbread(c, n, offset);
}

.
99c
	case Qdata:
.
96,97c
	switch(c->qid.path & ~CHDIR){
	case Qdir:
.
84a
	USED(c, dp);
.
78a
	USED(c);
.
72a
	USED(c, name, omode, perm);
.
60,67c
	return devopen(c, omode, XXXtab, NXXXtab, devgen);
.
54c
	devstat(c, db, XXXtab, NXXXtab, devgen);
.
48c
	return devwalk(c, name, XXXtab, NXXXtab, devgen);
.
21c
#define NXXXtab (sizeof(XXXtab)/sizeof(Dirtab))
.
19c
	"data",		{Qdata, 0},	0,	0600,
.
15,16c
	Qdir,
	Qdata,
.
## diffname port/devXXX.c 1996/0223
## diff -e /n/fornaxdump/1995/0110/sys/src/brazil/port/devXXX.c /n/fornaxdump/1996/0223/sys/src/brazil/port/devXXX.c
12d
## diffname port/devXXX.c 1997/0327
## diff -e /n/fornaxdump/1996/0223/sys/src/brazil/port/devXXX.c /n/emeliedump/1997/0327/sys/src/brazil/port/devXXX.c
125a

Dev XXXdevtab = {					/* defaults in dev.c */
	XXXreset,					/* devreset */
	XXXinit,					/* devinit */
	XXXattach,
	XXXclone,					/* devclone */
	XXXwalk,
	XXXstat,
	XXXopen,
	XXXcreate,					/* devcreate */
	XXXclose,
	XXXread,
	XXXbread,					/* devbread */
	XXXwrite,
	XXXbwrite,					/* devbwrite */
	XXXremove,					/* devremove */
	XXXwstat,					/* devwstat */
};
.
121,122c
static long
XXXbwrite(Chan* c, Block* bp, ulong offset)		/* default in dev.c */
.
111a
	USED(a, offset);

.
109,110c
static long
XXXwrite(Chan* c, char* a, long n, ulong offset)
.
103,104c
static Block*
XXXbread(Chan* c, long n, ulong offset)			/* default in dev.c */
.
93c
		return devdirread(c, a, n, XXXtab, nelem(XXXtab), devgen);
.
90a
	USED(offset);

.
88,89c
static long
XXXread(Chan* c, void* a, long n, ulong offset)
.
85a
	USED(c);
.
83,84c
static void
XXXclose(Chan* c)
.
76,77c
static void
XXXwstat(Chan* c, char* dp)				/* default in dev.c */
.
69,70c
static void
XXXremove(Chan* c)					/* default in dev.c */
.
62,63c
static void
XXXcreate(Chan* c, char* name, int omode, ulong perm)	/* default in dev.c */
.
59c
	return devopen(c, omode, XXXtab, nelem(XXXtab), devgen);
.
56,57c
static Chan*
XXXopen(Chan* c, int omode)
.
53c
	devstat(c, db, XXXtab, nelem(XXXtab), devgen);
.
50,51c
static void
XXXstat(Chan* c, char* db)
.
47c
	return devwalk(c, name, XXXtab, nelem(XXXtab), devgen);
.
44,45c
static int
XXXwalk(Chan* c, char* name)
.
38,39c
static Chan*
XXXclone(Chan* c, Chan* nc)				/* default in dev.c */
.
32,33c
static Chan*
XXXattach(char* spec)
.
27,28c
static void
XXXinit(void)						/* default in dev.c */
.
22,23c
static void
XXXreset(void)						/* default in dev.c */
.
20d
## diffname port/devXXX.c 1997/0408
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/port/devXXX.c /n/emeliedump/1997/0408/sys/src/brazil/port/devXXX.c
131a
	'X',
	"XXX",

.
## diffname port/devXXX.c 1997/1101 # deleted
## diff -e /n/emeliedump/1997/0408/sys/src/brazil/port/devXXX.c /n/emeliedump/1997/1101/sys/src/brazil/port/devXXX.c
1,150d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].