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='System call list consistency checks') parser.add_argument('--cc', metavar='CC', required=True, help='C compiler (including options) to use') parser.add_argument('--lock', metavar='PATH', required=True, help='file to lock during the updates') parser.add_argument('arch_syscall', metavar='ARCH-SYSCALL-H', help='The <arch-syscall.h> file to update') parser.add_argument('names_list', metavar='SYSCALL-NAMES-LIST', help='The syscall name list to update ') args = parser.parse_args() kernel_constants = glibcsyscalls.kernel_constants(args.cc) with open(args.lock, 'r+') as lockfile: os.lockf(lockfile.fileno(), os.F_LOCK, 0) # Replace <arch-syscall.h> with data derived from kernel headers. # No merging is necessary here. Arch-specific changes should go # into <fixup-unistd-asm.h>. out = io.StringIO() out.write('/* AUTOGENERATED by update-syscall-lists.py. */\n') for name, value in sorted(kernel_constants.items()): out.write('#define __NR_{} {}\n'.format(name, value)) atomic_replace(args.arch_syscall, out.getvalue()) # Merge the architecture-specific system call names into the # global names list, syscall-names.list. This file contains names # from other architectures (and comments), so it is necessary to # merge the existing files with the names obtained from the # kernel. with open(args.names_list, 'r') as list_file: names_list = glibcsyscalls.SyscallNamesList(list_file) merged = names_list.merge(kernel_constants.keys()) out = io.StringIO() for line in merged: out.write(line) atomic_replace(args.names_list, out.getvalue())