static int32_t wstat(Chan* c, uint8_t* p, usize n) { Proc *up = externup(); int32_t l; usize namelen; if(waserror()){ cclose(c); nexterror(); } /* * Renaming mount points is disallowed to avoid surprises * (which should be renamed? the mount point or the mounted Chan?). */ if(c->ismtpt){ dirname(p, &namelen); if(namelen) nameerror(chanpath(c), Eismtpt); } l = c->dev->wstat(c, p, n); poperror(); cclose(c); return l; }
void sysfd2path(Ar0* ar0, ...) { Chan *c; char *buf; int fd; usize nbuf; va_list list; va_start(list, ar0); /* * int fd2path(int fd, char* buf, int nbuf); * should be * int fd2path(int fd, char* buf, usize nbuf); */ fd = va_arg(list, int); buf = va_arg(list, char*); nbuf = va_arg(list, usize); va_end(list); buf = validaddr(buf, nbuf, 1); c = fdtochan(fd, -1, 0, 1); snprint(buf, nbuf, "%s", chanpath(c)); cclose(c); ar0->i = 0; }
long sysfd2path(ulong *arg) { Chan *c; validaddr(arg[1], arg[2], 1); c = fdtochan(arg[0], -1, 0, 1); snprint((char*)arg[1], arg[2], "%s", chanpath(c)); cclose(c); return 0; }
static char* looprtopctl(SDev *s, char *p, char *e) { Ctlr *c; char *r; c = s->ctlr; r = "ro"; if(c->mode == ORDWR) r = "rw"; return seprint(p, e, "%s loop %s %s\n", s->name, r, chanpath(c->c)); }
long sysfd2path(uint32 *arg) { Chan *c; char *buf; buf = uvalidaddr(arg[1], arg[2], 1); c = fdtochan(arg[0], -1, 0, 1); snprint(buf, arg[2], "%s", chanpath(c)); cclose(c); return 0; }
static int looprctl(SDunit *unit, char *p, int l) { Ctlr *ctlr; char *e, *op; ctlr = unit->dev->ctlr; e = p+l; op = p; p = seprint(p, e, "loop %s %s\n", ctlr->mode == ORDWR ? "rw" : "ro", chanpath(ctlr->c)); p = seprint(p, e, "geometry %llud 512\n", unit->sectors*512); return p - op; }
static long wstat(Chan *c, uchar *d, int nd) { long l; int namelen; if(waserror()){ cclose(c); nexterror(); } if(c->ismtpt){ /* * Renaming mount points is disallowed to avoid surprises * (which should be renamed? the mount point or the mounted Chan?). */ dirname(d, &namelen); if(namelen) nameerror(chanpath(c), Eismtpt); } l = devtab[c->type]->wstat(c, d, nd); poperror(); cclose(c); return l; }