summaryrefslogtreecommitdiff
path: root/src/sys/stat/stat.c
blob: c507929551d48f8a1620c8bdc9f0d56c2f77b158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "sys/types.h"
#include <sys/stat.h>
#include "stdlib.h"
#include "nonstd/assert.h"

int stat(const char * restrict path, struct stat * restrict buf)
{
	ASSERT_NONNULL(path);
	ASSERT_NONNULL(buf);

	int ret = 0;
	#if 0
	char *linkbuf = NULL;

	do {
		ret = lstat(path, buf);
		if (S_ISLNK(buf->st_mode)) {
			linkbuf = realloc(linkbuf, buf->st_size + 1);
			readlink(path, linkbuf, buf->st_size);
			path = linkbuf;
		} else {
			path = NULL;
		}
	} while (path);
	realloc(linkbuf, 0);
	#endif

	return ret;
}
/*
POSIX(1)
*/