Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "lib.h"
2
#include <stddef.h>
3
#include <stdlib.h>
4
#include <unistd.h>
5
#include <errno.h>
6
#include <string.h>
7
#include <stdio.h>
8
#include "sys9.h"
9
#include "dir.h"
10
 
11
char*
12
getcwd(char *buf, size_t len)
13
{
14
	int fd;
15
 
16
	fd = _OPEN(".", OREAD);
17
	if(fd < 0) {
18
		errno = EACCES;
19
		return 0;
20
	}
21
	if(_FD2PATH(fd, buf, len) < 0) {
22
		errno = EIO;
23
		_CLOSE(fd);
24
		return 0;
25
	}
26
	_CLOSE(fd);
27
 
28
/* RSC: is this necessary? */
29
	if(buf[0] == '\0')
30
		strcpy(buf, "/");
31
	return buf;
32
}