Matthew Veetyupdated manpage8c66c2a10 years agoHistory
94 lines · 1.9 KB · Text
RawDownload
.TH GIO 2.SH NAMEgopen, gclose, gseek, gread, gwrite, fd2gio \- Programmable streams.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.br.B #include <gio.h>.PP.ft L.nftypedef struct ReadWriter {	RWLock;	int (*open)(ReadWriter*);	int (*close)(ReadWriter*);	long (*pread)(ReadWriter*, void*, long, vlong);	long (*pwrite)(ReadWriter*, void*, long, vlong);	void *aux;	u64int offset;	u64int length;} ReadWriter;.fi.PP.Bint gopen(ReadWriter *r, void *aux).PP.Bint gclose(int gfd).PP.Bvlong gseek(int gfd, vlong offset, int whence).PP.Blong gread(int gfd, void *buf, long nbytes, vlong offset).PP.Blong gwrite(int gfd, void *buf, long nbytes, vlong offset).PP.Bint fd2gio(int fd).SH DESCRIPTION.I gopentakes a ReadWriter struct and creates a new instance of a gio fd..I auxis an auxillary argument that may or may not be optional depending on how the gio stream is implemented..I gclosecloses a gio fd and frees any resources allocated to it..I gseekchanges the fd in a similar way to.IR seek (2)..I greadand.I gwriteare the gio equivalents to.IR pread (2)and.IR pwrite (2).They are functionally equivalent and have nearly the same usage..I fd2giotakes a Plan 9 file descriptor and returns a gio descriptor made from that fd..SH SOURCE.B /sys/src/libgio.SH NOTESThe gio functions automatically lock the ReadWriter struct in use hopefully making things work better with.IR thread (2)..SH BUGSThings get interesting with.IR rfork (2)when you disable shared memory..brThe file descriptor table is poorly implemented..brYou cannot easily mix gio file descriptors with functions that want Plan 9 ones..br .SH SEE ALSO.IR read (2),.IR seek (2),.IR open (2).SH DIAGNOSTICSBy default, no. Users can have their methods set .I errstr,and.I gopen,.I gclose,.I gread,and.I gwritewill return -2 if a function pointer is nil..SH HISTORYFirst appeared as part of.IR ngfs (8)in September 2015