plan 9 kernel history: overview | file list | diff list

1991/0111/port/devroot.c (diff list | history)

port/devroot.c on 1990/0227
1990/0227    
#include	"u.h" 
#include	"lib.h" 
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
#include	"errno.h" 
#include	"devtab.h" 
 
enum{ 
	Qdir, 
	Qbin, 
	Qboot, 
	Qdev, 
	Qenv, 
	Qproc, 
}; 
 
Dirtab rootdir[]={ 
1990/11211    
	"bin",		{Qbin|CHDIR},	0,			0700, 
	"boot",		{Qboot},	0,			0700, 
	"dev",		{Qdev|CHDIR},	0,			0700, 
	"env",		{Qenv|CHDIR},	0,			0700, 
	"proc",		{Qproc|CHDIR},	0,			0700, 
1990/0227    
}; 
 
#define	NROOT	(sizeof rootdir/sizeof(Dirtab)) 
 
void 
rootreset(void) 
{ 
} 
 
void 
rootinit(void) 
{ 
} 
 
Chan* 
rootattach(char *spec) 
{ 
	return devattach('/', spec); 
} 
 
Chan* 
rootclone(Chan *c, Chan *nc) 
{ 
	return devclone(c, nc); 
} 
 
int	  
rootwalk(Chan *c, char *name) 
{ 
	return devwalk(c, name, rootdir, NROOT, devgen); 
} 
 
void	  
rootstat(Chan *c, char *dp) 
{ 
	devstat(c, dp, rootdir, NROOT, devgen); 
} 
 
Chan* 
rootopen(Chan *c, int omode) 
{ 
	return devopen(c, omode, rootdir, NROOT, devgen); 
} 
 
void	  
rootcreate(Chan *c, char *name, int omode, ulong perm) 
{ 
1990/11211    
	error(Eperm); 
1990/0227    
} 
 
/* 
 * sysremove() knows this is a nop 
 */ 
void	  
rootclose(Chan *c) 
{ 
} 
 
#include	"boot.h" 
 
long	  
rootread(Chan *c, void *buf, long n) 
{ 
 
1990/11211    
	switch(c->qid.path & ~CHDIR){ 
1990/0227    
	case Qdir: 
		return devdirread(c, buf, n, rootdir, NROOT, devgen); 
 
	case Qboot:		/* boot */ 
		if(c->offset >= sizeof bootcode) 
			return 0; 
		if(c->offset+n > sizeof bootcode) 
			n = sizeof bootcode - c->offset; 
		memcpy(buf, ((char*)bootcode)+c->offset, n); 
		return n; 
 
	case Qdev: 
		return 0; 
	} 
1990/11211    
	error(Egreg); 
1990/0227    
	return 0; 
} 
 
long	  
rootwrite(Chan *c, void *buf, long n) 
{ 
1990/11211    
	error(Egreg); 
1990/0227    
} 
 
void	  
rootremove(Chan *c) 
{ 
1990/11211    
	error(Eperm); 
1990/0227    
} 
 
void	  
rootwstat(Chan *c, char *dp) 
{ 
1990/11211    
	error(Eperm); 
1990/0227    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)