Dmitry V. Levin
96a9ff5746
Automatically change tests/*.c files using the following script: for f in tests/*.c; do grep -Fv errno.h "$f" | grep -Ewq '(si_)?errno|SOCK_FILTER_DENY_SYSCALL' || sed -i '/# *include *<errno\.h>/d' "$f" done
42 lines
789 B
C
42 lines
789 B
C
#include "tests.h"
|
|
#include <sys/syscall.h>
|
|
|
|
#ifdef __NR_mknod
|
|
|
|
# include <stdio.h>
|
|
# include <sys/stat.h>
|
|
# include <unistd.h>
|
|
|
|
# ifdef MAJOR_IN_SYSMACROS
|
|
# include <sys/sysmacros.h>
|
|
# endif
|
|
# ifdef MAJOR_IN_MKDEV
|
|
# include <sys/mkdev.h>
|
|
# endif
|
|
|
|
# define TMP_FILE "mknod"
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
long rc = syscall(__NR_mknod, TMP_FILE, S_IFREG|0600, 0);
|
|
printf("mknod(\"%s\", S_IFREG|0600) = %ld %s (%m)\n",
|
|
TMP_FILE, rc, errno2name());
|
|
|
|
const unsigned long dev =
|
|
(unsigned long) 0xdeadbeef00000000 | makedev(1, 7);
|
|
|
|
rc = syscall(__NR_mknod, TMP_FILE, S_IFCHR | 0400, dev);
|
|
printf("mknod(\"%s\", S_IFCHR|0400, makedev(1, 7)) = %ld %s (%m)\n",
|
|
TMP_FILE, rc, errno2name());
|
|
|
|
puts("+++ exited with 0 +++");
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
SKIP_MAIN_UNDEFINED("__NR_mknod")
|
|
|
|
#endif
|