strace/tests/mknod.c
Dmitry V. Levin 9d91928320 Fix decoding of device numbers in mknod and mknodat syscalls
* mknod.c (decode_mknod): Treat device number argument as unsigned int.
* tests/mknod.c: Include <sys/sysmacros.h> or <sys/mkdev.h>
for definition of makedev macro.
(main): Add a check for a character special file.
2016-03-25 23:48:48 +00:00

44 lines
871 B
C

#include "tests.h"
#include <sys/syscall.h>
#ifdef __NR_mknod
# include <errno.h>
# 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)
{
int rc = syscall(__NR_mknod, TMP_FILE, S_IFREG|0600, 0);
printf("mknod(\"%s\", S_IFREG|0600) = %d %s (%m)\n",
TMP_FILE, rc,
errno == ENOSYS ? "ENOSYS" : "EEXIST");
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)) = %d %s (%m)\n",
TMP_FILE, rc,
errno == ENOSYS ? "ENOSYS" : "EEXIST");
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_mknod")
#endif