📄 devlfd.c
字号:
#include "u.h"#include <errno.h>#include "lib.h"#include "dat.h"#include "fns.h"#include "error.h"#undef pread#undef pwriteChan*lfdchan(int fd){ Chan *c; c = newchan(); c->type = devno('L', 0); c->aux = (void*)(uintptr)fd; c->name = newcname("fd"); c->mode = ORDWR; c->qid.type = 0; c->qid.path = 0; c->qid.vers = 0; c->dev = 0; c->offset = 0; return c;}intlfdfd(int fd){ return newfd(lfdchan(fd));}static Chan*lfdattach(char *x){ USED(x); error(Egreg); return nil;}static Walkqid*lfdwalk(Chan *c, Chan *nc, char **name, int nname){ USED(c); USED(nc); USED(name); USED(nname); error(Egreg); return nil;}static intlfdstat(Chan *c, uchar *dp, int n){ USED(c); USED(dp); USED(n); error(Egreg); return -1;}static Chan*lfdopen(Chan *c, int omode){ USED(c); USED(omode); error(Egreg); return nil;}static voidlfdclose(Chan *c){ close((int)(uintptr)c->aux);}static longlfdread(Chan *c, void *buf, long n, vlong off){ USED(off); /* can't pread on pipes */ n = read((int)(uintptr)c->aux, buf, n); if(n < 0){ iprint("error %d\n", errno); oserror(); } return n;}static longlfdwrite(Chan *c, void *buf, long n, vlong off){ USED(off); /* can't pread on pipes */ n = write((int)(uintptr)c->aux, buf, n); if(n < 0){ iprint("error %d\n", errno); oserror(); } return n;}Dev lfddevtab = { 'L', "lfd", devreset, devinit, devshutdown, lfdattach, lfdwalk, lfdstat, lfdopen, devcreate, lfdclose, lfdread, devbread, lfdwrite, devbwrite, devremove, devwstat,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -