aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/realpath.c
blob: a59808d371804325593347f19731478c6bf10db6 (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
/* 
 * Copyright (c) 2010 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * static char *
 * wrap_realpath(const char *name, char *resolved_name) {
 *	char * rc = NULL;
 */
	char *rname = PSEUDO_ROOT_PATH(AT_FDCWD, name, 0);
	ssize_t len;
	if (!rname) {
		errno = ENAMETOOLONG;
		return NULL;
	}
	if ((len = strlen(rname)) >= pseudo_sys_path_max()) {
		errno = ENAMETOOLONG;
		return NULL;
	}
	if (resolved_name) {
		memcpy(resolved_name, rname, len + 1);
		rc = resolved_name;
	} else {
		rc = strdup(rname);
	}

/*	return rc;
 * }
 */