Dmitry V. Levin
50608a4098
glibc, starting with commit glibc-2.24-28-gdbab657, has deprecated inclusion of <sys/sysmacros.h> by <sys/types.h>. The method used for deprecation breaks AC_HEADER_MAJOR: this autoconf macro no longer defines MAJOR_IN_SYSMACROS, which consequently breaks build. Let's assume that all systems supported by strace provide major, minor, and makedev macros via <sys/sysmacros.h>. * configure.ac (AC_HEADER_MAJOR): Remove. * mknod.c [MAJOR_IN_SYSMACROS, MAJOR_IN_MKDEV]: Remove. Include <sys/sysmacros.h> unconditionally. * print_struct_stat.c: Likewise. * tests/mknod.c: Likewise. * tests/mknodat.c: Likewise. * tests/xstatx.c: Likewise.
75 lines
2.0 KiB
C
75 lines
2.0 KiB
C
#include "tests.h"
|
|
#include <asm/unistd.h>
|
|
|
|
#ifdef __NR_mknodat
|
|
|
|
# include <stdio.h>
|
|
# include <sys/stat.h>
|
|
# include <sys/sysmacros.h>
|
|
# include <unistd.h>
|
|
|
|
static const char sample[] = "mknodat_sample";
|
|
static const long int fd = (long int) 0xdeadbeefffffffff;
|
|
|
|
static long
|
|
call_mknodat(unsigned short mode, unsigned long dev)
|
|
{
|
|
unsigned long lmode = (unsigned long) 0xffffffffffff0000 | mode;
|
|
return syscall(__NR_mknodat, fd, sample, lmode, dev);
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
unsigned long dev = (unsigned long) 0xdeadbeefbadc0ded;
|
|
|
|
long rc = call_mknodat(0, dev);
|
|
printf("mknodat(-1, \"%s\", 000) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
rc = call_mknodat(0xffff, dev);
|
|
printf("mknodat(-1, \"%s\", %#03ho) = %ld %s (%m)\n",
|
|
sample, (unsigned short) -1, rc, errno2name());
|
|
|
|
rc = call_mknodat(S_IFREG, 0);
|
|
printf("mknodat(-1, \"%s\", S_IFREG|000) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
rc = call_mknodat(S_IFDIR | 06, 0);
|
|
printf("mknodat(-1, \"%s\", S_IFDIR|006) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
rc = call_mknodat(S_IFLNK | 060, 0);
|
|
printf("mknodat(-1, \"%s\", S_IFLNK|060) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
rc = call_mknodat(S_IFIFO | 0600, 0);
|
|
printf("mknodat(-1, \"%s\", S_IFIFO|0600) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
dev = (unsigned long) 0xdeadbeef00000000 | makedev(1, 7);
|
|
|
|
rc = call_mknodat(S_IFCHR | 024, dev);
|
|
printf("mknodat(-1, \"%s\", S_IFCHR|024, makedev(1, 7)) = %ld %s (%m)\n",
|
|
sample, rc, errno2name());
|
|
|
|
const unsigned short mode = (0xffff & ~S_IFMT) | S_IFBLK;
|
|
dev = (unsigned long) 0xdeadbeefbadc0ded;
|
|
|
|
rc = call_mknodat(mode, dev);
|
|
printf("mknodat(-1, \"%s\", S_IFBLK|S_ISUID|S_ISGID|S_ISVTX|%#03ho"
|
|
", makedev(%u, %u)) = %ld %s (%m)\n",
|
|
sample, mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX),
|
|
major((unsigned) dev), minor((unsigned) dev),
|
|
rc, errno2name());
|
|
|
|
puts("+++ exited with 0 +++");
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
SKIP_MAIN_UNDEFINED("__NR_mknodat")
|
|
|
|
#endif
|