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

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

1990/1009/sys/src/9/port/sysfile.c:21,271990/11211/sys/src/9/port/sysfile.c:21,27 (short | long | prev | next)
1990/0227    
				u->maxfd = i; 
			return i; 
		} 
	error(0, Enofd); 
1990/11211    
	error(Enofd); 
1990/0227    
} 
 
Chan* 
1990/1009/sys/src/9/port/sysfile.c:30,411990/11211/sys/src/9/port/sysfile.c:30,41
1990/0227    
	Chan *c; 
 
	if(fd<0 || NFD<=fd || (c=u->fd[fd])==0) 
		error(0, Ebadfd); 
1990/11211    
		error(Ebadfd); 
1990/1009    
	if(mode<0 || c->mode==ORDWR) 
1990/0227    
		return c; 
1990/1009    
	if((mode&OTRUNC) && c->mode==OREAD) 
1990/0227    
    err: 
		error(0, Ebadusefd); 
1990/11211    
		error(Ebadusefd); 
1990/1009    
	if((mode&~OTRUNC) != c->mode) 
1990/0227    
		goto err; 
	return c; 
1990/1009/sys/src/9/port/sysfile.c:46,521990/11211/sys/src/9/port/sysfile.c:46,52
1990/0227    
{ 
1990/08141    
	if(o >= (OTRUNC|OCEXEC|ORCLOSE|OEXEC)) 
1990/0227    
    Err: 
		error(0, Ebadarg); 
1990/11211    
		error(Ebadarg); 
1990/08141    
	o &= ~(OTRUNC|OCEXEC|ORCLOSE); 
1990/0227    
	if(o > OEXEC) 
		goto Err; 
1990/1009/sys/src/9/port/sysfile.c:227,2381990/11211/sys/src/9/port/sysfile.c:227,238
1990/0227    
		nexterror(); 
	} 
	n = arg[2]; 
	if(c->qid&CHDIR){ 
1990/11211    
	if(c->qid.path & CHDIR){ 
1990/0227    
		n -= n%DIRLEN; 
		if(c->offset%DIRLEN || n==0) 
			error(0, Ebaddirread); 
1990/11211    
			error(Ebaddirread); 
1990/0227    
	} 
1990/0821    
	if((c->qid&CHDIR) && (c->flag&CMOUNT)) 
1990/11211    
	if((c->qid.path&CHDIR) && (c->flag&CMOUNT)) 
1990/0227    
		n = unionread(c, (void*)arg[1], n); 
	else 
		n = (*devtab[c->type].read)(c, (void*)arg[1], n); 
1990/1009/sys/src/9/port/sysfile.c:254,2611990/11211/sys/src/9/port/sysfile.c:254,261
1990/0227    
		qunlock(c); 
		nexterror(); 
	} 
	if(c->qid & CHDIR) 
		error(0, Eisdir); 
1990/11211    
	if(c->qid.path & CHDIR) 
		error(Eisdir); 
1990/0227    
	n = (*devtab[c->type].write)(c, (void*)arg[1], arg[2]); 
	c->offset += n; 
	qunlock(c); 
1990/1009/sys/src/9/port/sysfile.c:271,2781990/11211/sys/src/9/port/sysfile.c:271,278
1990/0227    
	long off; 
 
	c = fdtochan(arg[0], -1); 
	if(c->qid & CHDIR) 
		error(0, Eisdir); 
1990/11211    
	if(c->qid.path & CHDIR) 
		error(Eisdir); 
1990/0227    
	qlock(c); 
	if(waserror()){ 
		qunlock(c); 
1990/1009/sys/src/9/port/sysfile.c:365,3771990/11211/sys/src/9/port/sysfile.c:365,379
1990/0227    
	struct{ 
		Chan	*chan; 
		char	*spec; 
1990/11211    
		char	*auth; 
1990/0227    
	}bogus; 
 
	flag = arg[2]; 
	if(flag>MMASK || (flag&MORDER)==(MBEFORE|MAFTER)) 
		error(0, Ebadarg); 
1990/11211    
		error(Ebadarg); 
1990/0227    
	if(ismount){ 
		bogus.chan = fdtochan(arg[0], 2); 
1990/11211    
		validaddr(arg[3], 1, 0); 
1990/0918    
		p = (char*)arg[3]; 
		t = BY2PG-((ulong)p&(BY2PG-1)); 
		while(vmemchr(p, 0, t) == 0){ 
1990/1009/sys/src/9/port/sysfile.c:379,3841990/11211/sys/src/9/port/sysfile.c:381,394
1990/0918    
			t = BY2PG; 
		} 
1990/0227    
		bogus.spec = (char*)arg[3]; 
1990/11211    
		validaddr(arg[4], 1, 0); 
		p = (char*)arg[4]; 
		t = BY2PG-((ulong)p&(BY2PG-1)); 
		while(vmemchr(p, 0, t) == 0){ 
			p += t; 
			t = BY2PG; 
		} 
		bogus.auth = (char*)arg[4]; 
1990/0227    
		ret = devno('M', 0); 
		c0 = (*devtab[ret].attach)((char*)&bogus); 
	}else{ 
1990/1009/sys/src/9/port/sysfile.c:395,4041990/11211/sys/src/9/port/sysfile.c:405,414
1990/0227    
		close(c1); 
		nexterror(); 
	} 
	if((c0->qid^c1->qid) & CHDIR) 
		error(0, Ebadmount); 
	if(flag && !(c0->qid&CHDIR)) 
		error(0, Ebadmount); 
1990/11211    
	if((c0->qid.path^c1->qid.path) & CHDIR) 
		error(Ebadmount); 
	if(flag && !(c0->qid.path&CHDIR)) 
		error(Ebadmount); 
1990/0227    
	ret = mount(c0, c1, flag); 
	close(c0); 
	close(c1); 
1990/1009/sys/src/9/port/sysfile.c:433,4571990/11211/sys/src/9/port/sysfile.c:443,448
1990/0227    
	c = namec((char*)arg[0], Acreate, arg[1], arg[2]); 
	u->fd[fd] = c; 
	return fd; 
} 
                 
long 
sysuserstr(ulong *arg) 
{ 
	Error err; 
	char buf[NAMELEN]; 
                 
	validaddr(arg[0], sizeof(Error), 0); 
	validaddr(arg[1], NAMELEN, 1); 
	err = *(Error*)arg[0]; 
	err.type = devno(err.type, 1); 
	if(err.type == -1) 
		strcpy((char*)arg[1], "*gok*"); 
	else{ 
		(*devtab[err.type].userstr)(&err, buf); 
		memcpy((char*)arg[1], buf, sizeof buf); 
	} 
	return 0; 
} 
 
long 


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