#include <9pm/u.h> #include <9pm/libc.h> #include <9pm/ns.h> int chdir(char *dir) { int ret; char *fullpath, *path; Mnt *mnt; Proc *p; if((path = nsassign(dir, &mnt, &fullpath)) == nil) return -1; ret = -1; checkerrstack(); if(!waserror()){ (*mnt->dev->_chdir)(mnt, path); ret = 0; p = getproc(); free(p->wd); p->wd = fullpath; poperror(); } checkerrstack(); return ret; }