From 471a3549a96b3792db9f3bf038100ab8306efb4c Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Wed, 31 Jul 2013 20:01:52 +0100 Subject: [PATCH] Fix fasttrap ioctls and headers_check. These were being included before their structure definitions, leading to the possibility of wrong values for FASTTRAPIOC_*. Instead, split the FASTTRAPIOC* definitions into a new header, fasttrap_ioctl.h: this includes fasttrap.h to get the structure definitions, and is also included by it, so that either header can be included to get the ioctl definitions. We then extend "make headers_check" so that it does the extended ioctl checks on all headers named *ioctl.h, not just ioctl.h. (These checks are quite grotesque: we don't want to run them on every DTrace uapi header if that can be avoided.) Signed-off-by: Nick Alcock --- dtrace/Makefile | 8 ++-- dtrace/include/uapi/linux/dtrace/fasttrap.h | 12 ++++-- .../uapi/linux/dtrace/fasttrap_ioctl.h | 37 +++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 dtrace/include/uapi/linux/dtrace/fasttrap_ioctl.h diff --git a/dtrace/Makefile b/dtrace/Makefile index 94dc1d77ea20..d31fdcfd77c1 100644 --- a/dtrace/Makefile +++ b/dtrace/Makefile @@ -11,14 +11,14 @@ install:: modules_install %:: $(MAKE) -C $(KERNELDIR) M=`pwd` $@ -# One header, ioctl.h, has to be compiled in kernel mode so that typechecking -# is enabled. The rest get compiled in user mode. We go to some lengths -# to use any ioctl() identifiers, since typechecking only kicks in at +# Headers named *_ioctl.h have to be compiled in kernel mode so that +# typechecking is enabled. The rest get compiled in user mode. We go to some +# lengths to use any ioctl() identifiers, since typechecking only kicks in at # time of use. headers_check: @for name in $(notdir $(wildcard include/uapi/linux/dtrace/*.h)); do \ - if [[ $$name = ioctl.h ]]; then \ + if [[ $$name =~ .*ioctl\.h$$ ]]; then \ INC="-I../arch/x86/include -I../include -I../include/asm-generic -Iinclude -D__KERNEL__ -include linux/types.h -include dtrace/types.h"; \ else \ INC="-include sys/types.h -include sys/ctf_types.h -include unistd.h -I../include"; \ diff --git a/dtrace/include/uapi/linux/dtrace/fasttrap.h b/dtrace/include/uapi/linux/dtrace/fasttrap.h index fad93dc588e3..f707ed3d67e3 100644 --- a/dtrace/include/uapi/linux/dtrace/fasttrap.h +++ b/dtrace/include/uapi/linux/dtrace/fasttrap.h @@ -35,10 +35,6 @@ #include #include -#define FASTTRAPIOC 0xf4 -#define FASTTRAPIOC_MAKEPROBE _IOW(FASTTRAPIOC, 1, fasttrap_probe_spec_t) -#define FASTTRAPIOC_GETINSTR _IOR(FASTTRAPIOC, 2, fasttrap_instr_query_t) - typedef enum fasttrap_probe_type { DTFTP_NONE = 0, DTFTP_ENTRY, @@ -67,4 +63,12 @@ typedef struct fasttrap_instr_query { fasttrap_instr_t ftiq_instr; } fasttrap_instr_query_t; +/* + * Include after the definitions, to get ioctl()s when fasttrap.h is included. + * fasttrap_ioctl.h also #includes this header, to get structures when it is + * included itself, as is done by headers_check. + */ + +#include + #endif /* _LINUX_DTRACE_FASTTRAP_H */ diff --git a/dtrace/include/uapi/linux/dtrace/fasttrap_ioctl.h b/dtrace/include/uapi/linux/dtrace/fasttrap_ioctl.h new file mode 100644 index 000000000000..556563a7c536 --- /dev/null +++ b/dtrace/include/uapi/linux/dtrace/fasttrap_ioctl.h @@ -0,0 +1,37 @@ +/* Copyright (C) 2011, 2012, 2013 Oracle, Inc. */ + +#ifndef _LINUX_DTRACE_FASTRRAP_IOCTL_H_ +#define _LINUX_DTRACE_FASTTRAP_IOCTL_H_ + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2009 -- 2013 Oracle, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +#include + +#define FASTTRAPIOC 0xf4 +#define FASTTRAPIOC_MAKEPROBE _IOW(FASTTRAPIOC, 1, fasttrap_probe_spec_t) +#define FASTTRAPIOC_GETINSTR _IOR(FASTTRAPIOC, 2, fasttrap_instr_query_t) + +#endif /* _LINUX_DTRACE_FASTTRAP_IOCTL_H_ */ -- 2.50.1