summaryrefslogtreecommitdiff
path: root/src/unistd/getcwd.c
blob: e8e46a6074fa95c1b0d262802379cd75617fc1ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stddef.h"
#include "sys/types.h"
#include <unistd.h>
#include "errno.h"
#include "nonstd/assert.h"
#include "nonstd/syscall.h"

char * getcwd(char *buf, size_t size)
{
	ASSERT_NONNULL(buf);
	SCNO(scno, "getcwd", NULL);
	int r = __libc.syscall(scno, buf, size);
	if (r < 0) {
		errno = -r;
		return NULL;
	}
	return buf;
}
/*
POSIX(1)
*/