]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/misc/realpath.c
10 char *realpath(const char *restrict filename
, char *restrict resolved
)
15 char buf
[15+3*sizeof(int)];
23 fd
= sys_open(filename
, O_PATH
|O_NONBLOCK
|O_CLOEXEC
);
25 __procfdname(buf
, fd
);
27 r
= readlink(buf
, tmp
, sizeof tmp
- 1);
33 if (r
<0 || st1
.st_dev
!= st2
.st_dev
|| st1
.st_ino
!= st2
.st_ino
) {
34 if (!r
) errno
= ELOOP
;
38 __syscall(SYS_close
, fd
);
39 return resolved
? strcpy(resolved
, tmp
) : strdup(tmp
);
41 __syscall(SYS_close
, fd
);