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

1990/1009/port/sysfile.c (diff list | history)

1990/1004/sys/src/9/port/sysfile.c:31,421990/1009/sys/src/9/port/sysfile.c:31,42 (short | long | prev | next)
1990/0227    
 
	if(fd<0 || NFD<=fd || (c=u->fd[fd])==0) 
		error(0, Ebadfd); 
	if(mode<0 || c->mode == 2) 
1990/1009    
	if(mode<0 || c->mode==ORDWR) 
1990/0227    
		return c; 
	if((mode&16) && c->mode==0) 
1990/1009    
	if((mode&OTRUNC) && c->mode==OREAD) 
1990/0227    
    err: 
		error(0, Ebadusefd); 
	if((mode&~16) != c->mode) 
1990/1009    
	if((mode&~OTRUNC) != c->mode) 
1990/0227    
		goto err; 
	return c; 
} 
1990/1004/sys/src/9/port/sysfile.c:56,611990/1009/sys/src/9/port/sysfile.c:56,100
1990/0227    
} 
 
long 
1990/1009    
syspipe(ulong *arg) 
{ 
	int fd[2]; 
	Chan *c[2]; 
	Dev *d; 
 
	validaddr(arg[0], 2*BY2WD, 1); 
	evenaddr(arg[0]); 
	d = &devtab[devno('|', 0)]; 
	c[0] = (*d->attach)(0); 
	c[1] = 0; 
	fd[0] = -1; 
	fd[1] = -1; 
	if(waserror()){ 
		close(c[0]); 
		if(c[1]) 
			close(c[1]); 
		if(fd[0] >= 0) 
			u->fd[fd[0]]=0; 
		if(fd[1] >= 0) 
			u->fd[fd[1]]=0; 
		nexterror(); 
	} 
	c[1] = (*d->clone)(c[0], 0); 
	(*d->walk)(c[0], "data"); 
	(*d->walk)(c[1], "data1"); 
	c[0] = (*d->open)(c[0], ORDWR); 
	c[1] = (*d->open)(c[1], ORDWR); 
	fd[0] = newfd(); 
	u->fd[fd[0]] = c[0]; 
	fd[1] = newfd(); 
	u->fd[fd[1]] = c[1]; 
	((long*)arg[0])[0] = fd[0]; 
	((long*)arg[0])[1] = fd[1]; 
	poperror(); 
	return 0; 
} 
 
long 
1990/0227    
sysdup(ulong *arg) 
{ 
	int fd; 
1990/1004/sys/src/9/port/sysfile.c:180,1861990/1009/sys/src/9/port/sysfile.c:219,225
1990/0227    
	Chan *c; 
	long n; 
 
	c = fdtochan(arg[0], 0); 
1990/1009    
	c = fdtochan(arg[0], OREAD); 
1990/1004    
	validaddr(arg[1], arg[2], 1); 
1990/0227    
	qlock(c); 
	if(waserror()){ 
1990/1004/sys/src/9/port/sysfile.c:208,2141990/1009/sys/src/9/port/sysfile.c:247,253
1990/0227    
	Chan *c; 
	long n; 
 
	c = fdtochan(arg[0], 1); 
1990/1009    
	c = fdtochan(arg[0], OWRITE); 
1990/0227    
	validaddr(arg[1], arg[2], 0); 
	qlock(c); 
	if(waserror()){ 
1990/1004/sys/src/9/port/sysfile.c:380,4221990/1009/sys/src/9/port/sysfile.c:419,424
1990/0227    
sysmount(ulong *arg) 
{ 
	return bindmount(arg, 1); 
} 
                 
long 
syspipe(ulong *arg) 
{ 
	int fd[2]; 
	Chan *c[2]; 
	Dev *d; 
                 
	validaddr(arg[0], 2*BY2WD, 1); 
	evenaddr(arg[0]); 
	d = &devtab[devno('|', 0)]; 
	c[0] = (*d->attach)(0); 
	c[1] = 0; 
	fd[0] = -1; 
	fd[1] = -1; 
	if(waserror()){ 
		close(c[0]); 
		if(c[1]) 
			close(c[1]); 
		if(fd[0] >= 0) 
			u->fd[fd[0]]=0; 
		if(fd[1] >= 0) 
			u->fd[fd[1]]=0; 
		nexterror(); 
	} 
	c[1] = (*d->clone)(c[0], 0); 
	c[0] = (*d->open)(c[0], ORDWR); 
	c[1] = (*d->open)(c[1], ORDWR); 
	fd[0] = newfd(); 
	u->fd[fd[0]] = c[0]; 
	fd[1] = newfd(); 
	u->fd[fd[1]] = c[1]; 
	((long*)arg[0])[0] = fd[0]; 
	((long*)arg[0])[1] = fd[1]; 
	poperror(); 
	return 0; 
} 
 
long 


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