0
1
mirror of https://github.com/termux/proot.git synced 2024-11-11 13:49:26 +00:00
proot/tests/test-a8e69d6f.c
2016-08-21 07:42:00 -04:00

32 lines
733 B
C

#include <unistd.h> /* syscall(2), */
#include <stdio.h> /* perror(3), fprintf(3), */
#include <stdlib.h> /* exit(3), */
#include <sys/syscall.h> /* SYS_lstat, */
#include <sys/stat.h> /* struct stat, */
#include <fcntl.h> /* AT_FDCWD */
int main(void)
{
struct stat stat;
int status;
#if defined(SYS_lstat)
status = syscall(SYS_lstat, "/proc/self/cwd/", &stat);
#elif defined(SYS_newfstatat)
status = syscall(SYS_newfstatat, AT_FDCWD, "/proc/self/cwd/", &stat, 0);
#else
#error "SYS_lstat and SYS_newfstatat doesn't exists"
#endif
if (status < 0) {
perror("lstat()");
exit(EXIT_FAILURE);
}
if (S_ISLNK(stat.st_mode)) {
fprintf(stderr, "trailing '/' ignored\n");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}