def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/mman.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) linux_version_glibc = (5, 5) sys.exit( glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include <sys/mman.h>\n', '#define _GNU_SOURCE 1\n' '#include <linux/mman.h>\n', args.cc, 'MAP_.*', # A series of MAP_HUGE_<size> macros are defined by the kernel # but not by glibc. MAP_UNINITIALIZED is kernel-only. # MAP_FAILED is not a MAP_* flag and is glibc-only, as is the # MAP_ANON alias for MAP_ANONYMOUS. MAP_RENAME, MAP_AUTOGROW, # MAP_LOCAL and MAP_AUTORSRV are in the kernel header for # MIPS, marked as "not used by linux"; SPARC has MAP_INHERIT # in the kernel header, but does not use it. 'MAP_HUGE_[0-9].*|MAP_UNINITIALIZED|MAP_FAILED|MAP_ANON' '|MAP_RENAME|MAP_AUTOGROW|MAP_LOCAL|MAP_AUTORSRV|MAP_INHERIT', linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc))
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="System call list consistency checks") parser.add_argument('--cc', metavar='CC', required=True, help='C compiler (including options) to use') parser.add_argument('syscall_numbers_list', metavar='PATH', help='Path to the list of system call numbers') parser.add_argument('syscall_names_list', metavar='PATH', help='Path to the list of system call names') args = parser.parse_args() glibc_constants = glibcsyscalls.load_arch_syscall_header( args.syscall_numbers_list) with open(args.syscall_names_list) as inp: glibc_names = glibcsyscalls.SyscallNamesList(inp) kernel_constants = glibcsyscalls.kernel_constants(args.cc) kernel_version = glibcsyscalls.linux_kernel_version(args.cc) errors = 0 warnings = False for name in glibc_constants.keys() & kernel_constants.keys(): if glibc_constants[name] != kernel_constants[name]: print("error: syscall {!r} number mismatch: glibc={!r} kernel={!r}" .format(name, glibc_constants[name], kernel_constants[name])) errors = 1 # The architecture-specific list in the glibc tree must be a # subset of the global list of system call names. for name in glibc_constants.keys() - set(glibc_names.syscalls): print("error: architecture syscall {!r} missing from global names list" .format(name)) errors = 1 for name in glibc_constants.keys() - kernel_constants.keys(): print("info: glibc syscall {!r} not known to kernel".format(name)) warnings = True # If the glibc-recorded kernel version is not older than the # installed kernel headers, the glibc system call set must be a # superset of the kernel system call set. if glibc_names.kernel_version >= kernel_version: for name in kernel_constants.keys() - glibc_constants.keys(): print("error: kernel syscall {!r} ({}) not known to glibc" .format(name, kernel_constants[name])) errors = 1 else: for name in kernel_constants.keys() - glibc_constants.keys(): print("warning: kernel syscall {!r} ({}) not known to glibc" .format(name, kernel_constants[name])) warnings = True if errors > 0 or warnings: print("info: glibc tables are based on kernel version {}".format( ".".join(map(str, glibc_names.kernel_version)))) print("info: installed kernel headers are version {}".format( ".".join(map(str, kernel_version)))) sys.exit(errors)
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/pidfd.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) # Linux started to provide pidfd.h with 5.10. if linux_version_headers < (5, 10): sys.exit(77) linux_version_glibc = (5, 18) sys.exit( glibcextract.compare_macro_consts( '#include <sys/pidfd.h>\n', '#include <asm/fcntl.h>\n' '#include <linux/pidfd.h>\n', args.cc, 'PIDFD_.*', None, linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc))
def main(): """The main entry point.""" parser = argparse.ArgumentParser( description="Test that glibc's sys/mount.h constants " "match the kernel's.") parser.add_argument('--cc', metavar='CC', help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) # Constants in glibc were updated to match Linux v5.16. When glibc # constants are updated this value should be updated to match the # released kernel version from which the constants were taken. linux_version_glibc = (5, 16) def check(cte, exclude=None): return glibcextract.compare_macro_consts( '#include <sys/mount.h>\n', '#include <asm/fcntl.h>\n' '#include <linux/mount.h>\n', args.cc, cte, exclude, linux_version_glibc > linux_version_headers, linux_version_headers > linux_version_glibc) # Skip testing FS_CONFIG commands since they are only enums in the kernel # header. status = max( check('FSOPEN_.*'), check('FSMOUNT_.*'), # MOVE_MOUNT__MASK may vary depending of the kernel version. check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK'), check('OPEN_TREE_*'), # MOUNT_ATTR_SIZE_VER0 is used for mount_setattr. check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0')) sys.exit(status)