Matthew Veetyfixed warnings and fuckupsa5ff2ed10 years agoHistory
45 lines · 661 B · C
RawDownload
#include <u.h>#include <libc.h>#include <gio.h> longgread(int fd, void *bf, long len, vlong offset){	ReadWriter *rd;	long rval;		rd = getrdstruct(fd);	if(rd == nil)		return -1;	if(rd->pread == nil)		return -2;	rlock(rd);	rval = rd->pread(rd, bf, offset, len);	runlock(rd);	return rval;} vlonggseek(int fd, vlong offset, int type){	ReadWriter *rd; 	rd = getrdstruct(fd);	if(rd == nil)		return -1;	wlock(rd);	switch(type){	case 0:		rd->offset = (u64int)offset;		break;	case 1:		rd->offset = rd->offset + (u64int)offset;		break;	case 2:		rd->offset = rd->length + (u64int)offset;		break;	}	wunlock(rd);	return rd->offset;}