diff --git a/[refs] b/[refs] index bf93e16df25c..5067405d692d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 82810a906f8734ae6503ea11436a7164d2f86f2e +refs/heads/master: f16af555cc46a724507da371fbac94b430c93315 diff --git a/trunk/Documentation/Changes b/trunk/Documentation/Changes index 27232be26e1a..5eaab0441d76 100644 --- a/trunk/Documentation/Changes +++ b/trunk/Documentation/Changes @@ -237,12 +237,6 @@ udev udev is a userspace application for populating /dev dynamically with only entries for devices actually present. udev replaces devfs. -FUSE ----- - -Needs libfuse 2.4.0 or later. Absolute minimum is 2.3.0 but mount -options 'direct_io' and 'kernel_cache' won't work. - Networking ========== @@ -396,10 +390,6 @@ udev ---- o -FUSE ----- -o - Networking ********** diff --git a/trunk/Documentation/keys.txt b/trunk/Documentation/keys.txt index b22e7c8d059a..0321ded4b9ae 100644 --- a/trunk/Documentation/keys.txt +++ b/trunk/Documentation/keys.txt @@ -195,8 +195,8 @@ KEY ACCESS PERMISSIONS ====================== Keys have an owner user ID, a group access ID, and a permissions mask. The mask -has up to eight bits each for possessor, user, group and other access. Only -five of each set of eight bits are defined. These permissions granted are: +has up to eight bits each for user, group and other access. Only five of each +set of eight bits are defined. These permissions granted are: (*) View @@ -241,16 +241,16 @@ about the status of the key service: type, description and permissions. The payload of the key is not available this way: - SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY - 00000001 I----- 39 perm 1f1f0000 0 0 keyring _uid_ses.0: 1/4 - 00000002 I----- 2 perm 1f1f0000 0 0 keyring _uid.0: empty - 00000007 I----- 1 perm 1f1f0000 0 0 keyring _pid.1: empty - 0000018d I----- 1 perm 1f1f0000 0 0 keyring _pid.412: empty - 000004d2 I--Q-- 1 perm 1f1f0000 32 -1 keyring _uid.32: 1/4 - 000004d3 I--Q-- 3 perm 1f1f0000 32 -1 keyring _uid_ses.32: empty - 00000892 I--QU- 1 perm 1f000000 0 0 user metal:copper: 0 - 00000893 I--Q-N 1 35s 1f1f0000 0 0 user metal:silver: 0 - 00000894 I--Q-- 1 10h 001f0000 0 0 user metal:gold: 0 + SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY + 00000001 I----- 39 perm 1f0000 0 0 keyring _uid_ses.0: 1/4 + 00000002 I----- 2 perm 1f0000 0 0 keyring _uid.0: empty + 00000007 I----- 1 perm 1f0000 0 0 keyring _pid.1: empty + 0000018d I----- 1 perm 1f0000 0 0 keyring _pid.412: empty + 000004d2 I--Q-- 1 perm 1f0000 32 -1 keyring _uid.32: 1/4 + 000004d3 I--Q-- 3 perm 1f0000 32 -1 keyring _uid_ses.32: empty + 00000892 I--QU- 1 perm 1f0000 0 0 user metal:copper: 0 + 00000893 I--Q-N 1 35s 1f0000 0 0 user metal:silver: 0 + 00000894 I--Q-- 1 10h 1f0000 0 0 user metal:gold: 0 The flags are: @@ -637,34 +637,6 @@ call, and the key released upon close. How to deal with conflicting keys due to two different users opening the same file is left to the filesystem author to solve. -Note that there are two different types of pointers to keys that may be -encountered: - - (*) struct key * - - This simply points to the key structure itself. Key structures will be at - least four-byte aligned. - - (*) key_ref_t - - This is equivalent to a struct key *, but the least significant bit is set - if the caller "possesses" the key. By "possession" it is meant that the - calling processes has a searchable link to the key from one of its - keyrings. There are three functions for dealing with these: - - key_ref_t make_key_ref(const struct key *key, - unsigned long possession); - - struct key *key_ref_to_ptr(const key_ref_t key_ref); - - unsigned long is_key_possessed(const key_ref_t key_ref); - - The first function constructs a key reference from a key pointer and - possession information (which must be 0 or 1 and not any other value). - - The second function retrieves the key pointer from a reference and the - third retrieves the possession flag. - When accessing a key's payload contents, certain precautions must be taken to prevent access vs modification races. See the section "Notes on accessing payload contents" for more information. @@ -693,11 +665,7 @@ payload contents" for more information. void key_put(struct key *key); - Or: - - void key_ref_put(key_ref_t key_ref); - - These can be called from interrupt context. If CONFIG_KEYS is not set then + This can be called from interrupt context. If CONFIG_KEYS is not set then the argument will not be parsed. @@ -721,17 +689,13 @@ payload contents" for more information. (*) If a keyring was found in the search, this can be further searched by: - key_ref_t keyring_search(key_ref_t keyring_ref, - const struct key_type *type, - const char *description) + struct key *keyring_search(struct key *keyring, + const struct key_type *type, + const char *description) This searches the keyring tree specified for a matching key. Error ENOKEY - is returned upon failure (use IS_ERR/PTR_ERR to determine). If successful, - the returned key will need to be released. - - The possession attribute from the keyring reference is used to control - access through the permissions mask and is propagated to the returned key - reference pointer if successful. + is returned upon failure. If successful, the returned key will need to be + released. (*) To check the validity of a key, this function can be called: @@ -768,7 +732,7 @@ More complex payload contents must be allocated and a pointer to them set in key->payload.data. One of the following ways must be selected to access the data: - (1) Unmodifiable key type. + (1) Unmodifyable key type. If the key type does not have a modify method, then the key's payload can be accessed without any form of locking, provided that it's known to be diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index c1bc9a86a99d..7d1dd5bad39a 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -604,15 +604,6 @@ P: H. Peter Anvin M: hpa@zytor.com S: Maintained -CPUSETS -P: Paul Jackson -P: Simon Derr -M: pj@sgi.com -M: simon.derr@bull.net -L: linux-kernel@vger.kernel.org -W: http://www.bullopensource.org/cpuset/ -S: Supported - CRAMFS FILESYSTEM W: http://sourceforge.net/projects/cramfs/ S: Orphan @@ -1915,13 +1906,6 @@ M: joern@wh.fh-wedel.de L: linux-mtd@lists.infradead.org S: Maintained -PKTCDVD DRIVER -P: Peter Osterlund -M: petero2@telia.com -L: linux-kernel@vger.kernel.org -L: packet-writing@suse.com -S: Maintained - POSIX CLOCKS and TIMERS P: George Anzinger M: george@mvista.com diff --git a/trunk/arch/arm/mach-versatile/core.c b/trunk/arch/arm/mach-versatile/core.c index 58c1330d8638..3c8862fde51a 100644 --- a/trunk/arch/arm/mach-versatile/core.c +++ b/trunk/arch/arm/mach-versatile/core.c @@ -52,9 +52,8 @@ * * Setup a VA for the Versatile Vectored Interrupt Controller. */ -#define __io_address(n) __io(IO_ADDRESS(n)) -#define VA_VIC_BASE __io_address(VERSATILE_VIC_BASE) -#define VA_SIC_BASE __io_address(VERSATILE_SIC_BASE) +#define VA_VIC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) +#define VA_SIC_BASE IO_ADDRESS(VERSATILE_SIC_BASE) static void vic_mask_irq(unsigned int irq) { @@ -215,7 +214,7 @@ void __init versatile_map_io(void) iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc)); } -#define VERSATILE_REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) +#define VERSATILE_REFCOUNTER (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) /* * This is the Versatile sched_clock implementation. This has @@ -232,7 +231,7 @@ unsigned long long sched_clock(void) } -#define VERSATILE_FLASHCTRL (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET) +#define VERSATILE_FLASHCTRL (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET) static int versatile_flash_init(void) { @@ -310,7 +309,7 @@ static struct platform_device smc91x_device = { .resource = smc91x_resources, }; -#define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) +#define VERSATILE_SYSMCI (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) unsigned int mmc_status(struct device *dev) { @@ -344,11 +343,11 @@ static const struct icst307_params versatile_oscvco_params = { static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco) { - void __iomem *sys_lock = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET; + unsigned long sys_lock = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET; #if defined(CONFIG_ARCH_VERSATILE_PB) - void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET; + unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET; #elif defined(CONFIG_MACH_VERSATILE_AB) - void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET; + unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET; #endif u32 val; @@ -484,7 +483,7 @@ static struct clcd_panel epson_2_2_in = { */ static struct clcd_panel *versatile_clcd_panel(void) { - void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; + unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; struct clcd_panel *panel = &vga; u32 val; @@ -511,7 +510,7 @@ static struct clcd_panel *versatile_clcd_panel(void) */ static void versatile_clcd_disable(struct clcd_fb *fb) { - void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; + unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; u32 val; val = readl(sys_clcd); @@ -523,7 +522,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb) * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off */ if (fb->panel == &sanyo_2_5_in) { - void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL); + unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); unsigned long ctrl; ctrl = readl(versatile_ib2_ctrl); @@ -538,7 +537,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb) */ static void versatile_clcd_enable(struct clcd_fb *fb) { - void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; + unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; u32 val; val = readl(sys_clcd); @@ -572,7 +571,7 @@ static void versatile_clcd_enable(struct clcd_fb *fb) * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on */ if (fb->panel == &sanyo_2_5_in) { - void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL); + unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); unsigned long ctrl; ctrl = readl(versatile_ib2_ctrl); @@ -721,7 +720,7 @@ static struct amba_device *amba_devs[] __initdata = { }; #ifdef CONFIG_LEDS -#define VA_LEDS_BASE (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) +#define VA_LEDS_BASE (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) static void versatile_leds_event(led_event_t ledevt) { @@ -779,11 +778,11 @@ void __init versatile_init(void) /* * Where is the timer (VA)? */ -#define TIMER0_VA_BASE __io_address(VERSATILE_TIMER0_1_BASE) -#define TIMER1_VA_BASE (__io_address(VERSATILE_TIMER0_1_BASE) + 0x20) -#define TIMER2_VA_BASE __io_address(VERSATILE_TIMER2_3_BASE) -#define TIMER3_VA_BASE (__io_address(VERSATILE_TIMER2_3_BASE) + 0x20) -#define VA_IC_BASE __io_address(VERSATILE_VIC_BASE) +#define TIMER0_VA_BASE IO_ADDRESS(VERSATILE_TIMER0_1_BASE) +#define TIMER1_VA_BASE (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20) +#define TIMER2_VA_BASE IO_ADDRESS(VERSATILE_TIMER2_3_BASE) +#define TIMER3_VA_BASE (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20) +#define VA_IC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) /* * How long is the timer interval? @@ -878,12 +877,12 @@ static void __init versatile_timer_init(void) * VERSATILE_REFCLK is 32KHz * VERSATILE_TIMCLK is 1MHz */ - val = readl(__io_address(VERSATILE_SCTL_BASE)); + val = readl(IO_ADDRESS(VERSATILE_SCTL_BASE)); writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, - __io_address(VERSATILE_SCTL_BASE)); + IO_ADDRESS(VERSATILE_SCTL_BASE)); /* * Initialise to a known state (all timers off) diff --git a/trunk/arch/ppc/boot/ld.script b/trunk/arch/ppc/boot/ld.script index d4dd8f15395e..9362193742ac 100644 --- a/trunk/arch/ppc/boot/ld.script +++ b/trunk/arch/ppc/boot/ld.script @@ -1,4 +1,4 @@ -OUTPUT_ARCH(powerpc:common) +OUTPUT_ARCH(powerpc) SECTIONS { /* Read-only sections, merged into text segment: */ diff --git a/trunk/arch/ppc/kernel/perfmon.c b/trunk/arch/ppc/kernel/perfmon.c index 22df9a596a0f..04c18788e85f 100644 --- a/trunk/arch/ppc/kernel/perfmon.c +++ b/trunk/arch/ppc/kernel/perfmon.c @@ -45,8 +45,9 @@ static void dummy_perf(struct pt_regs *regs) mtpmr(PMRN_PMGC0, pmgc0); } -#elif defined(CONFIG_6xx) +#elif CONFIG_6xx /* Ensure exceptions are disabled */ + static void dummy_perf(struct pt_regs *regs) { unsigned int mmcr0 = mfspr(SPRN_MMCR0); diff --git a/trunk/arch/ppc/syslib/mv64x60.c b/trunk/arch/ppc/syslib/mv64x60.c index 4849850a59ed..839f8872826f 100644 --- a/trunk/arch/ppc/syslib/mv64x60.c +++ b/trunk/arch/ppc/syslib/mv64x60.c @@ -34,7 +34,7 @@ u8 mv64x60_pci_exclude_bridge = 1; DEFINE_SPINLOCK(mv64x60_lock); static phys_addr_t mv64x60_bridge_pbase; -static void __iomem *mv64x60_bridge_vbase; +static void *mv64x60_bridge_vbase; static u32 mv64x60_bridge_type = MV64x60_TYPE_INVALID; static u32 mv64x60_bridge_rev; #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) @@ -938,7 +938,7 @@ mv64x60_setup_for_chip(struct mv64x60_handle *bh) * * Return the virtual address of the bridge's registers. */ -void __iomem * +void * mv64x60_get_bridge_vbase(void) { return mv64x60_bridge_vbase; diff --git a/trunk/arch/ppc64/kernel/machine_kexec.c b/trunk/arch/ppc64/kernel/machine_kexec.c index bf7cc4f8210f..4775f12a013c 100644 --- a/trunk/arch/ppc64/kernel/machine_kexec.c +++ b/trunk/arch/ppc64/kernel/machine_kexec.c @@ -205,7 +205,6 @@ static void kexec_prepare_cpus(void) continue; while (paca[i].hw_cpu_id != -1) { - barrier(); if (!cpu_possible(i)) { printk("kexec: cpu %d hw_cpu_id %d is not" " possible, ignoring\n", diff --git a/trunk/arch/ppc64/mm/hash_native.c b/trunk/arch/ppc64/mm/hash_native.c index bfd385b7713c..eb1bbb5b6c16 100644 --- a/trunk/arch/ppc64/mm/hash_native.c +++ b/trunk/arch/ppc64/mm/hash_native.c @@ -343,7 +343,7 @@ static void native_flush_hash_range(unsigned long context, hpte_t *hptep; unsigned long hpte_v; struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); - unsigned long large = batch->large; + unsigned long large; local_irq_save(flags); @@ -356,6 +356,7 @@ static void native_flush_hash_range(unsigned long context, va = (vsid << 28) | (batch->addr[i] & 0x0fffffff); batch->vaddr[j] = va; + large = pte_huge(batch->pte[i]); if (large) vpn = va >> HPAGE_SHIFT; else @@ -405,7 +406,7 @@ static void native_flush_hash_range(unsigned long context, asm volatile("ptesync":::"memory"); for (i = 0; i < j; i++) - __tlbie(batch->vaddr[i], large); + __tlbie(batch->vaddr[i], 0); asm volatile("eieio; tlbsync; ptesync":::"memory"); diff --git a/trunk/arch/ppc64/mm/tlb.c b/trunk/arch/ppc64/mm/tlb.c index 21fbffb23a43..d8a6593a13f0 100644 --- a/trunk/arch/ppc64/mm/tlb.c +++ b/trunk/arch/ppc64/mm/tlb.c @@ -143,8 +143,7 @@ void hpte_update(struct mm_struct *mm, unsigned long addr, * up scanning and resetting referenced bits then our batch context * will change mid stream. */ - if (i != 0 && (context != batch->context || - batch->large != pte_huge(pte))) { + if (unlikely(i != 0 && context != batch->context)) { flush_tlb_pending(); i = 0; } @@ -152,7 +151,6 @@ void hpte_update(struct mm_struct *mm, unsigned long addr, if (i == 0) { batch->context = context; batch->mm = mm; - batch->large = pte_huge(pte); } batch->pte[i] = __pte(pte); batch->addr[i] = addr; diff --git a/trunk/arch/s390/kernel/compat_signal.c b/trunk/arch/s390/kernel/compat_signal.c index 4ff6808456ea..7358cdb8441f 100644 --- a/trunk/arch/s390/kernel/compat_signal.c +++ b/trunk/arch/s390/kernel/compat_signal.c @@ -143,7 +143,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) break; case __SI_FAULT >> 16: err |= __get_user(tmp, &from->si_addr); - to->si_addr = (void __user *)(u64) (tmp & PSW32_ADDR_INSN); + to->si_addr = (void *)(u64) (tmp & PSW32_ADDR_INSN); break; case __SI_POLL >> 16: err |= __get_user(to->si_band, &from->si_band); @@ -338,7 +338,7 @@ sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss, err |= __get_user(kss.ss_flags, &uss->ss_flags); if (err) return -EFAULT; - kss.ss_sp = (void __user *) ss_sp; + kss.ss_sp = (void *) ss_sp; } set_fs (KERNEL_DS); @@ -461,7 +461,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs) goto badframe; err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp); - st.ss_sp = compat_ptr(ss_sp); + st.ss_sp = (void *) A((unsigned long)ss_sp); err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size); err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags); if (err) diff --git a/trunk/arch/s390/kernel/signal.c b/trunk/arch/s390/kernel/signal.c index 6e0110d71191..6a3f5b7473a9 100644 --- a/trunk/arch/s390/kernel/signal.c +++ b/trunk/arch/s390/kernel/signal.c @@ -376,8 +376,8 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, /* Create the ucontext. */ err |= __put_user(0, &frame->uc.uc_flags); - err |= __put_user(NULL, &frame->uc.uc_link); - err |= __put_user((void __user *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); + err |= __put_user(0, &frame->uc.uc_link); + err |= __put_user((void *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); err |= __put_user(sas_ss_flags(regs->gprs[15]), &frame->uc.uc_stack.ss_flags); err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); diff --git a/trunk/arch/um/Makefile b/trunk/arch/um/Makefile index 7af37e342e33..5b5af95721ab 100644 --- a/trunk/arch/um/Makefile +++ b/trunk/arch/um/Makefile @@ -28,6 +28,8 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h +GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h + um-modes-$(CONFIG_MODE_TT) += tt um-modes-$(CONFIG_MODE_SKAS) += skas @@ -43,7 +45,9 @@ endif ARCH_INCLUDE := -I$(ARCH_DIR)/include ifneq ($(KBUILD_SRC),) +ARCH_INCLUDE += -I$(ARCH_DIR)/include2 ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include +MRPROPER_DIRS += $(ARCH_DIR)/include2 endif SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) @@ -83,6 +87,10 @@ CONFIG_KERNEL_HALF_GIGS ?= 0 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) +ifeq ($(CONFIG_MODE_SKAS), y) +$(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h +endif + .PHONY: linux all: linux @@ -103,8 +111,7 @@ else $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) endif -archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h -prepare: $(ARCH_DIR)/include/kern_constants.h +archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib @@ -139,13 +146,15 @@ endef #When cleaning we don't include .config, so we don't include #TT or skas makefiles and don't clean skas_ptregs.h. CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ - $(ARCH_DIR)/include/user_constants.h \ - $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch + $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \ + $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os archclean: + $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util + $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ -o -name '*.gcov' \) -type f -print | xargs rm -f @@ -171,7 +180,9 @@ $(ARCH_DIR)/include/sysdep: @echo ' SYMLINK $@' ifneq ($(KBUILD_SRC),) $(Q)mkdir -p $(ARCH_DIR)/include - $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep + $(Q)mkdir -p $(ARCH_DIR)/include2 + $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep + $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep else $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep endif @@ -191,6 +202,8 @@ endef define filechk_gen-asm-offsets (set -e; \ + echo "#ifndef __ASM_OFFSETS_H__"; \ + echo "#define __ASM_OFFSETS_H__"; \ echo "/*"; \ echo " * DO NOT MODIFY."; \ echo " *"; \ @@ -199,7 +212,8 @@ define filechk_gen-asm-offsets echo " */"; \ echo ""; \ sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ - echo ""; ) + echo ""; \ + echo "#endif" ) endef $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h @@ -208,18 +222,50 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c $(CC) $(USER_CFLAGS) -S -o $@ $< -$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s +$(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s $(call filechk,gen-asm-offsets) -CLEAN_FILES += $(ARCH_DIR)/user-offsets.s +CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ - archprepare + $(ARCH_SYMLINKS) \ + $(SYS_DIR)/sc.h \ + include/asm include/linux/version.h \ + include/config/MARKER \ + $(ARCH_DIR)/include/user_constants.h $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< -$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s +$(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s $(call filechk,gen-asm-offsets) -CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s +CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h + +$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task + $(call filechk,gen_header) + +$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants + $(call filechk,gen_header) + +$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants + $(call filechk,gen_header) + +$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs + $(call filechk,gen_header) + +$(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ; + +$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ + FORCE ; + +$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; + +$(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE + $(Q)$(MAKE) $(build)=$@ + +$(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE + $(Q)$(MAKE) $(build)=$@ + +$(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE + $(Q)$(MAKE) $(build)=$@ export SUBARCH USER_CFLAGS OS diff --git a/trunk/arch/um/Makefile-i386 b/trunk/arch/um/Makefile-i386 index 2ee8a2858117..1ab431a53ac3 100644 --- a/trunk/arch/um/Makefile-i386 +++ b/trunk/arch/um/Makefile-i386 @@ -32,3 +32,25 @@ CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) ifneq ($(CONFIG_GPROF),y) ARCH_CFLAGS += -DUM_FASTCALL endif + +SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util +SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h + +prepare: $(SYS_HEADERS) + +$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc + $(call filechk,gen_header) + +$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread + $(call filechk,gen_header) + +$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE + $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ + +$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE + $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ + +$(SYS_UTIL_DIR): scripts_basic include/asm FORCE + $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) + +CLEAN_FILES += $(SYS_HEADERS) diff --git a/trunk/arch/um/Makefile-skas b/trunk/arch/um/Makefile-skas index ac35de5316a6..fd18ec572271 100644 --- a/trunk/arch/um/Makefile-skas +++ b/trunk/arch/um/Makefile-skas @@ -10,3 +10,5 @@ CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) LINK-$(CONFIG_GCOV) += $(GCOV_OPT) LINK-$(CONFIG_GPROF) += $(GPROF_OPT) + +GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h diff --git a/trunk/arch/um/Makefile-x86_64 b/trunk/arch/um/Makefile-x86_64 index 4f118d5cc2ee..436abbba409b 100644 --- a/trunk/arch/um/Makefile-x86_64 +++ b/trunk/arch/um/Makefile-x86_64 @@ -12,3 +12,24 @@ CHECKFLAGS += -m64 ELF_ARCH := i386:x86-64 ELF_FORMAT := elf64-x86-64 + +SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util +SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64 + +SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h + +prepare: $(SYS_HEADERS) + +$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc + $(call filechk,gen_header) + +$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread + $(call filechk,gen_header) + +$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE + $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ + +$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE + $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ + +CLEAN_FILES += $(SYS_HEADERS) diff --git a/trunk/arch/um/include/common-offsets.h b/trunk/arch/um/include/common-offsets.h index 356390d1f8b9..782ac3a3baf9 100644 --- a/trunk/arch/um/include/common-offsets.h +++ b/trunk/arch/um/include/common-offsets.h @@ -1,7 +1,7 @@ /* for use by sys-$SUBARCH/kernel-offsets.c */ -OFFSET(HOST_TASK_REGS, task_struct, thread.regs); -OFFSET(HOST_TASK_PID, task_struct, pid); +OFFSET(TASK_REGS, task_struct, thread.regs); +OFFSET(TASK_PID, task_struct, pid); DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); diff --git a/trunk/arch/um/include/skas_ptregs.h b/trunk/arch/um/include/skas_ptregs.h deleted file mode 100644 index 73db19e9c077..000000000000 --- a/trunk/arch/um/include/skas_ptregs.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __SKAS_PT_REGS_ -#define __SKAS_PT_REGS_ - -#include - -#endif diff --git a/trunk/arch/um/include/sysdep-i386/sc.h b/trunk/arch/um/include/sysdep-i386/sc.h deleted file mode 100644 index c57d1780ad37..000000000000 --- a/trunk/arch/um/include/sysdep-i386/sc.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __SYSDEP_I386_SC_H -#define __SYSDEP_I386_SC_H - -#include - -#define SC_OFFSET(sc, field) \ - *((unsigned long *) &(((char *) (sc))[HOST_##field])) -#define SC_FP_OFFSET(sc, field) \ - *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) -#define SC_FP_OFFSET_PTR(sc, field, type) \ - ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) - -#define SC_IP(sc) SC_OFFSET(sc, SC_IP) -#define SC_SP(sc) SC_OFFSET(sc, SC_SP) -#define SC_FS(sc) SC_OFFSET(sc, SC_FS) -#define SC_GS(sc) SC_OFFSET(sc, SC_GS) -#define SC_DS(sc) SC_OFFSET(sc, SC_DS) -#define SC_ES(sc) SC_OFFSET(sc, SC_ES) -#define SC_SS(sc) SC_OFFSET(sc, SC_SS) -#define SC_CS(sc) SC_OFFSET(sc, SC_CS) -#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) -#define SC_EAX(sc) SC_OFFSET(sc, SC_EAX) -#define SC_EBX(sc) SC_OFFSET(sc, SC_EBX) -#define SC_ECX(sc) SC_OFFSET(sc, SC_ECX) -#define SC_EDX(sc) SC_OFFSET(sc, SC_EDX) -#define SC_EDI(sc) SC_OFFSET(sc, SC_EDI) -#define SC_ESI(sc) SC_OFFSET(sc, SC_ESI) -#define SC_EBP(sc) SC_OFFSET(sc, SC_EBP) -#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) -#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) -#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) -#define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE) -#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) -#define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW) -#define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW) -#define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG) -#define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF) -#define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL) -#define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF) -#define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL) -#define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate) -#define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void) - -#endif diff --git a/trunk/arch/um/include/sysdep-i386/thread.h b/trunk/arch/um/include/sysdep-i386/thread.h deleted file mode 100644 index e2bd6bae8b8a..000000000000 --- a/trunk/arch/um/include/sysdep-i386/thread.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __UM_THREAD_H -#define __UM_THREAD_H - -#include - -#define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS])) -#ifdef CONFIG_MODE_TT -#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) -#endif - -#endif diff --git a/trunk/arch/um/include/sysdep-x86_64/sc.h b/trunk/arch/um/include/sysdep-x86_64/sc.h deleted file mode 100644 index a160d9fcc596..000000000000 --- a/trunk/arch/um/include/sysdep-x86_64/sc.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __SYSDEP_X86_64_SC_H -#define __SYSDEP_X86_64_SC_H - -/* Copyright (C) 2003 - 2004 PathScale, Inc - * Released under the GPL - */ - -#include - -#define SC_OFFSET(sc, field) \ - *((unsigned long *) &(((char *) (sc))[HOST_##field])) - -#define SC_RBX(sc) SC_OFFSET(sc, SC_RBX) -#define SC_RCX(sc) SC_OFFSET(sc, SC_RCX) -#define SC_RDX(sc) SC_OFFSET(sc, SC_RDX) -#define SC_RSI(sc) SC_OFFSET(sc, SC_RSI) -#define SC_RDI(sc) SC_OFFSET(sc, SC_RDI) -#define SC_RBP(sc) SC_OFFSET(sc, SC_RBP) -#define SC_RAX(sc) SC_OFFSET(sc, SC_RAX) -#define SC_R8(sc) SC_OFFSET(sc, SC_R8) -#define SC_R9(sc) SC_OFFSET(sc, SC_R9) -#define SC_R10(sc) SC_OFFSET(sc, SC_R10) -#define SC_R11(sc) SC_OFFSET(sc, SC_R11) -#define SC_R12(sc) SC_OFFSET(sc, SC_R12) -#define SC_R13(sc) SC_OFFSET(sc, SC_R13) -#define SC_R14(sc) SC_OFFSET(sc, SC_R14) -#define SC_R15(sc) SC_OFFSET(sc, SC_R15) -#define SC_IP(sc) SC_OFFSET(sc, SC_IP) -#define SC_SP(sc) SC_OFFSET(sc, SC_SP) -#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) -#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) -#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) -#define SC_CS(sc) SC_OFFSET(sc, SC_CS) -#define SC_FS(sc) SC_OFFSET(sc, SC_FS) -#define SC_GS(sc) SC_OFFSET(sc, SC_GS) -#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) -#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) -#if 0 -#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX) -#define SC_DS(sc) SC_OFFSET(sc, SC_DS) -#define SC_ES(sc) SC_OFFSET(sc, SC_ES) -#define SC_SS(sc) SC_OFFSET(sc, SC_SS) -#endif - -#endif diff --git a/trunk/arch/um/include/sysdep-x86_64/thread.h b/trunk/arch/um/include/sysdep-x86_64/thread.h deleted file mode 100644 index 6a76a7f3683f..000000000000 --- a/trunk/arch/um/include/sysdep-x86_64/thread.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __UM_THREAD_H -#define __UM_THREAD_H - -#include - -#ifdef CONFIG_MODE_TT -#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) -#endif - -#endif diff --git a/trunk/arch/um/include/task.h b/trunk/arch/um/include/task.h deleted file mode 100644 index 6375ba7203c9..000000000000 --- a/trunk/arch/um/include/task.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __TASK_H -#define __TASK_H - -#include - -#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) -#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) - -#endif diff --git a/trunk/arch/um/kernel/skas/Makefile b/trunk/arch/um/kernel/skas/Makefile index 8de471b59c1c..db36c7c95940 100644 --- a/trunk/arch/um/kernel/skas/Makefile +++ b/trunk/arch/um/kernel/skas/Makefile @@ -6,6 +6,8 @@ obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ syscall.o tlb.o trap_user.o uaccess.o +subdir- := util + USER_OBJS := process.o clone.o include arch/um/scripts/Makefile.rules diff --git a/trunk/arch/um/kernel/skas/util/Makefile b/trunk/arch/um/kernel/skas/util/Makefile new file mode 100644 index 000000000000..f7b7eba83340 --- /dev/null +++ b/trunk/arch/um/kernel/skas/util/Makefile @@ -0,0 +1,5 @@ +hostprogs-y := mk_ptregs +always := $(hostprogs-y) + +mk_ptregs-objs := mk_ptregs-$(SUBARCH).o +HOSTCFLAGS_mk_ptregs-$(SUBARCH).o := -I$(objtree)/arch/um diff --git a/trunk/arch/um/kernel/skas/util/mk_ptregs-i386.c b/trunk/arch/um/kernel/skas/util/mk_ptregs-i386.c new file mode 100644 index 000000000000..1f96e1eeb8a7 --- /dev/null +++ b/trunk/arch/um/kernel/skas/util/mk_ptregs-i386.c @@ -0,0 +1,49 @@ +#include +#include + +#define SHOW(name) printf("#define %s %d\n", #name, name) + +int main(int argc, char **argv) +{ + printf("/* Automatically generated by " + "arch/um/kernel/skas/util/mk_ptregs */\n"); + printf("\n"); + printf("#ifndef __SKAS_PT_REGS_\n"); + printf("#define __SKAS_PT_REGS_\n"); + printf("\n"); + SHOW(HOST_FRAME_SIZE); + SHOW(HOST_FP_SIZE); + SHOW(HOST_XFP_SIZE); + + SHOW(HOST_IP); + SHOW(HOST_SP); + SHOW(HOST_EFLAGS); + SHOW(HOST_EAX); + SHOW(HOST_EBX); + SHOW(HOST_ECX); + SHOW(HOST_EDX); + SHOW(HOST_ESI); + SHOW(HOST_EDI); + SHOW(HOST_EBP); + SHOW(HOST_CS); + SHOW(HOST_SS); + SHOW(HOST_DS); + SHOW(HOST_FS); + SHOW(HOST_ES); + SHOW(HOST_GS); + + printf("\n"); + printf("#endif\n"); + return(0); +} + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * Emacs will notice this stuff at the end of the file and automatically + * adjust the settings for this buffer only. This must remain at the end + * of the file. + * --------------------------------------------------------------------------- + * Local variables: + * c-file-style: "linux" + * End: + */ diff --git a/trunk/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/trunk/arch/um/kernel/skas/util/mk_ptregs-x86_64.c new file mode 100644 index 000000000000..5fccbfe35f78 --- /dev/null +++ b/trunk/arch/um/kernel/skas/util/mk_ptregs-x86_64.c @@ -0,0 +1,66 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#include +#include + +#define SHOW(name) \ + printf("#define %s (%d / sizeof(unsigned long))\n", #name, name) + +int main(int argc, char **argv) +{ + printf("/* Automatically generated by " + "arch/um/kernel/skas/util/mk_ptregs */\n"); + printf("\n"); + printf("#ifndef __SKAS_PT_REGS_\n"); + printf("#define __SKAS_PT_REGS_\n"); + SHOW(HOST_FRAME_SIZE); + SHOW(HOST_RBX); + SHOW(HOST_RCX); + SHOW(HOST_RDI); + SHOW(HOST_RSI); + SHOW(HOST_RDX); + SHOW(HOST_RBP); + SHOW(HOST_RAX); + SHOW(HOST_R8); + SHOW(HOST_R9); + SHOW(HOST_R10); + SHOW(HOST_R11); + SHOW(HOST_R12); + SHOW(HOST_R13); + SHOW(HOST_R14); + SHOW(HOST_R15); + SHOW(HOST_ORIG_RAX); + SHOW(HOST_CS); + SHOW(HOST_SS); + SHOW(HOST_EFLAGS); +#if 0 + SHOW(HOST_FS); + SHOW(HOST_GS); + SHOW(HOST_DS); + SHOW(HOST_ES); +#endif + + SHOW(HOST_IP); + SHOW(HOST_SP); + printf("#define HOST_FP_SIZE 0\n"); + printf("#define HOST_XFP_SIZE 0\n"); + printf("\n"); + printf("\n"); + printf("#endif\n"); + return(0); +} + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * Emacs will notice this stuff at the end of the file and automatically + * adjust the settings for this buffer only. This must remain at the end + * of the file. + * --------------------------------------------------------------------------- + * Local variables: + * c-file-style: "linux" + * End: + */ diff --git a/trunk/arch/um/os-Linux/elf_aux.c b/trunk/arch/um/os-Linux/elf_aux.c index 5a99dd3fbed0..ab33cb3c74ec 100644 --- a/trunk/arch/um/os-Linux/elf_aux.c +++ b/trunk/arch/um/os-Linux/elf_aux.c @@ -12,7 +12,7 @@ #include "init.h" #include "elf_user.h" #include "mem_user.h" -#include +#include /* Use the one from the kernel - the host may miss it, if having old headers. */ #if UM_ELF_CLASS == UM_ELFCLASS32 diff --git a/trunk/arch/um/os-Linux/util/Makefile b/trunk/arch/um/os-Linux/util/Makefile new file mode 100644 index 000000000000..9778aed0c314 --- /dev/null +++ b/trunk/arch/um/os-Linux/util/Makefile @@ -0,0 +1,4 @@ +hostprogs-y := mk_user_constants +always := $(hostprogs-y) + +HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um diff --git a/trunk/arch/um/os-Linux/util/mk_user_constants.c b/trunk/arch/um/os-Linux/util/mk_user_constants.c new file mode 100644 index 000000000000..4838f30eecf0 --- /dev/null +++ b/trunk/arch/um/os-Linux/util/mk_user_constants.c @@ -0,0 +1,23 @@ +#include +#include + +int main(int argc, char **argv) +{ + printf("/*\n"); + printf(" * Generated by mk_user_constants\n"); + printf(" */\n"); + printf("\n"); + printf("#ifndef __UM_USER_CONSTANTS_H\n"); + printf("#define __UM_USER_CONSTANTS_H\n"); + printf("\n"); + /* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on + * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on + * both x86_64 and i386. + */ + printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE); + + printf("\n"); + printf("#endif\n"); + + return(0); +} diff --git a/trunk/arch/um/sys-i386/Makefile b/trunk/arch/um/sys-i386/Makefile index 6dfeb70f6957..4ca2a229da49 100644 --- a/trunk/arch/um/sys-i386/Makefile +++ b/trunk/arch/um/sys-i386/Makefile @@ -18,4 +18,6 @@ module.c-dir = kernel $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) +subdir- := util + include arch/um/scripts/Makefile.unmap diff --git a/trunk/arch/um/sys-i386/kernel-offsets.c b/trunk/arch/um/sys-i386/kernel-offsets.c index 35db85057506..a1070af2bcd8 100644 --- a/trunk/arch/um/sys-i386/kernel-offsets.c +++ b/trunk/arch/um/sys-i386/kernel-offsets.c @@ -18,9 +18,9 @@ void foo(void) { - OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs); + OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs); #ifdef CONFIG_MODE_TT - OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); + OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); #endif #include } diff --git a/trunk/arch/um/sys-i386/user-offsets.c b/trunk/arch/um/sys-i386/user-offsets.c index 677fc26a9bbe..3ceaabceb3d7 100644 --- a/trunk/arch/um/sys-i386/user-offsets.c +++ b/trunk/arch/um/sys-i386/user-offsets.c @@ -7,48 +7,47 @@ #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) -#define DEFINE_LONGS(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) - #define OFFSET(sym, str, mem) \ DEFINE(sym, offsetof(struct str, mem)); void foo(void) { - OFFSET(HOST_SC_IP, sigcontext, eip); - OFFSET(HOST_SC_SP, sigcontext, esp); - OFFSET(HOST_SC_FS, sigcontext, fs); - OFFSET(HOST_SC_GS, sigcontext, gs); - OFFSET(HOST_SC_DS, sigcontext, ds); - OFFSET(HOST_SC_ES, sigcontext, es); - OFFSET(HOST_SC_SS, sigcontext, ss); - OFFSET(HOST_SC_CS, sigcontext, cs); - OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); - OFFSET(HOST_SC_EAX, sigcontext, eax); - OFFSET(HOST_SC_EBX, sigcontext, ebx); - OFFSET(HOST_SC_ECX, sigcontext, ecx); - OFFSET(HOST_SC_EDX, sigcontext, edx); - OFFSET(HOST_SC_EDI, sigcontext, edi); - OFFSET(HOST_SC_ESI, sigcontext, esi); - OFFSET(HOST_SC_EBP, sigcontext, ebp); - OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); - OFFSET(HOST_SC_ERR, sigcontext, err); - OFFSET(HOST_SC_CR2, sigcontext, cr2); - OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate); - OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); - OFFSET(HOST_SC_FP_CW, _fpstate, cw); - OFFSET(HOST_SC_FP_SW, _fpstate, sw); - OFFSET(HOST_SC_FP_TAG, _fpstate, tag); - OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff); - OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel); - OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff); - OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel); - OFFSET(HOST_SC_FP_ST, _fpstate, _st); - OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env); + OFFSET(SC_IP, sigcontext, eip); + OFFSET(SC_SP, sigcontext, esp); + OFFSET(SC_FS, sigcontext, fs); + OFFSET(SC_GS, sigcontext, gs); + OFFSET(SC_DS, sigcontext, ds); + OFFSET(SC_ES, sigcontext, es); + OFFSET(SC_SS, sigcontext, ss); + OFFSET(SC_CS, sigcontext, cs); + OFFSET(SC_EFLAGS, sigcontext, eflags); + OFFSET(SC_EAX, sigcontext, eax); + OFFSET(SC_EBX, sigcontext, ebx); + OFFSET(SC_ECX, sigcontext, ecx); + OFFSET(SC_EDX, sigcontext, edx); + OFFSET(SC_EDI, sigcontext, edi); + OFFSET(SC_ESI, sigcontext, esi); + OFFSET(SC_EBP, sigcontext, ebp); + OFFSET(SC_TRAPNO, sigcontext, trapno); + OFFSET(SC_ERR, sigcontext, err); + OFFSET(SC_CR2, sigcontext, cr2); + OFFSET(SC_FPSTATE, sigcontext, fpstate); + OFFSET(SC_SIGMASK, sigcontext, oldmask); + OFFSET(SC_FP_CW, _fpstate, cw); + OFFSET(SC_FP_SW, _fpstate, sw); + OFFSET(SC_FP_TAG, _fpstate, tag); + OFFSET(SC_FP_IPOFF, _fpstate, ipoff); + OFFSET(SC_FP_CSSEL, _fpstate, cssel); + OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); + OFFSET(SC_FP_DATASEL, _fpstate, datasel); + OFFSET(SC_FP_ST, _fpstate, _st); + OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); - DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); - DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct)); - DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct)); + DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); + DEFINE(HOST_FP_SIZE, + sizeof(struct user_i387_struct) / sizeof(unsigned long)); + DEFINE(HOST_XFP_SIZE, + sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); DEFINE(HOST_IP, EIP); DEFINE(HOST_SP, UESP); @@ -66,5 +65,5 @@ void foo(void) DEFINE(HOST_FS, FS); DEFINE(HOST_ES, ES); DEFINE(HOST_GS, GS); - DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); + DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); } diff --git a/trunk/arch/um/sys-i386/util/Makefile b/trunk/arch/um/sys-i386/util/Makefile new file mode 100644 index 000000000000..bf61afd0b045 --- /dev/null +++ b/trunk/arch/um/sys-i386/util/Makefile @@ -0,0 +1,5 @@ +hostprogs-y := mk_sc mk_thread +always := $(hostprogs-y) + +HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um +HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um diff --git a/trunk/arch/um/sys-i386/util/mk_sc.c b/trunk/arch/um/sys-i386/util/mk_sc.c new file mode 100644 index 000000000000..04c0d73433aa --- /dev/null +++ b/trunk/arch/um/sys-i386/util/mk_sc.c @@ -0,0 +1,51 @@ +#include +#include + +#define SC_OFFSET(name, field) \ + printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ + name) + +#define SC_FP_OFFSET(name, field) \ + printf("#define " #name \ + "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ + name) + +#define SC_FP_OFFSET_PTR(name, field, type) \ + printf("#define " #name \ + "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ + name) + +int main(int argc, char **argv) +{ + SC_OFFSET(SC_IP, eip); + SC_OFFSET(SC_SP, esp); + SC_OFFSET(SC_FS, fs); + SC_OFFSET(SC_GS, gs); + SC_OFFSET(SC_DS, ds); + SC_OFFSET(SC_ES, es); + SC_OFFSET(SC_SS, ss); + SC_OFFSET(SC_CS, cs); + SC_OFFSET(SC_EFLAGS, eflags); + SC_OFFSET(SC_EAX, eax); + SC_OFFSET(SC_EBX, ebx); + SC_OFFSET(SC_ECX, ecx); + SC_OFFSET(SC_EDX, edx); + SC_OFFSET(SC_EDI, edi); + SC_OFFSET(SC_ESI, esi); + SC_OFFSET(SC_EBP, ebp); + SC_OFFSET(SC_TRAPNO, trapno); + SC_OFFSET(SC_ERR, err); + SC_OFFSET(SC_CR2, cr2); + SC_OFFSET(SC_FPSTATE, fpstate); + SC_OFFSET(SC_SIGMASK, oldmask); + SC_FP_OFFSET(SC_FP_CW, cw); + SC_FP_OFFSET(SC_FP_SW, sw); + SC_FP_OFFSET(SC_FP_TAG, tag); + SC_FP_OFFSET(SC_FP_IPOFF, ipoff); + SC_FP_OFFSET(SC_FP_CSSEL, cssel); + SC_FP_OFFSET(SC_FP_DATAOFF, dataoff); + SC_FP_OFFSET(SC_FP_DATASEL, datasel); + SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate"); + SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void"); + return(0); +} diff --git a/trunk/arch/um/sys-i386/util/mk_thread.c b/trunk/arch/um/sys-i386/util/mk_thread.c new file mode 100644 index 000000000000..7470d0dda67e --- /dev/null +++ b/trunk/arch/um/sys-i386/util/mk_thread.c @@ -0,0 +1,22 @@ +#include +#include + +int main(int argc, char **argv) +{ + printf("/*\n"); + printf(" * Generated by mk_thread\n"); + printf(" */\n"); + printf("\n"); + printf("#ifndef __UM_THREAD_H\n"); + printf("#define __UM_THREAD_H\n"); + printf("\n"); + printf("#define TASK_DEBUGREGS(task) ((unsigned long *) " + "&(((char *) (task))[%d]))\n", TASK_DEBUGREGS); +#ifdef TASK_EXTERN_PID + printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", + TASK_EXTERN_PID); +#endif + printf("\n"); + printf("#endif\n"); + return(0); +} diff --git a/trunk/arch/um/sys-x86_64/Makefile b/trunk/arch/um/sys-x86_64/Makefile index 06c3633457a2..f0ab574d1e95 100644 --- a/trunk/arch/um/sys-x86_64/Makefile +++ b/trunk/arch/um/sys-x86_64/Makefile @@ -29,4 +29,6 @@ module.c-dir = kernel $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) +subdir- := util + include arch/um/scripts/Makefile.unmap diff --git a/trunk/arch/um/sys-x86_64/kernel-offsets.c b/trunk/arch/um/sys-x86_64/kernel-offsets.c index bfcb104b846e..998541eade41 100644 --- a/trunk/arch/um/sys-x86_64/kernel-offsets.c +++ b/trunk/arch/um/sys-x86_64/kernel-offsets.c @@ -19,7 +19,7 @@ void foo(void) { #ifdef CONFIG_MODE_TT - OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); + OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); #endif #include } diff --git a/trunk/arch/um/sys-x86_64/user-offsets.c b/trunk/arch/um/sys-x86_64/user-offsets.c index 5a585bfbb8c2..513d17ceafd4 100644 --- a/trunk/arch/um/sys-x86_64/user-offsets.c +++ b/trunk/arch/um/sys-x86_64/user-offsets.c @@ -16,76 +16,71 @@ typedef __u32 u32; #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) -#define DEFINE_LONGS(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) - #define OFFSET(sym, str, mem) \ DEFINE(sym, offsetof(struct str, mem)); void foo(void) { - OFFSET(HOST_SC_RBX, sigcontext, rbx); - OFFSET(HOST_SC_RCX, sigcontext, rcx); - OFFSET(HOST_SC_RDX, sigcontext, rdx); - OFFSET(HOST_SC_RSI, sigcontext, rsi); - OFFSET(HOST_SC_RDI, sigcontext, rdi); - OFFSET(HOST_SC_RBP, sigcontext, rbp); - OFFSET(HOST_SC_RAX, sigcontext, rax); - OFFSET(HOST_SC_R8, sigcontext, r8); - OFFSET(HOST_SC_R9, sigcontext, r9); - OFFSET(HOST_SC_R10, sigcontext, r10); - OFFSET(HOST_SC_R11, sigcontext, r11); - OFFSET(HOST_SC_R12, sigcontext, r12); - OFFSET(HOST_SC_R13, sigcontext, r13); - OFFSET(HOST_SC_R14, sigcontext, r14); - OFFSET(HOST_SC_R15, sigcontext, r15); - OFFSET(HOST_SC_IP, sigcontext, rip); - OFFSET(HOST_SC_SP, sigcontext, rsp); - OFFSET(HOST_SC_CR2, sigcontext, cr2); - OFFSET(HOST_SC_ERR, sigcontext, err); - OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); - OFFSET(HOST_SC_CS, sigcontext, cs); - OFFSET(HOST_SC_FS, sigcontext, fs); - OFFSET(HOST_SC_GS, sigcontext, gs); - OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); - OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); + OFFSET(SC_RBX, sigcontext, rbx); + OFFSET(SC_RCX, sigcontext, rcx); + OFFSET(SC_RDX, sigcontext, rdx); + OFFSET(SC_RSI, sigcontext, rsi); + OFFSET(SC_RDI, sigcontext, rdi); + OFFSET(SC_RBP, sigcontext, rbp); + OFFSET(SC_RAX, sigcontext, rax); + OFFSET(SC_R8, sigcontext, r8); + OFFSET(SC_R9, sigcontext, r9); + OFFSET(SC_R10, sigcontext, r10); + OFFSET(SC_R11, sigcontext, r11); + OFFSET(SC_R12, sigcontext, r12); + OFFSET(SC_R13, sigcontext, r13); + OFFSET(SC_R14, sigcontext, r14); + OFFSET(SC_R15, sigcontext, r15); + OFFSET(SC_IP, sigcontext, rip); + OFFSET(SC_SP, sigcontext, rsp); + OFFSET(SC_CR2, sigcontext, cr2); + OFFSET(SC_ERR, sigcontext, err); + OFFSET(SC_TRAPNO, sigcontext, trapno); + OFFSET(SC_CS, sigcontext, cs); + OFFSET(SC_FS, sigcontext, fs); + OFFSET(SC_GS, sigcontext, gs); + OFFSET(SC_EFLAGS, sigcontext, eflags); + OFFSET(SC_SIGMASK, sigcontext, oldmask); #if 0 - OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax); - OFFSET(HOST_SC_DS, sigcontext, ds); - OFFSET(HOST_SC_ES, sigcontext, es); - OFFSET(HOST_SC_SS, sigcontext, ss); + OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); + OFFSET(SC_DS, sigcontext, ds); + OFFSET(SC_ES, sigcontext, es); + OFFSET(SC_SS, sigcontext, ss); #endif - DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); - DEFINE(HOST_FP_SIZE, 0); - DEFINE(HOST_XFP_SIZE, 0); - DEFINE_LONGS(HOST_RBX, RBX); - DEFINE_LONGS(HOST_RCX, RCX); - DEFINE_LONGS(HOST_RDI, RDI); - DEFINE_LONGS(HOST_RSI, RSI); - DEFINE_LONGS(HOST_RDX, RDX); - DEFINE_LONGS(HOST_RBP, RBP); - DEFINE_LONGS(HOST_RAX, RAX); - DEFINE_LONGS(HOST_R8, R8); - DEFINE_LONGS(HOST_R9, R9); - DEFINE_LONGS(HOST_R10, R10); - DEFINE_LONGS(HOST_R11, R11); - DEFINE_LONGS(HOST_R12, R12); - DEFINE_LONGS(HOST_R13, R13); - DEFINE_LONGS(HOST_R14, R14); - DEFINE_LONGS(HOST_R15, R15); - DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); - DEFINE_LONGS(HOST_CS, CS); - DEFINE_LONGS(HOST_SS, SS); - DEFINE_LONGS(HOST_EFLAGS, EFLAGS); + DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); + DEFINE(HOST_RBX, RBX); + DEFINE(HOST_RCX, RCX); + DEFINE(HOST_RDI, RDI); + DEFINE(HOST_RSI, RSI); + DEFINE(HOST_RDX, RDX); + DEFINE(HOST_RBP, RBP); + DEFINE(HOST_RAX, RAX); + DEFINE(HOST_R8, R8); + DEFINE(HOST_R9, R9); + DEFINE(HOST_R10, R10); + DEFINE(HOST_R11, R11); + DEFINE(HOST_R12, R12); + DEFINE(HOST_R13, R13); + DEFINE(HOST_R14, R14); + DEFINE(HOST_R15, R15); + DEFINE(HOST_ORIG_RAX, ORIG_RAX); + DEFINE(HOST_CS, CS); + DEFINE(HOST_SS, SS); + DEFINE(HOST_EFLAGS, EFLAGS); #if 0 - DEFINE_LONGS(HOST_FS, FS); - DEFINE_LONGS(HOST_GS, GS); - DEFINE_LONGS(HOST_DS, DS); - DEFINE_LONGS(HOST_ES, ES); + DEFINE(HOST_FS, FS); + DEFINE(HOST_GS, GS); + DEFINE(HOST_DS, DS); + DEFINE(HOST_ES, ES); #endif - DEFINE_LONGS(HOST_IP, RIP); - DEFINE_LONGS(HOST_SP, RSP); - DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); + DEFINE(HOST_IP, RIP); + DEFINE(HOST_SP, RSP); + DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); } diff --git a/trunk/arch/um/sys-x86_64/util/Makefile b/trunk/arch/um/sys-x86_64/util/Makefile new file mode 100644 index 000000000000..75b052cfc206 --- /dev/null +++ b/trunk/arch/um/sys-x86_64/util/Makefile @@ -0,0 +1,8 @@ +# Copyright 2003 - 2004 Pathscale, Inc +# Released under the GPL + +hostprogs-y := mk_sc mk_thread +always := $(hostprogs-y) + +HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um +HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um diff --git a/trunk/arch/um/sys-x86_64/util/mk_sc.c b/trunk/arch/um/sys-x86_64/util/mk_sc.c new file mode 100644 index 000000000000..7619bc377c1f --- /dev/null +++ b/trunk/arch/um/sys-x86_64/util/mk_sc.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2003 - 2004 PathScale, Inc + * Released under the GPL + */ + +#include +#include + +#define SC_OFFSET(name) \ + printf("#define " #name \ + "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ + name) + +int main(int argc, char **argv) +{ + SC_OFFSET(SC_RBX); + SC_OFFSET(SC_RCX); + SC_OFFSET(SC_RDX); + SC_OFFSET(SC_RSI); + SC_OFFSET(SC_RDI); + SC_OFFSET(SC_RBP); + SC_OFFSET(SC_RAX); + SC_OFFSET(SC_R8); + SC_OFFSET(SC_R9); + SC_OFFSET(SC_R10); + SC_OFFSET(SC_R11); + SC_OFFSET(SC_R12); + SC_OFFSET(SC_R13); + SC_OFFSET(SC_R14); + SC_OFFSET(SC_R15); + SC_OFFSET(SC_IP); + SC_OFFSET(SC_SP); + SC_OFFSET(SC_CR2); + SC_OFFSET(SC_ERR); + SC_OFFSET(SC_TRAPNO); + SC_OFFSET(SC_CS); + SC_OFFSET(SC_FS); + SC_OFFSET(SC_GS); + SC_OFFSET(SC_EFLAGS); + SC_OFFSET(SC_SIGMASK); +#if 0 + SC_OFFSET(SC_ORIG_RAX); + SC_OFFSET(SC_DS); + SC_OFFSET(SC_ES); + SC_OFFSET(SC_SS); +#endif + return(0); +} diff --git a/trunk/arch/um/sys-x86_64/util/mk_thread.c b/trunk/arch/um/sys-x86_64/util/mk_thread.c new file mode 100644 index 000000000000..15517396e9cf --- /dev/null +++ b/trunk/arch/um/sys-x86_64/util/mk_thread.c @@ -0,0 +1,20 @@ +#include +#include + +int main(int argc, char **argv) +{ + printf("/*\n"); + printf(" * Generated by mk_thread\n"); + printf(" */\n"); + printf("\n"); + printf("#ifndef __UM_THREAD_H\n"); + printf("#define __UM_THREAD_H\n"); + printf("\n"); +#ifdef TASK_EXTERN_PID + printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", + TASK_EXTERN_PID); +#endif + printf("\n"); + printf("#endif\n"); + return(0); +} diff --git a/trunk/arch/um/util/Makefile b/trunk/arch/um/util/Makefile new file mode 100644 index 000000000000..4c7551c28033 --- /dev/null +++ b/trunk/arch/um/util/Makefile @@ -0,0 +1,5 @@ +hostprogs-y := mk_task mk_constants +always := $(hostprogs-y) + +HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um +HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um diff --git a/trunk/arch/um/util/mk_constants.c b/trunk/arch/um/util/mk_constants.c new file mode 100644 index 000000000000..ab217becc36a --- /dev/null +++ b/trunk/arch/um/util/mk_constants.c @@ -0,0 +1,32 @@ +#include +#include + +#define SHOW_INT(sym) printf("#define %s %d\n", #sym, sym) +#define SHOW_STR(sym) printf("#define %s %s\n", #sym, sym) + +int main(int argc, char **argv) +{ + printf("/*\n"); + printf(" * Generated by mk_constants\n"); + printf(" */\n"); + printf("\n"); + printf("#ifndef __UM_CONSTANTS_H\n"); + printf("#define __UM_CONSTANTS_H\n"); + printf("\n"); + + SHOW_INT(UM_KERN_PAGE_SIZE); + + SHOW_STR(UM_KERN_EMERG); + SHOW_STR(UM_KERN_ALERT); + SHOW_STR(UM_KERN_CRIT); + SHOW_STR(UM_KERN_ERR); + SHOW_STR(UM_KERN_WARNING); + SHOW_STR(UM_KERN_NOTICE); + SHOW_STR(UM_KERN_INFO); + SHOW_STR(UM_KERN_DEBUG); + + SHOW_INT(UM_NSEC_PER_SEC); + printf("\n"); + printf("#endif\n"); + return(0); +} diff --git a/trunk/arch/um/util/mk_task.c b/trunk/arch/um/util/mk_task.c new file mode 100644 index 000000000000..36c9606505e2 --- /dev/null +++ b/trunk/arch/um/util/mk_task.c @@ -0,0 +1,30 @@ +#include +#include + +void print_ptr(char *name, char *type, int offset) +{ + printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, + offset); +} + +void print(char *name, char *type, int offset) +{ + printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, + offset); +} + +int main(int argc, char **argv) +{ + printf("/*\n"); + printf(" * Generated by mk_task\n"); + printf(" */\n"); + printf("\n"); + printf("#ifndef __TASK_H\n"); + printf("#define __TASK_H\n"); + printf("\n"); + print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS); + print("TASK_PID", "int", TASK_PID); + printf("\n"); + printf("#endif\n"); + return(0); +} diff --git a/trunk/arch/x86_64/kernel/time.c b/trunk/arch/x86_64/kernel/time.c index 703acde2a1a5..2373cb8b8625 100644 --- a/trunk/arch/x86_64/kernel/time.c +++ b/trunk/arch/x86_64/kernel/time.c @@ -959,6 +959,9 @@ static __init int unsynchronized_tsc(void) are handled in the OEM check above. */ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) return 0; + /* All in a single socket - should be synchronized */ + if (cpus_weight(cpu_core_map[0]) == num_online_cpus()) + return 0; #endif /* Assume multi socket systems are not synchronized */ return num_online_cpus() > 1; diff --git a/trunk/drivers/char/drm/drm_drv.c b/trunk/drivers/char/drm/drm_drv.c index 041bb47b5c39..6ba48f346fcf 100644 --- a/trunk/drivers/char/drm/drm_drv.c +++ b/trunk/drivers/char/drm/drm_drv.c @@ -376,7 +376,7 @@ static int __init drm_core_init(void) goto err_p2; } - drm_proc_root = proc_mkdir("dri", NULL); + drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL); if (!drm_proc_root) { DRM_ERROR("Cannot create /proc/dri\n"); ret = -1; diff --git a/trunk/drivers/char/drm/drm_proc.c b/trunk/drivers/char/drm/drm_proc.c index 977961002488..32d2bb99462c 100644 --- a/trunk/drivers/char/drm/drm_proc.c +++ b/trunk/drivers/char/drm/drm_proc.c @@ -95,7 +95,7 @@ int drm_proc_init(drm_device_t *dev, int minor, char name[64]; sprintf(name, "%d", minor); - *dev_root = proc_mkdir(name, root); + *dev_root = create_proc_entry(name, S_IFDIR, root); if (!*dev_root) { DRM_ERROR("Cannot create /proc/dri/%s\n", name); return -1; diff --git a/trunk/drivers/char/ipmi/ipmi_poweroff.c b/trunk/drivers/char/ipmi/ipmi_poweroff.c index f66947722e12..e82a96ba396b 100644 --- a/trunk/drivers/char/ipmi/ipmi_poweroff.c +++ b/trunk/drivers/char/ipmi/ipmi_poweroff.c @@ -55,7 +55,7 @@ extern void (*pm_power_off)(void); static int poweroff_powercycle; /* parameter definition to allow user to flag power cycle */ -module_param(poweroff_powercycle, int, 0644); +module_param(poweroff_powercycle, int, 0); MODULE_PARM_DESC(poweroff_powercycles, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); /* Stuff from the get device id command. */ diff --git a/trunk/drivers/char/n_r3964.c b/trunk/drivers/char/n_r3964.c index 97d6dc24b800..2291a87e8ada 100644 --- a/trunk/drivers/char/n_r3964.c +++ b/trunk/drivers/char/n_r3964.c @@ -229,8 +229,8 @@ static int __init r3964_init(void) TRACE_L("line discipline %d registered", N_R3964); TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, tty_ldisc_N_R3964.num); - TRACE_L("open=%p", tty_ldisc_N_R3964.open); - TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964); + TRACE_L("open=%x", (int)tty_ldisc_N_R3964.open); + TRACE_L("tty_ldisc_N_R3964 = %x", (int)&tty_ldisc_N_R3964); } else { @@ -267,8 +267,8 @@ static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH spin_unlock_irqrestore(&pInfo->lock, flags); - TRACE_Q("add_tx_queue %p, length %d, tx_first = %p", - pHeader, pHeader->length, pInfo->tx_first ); + TRACE_Q("add_tx_queue %x, length %d, tx_first = %x", + (int)pHeader, pHeader->length, (int)pInfo->tx_first ); } static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) @@ -285,10 +285,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) return; #ifdef DEBUG_QUEUE - printk("r3964: remove_from_tx_queue: %p, length %u - ", - pHeader, pHeader->length ); + printk("r3964: remove_from_tx_queue: %x, length %d - ", + (int)pHeader, (int)pHeader->length ); for(pDump=pHeader;pDump;pDump=pDump->next) - printk("%p ", pDump); + printk("%x ", (int)pDump); printk("\n"); #endif @@ -319,10 +319,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) spin_unlock_irqrestore(&pInfo->lock, flags); kfree(pHeader); - TRACE_M("remove_from_tx_queue - kfree %p",pHeader); + TRACE_M("remove_from_tx_queue - kfree %x",(int)pHeader); - TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p", - pInfo->tx_first, pInfo->tx_last ); + TRACE_Q("remove_from_tx_queue: tx_first = %x, tx_last = %x", + (int)pInfo->tx_first, (int)pInfo->tx_last ); } static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) @@ -346,9 +346,9 @@ static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH spin_unlock_irqrestore(&pInfo->lock, flags); - TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d", - pHeader, pHeader->length, - pInfo->rx_first, pInfo->blocks_in_rx_queue); + TRACE_Q("add_rx_queue: %x, length = %d, rx_first = %x, count = %d", + (int)pHeader, pHeader->length, + (int)pInfo->rx_first, pInfo->blocks_in_rx_queue); } static void remove_from_rx_queue(struct r3964_info *pInfo, @@ -360,10 +360,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo, if(pHeader==NULL) return; - TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", - pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue ); - TRACE_Q("remove_from_rx_queue: %p, length %u", - pHeader, pHeader->length ); + TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", + (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); + TRACE_Q("remove_from_rx_queue: %x, length %d", + (int)pHeader, (int)pHeader->length ); spin_lock_irqsave(&pInfo->lock, flags); @@ -401,10 +401,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo, spin_unlock_irqrestore(&pInfo->lock, flags); kfree(pHeader); - TRACE_M("remove_from_rx_queue - kfree %p",pHeader); + TRACE_M("remove_from_rx_queue - kfree %x",(int)pHeader); - TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", - pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue ); + TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", + (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); } static void put_char(struct r3964_info *pInfo, unsigned char ch) @@ -506,8 +506,8 @@ static void transmit_block(struct r3964_info *pInfo) if(tty->driver->write_room) room=tty->driver->write_room(tty); - TRACE_PS("transmit_block %p, room %d, length %d", - pBlock, room, pBlock->length); + TRACE_PS("transmit_block %x, room %d, length %d", + (int)pBlock, room, pBlock->length); while(pInfo->tx_position < pBlock->length) { @@ -588,7 +588,7 @@ static void on_receive_block(struct r3964_info *pInfo) /* prepare struct r3964_block_header: */ pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL); - TRACE_M("on_receive_block - kmalloc %p",pBlock); + TRACE_M("on_receive_block - kmalloc %x",(int)pBlock); if(pBlock==NULL) return; @@ -868,11 +868,11 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) if(pMsg) { kfree(pMsg); - TRACE_M("enable_signals - msg kfree %p",pMsg); + TRACE_M("enable_signals - msg kfree %x",(int)pMsg); } } kfree(pClient); - TRACE_M("enable_signals - kfree %p",pClient); + TRACE_M("enable_signals - kfree %x",(int)pClient); return 0; } } @@ -890,7 +890,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) { /* add client to client list */ pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL); - TRACE_M("enable_signals - kmalloc %p",pClient); + TRACE_M("enable_signals - kmalloc %x",(int)pClient); if(pClient==NULL) return -ENOMEM; @@ -954,7 +954,7 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, queue_the_message: pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); - TRACE_M("add_msg - kmalloc %p",pMsg); + TRACE_M("add_msg - kmalloc %x",(int)pMsg); if(pMsg==NULL) { return; } @@ -1067,11 +1067,11 @@ static int r3964_open(struct tty_struct *tty) struct r3964_info *pInfo; TRACE_L("open"); - TRACE_L("tty=%p, PID=%d, disc_data=%p", - tty, current->pid, tty->disc_data); + TRACE_L("tty=%x, PID=%d, disc_data=%x", + (int)tty, current->pid, (int)tty->disc_data); pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); - TRACE_M("r3964_open - info kmalloc %p",pInfo); + TRACE_M("r3964_open - info kmalloc %x",(int)pInfo); if(!pInfo) { @@ -1080,26 +1080,26 @@ static int r3964_open(struct tty_struct *tty) } pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); - TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf); + TRACE_M("r3964_open - rx_buf kmalloc %x",(int)pInfo->rx_buf); if(!pInfo->rx_buf) { printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); kfree(pInfo); - TRACE_M("r3964_open - info kfree %p",pInfo); + TRACE_M("r3964_open - info kfree %x",(int)pInfo); return -ENOMEM; } pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); - TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf); + TRACE_M("r3964_open - tx_buf kmalloc %x",(int)pInfo->tx_buf); if(!pInfo->tx_buf) { printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); kfree(pInfo->rx_buf); - TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf); + TRACE_M("r3964_open - rx_buf kfree %x",(int)pInfo->rx_buf); kfree(pInfo); - TRACE_M("r3964_open - info kfree %p",pInfo); + TRACE_M("r3964_open - info kfree %x",(int)pInfo); return -ENOMEM; } @@ -1154,11 +1154,11 @@ static void r3964_close(struct tty_struct *tty) if(pMsg) { kfree(pMsg); - TRACE_M("r3964_close - msg kfree %p",pMsg); + TRACE_M("r3964_close - msg kfree %x",(int)pMsg); } } kfree(pClient); - TRACE_M("r3964_close - client kfree %p",pClient); + TRACE_M("r3964_close - client kfree %x",(int)pClient); pClient=pNext; } /* Remove jobs from tx_queue: */ @@ -1177,11 +1177,11 @@ static void r3964_close(struct tty_struct *tty) /* Free buffers: */ wake_up_interruptible(&pInfo->read_wait); kfree(pInfo->rx_buf); - TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf); + TRACE_M("r3964_close - rx_buf kfree %x",(int)pInfo->rx_buf); kfree(pInfo->tx_buf); - TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf); + TRACE_M("r3964_close - tx_buf kfree %x",(int)pInfo->tx_buf); kfree(pInfo); - TRACE_M("r3964_close - info kfree %p",pInfo); + TRACE_M("r3964_close - info kfree %x",(int)pInfo); } static ssize_t r3964_read(struct tty_struct *tty, struct file *file, @@ -1234,7 +1234,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, count = sizeof(struct r3964_client_message); kfree(pMsg); - TRACE_M("r3964_read - msg kfree %p",pMsg); + TRACE_M("r3964_read - msg kfree %x",(int)pMsg); if (copy_to_user(buf,&theMsg, count)) return -EFAULT; @@ -1279,7 +1279,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, * Allocate a buffer for the data and copy it from the buffer with header prepended */ new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL); - TRACE_M("r3964_write - kmalloc %p",new_data); + TRACE_M("r3964_write - kmalloc %x",(int)new_data); if (new_data == NULL) { if (pInfo->flags & R3964_DEBUG) { diff --git a/trunk/drivers/char/watchdog/mv64x60_wdt.c b/trunk/drivers/char/watchdog/mv64x60_wdt.c index 6d3ff0836c44..1436aea3b28f 100644 --- a/trunk/drivers/char/watchdog/mv64x60_wdt.c +++ b/trunk/drivers/char/watchdog/mv64x60_wdt.c @@ -87,8 +87,6 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file) mv64x60_wdt_service(); mv64x60_wdt_handler_enable(); - nonseekable_open(inode, file); - return 0; } @@ -105,9 +103,12 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file) return 0; } -static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data, +static ssize_t mv64x60_wdt_write(struct file *file, const char *data, size_t len, loff_t * ppos) { + if (*ppos != file->f_pos) + return -ESPIPE; + if (len) mv64x60_wdt_service(); @@ -118,7 +119,6 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { int timeout; - void __user *argp = (void __user *)arg; static struct watchdog_info info = { .options = WDIOF_KEEPALIVEPING, .firmware_version = 0, @@ -127,13 +127,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, switch (cmd) { case WDIOC_GETSUPPORT: - if (copy_to_user(argp, &info, sizeof(info))) + if (copy_to_user((void *)arg, &info, sizeof(info))) return -EFAULT; break; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: - if (put_user(wdt_status, (int __user *)argp)) + if (put_user(wdt_status, (int *)arg)) return -EFAULT; wdt_status &= ~WDIOF_KEEPALIVEPING; break; @@ -154,7 +154,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, case WDIOC_GETTIMEOUT: timeout = mv64x60_wdt_timeout * HZ; - if (put_user(timeout, (int __user *)argp)) + if (put_user(timeout, (int *)arg)) return -EFAULT; break; diff --git a/trunk/drivers/infiniband/core/uverbs.h b/trunk/drivers/infiniband/core/uverbs.h index cc124344dd2c..b1897bed14ad 100644 --- a/trunk/drivers/infiniband/core/uverbs.h +++ b/trunk/drivers/infiniband/core/uverbs.h @@ -69,7 +69,6 @@ struct ib_uverbs_event_file { struct ib_uverbs_file { struct kref ref; - struct semaphore mutex; struct ib_uverbs_device *device; struct ib_ucontext *ucontext; struct ib_event_handler event_handler; diff --git a/trunk/drivers/infiniband/core/uverbs_cmd.c b/trunk/drivers/infiniband/core/uverbs_cmd.c index 562445165d2b..e91ebde46481 100644 --- a/trunk/drivers/infiniband/core/uverbs_cmd.c +++ b/trunk/drivers/infiniband/core/uverbs_cmd.c @@ -76,9 +76,8 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, struct ib_uverbs_get_context_resp resp; struct ib_udata udata; struct ib_device *ibdev = file->device->ib_dev; - struct ib_ucontext *ucontext; int i; - int ret; + int ret = in_len; if (out_len < sizeof resp) return -ENOSPC; @@ -86,56 +85,45 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; - down(&file->mutex); - - if (file->ucontext) { - ret = -EINVAL; - goto err; - } - INIT_UDATA(&udata, buf + sizeof cmd, (unsigned long) cmd.response + sizeof resp, in_len - sizeof cmd, out_len - sizeof resp); - ucontext = ibdev->alloc_ucontext(ibdev, &udata); - if (IS_ERR(ucontext)) - return PTR_ERR(file->ucontext); + file->ucontext = ibdev->alloc_ucontext(ibdev, &udata); + if (IS_ERR(file->ucontext)) { + ret = PTR_ERR(file->ucontext); + file->ucontext = NULL; + return ret; + } - ucontext->device = ibdev; - INIT_LIST_HEAD(&ucontext->pd_list); - INIT_LIST_HEAD(&ucontext->mr_list); - INIT_LIST_HEAD(&ucontext->mw_list); - INIT_LIST_HEAD(&ucontext->cq_list); - INIT_LIST_HEAD(&ucontext->qp_list); - INIT_LIST_HEAD(&ucontext->srq_list); - INIT_LIST_HEAD(&ucontext->ah_list); + file->ucontext->device = ibdev; + INIT_LIST_HEAD(&file->ucontext->pd_list); + INIT_LIST_HEAD(&file->ucontext->mr_list); + INIT_LIST_HEAD(&file->ucontext->mw_list); + INIT_LIST_HEAD(&file->ucontext->cq_list); + INIT_LIST_HEAD(&file->ucontext->qp_list); + INIT_LIST_HEAD(&file->ucontext->srq_list); + INIT_LIST_HEAD(&file->ucontext->ah_list); + spin_lock_init(&file->ucontext->lock); resp.async_fd = file->async_file.fd; for (i = 0; i < file->device->num_comp; ++i) if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab + i * sizeof (__u32), - &file->comp_file[i].fd, sizeof (__u32))) { - ret = -EFAULT; - goto err_free; - } + &file->comp_file[i].fd, sizeof (__u32))) + goto err; if (copy_to_user((void __user *) (unsigned long) cmd.response, - &resp, sizeof resp)) { - ret = -EFAULT; - goto err_free; - } - - file->ucontext = ucontext; - up(&file->mutex); + &resp, sizeof resp)) + goto err; return in_len; -err_free: - ibdev->dealloc_ucontext(ucontext); - err: - up(&file->mutex); - return ret; + ibdev->dealloc_ucontext(file->ucontext); + file->ucontext = NULL; + + return -EFAULT; } ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, @@ -364,9 +352,9 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, if (ret) goto err_pd; - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_add_tail(&uobj->list, &file->ucontext->pd_list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); memset(&resp, 0, sizeof resp); resp.pd_handle = uobj->id; @@ -380,9 +368,9 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, return in_len; err_list: - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); down(&ib_uverbs_idr_mutex); idr_remove(&ib_uverbs_pd_idr, uobj->id); @@ -422,9 +410,9 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); kfree(uobj); @@ -524,9 +512,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, resp.mr_handle = obj->uobject.id; - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp)) { @@ -539,9 +527,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, return in_len; err_list: - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&obj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); err_unreg: ib_dereg_mr(mr); @@ -582,9 +570,9 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&memobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); ib_umem_release(file->device->ib_dev, &memobj->umem); kfree(memobj); @@ -659,9 +647,9 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, if (ret) goto err_cq; - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); memset(&resp, 0, sizeof resp); resp.cq_handle = uobj->uobject.id; @@ -676,9 +664,9 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, return in_len; err_list: - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); down(&ib_uverbs_idr_mutex); idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); @@ -724,9 +712,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); spin_lock_irq(&file->comp_file[0].lock); list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { @@ -859,9 +847,9 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, resp.qp_handle = uobj->uobject.id; - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp)) { @@ -874,9 +862,9 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, return in_len; err_list: - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); err_destroy: ib_destroy_qp(qp); @@ -1001,9 +989,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); spin_lock_irq(&file->async_file.lock); list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { @@ -1148,9 +1136,9 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, resp.srq_handle = uobj->uobject.id; - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp)) { @@ -1163,9 +1151,9 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, return in_len; err_list: - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); err_destroy: ib_destroy_srq(srq); @@ -1239,9 +1227,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); - down(&file->mutex); + spin_lock_irq(&file->ucontext->lock); list_del(&uobj->uobject.list); - up(&file->mutex); + spin_unlock_irq(&file->ucontext->lock); spin_lock_irq(&file->async_file.lock); list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { diff --git a/trunk/drivers/infiniband/core/uverbs_main.c b/trunk/drivers/infiniband/core/uverbs_main.c index 12511808de21..ce5bdb7af306 100644 --- a/trunk/drivers/infiniband/core/uverbs_main.c +++ b/trunk/drivers/infiniband/core/uverbs_main.c @@ -448,9 +448,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, if (hdr.in_words * 4 != count) return -EINVAL; - if (hdr.command < 0 || - hdr.command >= ARRAY_SIZE(uverbs_cmd_table) || - !uverbs_cmd_table[hdr.command]) + if (hdr.command < 0 || hdr.command >= ARRAY_SIZE(uverbs_cmd_table)) return -EINVAL; if (!file->ucontext && @@ -486,29 +484,27 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) file = kmalloc(sizeof *file + (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file), GFP_KERNEL); - if (!file) { - ret = -ENOMEM; - goto err; - } + if (!file) + return -ENOMEM; file->device = dev; kref_init(&file->ref); - init_MUTEX(&file->mutex); file->ucontext = NULL; - kref_get(&file->ref); ret = ib_uverbs_event_init(&file->async_file, file); if (ret) - goto err_kref; + goto err; file->async_file.is_async = 1; + kref_get(&file->ref); + for (i = 0; i < dev->num_comp; ++i) { - kref_get(&file->ref); ret = ib_uverbs_event_init(&file->comp_file[i], file); if (ret) goto err_async; + kref_get(&file->ref); file->comp_file[i].is_async = 0; } @@ -528,16 +524,9 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) ib_uverbs_event_release(&file->async_file); -err_kref: - /* - * One extra kref_put() because we took a reference before the - * event file creation that failed and got us here. - */ - kref_put(&file->ref, ib_uverbs_release_file); +err: kref_put(&file->ref, ib_uverbs_release_file); -err: - module_put(dev->ib_dev->owner); return ret; } diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_cmd.c b/trunk/drivers/infiniband/hw/mthca/mthca_cmd.c index f6a8ac026557..cc758a2d2bc6 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_cmd.c @@ -605,7 +605,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, err = -EINVAL; goto out; } - for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i) { + for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i, ++nent) { if (virt != -1) { pages[nent * 2] = cpu_to_be64(virt); virt += 1 << lg; @@ -616,7 +616,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, ts += 1 << (lg - 10); ++tc; - if (++nent == MTHCA_MAILBOX_SIZE / 16) { + if (nent == MTHCA_MAILBOX_SIZE / 16) { err = mthca_cmd(dev, mailbox->dma, nent, 0, op, CMD_TIME_CLASS_B, status); if (err || *status) diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_eq.c b/trunk/drivers/infiniband/hw/mthca/mthca_eq.c index c81fa8e975ef..78152a8ad17d 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_eq.c @@ -836,7 +836,7 @@ int __devinit mthca_init_eq_table(struct mthca_dev *dev) dev->eq_table.clr_mask = swab32(1 << (dev->eq_table.inta_pin & 31)); dev->eq_table.clr_int = dev->clr_base + - (dev->eq_table.inta_pin < 32 ? 4 : 0); + (dev->eq_table.inta_pin < 31 ? 4 : 0); } dev->eq_table.arm_mask = 0; diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c b/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c index 7bd7a4bec7b4..1827400f189b 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -290,7 +290,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, int i; u8 status; - num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE; + num_icm = obj_size * nobj / MTHCA_TABLE_CHUNK_SIZE; table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL); if (!table) @@ -529,25 +529,12 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) goto found; } - for (i = start; i != end; i += dir) - if (!dev->db_tab->page[i].db_rec) { - page = dev->db_tab->page + i; - goto alloc; - } - if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { ret = -ENOMEM; goto out; } - if (group == 0) - ++dev->db_tab->max_group1; - else - --dev->db_tab->min_group2; - page = dev->db_tab->page + end; - -alloc: page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, &page->mapping, GFP_KERNEL); if (!page->db_rec) { @@ -567,6 +554,10 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) } bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); + if (group == 0) + ++dev->db_tab->max_group1; + else + --dev->db_tab->min_group2; found: j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_provider.c b/trunk/drivers/infiniband/hw/mthca/mthca_provider.c index 3f5319a46577..1c1c2e230871 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_provider.c @@ -84,7 +84,7 @@ static int mthca_query_device(struct ib_device *ibdev, props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & 0xffffff; props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); - props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); + props->hw_ver = be16_to_cpup((__be16 *) (out_mad->data + 32)); memcpy(&props->sys_image_guid, out_mad->data + 4, 8); memcpy(&props->node_guid, out_mad->data + 12, 8); diff --git a/trunk/drivers/isdn/divert/divert_procfs.c b/trunk/drivers/isdn/divert/divert_procfs.c index 0b0ea26023e5..e1f0d87de0eb 100644 --- a/trunk/drivers/isdn/divert/divert_procfs.c +++ b/trunk/drivers/isdn/divert/divert_procfs.c @@ -287,12 +287,12 @@ divert_dev_init(void) init_waitqueue_head(&rd_queue); #ifdef CONFIG_PROC_FS - isdn_proc_entry = proc_mkdir("net/isdn", NULL); + isdn_proc_entry = create_proc_entry("isdn", S_IFDIR | S_IRUGO | S_IXUGO, proc_net); if (!isdn_proc_entry) return (-1); isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); if (!isdn_divert_entry) { - remove_proc_entry("net/isdn", NULL); + remove_proc_entry("isdn", proc_net); return (-1); } isdn_divert_entry->proc_fops = &isdn_fops; @@ -312,7 +312,7 @@ divert_dev_deinit(void) #ifdef CONFIG_PROC_FS remove_proc_entry("divert", isdn_proc_entry); - remove_proc_entry("net/isdn", NULL); + remove_proc_entry("isdn", proc_net); #endif /* CONFIG_PROC_FS */ return (0); diff --git a/trunk/drivers/isdn/hardware/eicon/diva_didd.c b/trunk/drivers/isdn/hardware/eicon/diva_didd.c index 27204f4b111a..7fdf8ae5be52 100644 --- a/trunk/drivers/isdn/hardware/eicon/diva_didd.c +++ b/trunk/drivers/isdn/hardware/eicon/diva_didd.c @@ -30,6 +30,8 @@ static char *DRIVERNAME = static char *DRIVERLNAME = "divadidd"; char *DRIVERRELEASE_DIDD = "2.0"; +static char *main_proc_dir = "eicon"; + MODULE_DESCRIPTION("DIDD table driver for diva drivers"); MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); @@ -87,7 +89,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof, static int DIVA_INIT_FUNCTION create_proc(void) { - proc_net_eicon = proc_mkdir("net/eicon", NULL); + proc_net_eicon = create_proc_entry(main_proc_dir, S_IFDIR, proc_net); if (proc_net_eicon) { if ((proc_didd = @@ -103,7 +105,7 @@ static int DIVA_INIT_FUNCTION create_proc(void) static void DIVA_EXIT_FUNCTION remove_proc(void) { remove_proc_entry(DRIVERLNAME, proc_net_eicon); - remove_proc_entry("net/eicon", NULL); + remove_proc_entry(main_proc_dir, proc_net); } static int DIVA_INIT_FUNCTION divadidd_init(void) diff --git a/trunk/drivers/isdn/hardware/eicon/divasproc.c b/trunk/drivers/isdn/hardware/eicon/divasproc.c index c12efa6f8429..b6435589d459 100644 --- a/trunk/drivers/isdn/hardware/eicon/divasproc.c +++ b/trunk/drivers/isdn/hardware/eicon/divasproc.c @@ -381,7 +381,7 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a) char tmp[16]; sprintf(tmp, "%s%d", adapter_dir_name, a->controller); - if (!(de = proc_mkdir(tmp, proc_net_eicon))) + if (!(de = create_proc_entry(tmp, S_IFDIR, proc_net_eicon))) return (0); a->proc_adapter_dir = (void *) de; diff --git a/trunk/drivers/isdn/hysdn/hysdn_procconf.c b/trunk/drivers/isdn/hysdn/hysdn_procconf.c index 639582f61f41..5da507e532fc 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_procconf.c +++ b/trunk/drivers/isdn/hysdn/hysdn_procconf.c @@ -394,7 +394,7 @@ hysdn_procconf_init(void) hysdn_card *card; uchar conf_name[20]; - hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net); + hysdn_proc_entry = create_proc_entry(PROC_SUBDIR_NAME, S_IFDIR | S_IRUGO | S_IXUGO, proc_net); if (!hysdn_proc_entry) { printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n"); return (-1); diff --git a/trunk/drivers/md/dm-ioctl.c b/trunk/drivers/md/dm-ioctl.c index 54ec737195e0..200a0688f717 100644 --- a/trunk/drivers/md/dm-ioctl.c +++ b/trunk/drivers/md/dm-ioctl.c @@ -230,20 +230,11 @@ static int dm_hash_insert(const char *name, const char *uuid, struct mapped_devi static void __hash_remove(struct hash_cell *hc) { - struct dm_table *table; - /* remove from the dev hash */ list_del(&hc->uuid_list); list_del(&hc->name_list); unregister_with_devfs(hc); dm_set_mdptr(hc->md, NULL); - - table = dm_get_table(hc->md); - if (table) { - dm_table_event(table); - dm_table_put(table); - } - dm_put(hc->md); if (hc->new_map) dm_table_put(hc->new_map); diff --git a/trunk/drivers/md/dm-mpath.c b/trunk/drivers/md/dm-mpath.c index f9b7b32d5d5c..785806bdb248 100644 --- a/trunk/drivers/md/dm-mpath.c +++ b/trunk/drivers/md/dm-mpath.c @@ -329,17 +329,13 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio, /* * If we run out of usable paths, should we queue I/O or error it? */ -static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path, - unsigned save_old_value) +static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path) { unsigned long flags; spin_lock_irqsave(&m->lock, flags); - if (save_old_value) - m->saved_queue_if_no_path = m->queue_if_no_path; - else - m->saved_queue_if_no_path = queue_if_no_path; + m->saved_queue_if_no_path = m->queue_if_no_path; m->queue_if_no_path = queue_if_no_path; if (!m->queue_if_no_path && m->queue_size) queue_work(kmultipathd, &m->process_queued_ios); @@ -681,7 +677,7 @@ static int parse_features(struct arg_set *as, struct multipath *m, return 0; if (!strnicmp(shift(as), MESG_STR("queue_if_no_path"))) - return queue_if_no_path(m, 1, 0); + return queue_if_no_path(m, 1); else { ti->error = "Unrecognised multipath feature request"; return -EINVAL; @@ -1081,7 +1077,7 @@ static void multipath_presuspend(struct dm_target *ti) { struct multipath *m = (struct multipath *) ti->private; - queue_if_no_path(m, 0, 1); + queue_if_no_path(m, 0); } /* @@ -1226,9 +1222,9 @@ static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) if (argc == 1) { if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) - return queue_if_no_path(m, 1, 0); + return queue_if_no_path(m, 1); else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) - return queue_if_no_path(m, 0, 0); + return queue_if_no_path(m, 0); } if (argc != 2) diff --git a/trunk/drivers/media/dvb/frontends/tda10021.c b/trunk/drivers/media/dvb/frontends/tda10021.c index eaf130e666d8..87d5f4d8790f 100644 --- a/trunk/drivers/media/dvb/frontends/tda10021.c +++ b/trunk/drivers/media/dvb/frontends/tda10021.c @@ -100,8 +100,8 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) ret = i2c_transfer (state->i2c, msg, 2); if (ret != 2) - printk("DVB: TDA10021: %s: readreg error (ret == %i)\n", - __FUNCTION__, ret); + printk("DVB: TDA10021(%d): %s: readreg error (ret == %i)\n", + state->frontend.dvb->num, __FUNCTION__, ret); return b1[0]; } diff --git a/trunk/drivers/media/video/cpia.c b/trunk/drivers/media/video/cpia.c index b7ec9bf45085..8c08b7f1ad23 100644 --- a/trunk/drivers/media/video/cpia.c +++ b/trunk/drivers/media/video/cpia.c @@ -1397,7 +1397,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam) static void proc_cpia_create(void) { - cpia_proc_root = proc_mkdir("cpia", NULL); + cpia_proc_root = create_proc_entry("cpia", S_IFDIR, NULL); if (cpia_proc_root) cpia_proc_root->owner = THIS_MODULE; diff --git a/trunk/drivers/media/video/rds.h b/trunk/drivers/media/video/rds.h index 0d30eb744e61..30337d0f1a87 100644 --- a/trunk/drivers/media/video/rds.h +++ b/trunk/drivers/media/video/rds.h @@ -31,7 +31,7 @@ struct rds_command { unsigned int block_count; int result; - unsigned char __user *buffer; + unsigned char *buffer; struct file *instance; poll_table *event_list; }; diff --git a/trunk/drivers/media/video/saa6588.c b/trunk/drivers/media/video/saa6588.c index 72b70eb5da1d..1a657a70ff43 100644 --- a/trunk/drivers/media/video/saa6588.c +++ b/trunk/drivers/media/video/saa6588.c @@ -157,7 +157,7 @@ static struct i2c_client client_template; /* ---------------------------------------------------------------------- */ -static int block_to_user_buf(struct saa6588 *s, unsigned char __user *user_buf) +static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) { int i; @@ -191,7 +191,7 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a) { unsigned long flags; - unsigned char __user *buf_ptr = a->buffer; + unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ unsigned int i; unsigned int rd_blocks; diff --git a/trunk/drivers/mtd/maps/ixp4xx.c b/trunk/drivers/mtd/maps/ixp4xx.c index bbb0e6e569a6..5afe660aa2c4 100644 --- a/trunk/drivers/mtd/maps/ixp4xx.c +++ b/trunk/drivers/mtd/maps/ixp4xx.c @@ -254,6 +254,6 @@ module_init(ixp4xx_flash_init); module_exit(ixp4xx_flash_exit); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems"); +MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems") MODULE_AUTHOR("Deepak Saxena"); diff --git a/trunk/drivers/net/ibmveth.c b/trunk/drivers/net/ibmveth.c index a2c4dd4fb221..32d5fabd4b10 100644 --- a/trunk/drivers/net/ibmveth.c +++ b/trunk/drivers/net/ibmveth.c @@ -99,7 +99,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*); #ifdef CONFIG_PROC_FS -#define IBMVETH_PROC_DIR "net/ibmveth" +#define IBMVETH_PROC_DIR "ibmveth" static struct proc_dir_entry *ibmveth_proc_dir; #endif @@ -1010,7 +1010,7 @@ static int __devexit ibmveth_remove(struct vio_dev *dev) #ifdef CONFIG_PROC_FS static void ibmveth_proc_register_driver(void) { - ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL); + ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR, proc_net); if (ibmveth_proc_dir) { SET_MODULE_OWNER(ibmveth_proc_dir); } @@ -1018,7 +1018,7 @@ static void ibmveth_proc_register_driver(void) static void ibmveth_proc_unregister_driver(void) { - remove_proc_entry(IBMVETH_PROC_DIR, NULL); + remove_proc_entry(IBMVETH_PROC_DIR, proc_net); } static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) diff --git a/trunk/drivers/net/irda/vlsi_ir.c b/trunk/drivers/net/irda/vlsi_ir.c index 651c5a6578fd..6d9de626c967 100644 --- a/trunk/drivers/net/irda/vlsi_ir.c +++ b/trunk/drivers/net/irda/vlsi_ir.c @@ -1875,11 +1875,11 @@ static int __init vlsi_mod_init(void) sirpulse = !!sirpulse; - /* proc_mkdir returns NULL if !CONFIG_PROC_FS. + /* create_proc_entry returns NULL if !CONFIG_PROC_FS. * Failure to create the procfs entry is handled like running * without procfs - it's not required for the driver to work. */ - vlsi_proc_root = proc_mkdir(PROC_DIR, NULL); + vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, NULL); if (vlsi_proc_root) { /* protect registered procdir against module removal. * Because we are in the module init path there's no race diff --git a/trunk/drivers/net/pppoe.c b/trunk/drivers/net/pppoe.c index a842ecc60a34..82f236cc3b9b 100644 --- a/trunk/drivers/net/pppoe.c +++ b/trunk/drivers/net/pppoe.c @@ -1070,7 +1070,7 @@ static int __init pppoe_proc_init(void) { struct proc_dir_entry *p; - p = create_proc_entry("net/pppoe", S_IRUGO, NULL); + p = create_proc_entry("pppoe", S_IRUGO, proc_net); if (!p) return -ENOMEM; @@ -1142,7 +1142,7 @@ static void __exit pppoe_exit(void) dev_remove_pack(&pppoes_ptype); dev_remove_pack(&pppoed_ptype); unregister_netdevice_notifier(&pppoe_notifier); - remove_proc_entry("net/pppoe", NULL); + remove_proc_entry("pppoe", proc_net); proto_unregister(&pppoe_sk_proto); } diff --git a/trunk/drivers/net/sk98lin/skge.c b/trunk/drivers/net/sk98lin/skge.c index b18c92cb629e..2e72d79a143c 100644 --- a/trunk/drivers/net/sk98lin/skge.c +++ b/trunk/drivers/net/sk98lin/skge.c @@ -235,7 +235,7 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr); * Extern Function Prototypes * ******************************************************************************/ -static const char SKRootName[] = "net/sk98lin"; +static const char SKRootName[] = "sk98lin"; static struct proc_dir_entry *pSkRootDir; extern struct file_operations sk_proc_fops; @@ -5242,20 +5242,20 @@ static int __init skge_init(void) { int error; - pSkRootDir = proc_mkdir(SKRootName, NULL); + pSkRootDir = proc_mkdir(SKRootName, proc_net); if (pSkRootDir) pSkRootDir->owner = THIS_MODULE; error = pci_register_driver(&skge_driver); if (error) - remove_proc_entry(SKRootName, NULL); + proc_net_remove(SKRootName); return error; } static void __exit skge_exit(void) { pci_unregister_driver(&skge_driver); - remove_proc_entry(SKRootName, NULL); + proc_net_remove(SKRootName); } diff --git a/trunk/drivers/net/wireless/orinoco.c b/trunk/drivers/net/wireless/orinoco.c index 6deb7cc810cc..8de49fe57233 100644 --- a/trunk/drivers/net/wireless/orinoco.c +++ b/trunk/drivers/net/wireless/orinoco.c @@ -2458,6 +2458,7 @@ struct net_device *alloc_orinocodev(int sizeof_card, dev->watchdog_timeo = HZ; /* 1 second timeout */ dev->get_stats = orinoco_get_stats; dev->ethtool_ops = &orinoco_ethtool_ops; + dev->get_wireless_stats = orinoco_get_wireless_stats; dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def; dev->change_mtu = orinoco_change_mtu; dev->set_multicast_list = orinoco_set_multicast_list; @@ -4398,7 +4399,6 @@ static const struct iw_handler_def orinoco_handler_def = { .standard = orinoco_handler, .private = orinoco_private_handler, .private_args = orinoco_privtab, - .get_wireless_stats = orinoco_get_wireless_stats, }; static void orinoco_get_drvinfo(struct net_device *dev, diff --git a/trunk/drivers/pcmcia/rsrc_nonstatic.c b/trunk/drivers/pcmcia/rsrc_nonstatic.c index f9a5c70284b5..c42455d20eb6 100644 --- a/trunk/drivers/pcmcia/rsrc_nonstatic.c +++ b/trunk/drivers/pcmcia/rsrc_nonstatic.c @@ -691,7 +691,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned unsigned long size = end - start + 1; int ret = 0; - if (end < start) + if (end <= start) return -EINVAL; down(&rsrc_sem); @@ -724,7 +724,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long unsigned long size = end - start + 1; int ret = 0; - if (end < start) + if (end <= start) return -EINVAL; if (end > IO_SPACE_LIMIT) @@ -817,7 +817,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) /* if we got at least one of IO, and one of MEM, we can be glad and * activate the PCMCIA subsystem */ - if (done == (IORESOURCE_MEM | IORESOURCE_IO)) + if (done & (IORESOURCE_MEM | IORESOURCE_IO)) s->resource_setup_done = 1; return 0; @@ -925,7 +925,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size return -EINVAL; } } - if (end_addr < start_addr) + if (end_addr <= start_addr) return -EINVAL; ret = adjust_io(s, add, start_addr, end_addr); @@ -977,7 +977,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz return -EINVAL; } } - if (end_addr < start_addr) + if (end_addr <= start_addr) return -EINVAL; ret = adjust_memory(s, add, start_addr, end_addr); diff --git a/trunk/drivers/scsi/sg.c b/trunk/drivers/scsi/sg.c index ad94367df430..4d09a6e4dd2e 100644 --- a/trunk/drivers/scsi/sg.c +++ b/trunk/drivers/scsi/sg.c @@ -2849,7 +2849,8 @@ sg_proc_init(void) struct proc_dir_entry *pdep; struct sg_proc_leaf * leaf; - sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL); + sg_proc_sgp = create_proc_entry(sg_proc_sg_dirname, + S_IFDIR | S_IRUGO | S_IXUGO, NULL); if (!sg_proc_sgp) return 1; for (k = 0; k < num_leaves; ++k) { diff --git a/trunk/drivers/usb/media/vicam.c b/trunk/drivers/usb/media/vicam.c index 0bc0b1247a6b..4a5857c53f11 100644 --- a/trunk/drivers/usb/media/vicam.c +++ b/trunk/drivers/usb/media/vicam.c @@ -1148,7 +1148,7 @@ vicam_write_proc_gain(struct file *file, const char *buffer, static void vicam_create_proc_root(void) { - vicam_proc_root = proc_mkdir("video/vicam", NULL); + vicam_proc_root = create_proc_entry("video/vicam", S_IFDIR, 0); if (vicam_proc_root) vicam_proc_root->owner = THIS_MODULE; @@ -1181,7 +1181,7 @@ vicam_create_proc_entry(struct vicam_camera *cam) sprintf(name, "video%d", cam->vdev.minor); - cam->proc_dir = proc_mkdir(name, vicam_proc_root); + cam->proc_dir = create_proc_entry(name, S_IFDIR, vicam_proc_root); if ( !cam->proc_dir ) return; // FIXME: We should probably return an error here diff --git a/trunk/drivers/video/Kconfig b/trunk/drivers/video/Kconfig index 1cd942abb580..773ae11b4a19 100644 --- a/trunk/drivers/video/Kconfig +++ b/trunk/drivers/video/Kconfig @@ -768,7 +768,6 @@ config FB_INTEL select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_SOFT_CURSOR help This driver supports the on-board graphics built in to the Intel 830M/845G/852GM/855GM/865G chipsets. diff --git a/trunk/drivers/video/cyblafb.c b/trunk/drivers/video/cyblafb.c index 6992100a508c..ae2762cb5608 100644 --- a/trunk/drivers/video/cyblafb.c +++ b/trunk/drivers/video/cyblafb.c @@ -410,21 +410,20 @@ static void cyblafb_imageblit(struct fb_info *info, out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1)); while(index < index_end) { - const char *p = image->data + index; for(i=0;idata + index))); index+=4; } switch(width_dbs) { case 0: break; - case 8: out32(GE9C,*(u8*)p); + case 8: out32(GE9C,*((u8*)((u32)image->data+index))); index+=1; break; - case 16: out32(GE9C,*(u16*)p); + case 16: out32(GE9C,*((u16*)((u32)image->data+index))); index+=2; break; - case 24: out32(GE9C,*(u16*)p | *(u8*)(p+2)<<16); + case 24: out32(GE9C,(u32)(*((u16*)((u32)image->data+index))) | + (u32)(*((u8*)((u32)image->data+index+2)))<<16); index+=3; break; } diff --git a/trunk/drivers/video/i810/i810-i2c.c b/trunk/drivers/video/i810/i810-i2c.c index 689d2586366d..fda53aac1fc1 100644 --- a/trunk/drivers/video/i810/i810-i2c.c +++ b/trunk/drivers/video/i810/i810-i2c.c @@ -44,7 +44,7 @@ static void i810i2c_setscl(void *data, int state) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK); @@ -55,7 +55,7 @@ static void i810i2c_setsda(void *data, int state) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK); @@ -66,7 +66,7 @@ static int i810i2c_getscl(void *data) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOB, SCL_DIR_MASK); i810_writel(mmio, GPIOB, 0); @@ -77,7 +77,7 @@ static int i810i2c_getsda(void *data) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOB, SDA_DIR_MASK); i810_writel(mmio, GPIOB, 0); @@ -88,7 +88,7 @@ static void i810ddc_setscl(void *data, int state) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK); @@ -99,7 +99,7 @@ static void i810ddc_setsda(void *data, int state) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK); @@ -110,7 +110,7 @@ static int i810ddc_getscl(void *data) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOA, SCL_DIR_MASK); i810_writel(mmio, GPIOA, 0); @@ -121,7 +121,7 @@ static int i810ddc_getsda(void *data) { struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; struct i810fb_par *par = chan->par; - u8 __iomem *mmio = par->mmio_start_virtual; + u8 *mmio = par->mmio_start_virtual; i810_writel(mmio, GPIOA, SDA_DIR_MASK); i810_writel(mmio, GPIOA, 0); diff --git a/trunk/drivers/video/intelfb/intelfbdrv.c b/trunk/drivers/video/intelfb/intelfbdrv.c index 80a09344f1aa..bf62e6ed0382 100644 --- a/trunk/drivers/video/intelfb/intelfbdrv.c +++ b/trunk/drivers/video/intelfb/intelfbdrv.c @@ -226,7 +226,7 @@ MODULE_DEVICE_TABLE(pci, intelfb_pci_table); static int accel = 1; static int vram = 4; -static int hwcursor = 0; +static int hwcursor = 1; static int mtrr = 1; static int fixed = 0; static int noinit = 0; @@ -609,9 +609,15 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) dinfo->accel = 0; } + if (MB(voffset) < stolen_size) + offset = (stolen_size >> 12); + else + offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; + /* Framebuffer parameters - Use all the stolen memory if >= vram */ - if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) { + if (ROUND_UP_TO_PAGE(stolen_size) >= ((offset << 12) + MB(vram))) { dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); + dinfo->fb.offset = 0; dinfo->fbmem_gart = 0; } else { dinfo->fb.size = MB(vram); @@ -642,11 +648,6 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) return -ENODEV; } - if (MB(voffset) < stolen_size) - offset = (stolen_size >> 12); - else - offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; - /* set the mem offsets - set them after the already used pages */ if (dinfo->accel) { dinfo->ring.offset = offset + gtt_info.current_memory; @@ -661,11 +662,10 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) + (dinfo->cursor.size >> 12); } - /* Allocate memories (which aren't stolen) */ /* Map the fb and MMIO regions */ /* ioremap only up to the end of used aperture */ dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache - (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12) + (dinfo->aperture.physical, (dinfo->fb.offset << 12) + dinfo->fb.size); if (!dinfo->aperture.virtual) { ERR_MSG("Cannot remap FB region.\n"); @@ -682,6 +682,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) return -ENODEV; } + /* Allocate memories (which aren't stolen) */ if (dinfo->accel) { if (!(dinfo->gtt_ring_mem = agp_allocate_memory(bridge, dinfo->ring.size >> 12, @@ -1483,7 +1484,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) #endif if (!dinfo->hwcursor) - return soft_cursor(info, cursor); + return -ENXIO; intelfbhw_cursor_hide(dinfo); diff --git a/trunk/drivers/video/s3c2410fb.c b/trunk/drivers/video/s3c2410fb.c index 5ab79afb53b7..00c0223a352e 100644 --- a/trunk/drivers/video/s3c2410fb.c +++ b/trunk/drivers/video/s3c2410fb.c @@ -228,8 +228,8 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var, * information */ -static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi, - struct fb_var_screeninfo *var) +static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi, + struct fb_var_screeninfo *var) { fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; diff --git a/trunk/fs/9p/fid.c b/trunk/fs/9p/fid.c index d95f8626d170..821c9c4d76aa 100644 --- a/trunk/fs/9p/fid.c +++ b/trunk/fs/9p/fid.c @@ -71,28 +71,21 @@ static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) * */ -struct v9fs_fid *v9fs_fid_create(struct dentry *dentry, - struct v9fs_session_info *v9ses, int fid, int create) +struct v9fs_fid *v9fs_fid_create(struct dentry *dentry) { struct v9fs_fid *new; - dprintk(DEBUG_9P, "fid create dentry %p, fid %d, create %d\n", - dentry, fid, create); - new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); if (new == NULL) { dprintk(DEBUG_ERROR, "Out of Memory\n"); return ERR_PTR(-ENOMEM); } - new->fid = fid; - new->v9ses = v9ses; + new->fid = -1; new->fidopen = 0; - new->fidcreate = create; + new->fidcreate = 0; new->fidclunked = 0; new->iounit = 0; - new->rdir_pos = 0; - new->rdir_fcall = NULL; if (v9fs_fid_insert(new, dentry) == 0) return new; @@ -115,59 +108,6 @@ void v9fs_fid_destroy(struct v9fs_fid *fid) kfree(fid); } -/** - * v9fs_fid_walk_up - walks from the process current directory - * up to the specified dentry. - */ -static struct v9fs_fid *v9fs_fid_walk_up(struct dentry *dentry) -{ - int fidnum, cfidnum, err; - struct v9fs_fid *cfid; - struct dentry *cde; - struct v9fs_session_info *v9ses; - - v9ses = v9fs_inode2v9ses(current->fs->pwd->d_inode); - cfid = v9fs_fid_lookup(current->fs->pwd); - if (cfid == NULL) { - dprintk(DEBUG_ERROR, "process cwd doesn't have a fid\n"); - return ERR_PTR(-ENOENT); - } - - cfidnum = cfid->fid; - cde = current->fs->pwd; - /* TODO: take advantage of multiwalk */ - - fidnum = v9fs_get_idpool(&v9ses->fidpool); - if (fidnum < 0) { - dprintk(DEBUG_ERROR, "could not get a new fid num\n"); - err = -ENOENT; - goto clunk_fid; - } - - while (cde != dentry) { - if (cde == cde->d_parent) { - dprintk(DEBUG_ERROR, "can't find dentry\n"); - err = -ENOENT; - goto clunk_fid; - } - - err = v9fs_t_walk(v9ses, cfidnum, fidnum, "..", NULL); - if (err < 0) { - dprintk(DEBUG_ERROR, "problem walking to parent\n"); - goto clunk_fid; - } - - cfidnum = fidnum; - cde = cde->d_parent; - } - - return v9fs_fid_create(dentry, v9ses, fidnum, 0); - -clunk_fid: - v9fs_t_clunk(v9ses, fidnum, NULL); - return ERR_PTR(err); -} - /** * v9fs_fid_lookup - retrieve the right fid from a particular dentry * @dentry: dentry to look for fid in @@ -179,25 +119,49 @@ static struct v9fs_fid *v9fs_fid_walk_up(struct dentry *dentry) * */ -struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry) +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) { struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; struct v9fs_fid *current_fid = NULL; struct v9fs_fid *temp = NULL; struct v9fs_fid *return_fid = NULL; + int found_parent = 0; + int found_user = 0; - dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); + dprintk(DEBUG_9P, " dentry: %s (%p) type %d\n", dentry->d_iname, dentry, + type); - if (fid_list) { + if (fid_list && !list_empty(fid_list)) { list_for_each_entry_safe(current_fid, temp, fid_list, list) { - if (!current_fid->fidcreate) { - return_fid = current_fid; - break; + if (current_fid->uid == current->uid) { + if (return_fid == NULL) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_user = 1; + } + } + } + if (current_fid->pid == current->real_parent->pid) { + if ((return_fid == NULL) || (found_parent) + || (found_user)) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 1; + found_user = 0; + } + } + } + if (current_fid->pid == current->pid) { + if ((type == FID_OP) || + (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 0; + found_user = 0; + } } } - - if (!return_fid) - return_fid = current_fid; } /* we are at the root but didn't match */ @@ -223,33 +187,55 @@ struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry) /* XXX - there may be some duplication we can get rid of */ if (par == dentry) { - return_fid = v9fs_fid_walk_up(dentry); - if (IS_ERR(return_fid)) - return_fid = NULL; - } - } + /* we need to fid_lookup the starting point */ + int fidnum = -1; + int oldfid = -1; + int result = -1; + struct v9fs_session_info *v9ses = + v9fs_inode2v9ses(current->fs->pwd->d_inode); + + current_fid = + v9fs_fid_lookup(current->fs->pwd, FID_WALK); + if (current_fid == NULL) { + dprintk(DEBUG_ERROR, + "process cwd doesn't have a fid\n"); + return return_fid; + } + oldfid = current_fid->fid; + par = current->fs->pwd; + /* TODO: take advantage of multiwalk */ - return return_fid; -} + fidnum = v9fs_get_idpool(&v9ses->fidpool); + if (fidnum < 0) { + dprintk(DEBUG_ERROR, + "could not get a new fid num\n"); + return return_fid; + } -struct v9fs_fid *v9fs_fid_get_created(struct dentry *dentry) -{ - struct list_head *fid_list; - struct v9fs_fid *fid, *ftmp, *ret; - - dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); - fid_list = (struct list_head *)dentry->d_fsdata; - ret = NULL; - if (fid_list) { - list_for_each_entry_safe(fid, ftmp, fid_list, list) { - if (fid->fidcreate && fid->pid == current->pid) { - list_del(&fid->list); - ret = fid; - break; + while (par != dentry) { + result = + v9fs_t_walk(v9ses, oldfid, fidnum, "..", + NULL); + if (result < 0) { + dprintk(DEBUG_ERROR, + "problem walking to parent\n"); + + break; + } + oldfid = fidnum; + if (par == par->d_parent) { + dprintk(DEBUG_ERROR, + "can't find dentry\n"); + break; + } + par = par->d_parent; + } + if (par == dentry) { + return_fid = v9fs_fid_create(dentry); + return_fid->fid = fidnum; } } } - dprintk(DEBUG_9P, "return %p\n", ret); - return ret; + return return_fid; } diff --git a/trunk/fs/9p/fid.h b/trunk/fs/9p/fid.h index 84c673a44c83..7db478ccca36 100644 --- a/trunk/fs/9p/fid.h +++ b/trunk/fs/9p/fid.h @@ -25,7 +25,6 @@ #define FID_OP 0 #define FID_WALK 1 -#define FID_CREATE 2 struct v9fs_fid { struct list_head list; /* list of fids associated with a dentry */ @@ -53,8 +52,6 @@ struct v9fs_fid { struct v9fs_session_info *v9ses; /* session info for this FID */ }; -struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry); -struct v9fs_fid *v9fs_fid_get_created(struct dentry *); +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type); void v9fs_fid_destroy(struct v9fs_fid *fid); -struct v9fs_fid *v9fs_fid_create(struct dentry *, - struct v9fs_session_info *v9ses, int fid, int create); +struct v9fs_fid *v9fs_fid_create(struct dentry *); diff --git a/trunk/fs/9p/vfs_dentry.c b/trunk/fs/9p/vfs_dentry.c index a6aa947de0f9..306c96741f81 100644 --- a/trunk/fs/9p/vfs_dentry.c +++ b/trunk/fs/9p/vfs_dentry.c @@ -67,7 +67,7 @@ static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd) struct dentry *dc = current->fs->pwd; dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); - if (v9fs_fid_lookup(dentry)) { + if (v9fs_fid_lookup(dentry, FID_OP)) { dprintk(DEBUG_VFS, "VALID\n"); return 1; } diff --git a/trunk/fs/9p/vfs_dir.c b/trunk/fs/9p/vfs_dir.c index 57a43b8feef5..c478a7384186 100644 --- a/trunk/fs/9p/vfs_dir.c +++ b/trunk/fs/9p/vfs_dir.c @@ -197,18 +197,21 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) filemap_fdatawait(inode->i_mapping); if (fidnum >= 0) { + fid->fidopen--; dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, fid->fid); - if (v9fs_t_clunk(v9ses, fidnum, NULL)) - dprintk(DEBUG_ERROR, "clunk failed\n"); + if (fid->fidopen == 0) { + if (v9fs_t_clunk(v9ses, fidnum, NULL)) + dprintk(DEBUG_ERROR, "clunk failed\n"); - v9fs_put_idpool(fid->fid, &v9ses->fidpool); + v9fs_put_idpool(fid->fid, &v9ses->fidpool); + } kfree(fid->rdir_fcall); - kfree(fid); filp->private_data = NULL; + v9fs_fid_destroy(fid); } d_drop(filp->f_dentry); diff --git a/trunk/fs/9p/vfs_file.c b/trunk/fs/9p/vfs_file.c index a4799e971d1c..1f8ae7d580ab 100644 --- a/trunk/fs/9p/vfs_file.c +++ b/trunk/fs/9p/vfs_file.c @@ -53,36 +53,30 @@ int v9fs_file_open(struct inode *inode, struct file *file) { struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); - struct v9fs_fid *v9fid, *fid; + struct v9fs_fid *v9fid = v9fs_fid_lookup(file->f_dentry, FID_WALK); + struct v9fs_fid *v9newfid = NULL; struct v9fs_fcall *fcall = NULL; int open_mode = 0; unsigned int iounit = 0; int newfid = -1; long result = -1; - dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file); - - v9fid = v9fs_fid_get_created(file->f_dentry); - if (!v9fid) - v9fid = v9fs_fid_lookup(file->f_dentry); + dprintk(DEBUG_VFS, "inode: %p file: %p v9fid= %p\n", inode, file, + v9fid); if (!v9fid) { + struct dentry *dentry = file->f_dentry; dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); - return -EBADF; - } - if (!v9fid->fidcreate) { - fid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); - if (fid == NULL) { - dprintk(DEBUG_ERROR, "Out of Memory\n"); - return -ENOMEM; - } + /* XXX - some duplication from lookup, generalize later */ + /* basically vfs_lookup is too heavy weight */ + v9fid = v9fs_fid_lookup(file->f_dentry, FID_OP); + if (!v9fid) + return -EBADF; - fid->fidopen = 0; - fid->fidcreate = 0; - fid->fidclunked = 0; - fid->iounit = 0; - fid->v9ses = v9ses; + v9fid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); + if (!v9fid) + return -EBADF; newfid = v9fs_get_idpool(&v9ses->fidpool); if (newfid < 0) { @@ -91,16 +85,58 @@ int v9fs_file_open(struct inode *inode, struct file *file) } result = - v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, NULL); - + v9fs_t_walk(v9ses, v9fid->fid, newfid, + (char *)file->f_dentry->d_name.name, NULL); if (result < 0) { v9fs_put_idpool(newfid, &v9ses->fidpool); dprintk(DEBUG_ERROR, "rewalk didn't work\n"); return -EBADF; } - fid->fid = newfid; - v9fid = fid; + v9fid = v9fs_fid_create(dentry); + if (v9fid == NULL) { + dprintk(DEBUG_ERROR, "couldn't insert\n"); + return -ENOMEM; + } + v9fid->fid = newfid; + } + + if (v9fid->fidcreate) { + /* create case */ + newfid = v9fid->fid; + iounit = v9fid->iounit; + v9fid->fidcreate = 0; + } else { + if (!S_ISDIR(inode->i_mode)) + newfid = v9fid->fid; + else { + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "allocation failed\n"); + return -ENOSPC; + } + /* This would be a somewhat critical clone */ + result = + v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, + &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "clone error: %s\n", + FCALL_ERROR(fcall)); + kfree(fcall); + return result; + } + + v9newfid = v9fs_fid_create(file->f_dentry); + v9newfid->fid = newfid; + v9newfid->qid = v9fid->qid; + v9newfid->iounit = v9fid->iounit; + v9newfid->fidopen = 0; + v9newfid->fidclunked = 0; + v9newfid->v9ses = v9ses; + v9fid = v9newfid; + kfree(fcall); + } + /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ /* translate open mode appropriately */ open_mode = file->f_flags & 0x3; @@ -127,13 +163,9 @@ int v9fs_file_open(struct inode *inode, struct file *file) iounit = fcall->params.ropen.iounit; kfree(fcall); - } else { - /* create case */ - newfid = v9fid->fid; - iounit = v9fid->iounit; - v9fid->fidcreate = 0; } + file->private_data = v9fid; v9fid->rdir_pos = 0; diff --git a/trunk/fs/9p/vfs_inode.c b/trunk/fs/9p/vfs_inode.c index 2b696ae6655a..b16322db5ce6 100644 --- a/trunk/fs/9p/vfs_inode.c +++ b/trunk/fs/9p/vfs_inode.c @@ -307,7 +307,7 @@ v9fs_create(struct inode *dir, struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); struct super_block *sb = dir->i_sb; struct v9fs_fid *dirfid = - v9fs_fid_lookup(file_dentry->d_parent); + v9fs_fid_lookup(file_dentry->d_parent, FID_WALK); struct v9fs_fid *fid = NULL; struct inode *file_inode = NULL; struct v9fs_fcall *fcall = NULL; @@ -317,7 +317,6 @@ v9fs_create(struct inode *dir, long newfid = -1; int result = 0; unsigned int iounit = 0; - int wfidno = -1; perm = unixmode2p9mode(v9ses, perm); @@ -351,7 +350,7 @@ v9fs_create(struct inode *dir, if (result < 0) { dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); v9fs_put_idpool(newfid, &v9ses->fidpool); - newfid = -1; + newfid = 0; goto CleanUpFid; } @@ -370,39 +369,20 @@ v9fs_create(struct inode *dir, qid = fcall->params.rcreate.qid; kfree(fcall); - fid = v9fs_fid_create(file_dentry, v9ses, newfid, 1); - dprintk(DEBUG_VFS, "fid %p %d\n", fid, fid->fidcreate); + fid = v9fs_fid_create(file_dentry); if (!fid) { result = -ENOMEM; goto CleanUpFid; } + fid->fid = newfid; + fid->fidopen = 0; + fid->fidcreate = 1; fid->qid = qid; fid->iounit = iounit; - - /* walk to the newly created file and put the fid in the dentry */ - wfidno = v9fs_get_idpool(&v9ses->fidpool); - if (newfid < 0) { - eprintk(KERN_WARNING, "no free fids available\n"); - return -ENOSPC; - } - - result = v9fs_t_walk(v9ses, dirfidnum, wfidno, - (char *) file_dentry->d_name.name, NULL); - if (result < 0) { - dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); - v9fs_put_idpool(wfidno, &v9ses->fidpool); - wfidno = -1; - goto CleanUpFid; - } - - if (!v9fs_fid_create(file_dentry, v9ses, wfidno, 0)) { - if (!v9fs_t_clunk(v9ses, newfid, &fcall)) { - v9fs_put_idpool(wfidno, &v9ses->fidpool); - } - - goto CleanUpFid; - } + fid->rdir_pos = 0; + fid->rdir_fcall = NULL; + fid->v9ses = v9ses; if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || @@ -430,11 +410,11 @@ v9fs_create(struct inode *dir, d_instantiate(file_dentry, file_inode); if (perm & V9FS_DMDIR) { - if (!v9fs_t_clunk(v9ses, newfid, &fcall)) - v9fs_put_idpool(newfid, &v9ses->fidpool); - else + if (v9fs_t_clunk(v9ses, newfid, &fcall)) dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", FCALL_ERROR(fcall)); + + v9fs_put_idpool(newfid, &v9ses->fidpool); kfree(fcall); fid->fidopen = 0; fid->fidcreate = 0; @@ -446,22 +426,12 @@ v9fs_create(struct inode *dir, CleanUpFid: kfree(fcall); - if (newfid >= 0) { - if (!v9fs_t_clunk(v9ses, newfid, &fcall)) - v9fs_put_idpool(newfid, &v9ses->fidpool); - else - dprintk(DEBUG_ERROR, "clunk failed: %s\n", - FCALL_ERROR(fcall)); - - kfree(fcall); - } - if (wfidno >= 0) { - if (!v9fs_t_clunk(v9ses, wfidno, &fcall)) - v9fs_put_idpool(wfidno, &v9ses->fidpool); - else + if (newfid) { + if (v9fs_t_clunk(v9ses, newfid, &fcall)) dprintk(DEBUG_ERROR, "clunk failed: %s\n", FCALL_ERROR(fcall)); + v9fs_put_idpool(newfid, &v9ses->fidpool); kfree(fcall); } return result; @@ -491,7 +461,7 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir) file_inode = file->d_inode; sb = file_inode->i_sb; v9ses = v9fs_inode2v9ses(file_inode); - v9fid = v9fs_fid_lookup(file); + v9fid = v9fs_fid_lookup(file, FID_OP); if (!v9fid) { dprintk(DEBUG_ERROR, @@ -575,7 +545,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, sb = dir->i_sb; v9ses = v9fs_inode2v9ses(dir); - dirfid = v9fs_fid_lookup(dentry->d_parent); + dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); if (!dirfid) { dprintk(DEBUG_ERROR, "no dirfid\n"); @@ -603,7 +573,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, v9fs_put_idpool(newfid, &v9ses->fidpool); if (result == -ENOENT) { d_add(dentry, NULL); - dprintk(DEBUG_VFS, + dprintk(DEBUG_ERROR, "Return negative dentry %p count %d\n", dentry, atomic_read(&dentry->d_count)); return NULL; @@ -631,13 +601,16 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); - fid = v9fs_fid_create(dentry, v9ses, newfid, 0); + fid = v9fs_fid_create(dentry); if (fid == NULL) { dprintk(DEBUG_ERROR, "couldn't insert\n"); result = -ENOMEM; goto FreeFcall; } + fid->fid = newfid; + fid->fidopen = 0; + fid->v9ses = v9ses; fid->qid = fcall->params.rstat.stat->qid; dentry->d_op = &v9fs_dentry_operations; @@ -692,11 +665,11 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, { struct inode *old_inode = old_dentry->d_inode; struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); - struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK); struct v9fs_fid *olddirfid = - v9fs_fid_lookup(old_dentry->d_parent); + v9fs_fid_lookup(old_dentry->d_parent, FID_WALK); struct v9fs_fid *newdirfid = - v9fs_fid_lookup(new_dentry->d_parent); + v9fs_fid_lookup(new_dentry->d_parent, FID_WALK); struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); struct v9fs_fcall *fcall = NULL; int fid = -1; @@ -771,7 +744,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, { struct v9fs_fcall *fcall = NULL; struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); - struct v9fs_fid *fid = v9fs_fid_lookup(dentry); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); int err = -EPERM; dprintk(DEBUG_VFS, "dentry: %p\n", dentry); @@ -805,7 +778,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) { struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); - struct v9fs_fid *fid = v9fs_fid_lookup(dentry); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); struct v9fs_fcall *fcall = NULL; struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); int res = -EPERM; @@ -987,7 +960,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) if (retval != 0) goto FreeFcall; - newfid = v9fs_fid_lookup(dentry); + newfid = v9fs_fid_lookup(dentry, FID_OP); /* issue a twstat */ v9fs_blank_mistat(v9ses, mistat); @@ -1031,7 +1004,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) struct v9fs_fcall *fcall = NULL; struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); - struct v9fs_fid *fid = v9fs_fid_lookup(dentry); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); if (!fid) { dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); @@ -1175,7 +1148,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); struct v9fs_fcall *fcall = NULL; struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); - struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP); struct v9fs_fid *newfid = NULL; char *symname = __getname(); @@ -1195,7 +1168,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, if (retval != 0) goto FreeMem; - newfid = v9fs_fid_lookup(dentry); + newfid = v9fs_fid_lookup(dentry, FID_OP); if (!newfid) { dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); goto FreeMem; @@ -1273,7 +1246,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) if (retval != 0) goto FreeMem; - newfid = v9fs_fid_lookup(dentry); + newfid = v9fs_fid_lookup(dentry, FID_OP); if (!newfid) { dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); retval = -EINVAL; diff --git a/trunk/fs/9p/vfs_super.c b/trunk/fs/9p/vfs_super.c index 0957f4da91d4..1e2b2b54d300 100644 --- a/trunk/fs/9p/vfs_super.c +++ b/trunk/fs/9p/vfs_super.c @@ -129,7 +129,8 @@ static struct super_block *v9fs_get_sb(struct file_system_type if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { dprintk(DEBUG_ERROR, "problem initiating session\n"); - return newfid; + kfree(v9ses); + return ERR_PTR(newfid); } sb = sget(fs_type, NULL, v9fs_set_super, v9ses); @@ -154,19 +155,23 @@ static struct super_block *v9fs_get_sb(struct file_system_type sb->s_root = root; + /* Setup the Root Inode */ + root_fid = v9fs_fid_create(root); + if (root_fid == NULL) { + retval = -ENOMEM; + goto put_back_sb; + } + + root_fid->fidopen = 0; + root_fid->v9ses = v9ses; + stat_result = v9fs_t_stat(v9ses, newfid, &fcall); if (stat_result < 0) { dprintk(DEBUG_ERROR, "stat error\n"); v9fs_t_clunk(v9ses, newfid, NULL); v9fs_put_idpool(newfid, &v9ses->fidpool); } else { - /* Setup the Root Inode */ - root_fid = v9fs_fid_create(root, v9ses, newfid, 0); - if (root_fid == NULL) { - retval = -ENOMEM; - goto put_back_sb; - } - + root_fid->fid = newfid; root_fid->qid = fcall->params.rstat.stat->qid; root->d_inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); diff --git a/trunk/fs/Kconfig b/trunk/fs/Kconfig index 48f5422cb19a..068ccea2f184 100644 --- a/trunk/fs/Kconfig +++ b/trunk/fs/Kconfig @@ -472,9 +472,6 @@ config FUSE_FS utilities is available from the FUSE homepage: - See for more information. - See for needed library/utility version. - If you want to develop a userspace FS, or if you want to use a filesystem based on FUSE, answer Y or M. diff --git a/trunk/fs/eventpoll.c b/trunk/fs/eventpoll.c index 4284cd31eba6..403b90a1213d 100644 --- a/trunk/fs/eventpoll.c +++ b/trunk/fs/eventpoll.c @@ -101,10 +101,6 @@ /* Maximum number of poll wake up nests we are allowing */ #define EP_MAX_POLLWAKE_NESTS 4 -/* Maximum msec timeout value storeable in a long int */ -#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ) - - struct epoll_filefd { struct file *file; int fd; @@ -1510,8 +1506,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, * and the overflow condition. The passed timeout is in milliseconds, * that why (t * HZ) / 1000. */ - jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ? - MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000; + jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? + MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; retry: write_lock_irqsave(&ep->lock, flags); diff --git a/trunk/fs/ext2/ialloc.c b/trunk/fs/ext2/ialloc.c index e2d6208633a7..c8d07030c897 100644 --- a/trunk/fs/ext2/ialloc.c +++ b/trunk/fs/ext2/ialloc.c @@ -605,28 +605,27 @@ struct inode *ext2_new_inode(struct inode *dir, int mode) insert_inode_hash(inode); if (DQUOT_ALLOC_INODE(inode)) { + DQUOT_DROP(inode); err = -ENOSPC; - goto fail_drop; + goto fail2; } - err = ext2_init_acl(inode, dir); - if (err) - goto fail_free_drop; - + if (err) { + DQUOT_FREE_INODE(inode); + DQUOT_DROP(inode); + goto fail2; + } err = ext2_init_security(inode,dir); - if (err) - goto fail_free_drop; - + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } mark_inode_dirty(inode); ext2_debug("allocating inode %lu\n", inode->i_ino); ext2_preread_inode(inode); return inode; -fail_free_drop: - DQUOT_FREE_INODE(inode); - -fail_drop: - DQUOT_DROP(inode); +fail2: inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); diff --git a/trunk/fs/ext3/ialloc.c b/trunk/fs/ext3/ialloc.c index 6549945f9ac1..96552769d039 100644 --- a/trunk/fs/ext3/ialloc.c +++ b/trunk/fs/ext3/ialloc.c @@ -597,22 +597,27 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ret = inode; if(DQUOT_ALLOC_INODE(inode)) { + DQUOT_DROP(inode); err = -EDQUOT; - goto fail_drop; + goto fail2; } - err = ext3_init_acl(handle, inode, dir); - if (err) - goto fail_free_drop; - + if (err) { + DQUOT_FREE_INODE(inode); + DQUOT_DROP(inode); + goto fail2; + } err = ext3_init_security(handle,inode, dir); - if (err) - goto fail_free_drop; - + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } err = ext3_mark_inode_dirty(handle, inode); if (err) { ext3_std_error(sb, err); - goto fail_free_drop; + DQUOT_FREE_INODE(inode); + DQUOT_DROP(inode); + goto fail2; } ext3_debug("allocating inode %lu\n", inode->i_ino); @@ -626,11 +631,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) brelse(bitmap_bh); return ret; -fail_free_drop: - DQUOT_FREE_INODE(inode); - -fail_drop: - DQUOT_DROP(inode); +fail2: inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); diff --git a/trunk/fs/fuse/dir.c b/trunk/fs/fuse/dir.c index 29f1e9f6e85c..e79e49b3eec7 100644 --- a/trunk/fs/fuse/dir.c +++ b/trunk/fs/fuse/dir.c @@ -96,8 +96,6 @@ static int fuse_lookup_iget(struct inode *dir, struct dentry *entry, fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); err = req->out.h.error; - if (!err && (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID)) - err = -EIO; if (!err) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr); @@ -154,10 +152,6 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, fuse_put_request(fc, req); return err; } - if (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID) { - fuse_put_request(fc, req); - return -EIO; - } inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr); if (!inode) { diff --git a/trunk/include/asm-arm/arch-rpc/hardware.h b/trunk/include/asm-arm/arch-rpc/hardware.h index 9d7f87375aa7..be9754a05c19 100644 --- a/trunk/include/asm-arm/arch-rpc/hardware.h +++ b/trunk/include/asm-arm/arch-rpc/hardware.h @@ -15,7 +15,7 @@ #include #ifndef __ASSEMBLY__ -#define IOMEM(x) ((void __iomem *)(unsigned long)(x)) +#define IOMEM(x) ((void __iomem *)(x)) #else #define IOMEM(x) x #endif /* __ASSEMBLY__ */ @@ -52,7 +52,7 @@ /* * IO Addresses */ -#define VIDC_BASE IOMEM(0xe0400000) +#define VIDC_BASE (void __iomem *)0xe0400000 #define EXPMASK_BASE 0xe0360000 #define IOMD_BASE IOMEM(0xe0200000) #define IOC_BASE IOMEM(0xe0200000) diff --git a/trunk/include/asm-arm/arch-versatile/io.h b/trunk/include/asm-arm/arch-versatile/io.h index 47e904cf25c7..9f895bf61494 100644 --- a/trunk/include/asm-arm/arch-versatile/io.h +++ b/trunk/include/asm-arm/arch-versatile/io.h @@ -22,11 +22,7 @@ #define IO_SPACE_LIMIT 0xffffffff -static inline void __iomem *__io(unsigned long addr) -{ - return (void __iomem *)addr; -} -#define __io(a) __io(a) +#define __io(a) ((void __iomem *)(a)) #define __mem_pci(a) (a) #define __mem_isa(a) (a) diff --git a/trunk/include/asm-generic/pgtable.h b/trunk/include/asm-generic/pgtable.h index ff28c8b31f58..f86c1e549466 100644 --- a/trunk/include/asm-generic/pgtable.h +++ b/trunk/include/asm-generic/pgtable.h @@ -158,19 +158,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres #define lazy_mmu_prot_update(pte) do { } while (0) #endif -#ifndef __HAVE_ARCH_MULTIPLE_ZERO_PAGE -#define move_pte(pte, prot, old_addr, new_addr) (pte) -#else -#define move_pte(pte, prot, old_addr, new_addr) \ -({ \ - pte_t newpte = (pte); \ - if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \ - pte_page(pte) == ZERO_PAGE(old_addr)) \ - newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \ - newpte; \ -}) -#endif - /* * When walking page tables, get the address of the next boundary, * or the end address of the range if that comes earlier. Although no diff --git a/trunk/include/asm-ia64/uaccess.h b/trunk/include/asm-ia64/uaccess.h index 9adb51211c22..3a7829bb5954 100644 --- a/trunk/include/asm-ia64/uaccess.h +++ b/trunk/include/asm-ia64/uaccess.h @@ -187,8 +187,8 @@ extern void __get_user_unknown (void); ({ \ const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ __typeof__ (size) __gu_size = (size); \ - long __gu_err = -EFAULT; \ - unsigned long __gu_val = 0; \ + long __gu_err = -EFAULT, __gu_val = 0; \ + \ if (!check || __access_ok(__gu_ptr, size, segment)) \ switch (__gu_size) { \ case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ @@ -240,13 +240,13 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use static inline unsigned long __copy_to_user (void __user *to, const void *from, unsigned long count) { - return __copy_user(to, (__force void __user *) from, count); + return __copy_user(to, (void __user *) from, count); } static inline unsigned long __copy_from_user (void *to, const void __user *from, unsigned long count) { - return __copy_user((__force void __user *) to, from, count); + return __copy_user((void __user *) to, from, count); } #define __copy_to_user_inatomic __copy_to_user @@ -258,7 +258,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) long __cu_len = (n); \ \ if (__access_ok(__cu_to, __cu_len, get_fs())) \ - __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ + __cu_len = __copy_user(__cu_to, (void __user *) __cu_from, __cu_len); \ __cu_len; \ }) @@ -270,7 +270,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) \ __chk_user_ptr(__cu_from); \ if (__access_ok(__cu_from, __cu_len, get_fs())) \ - __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ + __cu_len = __copy_user((void __user *) __cu_to, __cu_from, __cu_len); \ __cu_len; \ }) diff --git a/trunk/include/asm-mips/pgtable.h b/trunk/include/asm-mips/pgtable.h index eaf5d9b3a0e1..cbd1672c94cb 100644 --- a/trunk/include/asm-mips/pgtable.h +++ b/trunk/include/asm-mips/pgtable.h @@ -68,8 +68,6 @@ extern unsigned long zero_page_mask; #define ZERO_PAGE(vaddr) \ (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) -#define __HAVE_ARCH_MULTIPLE_ZERO_PAGE - extern void paging_init(void); /* diff --git a/trunk/include/asm-ppc/mv64x60.h b/trunk/include/asm-ppc/mv64x60.h index ee2f9188cc64..75c2ffa26b26 100644 --- a/trunk/include/asm-ppc/mv64x60.h +++ b/trunk/include/asm-ppc/mv64x60.h @@ -233,7 +233,7 @@ struct mv64x60_chip_info { struct mv64x60_handle { u32 type; /* type of bridge */ u32 rev; /* revision of bridge */ - void __iomem *v_base;/* virtual base addr of bridge regs */ + void *v_base; /* virtual base addr of bridge regs */ phys_addr_t p_base; /* physical base addr of bridge regs */ u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/ @@ -303,7 +303,7 @@ void mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr, u32 cfg_data, struct pci_controller **hose); int mv64x60_get_type(struct mv64x60_handle *bh); int mv64x60_setup_for_chip(struct mv64x60_handle *bh); -void __iomem *mv64x60_get_bridge_vbase(void); +void *mv64x60_get_bridge_vbase(void); u32 mv64x60_get_bridge_type(void); u32 mv64x60_get_bridge_rev(void); void mv64x60_get_mem_windows(struct mv64x60_handle *bh, diff --git a/trunk/include/asm-ppc64/tlbflush.h b/trunk/include/asm-ppc64/tlbflush.h index 74271d7c1d16..45411a67e082 100644 --- a/trunk/include/asm-ppc64/tlbflush.h +++ b/trunk/include/asm-ppc64/tlbflush.h @@ -25,7 +25,6 @@ struct ppc64_tlb_batch { pte_t pte[PPC64_TLB_BATCH_NR]; unsigned long addr[PPC64_TLB_BATCH_NR]; unsigned long vaddr[PPC64_TLB_BATCH_NR]; - unsigned int large; }; DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); diff --git a/trunk/include/asm-ppc64/uaccess.h b/trunk/include/asm-ppc64/uaccess.h index 132c1276547b..c181a60d868c 100644 --- a/trunk/include/asm-ppc64/uaccess.h +++ b/trunk/include/asm-ppc64/uaccess.h @@ -164,8 +164,7 @@ do { \ #define __get_user_nocheck(x,ptr,size) \ ({ \ - long __gu_err; \ - unsigned long __gu_val; \ + long __gu_err, __gu_val; \ might_sleep(); \ __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ (x) = (__typeof__(*(ptr)))__gu_val; \ @@ -174,8 +173,7 @@ do { \ #define __get_user_check(x,ptr,size) \ ({ \ - long __gu_err = -EFAULT; \ - unsigned long __gu_val = 0; \ + long __gu_err = -EFAULT, __gu_val = 0; \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ might_sleep(); \ if (access_ok(VERIFY_READ,__gu_addr,size)) \ diff --git a/trunk/include/asm-s390/sigcontext.h b/trunk/include/asm-s390/sigcontext.h index 803545351dd8..d57bc0cebdce 100644 --- a/trunk/include/asm-s390/sigcontext.h +++ b/trunk/include/asm-s390/sigcontext.h @@ -61,7 +61,7 @@ typedef struct struct sigcontext { unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS]; - _sigregs __user *sregs; + _sigregs *sregs; }; diff --git a/trunk/include/asm-s390/signal.h b/trunk/include/asm-s390/signal.h index 7084626de215..3d6e11c6c1fd 100644 --- a/trunk/include/asm-s390/signal.h +++ b/trunk/include/asm-s390/signal.h @@ -165,7 +165,7 @@ struct sigaction { #endif /* __KERNEL__ */ typedef struct sigaltstack { - void __user *ss_sp; + void *ss_sp; int ss_flags; size_t ss_size; } stack_t; diff --git a/trunk/include/asm-sparc64/pgtable.h b/trunk/include/asm-sparc64/pgtable.h index 43cbb089cde2..53d612aba8d5 100644 --- a/trunk/include/asm-sparc64/pgtable.h +++ b/trunk/include/asm-sparc64/pgtable.h @@ -98,7 +98,9 @@ #define _PAGE_NFO _AC(0x1000000000000000,UL) /* No Fault Only */ #define _PAGE_IE _AC(0x0800000000000000,UL) /* Invert Endianness */ #define _PAGE_SOFT2 _AC(0x07FC000000000000,UL) /* Software bits, set 2 */ -#define _PAGE_RES1 _AC(0x0003000000000000,UL) /* Reserved */ +#define _PAGE_RES1 _AC(0x0002000000000000,UL) /* Reserved */ +#define _PAGE_SZ32MB _AC(0x0001000000000000,UL) /* (Panther) 32MB page */ +#define _PAGE_SZ256MB _AC(0x2001000000000000,UL) /* (Panther) 256MB page */ #define _PAGE_SN _AC(0x0000800000000000,UL) /* (Cheetah) Snoop */ #define _PAGE_RES2 _AC(0x0000780000000000,UL) /* Reserved */ #define _PAGE_PADDR_SF _AC(0x000001FFFFFFE000,UL) /* (Spitfire) paddr[40:13]*/ diff --git a/trunk/include/linux/key-ui.h b/trunk/include/linux/key-ui.h index 918c34a8347e..cc326174a808 100644 --- a/trunk/include/linux/key-ui.h +++ b/trunk/include/linux/key-ui.h @@ -42,14 +42,11 @@ struct keyring_list { /* * check to see whether permission is granted to use a key in the desired way */ -static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) +static inline int key_permission(const struct key *key, key_perm_t perm) { - struct key *key = key_ref_to_ptr(key_ref); key_perm_t kperm; - if (is_key_possessed(key_ref)) - kperm = key->perm >> 24; - else if (key->uid == current->fsuid) + if (key->uid == current->fsuid) kperm = key->perm >> 16; else if (key->gid != -1 && key->perm & KEY_GRP_ALL && @@ -68,14 +65,11 @@ static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) * check to see whether permission is granted to use a key in at least one of * the desired ways */ -static inline int key_any_permission(const key_ref_t key_ref, key_perm_t perm) +static inline int key_any_permission(const struct key *key, key_perm_t perm) { - struct key *key = key_ref_to_ptr(key_ref); key_perm_t kperm; - if (is_key_possessed(key_ref)) - kperm = key->perm >> 24; - else if (key->uid == current->fsuid) + if (key->uid == current->fsuid) kperm = key->perm >> 16; else if (key->gid != -1 && key->perm & KEY_GRP_ALL && @@ -100,17 +94,13 @@ static inline int key_task_groups_search(struct task_struct *tsk, gid_t gid) return ret; } -static inline int key_task_permission(const key_ref_t key_ref, +static inline int key_task_permission(const struct key *key, struct task_struct *context, key_perm_t perm) { - struct key *key = key_ref_to_ptr(key_ref); key_perm_t kperm; - if (is_key_possessed(key_ref)) { - kperm = key->perm >> 24; - } - else if (key->uid == context->fsuid) { + if (key->uid == context->fsuid) { kperm = key->perm >> 16; } else if (key->gid != -1 && @@ -131,9 +121,9 @@ static inline int key_task_permission(const key_ref_t key_ref, } -extern key_ref_t lookup_user_key(struct task_struct *context, - key_serial_t id, int create, int partial, - key_perm_t perm); +extern struct key *lookup_user_key(struct task_struct *context, + key_serial_t id, int create, int partial, + key_perm_t perm); extern long join_session_keyring(const char *name); diff --git a/trunk/include/linux/key.h b/trunk/include/linux/key.h index f1efa016dbf3..970bbd916cf4 100644 --- a/trunk/include/linux/key.h +++ b/trunk/include/linux/key.h @@ -35,18 +35,11 @@ struct key; #undef KEY_DEBUGGING -#define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */ -#define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */ -#define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */ -#define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */ -#define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */ -#define KEY_POS_ALL 0x1f000000 - -#define KEY_USR_VIEW 0x00010000 /* user permissions... */ -#define KEY_USR_READ 0x00020000 -#define KEY_USR_WRITE 0x00040000 -#define KEY_USR_SEARCH 0x00080000 -#define KEY_USR_LINK 0x00100000 +#define KEY_USR_VIEW 0x00010000 /* user can view a key's attributes */ +#define KEY_USR_READ 0x00020000 /* user can read key payload / view keyring */ +#define KEY_USR_WRITE 0x00040000 /* user can update key payload / add link to keyring */ +#define KEY_USR_SEARCH 0x00080000 /* user can find a key in search / search a keyring */ +#define KEY_USR_LINK 0x00100000 /* user can create a link to a key/keyring */ #define KEY_USR_ALL 0x001f0000 #define KEY_GRP_VIEW 0x00000100 /* group permissions... */ @@ -72,38 +65,6 @@ struct key_owner; struct keyring_list; struct keyring_name; -/*****************************************************************************/ -/* - * key reference with possession attribute handling - * - * NOTE! key_ref_t is a typedef'd pointer to a type that is not actually - * defined. This is because we abuse the bottom bit of the reference to carry a - * flag to indicate whether the calling process possesses that key in one of - * its keyrings. - * - * the key_ref_t has been made a separate type so that the compiler can reject - * attempts to dereference it without proper conversion. - * - * the three functions are used to assemble and disassemble references - */ -typedef struct __key_reference_with_attributes *key_ref_t; - -static inline key_ref_t make_key_ref(const struct key *key, - unsigned long possession) -{ - return (key_ref_t) ((unsigned long) key | possession); -} - -static inline struct key *key_ref_to_ptr(const key_ref_t key_ref) -{ - return (struct key *) ((unsigned long) key_ref & ~1UL); -} - -static inline unsigned long is_key_possessed(const key_ref_t key_ref) -{ - return (unsigned long) key_ref & 1UL; -} - /*****************************************************************************/ /* * authentication token / access credential / keyring @@ -254,25 +215,20 @@ static inline struct key *key_get(struct key *key) return key; } -static inline void key_ref_put(key_ref_t key_ref) -{ - key_put(key_ref_to_ptr(key_ref)); -} - extern struct key *request_key(struct key_type *type, const char *description, const char *callout_info); extern int key_validate(struct key *key); -extern key_ref_t key_create_or_update(key_ref_t keyring, - const char *type, - const char *description, - const void *payload, - size_t plen, - int not_in_quota); +extern struct key *key_create_or_update(struct key *keyring, + const char *type, + const char *description, + const void *payload, + size_t plen, + int not_in_quota); -extern int key_update(key_ref_t key, +extern int key_update(struct key *key, const void *payload, size_t plen); @@ -287,9 +243,9 @@ extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, extern int keyring_clear(struct key *keyring); -extern key_ref_t keyring_search(key_ref_t keyring, - struct key_type *type, - const char *description); +extern struct key *keyring_search(struct key *keyring, + struct key_type *type, + const char *description); extern int keyring_add_key(struct key *keyring, struct key *key); @@ -329,10 +285,6 @@ extern void key_init(void); #define key_serial(k) 0 #define key_get(k) ({ NULL; }) #define key_put(k) do { } while(0) -#define key_ref_put(k) do { } while(0) -#define make_key_ref(k) ({ NULL; }) -#define key_ref_to_ptr(k) ({ NULL; }) -#define is_key_possessed(k) 0 #define alloc_uid_keyring(u) 0 #define switch_uid_keyring(u) do { } while(0) #define __install_session_keyring(t, k) ({ NULL; }) diff --git a/trunk/include/rdma/ib_verbs.h b/trunk/include/rdma/ib_verbs.h index e6f4c9e55df7..e16cf94870f2 100644 --- a/trunk/include/rdma/ib_verbs.h +++ b/trunk/include/rdma/ib_verbs.h @@ -665,6 +665,7 @@ struct ib_ucontext { struct list_head qp_list; struct list_head srq_list; struct list_head ah_list; + spinlock_t lock; }; struct ib_uobject { diff --git a/trunk/kernel/cpuset.c b/trunk/kernel/cpuset.c index 6a6e87b2f2fd..79866bc6b3a1 100644 --- a/trunk/kernel/cpuset.c +++ b/trunk/kernel/cpuset.c @@ -969,7 +969,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, ssize_t retval = 0; char *s; char *start; - ssize_t n; + size_t n; if (!(page = (char *)__get_free_page(GFP_KERNEL))) return -ENOMEM; @@ -999,13 +999,12 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, *s++ = '\n'; *s = '\0'; - start = page + *ppos; - n = s - start; - /* Do nothing if *ppos is at the eof or beyond the eof. */ - if (n <= 0) - goto out; + if (s - page <= *ppos) + return 0; + start = page + *ppos; + n = s - start; retval = n - copy_to_user(buf, start, min(n, nbytes)); *ppos += retval; out: diff --git a/trunk/kernel/params.c b/trunk/kernel/params.c index 1a8614bac5d5..fbf173215fd2 100644 --- a/trunk/kernel/params.c +++ b/trunk/kernel/params.c @@ -80,6 +80,8 @@ static char *next_arg(char *args, char **param, char **val) int in_quote = 0, quoted = 0; char *next; + /* Chew any extra spaces */ + while (*args == ' ') args++; if (*args == '"') { args++; in_quote = 1; @@ -119,10 +121,6 @@ static char *next_arg(char *args, char **param, char **val) next = args + i + 1; } else next = args + i; - - /* Chew up trailing spaces. */ - while (*next == ' ') - next++; return next; } @@ -137,10 +135,6 @@ int parse_args(const char *name, DEBUGP("Parsing ARGS: %s\n", args); - /* Chew leading spaces */ - while (*args == ' ') - args++; - while (*args) { int ret; diff --git a/trunk/kernel/power/power.h b/trunk/kernel/power/power.h index 6748de23e83c..9c9167d910dd 100644 --- a/trunk/kernel/power/power.h +++ b/trunk/kernel/power/power.h @@ -9,9 +9,6 @@ #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) #endif -#define MAX_PBES ((PAGE_SIZE - sizeof(struct new_utsname) \ - - 4 - 3*sizeof(unsigned long) - sizeof(int) \ - - sizeof(void *)) / sizeof(swp_entry_t)) struct swsusp_info { struct new_utsname uts; @@ -21,7 +18,7 @@ struct swsusp_info { unsigned long image_pages; unsigned long pagedir_pages; suspend_pagedir_t * suspend_pagedir; - swp_entry_t pagedir[MAX_PBES]; + swp_entry_t pagedir[768]; } __attribute__((aligned(PAGE_SIZE))); diff --git a/trunk/kernel/power/swsusp.c b/trunk/kernel/power/swsusp.c index acf79ac1cb6d..1cc9ff25e479 100644 --- a/trunk/kernel/power/swsusp.c +++ b/trunk/kernel/power/swsusp.c @@ -402,14 +402,15 @@ static int write_page(unsigned long addr, swp_entry_t * loc) static void data_free(void) { swp_entry_t entry; - struct pbe * p; + int i; - for_each_pbe(p, pagedir_nosave) { - entry = p->swap_address; + for (i = 0; i < nr_copy_pages; i++) { + entry = (pagedir_nosave + i)->swap_address; if (entry.val) swap_free(entry); else break; + (pagedir_nosave + i)->swap_address = (swp_entry_t){0}; } } @@ -931,10 +932,6 @@ static int swsusp_alloc(void) if (!enough_swap()) return -ENOSPC; - if (MAX_PBES < nr_copy_pages / PBES_PER_PAGE + - !!(nr_copy_pages % PBES_PER_PAGE)) - return -ENOSPC; - if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) { printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); return -ENOMEM; @@ -1441,9 +1438,9 @@ static int read_pagedir(struct pbe *pblist) } if (error) - free_pagedir(pblist); - else - BUG_ON(i != swsusp_info.pagedir_pages); + free_page((unsigned long)pblist); + + BUG_ON(i != swsusp_info.pagedir_pages); return error; } diff --git a/trunk/mm/mremap.c b/trunk/mm/mremap.c index f343fc73a8bd..a32fed454bd7 100644 --- a/trunk/mm/mremap.c +++ b/trunk/mm/mremap.c @@ -141,10 +141,10 @@ move_one_page(struct vm_area_struct *vma, unsigned long old_addr, if (dst) { pte_t pte; pte = ptep_clear_flush(vma, old_addr, src); - /* ZERO_PAGE can be dependant on virtual addr */ - pte = move_pte(pte, new_vma->vm_page_prot, - old_addr, new_addr); + if (pfn_valid(pte_pfn(pte)) && + pte_page(pte) == ZERO_PAGE(old_addr)) + pte = pte_wrprotect(mk_pte(ZERO_PAGE(new_addr), new_vma->vm_page_prot)); set_pte_at(mm, new_addr, dst, pte); } else error = -ENOMEM; diff --git a/trunk/mm/slab.c b/trunk/mm/slab.c index 5cbbdfa6dd0e..c9adfce00405 100644 --- a/trunk/mm/slab.c +++ b/trunk/mm/slab.c @@ -2510,12 +2510,16 @@ cache_alloc_debugcheck_after(kmem_cache_t *cachep, #define cache_alloc_debugcheck_after(a,b,objp,d) (objp) #endif -static inline void *____cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) + +static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) { + unsigned long save_flags; void* objp; struct array_cache *ac; - check_irq_off(); + cache_alloc_debugcheck_before(cachep, flags); + + local_irq_save(save_flags); ac = ac_data(cachep); if (likely(ac->avail)) { STATS_INC_ALLOCHIT(cachep); @@ -2525,18 +2529,6 @@ static inline void *____cache_alloc(kmem_cache_t *cachep, unsigned int __nocast STATS_INC_ALLOCMISS(cachep); objp = cache_alloc_refill(cachep, flags); } - return objp; -} - -static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) -{ - unsigned long save_flags; - void* objp; - - cache_alloc_debugcheck_before(cachep, flags); - - local_irq_save(save_flags); - objp = ____cache_alloc(cachep, flags); local_irq_restore(save_flags); objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0)); @@ -2864,10 +2856,7 @@ void *kmem_cache_alloc_node(kmem_cache_t *cachep, unsigned int __nocast flags, i cache_alloc_debugcheck_before(cachep, flags); local_irq_save(save_flags); - if (nodeid == numa_node_id()) - ptr = ____cache_alloc(cachep, flags); - else - ptr = __cache_alloc_node(cachep, flags, nodeid); + ptr = __cache_alloc_node(cachep, flags, nodeid); local_irq_restore(save_flags); ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); diff --git a/trunk/net/core/pktgen.c b/trunk/net/core/pktgen.c index b7f2d65a614f..ef430b1e8e42 100644 --- a/trunk/net/core/pktgen.c +++ b/trunk/net/core/pktgen.c @@ -186,7 +186,7 @@ /* Used to help with determining the pkts on receive */ #define PKTGEN_MAGIC 0xbe9be955 -#define PG_PROC_DIR "net/pktgen" +#define PG_PROC_DIR "pktgen" #define MAX_CFLOWS 65536 @@ -1476,7 +1476,18 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer, static int create_proc_dir(void) { - pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL); + int len; + /* does proc_dir already exists */ + len = strlen(PG_PROC_DIR); + + for (pg_proc_dir = proc_net->subdir; pg_proc_dir; pg_proc_dir=pg_proc_dir->next) { + if ((pg_proc_dir->namelen == len) && + (! memcmp(pg_proc_dir->name, PG_PROC_DIR, len))) + break; + } + + if (!pg_proc_dir) + pg_proc_dir = create_proc_entry(PG_PROC_DIR, S_IFDIR, proc_net); if (!pg_proc_dir) return -ENODEV; @@ -1486,7 +1497,7 @@ static int create_proc_dir(void) static int remove_proc_dir(void) { - remove_proc_entry(PG_PROC_DIR, NULL); + remove_proc_entry(PG_PROC_DIR, proc_net); return 0; } @@ -2897,7 +2908,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) pkt_dev->udp_dst_max = 9; strncpy(pkt_dev->ifname, ifname, 31); - sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname); + sprintf(pkt_dev->fname, "net/%s/%s", PG_PROC_DIR, ifname); if (! pktgen_setup_dev(pkt_dev)) { printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); @@ -2970,7 +2981,7 @@ static int pktgen_create_thread(const char* name, int cpu) spin_lock_init(&t->if_lock); t->cpu = cpu; - sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name); + sprintf(t->fname, "net/%s/%s", PG_PROC_DIR, t->name); t->proc_ent = create_proc_entry(t->fname, 0600, NULL); if (!t->proc_ent) { printk("pktgen: cannot create %s procfs entry.\n", t->fname); @@ -3053,7 +3064,7 @@ static int __init pg_init(void) create_proc_dir(); - sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR); + sprintf(module_fname, "net/%s/pgctrl", PG_PROC_DIR); module_proc_ent = create_proc_entry(module_fname, 0600, NULL); if (!module_proc_ent) { printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); diff --git a/trunk/net/ieee80211/ieee80211_module.c b/trunk/net/ieee80211/ieee80211_module.c index 6059e9e37123..03a47343ddc7 100644 --- a/trunk/net/ieee80211/ieee80211_module.c +++ b/trunk/net/ieee80211/ieee80211_module.c @@ -230,7 +230,7 @@ static int __init ieee80211_init(void) struct proc_dir_entry *e; ieee80211_debug_level = debug; - ieee80211_proc = proc_mkdir(DRV_NAME, proc_net); + ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net); if (ieee80211_proc == NULL) { IEEE80211_ERROR("Unable to create " DRV_NAME " proc directory\n"); diff --git a/trunk/security/keys/internal.h b/trunk/security/keys/internal.h index db99ed434f3a..46c8602661c9 100644 --- a/trunk/security/keys/internal.h +++ b/trunk/security/keys/internal.h @@ -71,26 +71,26 @@ extern void keyring_publish_name(struct key *keyring); extern int __key_link(struct key *keyring, struct key *key); -extern key_ref_t __keyring_search_one(key_ref_t keyring_ref, - const struct key_type *type, - const char *description, - key_perm_t perm); +extern struct key *__keyring_search_one(struct key *keyring, + const struct key_type *type, + const char *description, + key_perm_t perm); extern struct key *keyring_search_instkey(struct key *keyring, key_serial_t target_id); typedef int (*key_match_func_t)(const struct key *, const void *); -extern key_ref_t keyring_search_aux(key_ref_t keyring_ref, - struct task_struct *tsk, - struct key_type *type, - const void *description, - key_match_func_t match); +extern struct key *keyring_search_aux(struct key *keyring, + struct task_struct *tsk, + struct key_type *type, + const void *description, + key_match_func_t match); -extern key_ref_t search_process_keyrings(struct key_type *type, - const void *description, - key_match_func_t match, - struct task_struct *tsk); +extern struct key *search_process_keyrings(struct key_type *type, + const void *description, + key_match_func_t match, + struct task_struct *tsk); extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); diff --git a/trunk/security/keys/key.c b/trunk/security/keys/key.c index 2182be9e9309..fb89f9844465 100644 --- a/trunk/security/keys/key.c +++ b/trunk/security/keys/key.c @@ -693,15 +693,14 @@ void key_type_put(struct key_type *ktype) * - the key has an incremented refcount * - we need to put the key if we get an error */ -static inline key_ref_t __key_update(key_ref_t key_ref, - const void *payload, size_t plen) +static inline struct key *__key_update(struct key *key, const void *payload, + size_t plen) { - struct key *key = key_ref_to_ptr(key_ref); int ret; /* need write permission on the key to update it */ ret = -EACCES; - if (!key_permission(key_ref, KEY_WRITE)) + if (!key_permission(key, KEY_WRITE)) goto error; ret = -EEXIST; @@ -720,12 +719,12 @@ static inline key_ref_t __key_update(key_ref_t key_ref, if (ret < 0) goto error; -out: - return key_ref; + out: + return key; -error: + error: key_put(key); - key_ref = ERR_PTR(ret); + key = ERR_PTR(ret); goto out; } /* end __key_update() */ @@ -735,56 +734,52 @@ static inline key_ref_t __key_update(key_ref_t key_ref, * search the specified keyring for a key of the same description; if one is * found, update it, otherwise add a new one */ -key_ref_t key_create_or_update(key_ref_t keyring_ref, - const char *type, - const char *description, - const void *payload, - size_t plen, - int not_in_quota) +struct key *key_create_or_update(struct key *keyring, + const char *type, + const char *description, + const void *payload, + size_t plen, + int not_in_quota) { struct key_type *ktype; - struct key *keyring, *key = NULL; + struct key *key = NULL; key_perm_t perm; - key_ref_t key_ref; int ret; + key_check(keyring); + /* look up the key type to see if it's one of the registered kernel * types */ ktype = key_type_lookup(type); if (IS_ERR(ktype)) { - key_ref = ERR_PTR(-ENODEV); + key = ERR_PTR(-ENODEV); goto error; } - key_ref = ERR_PTR(-EINVAL); + ret = -EINVAL; if (!ktype->match || !ktype->instantiate) goto error_2; - keyring = key_ref_to_ptr(keyring_ref); - - key_check(keyring); - - down_write(&keyring->sem); - - /* if we're going to allocate a new key, we're going to have - * to modify the keyring */ - key_ref = ERR_PTR(-EACCES); - if (!key_permission(keyring_ref, KEY_WRITE)) - goto error_3; - /* search for an existing key of the same type and description in the * destination keyring */ - key_ref = __keyring_search_one(keyring_ref, ktype, description, 0); - if (!IS_ERR(key_ref)) + down_write(&keyring->sem); + + key = __keyring_search_one(keyring, ktype, description, 0); + if (!IS_ERR(key)) goto found_matching_key; + /* if we're going to allocate a new key, we're going to have to modify + * the keyring */ + ret = -EACCES; + if (!key_permission(keyring, KEY_WRITE)) + goto error_3; + /* decide on the permissions we want */ - perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK; - perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; + perm = KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; if (ktype->read) - perm |= KEY_POS_READ | KEY_USR_READ; + perm |= KEY_USR_READ; if (ktype == &key_type_keyring || ktype->update) perm |= KEY_USR_WRITE; @@ -793,7 +788,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, key = key_alloc(ktype, description, current->fsuid, current->fsgid, perm, not_in_quota); if (IS_ERR(key)) { - key_ref = ERR_PTR(PTR_ERR(key)); + ret = PTR_ERR(key); goto error_3; } @@ -801,18 +796,15 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL); if (ret < 0) { key_put(key); - key_ref = ERR_PTR(ret); - goto error_3; + key = ERR_PTR(ret); } - key_ref = make_key_ref(key, is_key_possessed(keyring_ref)); - error_3: up_write(&keyring->sem); error_2: key_type_put(ktype); error: - return key_ref; + return key; found_matching_key: /* we found a matching key, so we're going to try to update it @@ -821,7 +813,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, up_write(&keyring->sem); key_type_put(ktype); - key_ref = __key_update(key_ref, payload, plen); + key = __key_update(key, payload, plen); goto error; } /* end key_create_or_update() */ @@ -832,16 +824,15 @@ EXPORT_SYMBOL(key_create_or_update); /* * update a key */ -int key_update(key_ref_t key_ref, const void *payload, size_t plen) +int key_update(struct key *key, const void *payload, size_t plen) { - struct key *key = key_ref_to_ptr(key_ref); int ret; key_check(key); /* the key must be writable */ ret = -EACCES; - if (!key_permission(key_ref, KEY_WRITE)) + if (!key_permission(key, KEY_WRITE)) goto error; /* attempt to update it if supported */ diff --git a/trunk/security/keys/keyctl.c b/trunk/security/keys/keyctl.c index 4c670ee6acf9..a6516a64b297 100644 --- a/trunk/security/keys/keyctl.c +++ b/trunk/security/keys/keyctl.c @@ -34,7 +34,7 @@ asmlinkage long sys_add_key(const char __user *_type, size_t plen, key_serial_t ringid) { - key_ref_t keyring_ref, key_ref; + struct key *keyring, *key; char type[32], *description; void *payload; long dlen, ret; @@ -86,25 +86,25 @@ asmlinkage long sys_add_key(const char __user *_type, } /* find the target keyring (which must be writable) */ - keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error3; } /* create or update the requested key and add it to the target * keyring */ - key_ref = key_create_or_update(keyring_ref, type, description, - payload, plen, 0); - if (!IS_ERR(key_ref)) { - ret = key_ref_to_ptr(key_ref)->serial; - key_ref_put(key_ref); + key = key_create_or_update(keyring, type, description, + payload, plen, 0); + if (!IS_ERR(key)) { + ret = key->serial; + key_put(key); } else { - ret = PTR_ERR(key_ref); + ret = PTR_ERR(key); } - key_ref_put(keyring_ref); + key_put(keyring); error3: kfree(payload); error2: @@ -131,8 +131,7 @@ asmlinkage long sys_request_key(const char __user *_type, key_serial_t destringid) { struct key_type *ktype; - struct key *key; - key_ref_t dest_ref; + struct key *key, *dest; char type[32], *description, *callout_info; long dlen, ret; @@ -188,11 +187,11 @@ asmlinkage long sys_request_key(const char __user *_type, } /* get the destination keyring if specified */ - dest_ref = NULL; + dest = NULL; if (destringid) { - dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); - if (IS_ERR(dest_ref)) { - ret = PTR_ERR(dest_ref); + dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); + if (IS_ERR(dest)) { + ret = PTR_ERR(dest); goto error3; } } @@ -205,8 +204,7 @@ asmlinkage long sys_request_key(const char __user *_type, } /* do the search */ - key = request_key_and_link(ktype, description, callout_info, - key_ref_to_ptr(dest_ref)); + key = request_key_and_link(ktype, description, callout_info, dest); if (IS_ERR(key)) { ret = PTR_ERR(key); goto error5; @@ -218,7 +216,7 @@ asmlinkage long sys_request_key(const char __user *_type, error5: key_type_put(ktype); error4: - key_ref_put(dest_ref); + key_put(dest); error3: kfree(callout_info); error2: @@ -236,17 +234,17 @@ asmlinkage long sys_request_key(const char __user *_type, */ long keyctl_get_keyring_ID(key_serial_t id, int create) { - key_ref_t key_ref; + struct key *key; long ret; - key_ref = lookup_user_key(NULL, id, create, 0, KEY_SEARCH); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, create, 0, KEY_SEARCH); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error; } - ret = key_ref_to_ptr(key_ref)->serial; - key_ref_put(key_ref); + ret = key->serial; + key_put(key); error: return ret; @@ -304,7 +302,7 @@ long keyctl_update_key(key_serial_t id, const void __user *_payload, size_t plen) { - key_ref_t key_ref; + struct key *key; void *payload; long ret; @@ -326,16 +324,16 @@ long keyctl_update_key(key_serial_t id, } /* find the target key (which must be writable) */ - key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error2; } /* update the key */ - ret = key_update(key_ref, payload, plen); + ret = key_update(key, payload, plen); - key_ref_put(key_ref); + key_put(key); error2: kfree(payload); error: @@ -351,19 +349,19 @@ long keyctl_update_key(key_serial_t id, */ long keyctl_revoke_key(key_serial_t id) { - key_ref_t key_ref; + struct key *key; long ret; - key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error; } - key_revoke(key_ref_to_ptr(key_ref)); + key_revoke(key); ret = 0; - key_ref_put(key_ref); + key_put(key); error: return ret; @@ -377,18 +375,18 @@ long keyctl_revoke_key(key_serial_t id) */ long keyctl_keyring_clear(key_serial_t ringid) { - key_ref_t keyring_ref; + struct key *keyring; long ret; - keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error; } - ret = keyring_clear(key_ref_to_ptr(keyring_ref)); + ret = keyring_clear(keyring); - key_ref_put(keyring_ref); + key_put(keyring); error: return ret; @@ -403,26 +401,26 @@ long keyctl_keyring_clear(key_serial_t ringid) */ long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) { - key_ref_t keyring_ref, key_ref; + struct key *keyring, *key; long ret; - keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error; } - key_ref = lookup_user_key(NULL, id, 1, 0, KEY_LINK); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 1, 0, KEY_LINK); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error2; } - ret = key_link(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref)); + ret = key_link(keyring, key); - key_ref_put(key_ref); + key_put(key); error2: - key_ref_put(keyring_ref); + key_put(keyring); error: return ret; @@ -437,26 +435,26 @@ long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) */ long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid) { - key_ref_t keyring_ref, key_ref; + struct key *keyring, *key; long ret; - keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error; } - key_ref = lookup_user_key(NULL, id, 0, 0, 0); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 0, 0, 0); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error2; } - ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref)); + ret = key_unlink(keyring, key); - key_ref_put(key_ref); + key_put(key); error2: - key_ref_put(keyring_ref); + key_put(keyring); error: return ret; @@ -478,26 +476,24 @@ long keyctl_describe_key(key_serial_t keyid, size_t buflen) { struct key *key, *instkey; - key_ref_t key_ref; char *tmpbuf; long ret; - key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); - if (IS_ERR(key_ref)) { + key = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); + if (IS_ERR(key)) { /* viewing a key under construction is permitted if we have the * authorisation token handy */ - if (PTR_ERR(key_ref) == -EACCES) { + if (PTR_ERR(key) == -EACCES) { instkey = key_get_instantiation_authkey(keyid); if (!IS_ERR(instkey)) { key_put(instkey); - key_ref = lookup_user_key(NULL, keyid, - 0, 1, 0); - if (!IS_ERR(key_ref)) + key = lookup_user_key(NULL, keyid, 0, 1, 0); + if (!IS_ERR(key)) goto okay; } } - ret = PTR_ERR(key_ref); + ret = PTR_ERR(key); goto error; } @@ -508,16 +504,13 @@ long keyctl_describe_key(key_serial_t keyid, if (!tmpbuf) goto error2; - key = key_ref_to_ptr(key_ref); - ret = snprintf(tmpbuf, PAGE_SIZE - 1, - "%s;%d;%d;%08x;%s", - key_ref_to_ptr(key_ref)->type->name, - key_ref_to_ptr(key_ref)->uid, - key_ref_to_ptr(key_ref)->gid, - key_ref_to_ptr(key_ref)->perm, - key_ref_to_ptr(key_ref)->description ? - key_ref_to_ptr(key_ref)->description : "" + "%s;%d;%d;%06x;%s", + key->type->name, + key->uid, + key->gid, + key->perm, + key->description ? key->description :"" ); /* include a NUL char at the end of the data */ @@ -537,7 +530,7 @@ long keyctl_describe_key(key_serial_t keyid, kfree(tmpbuf); error2: - key_ref_put(key_ref); + key_put(key); error: return ret; @@ -559,7 +552,7 @@ long keyctl_keyring_search(key_serial_t ringid, key_serial_t destringid) { struct key_type *ktype; - key_ref_t keyring_ref, key_ref, dest_ref; + struct key *keyring, *key, *dest; char type[32], *description; long dlen, ret; @@ -588,18 +581,18 @@ long keyctl_keyring_search(key_serial_t ringid, goto error2; /* get the keyring at which to begin the search */ - keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error2; } /* get the destination keyring if specified */ - dest_ref = NULL; + dest = NULL; if (destringid) { - dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); - if (IS_ERR(dest_ref)) { - ret = PTR_ERR(dest_ref); + dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); + if (IS_ERR(dest)) { + ret = PTR_ERR(dest); goto error3; } } @@ -612,9 +605,9 @@ long keyctl_keyring_search(key_serial_t ringid, } /* do the search */ - key_ref = keyring_search(keyring_ref, ktype, description); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = keyring_search(keyring, ktype, description); + if (IS_ERR(key)) { + ret = PTR_ERR(key); /* treat lack or presence of a negative key the same */ if (ret == -EAGAIN) @@ -623,26 +616,26 @@ long keyctl_keyring_search(key_serial_t ringid, } /* link the resulting key to the destination keyring if we can */ - if (dest_ref) { + if (dest) { ret = -EACCES; - if (!key_permission(key_ref, KEY_LINK)) + if (!key_permission(key, KEY_LINK)) goto error6; - ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref)); + ret = key_link(dest, key); if (ret < 0) goto error6; } - ret = key_ref_to_ptr(key_ref)->serial; + ret = key->serial; error6: - key_ref_put(key_ref); + key_put(key); error5: key_type_put(ktype); error4: - key_ref_put(dest_ref); + key_put(dest); error3: - key_ref_put(keyring_ref); + key_put(keyring); error2: kfree(description); error: @@ -650,6 +643,16 @@ long keyctl_keyring_search(key_serial_t ringid, } /* end keyctl_keyring_search() */ +/*****************************************************************************/ +/* + * see if the key we're looking at is the target key + */ +static int keyctl_read_key_same(const struct key *key, const void *target) +{ + return key == target; + +} /* end keyctl_read_key_same() */ + /*****************************************************************************/ /* * read a user key's payload @@ -662,33 +665,38 @@ long keyctl_keyring_search(key_serial_t ringid, */ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) { - struct key *key; - key_ref_t key_ref; + struct key *key, *skey; long ret; /* find the key first */ - key_ref = lookup_user_key(NULL, keyid, 0, 0, 0); - if (IS_ERR(key_ref)) { - ret = -ENOKEY; - goto error; - } - - key = key_ref_to_ptr(key_ref); - - /* see if we can read it directly */ - if (key_permission(key_ref, KEY_READ)) - goto can_read_key; - - /* we can't; see if it's searchable from this process's keyrings - * - we automatically take account of the fact that it may be - * dangling off an instantiation key - */ - if (!is_key_possessed(key_ref)) { - ret = -EACCES; + key = lookup_user_key(NULL, keyid, 0, 0, 0); + if (!IS_ERR(key)) { + /* see if we can read it directly */ + if (key_permission(key, KEY_READ)) + goto can_read_key; + + /* we can't; see if it's searchable from this process's + * keyrings + * - we automatically take account of the fact that it may be + * dangling off an instantiation key + */ + skey = search_process_keyrings(key->type, key, + keyctl_read_key_same, current); + if (!IS_ERR(skey)) + goto can_read_key2; + + ret = PTR_ERR(skey); + if (ret == -EAGAIN) + ret = -EACCES; goto error2; } + ret = -ENOKEY; + goto error; + /* the key is probably readable - now try to read it */ + can_read_key2: + key_put(skey); can_read_key: ret = key_validate(key); if (ret == 0) { @@ -719,21 +727,18 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) { struct key *key; - key_ref_t key_ref; long ret; ret = 0; if (uid == (uid_t) -1 && gid == (gid_t) -1) goto error; - key_ref = lookup_user_key(NULL, id, 1, 1, 0); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 1, 1, 0); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error; } - key = key_ref_to_ptr(key_ref); - /* make the changes with the locks held to prevent chown/chown races */ ret = -EACCES; down_write(&key->sem); @@ -779,21 +784,18 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) long keyctl_setperm_key(key_serial_t id, key_perm_t perm) { struct key *key; - key_ref_t key_ref; long ret; ret = -EINVAL; - if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) + if (perm & ~(KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) goto error; - key_ref = lookup_user_key(NULL, id, 1, 1, 0); - if (IS_ERR(key_ref)) { - ret = PTR_ERR(key_ref); + key = lookup_user_key(NULL, id, 1, 1, 0); + if (IS_ERR(key)) { + ret = PTR_ERR(key); goto error; } - key = key_ref_to_ptr(key_ref); - /* make the changes with the locks held to prevent chown/chmod races */ ret = -EACCES; down_write(&key->sem); @@ -822,8 +824,7 @@ long keyctl_instantiate_key(key_serial_t id, key_serial_t ringid) { struct request_key_auth *rka; - struct key *instkey; - key_ref_t keyring_ref; + struct key *instkey, *keyring; void *payload; long ret; @@ -856,21 +857,21 @@ long keyctl_instantiate_key(key_serial_t id, /* find the destination keyring amongst those belonging to the * requesting task */ - keyring_ref = NULL; + keyring = NULL; if (ringid) { - keyring_ref = lookup_user_key(rka->context, ringid, 1, 0, - KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(rka->context, ringid, 1, 0, + KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error3; } } /* instantiate the key and link it into a keyring */ ret = key_instantiate_and_link(rka->target_key, payload, plen, - key_ref_to_ptr(keyring_ref), instkey); + keyring, instkey); - key_ref_put(keyring_ref); + key_put(keyring); error3: key_put(instkey); error2: @@ -888,8 +889,7 @@ long keyctl_instantiate_key(key_serial_t id, long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) { struct request_key_auth *rka; - struct key *instkey; - key_ref_t keyring_ref; + struct key *instkey, *keyring; long ret; /* find the instantiation authorisation key */ @@ -903,20 +903,19 @@ long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) /* find the destination keyring if present (which must also be * writable) */ - keyring_ref = NULL; + keyring = NULL; if (ringid) { - keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); - if (IS_ERR(keyring_ref)) { - ret = PTR_ERR(keyring_ref); + keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); goto error2; } } /* instantiate the key and link it into a keyring */ - ret = key_negate_and_link(rka->target_key, timeout, - key_ref_to_ptr(keyring_ref), instkey); + ret = key_negate_and_link(rka->target_key, timeout, keyring, instkey); - key_ref_put(keyring_ref); + key_put(keyring); error2: key_put(instkey); error: diff --git a/trunk/security/keys/keyring.c b/trunk/security/keys/keyring.c index 0639396dd441..9c208c756df8 100644 --- a/trunk/security/keys/keyring.c +++ b/trunk/security/keys/keyring.c @@ -309,7 +309,7 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, int ret; keyring = key_alloc(&key_type_keyring, description, - uid, gid, KEY_POS_ALL | KEY_USR_ALL, not_in_quota); + uid, gid, KEY_USR_ALL, not_in_quota); if (!IS_ERR(keyring)) { ret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL); @@ -333,13 +333,12 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, * - we rely on RCU to prevent the keyring lists from disappearing on us * - we return -EAGAIN if we didn't find any matching key * - we return -ENOKEY if we only found negative matching keys - * - we propagate the possession attribute from the keyring ref to the key ref */ -key_ref_t keyring_search_aux(key_ref_t keyring_ref, - struct task_struct *context, - struct key_type *type, - const void *description, - key_match_func_t match) +struct key *keyring_search_aux(struct key *keyring, + struct task_struct *context, + struct key_type *type, + const void *description, + key_match_func_t match) { struct { struct keyring_list *keylist; @@ -348,33 +347,29 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, struct keyring_list *keylist; struct timespec now; - unsigned long possessed; - struct key *keyring, *key; - key_ref_t key_ref; + struct key *key; long err; int sp, kix; - keyring = key_ref_to_ptr(keyring_ref); - possessed = is_key_possessed(keyring_ref); key_check(keyring); + rcu_read_lock(); + /* top keyring must have search permission to begin the search */ - key_ref = ERR_PTR(-EACCES); - if (!key_task_permission(keyring_ref, context, KEY_SEARCH)) + key = ERR_PTR(-EACCES); + if (!key_task_permission(keyring, context, KEY_SEARCH)) goto error; - key_ref = ERR_PTR(-ENOTDIR); + key = ERR_PTR(-ENOTDIR); if (keyring->type != &key_type_keyring) goto error; - rcu_read_lock(); - now = current_kernel_time(); err = -EAGAIN; sp = 0; /* start processing a new keyring */ -descend: + descend: if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) goto not_this_keyring; @@ -402,8 +397,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, continue; /* key must have search permissions */ - if (!key_task_permission(make_key_ref(key, possessed), - context, KEY_SEARCH)) + if (!key_task_permission(key, context, KEY_SEARCH)) continue; /* we set a different error code if we find a negative key */ @@ -417,7 +411,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, /* search through the keyrings nested in this one */ kix = 0; -ascend: + ascend: for (; kix < keylist->nkeys; kix++) { key = keylist->keys[kix]; if (key->type != &key_type_keyring) @@ -429,8 +423,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, if (sp >= KEYRING_SEARCH_MAX_DEPTH) continue; - if (!key_task_permission(make_key_ref(key, possessed), - context, KEY_SEARCH)) + if (!key_task_permission(key, context, KEY_SEARCH)) continue; /* stack the current position */ @@ -445,7 +438,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, /* the keyring we're looking at was disqualified or didn't contain a * matching key */ -not_this_keyring: + not_this_keyring: if (sp > 0) { /* resume the processing of a keyring higher up in the tree */ sp--; @@ -454,18 +447,16 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, goto ascend; } - key_ref = ERR_PTR(err); - goto error_2; + key = ERR_PTR(err); + goto error; /* we found a viable match */ -found: + found: atomic_inc(&key->usage); key_check(key); - key_ref = make_key_ref(key, possessed); -error_2: + error: rcu_read_unlock(); -error: - return key_ref; + return key; } /* end keyring_search_aux() */ @@ -478,9 +469,9 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, * - we return -EAGAIN if we didn't find any matching key * - we return -ENOKEY if we only found negative matching keys */ -key_ref_t keyring_search(key_ref_t keyring, - struct key_type *type, - const char *description) +struct key *keyring_search(struct key *keyring, + struct key_type *type, + const char *description) { if (!type->match) return ERR_PTR(-ENOKEY); @@ -497,19 +488,15 @@ EXPORT_SYMBOL(keyring_search); * search the given keyring only (no recursion) * - keyring must be locked by caller */ -key_ref_t __keyring_search_one(key_ref_t keyring_ref, - const struct key_type *ktype, - const char *description, - key_perm_t perm) +struct key *__keyring_search_one(struct key *keyring, + const struct key_type *ktype, + const char *description, + key_perm_t perm) { struct keyring_list *klist; - unsigned long possessed; - struct key *keyring, *key; + struct key *key; int loop; - keyring = key_ref_to_ptr(keyring_ref); - possessed = is_key_possessed(keyring_ref); - rcu_read_lock(); klist = rcu_dereference(keyring->payload.subscriptions); @@ -520,21 +507,21 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref, if (key->type == ktype && (!key->type->match || key->type->match(key, description)) && - key_permission(make_key_ref(key, possessed), - perm) && + key_permission(key, perm) && !test_bit(KEY_FLAG_REVOKED, &key->flags) ) goto found; } } - rcu_read_unlock(); - return ERR_PTR(-ENOKEY); + key = ERR_PTR(-ENOKEY); + goto error; found: atomic_inc(&key->usage); + error: rcu_read_unlock(); - return make_key_ref(key, possessed); + return key; } /* end __keyring_search_one() */ @@ -616,8 +603,7 @@ struct key *find_keyring_by_name(const char *name, key_serial_t bound) if (strcmp(keyring->description, name) != 0) continue; - if (!key_permission(make_key_ref(keyring, 0), - KEY_SEARCH)) + if (!key_permission(keyring, KEY_SEARCH)) continue; /* found a potential candidate, but we still need to diff --git a/trunk/security/keys/proc.c b/trunk/security/keys/proc.c index 12b750e51fbf..c55cf1fd0826 100644 --- a/trunk/security/keys/proc.c +++ b/trunk/security/keys/proc.c @@ -167,7 +167,7 @@ static int proc_keys_show(struct seq_file *m, void *v) #define showflag(KEY, LETTER, FLAG) \ (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-') - seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ", + seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %06x %5d %5d %-9.9s ", key->serial, showflag(key, 'I', KEY_FLAG_INSTANTIATED), showflag(key, 'R', KEY_FLAG_REVOKED), diff --git a/trunk/security/keys/process_keys.c b/trunk/security/keys/process_keys.c index d42d2158ce13..c089f78fb94e 100644 --- a/trunk/security/keys/process_keys.c +++ b/trunk/security/keys/process_keys.c @@ -39,7 +39,7 @@ struct key root_user_keyring = { .type = &key_type_keyring, .user = &root_key_user, .sem = __RWSEM_INITIALIZER(root_user_keyring.sem), - .perm = KEY_POS_ALL | KEY_USR_ALL, + .perm = KEY_USR_ALL, .flags = 1 << KEY_FLAG_INSTANTIATED, .description = "_uid.0", #ifdef KEY_DEBUGGING @@ -54,7 +54,7 @@ struct key root_session_keyring = { .type = &key_type_keyring, .user = &root_key_user, .sem = __RWSEM_INITIALIZER(root_session_keyring.sem), - .perm = KEY_POS_ALL | KEY_USR_ALL, + .perm = KEY_USR_ALL, .flags = 1 << KEY_FLAG_INSTANTIATED, .description = "_uid_ses.0", #ifdef KEY_DEBUGGING @@ -98,7 +98,7 @@ int alloc_uid_keyring(struct user_struct *user) user->session_keyring = session_keyring; ret = 0; -error: + error: return ret; } /* end alloc_uid_keyring() */ @@ -156,7 +156,7 @@ int install_thread_keyring(struct task_struct *tsk) ret = 0; key_put(old); -error: + error: return ret; } /* end install_thread_keyring() */ @@ -193,7 +193,7 @@ int install_process_keyring(struct task_struct *tsk) } ret = 0; -error: + error: return ret; } /* end install_process_keyring() */ @@ -236,7 +236,7 @@ static int install_session_keyring(struct task_struct *tsk, /* we're using RCU on the pointer */ synchronize_rcu(); key_put(old); -error: + error: return ret; } /* end install_session_keyring() */ @@ -376,13 +376,13 @@ void key_fsgid_changed(struct task_struct *tsk) * - we return -EAGAIN if we didn't find any matching key * - we return -ENOKEY if we found only negative matching keys */ -key_ref_t search_process_keyrings(struct key_type *type, - const void *description, - key_match_func_t match, - struct task_struct *context) +struct key *search_process_keyrings(struct key_type *type, + const void *description, + key_match_func_t match, + struct task_struct *context) { struct request_key_auth *rka; - key_ref_t key_ref, ret, err, instkey_ref; + struct key *key, *ret, *err, *instkey; /* we want to return -EAGAIN or -ENOKEY if any of the keyrings were * searchable, but we failed to find a key or we found a negative key; @@ -391,48 +391,46 @@ key_ref_t search_process_keyrings(struct key_type *type, * * in terms of priority: success > -ENOKEY > -EAGAIN > other error */ - key_ref = NULL; + key = NULL; ret = NULL; err = ERR_PTR(-EAGAIN); /* search the thread keyring first */ if (context->thread_keyring) { - key_ref = keyring_search_aux( - make_key_ref(context->thread_keyring, 1), - context, type, description, match); - if (!IS_ERR(key_ref)) + key = keyring_search_aux(context->thread_keyring, + context, type, description, match); + if (!IS_ERR(key)) goto found; - switch (PTR_ERR(key_ref)) { + switch (PTR_ERR(key)) { case -EAGAIN: /* no key */ if (ret) break; case -ENOKEY: /* negative key */ - ret = key_ref; + ret = key; break; default: - err = key_ref; + err = key; break; } } /* search the process keyring second */ if (context->signal->process_keyring) { - key_ref = keyring_search_aux( - make_key_ref(context->signal->process_keyring, 1), - context, type, description, match); - if (!IS_ERR(key_ref)) + key = keyring_search_aux(context->signal->process_keyring, + context, type, description, match); + if (!IS_ERR(key)) goto found; - switch (PTR_ERR(key_ref)) { + switch (PTR_ERR(key)) { case -EAGAIN: /* no key */ if (ret) break; case -ENOKEY: /* negative key */ - ret = key_ref; + ret = key; break; default: - err = key_ref; + err = key; break; } } @@ -440,25 +438,23 @@ key_ref_t search_process_keyrings(struct key_type *type, /* search the session keyring */ if (context->signal->session_keyring) { rcu_read_lock(); - key_ref = keyring_search_aux( - make_key_ref(rcu_dereference( - context->signal->session_keyring), - 1), + key = keyring_search_aux( + rcu_dereference(context->signal->session_keyring), context, type, description, match); rcu_read_unlock(); - if (!IS_ERR(key_ref)) + if (!IS_ERR(key)) goto found; - switch (PTR_ERR(key_ref)) { + switch (PTR_ERR(key)) { case -EAGAIN: /* no key */ if (ret) break; case -ENOKEY: /* negative key */ - ret = key_ref; + ret = key; break; default: - err = key_ref; + err = key; break; } @@ -469,54 +465,51 @@ key_ref_t search_process_keyrings(struct key_type *type, goto no_key; rcu_read_lock(); - instkey_ref = __keyring_search_one( - make_key_ref(rcu_dereference( - context->signal->session_keyring), - 1), + instkey = __keyring_search_one( + rcu_dereference(context->signal->session_keyring), &key_type_request_key_auth, NULL, 0); rcu_read_unlock(); - if (IS_ERR(instkey_ref)) + if (IS_ERR(instkey)) goto no_key; - rka = key_ref_to_ptr(instkey_ref)->payload.data; + rka = instkey->payload.data; - key_ref = search_process_keyrings(type, description, match, - rka->context); - key_ref_put(instkey_ref); + key = search_process_keyrings(type, description, match, + rka->context); + key_put(instkey); - if (!IS_ERR(key_ref)) + if (!IS_ERR(key)) goto found; - switch (PTR_ERR(key_ref)) { + switch (PTR_ERR(key)) { case -EAGAIN: /* no key */ if (ret) break; case -ENOKEY: /* negative key */ - ret = key_ref; + ret = key; break; default: - err = key_ref; + err = key; break; } } /* or search the user-session keyring */ else { - key_ref = keyring_search_aux( - make_key_ref(context->user->session_keyring, 1), - context, type, description, match); - if (!IS_ERR(key_ref)) + key = keyring_search_aux(context->user->session_keyring, + context, type, description, match); + if (!IS_ERR(key)) goto found; - switch (PTR_ERR(key_ref)) { + switch (PTR_ERR(key)) { case -EAGAIN: /* no key */ if (ret) break; case -ENOKEY: /* negative key */ - ret = key_ref; + ret = key; break; default: - err = key_ref; + err = key; break; } } @@ -524,40 +517,29 @@ key_ref_t search_process_keyrings(struct key_type *type, no_key: /* no key - decide on the error we're going to go for */ - key_ref = ret ? ret : err; + key = ret ? ret : err; found: - return key_ref; + return key; } /* end search_process_keyrings() */ -/*****************************************************************************/ -/* - * see if the key we're looking at is the target key - */ -static int lookup_user_key_possessed(const struct key *key, const void *target) -{ - return key == target; - -} /* end lookup_user_key_possessed() */ - /*****************************************************************************/ /* * lookup a key given a key ID from userspace with a given permissions mask * - don't create special keyrings unless so requested * - partially constructed keys aren't found unless requested */ -key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, - int create, int partial, key_perm_t perm) +struct key *lookup_user_key(struct task_struct *context, key_serial_t id, + int create, int partial, key_perm_t perm) { - key_ref_t key_ref, skey_ref; struct key *key; int ret; if (!context) context = current; - key_ref = ERR_PTR(-ENOKEY); + key = ERR_PTR(-ENOKEY); switch (id) { case KEY_SPEC_THREAD_KEYRING: @@ -574,7 +556,6 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, key = context->thread_keyring; atomic_inc(&key->usage); - key_ref = make_key_ref(key, 1); break; case KEY_SPEC_PROCESS_KEYRING: @@ -591,7 +572,6 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, key = context->signal->process_keyring; atomic_inc(&key->usage); - key_ref = make_key_ref(key, 1); break; case KEY_SPEC_SESSION_KEYRING: @@ -599,7 +579,7 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, /* always install a session keyring upon access if one * doesn't exist yet */ ret = install_session_keyring( - context, context->user->session_keyring); + context, context->user->session_keyring); if (ret < 0) goto error; } @@ -608,19 +588,16 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, key = rcu_dereference(context->signal->session_keyring); atomic_inc(&key->usage); rcu_read_unlock(); - key_ref = make_key_ref(key, 1); break; case KEY_SPEC_USER_KEYRING: key = context->user->uid_keyring; atomic_inc(&key->usage); - key_ref = make_key_ref(key, 1); break; case KEY_SPEC_USER_SESSION_KEYRING: key = context->user->session_keyring; atomic_inc(&key->usage); - key_ref = make_key_ref(key, 1); break; case KEY_SPEC_GROUP_KEYRING: @@ -629,28 +606,13 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, goto error; default: - key_ref = ERR_PTR(-EINVAL); + key = ERR_PTR(-EINVAL); if (id < 1) goto error; key = key_lookup(id); - if (IS_ERR(key)) { - key_ref = ERR_PTR(PTR_ERR(key)); + if (IS_ERR(key)) goto error; - } - - key_ref = make_key_ref(key, 0); - - /* check to see if we possess the key */ - skey_ref = search_process_keyrings(key->type, key, - lookup_user_key_possessed, - current); - - if (!IS_ERR(skey_ref)) { - key_put(key); - key_ref = skey_ref; - } - break; } @@ -668,15 +630,15 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, /* check the permissions */ ret = -EACCES; - if (!key_task_permission(key_ref, context, perm)) + if (!key_task_permission(key, context, perm)) goto invalid_key; -error: - return key_ref; + error: + return key; -invalid_key: - key_ref_put(key_ref); - key_ref = ERR_PTR(ret); + invalid_key: + key_put(key); + key = ERR_PTR(ret); goto error; } /* end lookup_user_key() */ @@ -732,9 +694,9 @@ long join_session_keyring(const char *name) ret = keyring->serial; key_put(keyring); -error2: + error2: up(&key_session_sem); -error: + error: return ret; } /* end join_session_keyring() */ diff --git a/trunk/security/keys/request_key.c b/trunk/security/keys/request_key.c index e6dd366d43a3..90c1506d007c 100644 --- a/trunk/security/keys/request_key.c +++ b/trunk/security/keys/request_key.c @@ -129,7 +129,7 @@ static struct key *__request_key_construction(struct key_type *type, /* create a key and add it to the queue */ key = key_alloc(type, description, - current->fsuid, current->fsgid, KEY_POS_ALL, 0); + current->fsuid, current->fsgid, KEY_USR_ALL, 0); if (IS_ERR(key)) goto alloc_failed; @@ -365,24 +365,14 @@ struct key *request_key_and_link(struct key_type *type, { struct key_user *user; struct key *key; - key_ref_t key_ref; kenter("%s,%s,%s,%p", type->name, description, callout_info, dest_keyring); /* search all the process keyrings for a key */ - key_ref = search_process_keyrings(type, description, type->match, - current); + key = search_process_keyrings(type, description, type->match, current); - kdebug("search 1: %p", key_ref); - - if (!IS_ERR(key_ref)) { - key = key_ref_to_ptr(key_ref); - } - else if (PTR_ERR(key_ref) != -EAGAIN) { - key = ERR_PTR(PTR_ERR(key_ref)); - } - else { + if (PTR_ERR(key) == -EAGAIN) { /* the search failed, but the keyrings were searchable, so we * should consult userspace if we can */ key = ERR_PTR(-ENOKEY); @@ -394,7 +384,7 @@ struct key *request_key_and_link(struct key_type *type, if (!user) goto nomem; - for (;;) { + do { if (signal_pending(current)) goto interrupted; @@ -407,22 +397,10 @@ struct key *request_key_and_link(struct key_type *type, /* someone else made the key we want, so we need to * search again as it might now be available to us */ - key_ref = search_process_keyrings(type, description, - type->match, - current); - - kdebug("search 2: %p", key_ref); + key = search_process_keyrings(type, description, + type->match, current); - if (!IS_ERR(key_ref)) { - key = key_ref_to_ptr(key_ref); - break; - } - - if (PTR_ERR(key_ref) != -EAGAIN) { - key = ERR_PTR(PTR_ERR(key_ref)); - break; - } - } + } while (PTR_ERR(key) == -EAGAIN); key_user_put(user); diff --git a/trunk/security/keys/request_key_auth.c b/trunk/security/keys/request_key_auth.c index 1ecd3d3fa9f8..f22264632229 100644 --- a/trunk/security/keys/request_key_auth.c +++ b/trunk/security/keys/request_key_auth.c @@ -126,7 +126,7 @@ struct key *request_key_auth_new(struct key *target, struct key **_rkakey) rkakey = key_alloc(&key_type_request_key_auth, desc, current->fsuid, current->fsgid, - KEY_POS_VIEW | KEY_USR_VIEW, 1); + KEY_USR_VIEW, 1); if (IS_ERR(rkakey)) { key_put(keyring); kleave("= %ld", PTR_ERR(rkakey));