xref: /plan9-contrib/sys/src/libc/9sys/getwd.c (revision 59cc4ca53493a3c6d2349fe2b7f7c40f7dce7294)
1 #include <u.h>
2 #include <libc.h>
3 
4 static char *nsgetwd(char*, int);
5 
6 char*
getwd(char * buf,int nbuf)7 getwd(char *buf, int nbuf)
8 {
9 	int n, fd;
10 
11 	fd = open(".", OREAD);
12 	if(fd < 0)
13 		return nil;
14 	n = fd2path(fd, buf, nbuf);
15 	close(fd);
16 	if(n < 0)
17 		return nil;
18 	return buf;
19 }
20