Plan 9 from User Space's /usr/local/plan9/9pm/src/libc/port/chdir.c

#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;
}

Space Glenda

Copyright © 2005 Lucent Technologies, Russ Cox, MIT.
See license for details.