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

1990/0319/gnot/devdk.c (diff list | history)

1990/0315/sys/src/9/gnot/devdk.c:644,6511990/0319/sys/src/9/gnot/devdk.c:644,658 (short | long | prev | next)
1990/0312    
	Dk *dp; 
	int line; 
 
	if(c->qid == Dcloneqid){ 
1990/0319    
	if(c->qid & CHDIR){ 
1990/0312    
		/* 
1990/0319    
		 *  directories are read only 
		 */ 
		if(omode != OREAD) 
			error(0, Ebadarg); 
	} else switch(STREAMTYPE(c->qid)){ 
	case Dcloneqid: 
		/* 
1990/0312    
		 *  get an unused device and open it's control file 
		 */ 
		dp = &dk[c->dev]; 
1990/0315/sys/src/9/gnot/devdk.c:665,6711990/0319/sys/src/9/gnot/devdk.c:672,679
1990/0312    
			error(0, Enodev); 
		streamopen(c, &dkinfo); 
		pushq(c->stream, &urpinfo); 
	} else if(STREAMTYPE(c->qid) == Dlistenqid){ 
1990/0319    
		break; 
	case Dlistenqid: 
1990/0312    
		/* 
		 *  listen for a call and open the control file for the 
		 *  channel on which the call arrived. 
1990/0315/sys/src/9/gnot/devdk.c:675,6871990/0319/sys/src/9/gnot/devdk.c:683,707
1990/0312    
		streamopen(c, &dkinfo); 
		pushq(c->stream, &urpinfo); 
		dkwindow(c); 
	} else if(c->qid != CHDIR){ 
1990/0319    
		break; 
	case Daddrqid: 
	case Draddrqid: 
	case Duserqid: 
	case Dotherqid: 
1990/0312    
		/* 
1990/0319    
		 *  read only files 
		 */ 
		if(omode != OREAD) 
			error(0, Ebadarg); 
		break; 
	default: 
		/* 
1990/0312    
		 *  open whatever c points to, make sure it has an urp 
		 */ 
		streamopen(c, &dkinfo); 
		if(strcmp(c->stream->procq->next->info->name, "urp")!=0) 
			pushq(c->stream, &urpinfo); 
1990/0319    
		break; 
1990/0312    
	} 
 
	c->mode = openmode(omode); 
1990/0315/sys/src/9/gnot/devdk.c:702,7081990/0319/sys/src/9/gnot/devdk.c:722,728
1990/0312    
	Dk *dp; 
 
	/* real closing happens in lancestclose */ 
	if(c->qid != CHDIR) 
1990/0319    
	if(c->stream) 
1990/0312    
		streamclose(c); 
 
	dp = &dk[c->dev]; 
1990/0315/sys/src/9/gnot/devdk.c:714,7301990/0319/sys/src/9/gnot/devdk.c:734,753
1990/0312    
long	  
dkread(Chan *c, void *a, long n) 
{ 
	int t; 
	Line *lp; 
 
	t = STREAMTYPE(c->qid); 
	if(t>=Slowqid || t==Dlineqid) 
1990/0319    
	if(c->stream) 
1990/0312    
		return streamread(c, a, n); 
	if(c->qid == CHDIR) 
		return devdirread(c, a, n, dkdir, dk[c->dev].lines, devgen); 
 
1990/0319    
	if(c->qid & CHDIR){ 
		if(c->qid == CHDIR) 
			return devdirread(c, a, n, dkdir, dk[c->dev].lines, devgen); 
		else 
			return devdirread(c, a, n, dksubdir, Nsubdir, streamgen); 
	} 
 
1990/0312    
	lp = &dk[c->dev].line[STREAMID(c->qid)]; 
	switch(t){ 
1990/0319    
	switch(STREAMTYPE(c->qid)){ 
1990/0312    
	case Daddrqid: 
		return stringread(c, a, n, lp->addr); 
	case Draddrqid: 
1990/0315/sys/src/9/gnot/devdk.c:781,7891990/0319/sys/src/9/gnot/devdk.c:804,809
1990/0312    
			return streamwrite(c, a, n, 0); 
		return n; 
	} 
                 
	if(t >= Slowqid) 
		return streamwrite(c, a, n, 0); 
 
	error(0, Eperm); 
} 


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