From owner-svn-src-user@FreeBSD.ORG Sun Feb 14 00:30:25 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C114106566B; Sun, 14 Feb 2010 00:30:25 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26E058FC0A; Sun, 14 Feb 2010 00:30:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1E0UPdJ006889; Sun, 14 Feb 2010 00:30:25 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1E0UOuO006857; Sun, 14 Feb 2010 00:30:24 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002140030.o1E0UOuO006857@svn.freebsd.org> From: Warner Losh Date: Sun, 14 Feb 2010 00:30:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203850 - in user/imp/tbemd: gnu/usr.bin/gdb/kgdb lib/libusb sbin/growfs sbin/restore share/man/man9 sys/boot/sparc64/loader sys/dev/acpica sys/dev/cxgb sys/dev/e1000 sys/dev/ixgbe sys/... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2010 00:30:25 -0000 Author: imp Date: Sun Feb 14 00:30:24 2010 New Revision: 203850 URL: http://svn.freebsd.org/changeset/base/203850 Log: merge from head. Added: user/imp/tbemd/sys/sparc64/include/cmt.h - copied unchanged from r203844, head/sys/sparc64/include/cmt.h user/imp/tbemd/sys/sparc64/include/fireplane.h - copied unchanged from r203844, head/sys/sparc64/include/fireplane.h user/imp/tbemd/sys/sparc64/include/jbus.h - copied unchanged from r203844, head/sys/sparc64/include/jbus.h user/imp/tbemd/sys/sparc64/include/nexusvar.h - copied unchanged from r203844, head/sys/sparc64/include/nexusvar.h user/imp/tbemd/sys/sun4v/include/cmt.h - copied unchanged from r203844, head/sys/sun4v/include/cmt.h user/imp/tbemd/sys/sun4v/include/fireplane.h - copied unchanged from r203844, head/sys/sun4v/include/fireplane.h user/imp/tbemd/sys/sun4v/include/jbus.h - copied unchanged from r203844, head/sys/sun4v/include/jbus.h Modified: user/imp/tbemd/gnu/usr.bin/gdb/kgdb/kthr.c user/imp/tbemd/lib/libusb/libusb.h user/imp/tbemd/lib/libusb/libusb10.c user/imp/tbemd/lib/libusb/libusb10_desc.c user/imp/tbemd/lib/libusb/libusb10_io.c user/imp/tbemd/lib/libusb/libusb20.c user/imp/tbemd/lib/libusb/libusb20.h user/imp/tbemd/lib/libusb/libusb20_compat01.c user/imp/tbemd/lib/libusb/libusb20_desc.c user/imp/tbemd/lib/libusb/libusb20_ugen20.c user/imp/tbemd/lib/libusb/usb.h user/imp/tbemd/sbin/growfs/growfs.c user/imp/tbemd/sbin/restore/tape.c user/imp/tbemd/share/man/man9/locking.9 user/imp/tbemd/share/man/man9/vnode.9 user/imp/tbemd/sys/boot/sparc64/loader/main.c user/imp/tbemd/sys/dev/acpica/acpi_video.c user/imp/tbemd/sys/dev/cxgb/cxgb_sge.c user/imp/tbemd/sys/dev/e1000/if_em.c user/imp/tbemd/sys/dev/e1000/if_igb.c user/imp/tbemd/sys/dev/ixgbe/ixgbe.c user/imp/tbemd/sys/dev/mxge/if_mxge.c user/imp/tbemd/sys/fs/msdosfs/bootsect.h user/imp/tbemd/sys/fs/msdosfs/bpb.h user/imp/tbemd/sys/fs/msdosfs/denode.h user/imp/tbemd/sys/fs/msdosfs/direntry.h user/imp/tbemd/sys/fs/msdosfs/msdosfs_conv.c user/imp/tbemd/sys/fs/msdosfs/msdosfs_denode.c user/imp/tbemd/sys/fs/msdosfs/msdosfs_lookup.c user/imp/tbemd/sys/fs/msdosfs/msdosfs_vnops.c user/imp/tbemd/sys/net/if_var.h user/imp/tbemd/sys/sparc64/include/asi.h user/imp/tbemd/sys/sparc64/include/ktr.h user/imp/tbemd/sys/sparc64/include/md_var.h user/imp/tbemd/sys/sparc64/include/upa.h user/imp/tbemd/sys/sparc64/sparc64/locore.S user/imp/tbemd/sys/sparc64/sparc64/machdep.c user/imp/tbemd/sys/sparc64/sparc64/mp_locore.S user/imp/tbemd/sys/sparc64/sparc64/mp_machdep.c user/imp/tbemd/sys/sparc64/sparc64/nexus.c user/imp/tbemd/sys/sparc64/sparc64/pmap.c user/imp/tbemd/sys/sun4v/include/asi.h user/imp/tbemd/sys/ufs/ffs/ffs_alloc.c Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/gnu/usr.bin/gdb/kgdb/kthr.c ============================================================================== --- user/imp/tbemd/gnu/usr.bin/gdb/kgdb/kthr.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/gnu/usr.bin/gdb/kgdb/kthr.c Sun Feb 14 00:30:24 2010 (r203850) @@ -58,6 +58,7 @@ kgdb_lookup(const char *sym) { struct nlist nl[2]; + nl[0].n_type = N_UNDF; nl[0].n_name = (char *)(uintptr_t)sym; nl[1].n_name = NULL; if (kvm_nlist(kvm, nl) != 0) Modified: user/imp/tbemd/lib/libusb/libusb.h ============================================================================== --- user/imp/tbemd/lib/libusb/libusb.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb.h Sun Feb 14 00:30:24 2010 (r203850) @@ -30,8 +30,6 @@ #include #include - - #ifdef __cplusplus extern "C" { #endif Modified: user/imp/tbemd/lib/libusb/libusb10.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb10.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb10.c Sun Feb 14 00:30:24 2010 (r203850) @@ -25,16 +25,17 @@ * SUCH DAMAGE. */ +#include +#include +#include + #include -#include -#include -#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/libusb10_desc.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb10_desc.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb10_desc.c Sun Feb 14 00:30:24 2010 (r203850) @@ -24,10 +24,11 @@ * SUCH DAMAGE. */ -#include -#include #include +#include +#include + #include "libusb20.h" #include "libusb20_desc.h" #include "libusb20_int.h" Modified: user/imp/tbemd/lib/libusb/libusb10_io.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb10_io.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb10_io.c Sun Feb 14 00:30:24 2010 (r203850) @@ -24,14 +24,15 @@ * SUCH DAMAGE. */ -#include -#include -#include +#include + +#include #include #include +#include +#include #include -#include -#include +#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/libusb20.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb20.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb20.c Sun Feb 14 00:30:24 2010 (r203850) @@ -24,12 +24,13 @@ * SUCH DAMAGE. */ +#include + +#include +#include #include #include #include -#include -#include -#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/libusb20.h ============================================================================== --- user/imp/tbemd/lib/libusb/libusb20.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb20.h Sun Feb 14 00:30:24 2010 (r203850) @@ -29,13 +29,13 @@ #ifndef _LIBUSB20_H_ #define _LIBUSB20_H_ -#include -#include -#include - +#include #include #include -#include + +#include +#include +#include #ifdef __cplusplus extern "C" { Modified: user/imp/tbemd/lib/libusb/libusb20_compat01.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb20_compat01.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb20_compat01.c Sun Feb 14 00:30:24 2010 (r203850) @@ -30,9 +30,9 @@ #include -#include -#include #include +#include +#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/libusb20_desc.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb20_desc.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb20_desc.c Sun Feb 14 00:30:24 2010 (r203850) @@ -24,10 +24,11 @@ * SUCH DAMAGE. */ +#include + #include #include #include -#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/libusb20_ugen20.c ============================================================================== --- user/imp/tbemd/lib/libusb/libusb20_ugen20.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/libusb20_ugen20.c Sun Feb 14 00:30:24 2010 (r203850) @@ -27,12 +27,12 @@ #include #include +#include +#include #include #include -#include #include -#include -#include +#include #include "libusb20.h" #include "libusb20_desc.h" Modified: user/imp/tbemd/lib/libusb/usb.h ============================================================================== --- user/imp/tbemd/lib/libusb/usb.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/lib/libusb/usb.h Sun Feb 14 00:30:24 2010 (r203850) @@ -27,9 +27,10 @@ #ifndef _LIBUSB20_COMPAT_01_H_ #define _LIBUSB20_COMPAT_01_H_ -#include -#include #include +#include + +#include /* USB interface class codes */ Modified: user/imp/tbemd/sbin/growfs/growfs.c ============================================================================== --- user/imp/tbemd/sbin/growfs/growfs.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sbin/growfs/growfs.c Sun Feb 14 00:30:24 2010 (r203850) @@ -450,13 +450,11 @@ initcg(int cylno, time_t utime, int fso, acg.cg_cs.cs_nifree--; } /* - * XXX Newfs writes out two blocks of initialized inodes - * unconditionally. Should we check here to make sure that they - * were actually written? + * For the old file system, we have to initialize all the inodes. */ if (sblock.fs_magic == FS_UFS1_MAGIC) { bzero(iobuf, sblock.fs_bsize); - for (i = 2 * sblock.fs_frag; i < sblock.fs_ipg / INOPF(&sblock); + for (i = 0; i < sblock.fs_ipg / INOPF(&sblock); i += sblock.fs_frag) { dp1 = (struct ufs1_dinode *)iobuf; #ifdef FSIRAND Modified: user/imp/tbemd/sbin/restore/tape.c ============================================================================== --- user/imp/tbemd/sbin/restore/tape.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sbin/restore/tape.c Sun Feb 14 00:30:24 2010 (r203850) @@ -227,7 +227,7 @@ setup(void) volno = 1; setdumpnum(); FLUSHTAPEBUF(); - if (!pipein && !bflag) + if (!pipein && !pipecmdin && !bflag) findtapeblksize(); if (gethead(&spcl) == FAIL) { fprintf(stderr, "Tape is not a dump tape\n"); Modified: user/imp/tbemd/share/man/man9/locking.9 ============================================================================== --- user/imp/tbemd/share/man/man9/locking.9 Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/share/man/man9/locking.9 Sun Feb 14 00:30:24 2010 (r203850) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 10, 2010 +.Dd February 13, 2010 .Dt LOCKING 9 .Os .Sh NAME @@ -36,41 +36,9 @@ The kernel is written to run across multiple CPUs and as such requires several different synchronization primitives to allow the developers to safely access and manipulate the many data types required. -.Pp -These include: -.Bl -enum -.It -Mutexes -.It -Spin mutexes -.It -Pool mutexes -.It -Shared/exclusive locks -.It -Reader/writer locks -.It -Read-mostly locks -.It -Counting semaphores -.It -Condition variables -.It -Sleep/wakeup -.It -Giant -.It -Lockmanager locks -.El -.Pp -The primitives interact and have a number of rules regarding how -they can and can not be combined. -Many of these rules are checked using the -.Xr witness 4 -code. -.Pp .Ss Mutexes -Mutexes are the most commonly used synchronization primitive in the kernel. +Mutexes (also called "sleep mutexes") are the most commonly used +synchronization primitive in the kernel. Thread acquires (locks) a mutex before accessing data shared with other threads (including interrupt threads), and releases (unlocks) it afterwards. If the mutex cannot be acquired, the thread requesting it will sleep. @@ -85,12 +53,10 @@ the two is that spin mutexes never sleep for the thread holding the lock, which runs on another CPU, to release it. Differently from ordinary mutex, spin mutexes disable interrupts when acquired. Since disabling interrupts is expensive, they are also generally slower. -Spin mutexes should only be used to protect data shared with primary -(INTR_FILTER) interrupt code. -You -.Em must not -do anything that deschedules the thread while you -are holding a spin mutex. +Spin mutexes should be used only when neccessary, e.g. to protect data shared +with interrupt filter code (see +.Xr bus_setup_intr 9 +for details). .Ss Pool mutexes With most synchronisaton primitives, such as mutexes, programmer must provide a piece of allocated memory to hold the primitive. @@ -284,6 +250,11 @@ See .Xr lock 9 for details. .Sh INTERACTIONS +The primitives interact and have a number of rules regarding how +they can and can not be combined. +Many of these rules are checked using the +.Xr witness 4 +code. .Ss Bounded vs. unbounded sleep The following primitives perform bounded sleep: mutexes, pool mutexes, reader/writer locks and read-mostly locks. @@ -320,21 +291,23 @@ rwlock, your sleep, will cause a panic. If the sleep only happens rarely it may be years before the bad code path is found. .Pp +It is an error to do any operation that could result in any kind of sleep when +running inside an interrupt filter. +.Pp It is an error to do any operation that could result in unbounded sleep when running inside an interrupt thread. .Ss Interaction table -The following table shows what you can and can not do if you hold -one of the synchronization primitives discussed here: -(someone who knows what they are talking about should write this table) +The following table shows what you can and can not do while holding +one of the synchronization primitives discussed: .Bl -column ".Ic xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent .It Xo .Em "You have: You want:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep .Xc -.It Ic spin mtx Ta \&ok-1 Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no-3 -.It Ic mutex Ta \&ok Ta \&ok-1 Ta \&no Ta \&ok Ta \&ok Ta \&no-3 -.It Ic sx Ta \&ok Ta \&ok Ta \&ok-2 Ta \&ok Ta \&ok Ta \&ok-4 -.It Ic rwlock Ta \&ok Ta \&ok Ta \&no Ta \&ok-2 Ta \&ok Ta \&no-3 -.It Ic rmlock Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok-2 Ta \&no +.It spin mtx Ta \&ok-1 Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no-3 +.It mutex Ta \&ok Ta \&ok-1 Ta \&no Ta \&ok Ta \&ok Ta \&no-3 +.It sx Ta \&ok Ta \&ok Ta \&ok-2 Ta \&ok Ta \&ok Ta \&ok-4 +.It rwlock Ta \&ok Ta \&ok Ta \&no Ta \&ok-2 Ta \&ok Ta \&no-3 +.It rmlock Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok-2 Ta \&no .El .Pp .Em *1 @@ -364,10 +337,12 @@ The next table shows what can be used in At this time this is a rather easy to remember table. .Bl -column ".Ic Xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent .It Xo -.Em "Context:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep +.Em "Context:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep .Xc -.It interrupt: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no -.It idle: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no +.It interrupt filter: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no +.It ithread: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok Ta \&no +.It callout: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&no Ta \&no +.It syscall: Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok .El .Sh SEE ALSO .Xr condvar 9 , Modified: user/imp/tbemd/share/man/man9/vnode.9 ============================================================================== --- user/imp/tbemd/share/man/man9/vnode.9 Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/share/man/man9/vnode.9 Sun Feb 14 00:30:24 2010 (r203850) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 9, 2010 +.Dd February 13, 2010 .Os .Dt VNODE 9 .Sh NAME @@ -137,7 +137,7 @@ Advisory locking will not work on this. A FIFO (named pipe). Advisory locking will not work on this. .It Dv VBAD -An old style bad sector map +Indicates that the vnode has been reclaimed. .El .Sh IMPLEMENTATION NOTES VFIFO uses the "struct fileops" from Modified: user/imp/tbemd/sys/boot/sparc64/loader/main.c ============================================================================== --- user/imp/tbemd/sys/boot/sparc64/loader/main.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/boot/sparc64/loader/main.c Sun Feb 14 00:30:24 2010 (r203850) @@ -46,16 +46,19 @@ __FBSDID("$FreeBSD$"); */ #include -#include #include -#include +#include #include +#include #include #include #include +#include #include #include +#include +#include #include #include #include @@ -68,6 +71,12 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" #include "dev_net.h" +#ifndef CTASSERT +#define CTASSERT(x) _CTASSERT(x, __LINE__) +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] +#endif + extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; enum { @@ -76,6 +85,9 @@ enum { LOADSZ = 0x1000000 /* for kernel and modules */ }; +/* At least Sun Fire V1280 require page sized allocations to be claimed. */ +CTASSERT(HEAPSZ % PAGE_SIZE == 0); + static struct mmu_ops { void (*tlb_init)(void); int (*mmu_mapin)(vm_offset_t va, vm_size_t len); @@ -84,11 +96,11 @@ static struct mmu_ops { typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3, void *openfirmware); -static inline u_long dtlb_get_data_sun4u(int slot); -static void dtlb_enter_sun4u(u_long vpn, u_long data); +static inline u_long dtlb_get_data_sun4u(u_int); +static int dtlb_enter_sun4u(u_int, u_long data, vm_offset_t); static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t); -static inline u_long itlb_get_data_sun4u(int slot); -static void itlb_enter_sun4u(u_long vpn, u_long data); +static inline u_long itlb_get_data_sun4u(u_int); +static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t); static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t); static void itlb_relocate_locked0_sun4u(void); extern vm_offset_t md_load(char *, vm_offset_t *); @@ -104,6 +116,9 @@ static int __elfN(exec)(struct preloaded static int mmu_mapin_sun4u(vm_offset_t, vm_size_t); static int mmu_mapin_sun4v(vm_offset_t, vm_size_t); static vm_offset_t init_heap(void); +static phandle_t find_bsp_sun4u(phandle_t, uint32_t); +const char *cpu_cpuid_prop_sun4u(void); +uint32_t cpu_get_mid_sun4u(void); static void tlb_init_sun4u(void); static void tlb_init_sun4v(void); @@ -120,11 +135,11 @@ static struct mmu_ops mmu_ops_sun4v = { /* sun4u */ struct tlb_entry *dtlb_store; struct tlb_entry *itlb_store; -int dtlb_slot; -int itlb_slot; +u_int dtlb_slot; +u_int itlb_slot; int cpu_impl; -static int dtlb_slot_max; -static int itlb_slot_max; +static u_int dtlb_slot_max; +static u_int itlb_slot_max; /* sun4v */ static struct tlb_entry *tlb_store; @@ -398,7 +413,7 @@ __elfN(exec)(struct preloaded_file *fp) } static inline u_long -dtlb_get_data_sun4u(int slot) +dtlb_get_data_sun4u(u_int slot) { /* @@ -410,7 +425,7 @@ dtlb_get_data_sun4u(int slot) } static inline u_long -itlb_get_data_sun4u(int slot) +itlb_get_data_sun4u(u_int slot) { /* @@ -467,55 +482,24 @@ itlb_va_to_pa_sun4u(vm_offset_t va) return (-1); } -static void -dtlb_enter_sun4u(u_long vpn, u_long data) +static int +dtlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt) { - u_long reg; - reg = rdpr(pstate); - wrpr(pstate, reg & ~PSTATE_IE, 0); - stxa(AA_DMMU_TAR, ASI_DMMU, - TLB_TAR_VA(vpn) | TLB_TAR_CTX(TLB_CTX_KERNEL)); - stxa(0, ASI_DTLB_DATA_IN_REG, data); - membar(Sync); - wrpr(pstate, reg, 0); + return (OF_call_method("SUNW,dtlb-load", mmu, 3, 0, index, data, + virt)); } -static void -itlb_enter_sun4u(u_long vpn, u_long data) +static int +itlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt) { - u_long reg; - int i; - - reg = rdpr(pstate); - wrpr(pstate, reg & ~PSTATE_IE, 0); - if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp) { - /* - * Search an unused slot != 0 and explicitly enter the data - * and tag there in order to avoid Cheetah+ erratum 34. - */ - for (i = 1; i < itlb_slot_max; i++) { - if ((itlb_get_data_sun4u(i) & TD_V) != 0) - continue; - - stxa(AA_IMMU_TAR, ASI_IMMU, - TLB_TAR_VA(vpn) | TLB_TAR_CTX(TLB_CTX_KERNEL)); - stxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG, data); - flush(PROMBASE); - break; - } - wrpr(pstate, reg, 0); - if (i == itlb_slot_max) - panic("%s: could not find an unused slot", __func__); - return; - } - - stxa(AA_IMMU_TAR, ASI_IMMU, - TLB_TAR_VA(vpn) | TLB_TAR_CTX(TLB_CTX_KERNEL)); - stxa(0, ASI_ITLB_DATA_IN_REG, data); - flush(PROMBASE); - wrpr(pstate, reg, 0); + if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp && index == 0 && + (data & TD_L) != 0) + panic("%s: won't enter locked TLB entry at index 0 on USIII+", + __func__); + return (OF_call_method("SUNW,itlb-load", mmu, 3, 0, index, data, + virt)); } static void @@ -565,6 +549,7 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ { vm_offset_t pa, mva; u_long data; + u_int index; if (va + len > curkva) curkva = va + len; @@ -602,12 +587,20 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ TD_CV | TD_P | TD_W; dtlb_store[dtlb_slot].te_pa = pa; dtlb_store[dtlb_slot].te_va = va; + index = dtlb_slot_max - dtlb_slot - 1; + if (dtlb_enter_sun4u(index, data, va) < 0) + panic("%s: can't enter dTLB slot %d data " + "%#lx va %#lx", __func__, index, data, + va); + dtlb_slot++; itlb_store[itlb_slot].te_pa = pa; itlb_store[itlb_slot].te_va = va; - dtlb_slot++; + index = itlb_slot_max - itlb_slot - 1; + if (itlb_enter_sun4u(index, data, va) < 0) + panic("%s: can't enter iTLB slot %d data " + "%#lx va %#lxd", __func__, index, data, + va); itlb_slot++; - dtlb_enter_sun4u(va, data); - itlb_enter_sun4u(va, data); pa = (vm_offset_t)-1; } len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; @@ -668,33 +661,98 @@ init_heap(void) return (heapva); } +static phandle_t +find_bsp_sun4u(phandle_t node, uint32_t bspid) +{ + char type[sizeof("cpu")]; + phandle_t child; + uint32_t cpuid; + + for (; node > 0; node = OF_peer(node)) { + child = OF_child(node); + if (child > 0) { + child = find_bsp_sun4u(child, bspid); + if (child > 0) + return (child); + } else { + if (OF_getprop(node, "device_type", type, + sizeof(type)) <= 0) + continue; + if (strcmp(type, "cpu") != 0) + continue; + if (OF_getprop(node, cpu_cpuid_prop_sun4u(), &cpuid, + sizeof(cpuid)) <= 0) + continue; + if (cpuid == bspid) + return (node); + } + } + return (0); +} + +const char * +cpu_cpuid_prop_sun4u(void) +{ + + switch (cpu_impl) { + case CPU_IMPL_SPARC64: + case CPU_IMPL_ULTRASPARCI: + case CPU_IMPL_ULTRASPARCII: + case CPU_IMPL_ULTRASPARCIIi: + case CPU_IMPL_ULTRASPARCIIe: + return ("upa-portid"); + case CPU_IMPL_ULTRASPARCIII: + case CPU_IMPL_ULTRASPARCIIIp: + case CPU_IMPL_ULTRASPARCIIIi: + case CPU_IMPL_ULTRASPARCIIIip: + return ("portid"); + case CPU_IMPL_ULTRASPARCIV: + case CPU_IMPL_ULTRASPARCIVp: + return ("cpuid"); + default: + return (""); + } +} + +uint32_t +cpu_get_mid_sun4u(void) +{ + + switch (cpu_impl) { + case CPU_IMPL_SPARC64: + case CPU_IMPL_ULTRASPARCI: + case CPU_IMPL_ULTRASPARCII: + case CPU_IMPL_ULTRASPARCIIi: + case CPU_IMPL_ULTRASPARCIIe: + return (UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG))); + case CPU_IMPL_ULTRASPARCIII: + case CPU_IMPL_ULTRASPARCIIIp: + return (FIREPLANE_CR_GET_AID(ldxa(AA_FIREPLANE_CONFIG, + ASI_FIREPLANE_CONFIG_REG))); + case CPU_IMPL_ULTRASPARCIIIi: + case CPU_IMPL_ULTRASPARCIIIip: + return (JBUS_CR_GET_JID(ldxa(0, ASI_JBUS_CONFIG_REG))); + case CPU_IMPL_ULTRASPARCIV: + case CPU_IMPL_ULTRASPARCIVp: + return (INTR_ID_GET_ID(ldxa(AA_INTR_ID, ASI_INTR_ID))); + default: + return (0); + } +} + static void tlb_init_sun4u(void) { - phandle_t child; - char buf[128]; - u_int bootcpu; - u_int cpu; + phandle_t bsp; cpu_impl = VER_IMPL(rdpr(ver)); - bootcpu = UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)); - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (OF_getprop(child, "device_type", buf, sizeof(buf)) <= 0) - continue; - if (strcmp(buf, "cpu") != 0) - continue; - if (OF_getprop(child, cpu_impl < CPU_IMPL_ULTRASPARCIII ? - "upa-portid" : "portid", &cpu, sizeof(cpu)) <= 0) - continue; - if (cpu == bootcpu) - break; - } - if (cpu != bootcpu) + bsp = find_bsp_sun4u(OF_child(root), cpu_get_mid_sun4u()); + if (bsp == 0) panic("%s: no node for bootcpu?!?!", __func__); - if (OF_getprop(child, "#dtlb-entries", &dtlb_slot_max, + if (OF_getprop(bsp, "#dtlb-entries", &dtlb_slot_max, sizeof(dtlb_slot_max)) == -1 || - OF_getprop(child, "#itlb-entries", &itlb_slot_max, + OF_getprop(bsp, "#itlb-entries", &itlb_slot_max, sizeof(itlb_slot_max)) == -1) panic("%s: can't get TLB slot max.", __func__); @@ -749,14 +807,15 @@ main(int (*openfirm)(void *)) archsw.arch_autoload = sparc64_autoload; archsw.arch_maphint = sparc64_maphint; - init_heap(); - setheap((void *)heapva, (void *)(heapva + HEAPSZ)); - /* * Probe for a console. */ cons_probe(); + if (init_heap() == (vm_offset_t)-1) + panic("%s: can't claim heap", __func__); + setheap((void *)heapva, (void *)(heapva + HEAPSZ)); + if ((root = OF_peer(0)) == -1) panic("%s: can't get root phandle", __func__); OF_getprop(root, "compatible", compatible, sizeof(compatible)); Modified: user/imp/tbemd/sys/dev/acpica/acpi_video.c ============================================================================== --- user/imp/tbemd/sys/dev/acpica/acpi_video.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/acpica/acpi_video.c Sun Feb 14 00:30:24 2010 (r203850) @@ -645,7 +645,7 @@ acpi_video_vo_notify_handler(ACPI_HANDLE vo = context; ACPI_SERIAL_BEGIN(video_output); - if (vo->handle == NULL) { + if (vo->handle != handle) { ACPI_SERIAL_END(video_output); return; } @@ -655,7 +655,7 @@ acpi_video_vo_notify_handler(ACPI_HANDLE case VID_NOTIFY_DEC_BRN: if (vo->vo_levels == NULL) break; - level = vo_get_brightness(vo->handle); + level = vo_get_brightness(handle); if (level < 0) break; new_level = level; @@ -672,13 +672,13 @@ acpi_video_vo_notify_handler(ACPI_HANDLE } } if (new_level != level) { - vo_set_brightness(vo->handle, new_level); + vo_set_brightness(handle, new_level); vo->vo_brightness = new_level; } break; default: - printf("%s: unknown notify event 0x%x\n", - acpi_name(vo->handle), notify); + printf("unknown notify event 0x%x from %s\n", + notify, acpi_name(handle)); } ACPI_SERIAL_END(video_output); } Modified: user/imp/tbemd/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/imp/tbemd/sys/dev/cxgb/cxgb_sge.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/cxgb/cxgb_sge.c Sun Feb 14 00:30:24 2010 (r203850) @@ -228,6 +228,8 @@ static uint8_t flit_desc_map[] = { #define TXQ_LOCK(qs) mtx_lock(&(qs)->lock) #define TXQ_UNLOCK(qs) mtx_unlock(&(qs)->lock) #define TXQ_RING_EMPTY(qs) drbr_empty((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr) +#define TXQ_RING_NEEDS_ENQUEUE(qs) \ + drbr_needs_enqueue((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr) #define TXQ_RING_FLUSH(qs) drbr_flush((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr) #define TXQ_RING_DEQUEUE_COND(qs, func, arg) \ drbr_dequeue_cond((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr, func, arg) @@ -1712,7 +1714,7 @@ cxgb_transmit_locked(struct ifnet *ifp, * - there is space in hardware transmit queue */ if (check_pkt_coalesce(qs) == 0 && - TXQ_RING_EMPTY(qs) && avail > 4) { + !TXQ_RING_NEEDS_ENQUEUE(qs) && avail > 4) { if (t3_encap(qs, &m)) { if (m != NULL && (error = drbr_enqueue(ifp, br, m)) != 0) Modified: user/imp/tbemd/sys/dev/e1000/if_em.c ============================================================================== --- user/imp/tbemd/sys/dev/e1000/if_em.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/e1000/if_em.c Sun Feb 14 00:30:24 2010 (r203850) @@ -955,7 +955,7 @@ em_mq_start_locked(struct ifnet *ifp, st || (!adapter->link_active)) { error = drbr_enqueue(ifp, adapter->br, m); return (error); - } else if (drbr_empty(ifp, adapter->br) && + } else if (!drbr_needs_enqueue(ifp, adapter->br) && (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) { if ((error = em_xmit(adapter, &m)) != 0) { if (m) Modified: user/imp/tbemd/sys/dev/e1000/if_igb.c ============================================================================== --- user/imp/tbemd/sys/dev/e1000/if_igb.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/e1000/if_igb.c Sun Feb 14 00:30:24 2010 (r203850) @@ -842,9 +842,13 @@ igb_mq_start_locked(struct ifnet *ifp, s } enq = 0; - if (m == NULL) + if (m == NULL) { next = drbr_dequeue(ifp, txr->br); - else + } else if (drbr_needs_enqueue(ifp, txr->br)) { + if ((err = drbr_enqueue(ifp, txr->br, m)) != 0) + return (err); + next = drbr_dequeue(ifp, txr->br); + } else next = m; /* Process the queue */ while (next != NULL) { Modified: user/imp/tbemd/sys/dev/ixgbe/ixgbe.c ============================================================================== --- user/imp/tbemd/sys/dev/ixgbe/ixgbe.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/ixgbe/ixgbe.c Sun Feb 14 00:30:24 2010 (r203850) @@ -861,7 +861,7 @@ ixgbe_mq_start_locked(struct ifnet *ifp, goto process; /* If nothing queued go right to xmit */ - if (drbr_empty(ifp, txr->br)) { + if (!drbr_needs_enqueue(ifp, txr->br)) { if ((err = ixgbe_xmit(txr, &m)) != 0) { if (m != NULL) err = drbr_enqueue(ifp, txr->br, m); Modified: user/imp/tbemd/sys/dev/mxge/if_mxge.c ============================================================================== --- user/imp/tbemd/sys/dev/mxge/if_mxge.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/dev/mxge/if_mxge.c Sun Feb 14 00:30:24 2010 (r203850) @@ -2249,7 +2249,7 @@ mxge_transmit_locked(struct mxge_slice_s return (err); } - if (drbr_empty(ifp, tx->br) && + if (!drbr_needs_enqueue(ifp, tx->br) && ((tx->mask - (tx->req - tx->done)) > tx->max_desc)) { /* let BPF see it */ BPF_MTAP(ifp, m); Modified: user/imp/tbemd/sys/fs/msdosfs/bootsect.h ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/bootsect.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/bootsect.h Sun Feb 14 00:30:24 2010 (r203850) @@ -16,6 +16,8 @@ * * October 1992 */ +#ifndef _FS_MSDOSFS_BOOTSECT_H_ +#define _FS_MSDOSFS_BOOTSECT_H_ /* * Format of a boot sector. This is the first sector on a DOS floppy disk @@ -91,3 +93,5 @@ union bootsector { #define bsHiddenSecs bsBPB.bpbHiddenSecs #define bsHugeSectors bsBPB.bpbHugeSectors #endif + +#endif /* !_FS_MSDOSFS_BOOTSECT_H_ */ Modified: user/imp/tbemd/sys/fs/msdosfs/bpb.h ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/bpb.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/bpb.h Sun Feb 14 00:30:24 2010 (r203850) @@ -17,6 +17,9 @@ * October 1992 */ +#ifndef _FS_MSDOSFS_BPB_H_ +#define _FS_MSDOSFS_BPB_H_ + /* * BIOS Parameter Block (BPB) for DOS 3.3 */ @@ -78,7 +81,7 @@ struct bpb710 { u_int32_t bpbRootClust; /* start cluster for root directory */ u_int16_t bpbFSInfo; /* filesystem info structure sector */ u_int16_t bpbBackup; /* backup boot sector */ - /* There is a 12 byte filler here, but we ignore it */ + u_int8_t bpbReserved[12]; /* reserved for future expansion */ }; /* @@ -153,7 +156,7 @@ struct byte_bpb710 { u_int8_t bpbRootClust[4]; /* start cluster for root directory */ u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */ u_int8_t bpbBackup[2]; /* backup boot sector */ - /* There is a 12 byte filler here, but we ignore it */ + u_int8_t bpbReserved[12]; /* reserved for future expansion */ }; /* @@ -168,3 +171,4 @@ struct fsinfo { u_int8_t fsifill2[12]; u_int8_t fsisig3[4]; }; +#endif /* !_FS_MSDOSFS_BPB_H_ */ Modified: user/imp/tbemd/sys/fs/msdosfs/denode.h ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/denode.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/denode.h Sun Feb 14 00:30:24 2010 (r203850) @@ -207,9 +207,6 @@ struct denode { ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \ putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16)) -#define de_forw de_chain[0] -#define de_back de_chain[1] - #ifdef _KERNEL #define VTODE(vp) ((struct denode *)(vp)->v_data) Modified: user/imp/tbemd/sys/fs/msdosfs/direntry.h ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/direntry.h Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/direntry.h Sun Feb 14 00:30:24 2010 (r203850) @@ -47,16 +47,17 @@ * * October 1992 */ +#ifndef _FS_MSDOSFS_DIRENTRY_H_ +#define _FS_MSDOSFS_DIRENTRY_H_ /* * Structure of a dos directory entry. */ struct direntry { - u_int8_t deName[8]; /* filename, blank filled */ + u_int8_t deName[11]; /* filename, blank filled */ #define SLOT_EMPTY 0x00 /* slot has never been used */ #define SLOT_E5 0x05 /* the real value is 0xe5 */ #define SLOT_DELETED 0xe5 /* file in this slot deleted */ - u_int8_t deExtension[3]; /* extension, blank filled */ u_int8_t deAttributes; /* file attributes */ #define ATTR_NORMAL 0x00 /* normal file */ #define ATTR_READONLY 0x01 /* file is readonly */ @@ -155,7 +156,8 @@ int winChkName(struct mbnambuf *nbp, con int chksum, struct msdosfsmount *pmp); int win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum, struct msdosfsmount *pmp); -u_int8_t winChksum(struct direntry *dep); +u_int8_t winChksum(u_int8_t *name); int winSlotCnt(const u_char *un, size_t unlen, struct msdosfsmount *pmp); size_t winLenFixup(const u_char *un, size_t unlen); #endif /* _KERNEL */ +#endif /* !_FS_MSDOSFS_DIRENTRY_H_ */ Modified: user/imp/tbemd/sys/fs/msdosfs/msdosfs_conv.c ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/msdosfs_conv.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/msdosfs_conv.c Sun Feb 14 00:30:24 2010 (r203850) @@ -741,22 +741,13 @@ win2unixfn(nbp, wep, chksum, pmp) * Compute the unrolled checksum of a DOS filename for Win95 LFN use. */ u_int8_t -winChksum(struct direntry *dep) +winChksum(u_int8_t *name) { + int i; u_int8_t s; - s = dep->deName[0]; - s = ((s << 7) | (s >> 1)) + dep->deName[1]; - s = ((s << 7) | (s >> 1)) + dep->deName[2]; - s = ((s << 7) | (s >> 1)) + dep->deName[3]; - s = ((s << 7) | (s >> 1)) + dep->deName[4]; - s = ((s << 7) | (s >> 1)) + dep->deName[5]; - s = ((s << 7) | (s >> 1)) + dep->deName[6]; - s = ((s << 7) | (s >> 1)) + dep->deName[7]; - s = ((s << 7) | (s >> 1)) + dep->deExtension[0]; - s = ((s << 7) | (s >> 1)) + dep->deExtension[1]; - s = ((s << 7) | (s >> 1)) + dep->deExtension[2]; - + for (s = 0, i = 11; --i >= 0; s += *name++) + s = (s << 7)|(s >> 1); return (s); } Modified: user/imp/tbemd/sys/fs/msdosfs/msdosfs_denode.c ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/msdosfs_denode.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/msdosfs_denode.c Sun Feb 14 00:30:24 2010 (r203850) @@ -144,11 +144,11 @@ deget(pmp, dirclust, diroffset, depp) } /* - * Do the MALLOC before the getnewvnode since doing so afterward + * Do the malloc before the getnewvnode since doing so afterward * might cause a bogus v_data pointer to get dereferenced - * elsewhere if MALLOC should block. + * elsewhere if malloc should block. */ - ldep = malloc(sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK); + ldep = malloc(sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK | M_ZERO); /* * Directory entry was not in cache, have to create a vnode and @@ -161,7 +161,6 @@ deget(pmp, dirclust, diroffset, depp) free(ldep, M_MSDOSFSNODE); return error; } - bzero((caddr_t)ldep, sizeof *ldep); nvp->v_data = ldep; ldep->de_vnode = nvp; ldep->de_flag = 0; Modified: user/imp/tbemd/sys/fs/msdosfs/msdosfs_lookup.c ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/msdosfs_lookup.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/msdosfs_lookup.c Sun Feb 14 00:30:24 2010 (r203850) @@ -276,7 +276,7 @@ msdosfs_lookup(ap) /* * Check for a checksum or name match */ - chksum_ok = (chksum == winChksum(dep)); + chksum_ok = (chksum == winChksum(dep->deName)); if (!chksum_ok && (!olddos || bcmp(dosfilename, dep->deName, 11))) { chksum = -1; @@ -617,7 +617,7 @@ createde(dep, ddep, depp, cnp) * Now write the Win95 long name */ if (ddep->de_fndcnt > 0) { - u_int8_t chksum = winChksum(ndep); + u_int8_t chksum = winChksum(ndep->deName); const u_char *un = (const u_char *)cnp->cn_nameptr; int unlen = cnp->cn_namelen; int cnt = 1; Modified: user/imp/tbemd/sys/fs/msdosfs/msdosfs_vnops.c ============================================================================== --- user/imp/tbemd/sys/fs/msdosfs/msdosfs_vnops.c Sun Feb 14 00:18:32 2010 (r203849) +++ user/imp/tbemd/sys/fs/msdosfs/msdosfs_vnops.c Sun Feb 14 00:30:24 2010 (r203850) @@ -1287,7 +1287,7 @@ static struct { struct direntry dot; struct direntry dotdot; } dosdirtemplate = { - { ". ", " ", /* the . entry */ + { ". ", /* the . entry */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun Feb 14 05:44:06 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C4DC106566B; Sun, 14 Feb 2010 05:44:06 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CE8B8FC17; Sun, 14 Feb 2010 05:44:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1E5i6AG078083; Sun, 14 Feb 2010 05:44:06 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1E5i6na078081; Sun, 14 Feb 2010 05:44:06 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201002140544.o1E5i6na078081@svn.freebsd.org> From: Doug Barton Date: Sun, 14 Feb 2010 05:44:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203853 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2010 05:44:06 -0000 Author: dougb Date: Sun Feb 14 05:44:06 2010 New Revision: 203853 URL: http://svn.freebsd.org/changeset/base/203853 Log: Catch up with the cons* fix committed in ports version 2.19. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Feb 14 05:02:08 2010 (r203852) +++ user/dougb/portmaster/portmaster Sun Feb 14 05:44:06 2010 (r203853) @@ -1666,7 +1666,7 @@ check_fetch_only () { term_printf () { [ -n "$PM_NO_TERM_TITLE" ] && return - [ "$TERM" = cons25 ] && return + case "$TERM" in cons*) return ;; esac printf "\033]0;${0##*/}: ${PM_PARENT_PORT}${1}\007" } From owner-svn-src-user@FreeBSD.ORG Sun Feb 14 07:20:58 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B8B41065672; Sun, 14 Feb 2010 07:20:58 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8076E8FC08; Sun, 14 Feb 2010 07:20:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1E7KwBc099170; Sun, 14 Feb 2010 07:20:58 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1E7Kwmr099168; Sun, 14 Feb 2010 07:20:58 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201002140720.o1E7Kwmr099168@svn.freebsd.org> From: Doug Barton Date: Sun, 14 Feb 2010 07:20:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203854 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2010 07:20:58 -0000 Author: dougb Date: Sun Feb 14 07:20:58 2010 New Revision: 203854 URL: http://svn.freebsd.org/changeset/base/203854 Log: Correct the error message output for the recently introduced pm_cd_pd() First step towards INDEX file support, downloading and installing Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Feb 14 05:44:06 2010 (r203853) +++ user/dougb/portmaster/portmaster Sun Feb 14 07:20:58 2010 (r203854) @@ -246,6 +246,7 @@ usage () { echo " [[--packages|--packages-only] [-P|-PP] | [--packages-build]]" echo " [--packages-if-newer] [--delete-build-only] [--always-fetch]" echo " [--local-packagedir=] [--no-confirm] [--no-term-title]" + echo " [--index]" echo " [-m ] [-x ]" echo "${0##*/} [Common flags] " echo "${0##*/} [Common flags] " @@ -304,6 +305,7 @@ usage () { echo '--no-confirm do not ask user to confirm list of ports to be' echo ' installed and/or updated before proceeding' echo '--no-term-title do not update the xterm title bar' + echo "--index use $pd/INDEX-[6-9] to check if a port is out of date" echo '' echo '--show-work list what ports are and would be installed' echo '' @@ -350,7 +352,7 @@ usage () { pm_cd () { builtin cd $1 2>/dev/null || return 1; } pm_cd_pd () { builtin cd $pd/$1 2>/dev/null || - fail "Cannot cd to port directory: $pd/$origin"; } + fail "Cannot cd to port directory: $pd/$1"; } pm_kill () { /bin/kill $* >/dev/null 2>/dev/null; } pm_make () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH; unset -v MASTER_RB_LIST CONFIG_SEEN_LIST; @@ -446,6 +448,7 @@ for var in "$@" ; do export PM_NO_CONFIRM ;; --no-term-title) PM_NO_TERM_TITLE=pm_no_term_title export PM_NO_TERM_TITLE ;; + --index) PM_INDEX=pm_index ; export PM_INDEX ;; --help) usage 0 ;; --version) version ; exit 0 ;; --clean-distfiles) CLEAN_DISTFILES=clean_distfiles ;; @@ -2211,6 +2214,41 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S export DI_FILES=`pm_mktemp DI-FILES` fi +# XXX + if [ -n "$PM_INDEX" ]; then + pm_cd_pd + if [ -z "$FETCHINDEX" ]; then + FETCHINDEX=`pm_make_b -V FETCHINDEX` + [ -n "$FETCHINDEX" ] || + fail 'The value of FETCHINDEX cannot be empty' + fi + if [ -z "$MASTER_SITE_INDEX" ]; then + MASTER_SITE_INDEX=`pm_make_b -V MASTER_SITE_INDEX` + [ -n "$MASTER_SITE_INDEX" ] || + fail 'The value of MASTER_SITE_INDEX cannot be empty' + fi + if [ -z "$INDEXDIR" ]; then + INDEXDIR=`pm_make_b -V INDEXDIR` + [ -n "$INDEXDIR" ] || + fail 'The value of INDEXDIR cannot be empty' + fi + if [ -z "$INDEXFILE" ]; then + INDEXFILE=`pm_make_b -V INDEXFILE` + [ -n "$INDEXFILE" ] || + fail 'The value of INDEXFILE cannot be empty' + fi + + i="${INDEXDIR}/${INDEXFILE}" + + [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Fetching INDEX file" + $PM_SU_CMD $FETCHINDEX ${i}.bz2 ${MASTER_SITE_INDEX}${INDEXFILE}.bz2 + temp_index=`pm_mktemp index` + bunzip2 < ${i}.bz2 > $temp_index + pm_install_s $temp_index $i + + unset i temp_index + fi + if [ $# -gt 1 -a -z "$REPLACE_ORIGIN" ]; then multiport $@ fi From owner-svn-src-user@FreeBSD.ORG Sun Feb 14 22:10:07 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B25D81065676; Sun, 14 Feb 2010 22:10:07 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A2A6C8FC0C; Sun, 14 Feb 2010 22:10:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1EMA7eI099923; Sun, 14 Feb 2010 22:10:07 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1EMA7Gh099922; Sun, 14 Feb 2010 22:10:07 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201002142210.o1EMA7Gh099922@svn.freebsd.org> From: Doug Barton Date: Sun, 14 Feb 2010 22:10:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203907 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2010 22:10:07 -0000 Author: dougb Date: Sun Feb 14 22:10:06 2010 New Revision: 203907 URL: http://svn.freebsd.org/changeset/base/203907 Log: The path/name of the local INDEX file needs to be persistent so it can be used later. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Feb 14 20:10:41 2010 (r203906) +++ user/dougb/portmaster/portmaster Sun Feb 14 22:10:06 2010 (r203907) @@ -2238,15 +2238,16 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S fail 'The value of INDEXFILE cannot be empty' fi - i="${INDEXDIR}/${INDEXFILE}" + PM_INDEX="${INDEXDIR}/${INDEXFILE}" + export PM_INDEX - [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Fetching INDEX file" - $PM_SU_CMD $FETCHINDEX ${i}.bz2 ${MASTER_SITE_INDEX}${INDEXFILE}.bz2 + [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Updating INDEX file" + $PM_SU_CMD $FETCHINDEX ${PM_INDEX}.bz2 ${MASTER_SITE_INDEX}${INDEXFILE}.bz2 temp_index=`pm_mktemp index` - bunzip2 < ${i}.bz2 > $temp_index + bunzip2 < ${PM_INDEX}.bz2 > $temp_index pm_install_s $temp_index $i - unset i temp_index + unset temp_index fi if [ $# -gt 1 -a -z "$REPLACE_ORIGIN" ]; then From owner-svn-src-user@FreeBSD.ORG Mon Feb 15 07:41:16 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BBFC7106566C; Mon, 15 Feb 2010 07:41:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A9DF28FC14; Mon, 15 Feb 2010 07:41:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1F7fGTq033672; Mon, 15 Feb 2010 07:41:16 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1F7fGtS033664; Mon, 15 Feb 2010 07:41:16 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002150741.o1F7fGtS033664@svn.freebsd.org> From: Warner Losh Date: Mon, 15 Feb 2010 07:41:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203912 - in user/imp/tbemd: release/picobsd/build release/picobsd/tinyware/login sbin/fsck_msdosfs sbin/newfs_msdos sys/arm/include sys/conf sys/dev/aac sys/dev/ahci sys/dev/ath/ath_ha... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2010 07:41:16 -0000 Author: imp Date: Mon Feb 15 07:41:16 2010 New Revision: 203912 URL: http://svn.freebsd.org/changeset/base/203912 Log: Sync to head at about 203911. Added: user/imp/tbemd/sys/sparc64/sparc64/ssm.c - copied unchanged from r203911, head/sys/sparc64/sparc64/ssm.c Modified: user/imp/tbemd/release/picobsd/build/picobsd user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c user/imp/tbemd/sbin/fsck_msdosfs/boot.c user/imp/tbemd/sbin/fsck_msdosfs/check.c user/imp/tbemd/sbin/fsck_msdosfs/dir.c user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h user/imp/tbemd/sbin/fsck_msdosfs/ext.h user/imp/tbemd/sbin/fsck_msdosfs/fat.c user/imp/tbemd/sbin/fsck_msdosfs/fsck_msdosfs.8 user/imp/tbemd/sbin/fsck_msdosfs/main.c user/imp/tbemd/sbin/newfs_msdos/newfs_msdos.8 user/imp/tbemd/sbin/newfs_msdos/newfs_msdos.c user/imp/tbemd/sys/arm/include/armreg.h user/imp/tbemd/sys/conf/files user/imp/tbemd/sys/conf/files.sparc64 user/imp/tbemd/sys/dev/aac/aac.c user/imp/tbemd/sys/dev/aac/aac_cam.c user/imp/tbemd/sys/dev/aac/aacreg.h user/imp/tbemd/sys/dev/aac/aacvar.h user/imp/tbemd/sys/dev/ahci/ahci.c user/imp/tbemd/sys/dev/ahci/ahci.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9160_attach.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280_attach.c user/imp/tbemd/sys/dev/siis/siis.c user/imp/tbemd/sys/dev/usb/input/ukbd.c user/imp/tbemd/sys/dev/usb/quirk/usb_quirk.c user/imp/tbemd/sys/dev/usb/quirk/usb_quirk.h user/imp/tbemd/sys/dev/usb/serial/u3g.c user/imp/tbemd/sys/dev/usb/serial/uftdi.c user/imp/tbemd/sys/dev/usb/serial/umodem.c user/imp/tbemd/sys/dev/usb/usb_msctest.c user/imp/tbemd/sys/dev/usb/usb_msctest.h user/imp/tbemd/sys/dev/usb/usbdevs user/imp/tbemd/sys/fs/msdosfs/msdosfs_fat.c user/imp/tbemd/sys/fs/nfsserver/nfs_nfsdcache.c user/imp/tbemd/sys/fs/nfsserver/nfs_nfsdstate.c user/imp/tbemd/sys/ia64/acpica/madt.c user/imp/tbemd/sys/ia64/ia64/bus_machdep.c user/imp/tbemd/sys/ia64/ia64/efi.c user/imp/tbemd/sys/ia64/ia64/interrupt.c user/imp/tbemd/sys/ia64/ia64/machdep.c user/imp/tbemd/sys/ia64/ia64/mp_machdep.c user/imp/tbemd/sys/ia64/ia64/pmap.c user/imp/tbemd/sys/ia64/ia64/sapic.c user/imp/tbemd/sys/ia64/include/bus.h user/imp/tbemd/sys/ia64/include/intr.h user/imp/tbemd/sys/ia64/include/md_var.h user/imp/tbemd/sys/ia64/include/pci_cfgreg.h user/imp/tbemd/sys/ia64/include/pmap.h user/imp/tbemd/sys/ia64/include/vmparam.h user/imp/tbemd/sys/kern/kern_event.c user/imp/tbemd/sys/netinet/sctp_header.h user/imp/tbemd/sys/sparc64/include/asmacros.h user/imp/tbemd/sys/sys/timeb.h user/imp/tbemd/usr.bin/find/function.c Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/release/picobsd/build/picobsd ============================================================================== --- user/imp/tbemd/release/picobsd/build/picobsd Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/release/picobsd/build/picobsd Mon Feb 15 07:41:16 2010 (r203912) @@ -889,7 +889,7 @@ fill_floppy_image() { if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then mfs_ofs=$((${mfs_start} + 8192)) log "Preload kernel with file ${c_fs} at ${mfs_ofs}" - logverbose "`ls -l ${c_fs}` to fit in ${mfs_size}" + log "`ls -l ${c_fs}` to fit in ${mfs_size}" dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \ oseek=1 conv=notrunc # 2> /dev/null else @@ -944,7 +944,7 @@ fill_floppy_image() { ls -l ${c_img} ${c_label} -f `pwd`/${c_img} - logverbose "after disklabel" + log "after disklabel" ) echo "BUILDDIR ${BUILDDIR}" @@ -958,7 +958,7 @@ fill_floppy_image() { dd if=${b2} iseek=1 ibs=276 2> /dev/null | \ dd of=${BUILDDIR}/${c_img} oseek=1 obs=788 conv=notrunc 2>/dev/null - logverbose "done floppy image" + log "done disk image" # XXX (log "Fixing permissions"; cd ${dst}; chown -R root *) rm -rf ${BUILDDIR}/floppy.tree || true # cleanup # df -ik ${dst} | colrm 70 > .build.reply Modified: user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c ============================================================================== --- user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c Mon Feb 15 07:41:16 2010 (r203912) @@ -76,7 +76,7 @@ static const char rcsid[] = #include #include #include -#include +#include #ifdef USE_PAM #include @@ -119,7 +119,6 @@ static char **environ_pam; #endif static int auth_traditional(void); -extern void login(struct utmp *); static void usage(void); #define TTYGRPNAME "tty" /* name of group to own ttys */ @@ -152,7 +151,7 @@ main(argc, argv) struct group *gr; struct stat st; struct timeval tp; - struct utmp utmp; + struct utmpx utmp; int rootok, retries, backoff; int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval; int changepass; @@ -164,6 +163,8 @@ main(argc, argv) char tname[sizeof(_PATH_TTY) + 10]; const char *shell = NULL; login_cap_t *lc = NULL; + int UT_HOSTSIZE = sizeof(utmp.ut_host); + int UT_NAMESIZE = sizeof(utmp.ut_user); #ifdef USE_PAM pid_t pid; int e; @@ -508,14 +509,18 @@ main(argc, argv) refused("Permission denied", "ACCESS", 1); #endif /* LOGIN_ACCESS */ +#if 1 + ulog_login(tty, username, hostname); +#else /* Nothing else left to fail -- really log in. */ memset((void *)&utmp, 0, sizeof(utmp)); - (void)time(&utmp.ut_time); - (void)strncpy(utmp.ut_name, username, sizeof(utmp.ut_name)); + (void)gettimeofday(&utmp.ut_tv, NULL); + (void)strncpy(utmp.ut_user, username, sizeof(utmp.ut_user)); if (hostname) (void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host)); (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line)); login(&utmp); +#endif dolastlog(quietlog); @@ -903,7 +908,7 @@ usage() * Allow for authentication style and/or kerberos instance */ -#define NBUFSIZ UT_NAMESIZE + 64 +#define NBUFSIZ 128 // XXX was UT_NAMESIZE + 64 void getloginname() @@ -985,6 +990,7 @@ void dolastlog(quiet) int quiet; { +#if 0 /* XXX not implemented after utmp->utmpx change */ struct lastlog ll; int fd; @@ -1016,6 +1022,7 @@ dolastlog(quiet) } else { syslog(LOG_ERR, "cannot open %s: %m", _PATH_LASTLOG); } +#endif } void Modified: user/imp/tbemd/sbin/fsck_msdosfs/boot.c ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/boot.c Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/boot.c Mon Feb 15 07:41:16 2010 (r203912) @@ -10,13 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -40,7 +33,6 @@ static const char rcsid[] = #include #include -#include #include #include @@ -48,16 +40,15 @@ static const char rcsid[] = #include "fsutil.h" int -readboot(dosfs, boot) - int dosfs; - struct bootblock *boot; +readboot(int dosfs, struct bootblock *boot) { u_char block[DOSBOOTBLOCKSIZE]; u_char fsinfo[2 * DOSBOOTBLOCKSIZE]; u_char backup[DOSBOOTBLOCKSIZE]; int ret = FSOK; + int i; - if (read(dosfs, block, sizeof block) < sizeof block) { + if ((size_t)read(dosfs, block, sizeof block) != sizeof block) { perror("could not read boot block"); return FSFATAL; } @@ -71,22 +62,22 @@ readboot(dosfs, boot) boot->ValidFat = -1; /* decode bios parameter block */ - boot->BytesPerSec = block[11] + (block[12] << 8); - boot->SecPerClust = block[13]; - boot->ResSectors = block[14] + (block[15] << 8); - boot->FATs = block[16]; - boot->RootDirEnts = block[17] + (block[18] << 8); - boot->Sectors = block[19] + (block[20] << 8); - boot->Media = block[21]; - boot->FATsmall = block[22] + (block[23] << 8); + boot->bpbBytesPerSec = block[11] + (block[12] << 8); + boot->bpbSecPerClust = block[13]; + boot->bpbResSectors = block[14] + (block[15] << 8); + boot->bpbFATs = block[16]; + boot->bpbRootDirEnts = block[17] + (block[18] << 8); + boot->bpbSectors = block[19] + (block[20] << 8); + boot->bpbMedia = block[21]; + boot->bpbFATsmall = block[22] + (block[23] << 8); boot->SecPerTrack = block[24] + (block[25] << 8); - boot->Heads = block[26] + (block[27] << 8); - boot->HiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + (block[31] << 24); - boot->HugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + (block[35] << 24); + boot->bpbHeads = block[26] + (block[27] << 8); + boot->bpbHiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + (block[31] << 24); + boot->bpbHugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + (block[35] << 24); - boot->FATsecs = boot->FATsmall; + boot->FATsecs = boot->bpbFATsmall; - if (!boot->RootDirEnts) + if (!boot->bpbRootDirEnts) boot->flags |= FAT32; if (boot->flags & FAT32) { boot->FATsecs = block[36] + (block[37] << 8) @@ -101,13 +92,13 @@ readboot(dosfs, boot) block[43], block[42]); return FSFATAL; } - boot->RootCl = block[44] + (block[45] << 8) + boot->bpbRootClust = block[44] + (block[45] << 8) + (block[46] << 16) + (block[47] << 24); - boot->FSInfo = block[48] + (block[49] << 8); - boot->Backup = block[50] + (block[51] << 8); + boot->bpbFSInfo = block[48] + (block[49] << 8); + boot->bpbBackup = block[50] + (block[51] << 8); - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec + if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) + != boot->bpbFSInfo * boot->bpbBytesPerSec || read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { perror("could not read fsinfo block"); @@ -133,18 +124,18 @@ readboot(dosfs, boot) fsinfo[0x3fc] = fsinfo[0x3fd] = 0; fsinfo[0x3fe] = 0x55; fsinfo[0x3ff] = 0xaa; - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec + if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) + != boot->bpbFSInfo * boot->bpbBytesPerSec || write(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("Unable to write FSInfo"); + perror("Unable to write bpbFSInfo"); return FSFATAL; } ret = FSBOOTMOD; } else - boot->FSInfo = 0; + boot->bpbFSInfo = 0; } - if (boot->FSInfo) { + if (boot->bpbFSInfo) { boot->FSFree = fsinfo[0x1e8] + (fsinfo[0x1e9] << 8) + (fsinfo[0x1ea] << 16) + (fsinfo[0x1eb] << 24); @@ -153,44 +144,54 @@ readboot(dosfs, boot) + (fsinfo[0x1ef] << 24); } - if (lseek(dosfs, boot->Backup * boot->BytesPerSec, SEEK_SET) - != boot->Backup * boot->BytesPerSec + if (lseek(dosfs, boot->bpbBackup * boot->bpbBytesPerSec, SEEK_SET) + != boot->bpbBackup * boot->bpbBytesPerSec || read(dosfs, backup, sizeof backup) != sizeof backup) { perror("could not read backup bootblock"); return FSFATAL; } backup[65] = block[65]; /* XXX */ if (memcmp(block + 11, backup + 11, 79)) { - /* Correct? XXX */ - pfatal("backup doesn't compare to primary bootblock"); - if (alwaysno) - pfatal("\n"); - else - return FSFATAL; + /* + * XXX We require a reference that explains + * that these bytes need to match, or should + * drop the check. gdt@NetBSD has observed + * filesystems that work fine under Windows XP + * and NetBSD that do not match, so the + * requirement is suspect. For now, just + * print out useful information and continue. + */ + pfatal("backup (block %d) mismatch with primary bootblock:\n", + boot->bpbBackup); + for (i = 11; i < 11 + 90; i++) { + if (block[i] != backup[i]) + pfatal("\ti=%d\tprimary 0x%02x\tbackup 0x%02x\n", + i, block[i], backup[i]); + } } - /* Check backup FSInfo? XXX */ + /* Check backup bpbFSInfo? XXX */ } - boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1) - / boot->BytesPerSec - + boot->ResSectors - + boot->FATs * boot->FATsecs - - CLUST_FIRST * boot->SecPerClust; + boot->ClusterOffset = (boot->bpbRootDirEnts * 32 + boot->bpbBytesPerSec - 1) + / boot->bpbBytesPerSec + + boot->bpbResSectors + + boot->bpbFATs * boot->FATsecs + - CLUST_FIRST * boot->bpbSecPerClust; - if (boot->BytesPerSec % DOSBOOTBLOCKSIZE != 0) { - pfatal("Invalid sector size: %u", boot->BytesPerSec); + if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE != 0) { + pfatal("Invalid sector size: %u", boot->bpbBytesPerSec); return FSFATAL; } - if (boot->SecPerClust == 0) { - pfatal("Invalid cluster size: %u", boot->SecPerClust); + if (boot->bpbSecPerClust == 0) { + pfatal("Invalid cluster size: %u", boot->bpbSecPerClust); return FSFATAL; } - if (boot->Sectors) { - boot->HugeSectors = 0; - boot->NumSectors = boot->Sectors; + if (boot->bpbSectors) { + boot->bpbHugeSectors = 0; + boot->NumSectors = boot->bpbSectors; } else - boot->NumSectors = boot->HugeSectors; - boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->SecPerClust; + boot->NumSectors = boot->bpbHugeSectors; + boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->bpbSecPerClust; if (boot->flags&FAT32) boot->ClustMask = CLUST32_MASK; @@ -206,13 +207,13 @@ readboot(dosfs, boot) switch (boot->ClustMask) { case CLUST32_MASK: - boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec) / 4; + boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec) / 4; break; case CLUST16_MASK: - boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec) / 2; + boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec) / 2; break; default: - boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec * 2) / 3; + boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec * 2) / 3; break; } @@ -221,7 +222,7 @@ readboot(dosfs, boot) boot->NumClusters, boot->FATsecs); return FSFATAL; } - boot->ClusterSize = boot->BytesPerSec * boot->SecPerClust; + boot->ClusterSize = boot->bpbBytesPerSec * boot->bpbSecPerClust; boot->NumFiles = 1; boot->NumFree = 0; @@ -230,14 +231,12 @@ readboot(dosfs, boot) } int -writefsinfo(dosfs, boot) - int dosfs; - struct bootblock *boot; +writefsinfo(int dosfs, struct bootblock *boot) { u_char fsinfo[2 * DOSBOOTBLOCKSIZE]; - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec + if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) + != boot->bpbFSInfo * boot->bpbBytesPerSec || read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { perror("could not read fsinfo block"); return FSFATAL; @@ -250,11 +249,11 @@ writefsinfo(dosfs, boot) fsinfo[0x1ed] = (u_char)(boot->FSNext >> 8); fsinfo[0x1ee] = (u_char)(boot->FSNext >> 16); fsinfo[0x1ef] = (u_char)(boot->FSNext >> 24); - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec + if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) + != boot->bpbFSInfo * boot->bpbBytesPerSec || write(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("Unable to write FSInfo"); + perror("Unable to write bpbFSInfo"); return FSFATAL; } /* Modified: user/imp/tbemd/sbin/fsck_msdosfs/check.c ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/check.c Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/check.c Mon Feb 15 07:41:16 2010 (r203912) @@ -10,13 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -40,7 +33,6 @@ static const char rcsid[] = #include #include -#include #include #include #include @@ -54,7 +46,8 @@ checkfilesys(const char *fname) int dosfs; struct bootblock boot; struct fatEntry *fat = NULL; - int i, finish_dosdirsection=0; + int finish_dosdirsection=0; + u_int i; int mod = 0; int ret = 8; @@ -105,7 +98,7 @@ checkfilesys(const char *fname) } if (boot.ValidFat < 0) - for (i = 1; i < (int)boot.FATs; i++) { + for (i = 1; i < (int)boot.bpbFATs; i++) { struct fatEntry *currentFat; mod |= readfat(dosfs, &boot, i, ¤tFat); Modified: user/imp/tbemd/sbin/fsck_msdosfs/dir.c ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/dir.c Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/dir.c Mon Feb 15 07:41:16 2010 (r203912) @@ -12,13 +12,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -44,7 +37,6 @@ static const char rcsid[] = #include #include #include -#include #include #include @@ -227,26 +219,38 @@ resetDosDirSection(struct bootblock *boo cl_t cl; int ret = FSOK; - b1 = boot->RootDirEnts * 32; - b2 = boot->SecPerClust * boot->BytesPerSec; + b1 = boot->bpbRootDirEnts * 32; + b2 = boot->bpbSecPerClust * boot->bpbBytesPerSec; - if (!(buffer = malloc(b1 > b2 ? b1 : b2)) - || !(delbuf = malloc(b2)) - || !(rootDir = newDosDirEntry())) { - perror("No space for directory"); + if ((buffer = malloc( b1 > b2 ? b1 : b2)) == NULL) { + perror("No space for directory buffer"); return FSFATAL; } + + if ((delbuf = malloc(b2)) == NULL) { + free(buffer); + perror("No space for directory delbuf"); + return FSFATAL; + } + + if ((rootDir = newDosDirEntry()) == NULL) { + free(buffer); + free(delbuf); + perror("No space for directory entry"); + return FSFATAL; + } + memset(rootDir, 0, sizeof *rootDir); if (boot->flags & FAT32) { - if (boot->RootCl < CLUST_FIRST || boot->RootCl >= boot->NumClusters) { + if (boot->bpbRootClust < CLUST_FIRST || boot->bpbRootClust >= boot->NumClusters) { pfatal("Root directory starts with cluster out of range(%u)", - boot->RootCl); + boot->bpbRootClust); return FSFATAL; } - cl = fat[boot->RootCl].next; + cl = fat[boot->bpbRootClust].next; if (cl < CLUST_FIRST || (cl >= CLUST_RSRVD && cl< CLUST_EOFS) - || fat[boot->RootCl].head != boot->RootCl) { + || fat[boot->bpbRootClust].head != boot->bpbRootClust) { if (cl == CLUST_FREE) pwarn("Root directory starts with free cluster\n"); else if (cl >= CLUST_RSRVD) @@ -257,14 +261,14 @@ resetDosDirSection(struct bootblock *boo return FSFATAL; } if (ask(1, "Fix")) { - fat[boot->RootCl].next = CLUST_FREE; + fat[boot->bpbRootClust].next = CLUST_FREE; ret = FSFATMOD; } else ret = FSFATAL; } - fat[boot->RootCl].flags |= FAT_USED; - rootDir->head = boot->RootCl; + fat[boot->bpbRootClust].flags |= FAT_USED; + rootDir->head = boot->bpbRootClust; } return ret; @@ -309,7 +313,7 @@ delete(int f, struct bootblock *boot, st { u_char *s, *e; off_t off; - int clsz = boot->SecPerClust * boot->BytesPerSec; + int clsz = boot->bpbSecPerClust * boot->bpbBytesPerSec; s = delbuf + startoff; e = delbuf + clsz; @@ -319,8 +323,8 @@ delete(int f, struct bootblock *boot, st break; e = delbuf + endoff; } - off = startcl * boot->SecPerClust + boot->ClusterOffset; - off *= boot->BytesPerSec; + off = startcl * boot->bpbSecPerClust + boot->ClusterOffset; + off *= boot->bpbBytesPerSec; if (lseek(f, off, SEEK_SET) != off || read(f, delbuf, clsz) != clsz) { perror("Unable to read directory"); @@ -367,7 +371,8 @@ removede(int f, struct bootblock *boot, return FSFATAL; start = buffer; } - if (endcl == curcl) + /* startcl is < CLUST_FIRST for !fat32 root */ + if ((endcl == curcl) || (startcl < CLUST_FIRST)) for (; start < end; start += 32) *start = SLOT_DELETED; return FSDIRMOD; @@ -385,7 +390,7 @@ checksize(struct bootblock *boot, struct /* * Check size on ordinary files */ - int32_t physicalSize; + u_int32_t physicalSize; if (dir->head == CLUST_FREE) physicalSize = 0; @@ -456,14 +461,14 @@ readDosDirSection(int f, struct bootbloc vallfn = invlfn = empty = NULL; do { if (!(boot->flags & FAT32) && !dir->parent) { - last = boot->RootDirEnts * 32; - off = boot->ResSectors + boot->FATs * boot->FATsecs; + last = boot->bpbRootDirEnts * 32; + off = boot->bpbResSectors + boot->bpbFATs * boot->FATsecs; } else { - last = boot->SecPerClust * boot->BytesPerSec; - off = cl * boot->SecPerClust + boot->ClusterOffset; + last = boot->bpbSecPerClust * boot->bpbBytesPerSec; + off = cl * boot->bpbSecPerClust + boot->ClusterOffset; } - off *= boot->BytesPerSec; + off *= boot->bpbBytesPerSec; if (lseek(f, off, SEEK_SET) != off || read(f, buffer, last) != last) { perror("Unable to read directory"); @@ -644,7 +649,8 @@ readDosDirSection(int f, struct bootbloc dirent.head |= (p[20] << 16) | (p[21] << 24); dirent.size = p[28] | (p[29] << 8) | (p[30] << 16) | (p[31] << 24); if (vallfn) { - strcpy(dirent.lname, longName); + strlcpy(dirent.lname, longName, + sizeof(dirent.lname)); longName[0] = '\0'; shortSum = -1; } @@ -832,6 +838,10 @@ readDosDirSection(int f, struct bootbloc } boot->NumFiles++; } + + if (!(boot->flags & FAT32) && !dir->parent) + break; + if (mod & THISMOD) { last *= 32; if (lseek(f, off, SEEK_SET) != off @@ -847,6 +857,19 @@ readDosDirSection(int f, struct bootbloc invlfn ? invlfn : vallfn, p, invlfn ? invcl : valcl, -1, 0, fullpath(dir), 1); + + /* The root directory of non fat32 filesystems is in a special + * area and may have been modified above without being written out. + */ + if ((mod & FSDIRMOD) && !(boot->flags & FAT32) && !dir->parent) { + last *= 32; + if (lseek(f, off, SEEK_SET) != off + || write(f, buffer, last) != last) { + perror("Unable to write directory"); + return FSFATAL; + } + mod &= ~THISMOD; + } return mod & ~THISMOD; } @@ -934,9 +957,9 @@ reconnect(int dosfs, struct bootblock *b return FSERROR; } lfoff = lfcl * boot->ClusterSize - + boot->ClusterOffset * boot->BytesPerSec; + + boot->ClusterOffset * boot->bpbBytesPerSec; if (lseek(dosfs, lfoff, SEEK_SET) != lfoff - || read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { + || (size_t)read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { perror("could not read LOST.DIR"); return FSFATAL; } @@ -966,7 +989,7 @@ reconnect(int dosfs, struct bootblock *b p[31] = (u_char)(d.size >> 24); fat[head].flags |= FAT_USED; if (lseek(dosfs, lfoff, SEEK_SET) != lfoff - || write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { + || (size_t)write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { perror("could not write LOST.DIR"); return FSFATAL; } Modified: user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h Mon Feb 15 07:41:16 2010 (r203912) @@ -12,13 +12,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -46,21 +39,21 @@ typedef u_int32_t cl_t; /* type holding * FAT boot block. */ struct bootblock { - u_int BytesPerSec; /* bytes per sector */ - u_int SecPerClust; /* sectors per cluster */ - u_int ResSectors; /* number of reserved sectors */ - u_int FATs; /* number of FATs */ - u_int RootDirEnts; /* number of root directory entries */ - u_int Media; /* media descriptor */ - u_int FATsmall; /* number of sectors per FAT */ + u_int bpbBytesPerSec; /* bytes per sector */ + u_int bpbSecPerClust; /* sectors per cluster */ + u_int bpbResSectors; /* number of reserved sectors */ + u_int bpbFATs; /* number of bpbFATs */ + u_int bpbRootDirEnts; /* number of root directory entries */ + u_int32_t bpbSectors; /* total number of sectors */ + u_int bpbMedia; /* media descriptor */ + u_int bpbFATsmall; /* number of sectors per FAT */ u_int SecPerTrack; /* sectors per track */ - u_int Heads; /* number of heads */ - u_int32_t Sectors; /* total number of sectors */ - u_int32_t HiddenSecs; /* # of hidden sectors */ - u_int32_t HugeSectors; /* # of sectors if bpbSectors == 0 */ - u_int FSInfo; /* FSInfo sector */ - u_int Backup; /* Backup of Bootblocks */ - cl_t RootCl; /* Start of Root Directory */ + u_int bpbHeads; /* number of heads */ + u_int32_t bpbHiddenSecs; /* # of hidden sectors */ + u_int32_t bpbHugeSectors; /* # of sectors if bpbbpbSectors == 0 */ + cl_t bpbRootClust; /* Start of Root Directory */ + u_int bpbFSInfo; /* FSInfo sector */ + u_int bpbBackup; /* Backup of Bootblocks */ cl_t FSFree; /* Number of free clusters acc. FSInfo */ cl_t FSNext; /* Next free cluster acc. FSInfo */ Modified: user/imp/tbemd/sbin/fsck_msdosfs/ext.h ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/ext.h Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/ext.h Mon Feb 15 07:41:16 2010 (r203912) @@ -10,13 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -77,12 +70,12 @@ int checkfilesys(const char *); #define FSDIRMOD 2 /* Some directory was modified */ #define FSFATMOD 4 /* The FAT was modified */ #define FSERROR 8 /* Some unrecovered error remains */ -#define FSFATAL 16 /* Some unrecoverable error occured */ +#define FSFATAL 16 /* Some unrecoverable error occurred */ #define FSDIRTY 32 /* File system is dirty */ #define FSFIXFAT 64 /* Fix file system FAT */ /* - * read a boot block in a machine independend fashion and translate + * read a boot block in a machine independent fashion and translate * it into our struct bootblock. */ int readboot(int, struct bootblock *); @@ -96,13 +89,13 @@ int writefsinfo(int, struct bootblock *) * Read one of the FAT copies and return a pointer to the new * allocated array holding our description of it. */ -int readfat(int, struct bootblock *, int, struct fatEntry **); +int readfat(int, struct bootblock *, u_int, struct fatEntry **); /* * Check two FAT copies for consistency and merge changes into the - * first if neccessary. + * first if necessary. */ -int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int); +int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, u_int); /* * Check a FAT Modified: user/imp/tbemd/sbin/fsck_msdosfs/fat.c ============================================================================== --- user/imp/tbemd/sbin/fsck_msdosfs/fat.c Mon Feb 15 05:44:43 2010 (r203911) +++ user/imp/tbemd/sbin/fsck_msdosfs/fat.c Mon Feb 15 07:41:16 2010 (r203912) @@ -10,13 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Martin Husemann - * and Wolfgang Solfrank. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -47,10 +40,10 @@ static const char rcsid[] = #include "ext.h" #include "fsutil.h" -static int checkclnum(struct bootblock *, int, cl_t, cl_t *); -static int clustdiffer(cl_t, cl_t *, cl_t *, int); +static int checkclnum(struct bootblock *, u_int, cl_t, cl_t *); +static int clustdiffer(cl_t, cl_t *, cl_t *, u_int); static int tryclear(struct bootblock *, struct fatEntry *, cl_t, cl_t *); -static int _readfat(int, struct bootblock *, int, u_char **); +static int _readfat(int, struct bootblock *, u_int, u_char **); /*- * The first 2 FAT entries contain pseudo-cluster numbers with the following @@ -80,10 +73,10 @@ checkdirty(int fs, struct bootblock *boo if (boot->ClustMask != CLUST16_MASK && boot->ClustMask != CLUST32_MASK) return 0; - off = boot->ResSectors; - off *= boot->BytesPerSec; + off = boot->bpbResSectors; + off *= boot->bpbBytesPerSec; - buffer = malloc(boot->BytesPerSec); + buffer = malloc(boot->bpbBytesPerSec); if (buffer == NULL) { perror("No space for FAT"); return 1; @@ -94,7 +87,7 @@ checkdirty(int fs, struct bootblock *boo goto err; } - if (read(fs, buffer, boot->BytesPerSec) != boot->BytesPerSec) { + if (read(fs, buffer, boot->bpbBytesPerSec) != boot->bpbBytesPerSec) { perror("Unable to read FAT"); goto err; } @@ -103,7 +96,7 @@ checkdirty(int fs, struct bootblock *boo * If we don't understand the FAT, then the file system must be * assumed to be unclean. */ - if (buffer[0] != boot->Media || buffer[1] != 0xff) + if (buffer[0] != boot->bpbMedia || buffer[1] != 0xff) goto err; if (boot->ClustMask == CLUST16_MASK) { if ((buffer[2] & 0xf8) != 0xf8 || (buffer[3] & 0x3f) != 0x3f) @@ -135,7 +128,7 @@ err: * Check a cluster number for valid value */ static int -checkclnum(struct bootblock *boot, int fat, cl_t cl, cl_t *next) +checkclnum(struct bootblock *boot, u_int fat, cl_t cl, cl_t *next) { if (*next >= (CLUST_RSRVD&boot->ClustMask)) *next |= ~boot->ClustMask; @@ -166,26 +159,26 @@ checkclnum(struct bootblock *boot, int f * Read a FAT from disk. Returns 1 if successful, 0 otherwise. */ static int -_readfat(int fs, struct bootblock *boot, int no, u_char **buffer) +_readfat(int fs, struct bootblock *boot, u_int no, u_char **buffer) { off_t off; - *buffer = malloc(boot->FATsecs * boot->BytesPerSec); + *buffer = malloc(boot->FATsecs * boot->bpbBytesPerSec); if (*buffer == NULL) { perror("No space for FAT"); return 0; } - off = boot->ResSectors + no * boot->FATsecs; - off *= boot->BytesPerSec; + off = boot->bpbResSectors + no * boot->FATsecs; + off *= boot->bpbBytesPerSec; if (lseek(fs, off, SEEK_SET) != off) { perror("Unable to read FAT"); goto err; } - if (read(fs, *buffer, boot->FATsecs * boot->BytesPerSec) - != boot->FATsecs * boot->BytesPerSec) { + if ((size_t)read(fs, *buffer, boot->FATsecs * boot->bpbBytesPerSec) + != boot->FATsecs * boot->bpbBytesPerSec) { perror("Unable to read FAT"); goto err; } @@ -201,26 +194,28 @@ _readfat(int fs, struct bootblock *boot, * Read a FAT and decode it into internal format */ int -readfat(int fs, struct bootblock *boot, int no, struct fatEntry **fp) +readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp) { struct fatEntry *fat; u_char *buffer, *p; cl_t cl; int ret = FSOK; + size_t len; boot->NumFree = boot->NumBad = 0; if (!_readfat(fs, boot, no, &buffer)) return FSFATAL; - fat = calloc(boot->NumClusters, sizeof(struct fatEntry)); + fat = malloc(len = boot->NumClusters * sizeof(struct fatEntry)); if (fat == NULL) { perror("No space for FAT"); free(buffer); return FSFATAL; } + (void)memset(fat, 0, len); - if (buffer[0] != boot->Media + if (buffer[0] != boot->bpbMedia || buffer[1] != 0xff || buffer[2] != 0xff || (boot->ClustMask == CLUST16_MASK && buffer[3] != 0xff) || (boot->ClustMask == CLUST32_MASK @@ -234,7 +229,7 @@ readfat(int fs, struct bootblock *boot, * file system is dirty if it doesn't reboot cleanly. * Check this special condition before errorring out. */ - if (buffer[0] == boot->Media && buffer[1] == 0xff + if (buffer[0] == boot->bpbMedia && buffer[1] == 0xff && buffer[2] == 0xff && ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f) || (boot->ClustMask == CLUST32_MASK @@ -311,7 +306,11 @@ readfat(int fs, struct bootblock *boot, } free(buffer); - *fp = fat; + if (ret & FSFATAL) { + free(fat); + *fp = NULL; + } else + *fp = fat; return ret; } @@ -331,7 +330,7 @@ rsrvdcltype(cl_t cl) } static int -clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, int fatnum) +clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, u_int fatnum) { if (*cp1 == CLUST_FREE || *cp1 >= CLUST_RSRVD) { if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) { @@ -346,13 +345,13 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp } return FSFATAL; } - pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %d\n", + pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %u\n", cl, rsrvdcltype(*cp1), rsrvdcltype(*cp2), fatnum); if (ask(0, "Use FAT 0's entry")) { *cp2 = *cp1; return FSFATMOD; } - if (ask(0, "Use FAT %d's entry", fatnum)) { + if (ask(0, "Use FAT %u's entry", fatnum)) { *cp1 = *cp2; return FSFATMOD; } @@ -360,7 +359,7 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp } pwarn("Cluster %u is marked %s in FAT 0, but continues with cluster %u in FAT %d\n", cl, rsrvdcltype(*cp1), *cp2, fatnum); - if (ask(0, "Use continuation from FAT %d", fatnum)) { + if (ask(0, "Use continuation from FAT %u", fatnum)) { *cp1 = *cp2; return FSFATMOD; } @@ -371,7 +370,7 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp return FSFATAL; } if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) { - pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %d\n", + pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %u\n", cl, *cp1, rsrvdcltype(*cp2), fatnum); if (ask(0, "Use continuation from FAT 0")) { *cp2 = *cp1; @@ -383,13 +382,13 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp } return FSERROR; } - pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %d\n", + pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %u\n", cl, *cp1, *cp2, fatnum); if (ask(0, "Use continuation from FAT 0")) { *cp2 = *cp1; return FSFATMOD; } - if (ask(0, "Use continuation from FAT %d", fatnum)) { + if (ask(0, "Use continuation from FAT %u", fatnum)) { *cp1 = *cp2; return FSFATMOD; } @@ -401,8 +400,8 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp * into the first one. */ int -comparefat(struct bootblock *boot, struct fatEntry *first, - struct fatEntry *second, int fatnum) +comparefat(struct bootblock *boot, struct fatEntry *first, + struct fatEntry *second, u_int fatnum) { cl_t cl; int ret = FSOK; @@ -542,12 +541,12 @@ writefat(int fs, struct bootblock *boot, { u_char *buffer, *p; cl_t cl; - int i; - u_int32_t fatsz; + u_int i; + size_t fatsz; off_t off; int ret = FSOK; - buffer = malloc(fatsz = boot->FATsecs * boot->BytesPerSec); + buffer = malloc(fatsz = boot->FATsecs * boot->bpbBytesPerSec); if (buffer == NULL) { perror("No space for FAT"); return FSFATAL; @@ -556,7 +555,7 @@ writefat(int fs, struct bootblock *boot, boot->NumFree = 0; p = buffer; if (correct_fat) { - *p++ = (u_char)boot->Media; + *p++ = (u_char)boot->bpbMedia; *p++ = 0xff; *p++ = 0xff; switch (boot->ClustMask) { @@ -629,11 +628,11 @@ writefat(int fs, struct bootblock *boot, break; } } - for (i = 0; i < boot->FATs; i++) { - off = boot->ResSectors + i * boot->FATsecs; - off *= boot->BytesPerSec; + for (i = 0; i < boot->bpbFATs; i++) { + off = boot->bpbResSectors + i * boot->FATsecs; + off *= boot->bpbBytesPerSec; if (lseek(fs, off, SEEK_SET) != off - || write(fs, buffer, fatsz) != fatsz) { + || (size_t)write(fs, buffer, fatsz) != fatsz) { perror("Unable to write FAT"); ret = FSFATAL; /* Return immediately? XXX */ } @@ -673,7 +672,7 @@ checklost(int dosfs, struct bootblock *b } finishlf(); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Feb 15 21:40:25 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC874106568B; Mon, 15 Feb 2010 21:40:25 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B9398FC1F; Mon, 15 Feb 2010 21:40:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1FLePxZ021851; Mon, 15 Feb 2010 21:40:25 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1FLePIb021849; Mon, 15 Feb 2010 21:40:25 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002152140.o1FLePIb021849@svn.freebsd.org> From: Kip Macy Date: Mon, 15 Feb 2010 21:40:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203937 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2010 21:40:25 -0000 Author: kmacy Date: Mon Feb 15 21:40:25 2010 New Revision: 203937 URL: http://svn.freebsd.org/changeset/base/203937 Log: - remove opt_inet{6}.h dependency Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.h Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.h ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.h Mon Feb 15 20:46:01 2010 (r203936) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.h Mon Feb 15 21:40:25 2010 (r203937) @@ -73,13 +73,9 @@ int kern_flowtable_insert(struct flowtab void flow_invalidate(struct flentry *fl); void flowtable_route_flush(struct flowtable *ft, struct rtentry *rt); -#ifdef INET void flow_to_route(struct flentry *fl, struct route *ro); -#endif -#ifdef INET6 void flow_to_route_in6(struct flentry *fl, struct route_in6 *ro); -#endif #endif /* _KERNEL */ From owner-svn-src-user@FreeBSD.ORG Tue Feb 16 11:33:18 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC97810656A3; Tue, 16 Feb 2010 11:33:18 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCF398FC16; Tue, 16 Feb 2010 11:33:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1GBXIZi008496; Tue, 16 Feb 2010 11:33:18 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1GBXI7M008493; Tue, 16 Feb 2010 11:33:18 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201002161133.o1GBXI7M008493@svn.freebsd.org> From: Ed Schouten Date: Tue, 16 Feb 2010 11:33:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203956 - user/ed/newcons/lib/libc/gen X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 11:33:19 -0000 Author: ed Date: Tue Feb 16 11:33:18 2010 New Revision: 203956 URL: http://svn.freebsd.org/changeset/base/203956 Log: Add missing volatile keywords. According to GCC, these variables may be clobbered by vfork(). Modified: user/ed/newcons/lib/libc/gen/popen.c user/ed/newcons/lib/libc/gen/posix_spawn.c Modified: user/ed/newcons/lib/libc/gen/popen.c ============================================================================== --- user/ed/newcons/lib/libc/gen/popen.c Tue Feb 16 09:31:36 2010 (r203955) +++ user/ed/newcons/lib/libc/gen/popen.c Tue Feb 16 11:33:18 2010 (r203956) @@ -66,12 +66,12 @@ static pthread_mutex_t pidlist_mutex = P #define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&pidlist_mutex) FILE * -popen(command, type) - const char *command, *type; +popen(const char *command, const char * volatile type) { struct pid *cur; FILE *iop; - int pdes[2], pid, twoway; + int pdes[2], pid; + volatile int twoway; char *argv[4]; struct pid *p; Modified: user/ed/newcons/lib/libc/gen/posix_spawn.c ============================================================================== --- user/ed/newcons/lib/libc/gen/posix_spawn.c Tue Feb 16 09:31:36 2010 (r203955) +++ user/ed/newcons/lib/libc/gen/posix_spawn.c Tue Feb 16 11:33:18 2010 (r203956) @@ -192,7 +192,7 @@ static int do_posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa, const posix_spawnattr_t *sa, - char * const argv[], char * const envp[], int use_env_path) + char * const argv[], char * const * volatile envp, int use_env_path) { pid_t p; volatile int error = 0; From owner-svn-src-user@FreeBSD.ORG Tue Feb 16 11:35:50 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C249E106566B; Tue, 16 Feb 2010 11:35:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2E048FC17; Tue, 16 Feb 2010 11:35:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1GBZosY009090; Tue, 16 Feb 2010 11:35:50 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1GBZoZj009088; Tue, 16 Feb 2010 11:35:50 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201002161135.o1GBZoZj009088@svn.freebsd.org> From: Ed Schouten Date: Tue, 16 Feb 2010 11:35:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203957 - user/ed/newcons/lib/libc/gen X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 11:35:50 -0000 Author: ed Date: Tue Feb 16 11:35:50 2010 New Revision: 203957 URL: http://svn.freebsd.org/changeset/base/203957 Log: Add missing void keywords for functions with no arguments. Modified: user/ed/newcons/lib/libc/gen/sem_new.c Modified: user/ed/newcons/lib/libc/gen/sem_new.c ============================================================================== --- user/ed/newcons/lib/libc/gen/sem_new.c Tue Feb 16 11:33:18 2010 (r203956) +++ user/ed/newcons/lib/libc/gen/sem_new.c Tue Feb 16 11:35:50 2010 (r203957) @@ -74,20 +74,20 @@ static pthread_mutex_t sem_llock; static LIST_HEAD(,sem_nameinfo) sem_list = LIST_HEAD_INITIALIZER(sem_list); static void -sem_prefork() +sem_prefork(void) { _pthread_mutex_lock(&sem_llock); } static void -sem_postfork() +sem_postfork(void) { _pthread_mutex_unlock(&sem_llock); } static void -sem_child_postfork() +sem_child_postfork(void) { _pthread_mutex_unlock(&sem_llock); } From owner-svn-src-user@FreeBSD.ORG Tue Feb 16 23:59:49 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8BAA106566B; Tue, 16 Feb 2010 23:59:49 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B5E428FC0C; Tue, 16 Feb 2010 23:59:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1GNxnT0073911; Tue, 16 Feb 2010 23:59:49 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1GNxnjK073910; Tue, 16 Feb 2010 23:59:49 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002162359.o1GNxnjK073910@svn.freebsd.org> From: Warner Losh Date: Tue, 16 Feb 2010 23:59:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203979 - in user/imp/tbemd: . bin/rmail etc/ppp games games/bcd games/caesar games/fortune/fortune games/fortune/strfile games/fortune/unstr games/grdc games/morse games/number games/p... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 23:59:50 -0000 Author: imp Date: Tue Feb 16 23:59:48 2010 New Revision: 203979 URL: http://svn.freebsd.org/changeset/base/203979 Log: Merge from current. Added: user/imp/tbemd/share/man/man4/bwn.4 - copied unchanged from r203978, head/share/man/man4/bwn.4 user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9285.c - copied unchanged from r203978, head/sys/dev/ath/ath_hal/ar5416/ar9285.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9285.h - copied unchanged from r203978, head/sys/dev/ath/ath_hal/ar5416/ar9285.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c - copied unchanged from r203978, head/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9285_reset.c - copied unchanged from r203978, head/sys/dev/ath/ath_hal/ar5416/ar9285_reset.c user/imp/tbemd/sys/dev/bwn/ - copied from r203978, head/sys/dev/bwn/ user/imp/tbemd/sys/modules/bwn/ - copied from r203978, head/sys/modules/bwn/ user/imp/tbemd/sys/modules/nfs_common/ - copied from r203978, head/sys/modules/nfs_common/ Modified: user/imp/tbemd/Makefile.inc1 user/imp/tbemd/bin/rmail/Makefile user/imp/tbemd/etc/ppp/ppp.conf user/imp/tbemd/games/Makefile.inc user/imp/tbemd/games/bcd/Makefile user/imp/tbemd/games/bcd/bcd.c user/imp/tbemd/games/caesar/Makefile user/imp/tbemd/games/caesar/caesar.c user/imp/tbemd/games/fortune/fortune/Makefile user/imp/tbemd/games/fortune/fortune/fortune.6 user/imp/tbemd/games/fortune/fortune/fortune.c user/imp/tbemd/games/fortune/fortune/pathnames.h user/imp/tbemd/games/fortune/strfile/Makefile user/imp/tbemd/games/fortune/strfile/strfile.8 user/imp/tbemd/games/fortune/strfile/strfile.c user/imp/tbemd/games/fortune/strfile/strfile.h user/imp/tbemd/games/fortune/unstr/Makefile user/imp/tbemd/games/fortune/unstr/unstr.c user/imp/tbemd/games/grdc/Makefile user/imp/tbemd/games/grdc/grdc.c user/imp/tbemd/games/morse/morse.c user/imp/tbemd/games/number/Makefile user/imp/tbemd/games/number/number.c user/imp/tbemd/games/pom/Makefile user/imp/tbemd/games/pom/pom.c user/imp/tbemd/games/ppt/Makefile user/imp/tbemd/games/ppt/ppt.c user/imp/tbemd/games/primes/pattern.c user/imp/tbemd/games/primes/pr_tbl.c user/imp/tbemd/games/primes/primes.c user/imp/tbemd/games/primes/primes.h user/imp/tbemd/games/random/Makefile user/imp/tbemd/games/random/random.c user/imp/tbemd/gnu/usr.bin/gdb/arch/ia64/Makefile user/imp/tbemd/gnu/usr.bin/gdb/arch/ia64/init.c user/imp/tbemd/include/_ctype.h user/imp/tbemd/include/a.out.h user/imp/tbemd/include/ar.h user/imp/tbemd/include/arpa/ftp.h user/imp/tbemd/include/arpa/inet.h user/imp/tbemd/include/arpa/nameser.h user/imp/tbemd/include/arpa/nameser_compat.h user/imp/tbemd/include/arpa/telnet.h user/imp/tbemd/include/arpa/tftp.h user/imp/tbemd/include/assert.h user/imp/tbemd/include/ctype.h user/imp/tbemd/include/db.h user/imp/tbemd/include/dirent.h user/imp/tbemd/include/dlfcn.h user/imp/tbemd/include/err.h user/imp/tbemd/include/fnmatch.h user/imp/tbemd/include/fstab.h user/imp/tbemd/include/fts.h user/imp/tbemd/include/getopt.h user/imp/tbemd/include/glob.h user/imp/tbemd/include/grp.h user/imp/tbemd/include/hesiod.h user/imp/tbemd/include/limits.h user/imp/tbemd/include/locale.h user/imp/tbemd/include/memory.h user/imp/tbemd/include/mpool.h user/imp/tbemd/include/ndbm.h user/imp/tbemd/include/netdb.h user/imp/tbemd/include/nl_types.h user/imp/tbemd/include/nlist.h user/imp/tbemd/include/nsswitch.h user/imp/tbemd/include/paths.h user/imp/tbemd/include/protocols/dumprestore.h user/imp/tbemd/include/protocols/routed.h user/imp/tbemd/include/protocols/rwhod.h user/imp/tbemd/include/protocols/talkd.h user/imp/tbemd/include/protocols/timed.h user/imp/tbemd/include/pwd.h user/imp/tbemd/include/ranlib.h user/imp/tbemd/include/regex.h user/imp/tbemd/include/regexp.h user/imp/tbemd/include/resolv.h user/imp/tbemd/include/runetype.h user/imp/tbemd/include/setjmp.h user/imp/tbemd/include/signal.h user/imp/tbemd/include/stab.h user/imp/tbemd/include/stddef.h user/imp/tbemd/include/stdio.h user/imp/tbemd/include/stdlib.h user/imp/tbemd/include/string.h user/imp/tbemd/include/sysexits.h user/imp/tbemd/include/tar.h user/imp/tbemd/include/termios.h user/imp/tbemd/include/time.h user/imp/tbemd/include/timeconv.h user/imp/tbemd/include/ttyent.h user/imp/tbemd/include/unistd.h user/imp/tbemd/include/utime.h user/imp/tbemd/include/vis.h user/imp/tbemd/include/wchar.h user/imp/tbemd/lib/libarchive/archive_write_disk.3 user/imp/tbemd/lib/libc/gen/tls.c user/imp/tbemd/lib/libc/stdio/printf.3 user/imp/tbemd/lib/libc/stdlib/malloc.c user/imp/tbemd/lib/libc/stdtime/strptime.3 user/imp/tbemd/lib/libc_r/Makefile user/imp/tbemd/lib/libkse/Makefile user/imp/tbemd/lib/libpam/modules/pam_echo/pam_echo.8 user/imp/tbemd/libexec/rtld-elf/arm/rtld_start.S user/imp/tbemd/libexec/rtld-elf/rtld.c user/imp/tbemd/sbin/devd/Makefile user/imp/tbemd/sbin/devfs/Makefile user/imp/tbemd/sbin/ffsinfo/Makefile user/imp/tbemd/sbin/ifconfig/ifieee80211.c user/imp/tbemd/sbin/mknod/Makefile user/imp/tbemd/sbin/mount_std/Makefile user/imp/tbemd/sbin/sunlabel/Makefile user/imp/tbemd/sbin/sysctl/Makefile user/imp/tbemd/sbin/sysctl/sysctl.c user/imp/tbemd/share/man/man5/tmpfs.5 user/imp/tbemd/share/man/man9/locking.9 user/imp/tbemd/share/misc/committers-src.dot user/imp/tbemd/share/syscons/keymaps/fr.dvorak.acc.kbd user/imp/tbemd/sys/amd64/conf/GENERIC user/imp/tbemd/sys/amd64/conf/XENHVM user/imp/tbemd/sys/arm/arm/pmap.c user/imp/tbemd/sys/arm/arm/support.S user/imp/tbemd/sys/arm/conf/AVILA user/imp/tbemd/sys/arm/conf/BWCT user/imp/tbemd/sys/arm/conf/CAMBRIA user/imp/tbemd/sys/arm/conf/CNS11XXNAS user/imp/tbemd/sys/arm/conf/CRB user/imp/tbemd/sys/arm/conf/DB-88F5XXX user/imp/tbemd/sys/arm/conf/DB-88F6XXX user/imp/tbemd/sys/arm/conf/EP80219 user/imp/tbemd/sys/arm/conf/GUMSTIX user/imp/tbemd/sys/arm/conf/HL200 user/imp/tbemd/sys/arm/conf/IQ31244 user/imp/tbemd/sys/arm/conf/KB920X user/imp/tbemd/sys/arm/conf/NSLU user/imp/tbemd/sys/arm/conf/SKYEYE user/imp/tbemd/sys/arm/include/_inttypes.h user/imp/tbemd/sys/arm/include/_stdint.h user/imp/tbemd/sys/arm/include/bus.h user/imp/tbemd/sys/arm/include/bus_dma.h user/imp/tbemd/sys/arm/include/ucontext.h user/imp/tbemd/sys/arm/sa11x0/sa11x0.c user/imp/tbemd/sys/arm/sa11x0/sa11x0_dmacreg.h user/imp/tbemd/sys/arm/sa11x0/sa11x0_gpioreg.h user/imp/tbemd/sys/arm/sa11x0/sa11x0_irq.S user/imp/tbemd/sys/arm/sa11x0/sa11x0_irqhandler.c user/imp/tbemd/sys/arm/sa11x0/sa11x0_ostreg.h user/imp/tbemd/sys/arm/sa11x0/sa11x0_ppcreg.h user/imp/tbemd/sys/arm/sa11x0/sa11x0_reg.h user/imp/tbemd/sys/arm/sa11x0/sa11x0_var.h user/imp/tbemd/sys/cam/scsi/scsi_cd.c user/imp/tbemd/sys/conf/NOTES user/imp/tbemd/sys/conf/files user/imp/tbemd/sys/dev/acpica/acpi_video.c user/imp/tbemd/sys/dev/ath/ath_hal/ah.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416reg.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280.h user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280_attach.c user/imp/tbemd/sys/dev/iwn/if_iwn.c user/imp/tbemd/sys/dev/siba/siba_core.c user/imp/tbemd/sys/dev/siba/sibareg.h user/imp/tbemd/sys/dev/siba/sibavar.h user/imp/tbemd/sys/i386/conf/GENERIC user/imp/tbemd/sys/i386/conf/XEN user/imp/tbemd/sys/ia64/conf/GENERIC user/imp/tbemd/sys/mips/cavium/octeon_machdep.c user/imp/tbemd/sys/mips/conf/ADM5120 user/imp/tbemd/sys/mips/conf/ALCHEMY user/imp/tbemd/sys/mips/conf/IDT user/imp/tbemd/sys/mips/conf/MALTA user/imp/tbemd/sys/mips/conf/MALTA64 user/imp/tbemd/sys/mips/conf/OCTEON1 user/imp/tbemd/sys/mips/conf/OCTEON1-32 user/imp/tbemd/sys/mips/conf/QEMU user/imp/tbemd/sys/mips/conf/SENTRY5 user/imp/tbemd/sys/mips/conf/SWARM user/imp/tbemd/sys/mips/conf/XLR user/imp/tbemd/sys/modules/nfsclient/Makefile user/imp/tbemd/sys/modules/nfsserver/Makefile user/imp/tbemd/sys/net/netisr.c user/imp/tbemd/sys/nfs/nfs_common.c user/imp/tbemd/sys/nfsclient/nfs_vfsops.c user/imp/tbemd/sys/nfsserver/nfs_srvsubs.c user/imp/tbemd/sys/pc98/conf/GENERIC user/imp/tbemd/sys/powerpc/booke/machdep.c user/imp/tbemd/sys/powerpc/conf/GENERIC user/imp/tbemd/sys/powerpc/conf/MPC85XX user/imp/tbemd/sys/sun4v/conf/GENERIC user/imp/tbemd/tools/regression/usr.bin/env/Makefile user/imp/tbemd/usr.bin/gencat/gencat.c user/imp/tbemd/usr.bin/getent/getent.1 user/imp/tbemd/usr.bin/getent/getent.c user/imp/tbemd/usr.bin/nl/nl.1 user/imp/tbemd/usr.bin/nl/nl.c user/imp/tbemd/usr.bin/stat/stat.1 user/imp/tbemd/usr.bin/stat/stat.c user/imp/tbemd/usr.bin/unzip/unzip.1 user/imp/tbemd/usr.bin/unzip/unzip.c user/imp/tbemd/usr.bin/usbhidaction/usbhidaction.1 user/imp/tbemd/usr.bin/usbhidaction/usbhidaction.c user/imp/tbemd/usr.bin/usbhidctl/usbhid.c user/imp/tbemd/usr.bin/usbhidctl/usbhidctl.1 user/imp/tbemd/usr.bin/xlint/lint1/makeman user/imp/tbemd/usr.sbin/arp/arp.c user/imp/tbemd/usr.sbin/cxgbtool/Makefile user/imp/tbemd/usr.sbin/eeprom/eeprom.8 user/imp/tbemd/usr.sbin/eeprom/eeprom.c user/imp/tbemd/usr.sbin/ftp-proxy/Makefile.inc user/imp/tbemd/usr.sbin/makefs/compat/pwcache.c user/imp/tbemd/usr.sbin/makefs/compat/strsuftoll.c user/imp/tbemd/usr.sbin/makefs/getid.c user/imp/tbemd/usr.sbin/rpcbind/util.c user/imp/tbemd/usr.sbin/usbdevs/usbdevs.8 user/imp/tbemd/usr.sbin/usbdevs/usbdevs.c user/imp/tbemd/usr.sbin/yppoll/yppoll.8 Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/Makefile.inc1 ============================================================================== --- user/imp/tbemd/Makefile.inc1 Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/Makefile.inc1 Tue Feb 16 23:59:48 2010 (r203979) @@ -15,6 +15,7 @@ # -DNO_CTF do not run the DTrace CTF conversion tools on built objects # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list # TARGET="machine" to crossbuild world for a different machine type +# TARGET_ARCH= may be required when a TARGET supports multiple endians. # # The intended user-driven targets are: @@ -30,7 +31,7 @@ .include .if ${MACHINE_CPUARCH} == "mips" -MK_RESCUE=no # not yet +#MK_RESCUE=no # not yet .endif # We must do share/info early so that installation of info `dir' @@ -120,10 +121,10 @@ VERSION+= ${OSRELDATE} # Guess machine architecture from machine type, and vice versa. .if !defined(TARGET_ARCH) && defined(TARGET) -TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/} +TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/:S/mips/mipsel/} .elif !defined(TARGET) && defined(TARGET_ARCH) && \ ${TARGET_ARCH} != ${MACHINE_ARCH} -TARGET= ${TARGET_ARCH} +TARGET= ${TARGET_ARCH:C/mipse[lb]/mips/:C/armeb/arm} .endif # Otherwise, default to current machine type and architecture. TARGET?= ${MACHINE} Modified: user/imp/tbemd/bin/rmail/Makefile ============================================================================== --- user/imp/tbemd/bin/rmail/Makefile Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/bin/rmail/Makefile Tue Feb 16 23:59:48 2010 (r203979) @@ -11,7 +11,7 @@ PROG= rmail SRCS= rmail.c MAN= rmail.8 -WARNS?= 0 +WARNS?= 2 CFLAGS+=-I${SENDMAIL_DIR}/include -I. LIBSMDIR= ${.OBJDIR}/../../lib/libsm Modified: user/imp/tbemd/etc/ppp/ppp.conf ============================================================================== --- user/imp/tbemd/etc/ppp/ppp.conf Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/etc/ppp/ppp.conf Tue Feb 16 23:59:48 2010 (r203979) @@ -10,7 +10,7 @@ default: set log Phase Chat LCP IPCP CCP tun command - ident user-ppp VERSION (built COMPILATIONDATE) + ident user-ppp VERSION # Ensure that "device" references the correct serial port # for your modem. (cuau0 = COM1, cuau1 = COM2) Modified: user/imp/tbemd/games/Makefile.inc ============================================================================== --- user/imp/tbemd/games/Makefile.inc Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/Makefile.inc Tue Feb 16 23:59:48 2010 (r203979) @@ -3,3 +3,4 @@ BINDIR?= /usr/games FILESDIR?= ${SHAREDIR}/games +WARNS?= 6 Modified: user/imp/tbemd/games/bcd/Makefile ============================================================================== --- user/imp/tbemd/games/bcd/Makefile Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/bcd/Makefile Tue Feb 16 23:59:48 2010 (r203979) @@ -2,7 +2,6 @@ # $FreeBSD$ PROG= bcd -WARNS?= 6 MAN= bcd.6 MLINKS= bcd.6 ppt.6 Modified: user/imp/tbemd/games/bcd/bcd.c ============================================================================== --- user/imp/tbemd/games/bcd/bcd.c Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/bcd/bcd.c Tue Feb 16 23:59:48 2010 (r203979) @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * Modified: user/imp/tbemd/games/caesar/Makefile ============================================================================== --- user/imp/tbemd/games/caesar/Makefile Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/caesar/Makefile Tue Feb 16 23:59:48 2010 (r203979) @@ -8,6 +8,4 @@ SCRIPTS=rot13.sh MAN= caesar.6 MLINKS= caesar.6 rot13.6 -WARNS?= 6 - .include Modified: user/imp/tbemd/games/caesar/caesar.c ============================================================================== --- user/imp/tbemd/games/caesar/caesar.c Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/caesar/caesar.c Tue Feb 16 23:59:48 2010 (r203979) @@ -18,11 +18,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * Modified: user/imp/tbemd/games/fortune/fortune/Makefile ============================================================================== --- user/imp/tbemd/games/fortune/fortune/Makefile Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/fortune/fortune/Makefile Tue Feb 16 23:59:48 2010 (r203979) @@ -3,7 +3,6 @@ PROG= fortune MAN= fortune.6 -WARNS?= 2 CFLAGS+=-DDEBUG -I${.CURDIR}/../strfile .include Modified: user/imp/tbemd/games/fortune/fortune/fortune.6 ============================================================================== --- user/imp/tbemd/games/fortune/fortune/fortune.6 Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/fortune/fortune/fortune.6 Tue Feb 16 23:59:48 2010 (r203979) @@ -12,11 +12,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" Modified: user/imp/tbemd/games/fortune/fortune/fortune.c ============================================================================== --- user/imp/tbemd/games/fortune/fortune/fortune.c Tue Feb 16 22:55:38 2010 (r203978) +++ user/imp/tbemd/games/fortune/fortune/fortune.c Tue Feb 16 23:59:48 2010 (r203979) @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -48,49 +44,50 @@ static const char sccsid[] = "@(#)fortun #include __FBSDID("$FreeBSD$"); -# include -# include +#include +#include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include "strfile.h" -# include "pathnames.h" - -# define TRUE 1 -# define FALSE 0 -# define bool short - -# define MINW 6 /* minimum wait if desired */ -# define CPERS 20 /* # of chars for each sec */ -# define SLEN 160 /* # of chars in short fortune */ - -# define POS_UNKNOWN ((uint32_t) -1) /* pos for file unknown */ -# define NO_PROB (-1) /* no prob specified for file */ - -# ifdef DEBUG -# define DPRINTF(l,x) { if (Debug >= l) fprintf x; } -# undef NDEBUG -# else -# define DPRINTF(l,x) -# define NDEBUG 1 -# endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "strfile.h" +#include "pathnames.h" + +#define TRUE 1 +#define FALSE 0 +#define bool short + +#define MINW 6 /* minimum wait if desired */ +#define CPERS 20 /* # of chars for each sec */ +#define SLEN 160 /* # of chars in short fortune */ + +#define POS_UNKNOWN ((uint32_t) -1) /* pos for file unknown */ +#define NO_PROB (-1) /* no prob specified for file */ + +#ifdef DEBUG +#define DPRINTF(l,x) { if (Debug >= l) fprintf x; } +#undef NDEBUG +#else +#define DPRINTF(l,x) +#define NDEBUG 1 +#endif typedef struct fd { int percent; int fd, datfd; uint32_t pos; FILE *inf; - char *name; - char *path; + const char *name; + const char *path; char *datfile, *posfile; bool read_tbl; bool was_pos_file; @@ -102,7 +99,7 @@ typedef struct fd { bool Found_one; /* did we find a match? */ bool Find_files = FALSE; /* just find a list of proper fortune files */ -bool Fortunes_only = FALSE; /* check only "fortunes" files */ +bool Fortunes_only = FALSE; /* check only "fortunes" files */ bool Wait = FALSE; /* wait desired after fortune */ bool Short_only = FALSE; /* short fortune desired */ bool Long_only = FALSE; /* long fortune desired */ @@ -126,14 +123,14 @@ FILEDESC *Fortfile; /* Fortune file to STRFILE Noprob_tbl; /* sum of data for all no prob files */ -char *Fortune_path; +const char *Fortune_path; char **Fortune_path_arr; int add_dir(FILEDESC *); -int add_file __P((int, - char *, char *, FILEDESC **, FILEDESC **, FILEDESC *)); +int add_file(int, const char *, const char *, FILEDESC **, FILEDESC **, + FILEDESC *); void all_forts(FILEDESC *, char *); -char *copy(char *, u_int); +char *copy(const char *, u_int); void display(FILEDESC *); void do_free(void *); void *do_malloc(u_int); @@ -145,13 +142,13 @@ void get_tbl(FILEDESC *); void getargs(int, char *[]); void getpath(void); void init_prob(void); -int is_dir(char *); -int is_fortfile(char *, char **, char **, int); -int is_off_name(char *); +int is_dir(const char *); +int is_fortfile(const char *, char **, char **, int); +int is_off_name(const char *); int max(int, int); FILEDESC * new_fp(void); -char *off_name(char *); +char *off_name(const char *); void open_dat(FILEDESC *); void open_fp(FILEDESC *); FILEDESC * @@ -171,18 +168,16 @@ int maxlen_in_list(FILEDESC *); static regex_t Re_pat; int -main(ac, av) -int ac; -char *av[]; +main(int argc, char *argv[]) { -#ifdef OK_TO_WRITE_DISK +#ifdef OK_TO_WRITE_DISK int fd; -#endif /* OK_TO_WRITE_DISK */ +#endif /* OK_TO_WRITE_DISK */ (void) setlocale(LC_ALL, ""); getpath(); - getargs(ac, av); + getargs(argc, argv); if (Match) exit(find_matches() != 0); @@ -195,45 +190,44 @@ char *av[]; display(Fortfile); -#ifdef OK_TO_WRITE_DISK +#ifdef OK_TO_WRITE_DISK if ((fd = creat(Fortfile->posfile, 0666)) < 0) { perror(Fortfile->posfile); exit(1); } -#ifdef LOCK_EX +#ifdef LOCK_EX /* * if we can, we exclusive lock, but since it isn't very * important, we just punt if we don't have easy locking * available. */ (void) flock(fd, LOCK_EX); -#endif /* LOCK_EX */ +#endif /* LOCK_EX */ write(fd, (char *) &Fortfile->pos, sizeof Fortfile->pos); if (!Fortfile->was_pos_file) (void) chmod(Fortfile->path, 0666); -#ifdef LOCK_EX +#ifdef LOCK_EX (void) flock(fd, LOCK_UN); -#endif /* LOCK_EX */ -#endif /* OK_TO_WRITE_DISK */ +#endif /* LOCK_EX */ +#endif /* OK_TO_WRITE_DISK */ if (Wait) { if (Fort_len == 0) (void) fortlen(); sleep((unsigned int) max(Fort_len / CPERS, MINW)); } - exit(0); - /* NOTREACHED */ + + return (0); } void -display(fp) -FILEDESC *fp; +display(FILEDESC *fp) { char *p; unsigned char ch; char line[BUFSIZ]; open_fp(fp); - (void) fseeko(fp->inf, Seekpts[0], 0); + fseeko(fp->inf, Seekpts[0], SEEK_SET); for (Fort_len = 0; fgets(line, sizeof line, fp->inf) != NULL && !STR_ENDSTRING(line, fp->tbl); Fort_len++) { if (fp->tbl.str_flags & STR_ROTATED) @@ -259,7 +253,7 @@ FILEDESC *fp; * Return the length of the fortune. */ int -fortlen() +fortlen(void) { int nchar; char line[BUFSIZ]; @@ -268,34 +262,31 @@ fortlen() nchar = (int)(Seekpts[1] - Seekpts[0]); else { open_fp(Fortfile); - (void) fseeko(Fortfile->inf, Seekpts[0], 0); + fseeko(Fortfile->inf, Seekpts[0], SEEK_SET); nchar = 0; while (fgets(line, sizeof line, Fortfile->inf) != NULL && !STR_ENDSTRING(line, Fortfile->tbl)) nchar += strlen(line); } Fort_len = nchar; - return nchar; + + return (nchar); } /* * This routine evaluates the arguments on the command line */ void -getargs(argc, argv) -int argc; -char **argv; +getargs(int argc, char *argv[]) { int ignore_case; char *pat; - extern char *optarg; - extern int optind; int ch; ignore_case = FALSE; pat = NULL; -# ifdef DEBUG +#ifdef DEBUG while ((ch = getopt(argc, argv, "aDefilm:osw")) != -1) #else while ((ch = getopt(argc, argv, "aefilm:osw")) != -1) @@ -304,11 +295,11 @@ char **argv; case 'a': /* any fortune */ All_forts++; break; -# ifdef DEBUG +#ifdef DEBUG case 'D': Debug++; break; -# endif /* DEBUG */ +#endif /* DEBUG */ case 'e': Equal_probs++; /* scatter un-allocted prob equally */ break; @@ -362,7 +353,7 @@ char **argv; error = regcomp(&Re_pat, pat, REG_BASIC); if (error) { fprintf(stderr, "regcomp(%s) fails\n", pat); - exit (1); + exit(1); } } } @@ -372,9 +363,7 @@ char **argv; * Form the file list from the file specifications. */ int -form_file_list(files, file_cnt) -char **files; -int file_cnt; +form_file_list(char **files, int file_cnt) { int i, percent; char *sp; @@ -386,7 +375,7 @@ int file_cnt; pstr = Fortune_path_arr; i = 0; while (*pstr) { - i += add_file(NO_PROB, *pstr++, NULL, + i += add_file(NO_PROB, *pstr++, NULL, &File_list, &File_tail, NULL); } Fortunes_only = FALSE; @@ -394,7 +383,7 @@ int file_cnt; fprintf(stderr, "No fortunes found in %s.\n", Fortune_path); } - return i != 0; + return (i != 0); } else { pstr = Fortune_path_arr; i = 0; @@ -406,7 +395,7 @@ int file_cnt; fprintf(stderr, "No fortunes found in %s.\n", Fortune_path); } - return i != 0; + return (i != 0); } } for (i = 0; i < file_cnt; i++) { @@ -419,11 +408,11 @@ int file_cnt; percent = percent * 10 + *sp - '0'; if (percent > 100) { fprintf(stderr, "percentages must be <= 100\n"); - return FALSE; + return (FALSE); } if (*sp == '.') { fprintf(stderr, "percentages must be integers\n"); - return FALSE; + return (FALSE); } /* * If the number isn't followed by a '%', then @@ -437,7 +426,7 @@ int file_cnt; else if (*++sp == '\0') { if (++i >= file_cnt) { fprintf(stderr, "percentages must precede files\n"); - return FALSE; + return (FALSE); } sp = files[i]; } @@ -446,20 +435,21 @@ int file_cnt; pstr = Fortune_path_arr; i = 0; while (*pstr) { - i += add_file(NO_PROB, *pstr++, NULL, + i += add_file(NO_PROB, *pstr++, NULL, &File_list, &File_tail, NULL); } if (!i) { fprintf(stderr, "No fortunes found in %s.\n", Fortune_path); - return FALSE; + return (FALSE); } - } else if (!add_file(percent, sp, NULL, &File_list, + } else if (!add_file(percent, sp, NULL, &File_list, &File_tail, NULL)) { - return FALSE; + return (FALSE); } } - return TRUE; + + return (TRUE); } /* @@ -467,32 +457,31 @@ int file_cnt; * Add a file to the file list. */ int -add_file(percent, file, dir, head, tail, parent) -int percent; -char *file; -char *dir; -FILEDESC **head, **tail; -FILEDESC *parent; +add_file(int percent, const char *file, const char *dir, FILEDESC **head, + FILEDESC **tail, FILEDESC *parent) { FILEDESC *fp; int fd; - char *path, *offensive; + const char *path; + char *tpath, *offensive; bool was_malloc; bool isdir; if (dir == NULL) { path = file; + tpath = NULL; was_malloc = FALSE; } else { - path = do_malloc((unsigned int) (strlen(dir) + strlen(file) + 2)); - (void) strcat(strcat(strcpy(path, dir), "/"), file); + tpath = do_malloc((unsigned int)(strlen(dir) + strlen(file) + 2)); + strcat(strcat(strcpy(tpath, dir), "/"), file); + path = tpath; was_malloc = TRUE; } if ((isdir = is_dir(path)) && parent != NULL) { if (was_malloc) - free(path); - return FALSE; /* don't recurse */ + free(tpath); + return (FALSE); /* don't recurse */ } offensive = NULL; if (!isdir && parent == NULL && (All_forts || Offend) && @@ -500,7 +489,7 @@ FILEDESC *parent; offensive = off_name(path); if (Offend) { if (was_malloc) - free(path); + free(tpath); path = offensive; offensive = NULL; was_malloc = TRUE; @@ -511,7 +500,7 @@ FILEDESC *parent; DPRINTF(1, (stderr, "adding file \"%s\"\n", path)); over: - if ((fd = open(path, 0)) < 0) { + if ((fd = open(path, O_RDONLY)) < 0) { /* * This is a sneak. If the user said -a, and if the * file we're given isn't a file, we check to see if @@ -522,7 +511,7 @@ over: */ if (All_forts && offensive != NULL) { if (was_malloc) - free(path); + free(tpath); path = offensive; offensive = NULL; was_malloc = TRUE; @@ -535,22 +524,22 @@ over: char **pstr = Fortune_path_arr; while (*pstr) { - i += add_file(percent, file, *pstr++, + i += add_file(percent, file, *pstr++, head, tail, parent); } if (!i) { fprintf(stderr, "No '%s' found in %s.\n", file, Fortune_path); } - return i != 0; + return (i != 0); } /* if (parent == NULL) perror(path); */ if (was_malloc) - free(path); - return FALSE; + free(tpath); + return (FALSE); } DPRINTF(2, (stderr, "path = \"%s\"\n", path)); @@ -571,12 +560,12 @@ over: "fortune:%s not a fortune file or directory\n", path); if (was_malloc) - free(path); + free(tpath); do_free(fp->datfile); do_free(fp->posfile); - free((char *) fp); + free(fp); do_free(offensive); - return FALSE; + return (FALSE); } /* * If the user said -a, we need to make this node a pointer to @@ -598,11 +587,11 @@ over: fp->next = *head; *head = fp; } -#ifdef OK_TO_WRITE_DISK +#ifdef OK_TO_WRITE_DISK fp->was_pos_file = (access(fp->posfile, W_OK) >= 0); -#endif /* OK_TO_WRITE_DISK */ +#endif /* OK_TO_WRITE_DISK */ - return TRUE; + return (TRUE); } /* @@ -610,11 +599,11 @@ over: * Return a pointer to an initialized new FILEDESC. */ FILEDESC * -new_fp() +new_fp(void) { FILEDESC *fp; - fp = (FILEDESC *) do_malloc(sizeof *fp); + fp = do_malloc(sizeof(*fp)); fp->datfd = -1; fp->pos = POS_UNKNOWN; fp->inf = NULL; @@ -627,7 +616,8 @@ new_fp() fp->parent = NULL; fp->datfile = NULL; fp->posfile = NULL; - return fp; + + return (fp); } /* @@ -635,13 +625,13 @@ new_fp() * Return a pointer to the offensive version of a file of this name. */ char * -off_name(file) -char *file; +off_name(const char *file) { char *new; new = copy(file, (unsigned int) (strlen(file) + 2)); - return strcat(new, "-o"); + + return (strcat(new, "-o")); } /* @@ -649,12 +639,12 @@ char *file; * Is the file an offensive-style name? */ int -is_off_name(file) -char *file; +is_off_name(const char *file) { int len; len = strlen(file); + return (len >= 3 && file[len - 2] == '-' && file[len - 1] == 'o'); } @@ -664,20 +654,18 @@ char *file; * there are two children to be a parent of. */ void -all_forts(fp, offensive) -FILEDESC *fp; -char *offensive; +all_forts(FILEDESC *fp, char *offensive) { char *sp; FILEDESC *scene, *obscene; int fd; - auto char *datfile, *posfile; + char *datfile, *posfile; if (fp->child != NULL) /* this is a directory, not a file */ return; if (!is_fortfile(offensive, &datfile, &posfile, FALSE)) return; - if ((fd = open(offensive, 0)) < 0) + if ((fd = open(offensive, O_RDONLY)) < 0) return; DPRINTF(1, (stderr, "adding \"%s\" because of -a\n", offensive)); scene = new_fp(); @@ -704,9 +692,9 @@ char *offensive; obscene->datfile = datfile; obscene->posfile = posfile; obscene->read_tbl = FALSE; -#ifdef OK_TO_WRITE_DISK +#ifdef OK_TO_WRITE_DISK obscene->was_pos_file = (access(obscene->posfile, W_OK) >= 0); -#endif /* OK_TO_WRITE_DISK */ +#endif /* OK_TO_WRITE_DISK */ } /* @@ -714,19 +702,18 @@ char *offensive; * Add the contents of an entire directory. */ int -add_dir(fp) -FILEDESC *fp; +add_dir(FILEDESC *fp) { DIR *dir; struct dirent *dirent; - auto FILEDESC *tailp; - auto char *name; + FILEDESC *tailp; + char *name; (void) close(fp->fd); fp->fd = -1; if ((dir = opendir(fp->path)) == NULL) { perror(fp->path); - return FALSE; + return (FALSE); } tailp = NULL; DPRINTF(1, (stderr, "adding dir \"%s\"\n", fp->path)); @@ -743,9 +730,10 @@ FILEDESC *fp; if (fp->num_children == 0) { (void) fprintf(stderr, "fortune: %s: No fortune files in directory.\n", fp->path); - return FALSE; + return (FALSE); } - return TRUE; + + return (TRUE); } /* @@ -753,13 +741,13 @@ FILEDESC *fp; * Return TRUE if the file is a directory, FALSE otherwise. */ int -is_dir(file) -char *file; +is_dir(const char *file) { - auto struct stat sbuf; + struct stat sbuf; if (stat(file, &sbuf) < 0) - return FALSE; + return (FALSE); + return (sbuf.st_mode & S_IFDIR); } @@ -772,19 +760,18 @@ char *file; */ /* ARGSUSED */ int -is_fortfile(file, datp, posp, check_for_offend) -char *file, **datp, **posp; -int check_for_offend; +is_fortfile(const char *file, char **datp, char **posp, int check_for_offend) { int i; - char *sp; + const char *sp; char *datfile; - static char *suflist[] = { /* list of "illegal" suffixes" */ - "dat", "pos", "c", "h", "p", "i", "f", - "pas", "ftn", "ins.c", "ins,pas", - "ins.ftn", "sml", - NULL - }; + static const char *suflist[] = { + /* list of "illegal" suffixes" */ + "dat", "pos", "c", "h", "p", "i", "f", + "pas", "ftn", "ins.c", "ins,pas", + "ins.ftn", "sml", + NULL + }; DPRINTF(2, (stderr, "is_fortfile(%s) returns ", file)); @@ -796,7 +783,7 @@ int check_for_offend; i = strlen(file); if (Offend ^ (file[i - 2] == '-' && file[i - 1] == 'o')) { DPRINTF(2, (stderr, "FALSE (offending file)\n")); - return FALSE; + return (FALSE); } } @@ -806,18 +793,18 @@ int check_for_offend; sp++; if (*sp == '.') { DPRINTF(2, (stderr, "FALSE (file starts with '.')\n")); - return FALSE; + return (FALSE); } if (Fortunes_only && strncmp(sp, "fortunes", 8) != 0) { DPRINTF(2, (stderr, "FALSE (check fortunes only)\n")); - return FALSE; + return (FALSE); } if ((sp = rindex(sp, '.')) != NULL) { sp++; for (i = 0; suflist[i] != NULL; i++) if (strcmp(sp, suflist[i]) == 0) { DPRINTF(2, (stderr, "FALSE (file has suffix \".%s\")\n", sp)); - return FALSE; + return (FALSE); } } @@ -830,22 +817,23 @@ int check_for_offend; DPRINTF(0, (stderr, "Warning: file \"%s\" unreadable\n", datfile)); #endif free(datfile); - return FALSE; + return (FALSE); } if (datp != NULL) *datp = datfile; else free(datfile); if (posp != NULL) { -#ifdef OK_TO_WRITE_DISK +#ifdef OK_TO_WRITE_DISK *posp = copy(file, (unsigned int) (strlen(file) + 4)); /* +4 for ".dat" */ (void) strcat(*posp, ".pos"); #else *posp = NULL; -#endif /* OK_TO_WRITE_DISK */ +#endif /* OK_TO_WRITE_DISK */ } DPRINTF(2, (stderr, "TRUE\n")); - return TRUE; + + return (TRUE); } /* @@ -853,18 +841,17 @@ int check_for_offend; * Return a malloc()'ed copy of the string */ char * -copy(str, len) -char *str; -unsigned int len; +copy(const char *str, unsigned int len) { - char *new, *sp; + char *new, *sp; new = do_malloc(len + 1); sp = new; do { *sp++ = *str; } while (*str++); - return new; + + return (new); } /* @@ -872,16 +859,16 @@ unsigned int len; * Do a malloc, checking for NULL return. */ void * -do_malloc(size) -unsigned int size; +do_malloc(unsigned int size) { - void *new; + void *new; if ((new = malloc(size)) == NULL) { (void) fprintf(stderr, "fortune: out of memory.\n"); exit(1); } - return new; + + return (new); } /* @@ -889,8 +876,7 @@ unsigned int size; * Free malloc'ed space, if any. */ void -do_free(ptr) -void *ptr; +do_free(void *ptr) { if (ptr != NULL) free(ptr); @@ -901,7 +887,7 @@ void *ptr; * Initialize the fortune probabilities. */ void -init_prob() +init_prob(void) { FILEDESC *fp, *last = NULL; int percent, num_noprob, frac; @@ -919,8 +905,7 @@ init_prob() num_noprob++; if (Equal_probs) last = fp; - } - else + } else percent += fp->percent; DPRINTF(1, (stderr, "summing probabilities:%d%% with %d NO_PROB's", percent, num_noprob)); @@ -928,14 +913,12 @@ init_prob() (void) fprintf(stderr, "fortune: probabilities sum to %d%% > 100%%!\n", percent); exit(1); - } - else if (percent < 100 && num_noprob == 0) { + } else if (percent < 100 && num_noprob == 0) { (void) fprintf(stderr, "fortune: no place to put residual probability (%d%% < 100%%)\n", percent); exit(1); - } - else if (percent == 100 && num_noprob != 0) { + } else if (percent == 100 && num_noprob != 0) { (void) fprintf(stderr, "fortune: no probability left to put in residual files (100%%)\n"); exit(1); @@ -955,7 +938,7 @@ init_prob() last->percent = percent; DPRINTF(1, (stderr, ", residual = %d%%", percent)); } - else + else DPRINTF(1, (stderr, ", %d%% distributed over remaining fortunes\n", percent)); @@ -973,7 +956,7 @@ init_prob() * Get the fortune data file's seek pointer for the next fortune. */ void -get_fort() +get_fort(void) { FILEDESC *fp; int choice; @@ -1004,7 +987,7 @@ get_fort() choice = arc4random_uniform(Noprob_tbl.str_numstr); DPRINTF(1, (stderr, "choice = %d (of %u) \n", choice, Noprob_tbl.str_numstr)); - while (choice >= fp->tbl.str_numstr) { + while ((unsigned int)choice >= fp->tbl.str_numstr) { choice -= fp->tbl.str_numstr; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 08:37:56 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFC071065676; Wed, 17 Feb 2010 08:37:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BFDE68FC12; Wed, 17 Feb 2010 08:37:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1H8buZe088403; Wed, 17 Feb 2010 08:37:56 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1H8bun4088401; Wed, 17 Feb 2010 08:37:56 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002170837.o1H8bun4088401@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 08:37:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203986 - user/luigi/ipfw3-head/sbin/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 08:37:56 -0000 Author: luigi Date: Wed Feb 17 08:37:56 2010 New Revision: 203986 URL: http://svn.freebsd.org/changeset/base/203986 Log: we don't need to include queue.h here Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Wed Feb 17 06:43:37 2010 (r203985) +++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Wed Feb 17 08:37:56 2010 (r203986) @@ -17,7 +17,6 @@ #include #include -#include /* XXX there are several sysctl leftover here */ #include From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 08:40:54 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99B81106566B; Wed, 17 Feb 2010 08:40:54 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89D9A8FC08; Wed, 17 Feb 2010 08:40:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1H8esVT089106; Wed, 17 Feb 2010 08:40:54 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1H8esJG089104; Wed, 17 Feb 2010 08:40:54 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002170840.o1H8esJG089104@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 08:40:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203987 - user/luigi/ipfw3-head/sbin/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 08:40:54 -0000 Author: luigi Date: Wed Feb 17 08:40:54 2010 New Revision: 203987 URL: http://svn.freebsd.org/changeset/base/203987 Log: permit building without altq (-DNO_ALTQ) Modified: user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c Modified: user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c ============================================================================== --- user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c Wed Feb 17 08:37:56 2010 (r203986) +++ user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c Wed Feb 17 08:40:54 2010 (r203987) @@ -1131,9 +1131,11 @@ show_ipfw(struct ip_fw *rule, int pcwidt else printf(" log"); } +#ifndef NO_ALTQ if (altqptr) { print_altq_cmd(altqptr); } +#endif if (tagptr) { if (tagptr->len & F_NOT) PRINT_UINT_ARG(" untag ", tagptr->arg1); @@ -1733,8 +1735,10 @@ ipfw_sysctl_handler(int ac, char *av[], } else if (_substrcmp(*av, "dyn_keepalive") == 0) { sysctlbyname("net.inet.ip.fw.dyn_keepalive", NULL, 0, &which, sizeof(which)); +#ifndef NO_ALTQ } else if (_substrcmp(*av, "altq") == 0) { altq_set_enabled(which); +#endif } else { warnx("unrecognize enable/disable keyword: %s\n", *av); } @@ -2863,6 +2867,7 @@ chkarg: } break; +#ifndef NO_ALTQ case TOK_ALTQ: { ipfw_insn_altq *a = (ipfw_insn_altq *)cmd; @@ -2878,6 +2883,7 @@ chkarg: ac--; av++; } break; +#endif case TOK_TAG: case TOK_UNTAG: { From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 15:37:04 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 833CC1065672; Wed, 17 Feb 2010 15:37:04 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 70AAB8FC1D; Wed, 17 Feb 2010 15:37:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HFb4Gj083447; Wed, 17 Feb 2010 15:37:04 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HFb4U6083440; Wed, 17 Feb 2010 15:37:04 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002171537.o1HFb4U6083440@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 15:37:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204005 - in user/luigi/ipfw3-head: sbin/ipfw sys/conf sys/netinet sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 15:37:04 -0000 Author: luigi Date: Wed Feb 17 15:37:04 2010 New Revision: 204005 URL: http://svn.freebsd.org/changeset/base/204005 Log: Almost final batch of compatibility fixes: - bring back the RED and GRED configuration; - implement a compatibility layer so that the kernel understands RELENG_7 and RELENG_8 versions of /sbin/ipfw and produces correct replies. Code from Riccardo Panicucci. Supported by: the Onelab2 project Added: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c (contents, props changed) Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c user/luigi/ipfw3-head/sys/conf/files user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Wed Feb 17 14:27:36 2010 (r204004) +++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Wed Feb 17 15:37:04 2010 (r204005) @@ -226,17 +226,16 @@ print_flowset_parms(struct dn_fs *fs, ch sprintf(plr, "plr %f", 1.0 * fs->plr / (double)(0x7fffffff)); else plr[0] = '\0'; -#if 0 - if (fs->flags_fs & DN_IS_RED) /* RED parameters */ + + if (fs->flags & DN_IS_RED) /* RED parameters */ sprintf(red, "\n\t %cRED w_q %f min_th %d max_th %d max_p %f", - (fs->flags_fs & DN_IS_GENTLE_RED) ? 'G' : ' ', + (fs->flags & DN_IS_GENTLE_RED) ? 'G' : ' ', 1.0 * fs->w_q / (double)(1 << SCALE_RED), - SCALE_VAL(fs->min_th), - SCALE_VAL(fs->max_th), + fs->min_th, + fs->max_th, 1.0 * fs->max_p / (double)(1 << SCALE_RED)); else -#endif sprintf(red, "droptail"); if (prefix[0]) { @@ -244,10 +243,10 @@ print_flowset_parms(struct dn_fs *fs, ch prefix, qs, plr, fs->oid.id, fs->buckets, red); prefix[0] = '\0'; } else { - printf("q%05d %s%s %d flows (%d buckets) %s sched %d " - "weight %d lmax %d pri %d\n", - fs->fs_nr, qs, plr, fs->oid.id, fs->buckets, red, - fs->sched_nr, fs->par[0], fs->par[1], fs->par[2]); + printf("q%05d %s%s %d flows (%d buckets) sched %d " + "weight %d lmax %d pri %d %s\n", + fs->fs_nr, qs, plr, fs->oid.id, fs->buckets, + fs->sched_nr, fs->par[0], fs->par[1], fs->par[2], red); if (fs->flags & DN_HAVE_MASK) print_mask(&fs->flow_mask); } @@ -371,32 +370,6 @@ list_pipes(struct dn_id *oid, struct dn_ flush_buf(buf); } -#if 0 - q = (struct dn_flow_queue *)(p+1); - list_queues(&(p->fs), q); - } - for (fs = next; nbytes >= sizeof *fs; fs = next) { - char prefix[80]; - - if (SLIST_NEXT(fs, next) != (struct dn_flow_set *)DN_IS_QUEUE) - break; - l = sizeof(*fs) + fs->rq_elements * sizeof(*q); - next = (char *)fs + l; - nbytes -= l; - - if (rulenum != 0 && ((rulenum != fs->fs_nr && co.do_pipe == 2) || - (rulenum != fs->parent_nr && co.do_pipe == 1))) { - continue; - } - - q = (struct dn_flow_queue *)(fs+1); - sprintf(prefix, "q%05d: weight %d sched %d ", - fs->fs_nr, fs->par[0], fs->parent_nr); - print_flowset_parms(fs, prefix); - list_queues(fs, q); - } -#endif - /* * Delete pipe, queue or scheduler i */ @@ -1024,13 +997,12 @@ ipfw_config_pipe(int ac, char **av) end_mask: break; -#if 0 case TOK_RED: case TOK_GRED: NEED1("red/gred needs w_q/min_th/max_th/max_p\n"); fs->flags |= DN_IS_RED; if (tok == TOK_GRED) - p.fs.flags_fs |= DN_IS_GENTLE_RED; + fs->flags |= DN_IS_GENTLE_RED; /* * the format for parameters is w_q/min_th/max_th/max_p */ @@ -1043,22 +1015,21 @@ end_mask: if ((end = strsep(&av[0], "/"))) { fs->min_th = strtoul(end, &end, 0); if (*end == 'K' || *end == 'k') - p.fs.min_th *= 1024; + fs->min_th *= 1024; } if ((end = strsep(&av[0], "/"))) { - p.fs.max_th = strtoul(end, &end, 0); + fs->max_th = strtoul(end, &end, 0); if (*end == 'K' || *end == 'k') - p.fs.max_th *= 1024; + fs->max_th *= 1024; } if ((end = strsep(&av[0], "/"))) { double max_p = strtod(end, NULL); if (max_p > 1 || max_p <= 0) errx(EX_DATAERR, "0 < max_p <= 1"); - p.fs.max_p = (int)(max_p * (1 << SCALE_RED)); + fs->max_p = (int)(max_p * (1 << SCALE_RED)); } ac--; av++; break; -#endif case TOK_DROPTAIL: NEED(fs, "droptail is only for flowsets"); @@ -1159,13 +1130,9 @@ end_mask: p->bandwidth = 0; } if (fs) { -#if 0 /* XXX accept a 0 scheduler to keep the default */ - if (fs->sched_nr == 0) - errx(EX_DATAERR, "sched must be > 0"); -#endif - - if (fs->flags & DN_QSIZE_BYTES) { - size_t len; + /* XXX accept a 0 scheduler to keep the default */ + if (fs->flags & DN_QSIZE_BYTES) { + size_t len; long limit; len = sizeof(limit); @@ -1185,19 +1152,16 @@ end_mask: if (fs->qsize > limit) errx(EX_DATAERR, "2 <= queue size <= %ld", limit); } - } -#if 0 /* RED CONFIGURATION */ - if (p.fs.flags_fs & DN_IS_RED) { + + if (fs->flags & DN_IS_RED) { size_t len; int lookup_depth, avg_pkt_size; - double s, idle, weight, w_q; - struct clockinfo ck; - int t; + double w_q; - if (p.fs.min_th >= p.fs.max_th) + if (fs->min_th >= fs->max_th) errx(EX_DATAERR, "min_th %d must be < than max_th %d", - p.fs.min_th, p.fs.max_th); - if (p.fs.max_th == 0) + fs->min_th, fs->max_th); + if (fs->max_th == 0) errx(EX_DATAERR, "max_th must be > 0"); len = sizeof(int); @@ -1220,10 +1184,6 @@ end_mask: "net.inet.ip.dummynet.red_avg_pkt_size must" " be greater than zero"); - len = sizeof(struct clockinfo); - if (sysctlbyname("kern.clockrate", &ck, &len, NULL, 0) == -1) - errx(1, "sysctlbyname(\"%s\")", "kern.clockrate"); - /* * Ticks needed for sending a medium-sized packet. * Unfortunately, when we are configuring a WF2Q+ queue, we @@ -1233,26 +1193,35 @@ end_mask: * correct. But on the other hand, why do we want RED with * WF2Q+ ? */ + /* XXX MPD TODO do it in kernel space when attaching the + * flowset to scheduler? + */ +#if 0 if (p.bandwidth==0) /* this is a WF2Q+ queue */ s = 0; else s = (double)ck.hz * avg_pkt_size * 8 / p.bandwidth; - +#endif /* * max idle time (in ticks) before avg queue size becomes 0. * NOTA: (3/w_q) is approx the value x so that * (1-w_q)^x < 10^-3. */ w_q = ((double)fs->w_q) / (1 << SCALE_RED); +#if 0 // go in kernel idle = s * 3. / w_q; fs->lookup_step = (int)idle / lookup_depth; if (!fs->lookup_step) - p.fs.lookup_step = 1; + fs->lookup_step = 1; weight = 1 - w_q; - for (t = p.fs.lookup_step; t > 1; --t) + for (t = fs->lookup_step; t > 1; --t) weight *= 1 - w_q; - p.fs.lookup_weight = (int)(weight * (1 << SCALE_RED)); + fs->lookup_weight = (int)(weight * (1 << SCALE_RED)); +#endif + } } + +#if 0 /* XXX profile ? */ if (p.samples_no <= 0) { struct dn_profile *prof; prof = o_next(&o, sizeof(*prof), DN_PROFILE); Modified: user/luigi/ipfw3-head/sys/conf/files ============================================================================== --- user/luigi/ipfw3-head/sys/conf/files Wed Feb 17 14:27:36 2010 (r204004) +++ user/luigi/ipfw3-head/sys/conf/files Wed Feb 17 15:37:04 2010 (r204005) @@ -2456,6 +2456,7 @@ netinet/ipfw/dn_sched_wf2q.c optional in netinet/ipfw/dn_sched_qfq.c optional inet dummynet netinet/ipfw/ip_dummynet.c optional inet dummynet netinet/ipfw/ip_dn_io.c optional inet dummynet +netinet/ipfw/ip_dn_glue.c optional inet dummynet netinet/ip_ecn.c optional inet | inet6 netinet/ip_encap.c optional inet | inet6 netinet/ip_fastfwd.c optional inet Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h Wed Feb 17 14:27:36 2010 (r204004) +++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h Wed Feb 17 15:37:04 2010 (r204005) @@ -77,6 +77,11 @@ enum { DN_CMD_DELETE, /* subtype + list of entries */ DN_CMD_GET, /* subtype + list of entries */ DN_CMD_FLUSH, + + /* for compatibility with FreeBSD 7.2/8 */ + DN_COMPAT_PIPE, + DN_COMPAT_QUEUE, + DN_GET_COMPAT, DN_LAST, }; @@ -135,6 +140,17 @@ struct dn_fs { * Now we use 0: weight, 1: lmax, 2: priority */ int par[4]; + + /* RED/GRED parameters */ +#define SCALE_RED 16 +#define SCALE(x) ( (x) << SCALE_RED ) +#define SCALE_VAL(x) ( (x) >> SCALE_RED ) +#define SCALE_MUL(x,y) ( ( (x) * (y) ) >> SCALE_RED ) + int w_q ; /* queue weight (scaled) */ + int max_th ; /* maximum threshold for queue (scaled) */ + int min_th ; /* minimum threshold for queue (scaled) */ + int max_p ; /* maximum value for p_b (scaled) */ + }; /* Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Wed Feb 17 14:27:36 2010 (r204004) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Wed Feb 17 15:37:04 2010 (r204005) @@ -151,6 +151,8 @@ dn_dequeue(struct dn_queue *q) q->_si->ni.length--; q->_si->ni.len_bytes -= m->m_pkthdr.len; } + if (q->ni.length == 0) /* queue is now idle */ + q->q_time = dn_cfg.curr_time; return m; } Added: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Wed Feb 17 15:37:04 2010 (r204005) @@ -0,0 +1,815 @@ + +#include "opt_inet6.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include +#include /* ip_output(), IP_FORWARDING */ +#include +#include +#include +#include +#include +#include + +/* FREEBSD7.2 ip_dummynet.h r191715*/ + +struct dn_heap_entry7 { + int64_t key; /* sorting key. Topmost element is smallest one */ + void *object; /* object pointer */ +}; + +struct dn_heap7 { + int size; + int elements; + int offset; /* XXX if > 0 this is the offset of direct ptr to obj */ + struct dn_heap_entry7 *p; /* really an array of "size" entries */ +}; + +/* Common to 7.2 and 8 */ +struct dn_flow_set { + SLIST_ENTRY(dn_flow_set) next; /* linked list in a hash slot */ + + u_short fs_nr ; /* flow_set number */ + u_short flags_fs; +#define DNOLD_HAVE_FLOW_MASK 0x0001 +#define DNOLD_IS_RED 0x0002 +#define DNOLD_IS_GENTLE_RED 0x0004 +#define DNOLD_QSIZE_IS_BYTES 0x0008 /* queue size is measured in bytes */ +#define DNOLD_NOERROR 0x0010 /* do not report ENOBUFS on drops */ +#define DNOLD_HAS_PROFILE 0x0020 /* the pipe has a delay profile. */ +#define DNOLD_IS_PIPE 0x4000 +#define DNOLD_IS_QUEUE 0x8000 + + struct dn_pipe7 *pipe ; /* pointer to parent pipe */ + u_short parent_nr ; /* parent pipe#, 0 if local to a pipe */ + + int weight ; /* WFQ queue weight */ + int qsize ; /* queue size in slots or bytes */ + int plr ; /* pkt loss rate (2^31-1 means 100%) */ + + struct ipfw_flow_id flow_mask ; + + /* hash table of queues onto this flow_set */ + int rq_size ; /* number of slots */ + int rq_elements ; /* active elements */ + struct dn_flow_queue7 **rq; /* array of rq_size entries */ + + u_int32_t last_expired ; /* do not expire too frequently */ + int backlogged ; /* #active queues for this flowset */ + + /* RED parameters */ +#define SCALE_RED 16 +#define SCALE(x) ( (x) << SCALE_RED ) +#define SCALE_VAL(x) ( (x) >> SCALE_RED ) +#define SCALE_MUL(x,y) ( ( (x) * (y) ) >> SCALE_RED ) + int w_q ; /* queue weight (scaled) */ + int max_th ; /* maximum threshold for queue (scaled) */ + int min_th ; /* minimum threshold for queue (scaled) */ + int max_p ; /* maximum value for p_b (scaled) */ + u_int c_1 ; /* max_p/(max_th-min_th) (scaled) */ + u_int c_2 ; /* max_p*min_th/(max_th-min_th) (scaled) */ + u_int c_3 ; /* for GRED, (1-max_p)/max_th (scaled) */ + u_int c_4 ; /* for GRED, 1 - 2*max_p (scaled) */ + u_int * w_q_lookup ; /* lookup table for computing (1-w_q)^t */ + u_int lookup_depth ; /* depth of lookup table */ + int lookup_step ; /* granularity inside the lookup table */ + int lookup_weight ; /* equal to (1-w_q)^t / (1-w_q)^(t+1) */ + int avg_pkt_size ; /* medium packet size */ + int max_pkt_size ; /* max packet size */ +}; +SLIST_HEAD(dn_flow_set_head, dn_flow_set); + +#define DN_IS_PIPE 0x4000 +#define DN_IS_QUEUE 0x8000 +struct dn_flow_queue7 { + struct dn_flow_queue7 *next ; + struct ipfw_flow_id id ; + + struct mbuf *head, *tail ; /* queue of packets */ + u_int len ; + u_int len_bytes ; + + u_long numbytes; + + u_int64_t tot_pkts ; /* statistics counters */ + u_int64_t tot_bytes ; + u_int32_t drops ; + + int hash_slot ; /* debugging/diagnostic */ + + /* RED parameters */ + int avg ; /* average queue length est. (scaled) */ + int count ; /* arrivals since last RED drop */ + int random ; /* random value (scaled) */ + u_int32_t q_time; /* start of queue idle time */ + + /* WF2Q+ support */ + struct dn_flow_set *fs ; /* parent flow set */ + int heap_pos ; /* position (index) of struct in heap */ + int64_t sched_time ; /* current time when queue enters ready_heap */ + + int64_t S,F ; /* start time, finish time */ +}; + +struct dn_pipe7 { /* a pipe */ + SLIST_ENTRY(dn_pipe7) next; /* linked list in a hash slot */ + + int pipe_nr ; /* number */ + int bandwidth; /* really, bytes/tick. */ + int delay ; /* really, ticks */ + + struct mbuf *head, *tail ; /* packets in delay line */ + + /* WF2Q+ */ + struct dn_heap7 scheduler_heap ; /* top extract - key Finish time*/ + struct dn_heap7 not_eligible_heap; /* top extract- key Start time */ + struct dn_heap7 idle_heap ; /* random extract - key Start=Finish time */ + + int64_t V ; /* virtual time */ + int sum; /* sum of weights of all active sessions */ + + int numbytes; + + int64_t sched_time ; /* time pipe was scheduled in ready_heap */ + + /* + * When the tx clock come from an interface (if_name[0] != '\0'), its name + * is stored below, whereas the ifp is filled when the rule is configured. + */ + char if_name[IFNAMSIZ]; + struct ifnet *ifp ; + int ready ; /* set if ifp != NULL and we got a signal from it */ + + struct dn_flow_set fs ; /* used with fixed-rate flows */ +}; +SLIST_HEAD(dn_pipe_head7, dn_pipe7); + + +/* FREEBSD8 ip_dummynet.h r196045 */ +struct dn_flow_queue8 { + struct dn_flow_queue8 *next ; + struct ipfw_flow_id id ; + + struct mbuf *head, *tail ; /* queue of packets */ + u_int len ; + u_int len_bytes ; + + uint64_t numbytes ; /* credit for transmission (dynamic queues) */ + int64_t extra_bits; /* extra bits simulating unavailable channel */ + + u_int64_t tot_pkts ; /* statistics counters */ + u_int64_t tot_bytes ; + u_int32_t drops ; + + int hash_slot ; /* debugging/diagnostic */ + + /* RED parameters */ + int avg ; /* average queue length est. (scaled) */ + int count ; /* arrivals since last RED drop */ + int random ; /* random value (scaled) */ + int64_t idle_time; /* start of queue idle time */ + + /* WF2Q+ support */ + struct dn_flow_set *fs ; /* parent flow set */ + int heap_pos ; /* position (index) of struct in heap */ + int64_t sched_time ; /* current time when queue enters ready_heap */ + + int64_t S,F ; /* start time, finish time */ +}; + +struct dn_pipe8 { /* a pipe */ + SLIST_ENTRY(dn_pipe8) next; /* linked list in a hash slot */ + + int pipe_nr ; /* number */ + int bandwidth; /* really, bytes/tick. */ + int delay ; /* really, ticks */ + + struct mbuf *head, *tail ; /* packets in delay line */ + + /* WF2Q+ */ + struct dn_heap7 scheduler_heap ; /* top extract - key Finish time*/ + struct dn_heap7 not_eligible_heap; /* top extract- key Start time */ + struct dn_heap7 idle_heap ; /* random extract - key Start=Finish time */ + + int64_t V ; /* virtual time */ + int sum; /* sum of weights of all active sessions */ + + /* Same as in dn_flow_queue, numbytes can become large */ + int64_t numbytes; /* bits I can transmit (more or less). */ + uint64_t burst; /* burst size, scaled: bits * hz */ + + int64_t sched_time ; /* time pipe was scheduled in ready_heap */ + int64_t idle_time; /* start of pipe idle time */ + + char if_name[IFNAMSIZ]; + struct ifnet *ifp ; + int ready ; /* set if ifp != NULL and we got a signal from it */ + + struct dn_flow_set fs ; /* used with fixed-rate flows */ + + /* fields to simulate a delay profile */ +#define ED_MAX_NAME_LEN 32 + char name[ED_MAX_NAME_LEN]; + int loss_level; + int samples_no; + int *samples; +}; + +#define ED_MAX_SAMPLES_NO 1024 +struct dn_pipe_max8 { + struct dn_pipe8 pipe; + int samples[ED_MAX_SAMPLES_NO]; +}; +SLIST_HEAD(dn_pipe_head8, dn_pipe8); + +/* + * Changes from 7.2 to 8: + * dn_pipe: + * numbytes from int to int64_t + * add burst (int64_t) + * add idle_time (int64_t) + * add profile + * add struct dn_pipe_max + * add flag DN_HAS_PROFILE + * + * dn_flow_queue + * numbytes from u_long to int64_t + * add extra_bits (int64_t) + * q_time from u_int32_t to int64_t and name idle_time + * + * dn_flow_set unchanged + * + */ + +/* NOTE:XXX copied from dummynet.c */ +#define O_NEXT(p, len) ((void *)((char *)p + len)) +static void +oid_fill(struct dn_id *oid, int len, int type, uintptr_t id) +{ + oid->len = len; + oid->type = type; + oid->subtype = 0; + oid->id = id; +} +/* make room in the buffer and move the pointer forward */ +static void * +o_next(struct dn_id **o, int len, int type) +{ + struct dn_id *ret = *o; + oid_fill(ret, len, type, 0); + *o = O_NEXT(*o, len); + return ret; +} + + +static size_t pipesize7 = sizeof(struct dn_pipe7); +static size_t pipesize8 = sizeof(struct dn_pipe8); +static size_t pipesizemax8 = sizeof(struct dn_pipe_max8); + +/* Indicate 'ipfw' version + * 1: from FreeBSD 7.2 + * 0: from FreeBSD 8 + * -1: unknow (for now is unused) + * + * It is update when a IP_DUMMYNET_DEL or IP_DUMMYNET_CONFIGURE request arrives + * NOTE: if a IP_DUMMYNET_GET arrives and the 'ipfw' version is unknow, + * it is suppose to be the FreeBSD 8 version. + */ +static int is7 = 0; + +static int +convertflags2new(int src) +{ + int dst = 0; + + if (src & DNOLD_HAVE_FLOW_MASK) + dst |= DN_HAVE_MASK; + if (src & DNOLD_QSIZE_IS_BYTES) + dst |= DN_QSIZE_BYTES; + if (src & DNOLD_NOERROR) + dst |= DN_NOERROR; + if (src & DNOLD_IS_RED) + dst |= DN_IS_RED; + if (src & DNOLD_IS_GENTLE_RED) + dst |= DN_IS_GENTLE_RED; + if (src & DNOLD_HAS_PROFILE) + dst |= DN_HAS_PROFILE; + + return dst; +} + +static int +convertflags2old(int src) +{ + int dst = 0; + + if (src & DN_HAVE_MASK) + dst |= DNOLD_HAVE_FLOW_MASK; + if (src & DN_IS_RED) + dst |= DNOLD_IS_RED; + if (src & DN_IS_GENTLE_RED) + dst |= DNOLD_IS_GENTLE_RED; + if (src & DN_NOERROR) + dst |= DNOLD_NOERROR; + if (src & DN_HAS_PROFILE) + dst |= DNOLD_HAS_PROFILE; + if (src & DN_QSIZE_BYTES) + dst |= DNOLD_QSIZE_IS_BYTES; + + return dst; +} + +static int +dn_compat_del(void *v) +{ + struct dn_pipe7 *p = (struct dn_pipe7 *) v; + struct dn_pipe8 *p8 = (struct dn_pipe8 *) v; + struct { + struct dn_id oid; + uintptr_t a[1]; /* add more if we want a list */ + } cmd; + + /* XXX DN_API_VERSION ??? */ + oid_fill((void *)&cmd, sizeof(cmd), DN_CMD_DELETE, DN_API_VERSION); + + if (is7) { + if (p->pipe_nr == 0 && p->fs.fs_nr == 0) + return EINVAL; + if (p->pipe_nr != 0 && p->fs.fs_nr != 0) + return EINVAL; + } else { + if (p8->pipe_nr == 0 && p8->fs.fs_nr == 0) + return EINVAL; + if (p8->pipe_nr != 0 && p8->fs.fs_nr != 0) + return EINVAL; + } + + if (p->pipe_nr != 0) { /* pipe x delete */ + cmd.a[0] = p->pipe_nr; + cmd.oid.subtype = DN_LINK; + } else { /* queue x delete */ + cmd.oid.subtype = DN_FS; + cmd.a[0] = (is7) ? p->fs.fs_nr : p8->fs.fs_nr; + } + + return do_config(&cmd, cmd.oid.len); +} + +static int +dn_compat_config_queue(struct dn_fs *fs, void* v) +{ + struct dn_pipe7 *p7 = (struct dn_pipe7 *)v; + struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; + struct dn_flow_set *f; + + if (is7) + f = &p7->fs; + else + f = &p8->fs; + + fs->fs_nr = f->fs_nr; + fs->sched_nr = f->parent_nr; + fs->flow_mask = f->flow_mask; + fs->buckets = f->rq_size; + fs->qsize = f->qsize; + fs->plr = f->plr; + fs->par[0] = f->weight; + fs->flags = convertflags2new(f->flags_fs); + if (fs->flags & DN_IS_GENTLE_RED || fs->flags & DN_IS_RED) { + fs->w_q = f->w_q; + fs->max_th = f->max_th; + fs->min_th = f->min_th; + fs->max_p = f->max_p; + } + + return 0; +} + +static int +dn_compat_config_pipe(struct dn_sch *sch, struct dn_link *p, + struct dn_fs *fs, void* v) +{ + struct dn_pipe7 *p7 = (struct dn_pipe7 *)v; + struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; + int i = p7->pipe_nr; + + sch->sched_nr = i; + sch->oid.subtype = 0; + p->link_nr = i; + fs->fs_nr = i + 2*DN_MAX_ID; + fs->sched_nr = i + DN_MAX_ID; + + /* Common to 7 and 8 */ + p->bandwidth = p7->bandwidth; + p->delay = p7->delay; + if (!is7) { + /* FreeBSD 8 has burst and profile */ + p->burst = p8->burst; + if (p8->samples > 0) + /*XXX TODO */ + ; + } + + /* fill the fifo flowset */ + dn_compat_config_queue(fs, v); + fs->fs_nr = i + 2*DN_MAX_ID; + fs->sched_nr = i + DN_MAX_ID; + + /* Move scheduler related parameter from fs to sch */ + sch->buckets = fs->buckets; /*XXX*/ + fs->buckets = 0; + if (fs->flags & DN_HAVE_MASK) { + sch->flags |= DN_HAVE_MASK; + fs->flags &= ~DN_HAVE_MASK; + sch->sched_mask = fs->flow_mask; + bzero(&fs->flow_mask, sizeof(struct ipfw_flow_id)); + } + + return 0; +} + +static int +dn_compat_config_profile(struct dn_profile *pf, struct dn_link *p, + void *v) +{ + struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; + + /* XXX NOT TESTED YET */ + p8->samples = &(((struct dn_pipe_max8 *)p8)->samples[0]); + + pf->link_nr = p->link_nr; + pf->loss_level = p8->loss_level; + pf->bandwidth = p->bandwidth; + pf->samples_no = p8->samples_no; + bcopy(p8->samples, pf->samples, sizeof(pf->samples)); + + return 0; +} + +/* + * If p->pipe_nr != 0 the command is 'pipe x config', so need to create + * the three main struct, else only a flowset is created + */ +static int +dn_compat_configure(void *v) +{ + struct dn_id *buf, *base; + struct dn_sch *sch = NULL; + struct dn_link *p = NULL; + struct dn_fs *fs = NULL; + struct dn_profile *pf = NULL; + int lmax; + int error; + + lmax = sizeof(struct dn_id); /* command header */ + lmax += sizeof(struct dn_sch) + sizeof(struct dn_link) + + sizeof(struct dn_fs) + sizeof(struct dn_profile); + + struct dn_pipe7 *p7 = (struct dn_pipe7 *)v; + struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; + + int i; /* number of object to configure */ + + base = buf = malloc(lmax, M_DUMMYNET, M_WAIT|M_ZERO); + o_next(&buf, sizeof(struct dn_id), DN_CMD_CONFIG); + base->id = DN_API_VERSION; + + /* pipe_nr is the same in p7 and p8 */ + i = p7->pipe_nr; + if (i != 0) { /* pipe config */ + sch = o_next(&buf, sizeof(*sch), DN_SCH); + p = o_next(&buf, sizeof(*p), DN_LINK); + fs = o_next(&buf, sizeof(*fs), DN_FS); + + error = dn_compat_config_pipe(sch, p, fs, v); + if (error) { + free(buf, M_DUMMYNET); + return error; + } + if (!is7 && p8->samples_no > 0) { + /* Add profiles*/ + pf = o_next(&buf, sizeof(*pf), DN_PROFILE); + error = dn_compat_config_profile(pf, p, v); + if (error) { + free(buf, M_DUMMYNET); + return error; + } + } + } else { /* queue config */ + fs = o_next(&buf, sizeof(*fs), DN_FS); + error = dn_compat_config_queue(fs, v); + if (error) { + free(buf, M_DUMMYNET); + return error; + } + } + error = do_config(base, (char *)buf - (char *)base); + + return error; +} + +int +dn_compat_calc_size(struct dn_parms dn_cfg) +{ + int need = 0; + /* XXX use FreeBSD 8 struct size */ + /* NOTE: + * - half scheduler: schk_count/2 + * - all flowset: fsk_count + * - all flowset queues: queue_count + * - all pipe queue: si_count + */ + need += dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2; + need += dn_cfg.fsk_count * sizeof(struct dn_flow_set); + need += dn_cfg.si_count * sizeof(struct dn_flow_queue8); + need += dn_cfg.queue_count * sizeof(struct dn_flow_queue8); + + return need; +} + +int +dn_c_copy_q (void *_ni, void *arg) +{ + struct copy_args *a = arg; + struct dn_flow_queue7 *fq7 = (struct dn_flow_queue7 *)*a->start; + struct dn_flow_queue8 *fq8 = (struct dn_flow_queue8 *)*a->start; + struct dn_flow *ni = (struct dn_flow *)_ni; + int size = 0; + + /* XXX hash slot not set */ + /* No difference between 7.2/8 */ + fq7->len = ni->length; + fq7->len_bytes = ni->len_bytes; + fq7->id = ni->fid; + + if (is7) { + size = sizeof(struct dn_flow_queue7); + fq7->tot_pkts = ni->tot_pkts; + fq7->tot_bytes = ni->tot_bytes; + fq7->drops = ni->drops; + } else { + size = sizeof(struct dn_flow_queue8); + fq8->tot_pkts = ni->tot_pkts; + fq8->tot_bytes = ni->tot_bytes; + fq8->drops = ni->drops; + } + + *a->start += size; + return 0; +} + +int +dn_c_copy_pipe(struct dn_schk *s, struct copy_args *a, int nq) +{ + struct dn_link *l = &s->link; + struct dn_fsk *f = s->fs; + + struct dn_pipe7 *pipe7 = (struct dn_pipe7 *)*a->start; + struct dn_pipe8 *pipe8 = (struct dn_pipe8 *)*a->start; + struct dn_flow_set *fs; + int size = 0; + + if (is7) { + fs = &pipe7->fs; + size = sizeof(struct dn_pipe7); + } else { + fs = &pipe8->fs; + size = sizeof(struct dn_pipe8); + } + + /* These 4 field are the same in pipe7 and pipe8 */ + pipe7->next.sle_next = (struct dn_pipe7 *)DN_IS_PIPE; + pipe7->bandwidth = l->bandwidth; + pipe7->delay = l->delay; + pipe7->pipe_nr = l->link_nr - DN_MAX_ID; + + if (!is7) { + if (s->profile) { + struct dn_profile *pf = s->profile; + strncpy(pf->name,pipe8->name,sizeof(pf->name)); + pipe8->loss_level = pf->loss_level; + pipe8->samples_no = pf->samples_no; + } + pipe8->burst = l->burst / 8 / hz; + } + + fs->flow_mask = s->sch.sched_mask; + fs->rq_size = s->sch.buckets ? s->sch.buckets : 1; + + fs->parent_nr = l->link_nr - DN_MAX_ID; + fs->qsize = f->fs.qsize; + fs->plr = f->fs.plr; + fs->w_q = f->fs.w_q; + fs->max_th = f->max_th; + fs->min_th = f->min_th; + fs->max_p = f->fs.max_p; + fs->rq_elements = nq; + + fs->flags_fs = convertflags2old(f->fs.flags); + + *a->start += size; + return 0; +} + + +int +dn_compat_copy_pipe(struct copy_args *a, void *_o) +{ + int have = a->end - *a->start; + int need = 0; + int pipe_size = sizeof(struct dn_pipe8); + int queue_size = sizeof(struct dn_flow_queue8); + int n_queue = 0; /* number of queues */ + + struct dn_schk *s = (struct dn_schk *)_o; + /* calculate needed space: + * - struct dn_pipe + * - if there are instances, dn_queue * n_instances + */ + n_queue = (s->sch.flags & DN_HAVE_MASK ? dn_ht_entries(s->siht) : + (s->siht ? 1 : 0)); + need = pipe_size + queue_size * n_queue; + if (have < need) { + D("have %d < need %d", have, need); + return 1; + } + /* copy pipe */ + dn_c_copy_pipe(s, a, n_queue); + + /* copy queues */ + if (s->sch.flags & DN_HAVE_MASK) + dn_ht_scan(s->siht, dn_c_copy_q, a); + else if (s->siht) + dn_c_copy_q(s->siht, a); + return 0; +} + +int +dn_c_copy_fs(struct dn_fsk *f, struct copy_args *a, int nq) +{ + struct dn_flow_set *fs = (struct dn_flow_set *)*a->start; + + fs->next.sle_next = (struct dn_flow_set *)DN_IS_QUEUE; + fs->fs_nr = f->fs.fs_nr; + fs->qsize = f->fs.qsize; + fs->plr = f->fs.plr; + fs->w_q = f->fs.w_q; + fs->max_th = f->max_th; + fs->min_th = f->min_th; + fs->max_p = f->fs.max_p; + fs->flow_mask = f->fs.flow_mask; + fs->rq_elements = nq; + fs->rq_size = (f->fs.buckets ? f->fs.buckets : 1); + fs->parent_nr = f->fs.sched_nr; + fs->weight = f->fs.par[0]; + + fs->flags_fs = convertflags2old(f->fs.flags); + *a->start += sizeof(struct dn_flow_set); + return 0; +} + +int +dn_compat_copy_queue(struct copy_args *a, void *_o) +{ + int have = a->end - *a->start; + int need = 0; + int fs_size = sizeof(struct dn_flow_set); + int queue_size = sizeof(struct dn_flow_queue8); + + struct dn_fsk *fs = (struct dn_fsk *)_o; + int n_queue = 0; /* number of queues */ + + n_queue = (fs->fs.flags & DN_HAVE_MASK ? dn_ht_entries(fs->qht) : + (fs->qht ? 1 : 0)); + + need = fs_size + queue_size * n_queue; + if (have < need) { + D("have < need"); + return 1; + } + + /* copy flowset */ + dn_c_copy_fs(fs, a, n_queue); + + /* copy queues */ + if (fs->fs.flags & DN_HAVE_MASK) + dn_ht_scan(fs->qht, dn_c_copy_q, a); + else if (fs->qht) + dn_c_copy_q(fs->qht, a); + + return 0; +} + +int +copy_data_helper_compat(void *_o, void *_arg) +{ + struct copy_args *a = _arg; + + if (a->type == DN_COMPAT_PIPE) { + struct dn_schk *s = _o; + if (s->sch.oid.subtype != 1 || s->sch.sched_nr <= DN_MAX_ID) { + return 0; /* not old type */ + } + /* copy pipe parameters, and if instance exists, copy + * other parameters and eventually queues. + */ + if(dn_compat_copy_pipe(a, _o)) + return DNHT_SCAN_END; + } else if (a->type == DN_COMPAT_QUEUE) { + struct dn_fsk *fs = _o; + if (fs->fs.fs_nr >= DN_MAX_ID) + return 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 15:39:31 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE54A106566B; Wed, 17 Feb 2010 15:39:31 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ADFAA8FC1A; Wed, 17 Feb 2010 15:39:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HFdVuE083999; Wed, 17 Feb 2010 15:39:31 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HFdVqs083997; Wed, 17 Feb 2010 15:39:31 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002171539.o1HFdVqs083997@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 15:39:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204006 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 15:39:31 -0000 Author: luigi Date: Wed Feb 17 15:39:31 2010 New Revision: 204006 URL: http://svn.freebsd.org/changeset/base/204006 Log: use M_NOWAIT when allocating memory with a lock held Submitted by: Riccardo Panicucci Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c Wed Feb 17 15:37:04 2010 (r204005) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_sockopt.c Wed Feb 17 15:39:31 2010 (r204006) @@ -115,7 +115,8 @@ get_map(struct ip_fw_chain *chain, int e int i; i = chain->n_rules + extra; - map = malloc(i * sizeof(struct ip_fw *), M_IPFW, M_WAITOK); + map = malloc(i * sizeof(struct ip_fw *), M_IPFW, + locked ? M_NOWAIT : M_WAITOK); if (map == NULL) { printf("%s: cannot allocate map\n", __FUNCTION__); return NULL; From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 15:44:02 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22818106566B; Wed, 17 Feb 2010 15:44:02 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 118B38FC21; Wed, 17 Feb 2010 15:44:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HFi1jQ085041; Wed, 17 Feb 2010 15:44:01 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HFi1Lu085038; Wed, 17 Feb 2010 15:44:01 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002171544.o1HFi1Lu085038@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 15:44:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204007 - in user/luigi/ipfw3-head/sys/netinet/ipfw: . test X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 15:44:02 -0000 Author: luigi Date: Wed Feb 17 15:44:01 2010 New Revision: 204007 URL: http://svn.freebsd.org/changeset/base/204007 Log: we also build the test harness... Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h user/luigi/ipfw3-head/sys/netinet/ipfw/test/main.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Wed Feb 17 15:39:31 2010 (r204006) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Wed Feb 17 15:44:01 2010 (r204007) @@ -309,6 +309,7 @@ struct copy_args { int extra; /* extra filtering */ }; +struct sockopt; int ip_dummynet_compat(struct sockopt *sopt); int dummynet_get(struct sockopt *sopt, void **compat); int dn_c_copy_q (void *_ni, void *arg); Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/test/main.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/test/main.c Wed Feb 17 15:39:31 2010 (r204006) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/test/main.c Wed Feb 17 15:44:01 2010 (r204007) @@ -85,6 +85,8 @@ struct cfg_s { int debug = 0; +struct dn_parms dn_cfg; + static void controller(struct cfg_s *c); /* release a packet: put the mbuf in the freelist, and the queue in From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 17:34:30 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EEE31065670; Wed, 17 Feb 2010 17:34:30 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5EAF88FC18; Wed, 17 Feb 2010 17:34:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HHYUVG009621; Wed, 17 Feb 2010 17:34:30 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HHYUsw009619; Wed, 17 Feb 2010 17:34:30 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002171734.o1HHYUsw009619@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 17:34:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204010 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 17:34:30 -0000 Author: luigi Date: Wed Feb 17 17:34:30 2010 New Revision: 204010 URL: http://svn.freebsd.org/changeset/base/204010 Log: no declarations after code Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Wed Feb 17 17:03:04 2010 (r204009) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Wed Feb 17 17:34:30 2010 (r204010) @@ -475,15 +475,15 @@ dn_compat_configure(void *v) int lmax; int error; - lmax = sizeof(struct dn_id); /* command header */ - lmax += sizeof(struct dn_sch) + sizeof(struct dn_link) + - sizeof(struct dn_fs) + sizeof(struct dn_profile); - struct dn_pipe7 *p7 = (struct dn_pipe7 *)v; struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; int i; /* number of object to configure */ + lmax = sizeof(struct dn_id); /* command header */ + lmax += sizeof(struct dn_sch) + sizeof(struct dn_link) + + sizeof(struct dn_fs) + sizeof(struct dn_profile); + base = buf = malloc(lmax, M_DUMMYNET, M_WAIT|M_ZERO); o_next(&buf, sizeof(struct dn_id), DN_CMD_CONFIG); base->id = DN_API_VERSION; From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 17:34:55 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D97B710656C1; Wed, 17 Feb 2010 17:34:55 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C95B68FC12; Wed, 17 Feb 2010 17:34:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HHYtUW009770; Wed, 17 Feb 2010 17:34:55 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HHYtwt009768; Wed, 17 Feb 2010 17:34:55 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002171734.o1HHYtwt009768@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 17 Feb 2010 17:34:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204011 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 17:34:55 -0000 Author: luigi Date: Wed Feb 17 17:34:55 2010 New Revision: 204011 URL: http://svn.freebsd.org/changeset/base/204011 Log: diff reduction Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Wed Feb 17 17:34:30 2010 (r204010) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Wed Feb 17 17:34:55 2010 (r204011) @@ -1676,20 +1676,20 @@ dummynet_get(struct sockopt *sopt, void struct dn_id cmd; struct copy_args a; + /* save and restore original sopt_valsize around copyin */ sopt_valsize = sopt->sopt_valsize; if (!compat) { D("standard mode"); - /* save and restore original sopt_valsize around copyin */ - error = sooptcopyin(sopt, &cmd, sizeof(cmd), sizeof(cmd)); - sopt->sopt_valsize = sopt_valsize; - if (error) - return error; + error = sooptcopyin(sopt, &cmd, sizeof(cmd), sizeof(cmd)); + sopt->sopt_valsize = sopt_valsize; + if (error) + return error; } else { cmd.type = DN_CMD_GET; cmd.len = sizeof(struct dn_id); cmd.subtype = DN_GET_COMPAT; -// cmd.id = sopt_valsize; + // cmd.id = sopt_valsize; D("compatibility mode"); } /* Count space (under lock) and allocate (outside lock). @@ -1721,9 +1721,8 @@ dummynet_get(struct sockopt *sopt, void if (start == NULL) { if (compat) { *compat = NULL; - return 1; + return 1; // XXX } - else return sooptcopyout(sopt, &cmd, sizeof(cmd)); } ND("have %d:%d sched %d, %d:%d links %d, %d:%d flowsets %d, " From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 22:10:48 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43B29106568F; Wed, 17 Feb 2010 22:10:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3114D8FC0C; Wed, 17 Feb 2010 22:10:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HMAmsx071252; Wed, 17 Feb 2010 22:10:48 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HMAm3R071242; Wed, 17 Feb 2010 22:10:48 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002172210.o1HMAm3R071242@svn.freebsd.org> From: Warner Losh Date: Wed, 17 Feb 2010 22:10:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204015 - in user/imp/tbemd: lib/libc/sys lib/libjail sys/dev/mge sys/mips/mips sys/mips/sibyte sys/netinet/ipfw usr.sbin/rpcbind X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 22:10:48 -0000 Author: imp Date: Wed Feb 17 22:10:47 2010 New Revision: 204015 URL: http://svn.freebsd.org/changeset/base/204015 Log: Merge through r204011 from head. Added: user/imp/tbemd/sys/mips/sibyte/sb_bus_space.h - copied unchanged from r204011, head/sys/mips/sibyte/sb_bus_space.h Modified: user/imp/tbemd/lib/libc/sys/unlink.2 user/imp/tbemd/lib/libjail/jail.c user/imp/tbemd/sys/dev/mge/if_mge.c user/imp/tbemd/sys/mips/mips/bus_space_generic.c user/imp/tbemd/sys/mips/sibyte/sb_asm.S user/imp/tbemd/sys/mips/sibyte/sb_zbpci.c user/imp/tbemd/sys/netinet/ipfw/ip_fw_sockopt.c user/imp/tbemd/usr.sbin/rpcbind/util.c Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/lib/libc/sys/unlink.2 ============================================================================== --- user/imp/tbemd/lib/libc/sys/unlink.2 Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/lib/libc/sys/unlink.2 Wed Feb 17 22:10:47 2010 (r204015) @@ -114,6 +114,8 @@ succeeds unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. +.It Bq Er EISDIR +The named file is a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. Modified: user/imp/tbemd/lib/libjail/jail.c ============================================================================== --- user/imp/tbemd/lib/libjail/jail.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/lib/libjail/jail.c Wed Feb 17 22:10:47 2010 (r204015) @@ -191,7 +191,7 @@ jailparam_all(struct jailparam **jpp) /* Add the parameter to the list */ if (njp >= nlist) { nlist *= 2; - jp = realloc(jp, nlist * sizeof(jp)); + jp = realloc(jp, nlist * sizeof(*jp)); if (jp == NULL) { jailparam_free(jp, njp); return (-1); Modified: user/imp/tbemd/sys/dev/mge/if_mge.c ============================================================================== --- user/imp/tbemd/sys/dev/mge/if_mge.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/sys/dev/mge/if_mge.c Wed Feb 17 22:10:47 2010 (r204015) @@ -457,10 +457,7 @@ mge_allocate_dma(struct mge_softc *sc) { int error; struct mge_desc_wrapper *dw; - int num, i; - - - num = MGE_TX_DESC_NUM + MGE_RX_DESC_NUM; + int i; /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ error = bus_dma_tag_create(NULL, /* parent */ @@ -543,7 +540,7 @@ mge_reinit_rx(struct mge_softc *sc) struct mge_desc_wrapper *dw; int i; - MGE_RECEIVE_LOCK(sc); + MGE_RECEIVE_LOCK_ASSERT(sc); mge_free_desc(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM, sc->mge_rx_dtag, 1); @@ -564,8 +561,6 @@ mge_reinit_rx(struct mge_softc *sc) /* Enable RX queue */ MGE_WRITE(sc, MGE_RX_QUEUE_CMD, MGE_ENABLE_RXQ(MGE_RX_DEFAULT_QUEUE)); - - MGE_RECEIVE_UNLOCK(sc); } #ifdef DEVICE_POLLING @@ -1375,9 +1370,6 @@ mge_encap(struct mge_softc *sc, struct m dw = &sc->mge_tx_desc[desc_no]; mapp = dw->buffer_dmap; - bus_dmamap_sync(sc->mge_desc_dtag, mapp, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - /* Create mapping in DMA memory */ error = bus_dmamap_load_mbuf_sg(sc->mge_tx_dtag, mapp, m0, segs, &nsegs, BUS_DMA_NOWAIT); @@ -1401,7 +1393,7 @@ mge_encap(struct mge_softc *sc, struct m mge_offload_setup_descriptor(sc, dw); } - bus_dmamap_sync(sc->mge_desc_dtag, mapp, + bus_dmamap_sync(sc->mge_desc_dtag, dw->desc_dmap, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); sc->tx_desc_curr = (++sc->tx_desc_curr) % MGE_TX_DESC_NUM; Modified: user/imp/tbemd/sys/mips/mips/bus_space_generic.c ============================================================================== --- user/imp/tbemd/sys/mips/mips/bus_space_generic.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/sys/mips/mips/bus_space_generic.c Wed Feb 17 22:10:47 2010 (r204015) @@ -206,6 +206,14 @@ static struct bus_space generic_space = #define wr8(a, v) oct_write8(a, v) #define wr16(a, v) oct_write16(a, v) #define wr32(a, v) oct_write32(a, v) +#elif defined(CPU_SB1) && _BYTE_ORDER == _BIG_ENDIAN +#include +#define rd8(a) sb_big_endian_read8(a) +#define rd16(a) sb_big_endian_read16(a) +#define rd32(a) sb_big_endian_read32(a) +#define wr8(a, v) sb_big_endian_write8(a, v) +#define wr16(a, v) sb_big_endian_write16(a, v) +#define wr32(a, v) sb_big_endian_write32(a, v) #else #define rd8(a) readb(a) #define rd16(a) readw(a) Modified: user/imp/tbemd/sys/mips/sibyte/sb_asm.S ============================================================================== --- user/imp/tbemd/sys/mips/sibyte/sb_asm.S Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/sys/mips/sibyte/sb_asm.S Wed Feb 17 22:10:47 2010 (r204015) @@ -28,6 +28,7 @@ #include #include +#include /* * We compile a 32-bit kernel to run on the SB-1 processor which is a 64-bit @@ -50,7 +51,7 @@ LEAF(sb_load64) ld v1, 0(a0) /* result = *(uint64_t *)ptr */ move v0, v1 -#if defined(TARGET_BIG_ENDIAN) +#if _BYTE_ORDER == _BIG_ENDIAN dsll32 v1, v1, 0 dsrl32 v1, v1, 0 /* v1 = lower_uint32(result) */ jr ra @@ -68,7 +69,7 @@ END(sb_load64) * Return value: void */ LEAF(sb_store64) -#if defined(TARGET_BIG_ENDIAN) +#if _BYTE_ORDER == _BIG_ENDIAN dsll32 a2, a2, 0 /* a2 = upper_uint32(val) */ dsll32 a3, a3, 0 /* a3 = lower_uint32(val) */ dsrl32 a3, a3, 0 Copied: user/imp/tbemd/sys/mips/sibyte/sb_bus_space.h (from r204011, head/sys/mips/sibyte/sb_bus_space.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sys/mips/sibyte/sb_bus_space.h Wed Feb 17 22:10:47 2010 (r204015, copy of r204011, head/sys/mips/sibyte/sb_bus_space.h) @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2010 Neelkanth Natu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SB_BUS_SPACE_H_ +#define _SB_BUS_SPACE_H_ + +#include + +#if _BYTE_ORDER == _BIG_ENDIAN +uint8_t sb_big_endian_read8(bus_addr_t addr); +uint16_t sb_big_endian_read16(bus_addr_t addr); +uint32_t sb_big_endian_read32(bus_addr_t addr); +void sb_big_endian_write8(bus_addr_t addr, uint8_t val); +void sb_big_endian_write16(bus_addr_t addr, uint16_t val); +void sb_big_endian_write32(bus_addr_t addr, uint32_t val); +#endif + +#endif Modified: user/imp/tbemd/sys/mips/sibyte/sb_zbpci.c ============================================================================== --- user/imp/tbemd/sys/mips/sibyte/sb_zbpci.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/sys/mips/sibyte/sb_zbpci.c Wed Feb 17 22:10:47 2010 (r204015) @@ -50,6 +50,7 @@ #include "pcib_if.h" +#include "sb_bus_space.h" #include "sb_scd.h" __FBSDID("$FreeBSD$"); @@ -63,6 +64,15 @@ static const vm_paddr_t CFG_PADDR_BASE = static const u_long PCI_IOSPACE_ADDR = 0xFC000000; static const u_long PCI_IOSPACE_SIZE = 0x02000000; +#define PCI_MATCH_BYTE_LANES_START 0x40000000 +#define PCI_MATCH_BYTE_LANES_END 0x5FFFFFFF +#define PCI_MATCH_BYTE_LANES_SIZE 0x20000000 + +#define PCI_MATCH_BIT_LANES_MASK (1 << 29) +#define PCI_MATCH_BIT_LANES_START 0x60000000 +#define PCI_MATCH_BIT_LANES_END 0x7FFFFFFF +#define PCI_MATCH_BIT_LANES_SIZE 0x20000000 + static struct rman port_rman; static int @@ -112,6 +122,19 @@ zbpci_attach(device_t dev) panic("Cannot allocate resource for config space accesses."); /* + * Allocate the entire "match bit lanes" address space. + */ +#if _BYTE_ORDER == _BIG_ENDIAN + rid = 2; + res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, + PCI_MATCH_BIT_LANES_START, + PCI_MATCH_BIT_LANES_END, + PCI_MATCH_BIT_LANES_SIZE, 0); + if (res == NULL) + panic("Cannot allocate resource for pci match bit lanes."); +#endif /* _BYTE_ORDER ==_BIG_ENDIAN */ + + /* * Allocate KVA for accessing PCI config space. */ va = kmem_alloc_nofault(kernel_map, PAGE_SIZE * mp_ncpus); @@ -177,21 +200,61 @@ static int zbpci_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { + int error; void *vaddr; - u_long paddr, psize; + u_long orig_paddr, paddr, psize; + + paddr = rman_get_start(res); + psize = rman_get_size(res); + orig_paddr = paddr; + +#if _BYTE_ORDER == _BIG_ENDIAN + /* + * The CFE allocates PCI memory resources that map to the + * "match byte lanes" address space. This address space works + * best for DMA transfers because it does not do any automatic + * byte swaps when data crosses the pci-cpu interface. + * + * This also makes it sub-optimal for accesses to PCI device + * registers because it exposes the little-endian nature of + * the PCI bus to the big-endian CPU. The Sibyte has another + * address window called the "match bit lanes" window which + * automatically swaps bytes when data crosses the pci-cpu + * interface. + * + * We "assume" that any bus_space memory accesses done by the + * CPU to a PCI device are register/configuration accesses and + * are done through the "match bit lanes" window. Any DMA + * transfers will continue to be through the "match byte lanes" + * window because the PCI BAR registers will not be changed. + */ + if (type == SYS_RES_MEMORY) { + if (paddr >= PCI_MATCH_BYTE_LANES_START && + paddr + psize - 1 <= PCI_MATCH_BYTE_LANES_END) { + paddr |= PCI_MATCH_BIT_LANES_MASK; + rman_set_start(res, paddr); + rman_set_end(res, paddr + psize - 1); + } + } +#endif if (type != SYS_RES_IOPORT) { - return (bus_generic_activate_resource(bus, child, type, - rid, res)); + error = bus_generic_activate_resource(bus, child, type, + rid, res); +#if _BYTE_ORDER == _BIG_ENDIAN + if (type == SYS_RES_MEMORY) { + rman_set_start(res, orig_paddr); + rman_set_end(res, orig_paddr + psize - 1); + } +#endif + return (error); } /* * Map the I/O space resource through the memory window starting * at PCI_IOSPACE_ADDR. */ - paddr = rman_get_start(res) + PCI_IOSPACE_ADDR; - psize = rman_get_size(res); - vaddr = pmap_mapdev(paddr, psize); + vaddr = pmap_mapdev(paddr + PCI_IOSPACE_ADDR, psize); rman_set_virtual(res, vaddr); rman_set_bustag(res, mips_bus_space_generic); @@ -280,6 +343,9 @@ zbpci_config_space_va(int bus, int slot, va_page = zbpci_config_space[cpu].vaddr; pa = CFG_PADDR_BASE | (bus << 16) | (slot << 11) | (func << 8) | reg; +#if _BYTE_ORDER == _BIG_ENDIAN + pa = pa ^ (4 - bytes); +#endif pa_page = pa & ~(PAGE_SIZE - 1); if (zbpci_config_space[cpu].paddr != pa_page) { pmap_kremove(va_page); @@ -397,3 +463,82 @@ DEFINE_CLASS_1(zbpci, zbpci_driver, zbpc static devclass_t zbpci_devclass; DRIVER_MODULE(zbpci, zbbus, zbpci_driver, zbpci_devclass, 0, 0); + +/* + * Big endian bus space routines + */ +#if _BYTE_ORDER == _BIG_ENDIAN + +/* + * The CPU correctly deals with the big-endian to little-endian swap if + * we are accessing 4 bytes at a time. However if we want to read 1 or 2 + * bytes then we need to fudge the address generated by the CPU such that + * it generates the right byte enables on the PCI bus. + */ +static bus_addr_t +sb_match_bit_lane_addr(bus_addr_t addr, int bytes) +{ + vm_offset_t pa; + + pa = vtophys(addr); + + if (pa >= PCI_MATCH_BIT_LANES_START && pa <= PCI_MATCH_BIT_LANES_END) + return (addr ^ (4 - bytes)); + else + return (addr); +} + +uint8_t +sb_big_endian_read8(bus_addr_t addr) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 1); + return (readb(addr2)); +} + +uint16_t +sb_big_endian_read16(bus_addr_t addr) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 2); + return (readw(addr2)); +} + +uint32_t +sb_big_endian_read32(bus_addr_t addr) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 4); + return (readl(addr2)); +} + +void +sb_big_endian_write8(bus_addr_t addr, uint8_t val) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 1); + writeb(addr2, val); +} + +void +sb_big_endian_write16(bus_addr_t addr, uint16_t val) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 2); + writew(addr2, val); +} + +void +sb_big_endian_write32(bus_addr_t addr, uint32_t val) +{ + bus_addr_t addr2; + + addr2 = sb_match_bit_lane_addr(addr, 4); + writel(addr2, val); +} +#endif /* _BIG_ENDIAN */ Modified: user/imp/tbemd/sys/netinet/ipfw/ip_fw_sockopt.c ============================================================================== --- user/imp/tbemd/sys/netinet/ipfw/ip_fw_sockopt.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/sys/netinet/ipfw/ip_fw_sockopt.c Wed Feb 17 22:10:47 2010 (r204015) @@ -343,27 +343,22 @@ del_entry(struct ip_fw_chain *chain, u_i break; case 2: /* move rules with given number to new set */ - IPFW_UH_WLOCK(chain); for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; if (rule->rulenum == rulenum) rule->set = new_set; } - IPFW_UH_WUNLOCK(chain); break; case 3: /* move rules with given set number to new set */ - IPFW_UH_WLOCK(chain); for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; if (rule->set == rulenum) rule->set = new_set; } - IPFW_UH_WUNLOCK(chain); break; case 4: /* swap two sets */ - IPFW_UH_WLOCK(chain); for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; if (rule->set == rulenum) @@ -371,7 +366,6 @@ del_entry(struct ip_fw_chain *chain, u_i else if (rule->set == new_set) rule->set = rulenum; } - IPFW_UH_WUNLOCK(chain); break; } rule = chain->reap; Modified: user/imp/tbemd/usr.sbin/rpcbind/util.c ============================================================================== --- user/imp/tbemd/usr.sbin/rpcbind/util.c Wed Feb 17 21:20:54 2010 (r204014) +++ user/imp/tbemd/usr.sbin/rpcbind/util.c Wed Feb 17 22:10:47 2010 (r204015) @@ -178,8 +178,6 @@ addrmerge(struct netbuf *caller, char *s if (ifsa == NULL || ifsa->sa_family != hint_sa->sa_family || !(ifap->ifa_flags & IFF_UP)) continue; - if (!addr_is_bound(ifsa)) - continue; if (!(ifap->ifa_flags & IFF_LOOPBACK) && !listen_addr(ifsa)) continue; From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 22:28:33 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F370F1065679; Wed, 17 Feb 2010 22:28:32 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3B088FC0A; Wed, 17 Feb 2010 22:28:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HMSWIO075357; Wed, 17 Feb 2010 22:28:32 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HMSW9r075355; Wed, 17 Feb 2010 22:28:32 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002172228.o1HMSW9r075355@svn.freebsd.org> From: Warner Losh Date: Wed, 17 Feb 2010 22:28:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204018 - user/imp/tbemd/tools/regression/bin/sh/expansion X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 22:28:33 -0000 Author: imp Date: Wed Feb 17 22:28:32 2010 New Revision: 204018 URL: http://svn.freebsd.org/changeset/base/204018 Log: Merge from head at r204016 Modified: user/imp/tbemd/tools/regression/bin/sh/expansion/arith2.0 Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/tools/regression/bin/sh/expansion/arith2.0 ============================================================================== --- user/imp/tbemd/tools/regression/bin/sh/expansion/arith2.0 Wed Feb 17 22:25:22 2010 (r204017) +++ user/imp/tbemd/tools/regression/bin/sh/expansion/arith2.0 Wed Feb 17 22:28:32 2010 (r204018) @@ -22,6 +22,7 @@ check "4611686018427387904" 461168601842 check "0x4000000000000000" 4611686018427387904 check "0400000000000000000000" 4611686018427387904 check "0x4Ab0000000000000" 5381801554707742720 +check "010" 8 # try out all operators v=42 From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 23:47:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B4BF106566B; Wed, 17 Feb 2010 23:47:08 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BB1C8FC15; Wed, 17 Feb 2010 23:47:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HNl8de092725; Wed, 17 Feb 2010 23:47:08 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HNl87W092723; Wed, 17 Feb 2010 23:47:08 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002172347.o1HNl87W092723@svn.freebsd.org> From: Warner Losh Date: Wed, 17 Feb 2010 23:47:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204020 - user/imp/tbemd/share/mk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 23:47:08 -0000 Author: imp Date: Wed Feb 17 23:47:08 2010 New Revision: 204020 URL: http://svn.freebsd.org/changeset/base/204020 Log: Include Makefile.$MACHINE, if it exists, otherwise Include Makefile.$MACHINE_ARCH, if it exists, otherwise Include Makefile.$MACHINE_CPUARCH, if it exists, otherwise do nothing Added: user/imp/tbemd/share/mk/bsd.arch.inc.mk Added: user/imp/tbemd/share/mk/bsd.arch.inc.mk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/share/mk/bsd.arch.inc.mk Wed Feb 17 23:47:08 2010 (r204020) @@ -0,0 +1,11 @@ +# +# Include the arch-specific Makefile.inc.$ARCH. We go from most specific +# to least specific, stopping after we get a hit. +# +.if exists(${.CURDIR}/Makefile.${MACHINE}) +.include "Makefile.${MACHINE}" +.elif exists(${.CURDIR}/Makefile.${MACHINE_ARCH}) +.include "Makefile.${MACHINE_ARCH}" +.elif exists(${.CURDIR}/Makefile.${MACHINE_CPUARCH}) +.include "Makefile.${MACHINE_CPUARCH}" +.endif From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 23:48:48 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37AE11065679; Wed, 17 Feb 2010 23:48:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27DC28FC08; Wed, 17 Feb 2010 23:48:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HNmmwG093133; Wed, 17 Feb 2010 23:48:48 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HNmlIV093124; Wed, 17 Feb 2010 23:48:47 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002172348.o1HNmlIV093124@svn.freebsd.org> From: Warner Losh Date: Wed, 17 Feb 2010 23:48:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204021 - user/imp/tbemd/sbin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 23:48:48 -0000 Author: imp Date: Wed Feb 17 23:48:47 2010 New Revision: 204021 URL: http://svn.freebsd.org/changeset/base/204021 Log: First directory to apply the simplification of the ARCH specific parts to. This also simplifies the MK_FOO items at the same time a little. Briefly, we create a list for all platforms. We then augment it for a specific platform. We then sort the result and do things alphabetically. Added: user/imp/tbemd/sbin/Makefile.amd64 user/imp/tbemd/sbin/Makefile.arm user/imp/tbemd/sbin/Makefile.i386 user/imp/tbemd/sbin/Makefile.ia64 user/imp/tbemd/sbin/Makefile.mips user/imp/tbemd/sbin/Makefile.pc98 user/imp/tbemd/sbin/Makefile.sparc64 Modified: user/imp/tbemd/sbin/Makefile Modified: user/imp/tbemd/sbin/Makefile ============================================================================== --- user/imp/tbemd/sbin/Makefile Wed Feb 17 23:47:08 2010 (r204020) +++ user/imp/tbemd/sbin/Makefile Wed Feb 17 23:48:47 2010 (r204021) @@ -5,26 +5,21 @@ # XXX MISSING: icheck ncheck -SUBDIR= adjkerntz \ +_SUBDIR=adjkerntz \ atacontrol \ - ${_atm} \ badsect \ - ${_bsdlabel} \ camcontrol \ ccdconfig \ clri \ comcontrol \ conscontrol \ ddb \ - ${_devd} \ devfs \ dhclient \ dmesg \ dump \ dumpfs \ dumpon \ - ${_fdisk} \ - ${_fdisk_pc98} \ ffsinfo \ fsck \ fsck_ffs \ @@ -38,15 +33,12 @@ SUBDIR= adjkerntz \ gvinum \ ifconfig \ init \ - ${_ipf} \ - ${_ipfw} \ iscontrol \ kldconfig \ kldload \ kldstat \ kldunload \ ldconfig \ - ${_mca} \ md5 \ mdconfig \ mdmfs \ @@ -60,96 +52,62 @@ SUBDIR= adjkerntz \ mount_nullfs \ mount_udf \ mount_unionfs \ - ${_natd} \ newfs \ newfs_msdos \ nfsiod \ nos-tun \ - ${_pfctl} \ - ${_pflogd} \ ping \ - ${_ping6} \ - ${_quotacheck} \ rcorder \ reboot \ recoverdisk \ restore \ route \ - ${_routed} \ - ${_rtsol} \ savecore \ - ${_sconfig} \ setkey \ shutdown \ spppcontrol \ - ${_sunlabel} \ swapon \ sysctl \ tunefs \ umount \ .if ${MK_ATM} != "no" -_atm= atm +_SUBDIR += atm .endif .if ${MK_CXX} != "no" -_devd= devd +_SUBDIR += devd .endif .if ${MK_IPFILTER} != "no" -_ipf= ipf +_SUBDIR += ipf .endif .if ${MK_IPFW} != "no" -_ipfw= ipfw -_natd= natd +_SUBDIR += ipfw +_SUBDIR += natd .endif .if ${MK_PF} != "no" -_pfctl= pfctl -_pflogd= pflogd +_SUBDIR += pfctl +_SUBDIR += pflogd .endif .if ${MK_INET6} != "no" -_ping6= ping6 -_rtsol= rtsol -.endif - -.if ${MACHINE_CPUARCH} != "ia64" && ${MACHINE_CPUARCH} != "powerpc" -_bsdlabel= bsdlabel +_SUBDIR += ping6 +_SUBDIR += rtsol .endif .if ${MK_QUOTAS} != "no" -_quotacheck= quotacheck +_SUBDIR += quotacheck .endif .if ${MK_ROUTED} != "no" -_routed= routed -.endif - -.if ${MACHINE_CPUARCH} == "i386" -.if ${MACHINE} == "i386" -_fdisk= fdisk -.elif ${MACHINE} == "pc98" -_fdisk_pc98= fdisk_pc98 -.endif -_sconfig= sconfig +_SUBDIR += routed .endif -.if ${MACHINE_CPUARCH} == "amd64" -_fdisk= fdisk -.endif +.include -.if ${MACHINE_CPUARCH} == "arm" -_fdisk= fdisk -.endif - -.if ${MACHINE_CPUARCH} == "ia64" -_mca= mca -.endif - -.if ${MACHINE_CPUARCH} == "sparc64" -_sunlabel= sunlabel -.endif +SUBDIR=${_SUBDIR:O} .include Added: user/imp/tbemd/sbin/Makefile.amd64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.amd64 Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += fdisk Added: user/imp/tbemd/sbin/Makefile.arm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.arm Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += fdisk Added: user/imp/tbemd/sbin/Makefile.i386 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.i386 Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += fdisk +_SUBDIR += sconfig Added: user/imp/tbemd/sbin/Makefile.ia64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.ia64 Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +_SUBDIR += mca Added: user/imp/tbemd/sbin/Makefile.mips ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.mips Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += fdisk Added: user/imp/tbemd/sbin/Makefile.pc98 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.pc98 Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += fdisk_pc98 +_SUBDIR += sconfig Added: user/imp/tbemd/sbin/Makefile.sparc64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/sbin/Makefile.sparc64 Wed Feb 17 23:48:47 2010 (r204021) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +_SUBDIR += bsdlabel +_SUBDIR += sunlabel From owner-svn-src-user@FreeBSD.ORG Wed Feb 17 23:54:55 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5852106566C; Wed, 17 Feb 2010 23:54:54 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D583A8FC1A; Wed, 17 Feb 2010 23:54:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1HNssMG094508; Wed, 17 Feb 2010 23:54:54 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1HNss06094499; Wed, 17 Feb 2010 23:54:54 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002172354.o1HNss06094499@svn.freebsd.org> From: Warner Losh Date: Wed, 17 Feb 2010 23:54:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204022 - user/imp/tbemd/sbin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 23:54:55 -0000 Author: imp Date: Wed Feb 17 23:54:54 2010 New Revision: 204022 URL: http://svn.freebsd.org/changeset/base/204022 Log: Use SUBDIR := ${SUBDIR:O} in preference to SUBDIR = ${_SUBDIR:O} Submitted by: jmallet@ Modified: user/imp/tbemd/sbin/Makefile user/imp/tbemd/sbin/Makefile.amd64 user/imp/tbemd/sbin/Makefile.arm user/imp/tbemd/sbin/Makefile.i386 user/imp/tbemd/sbin/Makefile.ia64 user/imp/tbemd/sbin/Makefile.mips user/imp/tbemd/sbin/Makefile.pc98 user/imp/tbemd/sbin/Makefile.sparc64 Modified: user/imp/tbemd/sbin/Makefile ============================================================================== --- user/imp/tbemd/sbin/Makefile Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile Wed Feb 17 23:54:54 2010 (r204022) @@ -5,7 +5,7 @@ # XXX MISSING: icheck ncheck -_SUBDIR=adjkerntz \ +SUBDIR=adjkerntz \ atacontrol \ badsect \ camcontrol \ @@ -72,42 +72,42 @@ _SUBDIR=adjkerntz \ umount \ .if ${MK_ATM} != "no" -_SUBDIR += atm +SUBDIR += atm .endif .if ${MK_CXX} != "no" -_SUBDIR += devd +SUBDIR += devd .endif .if ${MK_IPFILTER} != "no" -_SUBDIR += ipf +SUBDIR += ipf .endif .if ${MK_IPFW} != "no" -_SUBDIR += ipfw -_SUBDIR += natd +SUBDIR += ipfw +SUBDIR += natd .endif .if ${MK_PF} != "no" -_SUBDIR += pfctl -_SUBDIR += pflogd +SUBDIR += pfctl +SUBDIR += pflogd .endif .if ${MK_INET6} != "no" -_SUBDIR += ping6 -_SUBDIR += rtsol +SUBDIR += ping6 +SUBDIR += rtsol .endif .if ${MK_QUOTAS} != "no" -_SUBDIR += quotacheck +SUBDIR += quotacheck .endif .if ${MK_ROUTED} != "no" -_SUBDIR += routed +SUBDIR += routed .endif .include -SUBDIR=${_SUBDIR:O} +SUBDIR := ${SUBDIR:O} .include Modified: user/imp/tbemd/sbin/Makefile.amd64 ============================================================================== --- user/imp/tbemd/sbin/Makefile.amd64 Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.amd64 Wed Feb 17 23:54:54 2010 (r204022) @@ -1,4 +1,4 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += fdisk +SUBDIR += bsdlabel +SUBDIR += fdisk Modified: user/imp/tbemd/sbin/Makefile.arm ============================================================================== --- user/imp/tbemd/sbin/Makefile.arm Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.arm Wed Feb 17 23:54:54 2010 (r204022) @@ -1,4 +1,4 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += fdisk +SUBDIR += bsdlabel +SUBDIR += fdisk Modified: user/imp/tbemd/sbin/Makefile.i386 ============================================================================== --- user/imp/tbemd/sbin/Makefile.i386 Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.i386 Wed Feb 17 23:54:54 2010 (r204022) @@ -1,5 +1,5 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += fdisk -_SUBDIR += sconfig +SUBDIR += bsdlabel +SUBDIR += fdisk +SUBDIR += sconfig Modified: user/imp/tbemd/sbin/Makefile.ia64 ============================================================================== --- user/imp/tbemd/sbin/Makefile.ia64 Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.ia64 Wed Feb 17 23:54:54 2010 (r204022) @@ -1,3 +1,3 @@ # $FreeBSD$ -_SUBDIR += mca +SUBDIR += mca Modified: user/imp/tbemd/sbin/Makefile.mips ============================================================================== --- user/imp/tbemd/sbin/Makefile.mips Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.mips Wed Feb 17 23:54:54 2010 (r204022) @@ -1,4 +1,4 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += fdisk +SUBDIR += bsdlabel +SUBDIR += fdisk Modified: user/imp/tbemd/sbin/Makefile.pc98 ============================================================================== --- user/imp/tbemd/sbin/Makefile.pc98 Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.pc98 Wed Feb 17 23:54:54 2010 (r204022) @@ -1,5 +1,5 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += fdisk_pc98 -_SUBDIR += sconfig +SUBDIR += bsdlabel +SUBDIR += fdisk_pc98 +SUBDIR += sconfig Modified: user/imp/tbemd/sbin/Makefile.sparc64 ============================================================================== --- user/imp/tbemd/sbin/Makefile.sparc64 Wed Feb 17 23:48:47 2010 (r204021) +++ user/imp/tbemd/sbin/Makefile.sparc64 Wed Feb 17 23:54:54 2010 (r204022) @@ -1,4 +1,4 @@ # $FreeBSD$ -_SUBDIR += bsdlabel -_SUBDIR += sunlabel +SUBDIR += bsdlabel +SUBDIR += sunlabel From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 04:32:54 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A39671065670; Thu, 18 Feb 2010 04:32:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 79AAA8FC18; Thu, 18 Feb 2010 04:32:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1I4WsDt055897; Thu, 18 Feb 2010 04:32:54 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1I4WsYD055895; Thu, 18 Feb 2010 04:32:54 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002180432.o1I4WsYD055895@svn.freebsd.org> From: Kip Macy Date: Thu, 18 Feb 2010 04:32:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204028 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 04:32:54 -0000 Author: kmacy Date: Thu Feb 18 04:32:54 2010 New Revision: 204028 URL: http://svn.freebsd.org/changeset/base/204028 Log: - white space cleanup - don't use flowtable if src == dst Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.c Thu Feb 18 03:32:51 2010 (r204027) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.c Thu Feb 18 04:32:54 2010 (r204028) @@ -1035,14 +1035,15 @@ flowtable_lookup(struct flowtable *ft, s memcpy(&ro->ro_dst, dsa, sizeof(struct sockaddr_in)); dsin = (struct sockaddr_in *)dsa; ssin = (struct sockaddr_in *)ssa; - if ((ntohl(dsin->sin_addr.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || + if ((dsin->sin_addr.s_addr == ssin->sin_addr.s_addr) || + (ntohl(dsin->sin_addr.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || (ntohl(ssin->sin_addr.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) return (NULL); hash = ipv4_flow_lookup_hash_internal(ssin, dsin, key, flags); } -#endif -#ifdef INET6 +#endif +#ifdef INET6 if (ssa->ss_family == AF_INET6) { struct sockaddr_in6 *ssin6, *dsin6; @@ -1111,7 +1112,7 @@ uncached: if ((ro->ro_dst.sa_family != AF_INET) && (ro->ro_dst.sa_family != AF_INET6)) panic("sa_family == %d\n", ro->ro_dst.sa_family); - + ft->ft_rtalloc(ro, hash, fibnum); if (ro->ro_rt == NULL) error = ENETUNREACH; @@ -1126,7 +1127,7 @@ uncached: ro->ro_rt = NULL; return (NULL); } -#ifdef INET6 +#ifdef INET6 if (ssa->ss_family == AF_INET6) { if (rt->rt_flags & RTF_GATEWAY) l3addr = (struct sockaddr_storage *)rt->rt_gateway; @@ -1136,7 +1137,7 @@ uncached: llentry_update(&lle, LLTABLE6(ifp), l3addr, ifp); } #endif -#ifdef INET +#ifdef INET if (ssa->ss_family == AF_INET) { if (rt->rt_flags & RTF_GATEWAY) l3addr = (struct sockaddr_storage *)rt->rt_gateway; @@ -1154,7 +1155,7 @@ uncached: return (NULL); } error = flowtable_insert(ft, hash, key, fibnum, ro, flags); - + if (error) { RTFREE(rt); LLE_FREE(lle); From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 05:12:05 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C99E51065672; Thu, 18 Feb 2010 05:12:05 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA28F8FC16; Thu, 18 Feb 2010 05:12:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1I5C5bn064440; Thu, 18 Feb 2010 05:12:05 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1I5C55I064438; Thu, 18 Feb 2010 05:12:05 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002180512.o1I5C55I064438@svn.freebsd.org> From: Warner Losh Date: Thu, 18 Feb 2010 05:12:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204029 - user/imp/tbemd/bin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 05:12:05 -0000 Author: imp Date: Thu Feb 18 05:12:05 2010 New Revision: 204029 URL: http://svn.freebsd.org/changeset/base/204029 Log: Update to new style SUBDIRS. Modified: user/imp/tbemd/bin/Makefile Modified: user/imp/tbemd/bin/Makefile ============================================================================== --- user/imp/tbemd/bin/Makefile Thu Feb 18 04:32:54 2010 (r204028) +++ user/imp/tbemd/bin/Makefile Thu Feb 18 05:12:05 2010 (r204029) @@ -8,7 +8,6 @@ SUBDIR= cat \ chio \ chmod \ cp \ - ${_csh} \ date \ dd \ df \ @@ -29,10 +28,8 @@ SUBDIR= cat \ ps \ pwait \ pwd \ - ${_rcp} \ realpath \ rm \ - ${_rmail} \ rmdir \ setfacl \ sh \ @@ -43,15 +40,19 @@ SUBDIR= cat \ uuidgen .if ${MK_RCMDS} != "no" -_rcp= rcp +SUBDIR += rcp .endif .if ${MK_SENDMAIL} != "no" -_rmail= rmail +SUBDIR += rmail .endif .if ${MK_TCSH} != "no" -_csh= csh +SUBDIR += csh .endif +.include + +SUBDIR := ${SUBDIR:O} + .include From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 15:12:48 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C1D81065670; Thu, 18 Feb 2010 15:12:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B5E48FC08; Thu, 18 Feb 2010 15:12:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IFCmgx099949; Thu, 18 Feb 2010 15:12:48 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IFCmx2099942; Thu, 18 Feb 2010 15:12:48 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002181512.o1IFCmx2099942@svn.freebsd.org> From: Warner Losh Date: Thu, 18 Feb 2010 15:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204043 - in user/imp/tbemd: share/mk sys/dev/aac tools/regression/bin/sh/expansion usr.bin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 15:12:48 -0000 Author: imp Date: Thu Feb 18 15:12:48 2010 New Revision: 204043 URL: http://svn.freebsd.org/changeset/base/204043 Log: Merge from head. Added: user/imp/tbemd/tools/regression/bin/sh/expansion/arith3.0 - copied unchanged from r204030, head/tools/regression/bin/sh/expansion/arith3.0 Modified: user/imp/tbemd/share/mk/bsd.prog.mk user/imp/tbemd/share/mk/bsd.sys.mk user/imp/tbemd/share/mk/sys.mk user/imp/tbemd/sys/dev/aac/aac.c user/imp/tbemd/usr.bin/Makefile Directory Properties: user/imp/tbemd/ (props changed) Modified: user/imp/tbemd/share/mk/bsd.prog.mk ============================================================================== --- user/imp/tbemd/share/mk/bsd.prog.mk Thu Feb 18 15:00:43 2010 (r204042) +++ user/imp/tbemd/share/mk/bsd.prog.mk Thu Feb 18 15:12:48 2010 (r204043) @@ -17,6 +17,7 @@ NO_WERROR= .if defined(DEBUG_FLAGS) CFLAGS+=${DEBUG_FLAGS} +CXXFLAGS+=${DEBUG_FLAGS} .if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") CTFFLAGS+= -g Modified: user/imp/tbemd/share/mk/bsd.sys.mk ============================================================================== --- user/imp/tbemd/share/mk/bsd.sys.mk Thu Feb 18 15:00:43 2010 (r204042) +++ user/imp/tbemd/share/mk/bsd.sys.mk Thu Feb 18 15:12:48 2010 (r204043) @@ -43,7 +43,10 @@ CWARNFLAGS += -W -Wno-unused-parameter - . endif . if ${WARNS} >= 4 CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\ - -Wshadow -Wcast-align -Wunused-parameter + -Wshadow -Wunused-parameter +. if !defined(NO_WCAST_ALIGN) +CWARNFLAGS += -Wcast-align +. endif . endif # BDECFLAGS . if ${WARNS} >= 6 Modified: user/imp/tbemd/share/mk/sys.mk ============================================================================== --- user/imp/tbemd/share/mk/sys.mk Thu Feb 18 15:00:43 2010 (r204042) +++ user/imp/tbemd/share/mk/sys.mk Thu Feb 18 15:12:48 2010 (r204043) @@ -78,7 +78,7 @@ CFLAGS += -g .endif CXX ?= c++ -CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign} +CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} PO_CXXFLAGS ?= ${CXXFLAGS} CPP ?= cpp Modified: user/imp/tbemd/sys/dev/aac/aac.c ============================================================================== --- user/imp/tbemd/sys/dev/aac/aac.c Thu Feb 18 15:00:43 2010 (r204042) +++ user/imp/tbemd/sys/dev/aac/aac.c Thu Feb 18 15:12:48 2010 (r204043) @@ -2352,8 +2352,9 @@ aac_timeout(struct aac_softc *sc) /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) { cm->cm_flags |= AAC_CMD_TIMEDOUT; device_printf(sc->aac_dev, - "COMMAND %p TIMEOUT AFTER %d SECONDS\n", - cm, (int)(time_uptime-cm->cm_timestamp)); + "COMMAND %p (TYPE %d) TIMEOUT AFTER %d SECONDS\n", + cm, cm->cm_fib->Header.Command, + (int)(time_uptime-cm->cm_timestamp)); AAC_PRINT_FIB(sc, cm->cm_fib); timedout++; } Copied: user/imp/tbemd/tools/regression/bin/sh/expansion/arith3.0 (from r204030, head/tools/regression/bin/sh/expansion/arith3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/tools/regression/bin/sh/expansion/arith3.0 Thu Feb 18 15:12:48 2010 (r204043, copy of r204030, head/tools/regression/bin/sh/expansion/arith3.0) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +failures=0 + +check() { + if [ $(($1)) != $2 ]; then + failures=$((failures+1)) + echo "For $1, expected $2 actual $(($1))" + fi +} + +check "1 << 1 + 1 | 1" 5 + +exit $((failures != 0)) Modified: user/imp/tbemd/usr.bin/Makefile ============================================================================== --- user/imp/tbemd/usr.bin/Makefile Thu Feb 18 15:00:43 2010 (r204042) +++ user/imp/tbemd/usr.bin/Makefile Thu Feb 18 15:12:48 2010 (r204043) @@ -5,7 +5,7 @@ # XXX MISSING: deroff diction graph learn plot # spell spline struct xsend -# XXX Use GNU versions: apropos bc dc diff grep ld man patch whatis +# XXX Use GNU versions: apropos diff grep ld man patch whatis # Moved to secure: bdes # From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 16:25:38 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD9ED106566C; Thu, 18 Feb 2010 16:25:38 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC9528FC1D; Thu, 18 Feb 2010 16:25:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IGPcRI016380; Thu, 18 Feb 2010 16:25:38 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IGPcpF016375; Thu, 18 Feb 2010 16:25:38 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201002181625.o1IGPcpF016375@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 18 Feb 2010 16:25:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204047 - in user/luigi/ipfw3-head: sbin/ipfw sys/netinet sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 16:25:38 -0000 Author: luigi Date: Thu Feb 18 16:25:38 2010 New Revision: 204047 URL: http://svn.freebsd.org/changeset/base/204047 Log: corrections to the previous version -- don't do floating point in the kernel! Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Modified: user/luigi/ipfw3-head/sbin/ipfw/dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Thu Feb 18 16:23:13 2010 (r204046) +++ user/luigi/ipfw3-head/sbin/ipfw/dummynet.c Thu Feb 18 16:25:38 2010 (r204047) @@ -366,8 +366,8 @@ list_pipes(struct dn_id *oid, struct dn_ flush_buf(buf); print_extra_delay_parms((struct dn_profile *)oid); } + flush_buf(buf); // XXX does it really go here ? } - flush_buf(buf); } /* @@ -576,7 +576,8 @@ compare_points(const void *vp1, const vo #define ED_EFMT(s) EX_DATAERR,"error in %s at line %d: "#s,filename,lineno static void -load_extra_delays(const char *filename, struct dn_profile *p) +load_extra_delays(const char *filename, struct dn_profile *p, + struct dn_link *link) { char line[ED_MAX_LINE_LEN]; FILE *f; @@ -591,6 +592,10 @@ load_extra_delays(const char *filename, struct point points[ED_MAX_SAMPLES_NO]; int points_no = 0; + if (link == NULL) + return; /*XXX error */ + p->link_nr = link->link_nr; + profile_name[0] = '\0'; f = fopen(filename, "r"); if (f == NULL) @@ -1098,7 +1103,7 @@ end_mask: { pf = o_next(&buf, sizeof(*pf), DN_PROFILE); NEED1("extra delay needs the file name\n"); - load_extra_delays(av[0], pf); + load_extra_delays(av[0], pf, p); --ac; ++av; } break; Modified: user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h Thu Feb 18 16:23:13 2010 (r204046) +++ user/luigi/ipfw3-head/sys/netinet/ip_dummynet.h Thu Feb 18 16:25:38 2010 (r204047) @@ -77,11 +77,15 @@ enum { DN_CMD_DELETE, /* subtype + list of entries */ DN_CMD_GET, /* subtype + list of entries */ DN_CMD_FLUSH, - /* for compatibility with FreeBSD 7.2/8 */ DN_COMPAT_PIPE, DN_COMPAT_QUEUE, DN_GET_COMPAT, + + /* special commands for emulation of sysctl variables */ + DN_SYSCTL_GET, + DN_SYSCTL_SET, + DN_LAST, }; @@ -141,7 +145,10 @@ struct dn_fs { */ int par[4]; - /* RED/GRED parameters */ + /* RED/GRED parameters. + * weight and probabilities are in the range 0..1 represented + * in fixed point arithmetic with SCALE_RED decimal bits. + */ #define SCALE_RED 16 #define SCALE(x) ( (x) << SCALE_RED ) #define SCALE_VAL(x) ( (x) >> SCALE_RED ) @@ -186,7 +193,9 @@ struct dn_sch { }; -/* A delay profile is attached to a link */ +/* A delay profile is attached to a link. + * Note that a profile, as any other object, cannot be longer than 2^16 + */ #define ED_MAX_SAMPLES_NO 1024 struct dn_profile { struct dn_id oid; @@ -195,7 +204,7 @@ struct dn_profile { char name[ED_MAX_NAME_LEN]; int link_nr; int loss_level; - int bandwidth; + int bandwidth; // XXX maybe not needed ? int samples_no; /* actual length of samples[] */ int samples[ED_MAX_SAMPLES_NO]; /* may be shorter */ }; Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Thu Feb 18 16:23:13 2010 (r204046) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_glue.c Thu Feb 18 16:25:38 2010 (r204047) @@ -455,6 +455,7 @@ dn_compat_config_profile(struct dn_profi pf->loss_level = p8->loss_level; pf->bandwidth = p->bandwidth; pf->samples_no = p8->samples_no; + strncpy(pf->name, p8->name,sizeof(pf->name)); bcopy(p8->samples, pf->samples, sizeof(pf->samples)); return 0; @@ -600,7 +601,7 @@ dn_c_copy_pipe(struct dn_schk *s, struct if (!is7) { if (s->profile) { struct dn_profile *pf = s->profile; - strncpy(pf->name,pipe8->name,sizeof(pf->name)); + strncpy(pipe8->name, pf->name, sizeof(pf->name)); pipe8->loss_level = pf->loss_level; pipe8->samples_no = pf->samples_no; } Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Thu Feb 18 16:23:13 2010 (r204046) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Thu Feb 18 16:25:38 2010 (r204047) @@ -823,6 +823,29 @@ copy_q(struct copy_args *a, struct dn_fs return 0; } +/* + * This routine only copies the initial part of a profile ? XXX + */ +static int +copy_profile(struct copy_args *a, struct dn_profile *p) +{ + int have = a->end - *a->start; + /* XXX here we check for max length */ + int profile_len = sizeof(struct dn_profile) - + ED_MAX_SAMPLES_NO*sizeof(int); + + if (p == NULL) + return 0; + if (have < profile_len) { + D("error have %d need %d", have, profile_len); + return 1; + } + bcopy(p, *a->start, profile_len); + ((struct dn_id *)(*a->start))->len = profile_len; + *a->start += profile_len; + return 0; +} + static int copy_flowset(struct copy_args *a, struct dn_fsk *fs, int flags) { @@ -910,6 +933,8 @@ copy_data_helper(void *_o, void *_arg) if (copy_obj(a->start, a->end, &s->link, "link", s->sch.sched_nr)) return DNHT_SCAN_END; + if (copy_profile(a, s->profile)) + return DNHT_SCAN_END; if (copy_flowset(a, s->fs, 0)) return DNHT_SCAN_END; } @@ -942,31 +967,33 @@ locate_scheduler(int i) return dn_ht_find(dn_cfg.schedhash, i, 0, NULL); } +/* + * red parameters are in fixed point arithmetic. + */ static int config_red(struct dn_fsk *fs) { - double s, idle, weight; + int64_t s, idle, weight, w0; int t, i; fs->w_q = fs->fs.w_q; fs->max_p = fs->fs.max_p; D("called"); /* Doing stuff that was in userland */ - if (fs->sched->link.bandwidth <= 0) - s = 0; - else - s = hz * dn_cfg.red_avg_pkt_size * 8 / fs->sched->link.bandwidth; - - idle = s * 3. / fs->fs.w_q; - fs->lookup_step = (int)idle / dn_cfg.red_lookup_depth; + i = fs->sched->link.bandwidth; + s = (i <= 0) ? 0 : + hz * dn_cfg.red_avg_pkt_size * 8 * SCALE(1) / i; + + idle = (s * 3) / fs->w_q; /* s, fs->w_q scaled; idle not scaled */ + fs->lookup_step = idle / dn_cfg.red_lookup_depth; + /* fs->lookup_step not scaled, */ if (!fs->lookup_step) fs->lookup_step = 1; - weight = 1 - fs->w_q; + w0 = weight = SCALE(1) - fs->w_q; //fs->w_q scaled for (t = fs->lookup_step; t > 1; --t) - weight *= 1 - fs->w_q; - - fs->lookup_weight = (int)(weight * (1 << SCALE_RED)); + weight = SCALE_MUL(weight, w0); + fs->lookup_weight = (int)(weight); // scaled /* Now doing stuff that was in kerneland */ fs->min_th = SCALE(fs->fs.min_th); @@ -1420,7 +1447,7 @@ static int config_profile(struct dn_profile *pf, struct dn_id *arg) { struct dn_schk *s; - int i; + int i, olen, err = 0; if (pf->oid.len < sizeof(*pf)) { D("short profile len %d", pf->oid.len); @@ -1431,12 +1458,12 @@ config_profile(struct dn_profile *pf, st return EINVAL; /* XXX other sanity checks */ DN_BH_WLOCK(); + for (; i < 2*DN_MAX_ID; i += DN_MAX_ID) { s = locate_scheduler(i); if (s == NULL) { - DN_BH_WUNLOCK(); - D("no scheduler %d", i); - return EINVAL; + err = EINVAL; + break; } dn_cfg.id++; /* @@ -1448,21 +1475,21 @@ config_profile(struct dn_profile *pf, st free(s->profile, M_DUMMYNET); s->profile = NULL; } + if (pf->samples_no == 0) + continue; /* - * if we have a new profile, possibly allocate memory + * new profile, possibly allocate memory * and copy data. */ - if (pf->samples_no > 0) { - int olen; if (s->profile == NULL) s->profile = malloc(pf->oid.len, M_DUMMYNET, M_NOWAIT | M_ZERO); if (s->profile == NULL) { - DN_BH_WUNLOCK(); D("no memory for profile %d", i); - return ENOMEM; + err = ENOMEM; + break; } - /* preserve larger length */ + /* preserve larger length XXX double check */ olen = s->profile->oid.len; if (olen < pf->oid.len) olen = pf->oid.len; @@ -1470,7 +1497,7 @@ config_profile(struct dn_profile *pf, st s->profile->oid.len = olen; } DN_BH_WUNLOCK(); - return 0; + return err; } /* @@ -1527,7 +1554,15 @@ do_config(void *p, int l) default: D("cmd %d not implemented", o->type); break; - +#ifdef EMULATE_SYSCTL + /* sysctl emulation. + * if we recognize the command, jump to the correct + * handler and return + */ + case DN_SYSCTL_SET: + err = kesysctl_set_w32(p); + return err; +#endif case DN_CMD_CONFIG: /* simply a header */ break; @@ -1596,6 +1631,8 @@ static int compute_space(struct dn_id *cmd, int *to_copy) { int x = 0, need = 0; + int profile_size = sizeof(struct dn_profile) - + ED_MAX_SAMPLES_NO*sizeof(int); /* NOTE about compute space: * NP = dn_cfg.schk_count @@ -1626,16 +1663,19 @@ compute_space(struct dn_id *cmd, int *to switch (cmd->subtype) { default: return -1; + /* XXX where do LINK and SCH differ ? */ case DN_LINK: /* pipe show */ - x = DN_C_LINK /*| DN_C_FS*/ | DN_C_SCH | DN_C_FLOW; - need += dn_cfg.schk_count * sizeof(struct dn_fs) / 2; + x = DN_C_LINK | DN_C_SCH | DN_C_FLOW; + need += dn_cfg.schk_count * + (sizeof(struct dn_fs) + profile_size) / 2; need += dn_cfg.si_count * max_qlen; need += dn_cfg.fsk_count * sizeof(uint32_t); break; case DN_SCH: /* sched show */ - need += dn_cfg.schk_count * sizeof(struct dn_fs) / 2; + need += dn_cfg.schk_count * + (sizeof(struct dn_fs) + profile_size) / 2; need += dn_cfg.fsk_count * sizeof(uint32_t); - x = DN_C_SCH | DN_C_LINK | DN_C_FLOW /*|| DN_C_QUEUE*/; + x = DN_C_SCH | DN_C_LINK | DN_C_FLOW; break; case DN_FS: /* queue show */ x = DN_C_FS | DN_C_QUEUE; @@ -1679,9 +1719,18 @@ dummynet_get(struct sockopt *sopt, void /* save and restore original sopt_valsize around copyin */ sopt_valsize = sopt->sopt_valsize; if (!compat) { - D("standard mode"); - error = sooptcopyin(sopt, &cmd, sizeof(cmd), sizeof(cmd)); +#ifdef EMULATE_SYSCTL + /* sysctl emulation. + * if we recognize the command, jump to the correct + * handler and return + */ + if (cmd.type == DN_SYSCTL_GET) { + //jump to sysctl handler + error = kesysctl_get_w32(sopt); + return error; + } +#endif sopt->sopt_valsize = sopt_valsize; if (error) return error; From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 17:11:06 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F917106566C; Thu, 18 Feb 2010 17:11:06 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D21E8FC13; Thu, 18 Feb 2010 17:11:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IHB6jV026502; Thu, 18 Feb 2010 17:11:06 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IHB6Op026489; Thu, 18 Feb 2010 17:11:06 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002181711.o1IHB6Op026489@svn.freebsd.org> From: Warner Losh Date: Thu, 18 Feb 2010 17:11:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204049 - in user/imp/tbemd: release/scripts sys/amd64/amd64 sys/conf sys/i386/i386 sys/i386/xen sys/kern sys/mips/mips sys/netinet sys/powerpc/aim usr.bin/kdump X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 17:11:06 -0000 Author: imp Date: Thu Feb 18 17:11:06 2010 New Revision: 204049 URL: http://svn.freebsd.org/changeset/base/204049 Log: Merge to head 204047 Added: user/imp/tbemd/release/scripts/make-memstick.sh - copied unchanged from r204047, head/release/scripts/make-memstick.sh Modified: user/imp/tbemd/sys/amd64/amd64/pmap.c user/imp/tbemd/sys/conf/files.mips user/imp/tbemd/sys/conf/kmod.mk user/imp/tbemd/sys/i386/i386/pmap.c user/imp/tbemd/sys/i386/xen/pmap.c user/imp/tbemd/sys/kern/link_elf_obj.c user/imp/tbemd/sys/mips/mips/elf_machdep.c user/imp/tbemd/sys/netinet/sctp_indata.c user/imp/tbemd/sys/powerpc/aim/mmu_oea.c user/imp/tbemd/sys/powerpc/aim/mmu_oea64.c user/imp/tbemd/usr.bin/kdump/kdump.c Directory Properties: user/imp/tbemd/ (props changed) Copied: user/imp/tbemd/release/scripts/make-memstick.sh (from r204047, head/release/scripts/make-memstick.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/imp/tbemd/release/scripts/make-memstick.sh Thu Feb 18 17:11:06 2010 (r204049, copy of r204047, head/release/scripts/make-memstick.sh) @@ -0,0 +1,83 @@ +#!/bin/sh +# +# This script generates a "memstick image" (image that can be copied to a +# USB memory stick) from a directory tree. Note that the script does not +# clean up after itself very well for error conditions on purpose so the +# problem can be diagnosed (full filesystem most likely but ...). +# +# Usage: make-memstick.sh +# +# $FreeBSD$ +# + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +BLOCKSIZE=10240 + +if [ $# -ne 2 ]; then + echo "make-memstick.sh /path/to/directory /path/to/image/file" + exit 1 +fi + +tempfile="${2}.$$" + +if [ ! -d ${1} ]; then + echo "${1} must be a directory" + exit 1 +fi + +if [ -e ${2} ]; then + echo "won't overwrite ${2}" + exit 1 +fi + +rm -f ${tempfile} +makefs ${tempfile} ${1} +if [ $? -ne 0 ]; then + echo "makefs failed" + exit 1 +fi + +# +# Use $BLOCKSIZE for transfers to improve efficiency. When calculating +# how many blocks to transfer "+ 2" is to account for truncation in the +# division and to provide space for the label. +# + +filesize=`stat -f "%z" ${tempfile}` +blocks=$(($filesize / ${BLOCKSIZE} + 2)) +dd if=/dev/zero of=${2} bs=${BLOCKSIZE} count=${blocks} +if [ $? -ne 0 ]; then + echo "creation of image file failed" + exit 1 +fi + +unit=`mdconfig -a -t vnode -f ${2}` +if [ $? -ne 0 ]; then + echo "mdconfig failed" + exit 1 +fi + +fdisk -BIq /dev/${unit} +if [ $? -ne 0 ]; then + echo "fdisk failed" + exit 1 +fi + +bsdlabel -B -w /dev/${unit} +if [ $? -ne 0 ]; then + echo "bsdlabel failed" + exit 1 +fi + +dd if=${tempfile} of=/dev/${unit}a bs=$BLOCKSIZE conv=sync +if [ $? -ne 0 ]; then + echo "copying filesystem into image file failed" + exit 1 +fi + +mdconfig -d -u ${unit} + +rm -f ${tempfile} + Modified: user/imp/tbemd/sys/amd64/amd64/pmap.c ============================================================================== --- user/imp/tbemd/sys/amd64/amd64/pmap.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/amd64/amd64/pmap.c Thu Feb 18 17:11:06 2010 (r204049) @@ -151,7 +151,11 @@ __FBSDID("$FreeBSD$"); #endif #if !defined(DIAGNOSTIC) +#ifdef __GNUC_GNU_INLINE__ +#define PMAP_INLINE inline +#else #define PMAP_INLINE extern inline +#endif #else #define PMAP_INLINE #endif Modified: user/imp/tbemd/sys/conf/files.mips ============================================================================== --- user/imp/tbemd/sys/conf/files.mips Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/conf/files.mips Thu Feb 18 17:11:06 2010 (r204049) @@ -89,6 +89,8 @@ libkern/umoddi3.c optional isa_mips32 #libkern/mips/strcmp.S standard #libkern/mips/strncmp.S standard +kern/link_elf_obj.c standard + dev/cfe/cfe_api.c optional cfe dev/cfe/cfe_console.c optional cfe_console dev/cfe/cfe_env.c optional cfe_env Modified: user/imp/tbemd/sys/conf/kmod.mk ============================================================================== --- user/imp/tbemd/sys/conf/kmod.mk Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/conf/kmod.mk Thu Feb 18 17:11:06 2010 (r204049) @@ -128,6 +128,10 @@ CFLAGS+= -fno-omit-frame-pointer CFLAGS+= -mlongcall -fno-omit-frame-pointer .endif +.if ${MACHINE_ARCH} == "mips" +CFLAGS+= -G0 -fno-pic -mno-abicalls -mlong-calls +.endif + .if defined(FIRMWS) .if !exists(@) ${KMOD:S/$/.c/}: @ @@ -174,7 +178,7 @@ ${PROG}.symbols: ${FULLPROG} ${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET} .endif -.if ${MACHINE_CPUARCH} != amd64 +.if ${MACHINE_CPUARCH} != amd64 && ${MACHINE_ARCH} != mips ${FULLPROG}: ${KMOD}.kld ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld .if !defined(DEBUG_FLAGS) @@ -187,7 +191,7 @@ EXPORT_SYMS?= NO CLEANFILES+= export_syms .endif -.if ${MACHINE_CPUARCH} != amd64 +.if ${MACHINE_CPUARCH} != amd64 && ${MACHINE_CPUARCH} != mips ${KMOD}.kld: ${OBJS} .else ${FULLPROG}: ${OBJS} @@ -206,7 +210,8 @@ ${FULLPROG}: ${OBJS} export_syms | xargs -J% ${OBJCOPY} % ${.TARGET} .endif .endif -.if !defined(DEBUG_FLAGS) && ${MACHINE_CPUARCH} == amd64 +.if !defined(DEBUG_FLAGS) && \ + (${MACHINE_CPUARCH} == amd64 || ${MACHINE_CPUARCH} == mips) ${OBJCOPY} --strip-debug ${.TARGET} .endif Modified: user/imp/tbemd/sys/i386/i386/pmap.c ============================================================================== --- user/imp/tbemd/sys/i386/i386/pmap.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/i386/i386/pmap.c Thu Feb 18 17:11:06 2010 (r204049) @@ -162,7 +162,11 @@ __FBSDID("$FreeBSD$"); #endif #if !defined(DIAGNOSTIC) +#ifdef __GNUC_GNU_INLINE__ +#define PMAP_INLINE inline +#else #define PMAP_INLINE extern inline +#endif #else #define PMAP_INLINE #endif Modified: user/imp/tbemd/sys/i386/xen/pmap.c ============================================================================== --- user/imp/tbemd/sys/i386/xen/pmap.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/i386/xen/pmap.c Thu Feb 18 17:11:06 2010 (r204049) @@ -173,7 +173,11 @@ __FBSDID("$FreeBSD$"); #endif #if !defined(PMAP_DIAGNOSTIC) +#ifdef __GNUC_GNU_INLINE__ +#define PMAP_INLINE inline +#else #define PMAP_INLINE extern inline +#endif #else #define PMAP_INLINE #endif Modified: user/imp/tbemd/sys/kern/link_elf_obj.c ============================================================================== --- user/imp/tbemd/sys/kern/link_elf_obj.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/kern/link_elf_obj.c Thu Feb 18 17:11:06 2010 (r204049) @@ -853,8 +853,8 @@ link_elf_load_file(linker_class_t cls, c panic("lost relatab"); if (mapbase != (vm_offset_t)ef->address + mapsize) panic("mapbase 0x%lx != address %p + mapsize 0x%lx (0x%lx)\n", - mapbase, ef->address, mapsize, - (vm_offset_t)ef->address + mapsize); + (u_long)mapbase, ef->address, (u_long)mapsize, + (u_long)(vm_offset_t)ef->address + mapsize); /* Local intra-module relocations */ link_elf_reloc_local(lf); Modified: user/imp/tbemd/sys/mips/mips/elf_machdep.c ============================================================================== --- user/imp/tbemd/sys/mips/mips/elf_machdep.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/mips/mips/elf_machdep.c Thu Feb 18 17:11:06 2010 (r204049) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef __mips_n64 struct sysentvec elf64_freebsd_sysvec = { @@ -163,7 +164,12 @@ elf_reloc_internal(linker_file_t lf, Elf Elf_Addr addend = (Elf_Addr)0; Elf_Word rtype = (Elf_Word)0, symidx; const Elf_Rel *rel; - const Elf_Rela *rela; + + /* + * Stash R_MIPS_HI16 info so we can use it when processing R_MIPS_LO16 + */ + static Elf_Addr ahl; + static Elf_Addr *where_hi16; switch (type) { case ELF_RELOC_REL: @@ -173,108 +179,63 @@ elf_reloc_internal(linker_file_t lf, Elf rtype = ELF_R_TYPE(rel->r_info); symidx = ELF_R_SYM(rel->r_info); break; - case ELF_RELOC_RELA: - rela = (const Elf_Rela *)data; - where = (Elf_Addr *) (relocbase + rela->r_offset); - addend = rela->r_addend; - rtype = ELF_R_TYPE(rela->r_info); - symidx = ELF_R_SYM(rela->r_info); - break; default: panic("unknown reloc type %d\n", type); } - if (local) { -#if 0 /* TBD */ - if (rtype == R_386_RELATIVE) { /* A + B */ - addr = elf_relocaddr(lf, relocbase + addend); - if (*where != addr) - *where = addr; - } - return (0); -#endif - } - switch (rtype) { + case R_MIPS_NONE: /* none */ + break; - case R_MIPS_NONE: /* none */ - break; + case R_MIPS_32: /* S + A */ + addr = lookup(lf, symidx, 1); + if (addr == 0) + return (-1); + addr += addend; + if (*where != addr) + *where = addr; + break; - case R_MIPS_16: /* S + sign-extend(A) */ - /* - * There shouldn't be R_MIPS_16 relocs in kernel objects. - */ - printf("kldload: unexpected R_MIPS_16 relocation\n"); - return -1; - break; - - case R_MIPS_32: /* S + A - P */ - addr = lookup(lf, symidx, 1); - if (addr == 0) - return -1; - addr += addend; - if (*where != addr) - *where = addr; - break; - - case R_MIPS_REL32: /* A - EA + S */ - /* - * There shouldn't be R_MIPS_REL32 relocs in kernel objects? - */ - printf("kldload: unexpected R_MIPS_REL32 relocation\n"); - return -1; - break; - - case R_MIPS_26: /* ((A << 2) | (P & 0xf0000000) + S) >> 2 */ - break; - - case R_MIPS_HI16: - /* extern/local: ((AHL + S) - ((short)(AHL + S)) >> 16 */ - /* _gp_disp: ((AHL + GP - P) - (short)(AHL + GP - P)) >> 16 */ - break; - - case R_MIPS_LO16: - /* extern/local: AHL + S */ - /* _gp_disp: AHL + GP - P + 4 */ - break; - - case R_MIPS_GPREL16: - /* extern/local: ((AHL + S) - ((short)(AHL + S)) >> 16 */ - /* _gp_disp: ((AHL + GP - P) - (short)(AHL + GP - P)) >> 16 */ - break; - - case R_MIPS_LITERAL: /* sign-extend(A) + L */ - break; - - case R_MIPS_GOT16: /* external: G */ - /* local: tbd */ - break; - - case R_MIPS_PC16: /* sign-extend(A) + S - P */ - break; - - case R_MIPS_CALL16: /* G */ - break; - - case R_MIPS_GPREL32: /* A + S + GP0 - GP */ - break; - - case R_MIPS_GOTHI16: /* (G - (short)G) >> 16 + A */ - break; - - case R_MIPS_GOTLO16: /* G & 0xffff */ - break; - - case R_MIPS_CALLHI16: /* (G - (short)G) >> 16 + A */ - break; - - case R_MIPS_CALLLO16: /* G & 0xffff */ - break; - - default: - printf("kldload: unexpected relocation type %d\n", - rtype); + case R_MIPS_26: /* ((A << 2) | (P & 0xf0000000) + S) >> 2 */ + addr = lookup(lf, symidx, 1); + if (addr == 0) return (-1); + + addend &= 0x03ffffff; + addend <<= 2; + + addr += ((Elf_Addr)where & 0xf0000000) | addend; + addr >>= 2; + + *where &= ~0x03ffffff; + *where |= addr & 0x03ffffff; + break; + + case R_MIPS_HI16: /* ((AHL + S) - ((short)(AHL + S)) >> 16 */ + ahl = addend << 16; + where_hi16 = where; + break; + + case R_MIPS_LO16: /* AHL + S */ + ahl += (int16_t)addend; + addr = lookup(lf, symidx, 1); + if (addr == 0) + return (-1); + + addend &= 0xffff0000; + addend |= (uint16_t)(ahl + addr); + *where = addend; + + addend = *where_hi16; + addend &= 0xffff0000; + addend |= ((ahl + addr) - (int16_t)(ahl + addr)) >> 16; + *where_hi16 = addend; + break; + + default: + printf("kldload: unexpected relocation type %d\n", + rtype); + return (-1); } return(0); } @@ -299,6 +260,11 @@ int elf_cpu_load_file(linker_file_t lf __unused) { + /* + * Sync the I and D caches to make sure our relocations are visible. + */ + mips_icache_sync_all(); + return (0); } Modified: user/imp/tbemd/sys/netinet/sctp_indata.c ============================================================================== --- user/imp/tbemd/sys/netinet/sctp_indata.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/netinet/sctp_indata.c Thu Feb 18 17:11:06 2010 (r204049) @@ -3513,7 +3513,7 @@ sctp_handle_segments(struct mbuf *m, int static void sctp_check_for_revoked(struct sctp_tcb *stcb, struct sctp_association *asoc, uint32_t cumack, - u_long biggest_tsn_acked) + uint32_t biggest_tsn_acked) { struct sctp_tmit_chunk *tp1; int tot_revoked = 0; @@ -3595,7 +3595,7 @@ sctp_check_for_revoked(struct sctp_tcb * static void sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, - u_long biggest_tsn_acked, u_long biggest_tsn_newly_acked, u_long this_sack_lowest_newack, int accum_moved) + uint32_t biggest_tsn_acked, uint32_t biggest_tsn_newly_acked, uint32_t this_sack_lowest_newack, int accum_moved) { struct sctp_tmit_chunk *tp1; int strike_flag = 0; @@ -4781,7 +4781,7 @@ again: static void sctp_check_for_nr_revoked(struct sctp_tcb *stcb, struct sctp_association *asoc, uint32_t cumack, - u_long biggest_tsn_acked) + uint32_t biggest_tsn_acked) { struct sctp_tmit_chunk *tp1; Modified: user/imp/tbemd/sys/powerpc/aim/mmu_oea.c ============================================================================== --- user/imp/tbemd/sys/powerpc/aim/mmu_oea.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/powerpc/aim/mmu_oea.c Thu Feb 18 17:11:06 2010 (r204049) @@ -1729,6 +1729,10 @@ moea_remove_all(mmu_t mmu, vm_page_t m) moea_pvo_remove(pvo, -1); PMAP_UNLOCK(pmap); } + if ((m->flags & PG_WRITEABLE) && moea_is_modified(mmu, m)) { + moea_attr_clear(m, LPTE_CHG); + vm_page_dirty(m); + } vm_page_flag_clear(m, PG_WRITEABLE); } @@ -2203,10 +2207,8 @@ moea_query_bit(vm_page_t m, int ptebit) struct pvo_entry *pvo; struct pte *pt; -#if 0 if (moea_attr_fetch(m) & ptebit) return (TRUE); -#endif LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { MOEA_PVO_CHECK(pvo); /* sanity check */ Modified: user/imp/tbemd/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- user/imp/tbemd/sys/powerpc/aim/mmu_oea64.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/sys/powerpc/aim/mmu_oea64.c Thu Feb 18 17:11:06 2010 (r204049) @@ -172,6 +172,7 @@ va_to_vsid(pmap_t pm, vm_offset_t va) return ((pm->pm_sr[(uintptr_t)va >> ADDR_SR_SHFT]) & SR_VSID_MASK); } +#define PTESYNC() __asm __volatile("ptesync"); #define TLBSYNC() __asm __volatile("tlbsync; ptesync"); #define SYNC() __asm __volatile("sync"); #define EIEIO() __asm __volatile("eieio"); @@ -194,6 +195,7 @@ TLBIE(pmap_t pmap, vm_offset_t va) { vpn = (uint64_t)(va & ADDR_PIDX); if (pmap != NULL) vpn |= (va_to_vsid(pmap,va) << 28); + vpn &= ~(0xffffULL << 48); vpn_hi = (uint32_t)(vpn >> 32); vpn_lo = (uint32_t)vpn; @@ -201,8 +203,7 @@ TLBIE(pmap_t pmap, vm_offset_t va) { mtx_lock_spin(&tlbie_mutex); __asm __volatile("\ mfmsr %0; \ - clrldi %1,%0,49; \ - mtmsr %1; \ + mr %1, %0; \ insrdi %1,%5,1,0; \ mtmsrd %1; \ ptesync; \ @@ -215,7 +216,8 @@ TLBIE(pmap_t pmap, vm_offset_t va) { eieio; \ tlbsync; \ ptesync;" - : "=r"(msr), "=r"(scratch) : "r"(vpn_hi), "r"(vpn_lo), "r"(32), "r"(1)); + : "=r"(msr), "=r"(scratch) : "r"(vpn_hi), "r"(vpn_lo), "r"(32), "r"(1) + : "memory"); mtx_unlock_spin(&tlbie_mutex); } @@ -226,13 +228,13 @@ TLBIE(pmap_t pmap, vm_offset_t va) { #define VSID_TO_SR(vsid) ((vsid) & 0xf) #define VSID_TO_HASH(vsid) (((vsid) >> 4) & 0xfffff) -#define PVO_PTEGIDX_MASK 0x007 /* which PTEG slot */ -#define PVO_PTEGIDX_VALID 0x008 /* slot is valid */ -#define PVO_WIRED 0x010 /* PVO entry is wired */ -#define PVO_MANAGED 0x020 /* PVO entry is managed */ -#define PVO_BOOTSTRAP 0x080 /* PVO entry allocated during +#define PVO_PTEGIDX_MASK 0x007UL /* which PTEG slot */ +#define PVO_PTEGIDX_VALID 0x008UL /* slot is valid */ +#define PVO_WIRED 0x010UL /* PVO entry is wired */ +#define PVO_MANAGED 0x020UL /* PVO entry is managed */ +#define PVO_BOOTSTRAP 0x080UL /* PVO entry allocated during bootstrap */ -#define PVO_FAKE 0x100 /* fictitious phys page */ +#define PVO_FAKE 0x100UL /* fictitious phys page */ #define PVO_VADDR(pvo) ((pvo)->pvo_vaddr & ~ADDR_POFF) #define PVO_ISFAKE(pvo) ((pvo)->pvo_vaddr & PVO_FAKE) #define PVO_PTEGIDX_GET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK) @@ -512,23 +514,6 @@ moea64_attr_save(vm_page_t m, u_int64_t m->md.mdpg_attrs |= ptebit; } -static __inline int -moea64_pte_compare(const struct lpte *pt, const struct lpte *pvo_pt) -{ - if (pt->pte_hi == pvo_pt->pte_hi) - return (1); - - return (0); -} - -static __inline int -moea64_pte_match(struct lpte *pt, uint64_t vsid, vm_offset_t va, int which) -{ - return (pt->pte_hi & ~LPTE_VALID) == - ((vsid << LPTE_VSID_SHIFT) | - ((uint64_t)(va >> ADDR_API_SHFT64) & LPTE_API) | which); -} - static __inline void moea64_pte_create(struct lpte *pt, uint64_t vsid, vm_offset_t va, uint64_t pte_lo) @@ -583,7 +568,7 @@ moea64_pte_set(struct lpte *pt, struct l pt->pte_lo = pvo_pt->pte_lo; EIEIO(); pt->pte_hi = pvo_pt->pte_hi; - SYNC(); + PTESYNC(); moea64_pte_valid++; } @@ -602,7 +587,6 @@ moea64_pte_unset(struct lpte *pt, struct * Invalidate the pte. */ pt->pte_hi &= ~LPTE_VALID; - TLBIE(pmap,va); /* @@ -621,6 +605,8 @@ moea64_pte_change(struct lpte *pt, struc */ moea64_pte_unset(pt, pvo_pt, pmap, va); moea64_pte_set(pt, pvo_pt); + if (pmap == kernel_pmap) + isync(); } static __inline uint64_t @@ -701,7 +687,7 @@ moea64_bridge_cpu_bootstrap(mmu_t mmup, for (i = 0; i < 16; i++) { mtsrin(i << ADDR_SR_SHFT, kernel_pmap->pm_sr[i]); } - __asm __volatile ("sync; mtsdr1 %0; isync" + __asm __volatile ("ptesync; mtsdr1 %0; isync" :: "r"((u_int)moea64_pteg_table | (32 - cntlzw(moea64_pteg_mask >> 11)))); tlbia(); @@ -1135,7 +1121,7 @@ void moea64_set_scratchpage_pa(int which EIEIO(); moea64_scratchpage_pte[which]->pte_hi |= LPTE_VALID; - TLBIE(kernel_pmap, moea64_scratchpage_va[which]); + PTESYNC(); isync(); } void @@ -1155,8 +1141,6 @@ moea64_copy_page(mmu_t mmu, vm_page_t ms kcopy((void *)moea64_scratchpage_va[0], (void *)moea64_scratchpage_va[1], PAGE_SIZE); - __syncicache((void *)moea64_scratchpage_va[1],PAGE_SIZE); - mtx_unlock(&moea64_scratchpage_mtx); } @@ -1174,8 +1158,6 @@ moea64_zero_page_area(mmu_t mmu, vm_page moea64_set_scratchpage_pa(0,pa); bzero((caddr_t)moea64_scratchpage_va[0] + off, size); - __syncicache((void *)moea64_scratchpage_va[0],PAGE_SIZE); - mtx_unlock(&moea64_scratchpage_mtx); } @@ -1266,9 +1248,6 @@ moea64_enter_locked(pmap_t pmap, vm_offs error = moea64_pvo_enter(pmap, zone, pvo_head, va, VM_PAGE_TO_PHYS(m), pte_lo, pvo_flags); - if (pmap == kernel_pmap) - TLBIE(pmap, va); - /* * Flush the page from the instruction cache if this page is * mapped executable and cacheable. @@ -1281,6 +1260,7 @@ moea64_enter_locked(pmap_t pmap, vm_offs static void moea64_syncicache(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t sz) { + /* * This is much trickier than on older systems because * we can't sync the icache on physical addresses directly @@ -1303,8 +1283,9 @@ moea64_syncicache(pmap_t pmap, vm_offset mtx_lock(&moea64_scratchpage_mtx); - moea64_set_scratchpage_pa(1,pa); - __syncicache((void *)moea64_scratchpage_va[1], sz); + moea64_set_scratchpage_pa(1,pa & ~ADDR_POFF); + __syncicache((void *)(moea64_scratchpage_va[1] + + (va & ADDR_POFF)), sz); mtx_unlock(&moea64_scratchpage_mtx); } @@ -1441,8 +1422,6 @@ moea64_uma_page_alloc(uma_zone_t zone, i &moea64_pvo_kunmanaged, va, VM_PAGE_TO_PHYS(m), LPTE_M, PVO_WIRED | PVO_BOOTSTRAP); - TLBIE(kernel_pmap, va); - if (needed_lock) PMAP_UNLOCK(kernel_pmap); @@ -1531,7 +1510,7 @@ moea64_remove_write(mmu_t mmu, vm_page_t lo |= pvo->pvo_pte.lpte.pte_lo; pvo->pvo_pte.lpte.pte_lo &= ~LPTE_CHG; moea64_pte_change(pt, &pvo->pvo_pte.lpte, - pvo->pvo_pmap, pvo->pvo_vaddr); + pvo->pvo_pmap, PVO_VADDR(pvo)); } UNLOCK_TABLE(); } @@ -1590,8 +1569,6 @@ moea64_kenter(mmu_t mmu, vm_offset_t va, &moea64_pvo_kunmanaged, va, pa, pte_lo, PVO_WIRED | VM_PROT_EXECUTE); - TLBIE(kernel_pmap, va); - if (error != 0 && error != ENOENT) panic("moea64_kenter: failed to enter va %#x pa %#x: %d", va, pa, error); @@ -1823,7 +1800,7 @@ moea64_protect(mmu_t mmu, pmap_t pm, vm_ */ if (pt != NULL) { moea64_pte_change(pt, &pvo->pvo_pte.lpte, - pvo->pvo_pmap, pvo->pvo_vaddr); + pvo->pvo_pmap, PVO_VADDR(pvo)); if ((pvo->pvo_pte.lpte.pte_lo & (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) { moea64_syncicache(pm, sva, @@ -1927,6 +1904,10 @@ moea64_remove_all(mmu_t mmu, vm_page_t m moea64_pvo_remove(pvo, -1); PMAP_UNLOCK(pmap); } + if ((m->flags & PG_WRITEABLE) && moea64_is_modified(mmu, m)) { + moea64_attr_clear(m, LPTE_CHG); + vm_page_dirty(m); + } vm_page_flag_clear(m, PG_WRITEABLE); } @@ -2107,7 +2088,7 @@ moea64_pvo_enter(pmap_t pm, uma_zone_t z first = 1; LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink); - if (pvo->pvo_pte.lpte.pte_lo & PVO_WIRED) + if (pvo->pvo_vaddr & PVO_WIRED) pm->pm_stats.wired_count++; pm->pm_stats.resident_count++; @@ -2122,6 +2103,9 @@ moea64_pvo_enter(pmap_t pm, uma_zone_t z moea64_pte_overflow++; } + if (pm == kernel_pmap) + isync(); + UNLOCK_TABLE(); return (first ? ENOENT : 0); @@ -2140,7 +2124,7 @@ moea64_pvo_remove(struct pvo_entry *pvo, pt = moea64_pvo_to_pte(pvo, pteidx); if (pt != NULL) { moea64_pte_unset(pt, &pvo->pvo_pte.lpte, pvo->pvo_pmap, - pvo->pvo_vaddr); + PVO_VADDR(pvo)); PVO_PTEGIDX_CLR(pvo); } else { moea64_pte_overflow--; @@ -2151,7 +2135,7 @@ moea64_pvo_remove(struct pvo_entry *pvo, * Update our statistics. */ pvo->pvo_pmap->pm_stats.resident_count--; - if (pvo->pvo_pte.lpte.pte_lo & PVO_WIRED) + if (pvo->pvo_vaddr & PVO_WIRED) pvo->pvo_pmap->pm_stats.wired_count--; /* @@ -2178,7 +2162,7 @@ moea64_pvo_remove(struct pvo_entry *pvo, */ LIST_REMOVE(pvo, pvo_olink); if (!(pvo->pvo_vaddr & PVO_BOOTSTRAP)) - uma_zfree(pvo->pvo_vaddr & PVO_MANAGED ? moea64_mpvo_zone : + uma_zfree((pvo->pvo_vaddr & PVO_MANAGED) ? moea64_mpvo_zone : moea64_upvo_zone, pvo); moea64_pvo_entries--; moea64_pvo_remove_calls++; @@ -2237,8 +2221,8 @@ moea64_pvo_to_pte(const struct pvo_entry int ptegidx; uint64_t vsid; - vsid = va_to_vsid(pvo->pvo_pmap, pvo->pvo_vaddr); - ptegidx = va_to_pteg(vsid, pvo->pvo_vaddr); + vsid = va_to_vsid(pvo->pvo_pmap, PVO_VADDR(pvo)); + ptegidx = va_to_pteg(vsid, PVO_VADDR(pvo)); pteidx = moea64_pvo_pte_index(pvo, ptegidx); } @@ -2325,10 +2309,8 @@ moea64_query_bit(vm_page_t m, u_int64_t struct pvo_entry *pvo; struct lpte *pt; -#if 0 if (moea64_attr_fetch(m) & ptebit) return (TRUE); -#endif LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { MOEA_PVO_CHECK(pvo); /* sanity check */ Modified: user/imp/tbemd/usr.bin/kdump/kdump.c ============================================================================== --- user/imp/tbemd/usr.bin/kdump/kdump.c Thu Feb 18 16:52:49 2010 (r204048) +++ user/imp/tbemd/usr.bin/kdump/kdump.c Thu Feb 18 17:11:06 2010 (r204049) @@ -1328,6 +1328,8 @@ ktrstruct(char *buf, size_t buflen) char *name, *data; size_t namelen, datalen; int i; + struct stat sb; + struct sockaddr_storage ss; for (name = buf, namelen = 0; namelen < buflen && name[namelen] != '\0'; @@ -1348,12 +1350,16 @@ ktrstruct(char *buf, size_t buflen) if (strcmp(name, "stat") == 0) { if (datalen != sizeof(struct stat)) goto invalid; - ktrstat((struct stat *)data); + memcpy(&sb, data, datalen); + ktrstat(&sb); } else if (strcmp(name, "sockaddr") == 0) { + if (datalen > sizeof(ss)) + goto invalid; + memcpy(&ss, data, datalen); if (datalen < sizeof(struct sockaddr) || - datalen != ((struct sockaddr *)(data))->sa_len) + datalen != ss.ss_len) goto invalid; - ktrsockaddr((struct sockaddr *)data); + ktrsockaddr((struct sockaddr *)&ss); } else { printf("unknown structure\n"); } From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 19:50:31 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BD4C1065676; Thu, 18 Feb 2010 19:50:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6CBE28FC15; Thu, 18 Feb 2010 19:50:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IJoVfW061701; Thu, 18 Feb 2010 19:50:31 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IJoVLa061699; Thu, 18 Feb 2010 19:50:31 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002181950.o1IJoVLa061699@svn.freebsd.org> From: Warner Losh Date: Thu, 18 Feb 2010 19:50:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204057 - user/imp/tbemd/bin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 19:50:31 -0000 Author: imp Date: Thu Feb 18 19:50:31 2010 New Revision: 204057 URL: http://svn.freebsd.org/changeset/base/204057 Log: Make this conform to style.Makefile(5), without overly bloating the diffs. Modified: user/imp/tbemd/bin/Makefile Modified: user/imp/tbemd/bin/Makefile ============================================================================== --- user/imp/tbemd/bin/Makefile Thu Feb 18 19:41:38 2010 (r204056) +++ user/imp/tbemd/bin/Makefile Thu Feb 18 19:50:31 2010 (r204057) @@ -40,19 +40,19 @@ SUBDIR= cat \ uuidgen .if ${MK_RCMDS} != "no" -SUBDIR += rcp +SUBDIR+= rcp .endif .if ${MK_SENDMAIL} != "no" -SUBDIR += rmail +SUBDIR+= rmail .endif .if ${MK_TCSH} != "no" -SUBDIR += csh +SUBDIR+= csh .endif .include -SUBDIR := ${SUBDIR:O} +SUBDIR:= ${SUBDIR:O} .include From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 19:52:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26C6F106566B; Thu, 18 Feb 2010 19:52:08 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17A9F8FC13; Thu, 18 Feb 2010 19:52:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IJq7WE062103; Thu, 18 Feb 2010 19:52:07 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IJq7Mb062101; Thu, 18 Feb 2010 19:52:07 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201002181952.o1IJq7Mb062101@svn.freebsd.org> From: Warner Losh Date: Thu, 18 Feb 2010 19:52:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204058 - user/imp/tbemd/sbin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 19:52:08 -0000 Author: imp Date: Thu Feb 18 19:52:07 2010 New Revision: 204058 URL: http://svn.freebsd.org/changeset/base/204058 Log: Make this conform more closely to style.Makefile(5). Submitted by: bde Modified: user/imp/tbemd/sbin/Makefile Modified: user/imp/tbemd/sbin/Makefile ============================================================================== --- user/imp/tbemd/sbin/Makefile Thu Feb 18 19:50:31 2010 (r204057) +++ user/imp/tbemd/sbin/Makefile Thu Feb 18 19:52:07 2010 (r204058) @@ -72,42 +72,42 @@ SUBDIR=adjkerntz \ umount \ .if ${MK_ATM} != "no" -SUBDIR += atm +SUBDIR+= atm .endif .if ${MK_CXX} != "no" -SUBDIR += devd +SUBDIR+= devd .endif .if ${MK_IPFILTER} != "no" -SUBDIR += ipf +SUBDIR+= ipf .endif .if ${MK_IPFW} != "no" -SUBDIR += ipfw -SUBDIR += natd +SUBDIR+= ipfw +SUBDIR+= natd .endif .if ${MK_PF} != "no" -SUBDIR += pfctl -SUBDIR += pflogd +SUBDIR+= pfctl +SUBDIR+= pflogd .endif .if ${MK_INET6} != "no" -SUBDIR += ping6 -SUBDIR += rtsol +SUBDIR+= ping6 +SUBDIR+= rtsol .endif .if ${MK_QUOTAS} != "no" -SUBDIR += quotacheck +SUBDIR+= quotacheck .endif .if ${MK_ROUTED} != "no" -SUBDIR += routed +SUBDIR+= routed .endif .include -SUBDIR := ${SUBDIR:O} +SUBDIR:= ${SUBDIR:O} .include From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 20:02:38 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A28FC1065676; Thu, 18 Feb 2010 20:02:38 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92FC98FC1B; Thu, 18 Feb 2010 20:02:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1IK2cir064463; Thu, 18 Feb 2010 20:02:38 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1IK2cOM064461; Thu, 18 Feb 2010 20:02:38 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002182002.o1IK2cOM064461@svn.freebsd.org> From: Kip Macy Date: Thu, 18 Feb 2010 20:02:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204059 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 20:02:38 -0000 Author: kmacy Date: Thu Feb 18 20:02:38 2010 New Revision: 204059 URL: http://svn.freebsd.org/changeset/base/204059 Log: skip flowtable lookup for local addresses on ipv6 Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.c Thu Feb 18 19:52:07 2010 (r204058) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.c Thu Feb 18 20:02:38 2010 (r204059) @@ -1053,6 +1053,10 @@ flowtable_lookup(struct flowtable *ft, s dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; + if (in6_localaddr(&dsin6->sin6_addr) || + in6_localaddr(&ssin6->sin6_addr)) + return (NULL); + flags |= FL_IPV6; hash = ipv6_flow_lookup_hash_internal(ssin6, dsin6, key, flags); } From owner-svn-src-user@FreeBSD.ORG Thu Feb 18 21:21:54 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EABFE106566B; Thu, 18 Feb 2010 21:21:54 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BFE2B8FC08; Thu, 18 Feb 2010 21:21:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1ILLsT9082034; Thu, 18 Feb 2010 21:21:54 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1ILLs24082031; Thu, 18 Feb 2010 21:21:54 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201002182121.o1ILLs24082031@svn.freebsd.org> From: Edwin Groothuis Date: Thu, 18 Feb 2010 21:21:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204062 - user/edwin/calendar X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2010 21:21:55 -0000 Author: edwin Date: Thu Feb 18 21:21:54 2010 New Revision: 204062 URL: http://svn.freebsd.org/changeset/base/204062 Log: Fix usage of -l when -U is used. Document -l and -U Modified: user/edwin/calendar/calendar.1 user/edwin/calendar/calendar.c Modified: user/edwin/calendar/calendar.1 ============================================================================== --- user/edwin/calendar/calendar.1 Thu Feb 18 21:14:29 2010 (r204061) +++ user/edwin/calendar/calendar.1 Thu Feb 18 21:21:54 2010 (r204062) @@ -54,6 +54,8 @@ .Ek .Oc .Op Fl W Ar num +.Op Fl U Ar UTF-offset +.Op Fl l Ar longitude .Sh DESCRIPTION The .Nm @@ -93,6 +95,12 @@ as the default calendar file. .Sm on .Xc For test purposes only: set date directly to argument values. +.It Fl l Ar longitude , Fl U Ar UTC-offset +Only one is needed: +Perform lunar and solar calculations from this longitude or from +this UTC offset. +If neither is specified, the calculations will be based on the +difference between UTC time and localtime. .It Fl W Ar num Print lines from today and the next .Ar num Modified: user/edwin/calendar/calendar.c ============================================================================== --- user/edwin/calendar/calendar.c Thu Feb 18 21:14:29 2010 (r204061) +++ user/edwin/calendar/calendar.c Thu Feb 18 21:21:54 2010 (r204062) @@ -174,7 +174,7 @@ main(int argc, char *argv[]) } else if (UTCoffset == UTCOFFSET_NOTSET) { /* Base on information given */ UTCoffset = eastlongitude / 15; - } else { + } else if (eastlongitude == LONGITUDE_NOTSET) { /* Base on information given */ eastlongitude = UTCoffset * 15; } @@ -218,9 +218,11 @@ static void __dead2 usage(void) { - fprintf(stderr, "%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n", "usage: calendar [-a] [-A days] [-B days] [-F friday] " "[-f calendarfile]", - " [-d] [-t dd[.mm[.year]]] [-W days]"); + " [-d] [-t dd[.mm[.year]]] [-W days]", + " [-U utcoffset] [-l longitude]" + ); exit(1); } From owner-svn-src-user@FreeBSD.ORG Fri Feb 19 01:09:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A97561065672; Fri, 19 Feb 2010 01:09:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 994A48FC12; Fri, 19 Feb 2010 01:09:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1J198Gf032705; Fri, 19 Feb 2010 01:09:08 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1J1984Z032703; Fri, 19 Feb 2010 01:09:08 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002190109.o1J1984Z032703@svn.freebsd.org> From: Kip Macy Date: Fri, 19 Feb 2010 01:09:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204078 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 01:09:08 -0000 Author: kmacy Date: Fri Feb 19 01:09:08 2010 New Revision: 204078 URL: http://svn.freebsd.org/changeset/base/204078 Log: - move in6_localaddr check out of the fast path and only check destination the source will of course be local if we're not forwarding Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.c Thu Feb 18 23:20:15 2010 (r204077) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.c Fri Feb 19 01:09:08 2010 (r204078) @@ -1053,10 +1053,6 @@ flowtable_lookup(struct flowtable *ft, s dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; - if (in6_localaddr(&dsin6->sin6_addr) || - in6_localaddr(&ssin6->sin6_addr)) - return (NULL); - flags |= FL_IPV6; hash = ipv6_flow_lookup_hash_internal(ssin6, dsin6, key, flags); } @@ -1133,6 +1129,15 @@ uncached: } #ifdef INET6 if (ssa->ss_family == AF_INET6) { + struct sockaddr_in6 *dsin6; + + dsin6 = (struct sockaddr_in6 *)dsa; + if (in6_localaddr(&dsin6->sin6_addr)) { + RTFREE(rt); + ro->ro_rt = NULL; + return (NULL); + } + if (rt->rt_flags & RTF_GATEWAY) l3addr = (struct sockaddr_storage *)rt->rt_gateway; From owner-svn-src-user@FreeBSD.ORG Fri Feb 19 01:13:37 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65520106566C; Fri, 19 Feb 2010 01:13:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 554728FC19; Fri, 19 Feb 2010 01:13:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1J1Db2U033730; Fri, 19 Feb 2010 01:13:37 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1J1DbN3033728; Fri, 19 Feb 2010 01:13:37 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002190113.o1J1DbN3033728@svn.freebsd.org> From: Kip Macy Date: Fri, 19 Feb 2010 01:13:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204079 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 01:13:37 -0000 Author: kmacy Date: Fri Feb 19 01:13:37 2010 New Revision: 204079 URL: http://svn.freebsd.org/changeset/base/204079 Log: put panic sanity check under INVARIANTS Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.c Fri Feb 19 01:09:08 2010 (r204078) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.c Fri Feb 19 01:13:37 2010 (r204079) @@ -1109,9 +1109,11 @@ uncached: * receive the route locked */ +#ifdef INVARIANTS if ((ro->ro_dst.sa_family != AF_INET) && (ro->ro_dst.sa_family != AF_INET6)) panic("sa_family == %d\n", ro->ro_dst.sa_family); +#endif ft->ft_rtalloc(ro, hash, fibnum); if (ro->ro_rt == NULL) From owner-svn-src-user@FreeBSD.ORG Fri Feb 19 10:54:03 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6656A106566C; Fri, 19 Feb 2010 10:54:03 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 55FA78FC08; Fri, 19 Feb 2010 10:54:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1JAs35R062944; Fri, 19 Feb 2010 10:54:03 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1JAs3Z3062941; Fri, 19 Feb 2010 10:54:03 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201002191054.o1JAs3Z3062941@svn.freebsd.org> From: Edwin Groothuis Date: Fri, 19 Feb 2010 10:54:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204084 - user/edwin/calendar X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 10:54:03 -0000 Author: edwin Date: Fri Feb 19 10:54:03 2010 New Revision: 204084 URL: http://svn.freebsd.org/changeset/base/204084 Log: UTF -> UTC Modified: user/edwin/calendar/calendar.1 user/edwin/calendar/parsedata.c Modified: user/edwin/calendar/calendar.1 ============================================================================== --- user/edwin/calendar/calendar.1 Fri Feb 19 09:18:26 2010 (r204083) +++ user/edwin/calendar/calendar.1 Fri Feb 19 10:54:03 2010 (r204084) @@ -54,7 +54,7 @@ .Ek .Oc .Op Fl W Ar num -.Op Fl U Ar UTF-offset +.Op Fl U Ar UTC-offset .Op Fl l Ar longitude .Sh DESCRIPTION The Modified: user/edwin/calendar/parsedata.c ============================================================================== --- user/edwin/calendar/parsedata.c Fri Feb 19 09:18:26 2010 (r204083) +++ user/edwin/calendar/parsedata.c Fri Feb 19 10:54:03 2010 (r204084) @@ -899,7 +899,7 @@ dodebug(char *what) { int year; - printf("UTFOffset: %g\n", UTCoffset); + printf("UTCOffset: %g\n", UTCoffset); printf("eastlongitude: %d\n", eastlongitude); if (strcmp(what, "moon") == 0) { From owner-svn-src-user@FreeBSD.ORG Fri Feb 19 18:23:19 2010 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 941BE106566C; Fri, 19 Feb 2010 18:23:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by mx1.freebsd.org (Postfix) with ESMTP id 131538FC2F; Fri, 19 Feb 2010 18:23:18 +0000 (UTC) Received: from c122-106-163-215.carlnfd1.nsw.optusnet.com.au (c122-106-163-215.carlnfd1.nsw.optusnet.com.au [122.106.163.215]) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o1JINEvt001479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 20 Feb 2010 05:23:16 +1100 Date: Sat, 20 Feb 2010 05:23:14 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Warner Losh In-Reply-To: <201002181952.o1IJq7Mb062101@svn.freebsd.org> Message-ID: <20100220052256.F97028@delplex.bde.org> References: <201002181952.o1IJq7Mb062101@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org Subject: Re: svn commit: r204058 - user/imp/tbemd/sbin X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 18:23:19 -0000 On Thu, 18 Feb 2010, Warner Losh wrote: > Log: > Make this conform more closely to style.Makefile(5). > > Submitted by: bde Thanks. Bruce From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 16:10:42 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 038D9106568B; Sat, 20 Feb 2010 16:10:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDF0E8FC12; Sat, 20 Feb 2010 16:10:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KGAfj6052312; Sat, 20 Feb 2010 16:10:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KGAfZj052311; Sat, 20 Feb 2010 16:10:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201002201610.o1KGAfZj052311@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 20 Feb 2010 16:10:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204124 - user/kib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 16:10:42 -0000 Author: kib Date: Sat Feb 20 16:10:41 2010 New Revision: 204124 URL: http://svn.freebsd.org/changeset/base/204124 Log: Make my playground. Added: user/kib/ From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 16:12:38 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 505AF106568F; Sat, 20 Feb 2010 16:12:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 267338FC1D; Sat, 20 Feb 2010 16:12:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KGCcK8052789; Sat, 20 Feb 2010 16:12:38 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KGCc0E052788; Sat, 20 Feb 2010 16:12:38 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201002201612.o1KGCc0E052788@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 20 Feb 2010 16:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204125 - user/kib/vm6 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 16:12:38 -0000 Author: kib Date: Sat Feb 20 16:12:37 2010 New Revision: 204125 URL: http://svn.freebsd.org/changeset/base/204125 Log: Create a branch to keep the public copy of VMIO+rangelocks patch. Added: - copied from r204124, head/ Directory Properties: user/kib/vm6/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 16:34:42 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DB991065679; Sat, 20 Feb 2010 16:34:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A0D18FC13; Sat, 20 Feb 2010 16:34:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KGYguV057943; Sat, 20 Feb 2010 16:34:42 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KGYg2f057928; Sat, 20 Feb 2010 16:34:42 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201002201634.o1KGYg2f057928@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 20 Feb 2010 16:34:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204132 - in user/kib/vm6/sys: conf dev/md kern sys ufs/ffs ufs/ufs vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 16:34:42 -0000 Author: kib Date: Sat Feb 20 16:34:42 2010 New Revision: 204132 URL: http://svn.freebsd.org/changeset/base/204132 Log: Implementation of range locking for i/o and vm i/o. First vm_readwrite.c implementation by: jeff In collaboration with: pho Added: user/kib/vm6/sys/kern/kern_rangelock.c (contents, props changed) user/kib/vm6/sys/sys/rangelock.h (contents, props changed) user/kib/vm6/sys/vm/vm_readwrite.c (contents, props changed) Modified: user/kib/vm6/sys/conf/files user/kib/vm6/sys/dev/md/md.c user/kib/vm6/sys/kern/vfs_cluster.c user/kib/vm6/sys/kern/vfs_default.c user/kib/vm6/sys/kern/vfs_subr.c user/kib/vm6/sys/kern/vfs_vnops.c user/kib/vm6/sys/kern/vnode_if.src user/kib/vm6/sys/sys/buf.h user/kib/vm6/sys/sys/file.h user/kib/vm6/sys/sys/proc.h user/kib/vm6/sys/sys/vnode.h user/kib/vm6/sys/ufs/ffs/ffs_balloc.c user/kib/vm6/sys/ufs/ffs/ffs_softdep.c user/kib/vm6/sys/ufs/ffs/ffs_vnops.c user/kib/vm6/sys/ufs/ufs/ufs_vnops.c user/kib/vm6/sys/vm/vm_extern.h user/kib/vm6/sys/vm/vm_fault.c user/kib/vm6/sys/vm/vm_page.c user/kib/vm6/sys/vm/vm_page.h user/kib/vm6/sys/vm/vm_pageout.c user/kib/vm6/sys/vm/vm_pageout.h user/kib/vm6/sys/vm/vm_phys.c user/kib/vm6/sys/vm/vnode_pager.c Modified: user/kib/vm6/sys/conf/files ============================================================================== --- user/kib/vm6/sys/conf/files Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/conf/files Sat Feb 20 16:34:42 2010 (r204132) @@ -2077,6 +2077,7 @@ kern/kern_poll.c optional device_pollin kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard +kern/kern_rangelock.c standard kern/kern_resource.c standard kern/kern_rmlock.c standard kern/kern_rwlock.c standard @@ -2768,6 +2769,7 @@ vm/vm_page.c standard vm/vm_pageout.c standard vm/vm_pager.c standard vm/vm_phys.c standard +vm/vm_readwrite.c standard vm/vm_reserv.c standard vm/vm_unix.c standard vm/vm_zeroidle.c standard Modified: user/kib/vm6/sys/dev/md/md.c ============================================================================== --- user/kib/vm6/sys/dev/md/md.c Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/dev/md/md.c Sat Feb 20 16:34:42 2010 (r204132) @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -587,7 +588,7 @@ mdstart_swap(struct md_s *sc, struct bio { struct sf_buf *sf; int rv, offs, len, lastend; - vm_pindex_t i, lastp; + vm_pindex_t i, firstp, lastp; vm_page_t m; u_char *p; @@ -610,18 +611,26 @@ mdstart_swap(struct md_s *sc, struct bio * we're operating on complete aligned pages). */ offs = bp->bio_offset % PAGE_SIZE; + firstp = bp->bio_offset / PAGE_SIZE; lastp = (bp->bio_offset + bp->bio_length - 1) / PAGE_SIZE; lastend = (bp->bio_offset + bp->bio_length - 1) % PAGE_SIZE + 1; + vm_page_t ma[lastp - firstp + 1]; + rv = VM_PAGER_OK; VM_OBJECT_LOCK(sc->object); vm_object_pip_add(sc->object, 1); - for (i = bp->bio_offset / PAGE_SIZE; i <= lastp; i++) { + for (i = firstp; i <= lastp; i++) { len = ((i == lastp) ? lastend : PAGE_SIZE) - offs; - m = vm_page_grab(sc->object, i, - VM_ALLOC_NORMAL|VM_ALLOC_RETRY); + /* + * Write cleans pages of the buffer, give it a + * priority. + */ + m = vm_page_grab(sc->object, i, (bp->bio_cmd == BIO_WRITE ? + VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL) | VM_ALLOC_RETRY); VM_OBJECT_UNLOCK(sc->object); + ma[i - firstp] = m; sched_pin(); sf = sf_buf_alloc(m, SFB_CPUPRIVATE); VM_OBJECT_LOCK(sc->object); @@ -683,6 +692,12 @@ printf("wire_count %d busy %d flags %x h } vm_object_pip_subtract(sc->object, 1); vm_object_set_writeable_dirty(sc->object); + if (rv != VM_PAGER_ERROR && bp->bio_cmd == BIO_WRITE && + vm_page_count_severe()) { + vm_page_lock_queues(); + vm_pageout_flush(ma, lastp - firstp + 1, IO_SYNC); + vm_page_unlock_queues(); + } VM_OBJECT_UNLOCK(sc->object); return (rv != VM_PAGER_ERROR ? 0 : ENOSPC); } Added: user/kib/vm6/sys/kern/kern_rangelock.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kib/vm6/sys/kern/kern_rangelock.c Sat Feb 20 16:34:42 2010 (r204132) @@ -0,0 +1,186 @@ +/*- + * Copyright (c) 2009 Konstantin Belousov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +uma_zone_t rl_entry_zone; + +static void +rangelock_sys_init(void) +{ + + rl_entry_zone = uma_zcreate("rl_entry", sizeof(struct rl_q_entry), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); +} +SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, rangelock_sys_init, NULL); + +void +rangelock_init(struct rangelock *lock) +{ + + TAILQ_INIT(&lock->rl_waiters); + lock->rl_currdep = NULL; +} + +void +rangelock_destroy(struct rangelock *lock) +{ + + KASSERT(TAILQ_EMPTY(&lock->rl_waiters), ("Dangling waiters")); +} + +static int +rangelock_incompatible(const struct rl_q_entry *e1, + const struct rl_q_entry *e2) +{ + + if ((e1->rl_q_flags & RL_LOCK_TYPE_MASK) == RL_LOCK_READ && + (e2->rl_q_flags & RL_LOCK_TYPE_MASK) == RL_LOCK_READ) + return (0); +#define IN_RANGE(a, e) (a >= e->rl_q_start && a < e->rl_q_end) + if (IN_RANGE(e1->rl_q_start, e2) || IN_RANGE(e2->rl_q_start, e1) || + IN_RANGE(e1->rl_q_end, e2) || IN_RANGE(e2->rl_q_end, e1)) + return (1); +#undef IN_RANGE + return (0); +} + +static void +rangelock_calc_block(struct rangelock *lock) +{ + struct rl_q_entry *entry, *entry1, *whead; + + if (lock->rl_currdep == TAILQ_FIRST(&lock->rl_waiters) && + lock->rl_currdep != NULL) + lock->rl_currdep = TAILQ_NEXT(lock->rl_currdep, rl_q_link); + for (entry = lock->rl_currdep; entry; + entry = TAILQ_NEXT(entry, rl_q_link)) { + TAILQ_FOREACH(entry1, &lock->rl_waiters, rl_q_link) { + if (rangelock_incompatible(entry, entry1)) + goto out; + if (entry1 == entry) + break; + } + } +out: + lock->rl_currdep = entry; + TAILQ_FOREACH(whead, &lock->rl_waiters, rl_q_link) { + if (whead == lock->rl_currdep) + break; + if (!(whead->rl_q_flags & RL_LOCK_GRANTED)) { + whead->rl_q_flags |= RL_LOCK_GRANTED; + wakeup(whead); + } + } +} + +static void +rangelock_unlock_vp_locked(struct vnode *vp, struct rl_q_entry *entry) +{ + + ASSERT_VI_LOCKED(vp, "rangelock"); + KASSERT(entry != vp->v_rl.rl_currdep, ("stuck currdep")); + TAILQ_REMOVE(&vp->v_rl.rl_waiters, entry, rl_q_link); + rangelock_calc_block(&vp->v_rl); + VI_UNLOCK(vp); + uma_zfree(rl_entry_zone, entry); +} + +void +rangelock_unlock(struct vnode *vp, void *cookie) +{ + struct rl_q_entry *entry; + + entry = cookie; + VI_LOCK(vp); + rangelock_unlock_vp_locked(vp, entry); +} + +void * +rangelock_unlock_range(struct vnode *vp, void *cookie, off_t base, size_t len) +{ + struct rl_q_entry *entry; + + entry = cookie; + VI_LOCK(vp); + KASSERT(entry->rl_q_flags & RL_LOCK_GRANTED, ("XXX")); + KASSERT(entry->rl_q_start == base, ("XXX")); + KASSERT(entry->rl_q_end >= base + len, ("XXX")); + if (entry->rl_q_end == base + len) { + rangelock_unlock_vp_locked(vp, cookie); + return (NULL); + } + entry->rl_q_end = base + len; + rangelock_calc_block(&vp->v_rl); + VI_UNLOCK(vp); + return (cookie); +} + +static void * +rangelock_enqueue(struct vnode *vp, struct rl_q_entry *entry) +{ + + VI_LOCK(vp); + TAILQ_INSERT_TAIL(&vp->v_rl.rl_waiters, entry, rl_q_link); + if (vp->v_rl.rl_currdep == NULL) + vp->v_rl.rl_currdep = entry; + rangelock_calc_block(&vp->v_rl); + while (!(entry->rl_q_flags & RL_LOCK_GRANTED)) + msleep(entry, &vp->v_interlock, 0, "range", 0); + VI_UNLOCK(vp); + return (entry); +} + +void * +rangelock_rlock(struct vnode *vp, off_t base, size_t len) +{ + struct rl_q_entry *entry; + + entry = uma_zalloc(rl_entry_zone, M_WAITOK); + entry->rl_q_flags = RL_LOCK_READ; + entry->rl_q_start = base; + entry->rl_q_end = base + len; + return (rangelock_enqueue(vp, entry)); +} + +void * +rangelock_wlock(struct vnode *vp, off_t base, size_t len) +{ + struct rl_q_entry *entry; + + entry = uma_zalloc(rl_entry_zone, M_WAITOK); + entry->rl_q_flags = RL_LOCK_WRITE; + entry->rl_q_start = base; + entry->rl_q_end = base + len; + return (rangelock_enqueue(vp, entry)); +} Modified: user/kib/vm6/sys/kern/vfs_cluster.c ============================================================================== --- user/kib/vm6/sys/kern/vfs_cluster.c Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/kern/vfs_cluster.c Sat Feb 20 16:34:42 2010 (r204132) @@ -71,8 +71,8 @@ static int write_behind = 1; SYSCTL_INT(_vfs, OID_AUTO, write_behind, CTLFLAG_RW, &write_behind, 0, "Cluster write-behind; 0: disable, 1: enable, 2: backed off"); -static int read_max = 8; -SYSCTL_INT(_vfs, OID_AUTO, read_max, CTLFLAG_RW, &read_max, 0, +int vfs_read_max = 8; +SYSCTL_INT(_vfs, OID_AUTO, read_max, CTLFLAG_RW, &vfs_read_max, 0, "Cluster read-ahead max block count"); /* Page expended to mark partially backed buffers */ @@ -109,7 +109,7 @@ cluster_read(vp, filesize, lblkno, size, */ racluster = vp->v_mount->mnt_iosize_max / size; maxra = seqcount; - maxra = min(read_max, maxra); + maxra = min(vfs_read_max, maxra); maxra = min(nbuf/8, maxra); if (((u_quad_t)(lblkno + maxra + 1) * size) > filesize) maxra = (filesize / size) - lblkno; @@ -803,7 +803,9 @@ cluster_wbuild(vp, size, start_lbn, len) (tbp->b_bcount != tbp->b_bufsize) || (tbp->b_bcount != size) || (len == 1) || - ((bp = getpbuf(&cluster_pbuf_freecnt)) == NULL)) { + ((bp = (vp->v_vflag & VV_MD) ? + trypbuf(&cluster_pbuf_freecnt) : + getpbuf(&cluster_pbuf_freecnt)) == NULL)) { totalwritten += tbp->b_bufsize; bawrite(tbp); ++start_lbn; Modified: user/kib/vm6/sys/kern/vfs_default.c ============================================================================== --- user/kib/vm6/sys/kern/vfs_default.c Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/kern/vfs_default.c Sat Feb 20 16:34:42 2010 (r204132) @@ -77,6 +77,8 @@ static int dirent_exists(struct vnode *v #define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4) +static int vop_stdextend(struct vop_extend_args *ap); + /* * This vnode table stores what we want to do if the filesystem doesn't * implement a particular VOP. @@ -118,6 +120,7 @@ struct vop_vector default_vnodeops = { .vop_unlock = vop_stdunlock, .vop_vptocnp = vop_stdvptocnp, .vop_vptofh = vop_stdvptofh, + .vop_extend = vop_stdextend, }; /* @@ -825,6 +828,23 @@ out: return (error); } +static int +vop_stdextend(struct vop_extend_args *ap) +{ + struct vattr vattr, oattr; + int error; + + + error = VOP_GETATTR(ap->a_vp, &oattr, ap->a_cred); + if (error != 0) + return (error); + if (oattr.va_size >= ap->a_size) + return (0); + VATTR_NULL(&vattr); + vattr.va_size = ap->a_size; + return (VOP_SETATTR(ap->a_vp, &vattr, ap->a_cred)); +} + /* * vfs default ops * used to fill the vfs function table to get reasonable default return values. Modified: user/kib/vm6/sys/kern/vfs_subr.c ============================================================================== --- user/kib/vm6/sys/kern/vfs_subr.c Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/kern/vfs_subr.c Sat Feb 20 16:34:42 2010 (r204132) @@ -861,6 +861,7 @@ vdestroy(struct vnode *vp) /* XXX Elsewhere we can detect an already freed vnode via NULL v_op. */ vp->v_op = NULL; #endif + rangelock_destroy(&vp->v_rl); lockdestroy(vp->v_vnlock); mtx_destroy(&vp->v_interlock); mtx_destroy(BO_MTX(bo)); @@ -1015,6 +1016,7 @@ alloc: if ((mp->mnt_kern_flag & MNTK_NOKNOTE) != 0) vp->v_vflag |= VV_NOKNOTE; } + rangelock_init(&vp->v_rl); *vpp = vp; return (0); Modified: user/kib/vm6/sys/kern/vfs_vnops.c ============================================================================== --- user/kib/vm6/sys/kern/vfs_vnops.c Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/kern/vfs_vnops.c Sat Feb 20 16:34:42 2010 (r204132) @@ -37,12 +37,14 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include #include #include #include +#include #include #include #include @@ -62,6 +64,13 @@ __FBSDID("$FreeBSD$"); #include +#include +#include + +static int vmio_enabled = 1; +SYSCTL_INT(_vfs, OID_AUTO, vmio_enabled, CTLFLAG_RW, &vmio_enabled, 0, + "Use vm pages copyin/out instead of vops for read/write"); + static fo_rdwr_t vn_read; static fo_rdwr_t vn_write; static fo_truncate_t vn_truncate; @@ -83,6 +92,9 @@ struct fileops vnops = { .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; +static int vn_write_chunk(struct vnode *, struct uio *, struct ucred *, + struct ucred *, int); + int vn_open(ndp, flagp, cmode, fp) struct nameidata *ndp; @@ -275,17 +287,14 @@ vn_writechk(vp) * Vnode close call */ int -vn_close(vp, flags, file_cred, td) - register struct vnode *vp; - int flags; - struct ucred *file_cred; - struct thread *td; +vn_close(struct vnode *vp, int flags, struct ucred *file_cred, + struct thread *td) { - struct mount *mp; + struct mount *mp, *mp1; int error, lock_flags; - if (!(flags & FWRITE) && vp->v_mount != NULL && - vp->v_mount->mnt_kern_flag & MNTK_EXTENDED_SHARED) + if (!(flags & FWRITE) && (mp1 = vp->v_mount) != NULL && + MNT_SHARED_WRITES(mp1)) lock_flags = LK_SHARED; else lock_flags = LK_EXCLUSIVE; @@ -333,7 +342,7 @@ sequential_heuristic(struct uio *uio, st * closely related to the best I/O size for real disks than * to any block size used by software. */ - fp->f_seqcount += howmany(uio->uio_resid, 16384); + fp->f_seqcount += howmany(uio->uio_resid, FRA_BLOCK_SZ); if (fp->f_seqcount > IO_SEQMAX) fp->f_seqcount = IO_SEQMAX; return (fp->f_seqcount << IO_SEQSHIFT); @@ -351,76 +360,71 @@ sequential_heuristic(struct uio *uio, st * Package up an I/O request on a vnode into a uio and do it. */ int -vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, active_cred, file_cred, - aresid, td) - enum uio_rw rw; - struct vnode *vp; - void *base; - int len; - off_t offset; - enum uio_seg segflg; - int ioflg; - struct ucred *active_cred; - struct ucred *file_cred; - int *aresid; - struct thread *td; +vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset, + enum uio_seg segflg, int ioflg, struct ucred *active_cred, + struct ucred *file_cred, int *aresid, struct thread *td) { struct uio auio; struct iovec aiov; struct mount *mp; struct ucred *cred; + void *rl_cookie; int error, lock_flags; VFS_ASSERT_GIANT(vp->v_mount); + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + aiov.iov_base = base; + aiov.iov_len = len; + auio.uio_resid = len; + auio.uio_offset = offset; + auio.uio_segflg = segflg; + auio.uio_rw = rw; + auio.uio_td = td; + error = 0; + if ((ioflg & IO_NODELOCKED) == 0) { + if (rw == UIO_READ) + rl_cookie = rangelock_rlock(vp, offset, len); + else + rl_cookie = rangelock_wlock(vp, offset, len); mp = NULL; if (rw == UIO_WRITE) { if (vp->v_type != VCHR && (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) - return (error); + goto out; if (MNT_SHARED_WRITES(mp) || - ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) lock_flags = LK_SHARED; - } else { + else lock_flags = LK_EXCLUSIVE; - } - vn_lock(vp, lock_flags | LK_RETRY); } else - vn_lock(vp, LK_SHARED | LK_RETRY); + lock_flags = LK_SHARED; + vn_lock(vp, lock_flags | LK_RETRY); + } else + rl_cookie = NULL; - } ASSERT_VOP_LOCKED(vp, "IO_NODELOCKED with no vp lock held"); - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - aiov.iov_base = base; - aiov.iov_len = len; - auio.uio_resid = len; - auio.uio_offset = offset; - auio.uio_segflg = segflg; - auio.uio_rw = rw; - auio.uio_td = td; - error = 0; #ifdef MAC if ((ioflg & IO_NOMACCHECK) == 0) { - if (rw == UIO_READ) - error = mac_vnode_check_read(active_cred, file_cred, - vp); - else + if (rw == UIO_WRITE) error = mac_vnode_check_write(active_cred, file_cred, vp); } #endif if (error == 0) { - if (file_cred) + if (file_cred != NULL) cred = file_cred; else cred = active_cred; if (rw == UIO_READ) - error = VOP_READ(vp, &auio, ioflg, cred); + error = vn_read_chunk(vp, &auio, active_cred, cred, + ioflg | IO_NODELOCKED); else - error = VOP_WRITE(vp, &auio, ioflg, cred); + error = vn_write_chunk(vp, &auio, active_cred, cred, + ioflg | IO_NODELOCKED); } if (aresid) *aresid = auio.uio_resid; @@ -428,10 +432,13 @@ vn_rdwr(rw, vp, base, len, offset, segfl if (auio.uio_resid && error == 0) error = EIO; if ((ioflg & IO_NODELOCKED) == 0) { - if (rw == UIO_WRITE && vp->v_type != VCHR) - vn_finished_write(mp); VOP_UNLOCK(vp, 0); + if (mp != NULL) + vn_finished_write(mp); } + out: + if (rl_cookie != NULL) + rangelock_unlock(vp, rl_cookie); return (error); } @@ -493,68 +500,148 @@ vn_rdwr_inchunks(rw, vp, base, len, offs return (error); } +static struct mtx * +vn_lock_foffset(struct file *fp) +{ + struct mtx *mtxp; + + mtxp = mtx_pool_find(mtxpool_sleep, fp); + mtx_lock(mtxp); + while (fp->f_vnread_flags & FOFFSET_LOCKED) { + fp->f_vnread_flags |= FOFFSET_LOCK_WAITING; + msleep(&fp->f_vnread_flags, mtxp, PUSER -1, + "vnread offlock", 0); + } + fp->f_vnread_flags |= FOFFSET_LOCKED; + mtx_unlock(mtxp); + return (mtxp); +} + +static void +vn_unlock_foffset(struct file *fp, struct mtx *mtxp) +{ + + mtx_lock(mtxp); + if (fp->f_vnread_flags & FOFFSET_LOCK_WAITING) + wakeup(&fp->f_vnread_flags); + fp->f_vnread_flags = 0; + mtx_unlock(mtxp); +} + +int +vn_read_chunk(struct vnode *vp, struct uio *uio, struct ucred *active_cred, + struct ucred *fcred, int ioflag) +{ + int error, vfslocked; + + error = 0; + vfslocked = 0; /* gcc */ + + if ((ioflag & IO_NODELOCKED) == 0) { + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + vn_lock(vp, LK_SHARED | LK_RETRY); + } + +#ifdef MAC + if ((ioflag & IO_NOMACCHECK) == 0) + error = mac_vnode_check_read(active_cred, fcred, vp); +#endif + if (error == 0) { + if (!vmio_enabled || + (error = vnode_pager_read(vp, uio, ioflag)) == EOPNOTSUPP) + error = VOP_READ(vp, uio, ioflag, fcred); + } + if ((ioflag & IO_NODELOCKED) == 0) { + VOP_UNLOCK(vp, 0); + VFS_UNLOCK_GIANT(vfslocked); + } + return (error); +} + /* * File table vnode read routine. */ static int -vn_read(fp, uio, active_cred, flags, td) - struct file *fp; - struct uio *uio; - struct ucred *active_cred; - struct thread *td; - int flags; +vn_read(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, + struct thread *td) { struct vnode *vp; - int error, ioflag; struct mtx *mtxp; - int vfslocked; + void *rl_cookie; + int ioflag; + int error; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); - mtxp = NULL; - vp = fp->f_vnode; ioflag = 0; if (fp->f_flag & FNONBLOCK) ioflag |= IO_NDELAY; if (fp->f_flag & O_DIRECT) ioflag |= IO_DIRECT; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); + vp = fp->f_vnode; + /* * According to McKusick the vn lock was protecting f_offset here. * It is now protected by the FOFFSET_LOCKED flag. */ if ((flags & FOF_OFFSET) == 0) { - mtxp = mtx_pool_find(mtxpool_sleep, fp); - mtx_lock(mtxp); - while(fp->f_vnread_flags & FOFFSET_LOCKED) { - fp->f_vnread_flags |= FOFFSET_LOCK_WAITING; - msleep(&fp->f_vnread_flags, mtxp, PUSER -1, - "vnread offlock", 0); - } - fp->f_vnread_flags |= FOFFSET_LOCKED; - mtx_unlock(mtxp); - vn_lock(vp, LK_SHARED | LK_RETRY); + mtxp = vn_lock_foffset(fp); uio->uio_offset = fp->f_offset; } else - vn_lock(vp, LK_SHARED | LK_RETRY); - + mtxp = NULL; /* gcc */ + if (vp->v_type == VREG) + rl_cookie = rangelock_rlock(vp, uio->uio_offset, + uio->uio_resid); + else + rl_cookie = NULL; ioflag |= sequential_heuristic(uio, fp); + error = vn_read_chunk(vp, uio, active_cred, fp->f_cred, ioflag); + fp->f_nextoff = uio->uio_offset; + if (rl_cookie != NULL) + rangelock_unlock(vp, rl_cookie); + if ((flags & FOF_OFFSET) == 0) { + fp->f_offset = uio->uio_offset; + vn_unlock_foffset(fp, mtxp); + } + return (error); +} + +static int +vn_write_chunk(struct vnode *vp, struct uio *uio, struct ucred *active_cred, + struct ucred *fcred, int ioflag) +{ + struct mount *mp, *mp1; + int error, lock_flags, vfslocked; + + mp = NULL; + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + if (vp->v_type == VREG) + bwillwrite(); + if (vp->v_type != VCHR && + (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) + goto unlock; + if (MNT_SHARED_WRITES(mp) || + (mp == NULL && (mp1 = vp->v_mount) != NULL && + MNT_SHARED_WRITES(mp1))) + lock_flags = LK_SHARED; + else + lock_flags = LK_EXCLUSIVE; + vn_lock(vp, lock_flags | LK_RETRY); #ifdef MAC - error = mac_vnode_check_read(active_cred, fp->f_cred, vp); - if (error == 0) + error = mac_vnode_check_write(active_cred, fcred, vp); +#else + error = 0; #endif - error = VOP_READ(vp, uio, ioflag, fp->f_cred); - if ((flags & FOF_OFFSET) == 0) { - fp->f_offset = uio->uio_offset; - mtx_lock(mtxp); - if (fp->f_vnread_flags & FOFFSET_LOCK_WAITING) - wakeup(&fp->f_vnread_flags); - fp->f_vnread_flags = 0; - mtx_unlock(mtxp); + if (error == 0) { + if (!vmio_enabled || + (error = vnode_pager_write(vp, uio, ioflag)) == EOPNOTSUPP) + error = VOP_WRITE(vp, uio, ioflag, fcred); } - fp->f_nextoff = uio->uio_offset; VOP_UNLOCK(vp, 0); + if (vp->v_type != VCHR) + vn_finished_write(mp); +unlock: VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -563,24 +650,17 @@ vn_read(fp, uio, active_cred, flags, td) * File table vnode write routine. */ static int -vn_write(fp, uio, active_cred, flags, td) - struct file *fp; - struct uio *uio; - struct ucred *active_cred; - struct thread *td; - int flags; +vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, + struct thread *td) { struct vnode *vp; - struct mount *mp; - int error, ioflag, lock_flags; - int vfslocked; + struct mtx *mtxp; + void *rl_cookie; + int error, ioflag; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - if (vp->v_type == VREG) - bwillwrite(); ioflag = IO_UNIT; if (vp->v_type == VREG && (fp->f_flag & O_APPEND)) ioflag |= IO_APPEND; @@ -591,36 +671,32 @@ vn_write(fp, uio, active_cred, flags, td if ((fp->f_flag & O_FSYNC) || (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS))) ioflag |= IO_SYNC; - mp = NULL; - if (vp->v_type != VCHR && - (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) - goto unlock; - - if ((MNT_SHARED_WRITES(mp) || - ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) && - (flags & FOF_OFFSET) != 0) { - lock_flags = LK_SHARED; - } else { - lock_flags = LK_EXCLUSIVE; - } - - vn_lock(vp, lock_flags | LK_RETRY); - if ((flags & FOF_OFFSET) == 0) + if ((flags & FOF_OFFSET) == 0) { + mtxp = vn_lock_foffset(fp); uio->uio_offset = fp->f_offset; + } else + mtxp = NULL; /* gcc */ ioflag |= sequential_heuristic(uio, fp); -#ifdef MAC - error = mac_vnode_check_write(active_cred, fp->f_cred, vp); - if (error == 0) -#endif - error = VOP_WRITE(vp, uio, ioflag, fp->f_cred); - if ((flags & FOF_OFFSET) == 0) + if (vp->v_type == VREG) { + if ((ioflag & IO_APPEND) || !(flags & FOF_OFFSET)) + /* + * For appenders, punt and lock the whole + * range. It also protects f_offset. + */ + rl_cookie = rangelock_wlock(vp, 0, (size_t)-1); + else + rl_cookie = rangelock_wlock(vp, uio->uio_offset, + uio->uio_resid); + } else + rl_cookie = NULL; + error = vn_write_chunk(vp, uio, active_cred, fp->f_cred, ioflag); + if (rl_cookie != NULL) + rangelock_unlock(vp, rl_cookie); + if ((flags & FOF_OFFSET) == 0) { fp->f_offset = uio->uio_offset; + vn_unlock_foffset(fp, mtxp); + } fp->f_nextoff = uio->uio_offset; - VOP_UNLOCK(vp, 0); - if (vp->v_type != VCHR) - vn_finished_write(mp); -unlock: - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -628,25 +704,29 @@ unlock: * File table truncate routine. */ static int -vn_truncate(fp, length, active_cred, td) - struct file *fp; - off_t length; - struct ucred *active_cred; - struct thread *td; +vn_truncate(struct file *fp, off_t length, struct ucred *active_cred, + struct thread *td) { struct vattr vattr; struct mount *mp; struct vnode *vp; + void *rl_cookie; int vfslocked; int error; vp = fp->f_vnode; + + /* + * Lock the range where the shortening take place. Increase of + * file size does not need rangelock, but it is faster to lock + * the range then call VOP_GETATTR to get the current size and + * deal with races. + */ + rl_cookie = rangelock_wlock(vp, length, -1); vfslocked = VFS_LOCK_GIANT(vp->v_mount); error = vn_start_write(vp, &mp, V_WAIT | PCATCH); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); - return (error); - } + if (error) + goto out1; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (vp->v_type == VDIR) { error = EISDIR; @@ -666,7 +746,9 @@ vn_truncate(fp, length, active_cred, td) out: VOP_UNLOCK(vp, 0); vn_finished_write(mp); +out1: VFS_UNLOCK_GIANT(vfslocked); + rangelock_unlock(vp, rl_cookie); return (error); } Modified: user/kib/vm6/sys/kern/vnode_if.src ============================================================================== --- user/kib/vm6/sys/kern/vnode_if.src Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/kern/vnode_if.src Sat Feb 20 16:34:42 2010 (r204132) @@ -611,3 +611,12 @@ vop_vptocnp { INOUT char *buf; INOUT int *buflen; }; + +%% extend vp L L L + +vop_extend { + IN struct vnode *vp; + IN struct ucred *cred; + IN u_quad_t size; + IN int flags; +}; Modified: user/kib/vm6/sys/sys/buf.h ============================================================================== --- user/kib/vm6/sys/sys/buf.h Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/sys/buf.h Sat Feb 20 16:34:42 2010 (r204132) @@ -257,6 +257,8 @@ extern const char *buf_wmesg; /* Defaul #include /* XXX for curthread */ #include +extern int vfs_read_max; + /* * Initialize a lock. */ Modified: user/kib/vm6/sys/sys/file.h ============================================================================== --- user/kib/vm6/sys/sys/file.h Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/sys/file.h Sat Feb 20 16:34:42 2010 (r204132) @@ -141,6 +141,8 @@ struct file { #define FOFFSET_LOCKED 0x1 #define FOFFSET_LOCK_WAITING 0x2 +#define FRA_BLOCK_SZ 16384 + #endif /* _KERNEL || _WANT_FILE */ /* Modified: user/kib/vm6/sys/sys/proc.h ============================================================================== --- user/kib/vm6/sys/sys/proc.h Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/sys/proc.h Sat Feb 20 16:34:42 2010 (r204132) @@ -354,7 +354,7 @@ do { \ #define TDP_COWINPROGRESS 0x00000010 /* Snapshot copy-on-write in progress. */ #define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */ #define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */ -#define TDP_UNUSED80 0x00000080 /* available. */ +#define TDP_VMIO 0x00000080 /* Busied pages for vnode_pager io. */ #define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */ #define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */ #define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */ Added: user/kib/vm6/sys/sys/rangelock.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kib/vm6/sys/sys/rangelock.h Sat Feb 20 16:34:42 2010 (r204132) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2009 Konstantin Belousov + * All rights reserved. + * + * $FreeBSD$ + */ + +#ifndef _SYS_RANGELOCK_H +#define _SYS_RANGELOCK_H + +#include +#include +#include +#include +#include + +#ifdef _KERNEL + +struct vnode; + +struct rl_q_entry +{ + TAILQ_ENTRY(rl_q_entry) rl_q_link; + size_t rl_q_start, rl_q_end; + int rl_q_flags; +}; + +#define RL_LOCK_READ 0x0001 +#define RL_LOCK_WRITE 0x0002 +#define RL_LOCK_TYPE_MASK 0x0003 +#define RL_LOCK_GRANTED 0x0004 + +struct rangelock +{ + TAILQ_HEAD(, rl_q_entry) rl_waiters; + struct rl_q_entry *rl_currdep; +}; + +void rangelock_init(struct rangelock *lock); +void rangelock_destroy(struct rangelock *lock); +void rangelock_unlock(struct vnode *vp, void *cookie); +void *rangelock_unlock_range(struct vnode *vp, void *cookie, off_t base, + size_t len); +void *rangelock_rlock(struct vnode *vp, off_t base, size_t len); +void *rangelock_wlock(struct vnode *vp, off_t base, size_t len); +#endif + +#endif Modified: user/kib/vm6/sys/sys/vnode.h ============================================================================== --- user/kib/vm6/sys/sys/vnode.h Sat Feb 20 16:32:33 2010 (r204131) +++ user/kib/vm6/sys/sys/vnode.h Sat Feb 20 16:34:42 2010 (r204132) @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -168,7 +169,8 @@ struct vnode { */ struct vpollinfo *v_pollinfo; /* G Poll events, p for *v_pi */ struct label *v_label; /* MAC label for vnode */ - struct lockf *v_lockf; /* Byte-level lock list */ + struct lockf *v_lockf; /* Byte-level adv lock list */ + struct rangelock v_rl; /* Byte-range lock */ }; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 16:38:49 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DA89106566C; Sat, 20 Feb 2010 16:38:49 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EFBFC8FC12; Sat, 20 Feb 2010 16:38:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KGcmaw058950; Sat, 20 Feb 2010 16:38:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KGcmfE058948; Sat, 20 Feb 2010 16:38:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201002201638.o1KGcmfE058948@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 20 Feb 2010 16:38:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204133 - in user/kib/vm6/tools/tools/ufs: . fragc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 16:38:49 -0000 Author: kib Date: Sat Feb 20 16:38:48 2010 New Revision: 204133 URL: http://svn.freebsd.org/changeset/base/204133 Log: Tool to calculate fragmentation of the UFS volume Added: user/kib/vm6/tools/tools/ufs/ user/kib/vm6/tools/tools/ufs/fragc/ user/kib/vm6/tools/tools/ufs/fragc/fragc.c Added: user/kib/vm6/tools/tools/ufs/fragc/fragc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kib/vm6/tools/tools/ufs/fragc/fragc.c Sat Feb 20 16:38:48 2010 (r204133) @@ -0,0 +1,215 @@ +/* $Id: fragc.c,v 1.9 2010/02/07 14:32:22 kostik Exp kostik $ */ + +/* /usr/local/opt/gcc-4.4.3/bin/gcc -g -Wall -Wextra -O -o fragc fragc.c -lufs */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const int blocksz = 512; + +static int verbose; + +static void +usage(void) +{ + + fprintf(stderr, "Usage: fragc [-v] devname\n"); +} + +static ufs2_daddr_t blks_total; +static ufs2_daddr_t blks_breaks; + +static void +block_pair(struct fs *fs, ufs2_daddr_t *prev, ufs2_daddr_t curr) +{ + + blks_total++; + if (curr != 0) { + if (*prev != 0 && + (*prev) + fs->fs_bsize / fs->fs_fsize != curr) { + blks_breaks++; + if (verbose) + putchar('|'); + } + if (verbose) + printf(" %jd", (intmax_t)curr); + } + *prev = curr; +} + +static void +count_indir(struct uufsd *u, struct fs *fs, int level, int maxlevel, + ufs2_daddr_t ib, ufs2_daddr_t *prev) +{ + ufs2_daddr_t *b; + unsigned i; + + if (ib == 0) + return; + b = malloc(fs->fs_bsize); + if (bread(u, ib * fs->fs_fsize / blocksz, b, fs->fs_bsize) == -1) { + printf("\nRead block %jd: %s\n", (intmax_t)ib, u->d_error); + goto out; + } + for (i = 0; i < fs->fs_bsize / sizeof(ufs2_daddr_t); i++) { + if (level == maxlevel) + block_pair(fs, prev, b[i]); + else + count_indir(u, fs, level + 1, maxlevel, b[i], prev); + } + out: + free(b); +} + +static void +count_ino_ufs1(struct uufsd *u, struct fs *fs, struct ufs1_dinode *dp) +{ + ufs2_daddr_t prev; + unsigned i; + + if (dp->di_size == 0) + return; + if ((dp->di_mode & IFMT) == IFLNK && dp->di_size < + (u_int64_t)fs->fs_maxsymlinklen) + return; + + prev = 0; + for (i = 0; i < NDADDR; i++) + block_pair(fs, &prev, dp->di_db[i]); + for (i = 0; i < NIADDR; i++) { + if (0 && verbose) + printf(" [%d]", dp->di_ib[i]); + count_indir(u, fs, 0, i, dp->di_ib[i], &prev); + } +} + +static void +count_ino_ufs2(struct uufsd *u, struct fs *fs, struct ufs2_dinode *dp) +{ + ufs2_daddr_t prev; + unsigned i; + + if (dp->di_size == 0) + return; + if ((dp->di_mode & IFMT) == IFLNK && dp->di_size < + (u_int64_t)fs->fs_maxsymlinklen) + return; + + prev = 0; + for (i = 0; i < NDADDR; i++) + block_pair(fs, &prev, dp->di_db[i]); + for (i = 0; i < NIADDR; i++) { + if (0 && verbose) + printf(" [%jd]", (intmax_t)(dp->di_ib[i])); + count_indir(u, fs, 0, i, dp->di_ib[i], &prev); + } +} + +static void +frag_calc(struct uufsd *u) +{ + struct fs *fs; + struct cg *cg; + void *dino; + int32_t cgno; + uint32_t ino, inoused, cgino, next_cg_ino; + int mode; + u_int8_t *cp; + + fs = &u->d_fs; + if (verbose) + printf("%s UFS%d\n", u->d_name, u->d_ufs); + ino = 0; + for (cgno = 0; cgread(u); cgno++) { + cg = &u->d_cg; + if (u->d_ufs == 1) + inoused = fs->fs_ipg; + else + inoused = cg->cg_initediblk; + if (verbose) + printf("cg %d inodes %u\n", cgno, inoused); + cp = cg_inosused(cg); + next_cg_ino = ino + fs->fs_ipg; + for (cgino = 0; cgino < inoused; cgino++, ino++) { + if ((cp[cgino / CHAR_BIT] & (1 << (cgino % CHAR_BIT))) + != 0 && ino != 0 && ino != 1) { + if (verbose) + printf(" ino %u:", ino); + if (getino(u, &dino, ino, &mode) == -1) { + printf("\nReading ino %u: %s\n", + ino, u->d_error); + return; + } + if (mode == 0) { + printf( +"\nIno %u/%u is allocated in bitmap, but mode is 0\n", + ino, ino % fs->fs_ipg); + continue; + } + if (mode != IFDIR && mode != IFREG && + mode != IFLNK) + continue; + + if (u->d_ufs == 1) + count_ino_ufs1(u, fs, dino); + else + count_ino_ufs2(u, fs, dino); + if (verbose) + putchar('\n'); + } + } + ino = next_cg_ino; + } +} + +int +main(int argc, char *argv[]) +{ + struct uufsd ufsd; + int c; + + verbose = 0; + while ((c = getopt(argc, argv, "hv")) != -1) { + switch (c) { + case 'h': + usage(); + return (0); + case 'v': + verbose = 1; + break; + default: + usage(); + return (2); + } + } + if (optind + 1 != argc) { + usage(); + return (2); + } + + if (ufs_disk_fillout(&ufsd, argv[optind]) == -1) { + fprintf(stderr, "Fillout: %s\n", ufsd.d_error); + return (1); + } + + frag_calc(&ufsd); + + if (ufs_disk_close(&ufsd) == -1) { + fprintf(stderr, "Disk close: %s\n", ufsd.d_error); + return (1); + } + + printf("Total %jd data blocks, %jd breaks, %02.2f%% fragmentation.\n", + (intmax_t)blks_total, (intmax_t)blks_breaks, + (double)blks_breaks * 100.0 / blks_total); + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 16:41:29 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C89410656A6; Sat, 20 Feb 2010 16:41:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 497068FC14; Sat, 20 Feb 2010 16:41:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KGfTQX059558; Sat, 20 Feb 2010 16:41:29 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KGfToX059555; Sat, 20 Feb 2010 16:41:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201002201641.o1KGfToX059555@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 20 Feb 2010 16:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204134 - in user/kib/vm6/tools/regression: file/uio ufs/ba_clrbuf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 16:41:29 -0000 Author: kib Date: Sat Feb 20 16:41:29 2010 New Revision: 204134 URL: http://svn.freebsd.org/changeset/base/204134 Log: Add tests for io consistency Added: user/kib/vm6/tools/regression/file/uio/ user/kib/vm6/tools/regression/file/uio/uio.c user/kib/vm6/tools/regression/ufs/ba_clrbuf/ user/kib/vm6/tools/regression/ufs/ba_clrbuf/ba_clrbuf.c Added: user/kib/vm6/tools/regression/file/uio/uio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kib/vm6/tools/regression/file/uio/uio.c Sat Feb 20 16:41:29 2010 (r204134) @@ -0,0 +1,116 @@ +/*- + * Copyright (c) 2009 Konstantin Belousov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int chunk_cnt = 1024; +int chunk_size = 1024; + +int +main(int argc, char *argv[]) +{ + struct iovec *wiov, *riov; + char **wdata, **rdata; + int fd, i; + ssize_t io_error; + + if (argc < 2) { + fprintf(stderr, "Usage: uio file [chunk count [chunk size]]\n"); + return (2); + } + fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd == -1) { + fprintf(stderr, "Failed to create %s: %s\n", + argv[1], strerror(errno)); + return (1); + } + + if (argc > 2) + chunk_cnt = atoi(argv[2]); + if (argc > 3) + chunk_size = atoi(argv[3]); + + wiov = calloc(chunk_cnt, sizeof(*wiov)); + wdata = calloc(chunk_cnt, sizeof(*wdata)); + + riov = calloc(chunk_cnt, sizeof(*riov)); + rdata = calloc(chunk_cnt, sizeof(*rdata)); + + for (i = 0; i < chunk_cnt; i++) { + rdata[i] = malloc(chunk_size); + riov[i].iov_base = rdata[i]; + riov[i].iov_len = chunk_size; + + wdata[i] = malloc(chunk_size); + memset(wdata[i], i, chunk_size); + wiov[i].iov_base = wdata[i]; + wiov[i].iov_len = chunk_size; + } + + io_error = writev(fd, wiov, chunk_cnt); + if (io_error == -1) { + fprintf(stderr, "write failed: %s\n", strerror(errno)); + return (1); + } else if (io_error != chunk_cnt * chunk_size) { + fprintf(stderr, "truncated write: %d %d\n", + io_error, chunk_cnt * chunk_size); + return (1); + } + + if (lseek(fd, 0, SEEK_SET) == -1) { + fprintf(stderr, "lseek failed: %s\n", strerror(errno)); + return (1); + } + + io_error = readv(fd, riov, chunk_cnt); + if (io_error == -1) { + fprintf(stderr, "read failed: %s\n", strerror(errno)); + return (1); + } else if (io_error != chunk_cnt * chunk_size) { + fprintf(stderr, "truncated read: %d %d\n", + io_error, chunk_cnt * chunk_size); + return (1); + } + + for (i = 0; i < chunk_cnt; i++) { + if (memcmp(rdata[i], wdata[i], chunk_size) != 0) { + fprintf(stderr, "chunk %d differs\n", i); + return (1); + } + } + + return (0); +} Added: user/kib/vm6/tools/regression/ufs/ba_clrbuf/ba_clrbuf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kib/vm6/tools/regression/ufs/ba_clrbuf/ba_clrbuf.c Sat Feb 20 16:41:29 2010 (r204134) @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2009 Konstantin Belousov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const int blks = 2; + +static void +flush_buffers(int fd) +{ + struct stat st; + char *addr; + int error; + + printf("Flushing buffers\n"); + error = fstat(fd, &st); + if (error == -1) + err(2, "stat"); + fsync(fd); + addr = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (addr == (char *)-1) + err(2, "mmap"); + error = msync(addr, st.st_size, MS_SYNC | MS_INVALIDATE); + if (error == -1) + err(2, "msync"); + munmap(addr, st.st_size); +} + +int +main(int argc, char *argv[]) +{ + struct statfs fst; + char *data, *vrfy; + size_t sz; + int fd, i, error, ret; + + if (argc < 2) + errx(2, "Usage: ba_clrbuf file"); + + fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd == -1) + err(2, "Failed to create %s", argv[1]); + + if (fstatfs(fd, &fst) == -1) + err(2, "stat"); + + sz = fst.f_iosize * blks; + data = malloc(sz); + if (data == NULL) + err(2, "malloc"); + vrfy = malloc(sz); + if (vrfy == NULL) + err(2, "malloc"); + for (i = 0; i < (int)sz; i++) + data[i] = i; + error = write(fd, data, sz); + if (error == -1) + err(2, "write"); + else if (error != (int)sz) + errx(2, "Short write %d %d", error, sz); + + flush_buffers(fd); + + error = lseek(fd, 0, SEEK_SET); + if (error == -1) + err(2, "lseek 0"); + else if (error != 0) + errx(2, "lseek 0 returned %d", error); + error = write(fd, NULL, fst.f_iosize); + printf("faulty write, error %s\n", strerror(errno)); + + error = lseek(fd, 0, SEEK_SET); + if (error == -1) + err(2, "lseek 0/2"); + else if (error != 0) + errx(2, "lseek 0/2 returned %d", error); + error = read(fd, vrfy, sz); + if (error == -1) + err(2, "read"); + else if (error != (int)sz) + errx(2, "short read %d %d", error, sz); + + if (memcmp(data, vrfy, fst.f_iosize) != 0) { + printf("Zero block corrupted, byte at 0 is %x\n", + (unsigned char)vrfy[0]); + ret = 1; + } else { + printf("No corruption\n"); + ret = 0; + } + + return (ret); +} From owner-svn-src-user@FreeBSD.ORG Sat Feb 20 23:48:04 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAD66106566C; Sat, 20 Feb 2010 23:48:04 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99D5F8FC1A; Sat, 20 Feb 2010 23:48:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1KNm4m1054545; Sat, 20 Feb 2010 23:48:04 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1KNm42m054543; Sat, 20 Feb 2010 23:48:04 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002202348.o1KNm42m054543@svn.freebsd.org> From: Kip Macy Date: Sat, 20 Feb 2010 23:48:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204154 - user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 23:48:04 -0000 Author: kmacy Date: Sat Feb 20 23:48:04 2010 New Revision: 204154 URL: http://svn.freebsd.org/changeset/base/204154 Log: - import latest L2ARC changes from OpenSolaris - export L2ARC performance tunables as sysctls to permit run-time tuning Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Feb 20 23:42:24 2010 (r204153) +++ user/kmacy/releng_8_fcs_buf_xen/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Feb 20 23:48:04 2010 (r204154) @@ -189,6 +189,8 @@ extern kmem_cache_t *zio_buf_cache[]; extern kmem_cache_t *zio_data_buf_cache[]; #endif +#define ddi_get_lbolt() (LBOLT) + /* * Note that buffers can be in one of 6 states: * ARC_anon - anonymous (discussed below) @@ -567,8 +569,9 @@ uint64_t zfs_crc64_table[256]; */ #define L2ARC_WRITE_SIZE (8 * 1024 * 1024) /* initial write max */ -#define L2ARC_HEADROOM 4 /* num of writes */ -#define L2ARC_FEED_SECS 1 /* caching interval */ +#define L2ARC_HEADROOM 2 /* num of writes */ +#define L2ARC_FEED_SECS 1 /* caching interval secs */ +#define L2ARC_FEED_MIN_MS 200 /* min caching interval ms */ #define l2arc_writes_sent ARCSTAT(arcstat_l2_writes_sent) #define l2arc_writes_done ARCSTAT(arcstat_l2_writes_done) @@ -580,7 +583,29 @@ uint64_t l2arc_write_max = L2ARC_WRITE_S uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra write during warmup */ uint64_t l2arc_headroom = L2ARC_HEADROOM; /* number of dev writes */ uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */ +uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval milliseconds */ boolean_t l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */ +boolean_t l2arc_feed_again = B_TRUE; /* turbo warmup */ +boolean_t l2arc_norw = B_TRUE; /* no reads during writes */ + +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW, + &l2arc_write_max, 0, "max write size"); +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW, + &l2arc_write_boost, 0, "extra write during warmup"); +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW, + &l2arc_headroom, 0, "number of dev writes"); +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW, + &l2arc_feed_secs, 0, "interval seconds"); +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW, + &l2arc_feed_min_ms, 0, "min interval milliseconds"); + +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW, + &l2arc_noprefetch, 0, "don't cache prefetch bufs"); +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RW, + &l2arc_feed_again, 0, "turb warmup"); +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW, + &l2arc_norw, 0, "no reads during writes"); + /* * L2ARC Internals @@ -3891,8 +3916,70 @@ arc_fini(void) * * Tunables may be removed or added as future performance improvements are * integrated, and also may become zpool properties. + * + * There are three key functions that control how the L2ARC warms up: + * + * l2arc_write_eligible() check if a buffer is eligible to cache + * l2arc_write_size() calculate how much to write + * l2arc_write_interval() calculate sleep delay between writes + * + * These three functions determine what to write, how much, and how quickly + * to send writes. */ +static boolean_t +l2arc_write_eligible(spa_t *spa, arc_buf_hdr_t *ab) +{ + /* + * A buffer is *not* eligible for the L2ARC if it: + * 1. belongs to a different spa. + * 2. is already cached on the L2ARC. + * 3. has an I/O in progress (it may be an incomplete read). + * 4. is flagged not eligible (zfs property). + */ + if (ab->b_spa != spa || ab->b_l2hdr != NULL || + HDR_IO_IN_PROGRESS(ab) || !HDR_L2CACHE(ab)) + return (B_FALSE); + + return (B_TRUE); +} + +static uint64_t +l2arc_write_size(l2arc_dev_t *dev) +{ + uint64_t size; + + size = dev->l2ad_write; + + if (arc_warm == B_FALSE) + size += dev->l2ad_boost; + + return (size); + +} + +static clock_t +l2arc_write_interval(clock_t began, uint64_t wanted, uint64_t wrote) +{ + clock_t interval, next, now; + + /* + * If the ARC lists are busy, increase our write rate; if the + * lists are stale, idle back. This is achieved by checking + * how much we previously wrote - if it was more than half of + * what we wanted, schedule the next write much sooner. + */ + if (l2arc_feed_again && wrote > (wanted / 2)) + interval = (hz * l2arc_feed_min_ms) / 1000; + else + interval = hz * l2arc_feed_secs; + + now = ddi_get_lbolt(); + next = MAX(now, MIN(now + interval, began + interval)); + + return (next); +} + static void l2arc_hdr_stat_add(void) { @@ -4313,7 +4400,7 @@ top: * An ARC_L2_WRITING flag is set so that the L2ARC buffers are not valid * for reading until they have completed writing. */ -static void +static uint64_t l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) { arc_buf_hdr_t *ab, *ab_prev, *head; @@ -4379,20 +4466,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_de break; } - if (ab->b_spa != spa) { - mutex_exit(hash_lock); - continue; - } - - if (ab->b_l2hdr != NULL) { - /* - * Already in L2ARC. - */ - mutex_exit(hash_lock); - continue; - } - - if (HDR_IO_IN_PROGRESS(ab) || !HDR_L2CACHE(ab)) { + if (!l2arc_write_eligible(spa, ab)) { mutex_exit(hash_lock); continue; } @@ -4403,12 +4477,6 @@ l2arc_write_buffers(spa_t *spa, l2arc_de break; } - if (ab->b_buf == NULL) { - DTRACE_PROBE1(l2arc__buf__null, void *, ab); - mutex_exit(hash_lock); - continue; - } - if (pio == NULL) { /* * Insert a dummy header on the buflist so @@ -4475,7 +4543,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_de if (pio == NULL) { ASSERT3U(write_sz, ==, 0); kmem_cache_free(hdr_cache, head); - return; + return (0); } ASSERT3U(write_sz, <=, target_sz); @@ -4496,6 +4564,8 @@ l2arc_write_buffers(spa_t *spa, l2arc_de } (void) zio_wait(pio); + + return (write_sz); } /* @@ -4508,20 +4578,19 @@ l2arc_feed_thread(void *dummy __unused) callb_cpr_t cpr; l2arc_dev_t *dev; spa_t *spa; - uint64_t size; + uint64_t size, wrote; + clock_t begin, next = ddi_get_lbolt(); CALLB_CPR_INIT(&cpr, &l2arc_feed_thr_lock, callb_generic_cpr, FTAG); mutex_enter(&l2arc_feed_thr_lock); while (l2arc_thread_exit == 0) { - /* - * Pause for l2arc_feed_secs seconds between writes. - */ CALLB_CPR_SAFE_BEGIN(&cpr); (void) cv_timedwait(&l2arc_feed_thr_cv, &l2arc_feed_thr_lock, - hz * l2arc_feed_secs); + next); CALLB_CPR_SAFE_END(&cpr, &l2arc_feed_thr_lock); + next = ddi_get_lbolt() + hz; /* * Quick check for L2ARC devices. @@ -4532,6 +4601,7 @@ l2arc_feed_thread(void *dummy __unused) continue; } mutex_exit(&l2arc_dev_mtx); + begin = ddi_get_lbolt(); /* * This selects the next l2arc device to write to, and in @@ -4560,9 +4630,7 @@ l2arc_feed_thread(void *dummy __unused) ARCSTAT_BUMP(arcstat_l2_feeds); - size = dev->l2ad_write; - if (arc_warm == B_FALSE) - size += dev->l2ad_boost; + size = l2arc_write_size(dev); /* * Evict L2ARC buffers that will be overwritten. @@ -4572,7 +4640,12 @@ l2arc_feed_thread(void *dummy __unused) /* * Write ARC buffers. */ - l2arc_write_buffers(spa, dev, size); + wrote = l2arc_write_buffers(spa, dev, size); + + /* + * Calculate interval between writes. + */ + next = l2arc_write_interval(begin, size, wrote); spa_config_exit(spa, SCL_L2ARC, dev); }