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

#include <9pm/u.h>
#include <9pm/libc.h>

static char *nsgetwd(char*, int);

char*
getwd(char *buf, int nbuf)
{
	int n, fd;

	fd = open(".", OREAD);
	if(fd < 0)
		return nil;
	n = fd2path(fd, buf, nbuf);
	close(fd);
	if(n < 0)
		return nil;
	return buf;
}

Space Glenda

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