GIT 11e0853234815944b9b3eadf1b913e9b833c1fd3 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild.git commit Author: Anton Blanchard Date: Tue Mar 20 09:47:47 2007 -0500 kbuild: small documentation fix in Documentation/kbuild/modules.txt The Makefile fragment in Documentation/kbuild/modules.txt looks to be missing some braces. Signed-off-by: Anton Blanchard Signed-off-by: Sam Ravnborg commit 4cb11ae33153712dbbef894b4f6e82ce63e92567 Author: Sam Ravnborg Date: Fri Mar 23 20:05:30 2007 +0100 kbuild: ignore section mismatch warning for references from .paravirtprobe to .init.text Added on request from: Rusty Russell Signed-off-by: Sam Ravnborg Cc: Rusty Russell commit 984d35ec37866c9b10c2193fcd1b1b5c6ee4c6cb Author: David Woodhouse Date: Wed Mar 21 11:20:51 2007 +0000 kbuild: exempt more syscalls from warnings, for x86_64 and ARM. Signed-off-by: David Woodhouse Signed-off-by: Sam Ravnborg commit 9ca09c1ca8e5f65ea9f7f0bb3de71cc70a0f6511 Author: David Miller Date: Thu Mar 8 16:14:07 2007 -0800 kbuild: ignore more i386 legacy syscalls The vast majority of them vector to sys_ni_syscall in the i386 syscall table. sys_ugetrlimit is only necessary if the platform started out using the non-SuS compliant sys_old_getrlimit() The rest, like ioperm, iopl, modify_ldt, et al. are i386 specific. Signed-off-by: David S. Miller Signed-off-by: Sam Ravnborg commit 5fbf06eb42fdaf81529d2433fe0953297cbc7cc6 Author: David Woodhouse Date: Thu Mar 8 23:01:13 2007 +0000 kbuild: complain about missing system calls. Most system calls seem to get added to i386 first. This patch automatically generates a warning for any new system call which is implemented on i386 but not the architecture currently being compiled. On PowerPC at the moment, for example, it results in these warnings: init/missing_syscalls.h:935:3: warning: #warning syscall sync_file_range not implemented init/missing_syscalls.h:947:3: warning: #warning syscall getcpu not implemented init/missing_syscalls.h:950:3: warning: #warning syscall epoll_pwait not implemented Other contributors to this patch are Russell King and Stéphane Jourdois Signed-off-by: David Woodhouse Signed-off-by: Sam Ravnborg commit 84b48a0275b4474587cefecb455372e8df6dabda Author: Sam Ravnborg Date: Tue Mar 20 21:30:23 2007 +0100 kbuild: do not emit src version warning for non-modules modpost is now called with .o files that are not modules. So do not warn if there is no corresponding .mod file listing .o files (in .tmp_versions/). Signed-off-by: Sam Ravnborg commit 390e9e4e19a0912103f1e721bb8fde52f6adf83c Author: Sam Ravnborg Date: Sun Mar 18 10:48:46 2007 +0100 menuconfig: remember alternate config filename When loading an alternate configuration use that file as current configuration filename. Make the filename visible in the dialog. Default continue to be .config. Inspired by patch from: Cyrill Gorcunov Signed-off-by: Sam Ravnborg Cc: Cyrill Gorcunov commit 1cc5a1206d596c24db484fab9ad77f143466dfc6 Author: Don Mullis Date: Thu Jan 4 10:14:52 2007 -0800 kbuild: move tags from ARCH and include/ ahead of drivers Move tags extracted from the ARCH and include/ sub-trees ahead of those from device drivers, so that the former will appear first during searches. Saves user time during interactive searches for certain patterns that happen to find unwanted matches in driver files. Example in emacs: "M-x find-tag PAGE_SIZE" "M-1 M-." (repeated until definition from asm-i386/page.h appears) Signed-off-by: Don Mullis Signed-off-by: Sam Ravnborg commit c28e6126918973ff0051d19bcfe63f6f2ecfac67 Author: Matthew Wilcox Date: Sat Oct 7 05:35:32 2006 -0600 kbuild: distinguish between errors and warnings in modpost Some of modpost's warnings are fatal, and some are not. Adopt the compiler distinction between errors and warnings by calling merror() for fatal diagnostics and warn() for non-fatal ones. merror() was used as replacemtn for error() to avoid clash with glibc Signed-off-by: Matthew Wilcox Signed-off-by: Sam Ravnborg commit fa1cb2f5e5b976bcca4cc785379945a7255aa2e6 Author: Marco Costalba Date: Thu Oct 5 19:12:59 2006 +0200 kconfig/xconfig: sync main view with search dialog current menu When changing current menu in search dialog update also main view Signed-off-by: Marco Costalba Signed-off-by: Sam Ravnborg commit 755791ec1864061cff09669e8c1fa4c66c67872c Author: Uwe Zeisberger Date: Thu Oct 5 16:24:45 2006 +0200 kbuild: add a missing slash in the comments Signed-off-by: Uwe Zeisberger Signed-off-by: Sam Ravnborg commit 6d6798029861cda0f2827b312880c88016e3c263 Author: Mike Frysinger Date: Sat Mar 17 02:37:07 2007 -0400 menuconfig: dont use obsolete index() function in lxdialog The index() function is obsolete, use strchr() instead. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg commit 6063e24b8b427703f4b7e50f2890fd9ed833de68 Author: H. Peter Anvin Date: Fri Mar 16 14:45:06 2007 -0700 cleanpatch: a script to clean up stealth whitespace added by a patch This script is a companion to the "cleanfile" script. This cleans up a patch in unified diff format *before* it is applied. Note that the empty lines at the end of file detection *requires* that the diff was taken with at least one line of context around each hunk, or bad things will happen. This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg commit 97ab0c3d089ec89fff4c755f338e1225edf46f32 Author: H. Peter Anvin Date: Mon Mar 12 12:16:30 2007 -0700 cleanfile: a script to clean up stealth whitespace This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg commit 991025496562b3bca0b353b6c59d56eca9d0a527 Author: Sam Ravnborg Date: Fri Mar 9 19:59:06 2007 +0100 kbuild: remove dependency on input.h from file2alias Almost all definitions used by file2alias was already present in mod_devicetable.h. Added the last definition and killed the input.h usage. The errornous include was pointed out by: Jan Engelhardt Signed-off-by: Sam Ravnborg Cc: Jan Engelhardt Cc: Deepak Saxena commit 471efbbee5c9b4850ba34f71ea6e4059806e7a58 Author: Sam Ravnborg Date: Sat Mar 3 19:34:23 2007 +0100 kbuild: silence section mismatch warnings for exported functions There are legitime cases of exported functions which is marked __init. Some examples are in drivers/pci/ where the pci subsystem export symbols to be used by other __init functions. So ignore references from ksymtab* to .init.text Signed-off-by: Sam Ravnborg commit 265d16fe001a7ab39f1b1f10f6b88af6e5f89ef2 Author: Sam Ravnborg Date: Tue Feb 27 09:14:58 2007 +0100 kbuild: whitelist logo references from .text to .init.data drivers/video/logo has references from .text to .init.data but function is only used during early init. So reference is OK and we do not want to warn about them => whitelist the reference. Signed-off-by: Sam Ravnborg commit 7407944f632dad431e07a94ef008317d12d6ca63 Author: Sam Ravnborg Date: Mon Feb 26 19:46:52 2007 +0100 kbuild: fix segmentation fault in modpost If modpost was called manually with filenames without '/' then modpost would segfault. Signed-off-by: Sam Ravnborg commit 1cd98a50660ea1d41d1872db3ee864976c1cf41b Author: Sam Ravnborg Date: Mon Feb 26 17:49:06 2007 +0100 kbuild: fix warnings from .pci_fixup section Now where we do not pass vmlinux to modpost we started to see section mismatch warnings from .pci_fixup. Refactored code a little to include these in the whitelist again. Signed-off-by: Sam Ravnborg commit 23f2d5ec2e212d04603f9f6ef0a25354d33fcbd3 Author: Sam Ravnborg Date: Mon Feb 26 16:45:41 2007 +0100 kbuild: whitelist section mismatch in init/main.c In init/main.c we have a reference from rest_init() to .init.text which is intentional. Rename the function 'init' to 'kernel_init' to make it a kernel wide unique symbol and whitelist the reference. Signed-off-by: Sam Ravnborg commit 7c76abc122d7910052a78795d6b8e30c4d5938cd Author: Sam Ravnborg Date: Mon Feb 26 15:33:52 2007 +0100 kbuild: fix section mismatch check for vmlinux vmlinux does not contain relocation entries which is used by the section mismatch checks. Reported by: Atsushi Nemoto Use the individual objects as inputs to overcome this limitation. In modpost check the .o files and skip non-ELF files. Signed-off-by: Sam Ravnborg Documentation/kbuild/modules.txt | 2 Makefile | 14 +-- include/linux/input.h | 4 + include/linux/mod_devicetable.h | 1 init/Makefile | 12 ++ init/main.c | 6 + init/missing_syscalls.c | 97 +++++++++++++++++ scripts/Makefile.modpost | 8 + scripts/cleanfile | 126 +++++++++++++++++++++++ scripts/cleanpatch | 206 +++++++++++++++++++++++++++++++++++++ scripts/kconfig/lxdialog/dialog.h | 1 scripts/kconfig/lxdialog/util.c | 9 +- scripts/kconfig/mconf.c | 43 ++++++-- scripts/kconfig/qconf.cc | 5 + scripts/kconfig/qconf.h | 2 scripts/mod/file2alias.c | 21 ++-- scripts/mod/modpost.c | 153 ++++++++++++++++++++++----- scripts/mod/modpost.h | 1 scripts/mod/sumversion.c | 5 - scripts/syscallchk | 6 + 20 files changed, 645 insertions(+), 77 deletions(-) diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 769ee05..1d247d5 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -249,7 +249,7 @@ following files: --> filename: Makefile KERNELDIR := /lib/modules/`uname -r`/build all:: - $(MAKE) -C $KERNELDIR M=`pwd` $@ + $(MAKE) -C $(KERNELDIR) M=`pwd` $@ # Module specific targets genbin: diff --git a/Makefile b/Makefile index 2f57f57..fc46238 100644 --- a/Makefile +++ b/Makefile @@ -576,7 +576,7 @@ # Build vmlinux # --------------------------------------------------------------------------- # vmlinux is built from the objects selected by $(vmlinux-init) and # $(vmlinux-main). Most are built-in.o files from top-level directories -# in the kernel tree, others are specified in arch/$(ARCH)Makefile. +# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. # Ordering when linking is important, and $(vmlinux-init) must be first. # # vmlinux @@ -603,6 +603,7 @@ vmlinux-init := $(head-y) $(init-y) vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) vmlinux-all := $(vmlinux-init) $(vmlinux-main) vmlinux-lds := arch/$(ARCH)/kernel/vmlinux.lds +export KBUILD_VMLINUX_OBJS := $(vmlinux-all) # Rule to link vmlinux - also used during CONFIG_KALLSYMS # May be overridden by arch/$(ARCH)/Makefile @@ -1277,10 +1278,7 @@ endif ALLSOURCE_ARCHS := $(ARCH) define find-sources - ( find $(__srctree) $(RCS_FIND_IGNORE) \ - \( -name include -o -name arch \) -prune -o \ - -name $1 -print; \ - for ARCH in $(ALLSOURCE_ARCHS) ; do \ + ( for ARCH in $(ALLSOURCE_ARCHS) ; do \ find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ -name $1 -print; \ done ; \ @@ -1294,7 +1292,11 @@ define find-sources -name $1 -print; \ done ; \ find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ - -name $1 -print ) + -name $1 -print; \ + find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch \) -prune -o \ + -name $1 -print; \ + ) endef define all-sources diff --git a/include/linux/input.h b/include/linux/input.h index bde65c8..13d510c 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -1010,6 +1010,10 @@ #if EV_MAX != INPUT_DEVICE_ID_EV_MAX #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" #endif +#if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING +#error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" +#endif + #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" #endif diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index e96b2de..af04a55 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -262,6 +262,7 @@ struct i2c_device_id { /* Input */ #define INPUT_DEVICE_ID_EV_MAX 0x1f +#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 #define INPUT_DEVICE_ID_KEY_MAX 0x1ff #define INPUT_DEVICE_ID_REL_MAX 0x0f #define INPUT_DEVICE_ID_ABS_MAX 0x3f diff --git a/init/Makefile b/init/Makefile index 0154aea..af9f529 100644 --- a/init/Makefile +++ b/init/Makefile @@ -2,7 +2,7 @@ # # Makefile for the linux kernel. # -obj-y := main.o version.o mounts.o +obj-y := main.o version.o mounts.o missing_syscalls.o ifneq ($(CONFIG_BLK_DEV_INITRD),y) obj-y += noinitramfs.o else @@ -21,6 +21,7 @@ clean-files := ../include/linux/compile. # dependencies on generated files need to be listed explicitly $(obj)/version.o: include/linux/compile.h +$(obj)/missing_syscalls.o: $(obj)/missing_syscalls.h # compile.h changes depending on hostname, generation number, etc, # so we regenerate it always. @@ -31,3 +32,12 @@ include/linux/compile.h: FORCE @echo ' CHK $@' $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(CFLAGS)" + + +quiet_cmd_missing_syscalls = GEN $@ + cmd_missing_syscalls = sed -n -f $(srctree)/scripts/syscallchk $< > $@ + +targets += missing_syscalls.h +$(obj)/missing_syscalls.h: include/asm-i386/unistd.h \ + $(srctree)/scripts/syscallchk $(src)/Makefile + $(call if_changed,missing_syscalls) diff --git a/init/main.c b/init/main.c index a92989e..7a92b4c 100644 --- a/init/main.c +++ b/init/main.c @@ -82,7 +82,7 @@ #if __GNUC__ == 4 && __GNUC_MINOR__ == 1 #warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended. #endif -static int init(void *); +static int kernel_init(void *); extern void init_IRQ(void); extern void fork_init(unsigned long); @@ -435,7 +435,7 @@ static void __init setup_command_line(ch static void noinline rest_init(void) __releases(kernel_lock) { - kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND); + kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); unlock_kernel(); @@ -772,7 +772,7 @@ static int noinline init_post(void) panic("No init found. Try passing init= option to kernel."); } -static int __init init(void * unused) +static int __init kernel_init(void * unused) { lock_kernel(); /* diff --git a/init/missing_syscalls.c b/init/missing_syscalls.c new file mode 100644 index 0000000..0b7e7d2 --- /dev/null +++ b/init/missing_syscalls.c @@ -0,0 +1,97 @@ +#include +#include + +/* Force recompilation (and thus warnings) every time we rebuild the kernel */ +#include + +/* System calls for 32-bit kernels only */ +#if BITS_PER_LONG == 64 +#define __IGNORE_sendfile64 +#define __IGNORE_ftruncate64 +#define __IGNORE_truncate64 +#define __IGNORE_stat64 +#define __IGNORE_lstat64 +#define __IGNORE_fstat64 +#define __IGNORE_fcntl64 +#define __IGNORE_fadvise64_64 +#define __IGNORE_fstatat64 +#define __IGNORE_fstatfs64 +#define __IGNORE_statfs64 +#endif + +/* i386-specific or historical system calls */ +#define __IGNORE_break +#define __IGNORE_stty +#define __IGNORE_gtty +#define __IGNORE_ftime +#define __IGNORE_prof +#define __IGNORE_lock +#define __IGNORE_mpx +#define __IGNORE_ulimit +#define __IGNORE_profil +#define __IGNORE_ioperm +#define __IGNORE_iopl +#define __IGNORE_idle +#define __IGNORE_modify_ldt +#define __IGNORE_ugetrlimit +#define __IGNORE_mmap2 +#define __IGNORE_vm86 +#define __IGNORE_vm86old +#define __IGNORE_set_thread_area +#define __IGNORE_get_thread_area +#define __IGNORE_madvise1 +#define __IGNORE_oldstat +#define __IGNORE_oldfstat +#define __IGNORE_oldlstat +#define __IGNORE_oldolduname +#define __IGNORE_olduname +#define __IGNORE_umount2 +#define __IGNORE_umount +#define __IGNORE_waitpid +#define __IGNORE_stime +#define __IGNORE_nice +#define __IGNORE_signal +#define __IGNORE_sigaction +#define __IGNORE_sgetmask +#define __IGNORE_sigsuspend +#define __IGNORE_sigpending +#define __IGNORE_readdir +#define __IGNORE_socketcall +#define __IGNORE_ipc +#define __IGNORE_sigreturn +#define __IGNORE_sigprocmask +#define __IGNORE_bdflush +#define __IGNORE__llseek +#define __IGNORE__newselect +#define __IGNORE_create_module +#define __IGNORE_delete_module +#define __IGNORE_query_module +#define __IGNORE_get_kernel_syms +/* ... including the "new" 32-bit uid syscalls */ +#define __IGNORE_lchown32 +#define __IGNORE_getuid32 +#define __IGNORE_getgid32 +#define __IGNORE_geteuid32 +#define __IGNORE_getegid32 +#define __IGNORE_setreuid32 +#define __IGNORE_setregid32 +#define __IGNORE_getgroups32 +#define __IGNORE_setgroups32 +#define __IGNORE_fchown32 +#define __IGNORE_setresuid32 +#define __IGNORE_getresuid32 +#define __IGNORE_setresgid32 +#define __IGNORE_getresgid32 +#define __IGNORE_chown32 +#define __IGNORE_setuid32 +#define __IGNORE_setgid32 +#define __IGNORE_setfsuid32 +#define __IGNORE_setfsgid32 + +/* Unmerged syscalls for AFS, STREAMS, etc. */ +#define __IGNORE_afs_syscall +#define __IGNORE_getpmsg +#define __IGNORE_putpmsg +#define __IGNORE_vserver + +#include "missing_syscalls.h" diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 65e0a79..d5bbbcc 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -63,16 +63,16 @@ quiet_cmd_modpost = MODPOST $(words $(fi $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ - $(wildcard vmlinux) $(filter-out FORCE,$^) + $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) PHONY += __modpost __modpost: $(modules:.ko=.o) FORCE - $(call cmd,modpost) + $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) quiet_cmd_kernel-mod = MODPOST $@ - cmd_kernel-mod = $(cmd_modpost) + cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) +PHONY += vmlinux vmlinux: FORCE $(call cmd,kernel-mod) diff --git a/scripts/cleanfile b/scripts/cleanfile new file mode 100755 index 0000000..f1ba8aa --- /dev/null +++ b/scripts/cleanfile @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w +# +# Clean a text file -- or directory of text files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + $blank_bytes = 0; + + @blanks = (); + @lines = (); + + while ( defined($line = ) ) { + $in_bytes += length($line); + $line =~ s/[ \t\r]*$//; # Remove trailing spaces + $line = clean_space_tabs($line); + + if ( $line eq "\n" ) { + push(@blanks, $line); + $blank_bytes += length($line); + } else { + push(@lines, @blanks); + $out_bytes += $blank_bytes; + push(@lines, $line); + $out_bytes += length($line); + @blanks = (); + $blank_bytes = 0; + } + } + + # Any blanks at the end of the file are discarded + + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + + close(FILE); +} diff --git a/scripts/cleanpatch b/scripts/cleanpatch new file mode 100755 index 0000000..a53f987 --- /dev/null +++ b/scripts/cleanpatch @@ -0,0 +1,206 @@ +#!/usr/bin/perl -w +# +# Clean a patch file -- or directory of patch files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + + @lines = (); + + $in_hunk = 0; + $err = 0; + + while ( defined($line = ) ) { + $in_bytes += length($line); + + if (!$in_hunk) { + if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { + $minus_lines = $2; + $plus_lines = $4; + if ($minus_lines || $plus_lines) { + $in_hunk = 1; + @hunk_lines = ($line); + } + } else { + push(@lines, $line); + $out_bytes += length($line); + } + } else { + # We're in a hunk + + if ($line =~ /^\+/) { + $plus_lines--; + + $text = substr($line, 1); + $text =~ s/[ \t\r]*$//; # Remove trailing spaces + $text = clean_space_tabs($text); + + push(@hunk_lines, '+'.$text); + } elsif ($line =~ /^\-/) { + $minus_lines--; + push(@hunk_lines, $line); + } elsif ($line =~ /^ /) { + $plus_lines--; + $minus_lines--; + push(@hunk_lines, $line); + } else { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } + + if ($plus_lines < 0 || $minus_lines < 0) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } elsif ($plus_lines == 0 && $minus_lines == 0) { + # End of a hunk. Process this hunk. + my $i; + my $l; + my @h = (); + my $adj = 0; + my $done = 0; + + for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) { + $l = $hunk_lines[$i]; + if (!$done && $l eq "+\n") { + $adj++; # Skip this line + } elsif ($l =~ /^[ +]/) { + $done = 1; + unshift(@h, $l); + } else { + unshift(@h, $l); + } + } + + $l = $hunk_lines[0]; # Hunk header + undef @hunk_lines; # Free memory + + if ($adj) { + die unless + ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/); + my $mstart = $1; + my $mlin = $2; + my $pstart = $3; + my $plin = $4; + my $tail = $5; # doesn't include the final newline + + $l = sprintf("@@ -%d,%d +%d,%d @@%s\n", + $mstart, $mlin, $pstart, $plin-$adj, + $tail); + } + unshift(@h, $l); + + # Transfer to the output array + foreach $l (@h) { + $out_bytes += length($l); + push(@lines, $l); + } + + $in_hunk = 0; + } + } + } + + if ($in_hunk) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + } + + if (!$err) { + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + } + + close(FILE); +} diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index fd695e1..7e17eba 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win); int on_key_resize(void); void init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); void reset_dialog(void); void end_dialog(void); void attr_clear(WINDOW * win, int height, int width, chtype attr); diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index d54440f..a1bddef 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -272,6 +272,11 @@ void init_dialog(const char *backtitle) color_setup(getenv("MENUCONFIG_COLOR")); } +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + void reset_dialog(void) { initscr(); /* Init curses */ @@ -336,7 +341,7 @@ void print_autowrap(WINDOW * win, const newl = 1; word = tempstr; while (word && *word) { - sp = index(word, ' '); + sp = strchr(word, ' '); if (sp) *sp++ = 0; @@ -348,7 +353,7 @@ void print_autowrap(WINDOW * win, const if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room - && (!(sp2 = index(sp, ' ')) + && (!(sp2 = strchr(sp, ' ')) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 3f9a132..462256d 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -26,7 +26,6 @@ #define LKC_DIRECT_LINK #include "lkc.h" #include "lxdialog/dialog.h" -static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" "--------\n" @@ -271,7 +270,6 @@ search_help[] = N_( " USB$ => find all CONFIG_ symbols ending with USB\n" "\n"); -static char filename[PATH_MAX+1] = ".config"; static int indent; static struct termios ios_org; static int rows = 0, cols = 0; @@ -395,6 +393,28 @@ static struct gstr get_relations_str(str return res; } +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + struct symbol *sym; + + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + _("%s - Linux Kernel v%s Configuration"), + config_filename, sym_get_string_value(sym)); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + + static void search_conf(void) { struct symbol **sym_arr; @@ -816,8 +836,10 @@ static void conf_load(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_read(dialog_input_result)) + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: @@ -840,8 +862,10 @@ static void conf_save(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_write(dialog_input_result)) + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: @@ -860,7 +884,6 @@ static void conf_cleanup(void) int main(int ac, char **av) { - struct symbol *sym; char *mode; int res; @@ -871,11 +894,6 @@ int main(int ac, char **av) conf_parse(av[1]); conf_read(NULL); - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); - sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), - sym_get_string_value(sym)); - mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) @@ -886,7 +904,8 @@ int main(int ac, char **av) atexit(conf_cleanup); init_wsize(); reset_dialog(); - init_dialog(menu_backtitle); + init_dialog(NULL); + set_config_filename(".config"); do { conf(&rootmenu); dialog_clear(); @@ -903,7 +922,7 @@ int main(int ac, char **av) switch (res) { case 0: - if (conf_write(NULL)) { + if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 512c2f5..f2a23a9 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1182,7 +1182,7 @@ void ConfigInfoView::contentsContextMenu Parent::contentsContextMenuEvent(e); } -ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name) +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) : Parent(parent, name), result(NULL) { setCaption("Search Config"); @@ -1206,6 +1206,9 @@ ConfigSearchWindow::ConfigSearchWindow(Q info = new ConfigInfoView(split, name); connect(list->list, SIGNAL(menuChanged(struct menu *)), info, SLOT(setInfo(struct menu *))); + connect(list->list, SIGNAL(menuChanged(struct menu *)), + parent, SLOT(setMenuLink(struct menu *))); + layout1->addWidget(split); if (name) { diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 6fc1c5f..b3b5657 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -279,7 +279,7 @@ class ConfigSearchWindow : public QDialo Q_OBJECT typedef class QDialog Parent; public: - ConfigSearchWindow(QWidget* parent, const char *name = 0); + ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); public slots: void saveSettings(void); diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b2f73ff..ed1244d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -37,7 +37,6 @@ typedef unsigned char __u8; * even potentially has different endianness and word sizes, since * we handle those differences explicitly below */ #include "../../include/linux/mod_devicetable.h" -#include "../../include/linux/input.h" #define ADD(str, sep, cond, field) \ do { \ @@ -416,31 +415,33 @@ static int do_input_entry(const char *fi sprintf(alias + strlen(alias), "-e*"); if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) - do_input(alias, id->evbit, 0, EV_MAX); + do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); sprintf(alias + strlen(alias), "k*"); if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) - do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX); + do_input(alias, id->keybit, + INPUT_DEVICE_ID_KEY_MIN_INTERESTING, + INPUT_DEVICE_ID_KEY_MAX); sprintf(alias + strlen(alias), "r*"); if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) - do_input(alias, id->relbit, 0, REL_MAX); + do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); sprintf(alias + strlen(alias), "a*"); if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) - do_input(alias, id->absbit, 0, ABS_MAX); + do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); sprintf(alias + strlen(alias), "m*"); if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) - do_input(alias, id->mscbit, 0, MSC_MAX); + do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); sprintf(alias + strlen(alias), "l*"); if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) - do_input(alias, id->ledbit, 0, LED_MAX); + do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); sprintf(alias + strlen(alias), "s*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) - do_input(alias, id->sndbit, 0, SND_MAX); + do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); sprintf(alias + strlen(alias), "f*"); if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) - do_input(alias, id->ffbit, 0, FF_MAX); + do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); sprintf(alias + strlen(alias), "w*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) - do_input(alias, id->swbit, 0, SW_MAX); + do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); return 1; } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 65bdfdb..e7d3d53 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -55,6 +55,17 @@ void warn(const char *fmt, ...) va_end(arglist); } +void merror(const char *fmt, ...) +{ + va_list arglist; + + fprintf(stderr, "ERROR: "); + + va_start(arglist, fmt); + vfprintf(stderr, fmt, arglist); + va_end(arglist); +} + static int is_vmlinux(const char *modname) { const char *myname; @@ -333,10 +344,10 @@ void release_file(void *file, unsigned l munmap(file, size); } -static void parse_elf(struct elf_info *info, const char *filename) +static int parse_elf(struct elf_info *info, const char *filename) { unsigned int i; - Elf_Ehdr *hdr = info->hdr; + Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *sym; @@ -346,9 +357,18 @@ static void parse_elf(struct elf_info *i exit(1); } info->hdr = hdr; - if (info->size < sizeof(*hdr)) - goto truncated; - + if (info->size < sizeof(*hdr)) { + /* file too small, assume this is an empty .o file */ + return 0; + } + /* Is this a valid ELF file? */ + if ((hdr->e_ident[EI_MAG0] != ELFMAG0) || + (hdr->e_ident[EI_MAG1] != ELFMAG1) || + (hdr->e_ident[EI_MAG2] != ELFMAG2) || + (hdr->e_ident[EI_MAG3] != ELFMAG3)) { + /* Not an ELF file - silently ignore it */ + return 0; + } /* Fix endianness in ELF header */ hdr->e_shoff = TO_NATIVE(hdr->e_shoff); hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); @@ -371,8 +391,10 @@ static void parse_elf(struct elf_info *i = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; const char *secname; - if (sechdrs[i].sh_offset > info->size) - goto truncated; + if (sechdrs[i].sh_offset > info->size) { + fatal("%s is truncated. sechdrs[i].sh_offset=%u > sizeof(*hrd)=%ul\n", filename, (unsigned int)sechdrs[i].sh_offset, sizeof(*hdr)); + return 0; + } secname = secstrings + sechdrs[i].sh_name; if (strcmp(secname, ".modinfo") == 0) { info->modinfo = (void *)hdr + sechdrs[i].sh_offset; @@ -407,10 +429,7 @@ static void parse_elf(struct elf_info *i sym->st_value = TO_NATIVE(sym->st_value); sym->st_size = TO_NATIVE(sym->st_size); } - return; - - truncated: - fatal("%s is truncated.\n", filename); + return 1; } static void parse_elf_finish(struct elf_info *info) @@ -581,9 +600,17 @@ static int strrcmp(const char *s, const * the pattern is identified by: * tosec = .init.text | .exit.text | .init.data * fromsec = .data - * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one + * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console * * Pattern 3: + * Whitelist all references from .pci_fixup* section to .init.text + * This is part of the PCI init when built-in + * + * Pattern 4: + * Whitelist all refereces from .text.head to .init.data + * Whitelist all refereces from .text.head to .init.text + * + * Pattern 5: * Some symbols belong to init section but still it is ok to reference * these from non-init sections as these symbols don't have any memory * allocated for them and symbol address and value are same. So even @@ -591,6 +618,37 @@ static int strrcmp(const char *s, const * For ex. symbols marking the init section boundaries. * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext + * + * Pattern 6: + * During the early init phase we have references from .init.text to + * .text we have an intended section mismatch - do not warn about it. + * See kernel_init() in init/main.c + * tosec = .init.text + * fromsec = .text + * atsym = kernel_init + * + * Pattern 7: + * Logos used in drivers/video/logo reside in __initdata but the + * funtion that references them are EXPORT_SYMBOL() so cannot be + * marker __init. So we whitelist them here. + * The pattern is: + * tosec = .init.data + * fromsec = .text* + * refsymname = logo_ + * + * Pattern 8: + * Symbols exported may be marked __init because we need to + * export functions that are only used by init function. + * The pattern is: + * tosec = .init.text + * fromsec = __ksymtab* + * + * Pattern 9: + * Symbols contained in .paravirtprobe amy safely reference + * .init.text. + * The pattern is: + * tosec = .init.text + * fromsec = .paravirtprobe **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -641,25 +699,44 @@ static int secref_whitelist(const char * if (f1 && f2) return 1; - /* Whitelist all references from .pci_fixup section if vmlinux - * Whitelist all refereces from .text.head to .init.data if vmlinux - * Whitelist all refereces from .text.head to .init.text if vmlinux - */ - if (is_vmlinux(modname)) { - if ((strcmp(fromsec, ".pci_fixup") == 0) && - (strcmp(tosec, ".init.text") == 0)) + /* Check for pattern 3 */ + if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) && + (strcmp(tosec, ".init.text") == 0)) + return 1; + + /* Check for pattern 4 */ + if ((strcmp(fromsec, ".text.head") == 0) && + ((strcmp(tosec, ".init.data") == 0) || + (strcmp(tosec, ".init.text") == 0))) + return 1; + + /* Check for pattern 5 */ + for (s = pat3refsym; *s; s++) + if (strcmp(refsymname, *s) == 0) + return 1; + + /* Check for pattern 6 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".text") == 0) && + (strcmp(refsymname, "kernel_init") == 0)) return 1; - if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) + /* Check for pattern 7 */ + if ((strcmp(tosec, ".init.data") == 0) && + (strncmp(fromsec, ".text", strlen(".text")) == 0) && + (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) + return 1; + + /* Check for pattern 8 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strncmp(fromsec, "__ksymtab", strlen("__ksymtab")) == 0)) + return 1; + + /* Check for pattern 9 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".paravirtprobe") == 0)) return 1; - /* Check for pattern 3 */ - for (s = pat3refsym; *s; s++) - if (strcmp(refsymname, *s) == 0) - return 1; - } return 0; } @@ -1089,7 +1166,8 @@ static void read_symbols(char *modname) struct elf_info info = { }; Elf_Sym *sym; - parse_elf(&info, modname); + if (!parse_elf(&info, modname)) + return; mod = new_module(modname); @@ -1264,9 +1342,14 @@ static int add_versions(struct buffer *b exp = find_symbol(s->name); if (!exp || exp->module == mod) { if (have_vmlinux && !s->weak) { - warn("\"%s\" [%s.ko] undefined!\n", - s->name, mod->name); - err = warn_unresolved ? 0 : 1; + if (warn_unresolved) { + warn("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + } else { + merror("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + err = 1; + } } continue; } @@ -1317,6 +1400,7 @@ static void add_depends(struct buffer *b buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); buf_printf(b, "\"depends="); for (s = mod->unres; s; s = s->next) { + const char *p; if (!s->module) continue; @@ -1324,8 +1408,11 @@ static void add_depends(struct buffer *b continue; s->module->seen = 1; - buf_printf(b, "%s%s", first ? "" : ",", - strrchr(s->module->name, '/') + 1); + if ((p = strrchr(s->module->name, '/')) != NULL) + p++; + else + p = s->module->name; + buf_printf(b, "%s%s", first ? "" : ",", p); first = 0; } buf_printf(b, "\";\n"); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index d398c61..0858caa 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -145,3 +145,4 @@ void release_file(void *file, unsigned l void fatal(const char *fmt, ...); void warn(const char *fmt, ...); +void merror(const char *fmt, ...); diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 8a28756..6873d5a 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -397,10 +397,9 @@ void get_src_version(const char *modname (int) strlen(basename) - 2, basename); file = grab_file(filelist, &len); - if (!file) { - warn("could not find versions for %s\n", filelist); + if (!file) + /* not a module or .mod file missing - ignore */ return; - } sources = strchr(file, '\n'); if (!sources) { diff --git a/scripts/syscallchk b/scripts/syscallchk new file mode 100644 index 0000000..d545717 --- /dev/null +++ b/scripts/syscallchk @@ -0,0 +1,6 @@ +/^\#define/ { + s/[^_]*__NR_\([^[:space:]]*\).*/\ +\#if !defined (__NR_\1) \&\& !defined (__IGNORE_\1)\ +\#warning syscall \1 not implemented\ +\#endif/p +}