long sys_fstat(ulong *arg) { Chan *c; char *name; uint l; uchar buf[128]; /* old DIRLEN plus a little should be plenty */ char strs[128]; Dir d; char old[] = "old fstat system call - recompile"; validaddr(arg[1], 116, 1); c = fdtochan(arg[0], -1, 0, 1); if(waserror()){ cclose(c); nexterror(); } l = devtab[c->type]->stat(c, buf, sizeof buf); /* buf contains a new stat buf; convert to old. yuck. */ if(l <= BIT16SZ) /* buffer too small; time to face reality */ error(old); name = pathlast(c->path); if(name) l = dirsetname(name, strlen(name), buf, l, sizeof buf); l = convM2D(buf, l, &d, strs); if(l == 0) error(old); packoldstat((uchar*)arg[1], &d); poperror(); cclose(c); return 0; }
long sysstat(uint32 *arg) { char *name; Chan *c; uint l; uchar *p; l = arg[2]; p = uvalidaddr(arg[1], l, 1); name = uvalidaddr(arg[0], 1, 0); c = namec(name, Aaccess, 0, 0); if(waserror()){ cclose(c); nexterror(); } l = devtab[c->type]->stat(c, p, l); name = pathlast(c->path); if(name) l = dirsetname(name, strlen(name), p, l, arg[2]); poperror(); cclose(c); return l; }
long sys_stat(uint32 *arg) { Chan *c; uint l; uchar buf[128]; /* old DIRLEN plus a little should be plenty */ char strs[128], *name, *elem; Dir d; char old[] = "old stat system call - recompile"; uchar *p; p = uvalidaddr(arg[1], 116, 1); name = uvalidaddr(arg[0], 1, 0); c = namec(name, Aaccess, 0, 0); if(waserror()){ cclose(c); nexterror(); } l = devtab[c->type]->stat(c, buf, sizeof buf); /* buf contains a new stat buf; convert to old. yuck. */ if(l <= BIT16SZ) /* buffer too small; time to face reality */ error(old); elem = pathlast(c->path); if(elem) l = dirsetname(elem, strlen(elem), buf, l, sizeof buf); l = convM2D(buf, l, &d, strs); if(l == 0) error(old); packoldstat(p, &d); poperror(); cclose(c); return 0; }
/* * Returns a cvs path allocated with malloc() containing absolute pathname to a * file in cvs mode which can reside in the attic. XXX: filename has really no * restrictions. */ char * cvspath(const char *prefix, const char *file, int attic) { const char *last; char *path; last = pathlast(file); if (attic) xasprintf(&path, "%s/%.*sAttic/%s", prefix, (int)(last - file), file, last); else xasprintf(&path, "%s/%s", prefix, file); return (path); }
void sysstat(Ar0* ar0, ...) { Proc *up = externup(); char *aname; Chan *c; usize n; int r; uint8_t *p; va_list list; va_start(list, ar0); /* * int stat(char* name, uchar* edir, int nedir); * should really be * usize stat(char* name, uchar* edir, usize nedir); * but returning an unsigned is probably too * radical. */ aname = va_arg(list, char*); aname = validaddr(aname, 1, 0); p = va_arg(list, uint8_t*); n = va_arg(list, usize); va_end(list); p = validaddr(p, n, 1); c = namec(aname, Aaccess, 0, 0); if(waserror()){ cclose(c); nexterror(); } r = c->dev->stat(c, p, n); aname = pathlast(c->path); if(aname) r = dirsetname(aname, strlen(aname), p, r, n); poperror(); cclose(c); ar0->i = r; }