From brooks at FreeBSD.org Tue Sep 1 02:33:31 2009 From: brooks at FreeBSD.org (Brooks Davis) Date: Tue Sep 1 02:33:48 2009 Subject: svn commit: r196706 - head/usr.sbin/pkg_install/lib In-Reply-To: <200908311750.n7VHoXp0034601@svn.freebsd.org> References: <200908311750.n7VHoXp0034601@svn.freebsd.org> Message-ID: <20090901023240.GF65882@lor.one-eyed-alien.net> On Mon, Aug 31, 2009 at 05:50:33PM +0000, Doug Barton wrote: > Author: dougb > Date: Mon Aug 31 17:50:33 2009 > New Revision: 196706 > URL: http://svn.freebsd.org/changeset/base/196706 > > Log: > Add support for INDEX-9 [1] > > While I'm here, strip off support for FreeBSD 5.x. I'm rather baffled as to why you'd bother removing 5.x support and keep <=4.x support. It seems vanishingly unlikely we'll ever support plain INDEX files again. -- Brooks -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090901/8498a7c7/attachment.pgp From adrian at FreeBSD.org Tue Sep 1 03:44:25 2009 From: adrian at FreeBSD.org (Adrian Chadd) Date: Tue Sep 1 03:44:37 2009 Subject: svn commit: r196725 - head/sys/i386/xen Message-ID: <200909010344.n813iPcH047578@svn.freebsd.org> Author: adrian Date: Tue Sep 1 03:44:25 2009 New Revision: 196725 URL: http://svn.freebsd.org/changeset/base/196725 Log: Fix broken build. Modified: head/sys/i386/xen/pmap.c Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Mon Aug 31 23:35:59 2009 (r196724) +++ head/sys/i386/xen/pmap.c Tue Sep 1 03:44:25 2009 (r196725) @@ -311,6 +311,7 @@ static vm_offset_t pmap_kmem_choose(vm_o static boolean_t pmap_is_prefaultable_locked(pmap_t pmap, vm_offset_t addr); static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); +static __inline void pagezero(void *page); #if defined(PAE) && !defined(XEN) static void *pmap_pdpt_allocf(uma_zone_t zone, int bytes, u_int8_t *flags, int wait); From adrian at FreeBSD.org Tue Sep 1 05:15:46 2009 From: adrian at FreeBSD.org (Adrian Chadd) Date: Tue Sep 1 05:17:28 2009 Subject: svn commit: r196726 - head/sys/i386/xen Message-ID: <200909010515.n815FjLJ049311@svn.freebsd.org> Author: adrian Date: Tue Sep 1 05:15:45 2009 New Revision: 196726 URL: http://svn.freebsd.org/changeset/base/196726 Log: Merge in the pat_works work from sys/i386/i386/pmap.c - primarily to reduce diff size. Modified: head/sys/i386/xen/pmap.c Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Tue Sep 1 03:44:25 2009 (r196725) +++ head/sys/i386/xen/pmap.c Tue Sep 1 05:15:45 2009 (r196726) @@ -223,6 +223,8 @@ static uma_zone_t pdptzone; #endif #endif +static int pat_works; /* Is page attribute table sane? */ + /* * Data for the pv entry allocation mechanism */ @@ -514,33 +516,36 @@ pmap_init_pat(void) if (!(cpu_feature & CPUID_PAT)) return; -#ifdef PAT_WORKS - /* - * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. - * Program 4 and 5 as WP and WC. - * Leave 6 and 7 as UC and UC-. - */ - pat_msr = rdmsr(MSR_PAT); - pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); - pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | - PAT_VALUE(5, PAT_WRITE_COMBINING); -#else - /* - * Due to some Intel errata, we can only safely use the lower 4 - * PAT entries. Thus, just replace PAT Index 2 with WC instead - * of UC-. - * - * Intel Pentium III Processor Specification Update - * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B - * or Mode C Paging) - * - * Intel Pentium IV Processor Specification Update - * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) - */ - pat_msr = rdmsr(MSR_PAT); - pat_msr &= ~PAT_MASK(2); - pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); -#endif + if (cpu_vendor_id != CPU_VENDOR_INTEL || + (I386_CPU_FAMILY(cpu_id) == 6 && I386_CPU_MODEL(cpu_id) >= 0xe)) { + /* + * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. + * Program 4 and 5 as WP and WC. + * Leave 6 and 7 as UC and UC-. + */ + pat_msr = rdmsr(MSR_PAT); + pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); + pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | + PAT_VALUE(5, PAT_WRITE_COMBINING); + pat_works = 1; + } else { + /* + * Due to some Intel errata, we can only safely use the lower 4 + * PAT entries. Thus, just replace PAT Index 2 with WC instead + * of UC-. + * + * Intel Pentium III Processor Specification Update + * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B + * or Mode C Paging) + * + * Intel Pentium IV Processor Specification Update + * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) + */ + pat_msr = rdmsr(MSR_PAT); + pat_msr &= ~PAT_MASK(2); + pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); + pat_works = 0; + } wrmsr(MSR_PAT, pat_msr); } @@ -769,44 +774,48 @@ pmap_cache_bits(int mode, boolean_t is_p } /* Map the caching mode to a PAT index. */ - switch (mode) { -#ifdef PAT_WORKS - case PAT_UNCACHEABLE: - pat_index = 3; - break; - case PAT_WRITE_THROUGH: - pat_index = 1; - break; - case PAT_WRITE_BACK: - pat_index = 0; - break; - case PAT_UNCACHED: - pat_index = 2; - break; - case PAT_WRITE_COMBINING: - pat_index = 5; - break; - case PAT_WRITE_PROTECTED: - pat_index = 4; - break; -#else - case PAT_UNCACHED: - case PAT_UNCACHEABLE: - case PAT_WRITE_PROTECTED: - pat_index = 3; - break; - case PAT_WRITE_THROUGH: - pat_index = 1; - break; - case PAT_WRITE_BACK: - pat_index = 0; - break; - case PAT_WRITE_COMBINING: - pat_index = 2; - break; -#endif - default: - panic("Unknown caching mode %d\n", mode); + if (pat_works) { + switch (mode) { + case PAT_UNCACHEABLE: + pat_index = 3; + break; + case PAT_WRITE_THROUGH: + pat_index = 1; + break; + case PAT_WRITE_BACK: + pat_index = 0; + break; + case PAT_UNCACHED: + pat_index = 2; + break; + case PAT_WRITE_COMBINING: + pat_index = 5; + break; + case PAT_WRITE_PROTECTED: + pat_index = 4; + break; + default: + panic("Unknown caching mode %d\n", mode); + } + } else { + switch (mode) { + case PAT_UNCACHED: + case PAT_UNCACHEABLE: + case PAT_WRITE_PROTECTED: + pat_index = 3; + break; + case PAT_WRITE_THROUGH: + pat_index = 1; + break; + case PAT_WRITE_BACK: + pat_index = 0; + break; + case PAT_WRITE_COMBINING: + pat_index = 2; + break; + default: + panic("Unknown caching mode %d\n", mode); + } } /* Map the 3-bit index value into the PAT, PCD, and PWT bits. */ From maxim at FreeBSD.org Tue Sep 1 05:55:11 2009 From: maxim at FreeBSD.org (Maxim Konovalov) Date: Tue Sep 1 05:55:22 2009 Subject: svn commit: r196727 - head/share/man/man5 Message-ID: <200909010555.n815tAkx050140@svn.freebsd.org> Author: maxim Date: Tue Sep 1 05:55:10 2009 New Revision: 196727 URL: http://svn.freebsd.org/changeset/base/196727 Log: o Document MALLOC_PRODUCTION knob. PR: docs/136029 Submitted by: anonymous MFC after: 2 weeks Modified: head/share/man/man5/make.conf.5 Modified: head/share/man/man5/make.conf.5 ============================================================================== --- head/share/man/man5/make.conf.5 Tue Sep 1 05:15:45 2009 (r196726) +++ head/share/man/man5/make.conf.5 Tue Sep 1 05:55:10 2009 (r196727) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 5, 2006 +.Dd September 1, 2009 .Dt MAKE.CONF 5 .Os .Sh NAME @@ -466,6 +466,12 @@ console driver to and allow access over FireWire(IEEE1394) using .Xr dconschat 8 . Currently, only i386 and amd64 are supported. +.It Va MALLOC_PRODUCTION +.Pq Vt bool +Set this to disable assertions and statistics gathering in +.Xr malloc 3 . +It also defaults the A and J runtime options to off. +Disabled by default on -CURRENT. .It Va MODULES_WITH_WORLD .Pq Vt bool Set to build modules with the system instead of the kernel. From adrian at FreeBSD.org Tue Sep 1 06:15:52 2009 From: adrian at FreeBSD.org (Adrian Chadd) Date: Tue Sep 1 06:15:58 2009 Subject: svn commit: r196728 - head/sys/i386/xen Message-ID: <200909010615.n816Fo0Z050607@svn.freebsd.org> Author: adrian Date: Tue Sep 1 06:15:50 2009 New Revision: 196728 URL: http://svn.freebsd.org/changeset/base/196728 Log: Migrate to use cpuset_t. Modified: head/sys/i386/xen/pmap.c Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Tue Sep 1 05:55:10 2009 (r196727) +++ head/sys/i386/xen/pmap.c Tue Sep 1 06:15:50 2009 (r196728) @@ -1729,7 +1729,7 @@ retry: * Deal with a SMP shootdown of other users of the pmap that we are * trying to dispose of. This can be a bit hairy. */ -static u_int *lazymask; +static cpumask_t *lazymask; static u_int lazyptd; static volatile u_int lazywait; @@ -1738,7 +1738,7 @@ void pmap_lazyfix_action(void); void pmap_lazyfix_action(void) { - u_int mymask = PCPU_GET(cpumask); + cpumask_t mymask = PCPU_GET(cpumask); #ifdef COUNT_IPIS (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++; @@ -1750,7 +1750,7 @@ pmap_lazyfix_action(void) } static void -pmap_lazyfix_self(u_int mymask) +pmap_lazyfix_self(cpumask_t mymask) { if (rcr3() == lazyptd) @@ -1762,8 +1762,7 @@ pmap_lazyfix_self(u_int mymask) static void pmap_lazyfix(pmap_t pmap) { - u_int mymask; - u_int mask; + cpumask_t mymask, mask; u_int spins; while ((mask = pmap->pm_active) != 0) { From kib at FreeBSD.org Tue Sep 1 11:41:51 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Tue Sep 1 11:42:04 2009 Subject: svn commit: r196730 - in head/sys: arm/arm kern sys vm Message-ID: <200909011141.n81BfpGE060068@svn.freebsd.org> Author: kib Date: Tue Sep 1 11:41:51 2009 New Revision: 196730 URL: http://svn.freebsd.org/changeset/base/196730 Log: Reintroduce the r196640, after fixing the problem with my testing. Remove the altkstacks, instead instantiate threads with kernel stack allocated with the right size from the start. For the thread that has kernel stack cached, verify that requested stack size is equial to the actual, and reallocate the stack if sizes differ [1]. This fixes the bug introduced by r173361 that was committed several days after r173004 and consisted of kthread_add(9) ignoring the non-default kernel stack size. Also, r173361 removed the caching of the kernel stacks for a non-first thread in the process. Introduce separate kernel stack cache that keeps some limited amount of preallocated kernel stacks to lower the latency of thread allocation. Add vm_lowmem handler to prune the cache on low memory condition. This way, system with reasonable amount of the threads get lower latency of thread creation, while still not exhausting significant portion of KVA for unused kstacks. Submitted by: peter [1] Discussed with: jhb, julian, peter Reviewed by: jhb Tested by: pho (and retested according to new test scenarious) MFC after: 1 week Modified: head/sys/arm/arm/vm_machdep.c head/sys/kern/kern_fork.c head/sys/kern/kern_kthread.c head/sys/kern/kern_proc.c head/sys/kern/kern_thr.c head/sys/kern/kern_thread.c head/sys/sys/proc.h head/sys/vm/vm_extern.h head/sys/vm/vm_glue.c Modified: head/sys/arm/arm/vm_machdep.c ============================================================================== --- head/sys/arm/arm/vm_machdep.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/arm/arm/vm_machdep.c Tue Sep 1 11:41:51 2009 (r196730) @@ -119,9 +119,6 @@ cpu_fork(register struct thread *td1, re #ifdef __XSCALE__ #ifndef CPU_XSCALE_CORE3 pmap_use_minicache(td2->td_kstack, td2->td_kstack_pages * PAGE_SIZE); - if (td2->td_altkstack) - pmap_use_minicache(td2->td_altkstack, td2->td_altkstack_pages * - PAGE_SIZE); #endif #endif td2->td_pcb = pcb2; Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/kern/kern_fork.c Tue Sep 1 11:41:51 2009 (r196730) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "opt_kdtrace.h" #include "opt_ktrace.h" +#include "opt_kstack_pages.h" #include #include @@ -276,25 +277,29 @@ norfproc_fail: mem_charged = 0; vm2 = NULL; + if (pages == 0) + pages = KSTACK_PAGES; /* Allocate new proc. */ newproc = uma_zalloc(proc_zone, M_WAITOK); - if (TAILQ_EMPTY(&newproc->p_threads)) { - td2 = thread_alloc(); + td2 = FIRST_THREAD_IN_PROC(newproc); + if (td2 == NULL) { + td2 = thread_alloc(pages); if (td2 == NULL) { error = ENOMEM; goto fail1; } proc_linkup(newproc, td2); - } else - td2 = FIRST_THREAD_IN_PROC(newproc); - - /* Allocate and switch to an alternate kstack if specified. */ - if (pages != 0) { - if (!vm_thread_new_altkstack(td2, pages)) { - error = ENOMEM; - goto fail1; + } else { + if (td2->td_kstack == 0 || td2->td_kstack_pages != pages) { + if (td2->td_kstack != 0) + vm_thread_dispose(td2); + if (!thread_alloc_stack(td2, pages)) { + error = ENOMEM; + goto fail1; + } } } + if ((flags & RFMEM) == 0) { vm2 = vmspace_fork(p1->p_vmspace, &mem_charged); if (vm2 == NULL) { Modified: head/sys/kern/kern_kthread.c ============================================================================== --- head/sys/kern/kern_kthread.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/kern/kern_kthread.c Tue Sep 1 11:41:51 2009 (r196730) @@ -256,7 +256,7 @@ kthread_add(void (*func)(void *), void * } /* Initialize our new td */ - newtd = thread_alloc(); + newtd = thread_alloc(pages); if (newtd == NULL) return (ENOMEM); @@ -282,9 +282,6 @@ kthread_add(void (*func)(void *), void * newtd->td_pflags |= TDP_KTHREAD; newtd->td_ucred = crhold(p->p_ucred); - /* Allocate and switch to an alternate kstack if specified. */ - if (pages != 0) - vm_thread_new_altkstack(newtd, pages); /* this code almost the same as create_thread() in kern_thr.c */ PROC_LOCK(p); Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/kern/kern_proc.c Tue Sep 1 11:41:51 2009 (r196730) @@ -203,14 +203,6 @@ proc_dtor(void *mem, int size, void *arg #endif /* Free all OSD associated to this thread. */ osd_thread_exit(td); - - /* Dispose of an alternate kstack, if it exists. - * XXX What if there are more than one thread in the proc? - * The first thread in the proc is special and not - * freed, so you gotta do this here. - */ - if (((p->p_flag & P_KTHREAD) != 0) && (td->td_altkstack != 0)) - vm_thread_dispose_altkstack(td); } EVENTHANDLER_INVOKE(process_dtor, p); if (p->p_ksi != NULL) @@ -767,8 +759,6 @@ fill_kinfo_proc_only(struct proc *p, str FOREACH_THREAD_IN_PROC(p, td0) { if (!TD_IS_SWAPPED(td0)) kp->ki_rssize += td0->td_kstack_pages; - if (td0->td_altkstack_obj != NULL) - kp->ki_rssize += td0->td_altkstack_pages; } kp->ki_swrss = vm->vm_swrss; kp->ki_tsize = vm->vm_tsize; Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/kern/kern_thr.c Tue Sep 1 11:41:51 2009 (r196730) @@ -176,7 +176,7 @@ create_thread(struct thread *td, mcontex } /* Initialize our td */ - newtd = thread_alloc(); + newtd = thread_alloc(0); if (newtd == NULL) return (ENOMEM); Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/kern/kern_thread.c Tue Sep 1 11:41:51 2009 (r196730) @@ -283,7 +283,7 @@ thread_reap(void) * Allocate a thread. */ struct thread * -thread_alloc(void) +thread_alloc(int pages) { struct thread *td; @@ -291,7 +291,7 @@ thread_alloc(void) td = (struct thread *)uma_zalloc(thread_zone, M_WAITOK); KASSERT(td->td_kstack == 0, ("thread_alloc got thread with kstack")); - if (!vm_thread_new(td, 0)) { + if (!vm_thread_new(td, pages)) { uma_zfree(thread_zone, td); return (NULL); } @@ -299,6 +299,17 @@ thread_alloc(void) return (td); } +int +thread_alloc_stack(struct thread *td, int pages) +{ + + KASSERT(td->td_kstack == 0, + ("thread_alloc_stack called on a thread with kstack")); + if (!vm_thread_new(td, pages)) + return (0); + cpu_thread_alloc(td); + return (1); +} /* * Deallocate a thread. @@ -312,8 +323,6 @@ thread_free(struct thread *td) cpuset_rel(td->td_cpuset); td->td_cpuset = NULL; cpu_thread_free(td); - if (td->td_altkstack != 0) - vm_thread_dispose_altkstack(td); if (td->td_kstack != 0) vm_thread_dispose(td); uma_zfree(thread_zone, td); Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/sys/proc.h Tue Sep 1 11:41:51 2009 (r196730) @@ -267,9 +267,6 @@ struct thread { struct vm_object *td_kstack_obj;/* (a) Kstack object. */ vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */ int td_kstack_pages; /* (a) Size of the kstack. */ - struct vm_object *td_altkstack_obj;/* (a) Alternate kstack object. */ - vm_offset_t td_altkstack; /* (a) Kernel VA of alternate kstack. */ - int td_altkstack_pages; /* (a) Size of alternate kstack. */ volatile u_int td_critnest; /* (k*) Critical section nest level. */ struct mdthread td_md; /* (k) Any machine-dependent fields. */ struct td_sched *td_sched; /* (*) Scheduler-specific data. */ @@ -850,7 +847,8 @@ void cpu_thread_exit(struct thread *); void cpu_thread_free(struct thread *); void cpu_thread_swapin(struct thread *); void cpu_thread_swapout(struct thread *); -struct thread *thread_alloc(void); +struct thread *thread_alloc(int pages); +int thread_alloc_stack(struct thread *, int pages); void thread_exit(void) __dead2; void thread_free(struct thread *td); void thread_link(struct thread *td, struct proc *p); Modified: head/sys/vm/vm_extern.h ============================================================================== --- head/sys/vm/vm_extern.h Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/vm/vm_extern.h Tue Sep 1 11:41:51 2009 (r196730) @@ -80,9 +80,7 @@ int vm_fault_quick(caddr_t v, int prot); struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset); void vm_imgact_unmap_page(struct sf_buf *sf); void vm_thread_dispose(struct thread *td); -void vm_thread_dispose_altkstack(struct thread *td); int vm_thread_new(struct thread *td, int pages); -int vm_thread_new_altkstack(struct thread *td, int pages); void vm_thread_swapin(struct thread *td); void vm_thread_swapout(struct thread *td); #endif /* _KERNEL */ Modified: head/sys/vm/vm_glue.c ============================================================================== --- head/sys/vm/vm_glue.c Tue Sep 1 11:13:31 2009 (r196729) +++ head/sys/vm/vm_glue.c Tue Sep 1 11:41:51 2009 (r196730) @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -308,6 +309,20 @@ vm_imgact_unmap_page(struct sf_buf *sf) vm_page_unlock_queues(); } +struct kstack_cache_entry { + vm_object_t ksobj; + struct kstack_cache_entry *next_ks_entry; +}; + +static struct kstack_cache_entry *kstack_cache; +static int kstack_cache_size = 128; +static int kstacks; +static struct mtx kstack_cache_mtx; +SYSCTL_INT(_vm, OID_AUTO, kstack_cache_size, CTLFLAG_RW, &kstack_cache_size, 0, + ""); +SYSCTL_INT(_vm, OID_AUTO, kstacks, CTLFLAG_RD, &kstacks, 0, + ""); + #ifndef KSTACK_MAX_PAGES #define KSTACK_MAX_PAGES 32 #endif @@ -323,6 +338,7 @@ vm_thread_new(struct thread *td, int pag vm_object_t ksobj; vm_offset_t ks; vm_page_t m, ma[KSTACK_MAX_PAGES]; + struct kstack_cache_entry *ks_ce; int i; /* Bounds check */ @@ -330,6 +346,22 @@ vm_thread_new(struct thread *td, int pag pages = KSTACK_PAGES; else if (pages > KSTACK_MAX_PAGES) pages = KSTACK_MAX_PAGES; + + if (pages == KSTACK_PAGES) { + mtx_lock(&kstack_cache_mtx); + if (kstack_cache != NULL) { + ks_ce = kstack_cache; + kstack_cache = ks_ce->next_ks_entry; + mtx_unlock(&kstack_cache_mtx); + + td->td_kstack_obj = ks_ce->ksobj; + td->td_kstack = (vm_offset_t)ks_ce; + td->td_kstack_pages = KSTACK_PAGES; + return (1); + } + mtx_unlock(&kstack_cache_mtx); + } + /* * Allocate an object for the kstack. */ @@ -345,7 +377,8 @@ vm_thread_new(struct thread *td, int pag vm_object_deallocate(ksobj); return (0); } - + + atomic_add_int(&kstacks, 1); if (KSTACK_GUARD_PAGES != 0) { pmap_qremove(ks, KSTACK_GUARD_PAGES); ks += KSTACK_GUARD_PAGES * PAGE_SIZE; @@ -376,20 +409,13 @@ vm_thread_new(struct thread *td, int pag return (1); } -/* - * Dispose of a thread's kernel stack. - */ -void -vm_thread_dispose(struct thread *td) +static void +vm_thread_stack_dispose(vm_object_t ksobj, vm_offset_t ks, int pages) { - vm_object_t ksobj; - vm_offset_t ks; vm_page_t m; - int i, pages; + int i; - pages = td->td_kstack_pages; - ksobj = td->td_kstack_obj; - ks = td->td_kstack; + atomic_add_int(&kstacks, -1); pmap_qremove(ks, pages); VM_OBJECT_LOCK(ksobj); for (i = 0; i < pages; i++) { @@ -405,9 +431,66 @@ vm_thread_dispose(struct thread *td) vm_object_deallocate(ksobj); kmem_free(kernel_map, ks - (KSTACK_GUARD_PAGES * PAGE_SIZE), (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE); +} + +/* + * Dispose of a thread's kernel stack. + */ +void +vm_thread_dispose(struct thread *td) +{ + vm_object_t ksobj; + vm_offset_t ks; + struct kstack_cache_entry *ks_ce; + int pages; + + pages = td->td_kstack_pages; + ksobj = td->td_kstack_obj; + ks = td->td_kstack; td->td_kstack = 0; + td->td_kstack_pages = 0; + if (pages == KSTACK_PAGES && kstacks <= kstack_cache_size) { + ks_ce = (struct kstack_cache_entry *)ks; + ks_ce->ksobj = ksobj; + mtx_lock(&kstack_cache_mtx); + ks_ce->next_ks_entry = kstack_cache; + kstack_cache = ks_ce; + mtx_unlock(&kstack_cache_mtx); + return; + } + vm_thread_stack_dispose(ksobj, ks, pages); +} + +static void +vm_thread_stack_lowmem(void *nulll) +{ + struct kstack_cache_entry *ks_ce, *ks_ce1; + + mtx_lock(&kstack_cache_mtx); + ks_ce = kstack_cache; + kstack_cache = NULL; + mtx_unlock(&kstack_cache_mtx); + + while (ks_ce != NULL) { + ks_ce1 = ks_ce; + ks_ce = ks_ce->next_ks_entry; + + vm_thread_stack_dispose(ks_ce1->ksobj, (vm_offset_t)ks_ce1, + KSTACK_PAGES); + } +} + +static void +kstack_cache_init(void *nulll) +{ + + EVENTHANDLER_REGISTER(vm_lowmem, vm_thread_stack_lowmem, NULL, + EVENTHANDLER_PRI_ANY); } +MTX_SYSINIT(kstack_cache, &kstack_cache_mtx, "kstkch", MTX_DEF); +SYSINIT(vm_kstacks, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY, kstack_cache_init, NULL); + /* * Allow a thread's kernel stack to be paged out. */ @@ -468,37 +551,6 @@ vm_thread_swapin(struct thread *td) } /* - * Set up a variable-sized alternate kstack. - */ -int -vm_thread_new_altkstack(struct thread *td, int pages) -{ - - td->td_altkstack = td->td_kstack; - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack_pages = td->td_kstack_pages; - - return (vm_thread_new(td, pages)); -} - -/* - * Restore the original kstack. - */ -void -vm_thread_dispose_altkstack(struct thread *td) -{ - - vm_thread_dispose(td); - - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Implement fork's actions on an address space. * Here we arrange for the address space to be copied or referenced, * allocate a user struct (pcb and kernel stack), then call the From kib at FreeBSD.org Tue Sep 1 12:05:39 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Tue Sep 1 12:05:51 2009 Subject: svn commit: r196733 - head/sys/kern Message-ID: <200909011205.n81C5dSV060831@svn.freebsd.org> Author: kib Date: Tue Sep 1 12:05:39 2009 New Revision: 196733 URL: http://svn.freebsd.org/changeset/base/196733 Log: Fix mount reference leak when V_XSLEEP is specified to vn_start_write(). Submitted by: tegge Modified: head/sys/kern/vfs_vnops.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Tue Sep 1 12:04:43 2009 (r196732) +++ head/sys/kern/vfs_vnops.c Tue Sep 1 12:05:39 2009 (r196733) @@ -999,7 +999,7 @@ vn_start_write(vp, mpp, flags) goto unlock; mp->mnt_writeopcount++; unlock: - if (error != 0) + if (error != 0 || (flags & V_XSLEEP) != 0) MNT_REL(mp); MNT_IUNLOCK(mp); return (error); From adrian at FreeBSD.org Tue Sep 1 12:17:48 2009 From: adrian at FreeBSD.org (Adrian Chadd) Date: Tue Sep 1 12:17:54 2009 Subject: svn commit: r196734 - head/sys/i386/xen Message-ID: <200909011217.n81CHlZR061114@svn.freebsd.org> Author: adrian Date: Tue Sep 1 12:17:47 2009 New Revision: 196734 URL: http://svn.freebsd.org/changeset/base/196734 Log: Delete whitespace not in i386/pmap.c Modified: head/sys/i386/xen/pmap.c Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Tue Sep 1 12:05:39 2009 (r196733) +++ head/sys/i386/xen/pmap.c Tue Sep 1 12:17:47 2009 (r196734) @@ -4171,7 +4171,6 @@ pmap_activate(struct thread *td) td->td_pcb->pcb_cr3 = cr3; PT_UPDATES_FLUSH(); load_cr3(cr3); - PCPU_SET(curpmap, pmap); critical_exit(); } From trasz at FreeBSD.org Tue Sep 1 15:51:36 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Tue Sep 1 15:51:48 2009 Subject: svn commit: r196736 - head/tools/regression/acltools Message-ID: <200909011551.n81FpaIg065634@svn.freebsd.org> Author: trasz Date: Tue Sep 1 15:51:36 2009 New Revision: 196736 URL: http://svn.freebsd.org/changeset/base/196736 Log: Adapt to the fact that ls(1) correctly prints '+' for symlinks with ACLs now. Modified: head/tools/regression/acltools/tools-posix.test Modified: head/tools/regression/acltools/tools-posix.test ============================================================================== --- head/tools/regression/acltools/tools-posix.test Tue Sep 1 15:50:07 2009 (r196735) +++ head/tools/regression/acltools/tools-posix.test Tue Sep 1 15:51:36 2009 (r196736) @@ -77,9 +77,8 @@ $ getfacl -h lll > mask::rwx > other::r-x -# XXX: Why doesn't ls(1) print '+' for symbolic links with ACL set? $ ls -l lll | cut -d' ' -f1 -> lrwxrwxr-x +> lrwxrwxr-x+ # Check whether the original file is left untouched. $ ls -l xxx | cut -d' ' -f1 From dougb at FreeBSD.org Tue Sep 1 16:21:10 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Tue Sep 1 16:21:17 2009 Subject: svn commit: r196706 - head/usr.sbin/pkg_install/lib In-Reply-To: <20090901023240.GF65882@lor.one-eyed-alien.net> References: <200908311750.n7VHoXp0034601@svn.freebsd.org> <20090901023240.GF65882@lor.one-eyed-alien.net> Message-ID: <4A9D49EA.1070601@FreeBSD.org> Brooks Davis wrote: > On Mon, Aug 31, 2009 at 05:50:33PM +0000, Doug Barton wrote: >> Author: dougb >> Date: Mon Aug 31 17:50:33 2009 >> New Revision: 196706 >> URL: http://svn.freebsd.org/changeset/base/196706 >> >> Log: >> Add support for INDEX-9 [1] >> >> While I'm here, strip off support for FreeBSD 5.x. > > I'm rather baffled as to why you'd bother removing 5.x support and keep > <=4.x support. It seems vanishingly unlikely we'll ever support plain > INDEX files again. Feel free to remove it if you think that's the right decision. I wasn't sure, so I left it alone. Doug -- This .signature sanitized for your protection From dougb at FreeBSD.org Tue Sep 1 16:23:55 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Tue Sep 1 16:24:06 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <200909010555.n815tAkx050140@svn.freebsd.org> References: <200909010555.n815tAkx050140@svn.freebsd.org> Message-ID: <4A9D4A90.30700@FreeBSD.org> Maxim Konovalov wrote: > Author: maxim > Date: Tue Sep 1 05:55:10 2009 > New Revision: 196727 > URL: http://svn.freebsd.org/changeset/base/196727 > > Log: > o Document MALLOC_PRODUCTION knob. > > PR: docs/136029 > Submitted by: anonymous > MFC after: 2 weeks > > Modified: > head/share/man/man5/make.conf.5 Unless I'm missing something this should be in the src.conf man page instead of make.conf. Doug -- This .signature sanitized for your protection From danfe at FreeBSD.org Tue Sep 1 16:28:56 2009 From: danfe at FreeBSD.org (Alexey Dokuchaev) Date: Tue Sep 1 16:29:02 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <4A9D4A90.30700@FreeBSD.org> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> Message-ID: <20090901162856.GA54192@FreeBSD.org> On Tue, Sep 01, 2009 at 09:23:44AM -0700, Doug Barton wrote: > Maxim Konovalov wrote: > > Author: maxim > > Date: Tue Sep 1 05:55:10 2009 > > New Revision: 196727 > > URL: http://svn.freebsd.org/changeset/base/196727 > > > > Log: > > o Document MALLOC_PRODUCTION knob. > > > > PR: docs/136029 > > Submitted by: anonymous > > MFC after: 2 weeks > > > > Modified: > > head/share/man/man5/make.conf.5 > > Unless I'm missing something this should be in the src.conf man page > instead of make.conf. However, I'm used to make.conf since 4.x days, so at least cross-reference of some sort is in order (I'm not sure, there might be one already now that I write this). ./danfe From dougb at FreeBSD.org Tue Sep 1 17:40:56 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Tue Sep 1 17:41:08 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <20090901162856.GA54192@FreeBSD.org> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> <20090901162856.GA54192@FreeBSD.org> Message-ID: <4A9D5C9C.3060002@FreeBSD.org> Alexey Dokuchaev wrote: > However, I'm used to make.conf since 4.x days, so at least > cross-reference of some sort is in order (I'm not sure, there might be > one already now that I write this). SEE ALSO gcc(1), install(1), make(1), src.conf(5) ... :) Doug -- This .signature sanitized for your protection From bz at FreeBSD.org Tue Sep 1 17:53:02 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Sep 1 17:53:08 2009 Subject: svn commit: r196738 - head/sys/netinet Message-ID: <200909011753.n81Hr1AV068295@svn.freebsd.org> Author: bz Date: Tue Sep 1 17:53:01 2009 New Revision: 196738 URL: http://svn.freebsd.org/changeset/base/196738 Log: In case an upper layer protocol tries to send a packet but the L2 code does not have the ethernet address for the destination within the broadcast domain in the table, we remember the original mbuf in `la_hold' in arpresolve() and send out a different packet with an arp request. In case there will be more upper layer packets to send we will free an earlier one held in `la_hold' and queue the new one. Once we get a packet in, with which we can perfect our arp table entry we send out the original 'on hold' packet, should there be any. Rather than continuing to process the packet that we received, we returned without freeing the packet that came in, which basically means that we leaked an mbuf for every arp request we sent. Rather than freeing the received packet and returning, continue to process the incoming arp packet as well. This should (a) improve some setups, also proxy-arp, in case it was an incoming arp request and (b) resembles the behaviour FreeBSD had from day 1, which alignes with RFC826 "Packet reception" (merge case). Rename 'm0' to 'hold' to make the code more understandable as well as diffable to earlier versions more easily. Handle the link-layer entry 'la' lock comepletely in the block where needed and release it as early as possible, rather than holding it longer, down to the end of the function. Found by: pointyhat, ns1 Bug hunting session with: erwin, simon, rwatson Tested by: simon on cluster machines Reviewed by: ratson, kmacy, julian MFC after: 3 days Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Tue Sep 1 16:41:28 2009 (r196737) +++ head/sys/netinet/if_ether.c Tue Sep 1 17:53:01 2009 (r196738) @@ -462,11 +462,11 @@ in_arpinput(struct mbuf *m) struct rtentry *rt; struct ifaddr *ifa; struct in_ifaddr *ia; + struct mbuf *hold; struct sockaddr sa; struct in_addr isaddr, itaddr, myaddr; u_int8_t *enaddr = NULL; int op, flags; - struct mbuf *m0; int req_len; int bridged = 0, is_bridge = 0; #ifdef DEV_CARP @@ -631,11 +631,13 @@ match: la->lle_tbl->llt_ifp->if_xname, ifp->if_addrlen, (u_char *)ar_sha(ah), ":", ifp->if_xname); + LLE_WUNLOCK(la); goto reply; } if ((la->la_flags & LLE_VALID) && bcmp(ar_sha(ah), &la->ll_addr, ifp->if_addrlen)) { if (la->la_flags & LLE_STATIC) { + LLE_WUNLOCK(la); log(LOG_ERR, "arp: %*D attempts to modify permanent " "entry for %s on %s\n", @@ -655,6 +657,7 @@ match: } if (ifp->if_addrlen != ah->ar_hln) { + LLE_WUNLOCK(la); log(LOG_WARNING, "arp from %*D: addr len: new %d, i/f %d (ignored)", ifp->if_addrlen, (u_char *) ar_sha(ah), ":", @@ -671,15 +674,14 @@ match: } la->la_asked = 0; la->la_preempt = V_arp_maxtries; - if (la->la_hold != NULL) { - m0 = la->la_hold; - la->la_hold = 0; + hold = la->la_hold; + if (hold != NULL) { + la->la_hold = NULL; memcpy(&sa, L3_ADDR(la), sizeof(sa)); - LLE_WUNLOCK(la); - - (*ifp->if_output)(ifp, m0, &sa, NULL); - return; } + LLE_WUNLOCK(la); + if (hold != NULL) + (*ifp->if_output)(ifp, hold, &sa, NULL); } reply: if (op != ARPOP_REQUEST) @@ -750,8 +752,6 @@ reply: #endif } - if (la != NULL) - LLE_WUNLOCK(la); if (itaddr.s_addr == myaddr.s_addr && IN_LINKLOCAL(ntohl(itaddr.s_addr))) { /* RFC 3927 link-local IPv4; always reply by broadcast. */ @@ -777,8 +777,6 @@ reply: return; drop: - if (la != NULL) - LLE_WUNLOCK(la); m_freem(m); } #endif From gnn at FreeBSD.org Tue Sep 1 17:55:37 2009 From: gnn at FreeBSD.org (George V. Neville-Neil) Date: Tue Sep 1 17:55:43 2009 Subject: svn commit: r196739 - head/sys/dev/hwpmc Message-ID: <200909011755.n81HtbaJ068398@svn.freebsd.org> Author: gnn Date: Tue Sep 1 17:55:37 2009 New Revision: 196739 URL: http://svn.freebsd.org/changeset/base/196739 Log: Add counters for the i7 architecture which were accidentally left out of the original commit of i7 support. These are all the counters on pages A-32 and A-33 of the _Intel(R) 64 and IA32 Architectures Software Developer's Manual Vol 3B_, June 2009. Almost all of these counters relate to operations on the L2 cache. Reviewed by: jkoshy MFC after: 1 month Modified: head/sys/dev/hwpmc/hwpmc_core.c head/sys/dev/hwpmc/pmc_events.h Modified: head/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_core.c Tue Sep 1 17:53:01 2009 (r196738) +++ head/sys/dev/hwpmc/hwpmc_core.c Tue Sep 1 17:55:37 2009 (r196739) @@ -1182,6 +1182,29 @@ static struct iap_event_descr iap_events IAPDESCR(DBH_01H, 0xDB, 0x01, IAP_F_FM | IAP_F_I7), IAPDESCR(E4H_01H, 0xE4, 0x01, IAP_F_FM | IAP_F_I7), IAPDESCR(E5H_01H, 0xE5, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(E6H_01H, 0xE6, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(E6H_02H, 0xE6, 0x02, IAP_F_FM | IAP_F_I7), + IAPDESCR(E8H_01H, 0xE8, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(E8H_02H, 0xE8, 0x02, IAP_F_FM | IAP_F_I7), + IAPDESCR(E8H_03H, 0xE8, 0x03, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_01H, 0xF0, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_02H, 0xF0, 0x02, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_04H, 0xF0, 0x04, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_08H, 0xF0, 0x08, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_10H, 0xF0, 0x10, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_20H, 0xF0, 0x20, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_40H, 0xF0, 0x40, IAP_F_FM | IAP_F_I7), + IAPDESCR(F0H_80H, 0xF0, 0x80, IAP_F_FM | IAP_F_I7), + IAPDESCR(F1H_02H, 0xF1, 0x02, IAP_F_FM | IAP_F_I7), + IAPDESCR(F1H_04H, 0xF1, 0x04, IAP_F_FM | IAP_F_I7), + IAPDESCR(F1H_07H, 0xF1, 0x07, IAP_F_FM | IAP_F_I7), + IAPDESCR(F2H_01H, 0xF2, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(F2H_02H, 0xF2, 0x02, IAP_F_FM | IAP_F_I7), + IAPDESCR(F2H_04H, 0xF2, 0x04, IAP_F_FM | IAP_F_I7), + IAPDESCR(F2H_08H, 0xF2, 0x08, IAP_F_FM | IAP_F_I7), + IAPDESCR(F2H_0FH, 0xF2, 0x0F, IAP_F_FM | IAP_F_I7), + IAPDESCR(F3H_01H, 0xF3, 0x01, IAP_F_FM | IAP_F_I7), + IAPDESCR(F3H_02H, 0xF3, 0x02, IAP_F_FM | IAP_F_I7), IAPDESCR(F3H_04H, 0xF3, 0x04, IAP_F_FM | IAP_F_I7), IAPDESCR(F3H_08H, 0xF3, 0x08, IAP_F_FM | IAP_F_I7), IAPDESCR(F3H_10H, 0xF3, 0x10, IAP_F_FM | IAP_F_I7), Modified: head/sys/dev/hwpmc/pmc_events.h ============================================================================== --- head/sys/dev/hwpmc/pmc_events.h Tue Sep 1 17:53:01 2009 (r196738) +++ head/sys/dev/hwpmc/pmc_events.h Tue Sep 1 17:55:37 2009 (r196739) @@ -29,8 +29,18 @@ #ifndef _DEV_HWPMC_PMC_EVENTS_H_ #define _DEV_HWPMC_PMC_EVENTS_H_ -/* - * PMC event codes. +/* + * Note: Documentation on adding events can be found both in + * the source tree at src/share/doc/papers/hwpmc/hwpmc.ms + * as well as on-line at: + * + * http://wiki.freebsd.org/PmcTools/PmcHardwareHowTo + * + * Please refer to those resources before you attempt to modify + * this file or the hwpmc driver/subsystem. + */ + +/* * PMC event codes. * * __PMC_EV(CLASS, SYMBOLIC-NAME) * @@ -973,7 +983,30 @@ __PMC_EV(IAP, EVENT_FDH_04H) \ __PMC_EV(IAP, EVENT_FDH_08H) \ __PMC_EV(IAP, EVENT_FDH_10H) \ __PMC_EV(IAP, EVENT_FDH_20H) \ -__PMC_EV(IAP, EVENT_FDH_40H) +__PMC_EV(IAP, EVENT_FDH_40H) \ +__PMC_EV(IAP, EVENT_E6H_02H) \ +__PMC_EV(IAP, EVENT_E8H_01H) \ +__PMC_EV(IAP, EVENT_E8H_02H) \ +__PMC_EV(IAP, EVENT_E8H_03H) \ +__PMC_EV(IAP, EVENT_F0H_01H) \ +__PMC_EV(IAP, EVENT_F0H_02H) \ +__PMC_EV(IAP, EVENT_F0H_04H) \ +__PMC_EV(IAP, EVENT_F0H_08H) \ +__PMC_EV(IAP, EVENT_F0H_10H) \ +__PMC_EV(IAP, EVENT_F0H_20H) \ +__PMC_EV(IAP, EVENT_F0H_40H) \ +__PMC_EV(IAP, EVENT_F0H_80H) \ +__PMC_EV(IAP, EVENT_F1H_02H) \ +__PMC_EV(IAP, EVENT_F1H_04H) \ +__PMC_EV(IAP, EVENT_F1H_07H) \ +__PMC_EV(IAP, EVENT_F2H_01H) \ +__PMC_EV(IAP, EVENT_F2H_02H) \ +__PMC_EV(IAP, EVENT_F2H_04H) \ +__PMC_EV(IAP, EVENT_F2H_08H) \ +__PMC_EV(IAP, EVENT_F2H_0FH) \ +__PMC_EV(IAP, EVENT_F3H_01H) \ +__PMC_EV(IAP, EVENT_F3H_02H) + #define PMC_EV_IAP_FIRST PMC_EV_IAP_EVENT_02H_81H #define PMC_EV_IAP_LAST PMC_EV_IAP_EVENT_FDH_40H @@ -1894,6 +1927,29 @@ __PMC_EV_ALIAS("UOP_UNFUSION", IAP_EV __PMC_EV_ALIAS("BR_INST_DECODED", IAP_EVENT_E0H_01H) \ __PMC_EV_ALIAS("BOGUS_BR", IAP_EVENT_E4H_01H) \ __PMC_EV_ALIAS("BPU_MISSED_CALL_RET", IAP_EVENT_E5H_01H) \ +__PMC_EV_ALIAS("BACLEAR.CLEAR", IAP_EVENT_E6H_01H) \ +__PMC_EV_ALIAS("BACLEAR.BAD_TARGET", IAP_EVENT_E6H_02H) \ +__PMC_EV_ALIAS("BPU_CLEARS.EARLY", IAP_EVENT_E8H_01H) \ +__PMC_EV_ALIAS("BPU_CLEARS.LATE", IAP_EVENT_E8H_02H) \ +__PMC_EV_ALIAS("BPU_CLEARS.ANY", IAP_EVENT_E8H_03H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.LOAD", IAP_EVENT_F0H_01H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.RFO", IAP_EVENT_F0H_02H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.IFETCH", IAP_EVENT_F0H_04H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.PREFETCH", IAP_EVENT_F0H_08H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.L1D_WB", IAP_EVENT_F0H_10H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.FILL", IAP_EVENT_F0H_20H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.WB", IAP_EVENT_F0H_40H) \ +__PMC_EV_ALIAS("L2_TRANSACTIONS.ANY", IAP_EVENT_F0H_80H) \ +__PMC_EV_ALIAS("L2_LINES_IN.S_STATE", IAP_EVENT_F1H_02H) \ +__PMC_EV_ALIAS("L2_LINES_IN.E_STATE", IAP_EVENT_F1H_04H) \ +__PMC_EV_ALIAS("L2_LINES_IN.ANY", IAP_EVENT_F1H_07H) \ +__PMC_EV_ALIAS("L2_LINES_OUT.DEMAND_CLEAN", IAP_EVENT_F2H_01H) \ +__PMC_EV_ALIAS("L2_LINES_OUT.DEMAND_DIRTY", IAP_EVENT_F2H_02H) \ +__PMC_EV_ALIAS("L2_LINES_OUT.PREFETCH_CLEAN", IAP_EVENT_F2H_04H) \ +__PMC_EV_ALIAS("L2_LINES_OUT.PREFETCH_DIRTY", IAP_EVENT_F2H_08H) \ +__PMC_EV_ALIAS("L2_LINES_OUT.ANY", IAP_EVENT_F2H_0FH) \ +__PMC_EV_ALIAS("L2_HW_PREFETCH.HIT", IAP_EVENT_F3H_01H) \ +__PMC_EV_ALIAS("L2_HW_PREFETCH.ALLOC", IAP_EVENT_F3H_02H) \ __PMC_EV_ALIAS("L2_HW_PREFETCH.DATA_TRIGGER", IAP_EVENT_F3H_04H) \ __PMC_EV_ALIAS("L2_HW_PREFETCH.CODE_TRIGGER", IAP_EVENT_F3H_08H) \ __PMC_EV_ALIAS("L2_HW_PREFETCH.DCA_TRIGGER", IAP_EVENT_F3H_10H) \ From trasz at FreeBSD.org Tue Sep 1 18:30:18 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Tue Sep 1 18:30:24 2009 Subject: svn commit: r196740 - head/lib/libc/posix1e Message-ID: <200909011830.n81IUHAu069085@svn.freebsd.org> Author: trasz Date: Tue Sep 1 18:30:17 2009 New Revision: 196740 URL: http://svn.freebsd.org/changeset/base/196740 Log: Fix regression introduced with NFSv4 ACL support - make acl_to_text(3) and acl_calc_mask(3) return error instead of crashing when acl passed to them is NULL. Submitted by: markus Reviewed by: rwatson MFC after: 3 days Modified: head/lib/libc/posix1e/acl_calc_mask.c head/lib/libc/posix1e/acl_to_text.c Modified: head/lib/libc/posix1e/acl_calc_mask.c ============================================================================== --- head/lib/libc/posix1e/acl_calc_mask.c Tue Sep 1 17:55:37 2009 (r196739) +++ head/lib/libc/posix1e/acl_calc_mask.c Tue Sep 1 18:30:17 2009 (r196740) @@ -50,12 +50,6 @@ acl_calc_mask(acl_t *acl_p) acl_t acl_new; int i, mask_mode, mask_num; - if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { - errno = EINVAL; - return (-1); - } - _acl_brand_as(*acl_p, ACL_BRAND_POSIX); - /* * (23.4.2.4) requires acl_p to point to a pointer to a valid ACL. * Since one of the primary reasons to use this function would be @@ -67,6 +61,13 @@ acl_calc_mask(acl_t *acl_p) errno = EINVAL; return (-1); } + + if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { + errno = EINVAL; + return (-1); + } + _acl_brand_as(*acl_p, ACL_BRAND_POSIX); + acl_int = &(*acl_p)->ats_acl; if ((acl_int->acl_cnt < 3) || (acl_int->acl_cnt > ACL_MAX_ENTRIES)) { errno = EINVAL; Modified: head/lib/libc/posix1e/acl_to_text.c ============================================================================== --- head/lib/libc/posix1e/acl_to_text.c Tue Sep 1 17:55:37 2009 (r196739) +++ head/lib/libc/posix1e/acl_to_text.c Tue Sep 1 18:30:17 2009 (r196740) @@ -70,11 +70,6 @@ _posix1e_acl_to_text(acl_t acl, ssize_t if (buf == NULL) return(NULL); - if (acl == NULL) { - errno = EINVAL; - return(NULL); - } - acl_int = &acl->ats_acl; mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */ @@ -243,6 +238,11 @@ char * acl_to_text_np(acl_t acl, ssize_t *len_p, int flags) { + if (acl == NULL) { + errno = EINVAL; + return(NULL); + } + switch (_acl_brand(acl)) { case ACL_BRAND_POSIX: return (_posix1e_acl_to_text(acl, len_p, flags)); From simon at FreeBSD.org Tue Sep 1 20:27:02 2009 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Tue Sep 1 20:27:12 2009 Subject: svn commit: r196738 - head/sys/netinet In-Reply-To: <200909011753.n81Hr1AV068295@svn.freebsd.org> References: <200909011753.n81Hr1AV068295@svn.freebsd.org> Message-ID: <20090901202659.GA1495@arthur.nitro.dk> On 2009.09.01 17:53:01 +0000, Bjoern A. Zeeb wrote: > Author: bz > Date: Tue Sep 1 17:53:01 2009 > New Revision: 196738 > URL: http://svn.freebsd.org/changeset/base/196738 > > Log: > In case an upper layer protocol tries to send a packet but the > L2 code does not have the ethernet address for the destination > within the broadcast domain in the table, we remember the > original mbuf in `la_hold' in arpresolve() and send out a > different packet with an arp request. [...] Thanks! In case anybody is interested, this was the issue which indirectly killed the FreeBSD mail system for some hours recently. It was caused by ns1.FreeBSD.org stopped responding to network traffic due to it running out of mbuf's. Feel free to guess when bz's patch was applied ;-) : http://people.freebsd.org/~simon/misc/mbuf_leak_ns1_200908.png . The final spike on the graph is me running 'arp -da' a bunch of times. -- Simon L. Nielsen From ivoras at freebsd.org Tue Sep 1 21:50:41 2009 From: ivoras at freebsd.org (Ivan Voras) Date: Tue Sep 1 21:50:52 2009 Subject: svn commit: r196738 - head/sys/netinet In-Reply-To: <20090901202659.GA1495@arthur.nitro.dk> References: <200909011753.n81Hr1AV068295@svn.freebsd.org> <20090901202659.GA1495@arthur.nitro.dk> Message-ID: <9bbcef730909011450t37582b50pecf87bb9927faf18@mail.gmail.com> 2009/9/1 Simon L. Nielsen : > On 2009.09.01 17:53:01 +0000, Bjoern A. Zeeb wrote: >> Author: bz >> Date: Tue Sep ?1 17:53:01 2009 >> New Revision: 196738 >> URL: http://svn.freebsd.org/changeset/base/196738 >> >> Log: >> ? In case an upper layer protocol tries to send a packet but the >> ? L2 code does not have the ethernet address for the destination >> ? within the broadcast domain in the table, we remember the >> ? original mbuf in `la_hold' in arpresolve() and send out a >> ? different packet with an arp request. > > [...] > > Thanks! > > In case anybody is interested, this was the issue which indirectly > killed the FreeBSD mail system for some hours recently. ?It was caused > by ns1.FreeBSD.org stopped responding to network traffic due to it > running out of mbuf's. > > Feel free to guess when bz's patch was applied ;-) : > http://people.freebsd.org/~simon/misc/mbuf_leak_ns1_200908.png . ?The > final spike on the graph is me running 'arp -da' a bunch of times. Interesting :) I assume this is 8 / HEAD -specific due to work done in ARP code? From jhb at FreeBSD.org Wed Sep 2 00:39:59 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Sep 2 00:40:11 2009 Subject: svn commit: r196745 - in head/sys: amd64/amd64 i386/i386 Message-ID: <200909020039.n820dx8T076650@svn.freebsd.org> Author: jhb Date: Wed Sep 2 00:39:59 2009 New Revision: 196745 URL: http://svn.freebsd.org/changeset/base/196745 Log: Don't attempt to bind the current thread to the CPU an IRQ is bound to when removing an interrupt handler from an IRQ during shutdown. During shutdown we are already bound to CPU 0 and this was triggering a panic. MFC after: 3 days Modified: head/sys/amd64/amd64/local_apic.c head/sys/i386/i386/local_apic.c Modified: head/sys/amd64/amd64/local_apic.c ============================================================================== --- head/sys/amd64/amd64/local_apic.c Tue Sep 1 22:24:27 2009 (r196744) +++ head/sys/amd64/amd64/local_apic.c Wed Sep 2 00:39:59 2009 (r196745) @@ -990,18 +990,21 @@ apic_free_vector(u_int apic_id, u_int ve * we don't lose an interrupt delivery race. */ td = curthread; - thread_lock(td); - if (sched_is_bound(td)) - panic("apic_free_vector: Thread already bound.\n"); - sched_bind(td, apic_cpuid(apic_id)); - thread_unlock(td); + if (!rebooting) { + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); + } mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = -1; mtx_unlock_spin(&icu_lock); - thread_lock(td); - sched_unbind(td); - thread_unlock(td); - + if (!rebooting) { + thread_lock(td); + sched_unbind(td); + thread_unlock(td); + } } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ Modified: head/sys/i386/i386/local_apic.c ============================================================================== --- head/sys/i386/i386/local_apic.c Tue Sep 1 22:24:27 2009 (r196744) +++ head/sys/i386/i386/local_apic.c Wed Sep 2 00:39:59 2009 (r196745) @@ -994,18 +994,21 @@ apic_free_vector(u_int apic_id, u_int ve * we don't lose an interrupt delivery race. */ td = curthread; - thread_lock(td); - if (sched_is_bound(td)) - panic("apic_free_vector: Thread already bound.\n"); - sched_bind(td, apic_cpuid(apic_id)); - thread_unlock(td); + if (!rebooting) { + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); + } mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = -1; mtx_unlock_spin(&icu_lock); - thread_lock(td); - sched_unbind(td); - thread_unlock(td); - + if (!rebooting) { + thread_lock(td); + sched_unbind(td); + thread_unlock(td); + } } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ From ache at FreeBSD.org Wed Sep 2 04:26:34 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Wed Sep 2 04:26:41 2009 Subject: svn commit: r196750 - head/contrib/ee Message-ID: <200909020426.n824QY98081387@svn.freebsd.org> Author: ache Date: Wed Sep 2 04:26:34 2009 New Revision: 196750 URL: http://svn.freebsd.org/changeset/base/196750 Log: 1) Use isprint() instead of hardcoded values to detect non-printable. 2) Use (unsigned char) cast in waddch() calls. It fix highlighting bug: sign extension of 8bit to the attributes area. 3) Use setlocale() in any case. Modified: head/contrib/ee/ee.c Modified: head/contrib/ee/ee.c ============================================================================== --- head/contrib/ee/ee.c Wed Sep 2 03:03:53 2009 (r196749) +++ head/contrib/ee/ee.c Wed Sep 2 04:26:34 2009 (r196750) @@ -726,7 +726,7 @@ int character; /* new character */ } *point = character; /* insert new character */ wclrtoeol(text_win); - if (((character >= 0) && (character < ' ')) || (character >= 127)) /* check for TAB character*/ + if (!isprint((unsigned char)character)) /* check for TAB character*/ { scr_pos = scr_horz += out_char(text_win, character, scr_horz); point++; @@ -734,7 +734,7 @@ int character; /* new character */ } else { - waddch(text_win, character); + waddch(text_win, (unsigned char)character); scr_pos = ++scr_horz; point++; position ++; @@ -969,17 +969,17 @@ int column; } else { - waddch(window, (char)character ); + waddch(window, (unsigned char)character ); return(1); } } else { - waddch(window, (char)character); + waddch(window, (unsigned char)character); return(1); } for (i2 = 0; (string[i2] != '\0') && (((column+i2+1)-horiz_offset) < last_col); i2++) - waddch(window, string[i2]); + waddch(window, (unsigned char)string[i2]); return(strlen(string)); } @@ -1044,7 +1044,7 @@ int length; /* length (in bytes) of line wclrtoeol(text_win); while ((posit < length) && (column <= last_col)) { - if ((*temp < 32) || (*temp >= 127)) + if (!isprint(*temp)) { column += len_char(*temp, abs_column); abs_column += out_char(text_win, *temp, abs_column); @@ -1923,13 +1923,13 @@ int advance; /* if true, skip leading s } *nam_str = in; g_pos++; - if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 1))) + if (!isprint((unsigned char)in) && (g_horz < (last_col - 1))) g_horz += out_char(com_win, in, g_horz); else { g_horz++; if (g_horz < (last_col - 1)) - waddch(com_win, in); + waddch(com_win, (unsigned char)in); } nam_str++; } @@ -5085,8 +5085,8 @@ strings_init() { int counter; -#ifndef NO_CATGETS setlocale(LC_ALL, ""); +#ifndef NO_CATGETS catalog = catopen("ee", NL_CAT_LOCALE); #endif /* NO_CATGETS */ From ache at FreeBSD.org Wed Sep 2 04:43:47 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Wed Sep 2 04:43:54 2009 Subject: svn commit: r196751 - head/contrib/ee Message-ID: <200909020443.n824hl88081733@svn.freebsd.org> Author: ache Date: Wed Sep 2 04:43:46 2009 New Revision: 196751 URL: http://svn.freebsd.org/changeset/base/196751 Log: Move out of NO_CATGETS define too (as setlocale() in prev. commit) Modified: head/contrib/ee/ee.c Modified: head/contrib/ee/ee.c ============================================================================== --- head/contrib/ee/ee.c Wed Sep 2 04:26:34 2009 (r196750) +++ head/contrib/ee/ee.c Wed Sep 2 04:43:46 2009 (r196751) @@ -83,6 +83,7 @@ char *version = "@(#) ee, version " EE_ #include #include #include +#include #ifdef HAS_SYS_WAIT #include @@ -100,9 +101,7 @@ char *version = "@(#) ee, version " EE_ #include #endif - #ifndef NO_CATGETS -#include #include nl_catd catalog; From ache at FreeBSD.org Wed Sep 2 04:56:30 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Wed Sep 2 04:56:36 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime Message-ID: <200909020456.n824uUqQ082136@svn.freebsd.org> Author: ache Date: Wed Sep 2 04:56:30 2009 New Revision: 196752 URL: http://svn.freebsd.org/changeset/base/196752 Log: Use (unsigned char) cast for ctype macro Modified: head/lib/libc/stdtime/strptime.c Modified: head/lib/libc/stdtime/strptime.c ============================================================================== --- head/lib/libc/stdtime/strptime.c Wed Sep 2 04:43:46 2009 (r196751) +++ head/lib/libc/stdtime/strptime.c Wed Sep 2 04:56:30 2009 (r196752) @@ -529,7 +529,7 @@ label: buf++; i = 0; for (len = 4; len > 0; len--) { - if (isdigit((int)*buf)) { + if (isdigit((unsigned char)*buf)) { i *= 10; i += *buf - '0'; buf++; From maxim at macomnet.ru Wed Sep 2 05:21:06 2009 From: maxim at macomnet.ru (Maxim Konovalov) Date: Wed Sep 2 05:21:13 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <4A9D4A90.30700@FreeBSD.org> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> Message-ID: <20090902092054.Q27429@mp2.macomnet.net> On Tue, 1 Sep 2009, 09:23-0700, Doug Barton wrote: > Maxim Konovalov wrote: > > Author: maxim > > Date: Tue Sep 1 05:55:10 2009 > > New Revision: 196727 > > URL: http://svn.freebsd.org/changeset/base/196727 > > > > Log: > > o Document MALLOC_PRODUCTION knob. > > > > PR: docs/136029 > > Submitted by: anonymous > > MFC after: 2 weeks > > > > Modified: > > head/share/man/man5/make.conf.5 > > Unless I'm missing something this should be in the src.conf man page > instead of make.conf. > Please explain why. -- Maxim Konovalov From trasz at FreeBSD.org Wed Sep 2 05:27:00 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Wed Sep 2 05:27:12 2009 Subject: svn commit: r196753 - head/bin/chmod Message-ID: <200909020526.n825QxaP082834@svn.freebsd.org> Author: trasz Date: Wed Sep 2 05:26:59 2009 New Revision: 196753 URL: http://svn.freebsd.org/changeset/base/196753 Log: - Don't include both and - Keep variables sorted - Fix logic error with -f and -v options - don't print the usual -v output if there was an error, whether or not we were passed -f - Don't call free(3) just before exit(2) - Whitespace fixes Submitted by: bde Modified: head/bin/chmod/chmod.c Modified: head/bin/chmod/chmod.c ============================================================================== --- head/bin/chmod/chmod.c Wed Sep 2 04:56:30 2009 (r196752) +++ head/bin/chmod/chmod.c Wed Sep 2 05:26:59 2009 (r196753) @@ -41,7 +41,6 @@ static char sccsid[] = "@(#)chmod.c 8.8 #include __FBSDID("$FreeBSD$"); -#include #include #include @@ -63,7 +62,7 @@ main(int argc, char *argv[]) FTS *ftsp; FTSENT *p; mode_t *set; - int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval, error; + int Hflag, Lflag, Rflag, ch, error, fflag, fts_options, hflag, rval; int vflag; char *mode; mode_t newmode; @@ -170,7 +169,6 @@ done: argv += optind; */ if (!hflag) continue; - /* else */ /* FALLTHROUGH */ default: break; @@ -188,9 +186,11 @@ done: argv += optind; error = lchmod(p->fts_accpath, newmode); else error = chmod(p->fts_accpath, newmode); - if (error && !fflag) { - warn("%s", p->fts_path); - rval = 1; + if (error) { + if (!fflag) { + warn("%s", p->fts_path); + rval = 1; + } } else { if (vflag) { (void)printf("%s", p->fts_path); @@ -201,7 +201,6 @@ done: argv += optind; strmode(p->fts_statp->st_mode, m1); strmode((p->fts_statp->st_mode & S_IFMT) | newmode, m2); - (void)printf(": 0%o [%s] -> 0%o [%s]", p->fts_statp->st_mode, m1, (p->fts_statp->st_mode & S_IFMT) | @@ -209,12 +208,10 @@ done: argv += optind; } (void)printf("\n"); } - } } if (errno) err(1, "fts_read"); - free(set); exit(rval); } From simon at FreeBSD.org Wed Sep 2 07:08:11 2009 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Wed Sep 2 07:08:22 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <200909020456.n824uUqQ082136@svn.freebsd.org> References: <200909020456.n824uUqQ082136@svn.freebsd.org> Message-ID: <20090902070808.GA1290@arthur.nitro.dk> On 2009.09.02 04:56:30 +0000, Andrey A. Chernov wrote: > Author: ache > Date: Wed Sep 2 04:56:30 2009 > New Revision: 196752 > URL: http://svn.freebsd.org/changeset/base/196752 > > Log: > Use (unsigned char) cast for ctype macro Acording to the manual page and the C standard book I have, isdigit() takes an int for an argument, so why change this? Is passing it as an int instead of char causing problems? -- Simon L. Nielsen From trasz at FreeBSD.org Wed Sep 2 08:08:57 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Wed Sep 2 08:09:04 2009 Subject: svn commit: r196754 - head/bin/cp Message-ID: <200909020808.n8288vJK086081@svn.freebsd.org> Author: trasz Date: Wed Sep 2 08:08:57 2009 New Revision: 196754 URL: http://svn.freebsd.org/changeset/base/196754 Log: Add NFSv4 ACL support to cp(1) and fix a few memory leaks. Note that this changes error reporting behaviour somewhat - before, no error was reported if ACL couldn't be copied because the target filesystem doesn't support ACLs. Now, it will be reported - of course, only if there actually is an ACL to copy. Reviewed by: rwatson Modified: head/bin/cp/utils.c Modified: head/bin/cp/utils.c ============================================================================== --- head/bin/cp/utils.c Wed Sep 2 05:26:59 2009 (r196753) +++ head/bin/cp/utils.c Wed Sep 2 08:08:57 2009 (r196754) @@ -377,24 +377,52 @@ setfile(struct stat *fs, int fd) int preserve_fd_acls(int source_fd, int dest_fd) { - struct acl *aclp; acl_t acl; + acl_type_t acl_type; + int acl_supported = 0, ret, trivial; - if (fpathconf(source_fd, _PC_ACL_EXTENDED) != 1 || - fpathconf(dest_fd, _PC_ACL_EXTENDED) != 1) + ret = fpathconf(source_fd, _PC_ACL_NFS4); + if (ret > 0 ) { + acl_supported = 1; + acl_type = ACL_TYPE_NFS4; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_NFS4) failed for %s", to.p_path); + return (1); + } + if (acl_supported == 0) { + ret = fpathconf(source_fd, _PC_ACL_EXTENDED); + if (ret > 0 ) { + acl_supported = 1; + acl_type = ACL_TYPE_ACCESS; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_EXTENDED) failed for %s", + to.p_path); + return (1); + } + } + if (acl_supported == 0) return (0); - acl = acl_get_fd(source_fd); + + acl = acl_get_fd_np(source_fd, acl_type); if (acl == NULL) { warn("failed to get acl entries while setting %s", to.p_path); return (1); } - aclp = &acl->ats_acl; - if (aclp->acl_cnt == 3) + if (acl_is_trivial_np(acl, &trivial)) { + warn("acl_is_trivial() failed for %s", to.p_path); + acl_free(acl); + return (1); + } + if (trivial) { + acl_free(acl); return (0); - if (acl_set_fd(dest_fd, acl) < 0) { + } + if (acl_set_fd_np(dest_fd, acl, acl_type) < 0) { warn("failed to set acl entries for %s", to.p_path); + acl_free(acl); return (1); } + acl_free(acl); return (0); } @@ -405,10 +433,31 @@ preserve_dir_acls(struct stat *fs, char int (*aclsetf)(const char *, acl_type_t, acl_t); struct acl *aclp; acl_t acl; + acl_type_t acl_type; + int acl_supported = 0, ret, trivial; - if (pathconf(source_dir, _PC_ACL_EXTENDED) != 1 || - pathconf(dest_dir, _PC_ACL_EXTENDED) != 1) + ret = pathconf(source_dir, _PC_ACL_NFS4); + if (ret > 0) { + acl_supported = 1; + acl_type = ACL_TYPE_NFS4; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_NFS4) failed for %s", source_dir); + return (1); + } + if (acl_supported == 0) { + ret = pathconf(source_dir, _PC_ACL_EXTENDED); + if (ret > 0) { + acl_supported = 1; + acl_type = ACL_TYPE_ACCESS; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_EXTENDED) failed for %s", + source_dir); + return (1); + } + } + if (acl_supported == 0) return (0); + /* * If the file is a link we will not follow it */ @@ -419,34 +468,48 @@ preserve_dir_acls(struct stat *fs, char aclgetf = acl_get_file; aclsetf = acl_set_file; } - /* - * Even if there is no ACL_TYPE_DEFAULT entry here, a zero - * size ACL will be returned. So it is not safe to simply - * check the pointer to see if the default ACL is present. - */ - acl = aclgetf(source_dir, ACL_TYPE_DEFAULT); + if (acl_type == ACL_TYPE_ACCESS) { + /* + * Even if there is no ACL_TYPE_DEFAULT entry here, a zero + * size ACL will be returned. So it is not safe to simply + * check the pointer to see if the default ACL is present. + */ + acl = aclgetf(source_dir, ACL_TYPE_DEFAULT); + if (acl == NULL) { + warn("failed to get default acl entries on %s", + source_dir); + return (1); + } + aclp = &acl->ats_acl; + if (aclp->acl_cnt != 0 && aclsetf(dest_dir, + ACL_TYPE_DEFAULT, acl) < 0) { + warn("failed to set default acl entries on %s", + dest_dir); + acl_free(acl); + return (1); + } + acl_free(acl); + } + acl = aclgetf(source_dir, acl_type); if (acl == NULL) { - warn("failed to get default acl entries on %s", - source_dir); + warn("failed to get acl entries on %s", source_dir); return (1); } - aclp = &acl->ats_acl; - if (aclp->acl_cnt != 0 && aclsetf(dest_dir, - ACL_TYPE_DEFAULT, acl) < 0) { - warn("failed to set default acl entries on %s", - dest_dir); + if (acl_is_trivial_np(acl, &trivial)) { + warn("acl_is_trivial() failed on %s", source_dir); + acl_free(acl); return (1); } - acl = aclgetf(source_dir, ACL_TYPE_ACCESS); - if (acl == NULL) { - warn("failed to get acl entries on %s", source_dir); - return (1); + if (trivial) { + acl_free(acl); + return (0); } - aclp = &acl->ats_acl; - if (aclsetf(dest_dir, ACL_TYPE_ACCESS, acl) < 0) { + if (aclsetf(dest_dir, acl_type, acl) < 0) { warn("failed to set acl entries on %s", dest_dir); + acl_free(acl); return (1); } + acl_free(acl); return (0); } From ache at nagual.pp.ru Wed Sep 2 08:51:09 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Wed Sep 2 08:51:15 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090902070808.GA1290@arthur.nitro.dk> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> Message-ID: <20090902084002.GA17325@nagual.pp.ru> On Wed, Sep 02, 2009 at 09:08:09AM +0200, Simon L. Nielsen wrote: > > Log: > > Use (unsigned char) cast for ctype macro > > Acording to the manual page and the C standard book I have, isdigit() > takes an int for an argument, so why change this? Not exactly that. From our manual page: "The value of the argument must be representable as an unsigned char or the value of EOF." Signed char (automatically casted to int in expression even without direct (int) cast) passed to any ctype macro potentically may cause a lot of problems, such as: incorrect char class detection or even core dump in some systems. This is due to automatic sign extension of 8bit (if present). -- http://ache.pp.ru/ From mav at FreeBSD.org Wed Sep 2 11:39:21 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Sep 2 11:39:26 2009 Subject: svn commit: r196762 - head/sys/dev/sound/pci/hda Message-ID: <200909021139.n82BdKEX094794@svn.freebsd.org> Author: mav Date: Wed Sep 2 11:39:19 2009 New Revision: 196762 URL: http://svn.freebsd.org/changeset/base/196762 Log: Improve HDA controller capabilities logging. Modified: head/sys/dev/sound/pci/hda/hdac.c head/sys/dev/sound/pci/hda/hdac_private.h head/sys/dev/sound/pci/hda/hdac_reg.h Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Wed Sep 2 10:39:46 2009 (r196761) +++ head/sys/dev/sound/pci/hda/hdac.c Wed Sep 2 11:39:19 2009 (r196762) @@ -1520,7 +1520,7 @@ hdac_get_capabilities(struct hdac_softc sc->num_iss = HDAC_GCAP_ISS(gcap); sc->num_oss = HDAC_GCAP_OSS(gcap); sc->num_bss = HDAC_GCAP_BSS(gcap); - + sc->num_sdo = HDAC_GCAP_NSDO(gcap); sc->support_64bit = HDA_FLAG_MATCH(gcap, HDAC_GCAP_64OK); corbsize = HDAC_READ_1(&sc->mem, HDAC_CORBSIZE); @@ -1555,11 +1555,12 @@ hdac_get_capabilities(struct hdac_softc return (ENXIO); } - HDA_BOOTHVERBOSE( - device_printf(sc->dev, " CORB size: %d\n", sc->corb_size); - device_printf(sc->dev, " RIRB size: %d\n", sc->rirb_size); - device_printf(sc->dev, " Streams: ISS=%d OSS=%d BSS=%d\n", - sc->num_iss, sc->num_oss, sc->num_bss); + HDA_BOOTVERBOSE( + device_printf(sc->dev, "Caps: OSS %d, ISS %d, BSS %d, " + "NSDO %d%s, CORB %d, RIRB %d\n", + sc->num_oss, sc->num_iss, sc->num_bss, 1 << sc->num_sdo, + sc->support_64bit ? ", 64bit" : "", + sc->corb_size, sc->rirb_size); ); return (0); Modified: head/sys/dev/sound/pci/hda/hdac_private.h ============================================================================== --- head/sys/dev/sound/pci/hda/hdac_private.h Wed Sep 2 10:39:46 2009 (r196761) +++ head/sys/dev/sound/pci/hda/hdac_private.h Wed Sep 2 11:39:19 2009 (r196762) @@ -339,6 +339,7 @@ struct hdac_softc { int num_iss; int num_oss; int num_bss; + int num_sdo; int support_64bit; int streamcnt; Modified: head/sys/dev/sound/pci/hda/hdac_reg.h ============================================================================== --- head/sys/dev/sound/pci/hda/hdac_reg.h Wed Sep 2 10:39:46 2009 (r196761) +++ head/sys/dev/sound/pci/hda/hdac_reg.h Wed Sep 2 11:39:19 2009 (r196762) @@ -136,6 +136,8 @@ (((gcap) & HDAC_GCAP_ISS_MASK) >> HDAC_GCAP_ISS_SHIFT) #define HDAC_GCAP_OSS(gcap) \ (((gcap) & HDAC_GCAP_OSS_MASK) >> HDAC_GCAP_OSS_SHIFT) +#define HDAC_GCAP_NSDO(gcap) \ + (((gcap) & HDAC_GCAP_NSDO_MASK) >> HDAC_GCAP_NSDO_SHIFT) /* GCTL - Global Control */ #define HDAC_GCTL_CRST 0x00000001 From dimitry at andric.com Wed Sep 2 13:46:00 2009 From: dimitry at andric.com (Dimitry Andric) Date: Wed Sep 2 13:46:06 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <20090902092054.Q27429@mp2.macomnet.net> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> <20090902092054.Q27429@mp2.macomnet.net> Message-ID: <4A9E7718.1080503@andric.com> On 2009-09-02 07:21, Maxim Konovalov wrote: >> Unless I'm missing something this should be in the src.conf man page >> instead of make.conf. > Please explain why. make.conf(5): The file make.conf contains system-wide settings that will apply to every build using make(1) and the standard sys.mk file. src.conf(5): The src.conf file contains settings that will apply to every build involving the FreeBSD source tree; see build(7). The MALLOC_PRODUCTION define is used inside the FreeBSD source tree (actually only in jemalloc, it seems). You most likely don't want it to apply 'globally', since third-party programs (e.g. ports) might give a totally different meaning to this define -- or most likely: no meaning at all. :) From flz at FreeBSD.org Wed Sep 2 13:58:16 2009 From: flz at FreeBSD.org (Florent Thoumie) Date: Wed Sep 2 13:58:27 2009 Subject: svn commit: r196766 - head/usr.sbin/pkg_install/lib Message-ID: <200909021358.n82DwF2f097781@svn.freebsd.org> Author: flz Date: Wed Sep 2 13:58:15 2009 New Revision: 196766 URL: http://svn.freebsd.org/changeset/base/196766 Log: - Bump PKG_INSTALL_VERSION to 20090902 after dougb's changes. - Change the comment to say that version must be changed when a non-cosmetic change is made. Modified: head/usr.sbin/pkg_install/lib/lib.h Modified: head/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- head/usr.sbin/pkg_install/lib/lib.h Wed Sep 2 12:51:57 2009 (r196765) +++ head/usr.sbin/pkg_install/lib/lib.h Wed Sep 2 13:58:15 2009 (r196766) @@ -102,10 +102,10 @@ #define PKG_PREFIX_VNAME "PKG_PREFIX" /* - * Version of the package tools - increase only when some - * functionality used by bsd.port.mk is changed, added or removed + * Version of the package tools - increase whenever you make a change + * in the code that is not cosmetic only. */ -#define PKG_INSTALL_VERSION 20090519 +#define PKG_INSTALL_VERSION 20090902 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) From flz at FreeBSD.org Wed Sep 2 14:54:47 2009 From: flz at FreeBSD.org (Florent Thoumie) Date: Wed Sep 2 14:54:53 2009 Subject: svn commit: r196767 - in head/etc: . mtree Message-ID: <200909021454.n82EslhJ099254@svn.freebsd.org> Author: flz Date: Wed Sep 2 14:54:47 2009 New Revision: 196767 URL: http://svn.freebsd.org/changeset/base/196767 Log: - Remove BSD.{x11,x11-4}.dist as we merged prefixes a while ago and those files aren't used anymore. - Remove BSD.local.dist as the file moved to ports/Templates when we merged prefixes. Deleted: head/etc/mtree/BSD.local.dist head/etc/mtree/BSD.x11-4.dist head/etc/mtree/BSD.x11.dist Modified: head/etc/Makefile Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Wed Sep 2 13:58:15 2009 (r196766) +++ head/etc/Makefile Wed Sep 2 14:54:47 2009 (r196767) @@ -99,8 +99,7 @@ BIN1+= regdomain.xml # -rwxr-xr-x root:wheel, for the new cron root:wheel BIN2= netstart pccard_ether rc.suspend rc.resume -MTREE= BSD.include.dist BSD.local.dist BSD.root.dist BSD.usr.dist \ - BSD.var.dist BSD.x11.dist BSD.x11-4.dist +MTREE= BSD.include.dist BSD.root.dist BSD.usr.dist BSD.var.dist .if ${MK_SENDMAIL} != "no" MTREE+= BSD.sendmail.dist .endif From flz at FreeBSD.org Wed Sep 2 14:56:23 2009 From: flz at FreeBSD.org (Florent Thoumie) Date: Wed Sep 2 14:56:30 2009 Subject: svn commit: r196768 - head Message-ID: <200909021456.n82EuNcx099351@svn.freebsd.org> Author: flz Date: Wed Sep 2 14:56:23 2009 New Revision: 196768 URL: http://svn.freebsd.org/changeset/base/196768 Log: Remove BSD.{local,x11,x11-4}.dist mtree files as they're either obsolete or they've moved to ports. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Wed Sep 2 14:54:47 2009 (r196767) +++ head/ObsoleteFiles.inc Wed Sep 2 14:56:23 2009 (r196768) @@ -14,6 +14,10 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20090902: BSD.{x11,x11-4}.dist are dead and BSD.local.dist lives in ports/ +OLD_FILES+=etc/mtree/BSD.local.dist +OLD_FILES+=etc/mtree/BSD.x11.dist +OLD_FILES+=etc/mtree/BSD.x11-4.dist # 20090801: vimage.h removed in favour of vnet.h OLD_FILES+=usr/include/sys/vimage.h # 20090719: library version bump for 8.0 From dougb at FreeBSD.org Wed Sep 2 15:06:28 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Wed Sep 2 15:06:35 2009 Subject: svn commit: r196766 - head/usr.sbin/pkg_install/lib In-Reply-To: <200909021358.n82DwF2f097781@svn.freebsd.org> References: <200909021358.n82DwF2f097781@svn.freebsd.org> Message-ID: <4A9E89E9.50300@FreeBSD.org> Florent Thoumie wrote: > Author: flz > Date: Wed Sep 2 13:58:15 2009 > New Revision: 196766 > URL: http://svn.freebsd.org/changeset/base/196766 > > Log: > - Bump PKG_INSTALL_VERSION to 20090902 after dougb's changes. > - Change the comment to say that version must be changed when a > non-cosmetic change is made. Thanks! (For the change, and for the education.) Doug -- This .signature sanitized for your protection From dougb at FreeBSD.org Wed Sep 2 15:16:43 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Wed Sep 2 15:16:53 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <4A9E7718.1080503@andric.com> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> <20090902092054.Q27429@mp2.macomnet.net> <4A9E7718.1080503@andric.com> Message-ID: <4A9E8C50.5010402@FreeBSD.org> Dimitry Andric wrote: > On 2009-09-02 07:21, Maxim Konovalov wrote: >>> Unless I'm missing something this should be in the src.conf man page >>> instead of make.conf. >> Please explain why. > > make.conf(5): > The file make.conf contains system-wide settings that will apply to every > build using make(1) and the standard sys.mk file. > > src.conf(5): > The src.conf file contains settings that will apply to every build > involving the FreeBSD source tree; see build(7). > > The MALLOC_PRODUCTION define is used inside the FreeBSD source tree > (actually only in jemalloc, it seems). > > You most likely don't want it to apply 'globally', since third-party > programs (e.g. ports) might give a totally different meaning to this > define -- or most likely: no meaning at all. :) That's correct. Maxim, I forgot to include the pointer to src/tools/build/options in my previous mail, so there you go. :) Doug -- This .signature sanitized for your protection From jkim at FreeBSD.org Wed Sep 2 16:02:49 2009 From: jkim at FreeBSD.org (Jung-uk Kim) Date: Wed Sep 2 16:02:55 2009 Subject: svn commit: r196769 - in head/sys: amd64/amd64 i386/i386 Message-ID: <200909021602.n82G2mpE000812@svn.freebsd.org> Author: jkim Date: Wed Sep 2 16:02:48 2009 New Revision: 196769 URL: http://svn.freebsd.org/changeset/base/196769 Log: - Work around ACPI mode transition problem for recent NVIDIA 9400M chipset based Intel Macs. Since r189055, these platforms started freezing when ACPI is being initialized for unknown reason. For these platforms, we just use the old PAT layout. Note this change is not enough to boot fully on these platforms because of other problems but it makes debugging possible. Note MacBook5,2 may be affected as well but it was not added here because of lack of hardware to test. - Initialize PAT MSR fully instead of reading and modifying it for safety. Reported by: rpaulo, hps, Eygene Ryabinkin (rea-fbsd at codelabs dot ru) Reviewed by: jhb Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Sep 2 14:56:23 2009 (r196768) +++ head/sys/amd64/amd64/pmap.c Wed Sep 2 16:02:48 2009 (r196769) @@ -178,6 +178,8 @@ static vm_paddr_t dmaplimit; vm_offset_t kernel_vm_end = VM_MIN_KERNEL_ADDRESS; pt_entry_t pg_nx; +static int pat_works = 0; /* Is page attribute table sane? */ + SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); static int pg_ps_enabled = 1; @@ -590,20 +592,56 @@ void pmap_init_pat(void) { uint64_t pat_msr; + char *sysenv; + static int pat_tested = 0; /* Bail if this CPU doesn't implement PAT. */ if (!(cpu_feature & CPUID_PAT)) panic("no PAT??"); /* - * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. - * Program 4 and 5 as WP and WC. - * Leave 6 and 7 as UC and UC-. - */ - pat_msr = rdmsr(MSR_PAT); - pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); - pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | - PAT_VALUE(5, PAT_WRITE_COMBINING); + * Some Apple Macs based on nVidia chipsets cannot enter ACPI mode + * via SMI# when we use upper 4 PAT entries for unknown reason. + */ + if (!pat_tested) { + pat_works = 1; + sysenv = getenv("smbios.system.product"); + if (sysenv != NULL) { + if (strncmp(sysenv, "MacBook5,1", 10) == 0 || + strncmp(sysenv, "MacBookPro5,5", 13) == 0 || + strncmp(sysenv, "Macmini3,1", 10) == 0) + pat_works = 0; + freeenv(sysenv); + } + pat_tested = 1; + } + + /* Initialize default PAT entries. */ + pat_msr = PAT_VALUE(0, PAT_WRITE_BACK) | + PAT_VALUE(1, PAT_WRITE_THROUGH) | + PAT_VALUE(2, PAT_UNCACHED) | + PAT_VALUE(3, PAT_UNCACHEABLE) | + PAT_VALUE(4, PAT_WRITE_BACK) | + PAT_VALUE(5, PAT_WRITE_THROUGH) | + PAT_VALUE(6, PAT_UNCACHED) | + PAT_VALUE(7, PAT_UNCACHEABLE); + + if (pat_works) { + /* + * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. + * Program 4 and 5 as WP and WC. + * Leave 6 and 7 as UC and UC-. + */ + pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); + pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | + PAT_VALUE(5, PAT_WRITE_COMBINING); + } else { + /* + * Just replace PAT Index 2 with WC instead of UC-. + */ + pat_msr &= ~PAT_MASK(2); + pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); + } wrmsr(MSR_PAT, pat_msr); } @@ -754,27 +792,48 @@ pmap_cache_bits(int mode, boolean_t is_p pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT; /* Map the caching mode to a PAT index. */ - switch (mode) { - case PAT_UNCACHEABLE: - pat_index = 3; - break; - case PAT_WRITE_THROUGH: - pat_index = 1; - break; - case PAT_WRITE_BACK: - pat_index = 0; - break; - case PAT_UNCACHED: - pat_index = 2; - break; - case PAT_WRITE_COMBINING: - pat_index = 5; - break; - case PAT_WRITE_PROTECTED: - pat_index = 4; - break; - default: - panic("Unknown caching mode %d\n", mode); + if (pat_works) { + switch (mode) { + case PAT_UNCACHEABLE: + pat_index = 3; + break; + case PAT_WRITE_THROUGH: + pat_index = 1; + break; + case PAT_WRITE_BACK: + pat_index = 0; + break; + case PAT_UNCACHED: + pat_index = 2; + break; + case PAT_WRITE_COMBINING: + pat_index = 5; + break; + case PAT_WRITE_PROTECTED: + pat_index = 4; + break; + default: + panic("Unknown caching mode %d\n", mode); + } + } else { + switch (mode) { + case PAT_UNCACHED: + case PAT_UNCACHEABLE: + case PAT_WRITE_PROTECTED: + pat_index = 3; + break; + case PAT_WRITE_THROUGH: + pat_index = 1; + break; + case PAT_WRITE_BACK: + pat_index = 0; + break; + case PAT_WRITE_COMBINING: + pat_index = 2; + break; + default: + panic("Unknown caching mode %d\n", mode); + } } /* Map the 3-bit index value into the PAT, PCD, and PWT bits. */ Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Wed Sep 2 14:56:23 2009 (r196768) +++ head/sys/i386/i386/pmap.c Wed Sep 2 16:02:48 2009 (r196769) @@ -212,7 +212,7 @@ pt_entry_t pg_nx; static uma_zone_t pdptzone; #endif -static int pat_works; /* Is page attribute table sane? */ +static int pat_works = 0; /* Is page attribute table sane? */ SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); @@ -478,40 +478,69 @@ void pmap_init_pat(void) { uint64_t pat_msr; + char *sysenv; + static int pat_tested = 0; /* Bail if this CPU doesn't implement PAT. */ if (!(cpu_feature & CPUID_PAT)) return; - if (cpu_vendor_id != CPU_VENDOR_INTEL || - (I386_CPU_FAMILY(cpu_id) == 6 && I386_CPU_MODEL(cpu_id) >= 0xe)) { + /* + * Due to some Intel errata, we can only safely use the lower 4 + * PAT entries. + * + * Intel Pentium III Processor Specification Update + * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B + * or Mode C Paging) + * + * Intel Pentium IV Processor Specification Update + * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) + * + * Some Apple Macs based on nVidia chipsets cannot enter ACPI mode + * via SMI# when we use upper 4 PAT entries for unknown reason. + */ + if (!pat_tested) { + if (cpu_vendor_id != CPU_VENDOR_INTEL || + (I386_CPU_FAMILY(cpu_id) == 6 && + I386_CPU_MODEL(cpu_id) >= 0xe)) { + pat_works = 1; + sysenv = getenv("smbios.system.product"); + if (sysenv != NULL) { + if (strncmp(sysenv, "MacBook5,1", 10) == 0 || + strncmp(sysenv, "MacBookPro5,5", 13) == 0 || + strncmp(sysenv, "Macmini3,1", 10) == 0) + pat_works = 0; + freeenv(sysenv); + } + } + pat_tested = 1; + } + + /* Initialize default PAT entries. */ + pat_msr = PAT_VALUE(0, PAT_WRITE_BACK) | + PAT_VALUE(1, PAT_WRITE_THROUGH) | + PAT_VALUE(2, PAT_UNCACHED) | + PAT_VALUE(3, PAT_UNCACHEABLE) | + PAT_VALUE(4, PAT_WRITE_BACK) | + PAT_VALUE(5, PAT_WRITE_THROUGH) | + PAT_VALUE(6, PAT_UNCACHED) | + PAT_VALUE(7, PAT_UNCACHEABLE); + + if (pat_works) { /* * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. * Program 4 and 5 as WP and WC. * Leave 6 and 7 as UC and UC-. */ - pat_msr = rdmsr(MSR_PAT); pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | PAT_VALUE(5, PAT_WRITE_COMBINING); - pat_works = 1; } else { /* - * Due to some Intel errata, we can only safely use the lower 4 - * PAT entries. Thus, just replace PAT Index 2 with WC instead - * of UC-. - * - * Intel Pentium III Processor Specification Update - * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B - * or Mode C Paging) - * - * Intel Pentium IV Processor Specification Update - * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) + * Just replace PAT Index 2 with WC instead of UC-. */ - pat_msr = rdmsr(MSR_PAT); pat_msr &= ~PAT_MASK(2); pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); - pat_works = 0; } wrmsr(MSR_PAT, pat_msr); } From jkim at FreeBSD.org Wed Sep 2 16:47:11 2009 From: jkim at FreeBSD.org (Jung-uk Kim) Date: Wed Sep 2 16:47:18 2009 Subject: svn commit: r196771 - in head/sys: amd64/amd64 i386/i386 Message-ID: <200909021647.n82GlAeA001794@svn.freebsd.org> Author: jkim Date: Wed Sep 2 16:47:10 2009 New Revision: 196771 URL: http://svn.freebsd.org/changeset/base/196771 Log: Fix confusing comments about default PAT entries. Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Sep 2 16:35:57 2009 (r196770) +++ head/sys/amd64/amd64/pmap.c Wed Sep 2 16:47:10 2009 (r196771) @@ -628,9 +628,9 @@ pmap_init_pat(void) if (pat_works) { /* - * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. + * Leave the indices 0-3 at the default of WB, WT, UC-, and UC. * Program 4 and 5 as WP and WC. - * Leave 6 and 7 as UC and UC-. + * Leave 6 and 7 as UC- and UC. */ pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Wed Sep 2 16:35:57 2009 (r196770) +++ head/sys/i386/i386/pmap.c Wed Sep 2 16:47:10 2009 (r196771) @@ -528,9 +528,9 @@ pmap_init_pat(void) if (pat_works) { /* - * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. + * Leave the indices 0-3 at the default of WB, WT, UC-, and UC. * Program 4 and 5 as WP and WC. - * Leave 6 and 7 as UC and UC-. + * Leave 6 and 7 as UC- and UC. */ pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | From swell.k at gmail.com Wed Sep 2 16:57:28 2009 From: swell.k at gmail.com (Anonymous) Date: Wed Sep 2 16:57:39 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <4A9E7718.1080503@andric.com> (Dimitry Andric's message of "Wed, 02 Sep 2009 15:46:00 +0200") References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> <20090902092054.Q27429@mp2.macomnet.net> <4A9E7718.1080503@andric.com> Message-ID: <86hbvli9tg.fsf@gmail.com> Dimitry Andric writes: > On 2009-09-02 07:21, Maxim Konovalov wrote: >>> Unless I'm missing something this should be in the src.conf man page >>> instead of make.conf. >> Please explain why. > > make.conf(5): > The file make.conf contains system-wide settings that will apply to every > build using make(1) and the standard sys.mk file. > > src.conf(5): > The src.conf file contains settings that will apply to every build > involving the FreeBSD source tree; see build(7). > > The MALLOC_PRODUCTION define is used inside the FreeBSD source tree > (actually only in jemalloc, it seems). > > You most likely don't want it to apply 'globally', since third-party > programs (e.g. ports) might give a totally different meaning to this > define -- or most likely: no meaning at all. :) Don't you think this affects not only MALLOC_PRODUCTION but all defines under sections "BUILDING THE KERNEL" and "BUILDING THE WORLD"? For example, WITHOUT_MODULES conflicts with one in archivers/p7zip. From attilio at FreeBSD.org Wed Sep 2 17:33:52 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Wed Sep 2 17:34:03 2009 Subject: svn commit: r196772 - head/sys/kern Message-ID: <200909021733.n82HXpV6002870@svn.freebsd.org> Author: attilio Date: Wed Sep 2 17:33:51 2009 New Revision: 196772 URL: http://svn.freebsd.org/changeset/base/196772 Log: Fix some bugs related to adaptive spinning: In the lockmgr support: - GIANT_RESTORE() is just called when the sleep finishes, so the current code can ends up into a giant unlock problem. Fix it by appropriately call GIANT_RESTORE() when needed. Note that this is not exactly ideal because for any interation of the adaptive spinning we drop and restore Giant, but the overhead should be not a factor. - In the lock held in exclusive mode case, after the adaptive spinning is brought to completition, we should just retry to acquire the lock instead to fallthrough. Fix that. - Fix a style nit In the sx support: - Call GIANT_SAVE() before than looping. This saves some overhead because in the current code GIANT_SAVE() is called several times. Tested by: Giovanni Trematerra Modified: head/sys/kern/kern_lock.c head/sys/kern/kern_sx.c Modified: head/sys/kern/kern_lock.c ============================================================================== --- head/sys/kern/kern_lock.c Wed Sep 2 16:47:10 2009 (r196771) +++ head/sys/kern/kern_lock.c Wed Sep 2 17:33:51 2009 (r196772) @@ -467,7 +467,10 @@ __lockmgr_args(struct lock *lk, u_int fl /* * If the owner is running on another CPU, spin until * the owner stops running or the state of the lock - * changes. + * changes. We need a double-state handle here + * because for a failed acquisition the lock can be + * either held in exclusive mode or shared mode + * (for the writer starvation avoidance technique). */ if (LK_CAN_ADAPT(lk, flags) && (x & LK_SHARE) == 0 && LK_HOLDER(x) != LK_KERNPROC) { @@ -491,8 +494,10 @@ __lockmgr_args(struct lock *lk, u_int fl while (LK_HOLDER(lk->lk_lock) == (uintptr_t)owner && TD_IS_RUNNING(owner)) cpu_spinwait(); + GIANT_RESTORE(); + continue; } else if (LK_CAN_ADAPT(lk, flags) && - (x & LK_SHARE) !=0 && LK_SHARERS(x) && + (x & LK_SHARE) != 0 && LK_SHARERS(x) && spintries < alk_retries) { if (flags & LK_INTERLOCK) { class->lc_unlock(ilk); @@ -511,6 +516,7 @@ __lockmgr_args(struct lock *lk, u_int fl break; cpu_spinwait(); } + GIANT_RESTORE(); if (i != alk_loops) continue; } @@ -704,6 +710,8 @@ __lockmgr_args(struct lock *lk, u_int fl while (LK_HOLDER(lk->lk_lock) == (uintptr_t)owner && TD_IS_RUNNING(owner)) cpu_spinwait(); + GIANT_RESTORE(); + continue; } else if (LK_CAN_ADAPT(lk, flags) && (x & LK_SHARE) != 0 && LK_SHARERS(x) && spintries < alk_retries) { @@ -727,6 +735,7 @@ __lockmgr_args(struct lock *lk, u_int fl break; cpu_spinwait(); } + GIANT_RESTORE(); if (i != alk_loops) continue; } Modified: head/sys/kern/kern_sx.c ============================================================================== --- head/sys/kern/kern_sx.c Wed Sep 2 16:47:10 2009 (r196771) +++ head/sys/kern/kern_sx.c Wed Sep 2 17:33:51 2009 (r196772) @@ -531,13 +531,13 @@ _sx_xlock_hard(struct sx *sx, uintptr_t continue; } } else if (SX_SHARERS(x) && spintries < asx_retries) { + GIANT_SAVE(); spintries++; for (i = 0; i < asx_loops; i++) { if (LOCK_LOG_TEST(&sx->lock_object, 0)) CTR4(KTR_LOCK, "%s: shared spinning on %p with %u and %u", __func__, sx, spintries, i); - GIANT_SAVE(); x = sx->sx_lock; if ((x & SX_LOCK_SHARED) == 0 || SX_SHARERS(x) == 0) From trasz at FreeBSD.org Wed Sep 2 20:50:40 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Wed Sep 2 20:50:55 2009 Subject: svn commit: r196773 - head/bin/ls Message-ID: <200909022050.n82KodmI006768@svn.freebsd.org> Author: trasz Date: Wed Sep 2 20:50:39 2009 New Revision: 196773 URL: http://svn.freebsd.org/changeset/base/196773 Log: Fix regression introduced in r196712 - the 'name' string needs to be rewritten for each file we want to check ACL on. Without this change, ls(1) would check only the ACL on the first file to list. Modified: head/bin/ls/print.c Modified: head/bin/ls/print.c ============================================================================== --- head/bin/ls/print.c Wed Sep 2 17:33:51 2009 (r196772) +++ head/bin/ls/print.c Wed Sep 2 20:50:39 2009 (r196773) @@ -623,15 +623,19 @@ aclmode(char *buf, const FTSENT *p) S_ISWHT(p->fts_statp->st_mode)) return; + if (previous_dev == p->fts_statp->st_dev && supports_acls == 0) + return; + + if (p->fts_level == FTS_ROOTLEVEL) + snprintf(name, sizeof(name), "%s", p->fts_name); + else + snprintf(name, sizeof(name), "%s/%s", + p->fts_parent->fts_accpath, p->fts_name); + if (previous_dev != p->fts_statp->st_dev) { previous_dev = p->fts_statp->st_dev; supports_acls = 0; - if (p->fts_level == FTS_ROOTLEVEL) - snprintf(name, sizeof(name), "%s", p->fts_name); - else - snprintf(name, sizeof(name), "%s/%s", - p->fts_parent->fts_accpath, p->fts_name); ret = lpathconf(name, _PC_ACL_NFS4); if (ret > 0) { type = ACL_TYPE_NFS4; From des at des.no Thu Sep 3 07:26:04 2009 From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=) Date: Thu Sep 3 07:26:11 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090902084002.GA17325@nagual.pp.ru> (Andrey Chernov's message of "Wed, 2 Sep 2009 12:40:03 +0400") References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> Message-ID: <867hwgcwvo.fsf@ds4.des.no> Andrey Chernov writes: > "Simon L. Nielsen" writes: > > Acording to the manual page and the C standard book I have, > > isdigit() takes an int for an argument, so why change this? > "The value of the argument must be representable as an unsigned char or > the value of EOF." > > Signed char (automatically casted to int in expression even without direct > (int) cast) passed to any ctype macro potentically may cause a lot of > problems, such as: incorrect char class detection or even core dump in > some systems. > > This is due to automatic sign extension of 8bit (if present). To put it more clearly: - The is*() functions expect an int for the same reason fgetc() returns one: a char alone can't represent all possible char values *plus* EOF. - In most 8-bit locales, there are valid characters outside the 0-127 range. When stored in a signed char, such characters are represented as negative values. When that signed char is promoted to a signed int, the negative values remain negative instead of being converted to the correct positive value. - This would not be a problem if C distinguished between a character (unsigned) and a "short short int" (signed). - The core dump ache refers to can occur with a na?ve implementation that uses a lookup table and checks for EOF, but not for other negative values. DES -- Dag-Erling Sm?rgrav - des@des.no From ache at nagual.pp.ru Thu Sep 3 08:43:31 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Thu Sep 3 08:43:43 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <867hwgcwvo.fsf@ds4.des.no> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> Message-ID: <20090903084325.GA65192@nagual.pp.ru> On Thu, Sep 03, 2009 at 09:26:03AM +0200, Dag-Erling Sm??rgrav wrote: > > - The core dump ache refers to can occur with a na??ve implementation > that uses a lookup table and checks for EOF, but not for other > negative values. Thanx for detailed explanation. Just to note: even such naive implemetations still live inside POSIX, since POSIX says that behaviour outside of "unsigned char" range + exact EOF value is undefined. -- http://ache.pp.ru/ From des at des.no Thu Sep 3 09:08:28 2009 From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=) Date: Thu Sep 3 09:08:41 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090903084325.GA65192@nagual.pp.ru> (Andrey Chernov's message of "Thu, 3 Sep 2009 12:43:25 +0400") References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> Message-ID: <86zl9c9z05.fsf@ds4.des.no> Andrey Chernov writes: > Thanx for detailed explanation. np; I've made that mistake many times myself. What do you think of the attached patch? DES -- Dag-Erling Sm?rgrav - des@des.no -------------- next part -------------- A non-text attachment was scrubbed... Name: ctype-man.diff Type: text/x-patch Size: 15080 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090903/450dcd18/ctype-man.bin From ache at nagual.pp.ru Thu Sep 3 09:20:17 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Thu Sep 3 09:20:24 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <86zl9c9z05.fsf@ds4.des.no> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> Message-ID: <20090903092012.GA65660@nagual.pp.ru> On Thu, Sep 03, 2009 at 11:08:26AM +0200, Dag-Erling Sm??rgrav wrote: > > What do you think of the attached patch? Looks nice. -- http://ache.pp.ru/ From simon at FreeBSD.org Thu Sep 3 09:32:06 2009 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Thu Sep 3 09:32:18 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090903084325.GA65192@nagual.pp.ru> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> Message-ID: <20090903093205.GB1304@zaphod.nitro.dk> On 2009.09.03 12:43:25 +0400, Andrey Chernov wrote: > On Thu, Sep 03, 2009 at 09:26:03AM +0200, Dag-Erling Sm??rgrav wrote: > > > > - The core dump ache refers to can occur with a na??ve implementation > > that uses a lookup table and checks for EOF, but not for other > > negative values. > > Thanx for detailed explanation. Just to note: even such naive > implemetations still live inside POSIX, since POSIX says that behaviour > outside of "unsigned char" range + exact EOF value is undefined. Thanks to both of you for the detailed explanation. Always good to learn something new :-). I haven't had time to review des's patch (I can tonight if "needed"), but I certainly welcome documenting this case more clearly :-). -- Simon L. Nielsen From ed at FreeBSD.org Thu Sep 3 09:33:58 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Thu Sep 3 09:34:10 2009 Subject: svn commit: r196775 - in head/sys: conf dev/syscons dev/syscons/teken teken Message-ID: <200909030933.n839XwxV022031@svn.freebsd.org> Author: ed Date: Thu Sep 3 09:33:57 2009 New Revision: 196775 URL: http://svn.freebsd.org/changeset/base/196775 Log: Move libteken out of the syscons directory. I initially committed libteken to sys/dev/syscons/teken, but now that I'm working on a console driver myself, I noticed this was not a good decision. Move it to sys/teken to make it easier for other drivers to use a terminal emulator. Also list teken.c in sys/conf/files, instead of listing it in all the files.arch files separately. Added: head/sys/teken/ - copied from r196552, head/sys/dev/syscons/teken/ Deleted: head/sys/dev/syscons/teken/ Modified: head/sys/conf/files head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/conf/files.ia64 head/sys/conf/files.powerpc head/sys/conf/files.sparc64 head/sys/dev/syscons/scterm-teken.c Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files Thu Sep 3 09:33:57 2009 (r196775) @@ -91,8 +91,8 @@ pccarddevs.h standard \ no-obj no-implicit-rule before-depend \ clean "pccarddevs.h" teken_state.h optional sc \ - dependency "$S/dev/syscons/teken/gensequences $S/dev/syscons/teken/sequences" \ - compile-with "${AWK} -f $S/dev/syscons/teken/gensequences $S/dev/syscons/teken/sequences > teken_state.h" \ + dependency "$S/teken/gensequences $S/teken/sequences" \ + compile-with "${AWK} -f $S/teken/gensequences $S/teken/sequences > teken_state.h" \ no-obj no-implicit-rule before-depend \ clean "teken_state.h" usbdevs.h optional usb \ @@ -2616,6 +2616,7 @@ security/mac_portacl/mac_portacl.c optio security/mac_seeotheruids/mac_seeotheruids.c optional mac_seeotheruids security/mac_stub/mac_stub.c optional mac_stub security/mac_test/mac_test.c optional mac_test +teken/teken.c optional sc ufs/ffs/ffs_alloc.c optional ffs ufs/ffs/ffs_balloc.c optional ffs ufs/ffs/ffs_inode.c optional ffs Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files.amd64 Thu Sep 3 09:33:57 2009 (r196775) @@ -219,7 +219,6 @@ dev/syscons/apm/apm_saver.c optional apm dev/syscons/scterm-teken.c optional sc dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvtb.c optional sc -dev/syscons/teken/teken.c optional sc dev/uart/uart_cpu_amd64.c optional uart dev/wpi/if_wpi.c optional wpi isa/atrtc.c standard Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files.i386 Thu Sep 3 09:33:57 2009 (r196775) @@ -220,7 +220,6 @@ dev/syscons/scterm-teken.c optional sc dev/syscons/scvesactl.c optional sc vga vesa dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvtb.c optional sc -dev/syscons/teken/teken.c optional sc dev/uart/uart_cpu_i386.c optional uart dev/acpica/acpi_if.m standard dev/acpi_support/acpi_wmi_if.m standard Modified: head/sys/conf/files.ia64 ============================================================================== --- head/sys/conf/files.ia64 Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files.ia64 Thu Sep 3 09:33:57 2009 (r196775) @@ -60,7 +60,6 @@ dev/kbd/kbd.c optional atkbd | sc | uk dev/syscons/scterm-teken.c optional sc dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvtb.c optional sc -dev/syscons/teken/teken.c optional sc dev/uart/uart_cpu_ia64.c optional uart dev/acpica/acpi_if.m standard ia64/acpica/OsdEnvironment.c optional acpi Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files.powerpc Thu Sep 3 09:33:57 2009 (r196775) @@ -48,7 +48,6 @@ dev/sound/macio/tumbler.c optional snd_a dev/syscons/scgfbrndr.c optional sc dev/syscons/scterm-teken.c optional sc dev/syscons/scvtb.c optional sc -dev/syscons/teken/teken.c optional sc dev/tsec/if_tsec.c optional tsec dev/tsec/if_tsec_ocp.c optional tsec mpc85xx dev/uart/uart_bus_ocp.c optional uart mpc85xx Modified: head/sys/conf/files.sparc64 ============================================================================== --- head/sys/conf/files.sparc64 Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/conf/files.sparc64 Thu Sep 3 09:33:57 2009 (r196775) @@ -57,7 +57,6 @@ dev/sound/sbus/cs4231.c optional snd_au dev/syscons/scgfbrndr.c optional sc dev/syscons/scterm-teken.c optional sc dev/syscons/scvtb.c optional sc -dev/syscons/teken/teken.c optional sc dev/uart/uart_cpu_sparc64.c optional uart dev/uart/uart_kbd_sun.c optional uart sc kern/syscalls.c optional ktr Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Wed Sep 2 22:12:31 2009 (r196774) +++ head/sys/dev/syscons/scterm-teken.c Thu Sep 3 09:33:57 2009 (r196775) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include static void scteken_revattr(unsigned char, teken_attr_t *); static unsigned int scteken_attr(const teken_attr_t *); From des at FreeBSD.org Thu Sep 3 10:06:38 2009 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Thu Sep 3 10:06:45 2009 Subject: svn commit: r196776 - head/lib/libc/locale Message-ID: <200909031006.n83A6bMZ022789@svn.freebsd.org> Author: des Date: Thu Sep 3 10:06:37 2009 New Revision: 196776 URL: http://svn.freebsd.org/changeset/base/196776 Log: Document the need for a cast when passing a char to a ctype function. MFC after: 2 weeks Modified: head/lib/libc/locale/ctype.3 head/lib/libc/locale/digittoint.3 head/lib/libc/locale/isalnum.3 head/lib/libc/locale/isalpha.3 head/lib/libc/locale/isascii.3 head/lib/libc/locale/isblank.3 head/lib/libc/locale/iscntrl.3 head/lib/libc/locale/isdigit.3 head/lib/libc/locale/isgraph.3 head/lib/libc/locale/isideogram.3 head/lib/libc/locale/islower.3 head/lib/libc/locale/isphonogram.3 head/lib/libc/locale/isprint.3 head/lib/libc/locale/ispunct.3 head/lib/libc/locale/isrune.3 head/lib/libc/locale/isspace.3 head/lib/libc/locale/isspecial.3 head/lib/libc/locale/isupper.3 head/lib/libc/locale/isxdigit.3 head/lib/libc/locale/toascii.3 head/lib/libc/locale/tolower.3 head/lib/libc/locale/toupper.3 Modified: head/lib/libc/locale/ctype.3 ============================================================================== --- head/lib/libc/locale/ctype.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/ctype.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -28,7 +28,7 @@ .\" @(#)ctype.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 30, 2004 +.Dd September 3, 2009 .Dt CTYPE 3 .Os .Sh NAME @@ -111,6 +111,13 @@ They are available as macros, defined in .In ctype.h , or as true functions in the C library. See the specific manual pages for more information. +.Pp +.Em NOTE : +if the value passed to one of these functions is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh SEE ALSO .Xr digittoint 3 , .Xr isalnum 3 , Modified: head/lib/libc/locale/digittoint.3 ============================================================================== --- head/lib/libc/locale/digittoint.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/digittoint.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -28,7 +28,7 @@ .\" @(#)digittoint.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 6, 2001 +.Dd September 3, 2009 .Dt DIGITTOINT 3 .Os .Sh NAME @@ -46,6 +46,15 @@ The function converts a numeric character to its corresponding integer value. The character can be any decimal digit or hexadecimal digit. With hexadecimal characters, the case of the values does not matter. +.Pp +.Em NOTE : +if the value passed to the +.Fn digittoint +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn digittoint Modified: head/lib/libc/locale/isalnum.3 ============================================================================== --- head/lib/libc/locale/isalnum.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isalnum.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISALNUM 3 .Os .Sh NAME @@ -75,6 +75,15 @@ In the ASCII character set, this include .It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" .It "\&171\ ``y'' \t172\ ``z''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn isalnum +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isalnum Modified: head/lib/libc/locale/isalpha.3 ============================================================================== --- head/lib/libc/locale/isalpha.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isalpha.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISALPHA 3 .Os .Sh NAME @@ -73,6 +73,15 @@ In the ASCII character set, this include .It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" .It "\&171\ ``y'' \t172\ ``z''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn isalpha +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isalpha Modified: head/lib/libc/locale/isascii.3 ============================================================================== --- head/lib/libc/locale/isascii.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isascii.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -28,7 +28,7 @@ .\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd October 6, 2002 +.Dd September 3, 2009 .Dt ISASCII 3 .Os .Sh NAME @@ -47,6 +47,15 @@ function tests for an .Tn ASCII character, which is any character between 0 and octal 0177 inclusive. +.Pp +.Em NOTE : +if the value passed to the +.Fn isascii +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh SEE ALSO .Xr ctype 3 , .Xr iswascii 3 , Modified: head/lib/libc/locale/isblank.3 ============================================================================== --- head/lib/libc/locale/isblank.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isblank.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -28,7 +28,7 @@ .\" @(#)isblank.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISBLANK 3 .Os .Sh NAME @@ -57,6 +57,15 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn isblank +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isblank Modified: head/lib/libc/locale/iscntrl.3 ============================================================================== --- head/lib/libc/locale/iscntrl.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/iscntrl.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISCNTRL 3 .Os .Sh NAME @@ -65,6 +65,15 @@ In the ASCII character set, this include .It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS" .It "\&036\ RS \t037\ US \t177\ DEL" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn iscntrl +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn iscntrl Modified: head/lib/libc/locale/isdigit.3 ============================================================================== --- head/lib/libc/locale/isdigit.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isdigit.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd May 4, 2007 +.Dd September 3, 2009 .Dt ISDIGIT 3 .Os .Sh NAME @@ -68,6 +68,15 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn isdigit +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isdigit Modified: head/lib/libc/locale/isgraph.3 ============================================================================== --- head/lib/libc/locale/isgraph.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isgraph.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISGRAPH 3 .Os .Sh NAME @@ -80,6 +80,15 @@ In the ASCII character set, this include .It "\&166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' \t172\ ``z''" .It "\&173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn isgraph +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isgraph Modified: head/lib/libc/locale/isideogram.3 ============================================================================== --- head/lib/libc/locale/isideogram.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isideogram.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 30, 2004 +.Dd September 3, 2009 .Dt ISIDEOGRAM 3 .Os .Sh NAME @@ -41,6 +41,15 @@ The .Fn isideogram function tests for an ideographic character. +.Pp +.Em NOTE : +if the value passed to the +.Fn isideogram +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isideogram Modified: head/lib/libc/locale/islower.3 ============================================================================== --- head/lib/libc/locale/islower.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/islower.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)islower.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISLOWER 3 .Os .Sh NAME @@ -64,6 +64,15 @@ In the ASCII character set, this include .It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" .It "\&172\ ``z''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn islower +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn islower Modified: head/lib/libc/locale/isphonogram.3 ============================================================================== --- head/lib/libc/locale/isphonogram.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isphonogram.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 30, 2004 +.Dd September 3, 2009 .Dt ISPHONOGRAM 3 .Os .Sh NAME @@ -41,6 +41,15 @@ The .Fn isphonogram function tests for a phonographic character. +.Pp +.Em NOTE : +if the value passed to the +.Fn isphonogram +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isphonogram Modified: head/lib/libc/locale/isprint.3 ============================================================================== --- head/lib/libc/locale/isprint.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isprint.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isprint.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISPRINT 3 .Os .Sh NAME @@ -78,6 +78,15 @@ In the ASCII character set, this include .It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" .It "\&172\ ``z'' \t173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn isprint +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isprint Modified: head/lib/libc/locale/ispunct.3 ============================================================================== --- head/lib/libc/locale/ispunct.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/ispunct.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISPUNCT 3 .Os .Sh NAME @@ -70,6 +70,15 @@ In the ASCII character set, this include .It "\&136\ ``^'' \t137\ ``_'' \t140\ ```'' \t173\ ``{'' \t174\ ``|''" .It "\&175\ ``}'' \t176\ ``~''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn ispunct +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn ispunct Modified: head/lib/libc/locale/isrune.3 ============================================================================== --- head/lib/libc/locale/isrune.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isrune.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 30, 2004 +.Dd September 3, 2009 .Dt ISRUNE 3 .Os .Sh NAME @@ -46,6 +46,15 @@ In the .Tn ASCII character set, this is equivalent to .Fn isascii . +.Pp +.Em NOTE : +if the value passed to the +.Fn isrune +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isrune Modified: head/lib/libc/locale/isspace.3 ============================================================================== --- head/lib/libc/locale/isspace.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isspace.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISSPACE 3 .Os .Sh NAME @@ -61,6 +61,15 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn isspace +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isspace Modified: head/lib/libc/locale/isspecial.3 ============================================================================== --- head/lib/libc/locale/isspecial.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isspecial.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 30, 2004 +.Dd September 3, 2009 .Dt ISSPECIAL 3 .Os .Sh NAME @@ -41,6 +41,15 @@ The .Fn isspecial function tests for a special character. +.Pp +.Em NOTE : +if the value passed to the +.Fn isspecial +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isspecial Modified: head/lib/libc/locale/isupper.3 ============================================================================== --- head/lib/libc/locale/isupper.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isupper.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isupper.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISUPPER 3 .Os .Sh NAME @@ -64,6 +64,15 @@ In the ASCII character set, this include .It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''" .It "\&132\ ``Z''" .El +.Pp +.Em NOTE : +if the value passed to the +.Fn isupper +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isupper Modified: head/lib/libc/locale/isxdigit.3 ============================================================================== --- head/lib/libc/locale/isxdigit.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/isxdigit.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt ISXDIGIT 3 .Os .Sh NAME @@ -71,6 +71,15 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn isxdigit +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isxdigit Modified: head/lib/libc/locale/toascii.3 ============================================================================== --- head/lib/libc/locale/toascii.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/toascii.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -28,7 +28,7 @@ .\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 3, 2009 .Dt TOASCII 3 .Os .Sh NAME @@ -45,6 +45,15 @@ The .Fn toascii function strips all but the low 7 bits from a letter, including parity or other marker bits. +.Pp +.Em NOTE : +if the value passed to the +.Fn toascii +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES The .Fn toascii Modified: head/lib/libc/locale/tolower.3 ============================================================================== --- head/lib/libc/locale/tolower.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/tolower.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt TOLOWER 3 .Os .Sh NAME @@ -53,6 +53,15 @@ The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn tolower +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES If the argument is an upper-case letter, the .Fn tolower Modified: head/lib/libc/locale/toupper.3 ============================================================================== --- head/lib/libc/locale/toupper.3 Thu Sep 3 09:33:57 2009 (r196775) +++ head/lib/libc/locale/toupper.3 Thu Sep 3 10:06:37 2009 (r196776) @@ -32,7 +32,7 @@ .\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd September 3, 2009 .Dt TOUPPER 3 .Os .Sh NAME @@ -53,6 +53,15 @@ The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +.Em NOTE : +if the value passed to the +.Fn toupper +function is a +.Vt signed char , +as is usually the case, it must be cast to an +.Vt unsigned char +to avoid sign-extension errors. .Sh RETURN VALUES If the argument is a lower-case letter, the .Fn toupper From mav at FreeBSD.org Thu Sep 3 12:37:18 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Thu Sep 3 12:37:24 2009 Subject: svn commit: r196777 - head/sys/dev/ahci Message-ID: <200909031237.n83CbIgk032551@svn.freebsd.org> Author: mav Date: Thu Sep 3 12:37:17 2009 New Revision: 196777 URL: http://svn.freebsd.org/changeset/base/196777 Log: ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ). MFC after: 3 days Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Thu Sep 3 10:06:37 2009 (r196776) +++ head/sys/dev/ahci/ahci.c Thu Sep 3 12:37:17 2009 (r196777) @@ -1942,6 +1942,9 @@ ahciaction(struct cam_sim *sim, union cc cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; + /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ + if (pci_get_devid(device_get_parent(dev)) == 0x43801002) + cpi->maxio = min(cpi->maxio, 255 * 512); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; From attilio at FreeBSD.org Thu Sep 3 13:40:41 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Thu Sep 3 13:40:47 2009 Subject: svn commit: r196779 - in head/sys: kern sys Message-ID: <200909031340.n83Defkv034013@svn.freebsd.org> Author: attilio Date: Thu Sep 3 13:40:41 2009 New Revision: 196779 URL: http://svn.freebsd.org/changeset/base/196779 Log: Add intermediate states for attaching and detaching that will be reused by the enhached newbus locking once it is checked in. This change can be easilly MFCed to STABLE_8 at the appropriate moment. Reviewed by: jhb, scottl Tested by: Giovanni Trematerra Modified: head/sys/kern/subr_bus.c head/sys/sys/bus.h Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Thu Sep 3 12:41:00 2009 (r196778) +++ head/sys/kern/subr_bus.c Thu Sep 3 13:40:41 2009 (r196779) @@ -2625,10 +2625,16 @@ device_attach(device_t dev) { int error; + if (dev->state >= DS_ATTACHING) + return (0); device_sysctl_init(dev); if (!device_is_quiet(dev)) device_print_child(dev->parent, dev); + dev->state = DS_ATTACHING; if ((error = DEVICE_ATTACH(dev)) != 0) { + KASSERT(dev->state == DS_ATTACHING, + ("%s: %p device state must not been changing", __func__, + dev)); printf("device_attach: %s%d attach returned %d\n", dev->driver->name, dev->unit, error); /* Unset the class; set in device_probe_child */ @@ -2639,6 +2645,8 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; return (error); } + KASSERT(dev->state == DS_ATTACHING, + ("%s: %p device state must not been changing", __func__, dev)); device_sysctl_update(dev); dev->state = DS_ATTACHED; devadded(dev); @@ -2674,8 +2682,16 @@ device_detach(device_t dev) if (dev->state != DS_ATTACHED) return (0); - if ((error = DEVICE_DETACH(dev)) != 0) + dev->state = DS_DETACHING; + if ((error = DEVICE_DETACH(dev)) != 0) { + KASSERT(dev->state == DS_DETACHING, + ("%s: %p device state must not been changing", __func__, + dev)); + dev->state = DS_ATTACHED; return (error); + } + KASSERT(dev->state == DS_DETACHING, + ("%s: %p device state must not been changing", __func__, dev)); devremoved(dev); if (!device_is_quiet(dev)) device_printf(dev, "detached\n"); @@ -2730,7 +2746,7 @@ device_quiesce(device_t dev) int device_shutdown(device_t dev) { - if (dev->state < DS_ATTACHED) + if (dev->state < DS_ATTACHED || dev->state == DS_DETACHING) return (0); return (DEVICE_SHUTDOWN(dev)); } Modified: head/sys/sys/bus.h ============================================================================== --- head/sys/sys/bus.h Thu Sep 3 12:41:00 2009 (r196778) +++ head/sys/sys/bus.h Thu Sep 3 13:40:41 2009 (r196779) @@ -52,8 +52,11 @@ struct u_businfo { typedef enum device_state { DS_NOTPRESENT, /**< @brief not probed or probe failed */ DS_ALIVE, /**< @brief probe succeeded */ + DS_ATTACHING, /**< @brief attaching is in progress */ DS_ATTACHED, /**< @brief attach method called */ - DS_BUSY /**< @brief device is open */ + DS_BUSY, /**< @brief device is open */ + DS_DETACHING /**< @brief detaching is in progress */ + } device_state_t; /** From attilio at freebsd.org Thu Sep 3 13:46:43 2009 From: attilio at freebsd.org (Attilio Rao) Date: Thu Sep 3 13:46:49 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <200909031340.n83Defkv034013@svn.freebsd.org> References: <200909031340.n83Defkv034013@svn.freebsd.org> Message-ID: <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> 2009/9/3 Attilio Rao : > Author: attilio > Date: Thu Sep 3 13:40:41 2009 > New Revision: 196779 > URL: http://svn.freebsd.org/changeset/base/196779 > > Log: > Add intermediate states for attaching and detaching that will be > reused by the enhached newbus locking once it is checked in. > This change can be easilly MFCed to STABLE_8 at the appropriate moment. About this commit, there are a few of things which worths nothing: - This has been committed separately from the new-bus locking because it is planned to be MFCed before 8.0 goes out in order to offer the correct ABI compatibility for merging, while 8.1-REL, the newbus locking - Probabilly what we really wanted here is just a transitioning state instead than both DS_ATTACHING and DS_DETACHING. Some consumers would eventually understand what of the 2 is that and one of these consumers is device_is_attached(). That function is used improperly by many detach handlers in a construct like: int foo_attach(device_t dev) { ... if (error != 0) foo_detach(dev); ... } int foo_detach(device_dev) { ... if (device_is_attached(dev)) { /* do some handover */ } ... } That is an incorrect behaviour which needs to be discouraged and that will be fixed during 9.0. In the while this semantic (used by many drivers) makes the single-transition state impraticable and so we will need to stick with that device states also in 9.0. Attilio -- Peace can only be achieved by understanding - A. Einstein From scottl at samsco.org Thu Sep 3 14:22:14 2009 From: scottl at samsco.org (Scott Long) Date: Thu Sep 3 14:22:20 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <200909031237.n83CbIgk032551@svn.freebsd.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> Message-ID: <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> In this case, set maxio to 64k, not 127.5k. You'll typically get much better i/o performance out of two 64k transfers than you will out of one 127.k transfer and one 512 bytes transfer, which is what the block layer will give you if you try to send 128k. Scott On Sep 3, 2009, at 6:37 AM, Alexander Motin wrote: > Author: mav > Date: Thu Sep 3 12:37:17 2009 > New Revision: 196777 > URL: http://svn.freebsd.org/changeset/base/196777 > > Log: > ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ). > > MFC after: 3 days > > Modified: > head/sys/dev/ahci/ahci.c > > Modified: head/sys/dev/ahci/ahci.c > = > = > = > = > = > = > = > = > ====================================================================== > --- head/sys/dev/ahci/ahci.c Thu Sep 3 10:06:37 2009 (r196776) > +++ head/sys/dev/ahci/ahci.c Thu Sep 3 12:37:17 2009 (r196777) > @@ -1942,6 +1942,9 @@ ahciaction(struct cam_sim *sim, union cc > cpi->protocol = PROTO_ATA; > cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; > cpi->maxio = MAXPHYS; > + /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ > + if (pci_get_devid(device_get_parent(dev)) == 0x43801002) > + cpi->maxio = min(cpi->maxio, 255 * 512); > cpi->ccb_h.status = CAM_REQ_CMP; > xpt_done(ccb); > break; From mav at FreeBSD.org Thu Sep 3 14:54:56 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Thu Sep 3 14:55:09 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> Message-ID: <4A9FD8B4.2080605@FreeBSD.org> Scott Long wrote: > In this case, set maxio to 64k, not 127.5k. You'll typically get much > better i/o performance out of two 64k transfers > than you will out of one 127.k transfer and one 512 bytes transfer, > which is what the block layer will give you if > you try to send 128k. Couldn't it be somehow handled on that level? Limiting maxio from 127.5K to 64K is also a penalty for requests with length in that range. It would be nice if every level would do it's own job. > On Sep 3, 2009, at 6:37 AM, Alexander Motin wrote: >> Author: mav >> Date: Thu Sep 3 12:37:17 2009 >> New Revision: 196777 >> URL: http://svn.freebsd.org/changeset/base/196777 >> >> Log: >> ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ). >> >> MFC after: 3 days >> >> Modified: >> head/sys/dev/ahci/ahci.c >> >> Modified: head/sys/dev/ahci/ahci.c >> ============================================================================== >> >> --- head/sys/dev/ahci/ahci.c Thu Sep 3 10:06:37 2009 (r196776) >> +++ head/sys/dev/ahci/ahci.c Thu Sep 3 12:37:17 2009 (r196777) >> @@ -1942,6 +1942,9 @@ ahciaction(struct cam_sim *sim, union cc >> cpi->protocol = PROTO_ATA; >> cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; >> cpi->maxio = MAXPHYS; >> + /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ >> + if (pci_get_devid(device_get_parent(dev)) == 0x43801002) >> + cpi->maxio = min(cpi->maxio, 255 * 512); >> cpi->ccb_h.status = CAM_REQ_CMP; >> xpt_done(ccb); >> break; > -- Alexander Motin From scottl at samsco.org Thu Sep 3 15:59:46 2009 From: scottl at samsco.org (Scott Long) Date: Thu Sep 3 15:59:52 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <4A9FD8B4.2080605@FreeBSD.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> Message-ID: <20090903095224.N20031@pooker.samsco.org> On Thu, 3 Sep 2009, Alexander Motin wrote: > Scott Long wrote: >> In this case, set maxio to 64k, not 127.5k. You'll typically get much >> better i/o performance out of two 64k transfers >> than you will out of one 127.k transfer and one 512 bytes transfer, which >> is what the block layer will give you if >> you try to send 128k. > > Couldn't it be somehow handled on that level? It's a limitation of the paticular hardware, not the OS. Plain disks will behave like this, but RAID controllers might now. But if you want to add this feature to the upper layers, be my guest. > Limiting maxio from 127.5K to > 64K is also a penalty for requests with length in that range. Most I/O that goes to a disk comes from one of the VM pagers, and is thus page aligned and multi-of-page sized. Breaking one of these requests up into sub-page sized requests costs a whole lot more than what you are assuming. We analyzed exactly this situation a few years ago at Yahoo and came to this conclusion. > It would be > nice if every level would do it's own job. It's the job of the driver to handle the limitations of the hardware, yes. Again, if you want to experiment with pushing this functionality into GEOM, be my guest. But until then, consider following my advice. Scott > >> On Sep 3, 2009, at 6:37 AM, Alexander Motin wrote: >>> Author: mav >>> Date: Thu Sep 3 12:37:17 2009 >>> New Revision: 196777 >>> URL: http://svn.freebsd.org/changeset/base/196777 >>> >>> Log: >>> ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ). >>> >>> MFC after: 3 days >>> >>> Modified: >>> head/sys/dev/ahci/ahci.c >>> >>> Modified: head/sys/dev/ahci/ahci.c >>> ============================================================================== >>> --- head/sys/dev/ahci/ahci.c Thu Sep 3 10:06:37 2009 (r196776) >>> +++ head/sys/dev/ahci/ahci.c Thu Sep 3 12:37:17 2009 (r196777) >>> @@ -1942,6 +1942,9 @@ ahciaction(struct cam_sim *sim, union cc >>> cpi->protocol = PROTO_ATA; >>> cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; >>> cpi->maxio = MAXPHYS; >>> + /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ >>> + if (pci_get_devid(device_get_parent(dev)) == 0x43801002) >>> + cpi->maxio = min(cpi->maxio, 255 * 512); >>> cpi->ccb_h.status = CAM_REQ_CMP; >>> xpt_done(ccb); >>> break; >> > > > -- > Alexander Motin > From mav at FreeBSD.org Thu Sep 3 16:08:13 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Thu Sep 3 16:08:19 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <20090903095224.N20031@pooker.samsco.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> <20090903095224.N20031@pooker.samsco.org> Message-ID: <4A9FE9E2.1060205@FreeBSD.org> Scott Long wrote: > On Thu, 3 Sep 2009, Alexander Motin wrote: >> Scott Long wrote: >>> In this case, set maxio to 64k, not 127.5k. You'll typically get >>> much better i/o performance out of two 64k transfers >>> than you will out of one 127.k transfer and one 512 bytes transfer, >>> which is what the block layer will give you if >>> you try to send 128k. >> >> Couldn't it be somehow handled on that level? > > It's a limitation of the paticular hardware, not the OS. Plain disks > will behave like this, but RAID controllers might now. But if you want > to add this feature to the upper layers, be my guest. Huh. May be sometimes later. >> Limiting maxio from 127.5K to 64K is also a penalty for requests with >> length in that range. > > Most I/O that goes to a disk comes from one of the VM pagers, and is > thus page aligned and multi-of-page sized. Breaking one of these > requests up into sub-page sized requests costs a whole lot more than > what you are assuming. We analyzed exactly this situation a few years > ago at Yahoo and came to this conclusion. Sure, 127.5K is ugly, but what's about 96K or 112K? Is there benefits having it strictly in power of 2? -- Alexander Motin From scottl at samsco.org Thu Sep 3 16:17:53 2009 From: scottl at samsco.org (Scott Long) Date: Thu Sep 3 16:18:00 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <4A9FE9E2.1060205@FreeBSD.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> <20090903095224.N20031@pooker.samsco.org> <4A9FE9E2.1060205@FreeBSD.org> Message-ID: <20090903101015.P20031@pooker.samsco.org> On Thu, 3 Sep 2009, Alexander Motin wrote: > Scott Long wrote: >> On Thu, 3 Sep 2009, Alexander Motin wrote: >>> Scott Long wrote: >>>> In this case, set maxio to 64k, not 127.5k. You'll typically get much >>>> better i/o performance out of two 64k transfers >>>> than you will out of one 127.k transfer and one 512 bytes transfer, which >>>> is what the block layer will give you if >>>> you try to send 128k. >>> >>> Couldn't it be somehow handled on that level? >> >> It's a limitation of the paticular hardware, not the OS. Plain disks will >> behave like this, but RAID controllers might now. But if you want to add >> this feature to the upper layers, be my guest. > > Huh. May be sometimes later. > >>> Limiting maxio from 127.5K to 64K is also a penalty for requests with >>> length in that range. >> >> Most I/O that goes to a disk comes from one of the VM pagers, and is thus >> page aligned and multi-of-page sized. Breaking one of these requests up >> into sub-page sized requests costs a whole lot more than what you are >> assuming. We analyzed exactly this situation a few years ago at Yahoo and >> came to this conclusion. > > Sure, 127.5K is ugly, but what's about 96K or 112K? Is there benefits > it strictly in power of 2? It's convenient. We've analyzed the combinations. I'm just trying to offer some advice from experience. I'm going to drop the conversation now. Scott From sam at FreeBSD.org Thu Sep 3 16:24:21 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Sep 3 16:24:36 2009 Subject: svn commit: r196783 - head/sys/net80211 Message-ID: <200909031624.n83GOLhp038059@svn.freebsd.org> Author: sam Date: Thu Sep 3 16:24:21 2009 New Revision: 196783 URL: http://svn.freebsd.org/changeset/base/196783 Log: on transition to SLEEP state mark the station in power save, not awake MFC after: 3 days Modified: head/sys/net80211/ieee80211_sta.c Modified: head/sys/net80211/ieee80211_sta.c ============================================================================== --- head/sys/net80211/ieee80211_sta.c Thu Sep 3 14:23:50 2009 (r196782) +++ head/sys/net80211/ieee80211_sta.c Thu Sep 3 16:24:21 2009 (r196783) @@ -431,7 +431,7 @@ sta_newstate(struct ieee80211vap *vap, e goto invalid; break; case IEEE80211_S_SLEEP: - ieee80211_sta_pwrsave(vap, 0); + ieee80211_sta_pwrsave(vap, 1); break; default: invalid: From ache at FreeBSD.org Thu Sep 3 16:25:25 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Thu Sep 3 16:25:32 2009 Subject: svn commit: r196784 - head/etc/mtree Message-ID: <200909031625.n83GPPSK038134@svn.freebsd.org> Author: ache Date: Thu Sep 3 16:25:25 2009 New Revision: 196784 URL: http://svn.freebsd.org/changeset/base/196784 Log: Add la_LN.ISO8859-13 and lv_LV Modified: head/etc/mtree/BSD.usr.dist Modified: head/etc/mtree/BSD.usr.dist ============================================================================== --- head/etc/mtree/BSD.usr.dist Thu Sep 3 16:24:21 2009 (r196783) +++ head/etc/mtree/BSD.usr.dist Thu Sep 3 16:25:25 2009 (r196784) @@ -553,6 +553,8 @@ .. la_LN.ISO8859-1 .. + la_LN.ISO8859-13 + .. la_LN.ISO8859-15 .. la_LN.ISO8859-2 @@ -567,6 +569,10 @@ .. lt_LT.UTF-8 .. + lv_LV.ISO8859-13 + .. + lv_LV.UTF-8 + .. mn_MN.UTF-8 .. nb_NO.ISO8859-1 @@ -1077,6 +1083,8 @@ .. la_LN.ISO8859-1 .. + la_LN.ISO8859-13 + .. la_LN.ISO8859-15 .. la_LN.ISO8859-2 @@ -1091,6 +1099,10 @@ .. lt_LT.UTF-8 .. + lv_LV.ISO8859-13 + .. + lv_LV.UTF-8 + .. mn_MN.UTF-8 .. nl_BE.ISO8859-1 From sam at FreeBSD.org Thu Sep 3 16:29:03 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Sep 3 16:29:14 2009 Subject: svn commit: r196785 - head/sys/net80211 Message-ID: <200909031629.n83GT3Sp038234@svn.freebsd.org> Author: sam Date: Thu Sep 3 16:29:02 2009 New Revision: 196785 URL: http://svn.freebsd.org/changeset/base/196785 Log: correct timeout for doing NOL processing; need a ticks-relative value Obtained from: Marvell MFC after: 3 days Modified: head/sys/net80211/ieee80211_dfs.c Modified: head/sys/net80211/ieee80211_dfs.c ============================================================================== --- head/sys/net80211/ieee80211_dfs.c Thu Sep 3 16:25:25 2009 (r196784) +++ head/sys/net80211/ieee80211_dfs.c Thu Sep 3 16:29:02 2009 (r196785) @@ -235,7 +235,7 @@ dfs_timeout(void *arg) } if (oldest != now) { /* arrange to process next channel up for a status change */ - callout_schedule(&dfs->nol_timer, oldest + NOL_TIMEOUT); + callout_schedule(&dfs->nol_timer, oldest + NOL_TIMEOUT - now); } } From sam at errno.com Thu Sep 3 16:30:33 2009 From: sam at errno.com (Sam Leffler) Date: Thu Sep 3 16:30:44 2009 Subject: svn commit: r196785 - head/sys/net80211 In-Reply-To: <200909031629.n83GT3Sp038234@svn.freebsd.org> References: <200909031629.n83GT3Sp038234@svn.freebsd.org> Message-ID: <4A9FEF28.2070703@errno.com> Sam Leffler wrote: > Author: sam > Date: Thu Sep 3 16:29:02 2009 > New Revision: 196785 > URL: http://svn.freebsd.org/changeset/base/196785 > > Log: > correct timeout for doing NOL processing; need a ticks-relative value Reviewed by: rpaulo From ed at FreeBSD.org Thu Sep 3 16:31:12 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Thu Sep 3 16:31:24 2009 Subject: svn commit: r196786 - in head/sys: dev/syscons teken Message-ID: <200909031631.n83GVCp9038333@svn.freebsd.org> Author: ed Date: Thu Sep 3 16:31:11 2009 New Revision: 196786 URL: http://svn.freebsd.org/changeset/base/196786 Log: Expose the TF_REVERSE flag to the console driver. Right now libteken processes TF_REVERSE internally and returns the toggled colors to the console driver. This isn't entirely correct. This means that the bold flag is always processed by the foreground color, while reversing should be done after the foreground color has been set to a brighter version by the bold flag. This is no problem with the syscons driver, because with VGA it only supports 16 foreground and 8 background colors. My WIP console driver reconfigures the graphics hardware to disable the blink functionality and uses 16 foreground and 16 background colors. This means that this driver will handle the TF_REVERSE flag a little different from what syscons does right now. Modified: head/sys/dev/syscons/scterm-teken.c head/sys/teken/teken.c head/sys/teken/teken.h head/sys/teken/teken_demo.c Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/dev/syscons/scterm-teken.c Thu Sep 3 16:31:11 2009 (r196786) @@ -300,12 +300,20 @@ static unsigned int scteken_attr(const teken_attr_t *a) { unsigned int attr = 0; + teken_color_t fg, bg; + if (a->ta_format & TF_REVERSE) { + fg = a->ta_bgcolor; + bg = a->ta_fgcolor; + } else { + fg = a->ta_fgcolor; + bg = a->ta_bgcolor; + } if (a->ta_format & TF_BOLD) - attr |= fgcolors_bold[a->ta_fgcolor]; + attr |= fgcolors_bold[fg]; else - attr |= fgcolors_normal[a->ta_fgcolor]; - attr |= bgcolors[a->ta_bgcolor]; + attr |= fgcolors_normal[fg]; + attr |= bgcolors[bg]; #ifdef FG_UNDERLINE if (a->ta_format & TF_UNDERLINE) Modified: head/sys/teken/teken.c ============================================================================== --- head/sys/teken/teken.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken.c Thu Sep 3 16:31:11 2009 (r196786) @@ -70,9 +70,6 @@ static FILE *df; #define teken_scs_switch(t, g) #endif /* TEKEN_XTERM && TEKEN_UTF8 */ -/* Private flags for teken_format_t. */ -#define TF_REVERSE 0x08 - /* Private flags for t_stateflags. */ #define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */ #define TS_INSERT 0x02 /* Insert mode. */ @@ -114,19 +111,10 @@ static inline void teken_funcs_putchar(teken_t *t, const teken_pos_t *p, teken_char_t c, const teken_attr_t *a) { - teken_attr_t ta; teken_assert(p->tp_row < t->t_winsize.tp_row); teken_assert(p->tp_col < t->t_winsize.tp_col); - /* Apply inversion. */ - if (a->ta_format & TF_REVERSE) { - ta.ta_format = a->ta_format; - ta.ta_fgcolor = a->ta_bgcolor; - ta.ta_bgcolor = a->ta_fgcolor; - a = &ta; - } - t->t_funcs->tf_putchar(t->t_softc, p, c, a); } @@ -134,21 +122,12 @@ static inline void teken_funcs_fill(teken_t *t, const teken_rect_t *r, const teken_char_t c, const teken_attr_t *a) { - teken_attr_t ta; teken_assert(r->tr_end.tp_row > r->tr_begin.tp_row); teken_assert(r->tr_end.tp_row <= t->t_winsize.tp_row); teken_assert(r->tr_end.tp_col > r->tr_begin.tp_col); teken_assert(r->tr_end.tp_col <= t->t_winsize.tp_col); - /* Apply inversion. */ - if (a->ta_format & TF_REVERSE) { - ta.ta_format = a->ta_format; - ta.ta_fgcolor = a->ta_bgcolor; - ta.ta_bgcolor = a->ta_fgcolor; - a = &ta; - } - t->t_funcs->tf_fill(t->t_softc, r, c, a); } Modified: head/sys/teken/teken.h ============================================================================== --- head/sys/teken/teken.h Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken.h Thu Sep 3 16:31:11 2009 (r196786) @@ -54,6 +54,7 @@ typedef unsigned char teken_format_t; #define TF_BOLD 0x01 #define TF_UNDERLINE 0x02 #define TF_BLINK 0x04 +#define TF_REVERSE 0x08 typedef unsigned char teken_color_t; #define TC_BLACK 0 #define TC_RED 1 Modified: head/sys/teken/teken_demo.c ============================================================================== --- head/sys/teken/teken_demo.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken_demo.c Thu Sep 3 16:31:11 2009 (r196786) @@ -121,6 +121,8 @@ printchar(const teken_pos_t *p) attr |= A_UNDERLINE; if (px->a.ta_format & TF_BLINK) attr |= A_BLINK; + if (px->a.ta_format & TF_REVERSE) + attr |= A_REVERSE; bkgdset(attr | COLOR_PAIR(px->a.ta_fgcolor + 8 * px->a.ta_bgcolor)); mvaddstr(p->tp_row, p->tp_col, str); From remko at FreeBSD.org Thu Sep 3 16:34:21 2009 From: remko at FreeBSD.org (Remko Lodder) Date: Thu Sep 3 16:34:33 2009 Subject: svn commit: r196787 - in head: . etc libexec Message-ID: <200909031634.n83GYLkL038520@svn.freebsd.org> Author: remko Date: Thu Sep 3 16:34:20 2009 New Revision: 196787 URL: http://svn.freebsd.org/changeset/base/196787 Log: Do the first step in removing lukemftpd from the base system. Disconnect it from the build. If you are using the FTP daemon, please consider using the port ftp/tnftpd which is the same FTP server, but newer and might have more/better functionality. This results in us providing only one ftp daemon by default. Reviewed by: bz Approved by: imp (mentor, implicit) MFC after: 3 days Silence from: obrien Modified: head/ObsoleteFiles.inc head/etc/inetd.conf head/libexec/Makefile Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Thu Sep 3 16:31:11 2009 (r196786) +++ head/ObsoleteFiles.inc Thu Sep 3 16:34:20 2009 (r196787) @@ -14,6 +14,11 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20090904: remove lukemftpd +OLD_FILES+=usr/libexec/lukemftpd +OLD_FILES+=usr/share/man/man5/ftpd.conf.5.gz +OLD_FILES+=usr/share/man/man5/ftpusers.5.gz +OLD_FILES+=usr/share/man/man8/lukemftpd.8.gz # 20090902: BSD.{x11,x11-4}.dist are dead and BSD.local.dist lives in ports/ OLD_FILES+=etc/mtree/BSD.local.dist OLD_FILES+=etc/mtree/BSD.x11.dist Modified: head/etc/inetd.conf ============================================================================== --- head/etc/inetd.conf Thu Sep 3 16:31:11 2009 (r196786) +++ head/etc/inetd.conf Thu Sep 3 16:34:20 2009 (r196787) @@ -8,8 +8,6 @@ # #ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l #ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -l -#ftp stream tcp nowait root /usr/libexec/lukemftpd ftpd -l -r -#ftp stream tcp6 nowait root /usr/libexec/lukemftpd ftpd -l -r #ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4 #ssh stream tcp6 nowait root /usr/sbin/sshd sshd -i -6 #telnet stream tcp nowait root /usr/libexec/telnetd telnetd Modified: head/libexec/Makefile ============================================================================== --- head/libexec/Makefile Thu Sep 3 16:31:11 2009 (r196786) +++ head/libexec/Makefile Thu Sep 3 16:34:20 2009 (r196787) @@ -9,7 +9,6 @@ SUBDIR= ${_atrun} \ fingerd \ ftpd \ getty \ - lukemftpd \ ${_mail.local} \ ${_mknetid} \ ${_pppoed} \ From ed at 80386.nl Thu Sep 3 16:37:34 2009 From: ed at 80386.nl (Ed Schouten) Date: Thu Sep 3 16:37:40 2009 Subject: svn commit: r196787 - in head: . etc libexec In-Reply-To: <200909031634.n83GYLkL038520@svn.freebsd.org> References: <200909031634.n83GYLkL038520@svn.freebsd.org> Message-ID: <20090903163732.GQ2829@hoeg.nl> * Remko Lodder wrote: > Log: > Do the first step in removing lukemftpd from the base system. Disconnect > it from the build. > > > > MFC after: 3 days Is there a reason why we should MFC this? Wouldn't it be better to leave it in 8.0 for now? -- Ed Schouten WWW: http://80386.nl/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090903/ec6d382d/attachment.pgp From remko at elvandar.org Thu Sep 3 16:39:15 2009 From: remko at elvandar.org (Remko Lodder) Date: Thu Sep 3 16:39:26 2009 Subject: svn commit: r196787 - in head: . etc libexec In-Reply-To: <20090903163732.GQ2829@hoeg.nl> References: <200909031634.n83GYLkL038520@svn.freebsd.org> <20090903163732.GQ2829@hoeg.nl> Message-ID: On Sep 3, 2009, at 6:37 PM, Ed Schouten wrote: > * Remko Lodder wrote: >> Log: >> Do the first step in removing lukemftpd from the base system. >> Disconnect >> it from the build. >> >> >> >> MFC after: 3 days > > Is there a reason why we should MFC this? Wouldn't it be better to > leave > it in 8.0 for now? > > It will not automatically appear in 8.0. You can still build it if you connect it locally to the build again. Steps are under way to remove the rest of the code, but that might happen after 8.0 had happened. -- /"\ Best regards, | remko@FreeBSD.org \ / Remko Lodder | remko@EFnet X http://www.evilcoder.org/ | / \ ASCII Ribbon Campaign | Against HTML Mail and News From ed at 80386.nl Thu Sep 3 16:42:09 2009 From: ed at 80386.nl (Ed Schouten) Date: Thu Sep 3 16:42:17 2009 Subject: svn commit: r196787 - in head: . etc libexec In-Reply-To: References: <200909031634.n83GYLkL038520@svn.freebsd.org> <20090903163732.GQ2829@hoeg.nl> Message-ID: <20090903164208.GR2829@hoeg.nl> * Remko Lodder wrote: > It will not automatically appear in 8.0. You can still build it if > you connect it locally to the build again. > Steps are under way to remove the rest of the code, but that might > happen after 8.0 had happened. Hmhm... In my opinion it would have been better if we had a WITH_LUKEMFTPD instead of requiring users to manually rebuild it. I have to confess I don't use lukemftpd, so I'll stop complaining now. ;-) -- Ed Schouten WWW: http://80386.nl/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090903/5ed297c9/attachment.pgp From ache at FreeBSD.org Thu Sep 3 16:53:12 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Thu Sep 3 16:53:23 2009 Subject: svn commit: r196788 - head/share/colldef Message-ID: <200909031653.n83GrBVn038935@svn.freebsd.org> Author: ache Date: Thu Sep 3 16:53:11 2009 New Revision: 196788 URL: http://svn.freebsd.org/changeset/base/196788 Log: Add lv_LV, move lt_LT to common part Added: head/share/colldef/la_LN.ISO8859-13.src - copied, changed from r196787, head/share/colldef/lt_LT.ISO8859-13.src Deleted: head/share/colldef/lt_LT.ISO8859-13.src Modified: head/share/colldef/Makefile Modified: head/share/colldef/Makefile ============================================================================== --- head/share/colldef/Makefile Thu Sep 3 16:34:20 2009 (r196787) +++ head/share/colldef/Makefile Thu Sep 3 16:53:11 2009 (r196788) @@ -20,6 +20,7 @@ LOCALES= bg_BG.CP1251 \ is_IS.ISO8859-15 \ kk_KZ.PT154 \ la_LN.ISO8859-1 \ + la_LN.ISO8859-13 \ la_LN.ISO8859-15 \ la_LN.ISO8859-2 \ la_LN.ISO8859-4 \ @@ -27,7 +28,6 @@ LOCALES= bg_BG.CP1251 \ no_NO.ISO8859-1 \ no_NO.ISO8859-15 \ lt_LT.ISO8859-4 \ - lt_LT.ISO8859-13 \ pl_PL.ISO8859-2 \ ru_RU.CP1251 \ ru_RU.CP866 \ @@ -62,7 +62,7 @@ ${locale}.out: map.${locale:E} CLEANFILES= ${FILES} ENCODINGS= Big5 Big5HKSCS CP949 eucCN eucJP eucKR GB18030 GB2312 GBK \ - ISO8859-1 ISO8859-2 ISO8859-15 SJIS US-ASCII UTF-8 + ISO8859-1 ISO8859-2 ISO8859-13 ISO8859-15 SJIS US-ASCII UTF-8 ISO8859-1_Big5= is_IS:zh_TW ISO8859-1_ISO8859-1= ${ISO8859-15_ISO8859-15} pt_PT:pt_BR @@ -78,6 +78,9 @@ ISO8859-15_ISO8859-15= \ LATIN2LINKS= hu_HU ro_RO sr_YU ISO8859-2_ISO8859-2= ${LATIN2LINKS:C/^/la_LN:/} cs_CZ:sk_SK +LATIN13LINKS= lt_LT lv_LV +ISO8859-13_ISO8859-13= ${LATIN13LINKS:C/^/la_LN:/} + US-ASCII_Big5HKSCS= la_LN:zh_HK US-ASCII_CP949= la_LN:ko_KR US-ASCII_eucCN= la_LN:zh_CN @@ -95,7 +98,7 @@ UTF8LINKS= af_ZA am_ET be_BY bg_BG ca_AD da_DK de_AT de_CH de_DE \ el_GR en_AU en_CA en_GB en_IE en_NZ en_US es_ES et_EE eu_ES \ fi_FI fr_BE fr_CA fr_CH fr_FR he_IL hr_HR hu_HU hy_AM \ - is_IS it_CH it_IT ja_JP kk_KZ ko_KR lt_LT mn_MN \ + is_IS it_CH it_IT ja_JP kk_KZ ko_KR lt_LT lv_LV mn_MN \ nb_NO nl_BE nl_NL nn_NO no_NO pl_PL pt_BR pt_PT \ ro_RO ru_RU sk_SK sl_SI sr_YU sv_SE tr_TR uk_UA zh_CN zh_HK \ zh_TW Copied and modified: head/share/colldef/la_LN.ISO8859-13.src (from r196787, head/share/colldef/lt_LT.ISO8859-13.src) ============================================================================== --- head/share/colldef/lt_LT.ISO8859-13.src Thu Sep 3 16:34:20 2009 (r196787, copy source) +++ head/share/colldef/la_LN.ISO8859-13.src Thu Sep 3 16:53:11 2009 (r196788) @@ -1,4 +1,4 @@ -# Lithuanian (backward compatible with ASCII) +# Latin-7 / Baltic Rim (backward compatible with ASCII) # # $FreeBSD$ # From imp at FreeBSD.org Thu Sep 3 17:04:42 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Sep 3 17:05:00 2009 Subject: svn commit: r196789 - head Message-ID: <200909031704.n83H4gCM039220@svn.freebsd.org> Author: imp Date: Thu Sep 3 17:04:42 2009 New Revision: 196789 URL: http://svn.freebsd.org/changeset/base/196789 Log: Time for house-cleaning: o remove all entries before RELENG_7 was branched, as is tradition[*]. o Update examples... nobody cares about 5.x upgrades. o minor format tweaking in a few places. o update copyright (although at best I hold an editors copyright these days). o Remove giving people permission to buy me beer. I don't do enough for this document for that anymore... Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Thu Sep 3 16:53:11 2009 (r196788) +++ head/UPDATING Thu Sep 3 17:04:42 2009 (r196789) @@ -1,51 +1,53 @@ Updating Information for FreeBSD current users -This file is maintained and copyrighted by M. Warner Losh -. See end of file for further details. For commonly -done items, please see the COMMON ITEMS: section later in the file. +This file is maintained and copyrighted by M. Warner Losh . +See end of file for further details. For commonly done items, please see the +COMMON ITEMS: section later in the file. These instructions assume that you +basically know what you are doing. If not, then please consult the FreeBSD +handbook. Items affecting the ports and packages system can be found in -/usr/ports/UPDATING. Please read that file before running -portupgrade. +/usr/ports/UPDATING. Please read that file before running portupgrade. NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: - FreeBSD 9.x has many debugging features turned on, in - both the kernel and userland. These features attempt to detect - incorrect use of system primitives, and encourage loud failure - through extra sanity checking and fail stop semantics. They - also substantially impact system performance. If you want to - do performance measurement, benchmarking, and optimization, - you'll want to turn them off. This includes various WITNESS- - related kernel options, INVARIANTS, malloc debugging flags - in userland, and various verbose features in the kernel. Many - developers choose to disable these features on build machines - to maximize performance. (To disable malloc debugging, run + FreeBSD 9.x has many debugging features turned on, in both the kernel + and userland. These features attempt to detect incorrect use of + system primitives, and encourage loud failure through extra sanity + checking and fail stop semantics. They also substantially impact + system performance. If you want to do performance measurement, + benchmarking, and optimization, you'll want to turn them off. This + includes various WITNESS- related kernel options, INVARIANTS, malloc + debugging flags in userland, and various verbose features in the + kernel. Many developers choose to disable these features on build + machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) 20090813: - Remove the option STOP_NMI. The default action is now to use NMI - only for KDB via the newly introduced function stop_cpus_hard() - and maintain stop_cpus() to just use a normal IPI_STOP on ia32 - and amd64. + Remove the option STOP_NMI. The default action is now to use NMI only + for KDB via the newly introduced function stop_cpus_hard() and + maintain stop_cpus() to just use a normal IPI_STOP on ia32 and amd64. + +20090803: + RELENG_8 branched. 20090719: - Bump the shared library version numbers for all libraries that - do not use symbol versioning as part of the 8.0-RELEASE cycle. - Bump __FreeBSD_version to 800105. + Bump the shared library version numbers for all libraries that do not + use symbol versioning as part of the 8.0-RELEASE cycle. Bump + __FreeBSD_version to 800105. 20090714: - Due to changes in the implementation of virtual network stack - support, all network-related kernel modules must be recompiled. - As this change breaks the ABI, bump __FreeBSD_version to 800104. + Due to changes in the implementation of virtual network stack support, + all network-related kernel modules must be recompiled. As this change + breaks the ABI, bump __FreeBSD_version to 800104. 20090713: - The TOE interface to the TCP syncache has been modified to remove struct - tcpopt () from the ABI of the network stack. The - cxgb driver is the only TOE consumer affected by this change, and needs - to be recompiled along with the kernel. As this change breaks the ABI, - bump __FreeBSD_version to 800103. + The TOE interface to the TCP syncache has been modified to remove + struct tcpopt () from the ABI of the network stack. + The cxgb driver is the only TOE consumer affected by this change, and + needs to be recompiled along with the kernel. As this change breaks + the ABI, bump __FreeBSD_version to 800103. -20090712: +20090712: Padding has been added to struct tcpcb, sackhint and tcpstat in to facilitate future MFCs and bug fixes whilst maintainig the ABI. However, this change breaks the ABI, so bump @@ -53,79 +55,75 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. any of these structs (e.g. sockstat) need to be recompiled. 20090630: - The NFS_LEGACYRPC option has been removed along with the old - kernel RPC implementation that this option selected. Kernel - configurations may need to be adjusted. + The NFS_LEGACYRPC option has been removed along with the old kernel + RPC implementation that this option selected. Kernel configurations + may need to be adjusted. 20090629: - The network interface device nodes at /dev/net/ have - been removed. All ioctl operations can be performed the normal - way using routing sockets. The kqueue functionality can - generally be replaced with routing sockets. + The network interface device nodes at /dev/net/ have been + removed. All ioctl operations can be performed the normal way using + routing sockets. The kqueue functionality can generally be replaced + with routing sockets. 20090628: - The documentation from the FreeBSD Documentation Project - (Handbook, FAQ, etc.) is now installed via packages by - sysinstall(8) and under the /usr/local/share/doc/freebsd - directory instead of /usr/share/doc. + The documentation from the FreeBSD Documentation Project (Handbook, + FAQ, etc.) is now installed via packages by sysinstall(8) and under + the /usr/local/share/doc/freebsd directory instead of /usr/share/doc. 20090624: - The ABI of various structures related to the SYSV IPC API have - been changed. As a result, the COMPAT_FREEBSD[456] and COMPAT_43 - kernel options now all require COMPAT_FREEBSD7. - Bump __FreeBSD_version to 800100. + The ABI of various structures related to the SYSV IPC API have been + changed. As a result, the COMPAT_FREEBSD[456] and COMPAT_43 kernel + options now all require COMPAT_FREEBSD7. Bump __FreeBSD_version to + 800100. 20090622: - Layout of struct vnet has changed as routing related variables - were moved to their own Vimage module. Modules need to be - recompiled. Bump __FreeBSD_version to 800099. + Layout of struct vnet has changed as routing related variables were + moved to their own Vimage module. Modules need to be recompiled. Bump + __FreeBSD_version to 800099. 20090619: - NGROUPS_MAX and NGROUPS have been increased from 16 to 1023 - and 1024 respectively. As long as no more than 16 groups per - process are used, no changes should be visible. When more - than 16 groups are used, old binaries may fail if they call - getgroups() or getgrouplist() with statically sized storage. - Recompiling will work around this, but applications should be - modified to use dynamically allocated storage for group arrays - as POSIX.1-2008 does not cap an implementation's number of - supported groups at NGROUPS_MAX+1 as previous versions did. - - NFS and portalfs mounts may also be affected as the list of - groups is truncated to 16. Users of NFS who use more than 16 - groups, should take care that negative group permissions are not - used on the exported file systems as they will not be reliable - unless a GSSAPI based authentication method is used. - -20090616: - The compiling option ADAPTIVE_LOCKMGRS has been introduced. - This option compiles in the support for adaptive spinning for lockmgrs - which want to enable it. The lockinit() function now accepts the - flag LK_ADAPTIVE in order to make the lock object subject to - adaptive spinning when both held in write and read mode. + NGROUPS_MAX and NGROUPS have been increased from 16 to 1023 and 1024 + respectively. As long as no more than 16 groups per process are used, + no changes should be visible. When more than 16 groups are used, old + binaries may fail if they call getgroups() or getgrouplist() with + statically sized storage. Recompiling will work around this, but + applications should be modified to use dynamically allocated storage + for group arrays as POSIX.1-2008 does not cap an implementation's + number of supported groups at NGROUPS_MAX+1 as previous versions did. + + NFS and portalfs mounts may also be affected as the list of groups is + truncated to 16. Users of NFS who use more than 16 groups, should + take care that negative group permissions are not used on the exported + file systems as they will not be reliable unless a GSSAPI based + authentication method is used. + +20090616: + The compiling option ADAPTIVE_LOCKMGRS has been introduced. This + option compiles in the support for adaptive spinning for lockmgrs + which want to enable it. The lockinit() function now accepts the flag + LK_ADAPTIVE in order to make the lock object subject to adaptive + spinning when both held in write and read mode. 20090613: - The layout of the structure returned by IEEE80211_IOC_STA_INFO - has changed. User applications that use this ioctl need to be - rebuilt. + The layout of the structure returned by IEEE80211_IOC_STA_INFO has + changed. User applications that use this ioctl need to be rebuilt. 20090611: - The layout of struct thread has changed. Kernel and modules - need to be rebuilt. + The layout of struct thread has changed. Kernel and modules need to + be rebuilt. 20090608: - The layout of structs ifnet, domain, protosw and vnet_net has - changed. Kernel modules need to be rebuilt. - Bump __FreeBSD_version to 800097. + The layout of structs ifnet, domain, protosw and vnet_net has changed. + Kernel modules need to be rebuilt. Bump __FreeBSD_version to 800097. 20090602: window(1) has been removed from the base system. It can now be installed from ports. The port is called misc/window. 20090601: - The way we are storing and accessing `routing table' entries - has changed. Programs reading the FIB, like netstat, need to - be re-compiled. + The way we are storing and accessing `routing table' entries has + changed. Programs reading the FIB, like netstat, need to be + re-compiled. 20090601: A new netisr implementation has been added for FreeBSD 8. Network @@ -134,24 +132,24 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. Bump __FreeBSD_version to 800096. 20090530: - Remove the tunable/sysctl debug.mpsafevfs as its initial purpose - is no more valid. + Remove the tunable/sysctl debug.mpsafevfs as its initial purpose is no + more valid. 20090530: Add VOP_ACCESSX(9). File system modules need to be rebuilt. Bump __FreeBSD_version to 800094. 20090529: - Add mnt_xflag field to 'struct mount'. File system modules - need to be rebuilt. + Add mnt_xflag field to 'struct mount'. File system modules need to be + rebuilt. Bump __FreeBSD_version to 800093. 20090528: The compiling option ADAPTIVE_SX has been retired while it has been introduced the option NO_ADAPTIVE_SX which handles the reversed logic. The KPI for sx_init_flags() changes as accepting flags: - SX_ADAPTIVESPIN flag has been retired while the SX_NOADAPTIVE flag - has been introduced in order to handle the reversed logic. + SX_ADAPTIVESPIN flag has been retired while the SX_NOADAPTIVE flag has + been introduced in order to handle the reversed logic. Bump __FreeBSD_version to 800092. 20090527: @@ -164,20 +162,18 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. Bump __FreeBSD_version to 800090. 20090523: - The newly imported zic(8) produces a new format in the - output. Please run tzsetup(8) to install the newly created - data to /etc/localtime. + The newly imported zic(8) produces a new format in the output. Please + run tzsetup(8) to install the newly created data to /etc/localtime. 20090520: The sysctl tree for the usb stack has renamed from hw.usb2.* to hw.usb.* and is now consistent again with previous releases. 20090520: - 802.11 monitor mode support was revised and driver api's - were changed. Drivers dependent on net80211 now support - DLT_IEEE802_11_RADIO instead of DLT_IEEE802_11. No - user-visible data structures were changed but applications - that use DLT_IEEE802_11 may require changes. + 802.11 monitor mode support was revised and driver api's were changed. + Drivers dependent on net80211 now support DLT_IEEE802_11_RADIO instead + of DLT_IEEE802_11. No user-visible data structures were changed but + applications that use DLT_IEEE802_11 may require changes. Bump __FreeBSD_version to 800088. 20090430: @@ -768,730 +764,29 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. 20071010: RELENG_7 branched. -20071009: - Setting WITHOUT_LIBPTHREAD now means WITHOUT_LIBKSE and - WITHOUT_LIBTHR are set. - -20070930: - The PCI code has been made aware of PCI domains. This means that - the location strings as used by pciconf(8) etc are now in the - following format: pci::[:]. It - also means that consumers of potentially need to - be recompiled; this includes the hal and xorg-server ports. - -20070928: - The caching daemon (cached) was renamed to nscd. nscd.conf - configuration file should be used instead of cached.conf and - nscd_enable, nscd_pidfile and nscd_flags options should be used - instead of cached_enable, cached_pidfile and cached_flags in - rc.conf. - -20070921: - The getfacl(1) utility now prints owning user and group name - instead of owning uid and gid in the three line comment header. - This is the same behavior as getfacl(1) on Solaris and Linux. - -20070704: - The new IPsec code is now compiled in using the IPSEC option. The - IPSEC option now requires "device crypto" be defined in your kernel - configuration. The FAST_IPSEC kernel option is now deprecated. - -20070702: - The packet filter (pf) code has been updated to OpenBSD 4.1 Please - note the changed syntax - keep state is now on by default. Also - note the fact that ftp-proxy(8) has been changed from bottom up and - has been moved from libexec to usr/sbin. Changes in the ALTQ - handling also affect users of IPFW's ALTQ capabilities. - -20070701: - Remove KAME IPsec in favor of FAST_IPSEC, which is now the - only IPsec supported by FreeBSD. The new IPsec stack - supports both IPv4 and IPv6. The kernel option will change - after the code changes have settled in. For now the kernel - option IPSEC is deprecated and FAST_IPSEC is the only option, that - will change after some settling time. - -20070701: - The wicontrol(8) utility has been removed from the base system. wi(4) - cards should be configured using ifconfig(8), see the man page for more - information. - -20070612: - The i386/amd64 GENERIC kernel now defaults to the nfe(4) driver - instead of the nve(4) driver. Please update your configuration - accordingly. - -20070612: - By default, /etc/rc.d/sendmail no longer rebuilds the aliases - database if it is missing or older than the aliases file. If - desired, set the new rc.conf option sendmail_rebuild_aliases - to "YES" to restore that functionality. - -20070612: - The IPv4 multicast socket code has been considerably modified, and - moved to the file sys/netinet/in_mcast.c. Initial support for the - RFC 3678 Source-Specific Multicast Socket API has been added to - the IPv4 network stack. - - Strict multicast and broadcast reception is now the default for - UDP/IPv4 sockets; the net.inet.udp.strict_mcast_mship sysctl variable - has now been removed. - - The RFC 1724 hack for interface selection has been removed; the use - of the Linux-derived ip_mreqn structure with IP_MULTICAST_IF has - been added to replace it. Consumers such as routed will soon be - updated to reflect this. - - These changes affect users who are running routed(8) or rdisc(8) - from the FreeBSD base system on point-to-point or unnumbered - interfaces. - -20070610: - The net80211 layer has changed significantly and all wireless - drivers that depend on it need to be recompiled. Further these - changes require that any program that interacts with the wireless - support in the kernel be recompiled; this includes: ifconfig, - wpa_supplicant, hostapd, and wlanstats. Users must also, for - the moment, kldload the wlan_scan_sta and/or wlan_scan_ap modules - if they use modules for wireless support. These modules implement - scanning support for station and ap modes, respectively. Failure - to load the appropriate module before marking a wireless interface - up will result in a message to the console and the device not - operating properly. - -20070610: - The pam_nologin(8) module ceases to provide an authentication - function and starts providing an account management function. - Consequent changes to /etc/pam.d should be brought in using - mergemaster(8). Third-party files in /usr/local/etc/pam.d may - need manual editing as follows. Locate this line (or similar): - - auth required pam_nologin.so no_warn - - and change it according to this example: - - account required pam_nologin.so no_warn - - That is, the first word needs to be changed from "auth" to - "account". The new line can be moved to the account section - within the file for clarity. Not updating pam.conf(5) files - will result in nologin(5) ignored by the respective services. - -20070529: - The ether_ioctl() function has been synchronized with ioctl(2) - and ifnet.if_ioctl. Due to that, the size of one of its arguments - has changed on 64-bit architectures. All kernel modules using - ether_ioctl() need to be rebuilt on such architectures. - -20070516: - Improved INCLUDE_CONFIG_FILE support has been introduced to the - config(8) utility. In order to take advantage of this new - functionality, you are expected to recompile and install - src/usr.sbin/config. If you don't rebuild config(8), and your - kernel configuration depends on INCLUDE_CONFIG_FILE, the kernel - build will be broken because of a missing "kernconfstring" - symbol. - -20070513: - Symbol versioning is enabled by default. To disable it, use - option WITHOUT_SYMVER. It is not advisable to attempt to - disable symbol versioning once it is enabled; your installworld - will break because a symbol version-less libc will get installed - before the install tools. As a result, the old install tools, - which previously had symbol dependencies to FBSD_1.0, will fail - because the freshly installed libc will not have them. - - The default threading library (providing "libpthread") has been - changed to libthr. If you wish to have libkse as your default, - use option DEFAULT_THREAD_LIB=libkse for the buildworld. - -20070423: - The ABI breakage in sendmail(8)'s libmilter has been repaired - so it is no longer necessary to recompile mail filters (aka, - milters). If you recompiled mail filters after the 20070408 - note, it is not necessary to recompile them again. - -20070417: - The new trunk(4) driver has been renamed to lagg(4) as it better - reflects its purpose. ifconfig will need to be recompiled. - -20070408: - sendmail(8) has been updated to version 8.14.1. Mail filters - (aka, milters) compiled against the libmilter included in the - base operating system should be recompiled. - -20070302: - Firmwares for ipw(4) and iwi(4) are now included in the base tree. - In order to use them one must agree to the respective LICENSE in - share/doc/legal and define legal.intel_.license_ack=1 via - loader.conf(5) or kenv(1). Make sure to deinstall the now - deprecated modules from the respective firmware ports. - -20070228: - The name resolution/mapping functions addr2ascii(3) and ascii2addr(3) - were removed from FreeBSD's libc. These originally came from INRIA - IPv6. Nothing in FreeBSD ever used them. They may be regarded as - deprecated in previous releases. - The AF_LINK support for getnameinfo(3) was merged from NetBSD to - replace it as a more portable (and re-entrant) API. - -20070224: - To support interrupt filtering a modification to the newbus API - has occurred, ABI was broken and __FreeBSD_version was bumped - to 700031. Please make sure that your kernel and modules are in - sync. For more info: - http://docs.freebsd.org/cgi/mid.cgi?20070221233124.GA13941 - -20070224: - The IPv6 multicast forwarding code may now be loaded into GENERIC - kernels by loading the ip_mroute.ko module. This is built into the - module unless WITHOUT_INET6 or WITHOUT_INET6_SUPPORT options are - set; see src.conf(5) for more information. - -20070214: - The output of netstat -r has changed. Without -n, we now only - print a "network name" without the prefix length if the network - address and mask exactly match a Class A/B/C network, and an entry - exists in the nsswitch "networks" map. - With -n, we print the full unabbreviated CIDR network prefix in - the form "a.b.c.d/p". 0.0.0.0/0 is always printed as "default". - This change is in preparation for changes such as equal-cost - multipath, and to more generally assist operational deployment - of FreeBSD as a modern IPv4 router. - -20070210: - PIM has been turned on by default in the IPv4 multicast - routing code. The kernel option 'PIM' has now been removed. - PIM is now built by default if option 'MROUTING' is specified. - It may now be loaded into GENERIC kernels by loading the - ip_mroute.ko module. - -20070207: - Support for IPIP tunnels (VIFF_TUNNEL) in IPv4 multicast routing - has been removed. Its functionality may be achieved by explicitly - configuring gif(4) interfaces and using the 'phyint' keyword in - mrouted.conf. - XORP does not support source-routed IPv4 multicast tunnels nor the - integrated IPIP tunneling, therefore it is not affected by this - change. The __FreeBSD_version macro has been bumped to 700030. - -20061221: - Support for PCI Message Signalled Interrupts has been - re-enabled in the bge driver, only for those chips which are - believed to support it properly. If there are any problems, - MSI can be disabled completely by setting the - 'hw.pci.enable_msi' and 'hw.pci.enable_msix' tunables to 0 - in the loader. - -20061214: - Support for PCI Message Signalled Interrupts has been - disabled again in the bge driver. Many revisions of the - hardware fail to support it properly. Support can be - re-enabled by removing the #define of BGE_DISABLE_MSI in - "src/sys/dev/bge/if_bge.c". - -20061214: - Support for PCI Message Signalled Interrupts has been added - to the bge driver. If there are any problems, MSI can be - disabled completely by setting the 'hw.pci.enable_msi' and - 'hw.pci.enable_msix' tunables to 0 in the loader. - -20061205: - The removal of several facets of the experimental Threading - system from the kernel means that the proc and thread structures - have changed quite a bit. I suggest all kernel modules that might - reference these structures be recompiled.. Especially the - linux module. - -20061126: - Sound infrastructure has been updated with various fixes and - improvements. Most of the changes are pretty much transparent, - with exceptions of followings: - 1) All sound driver specific sysctls (hw.snd.pcm%d.*) have been - moved to their own dev sysctl nodes, for example: - hw.snd.pcm0.vchans -> dev.pcm.0.vchans - 2) /dev/dspr%d.%d has been deprecated. Each channel now has its - own chardev in the form of "dsp%d.%d", where - is p = playback, r = record and v = virtual, respectively. Users - are encouraged to use these devs instead of (old) "/dev/dsp%d.%d". - This does not affect those who are using "/dev/dsp". - -20061122: - geom(4)'s gmirror(8) class metadata structure has been - rev'd from v3 to v4. If you update across this point and - your metadata is converted for you, you will not be easily - able to downgrade since the /boot/kernel.old/geom_mirror.ko - kernel module will be unable to read the v4 metadata. You - can resolve this by doing from the loader(8) prompt: - - set vfs.root.mountfrom="ufs:/dev/XXX" - - where XXX is the root slice of one of the disks that composed - the mirror (i.e.: /dev/ad0s1a). You can then rebuild - the array the same way you built it originally. - -20061122: - The following binaries have been disconnected from the build: - mount_devfs, mount_ext2fs, mount_fdescfs, mount_procfs, mount_linprocfs, - and mount_std. The functionality of these programs has been - moved into the mount program. For example, to mount a devfs - filesystem, instead of using mount_devfs, use: "mount -t devfs". - This does not affect entries in /etc/fstab, since entries in - /etc/fstab are always processed with "mount -t fstype". - -20061113: - Support for PCI Message Signalled Interrupts on i386 and amd64 - has been added to the kernel and various drivers will soon be - updated to use MSI when it is available. If there are any problems, - MSI can be disabled completely by setting the 'hw.pci.enable_msi' - and 'hw.pci.enable_msix' tunables to 0 in the loader. - -20061110: - The MUTEX_PROFILING option has been renamed to LOCK_PROFILING. - The lockmgr object layout has been changed as a result of having - a lock_object embedded in it. As a consequence all file system - kernel modules must be re-compiled. The mutex profiling man page - has not yet been updated to reflect this change. - -20061026: - KSE in the kernel has now been made optional and turned on by - default. Use 'nooption KSE' in your kernel config to turn it - off. All kernel modules *must* be recompiled after this change. - There-after, modules from a KSE kernel should be compatible with - modules from a NOKSE kernel due to the temporary padding fields - added to 'struct proc'. - -20060929: - mrouted and its utilities have been removed from the base system. - -20060927: - Some ioctl(2) command codes have changed. Full backward ABI - compatibility is provided if the "options COMPAT_FREEBSD6" is - present in the kernel configuration file. Make sure to add - this option to your kernel config file, or recompile X.Org - and the rest of ports; otherwise they may refuse to work. - -20060924: - tcpslice has been removed from the base system. - -20060913: - The sizes of struct tcpcb (and struct xtcpcb) have changed due to - the rewrite of TCP syncookies. Tools like netstat, sockstat, and - systat needs to be rebuilt. - -20060903: - libpcap updated to v0.9.4 and tcpdump to v3.9.4 - -20060816: - The IPFIREWALL_FORWARD_EXTENDED option is gone and the behaviour - for IPFIREWALL_FORWARD is now as it was before when it was first - committed and for years after. The behaviour is now ON. - -20060725: - enigma(1)/crypt(1) utility has been changed on 64 bit architectures. - Now it can decrypt files created from different architectures. - Unfortunately, it is no longer able to decrypt a cipher text - generated with an older version on 64 bit architectures. - If you have such a file, you need old utility to decrypt it. - -20060709: - The interface version of the i4b kernel part has changed. So - after updating the kernel sources and compiling a new kernel, - the i4b user space tools in "/usr/src/usr.sbin/i4b" must also - be rebuilt, and vice versa. - -20060627: - The XBOX kernel now defaults to the nfe(4) driver instead of - the nve(4) driver. Please update your configuration - accordingly. - -20060514: - The i386-only lnc(4) driver for the AMD Am7900 LANCE and Am79C9xx - PCnet family of NICs has been removed. The new le(4) driver serves - as an equivalent but cross-platform replacement with the pcn(4) - driver still providing performance-optimized support for the subset - of AMD Am79C971 PCnet-FAST and greater chips as before. - -20060511: - The machdep.* sysctls and the adjkerntz utility have been - modified a bit. The new adjkerntz utility uses the new - sysctl names and sysctlbyname() calls, so it may be impossible - to run an old /sbin/adjkerntz utility in single-user mode - with a new kernel. Replace the `adjkerntz -i' step before - `make installworld' with: - - /usr/obj/usr/src/sbin/adjkerntz/adjkerntz -i - - and proceed as usual with the rest of the installworld-stage - steps. Otherwise, you risk installing binaries with their - timestamp set several hours in the future, especially if - you are running with local time set to GMT+X hours. - -20060412: - The ip6fw utility has been removed. The behavior provided by - ip6fw has been in ipfw2 for a good while and the rc.d scripts - have been updated to deal with it. There are some rules that - might not migrate cleanly. Use rc.firewall6 as a template to - rewrite rules. - -20060428: - The puc(4) driver has been overhauled. The ebus(4) and sbus(4) - attachments have been removed. Make sure to configure scc(4) - on sparc64. Note also that by default puc(4) will use uart(4) - and not sio(4) for serial ports because interrupt handling has - been optimized for multi-port serial cards and only uart(4) - implements the interface to support it. - -20060330: - The scc(4) driver replaces puc(4) for Serial Communications - Controllers (SCCs) like the Siemens SAB82532 and the Zilog - Z8530. On sparc64, it is advised to add scc(4) to the kernel - configuration to make sure that the serial ports remain - functional. - -20060317: - Most world/kernel related NO_* build options changed names. - New knobs have common prefixes WITHOUT_*/WITH_* (modelled - after FreeBSD ports) and should be set in /etc/src.conf - (the src.conf(5) manpage is provided). Full backwards - compatibility is maintained for the time being though it's - highly recommended to start moving old options out of the - system-wide /etc/make.conf file into the new /etc/src.conf - while also properly renaming them. More conversions will - likely follow. Posting to current@: - - http://lists.freebsd.org/pipermail/freebsd-current/2006-March/061725.html - -20060305: - The NETSMBCRYPTO kernel option has been retired because its - functionality is always included in NETSMB and smbfs.ko now. - -20060303: - The TDFX_LINUX kernel option was retired and replaced by the - tdfx_linux device. The latter can be loaded as the 3dfx_linux.ko - kernel module. Loading it alone should suffice to get 3dfx support - for Linux apps because it will pull in 3dfx.ko and linux.ko through - its dependencies. - -20060204: - The 'audit' group was added to support the new auditing functionality - in the base system. Be sure to follow the directions for updating, - including the requirement to run mergemaster -p. - -20060201: - The kernel ABI to file system modules was changed on i386. - Please make sure that your kernel and modules are in sync. - -20060118: - This actually occured some time ago, but installing the kernel - now also installs a bunch of symbol files for the kernel modules. - This increases the size of /boot/kernel to about 67Mbytes. You - will need twice this if you will eventually back this up to kernel.old - on your next install. - If you have a shortage of room in your root partition, you should add - -DINSTALL_NODEBUG to your make arguments or add INSTALL_NODEBUG="yes" - to your /etc/make.conf. - -20060113: - libc's malloc implementation has been replaced. This change has the - potential to uncover application bugs that previously went unnoticed. - See the malloc(3) manual page for more details. - -20060112: - The generic netgraph(4) cookie has been changed. If you upgrade - kernel passing this point, you also need to upgrade userland - and netgraph(4) utilities like ports/net/mpd or ports/net/mpd4. - -20060106: - si(4)'s device files now contain the unit number. - Uses of {cua,tty}A[0-9a-f] should be replaced by {cua,tty}A0[0-9a-f]. - -20060106: - The kernel ABI was mostly destroyed due to a change in the size - of struct lock_object which is nested in other structures such - as mutexes which are nested in all sorts of other structures. - Make sure your kernel and modules are in sync. - -20051231: - The page coloring algorithm in the VM subsystem was converted - from tuning with kernel options to autotuning. Please remove - any PQ_* option except PQ_NOOPT from your kernel config. - -20051211: - The net80211-related tools in the tools/tools/ath directory - have been moved to tools/tools/net80211 and renamed with a - "wlan" prefix. Scripts that use them should be adjusted - accordingly. - -20051202: - Scripts in the local_startup directories (as defined in - /etc/defaults/rc.conf) that have the new rc.d semantics will - now be run as part of the base system rcorder. If there are - errors or problems with one of these local scripts, it could - cause boot problems. If you encounter such problems, boot in - single user mode, remove that script from the */rc.d directory. - Please report the problem to the port's maintainer, and the - freebsd-ports@freebsd.org mailing list. - -20051129: - The nodev mount option was deprecated in RELENG_6 (where it - was a no-op), and is now unsupported. If you have nodev or dev listed - in /etc/fstab, remove it, otherwise it will result in a mount error. - -20051129: - ABI between ipfw(4) and ipfw(8) has been changed. You need - to rebuild ipfw(8) when rebuilding kernel. - -20051108: - rp(4)'s device files now contain the unit number. - Uses of {cua,tty}R[0-9a-f] should be replaced by {cua,tty}R0[0-9a-f]. - -20051029: - /etc/rc.d/ppp-user has been renamed to /etc/rc.d/ppp. - Its /etc/rc.conf.d configuration file has been `ppp' from - the beginning, and hence there is no need to touch it. - -20051014: - Now most modules get their build-time options from the kernel - configuration file. A few modules still have fixed options - due to their non-conformant implementation, but they will be - corrected eventually. You may need to review the options of - the modules in use, explicitly specify the non-default options - in the kernel configuration file, and rebuild the kernel and - modules afterwards. - -20051001: - kern.polling.enable sysctl MIB is now deprecated. Use ifconfig(8) - to turn polling(4) on your interfaces. - -20050927: - The old bridge(4) implementation was retired. The new - if_bridge(4) serves as a full functional replacement. - -20050722: - The ai_addrlen of a struct addrinfo was changed to a socklen_t - to conform to POSIX-2001. This change broke an ABI - compatibility on 64 bit architecture. You have to recompile - userland programs that use getaddrinfo(3) on 64 bit - architecture. - -20050711: - RELENG_6 branched here. - -20050629: - The pccard_ifconfig rc.conf variable has been removed and a new - variable, ifconfig_DEFAULT has been introduced. Unlike - pccard_ifconfig, ifconfig_DEFAULT applies to ALL interfaces that - do not have ifconfig_ifn entries rather than just those in - removable_interfaces. - -20050616: - Some previous versions of PAM have permitted the use of - non-absolute paths in /etc/pam.conf or /etc/pam.d/* when referring - to third party PAM modules in /usr/local/lib. A change has been - made to require the use of absolute paths in order to avoid - ambiguity and dependence on library path configuration, which may - affect existing configurations. - -20050610: - Major changes to network interface API. All drivers must be - recompiled. Drivers not in the base system will need to be - updated to the new APIs. - -20050609: - Changes were made to kinfo_proc in sys/user.h. Please recompile - userland, or commands like `fstat', `pkill', `ps', `top' and `w' - will not behave correctly. - - The API and ABI for hwpmc(4) have changed with the addition - of sampling support. Please recompile lib/libpmc(3) and - usr.sbin/{pmcstat,pmccontrol}. - -20050606: - The OpenBSD dhclient was imported in place of the ISC dhclient - and the network interface configuration scripts were updated - accordingly. If you use DHCP to configure your interfaces, you - must now run devd. Also, DNS updating was lost so you will need - to find a workaround if you use this feature. - - The '_dhcp' user was added to support the OpenBSD dhclient. Be - sure to run mergemaster -p (like you are supposed to do every time - anyway). - -20050605: - if_bridge was added to the tree. This has changed struct ifnet. - Please recompile userland and all network related modules. - -20050603: - The n_net of a struct netent was changed to an uint32_t, and - 1st argument of getnetbyaddr() was changed to an uint32_t, to - conform to POSIX-2001. These changes broke an ABI - compatibility on 64 bit architecture. With these changes, - shlib major of libpcap was bumped. You have to recompile - userland programs that use getnetbyaddr(3), getnetbyname(3), - getnetent(3) and/or libpcap on 64 bit architecture. - -20050528: - Kernel parsing of extra options on '#!' first lines of shell - scripts has changed. Lines with multiple options likely will - fail after this date. For full details, please see - http://people.freebsd.org/~gad/Updating-20050528.txt - -20050503: - The packet filter (pf) code has been updated to OpenBSD 3.7 - Please note the changed anchor syntax and the fact that - authpf(8) now needs a mounted fdescfs(5) to function. - -20050415: - The NO_MIXED_MODE kernel option has been removed from the i386 - amd64 platforms as its use has been superceded by the new local - APIC timer code. Any kernel config files containing this option - should be updated. - -20050227: - The on-disk format of LC_CTYPE files was changed to be machine - independent. Please make sure NOT to use NO_CLEAN buildworld - when crossing this point. Crossing this point also requires - recompile or reinstall of all locale depended packages. - -20050225: - The ifi_epoch member of struct if_data has been changed to - contain the uptime at which the interface was created or the - statistics zeroed rather then the wall clock time because - wallclock time may go backwards. This should have no impact - unless an snmp implementation is using this value (I know of - none at this point.) - -20050224: - The acpi_perf and acpi_throttle drivers are now part of the - acpi(4) main module. They are no longer built separately. - -20050223: - The layout of struct image_params has changed. You have to - recompile all compatibility modules (linux, svr4, etc) for use - with the new kernel. - -20050223: - The p4tcc driver has been merged into cpufreq(4). This makes - "options CPU_ENABLE_TCC" obsolete. Please load cpufreq.ko or - compile in "device cpufreq" to restore this functionality. - -20050220: - The responsibility of recomputing the file system summary of - a SoftUpdates-enabled dirty volume has been transferred to the - background fsck. A rebuild of fsck(8) utility is recommended - if you have updated the kernel. - - To get the old behavior (recompute file system summary at mount - time), you can set vfs.ffs.compute_summary_at_mount=1 before - mounting the new volume. - -20050206: - The cpufreq import is complete. As part of this, the sysctls for - acpi(4) throttling have been removed. The power_profile script - has been updated, so you can use performance/economy_cpu_freq in - rc.conf(5) to set AC on/offline cpu frequencies. - -20050206: - NG_VERSION has been increased. Recompiling kernel (or ng_socket.ko) - requires recompiling libnetgraph and userland netgraph utilities. - -20050114: - Support for abbreviated forms of a number of ipfw options is - now deprecated. Warnings are printed to stderr indicating the - correct full form when a match occurs. Some abbreviations may - be supported at a later date based on user feedback. To be - considered for support, abbreviations must be in use prior to - this commit and unlikely to be confused with current key words. - -20041221: - By a popular demand, a lot of NOFOO options were renamed - to NO_FOO (see bsd.compat.mk for a full list). The old - spellings are still supported, but will cause annoying - warnings on stderr. Make sure you upgrade properly (see - the COMMON ITEMS: section later in this file). - -20041219: - Auto-loading of ancillary wlan modules such as wlan_wep has - been temporarily disabled; you need to statically configure - the modules you need into your kernel or explicitly load them - prior to use. Specifically, if you intend to use WEP encryption - with an 802.11 device load/configure wlan_wep; if you want to - use WPA with the ath driver load/configure wlan_tkip, wlan_ccmp, - and wlan_xauth as required. - -20041213: - The behaviour of ppp(8) has changed slightly. If lqr is enabled - (``enable lqr''), older versions would revert to LCP ECHO mode on - negotiation failure. Now, ``enable echo'' is required for this - behaviour. The ppp version number has been bumped to 3.4.2 to - reflect the change. - -20041201: - The wlan support has been updated to split the crypto support - into separate modules. For static WEP you must configure the - wlan_wep module in your system or build and install the module - in place where it can be loaded (the kernel will auto-load - the module when a wep key is configured). - -20041201: - The ath driver has been updated to split the tx rate control - algorithm into a separate module. You need to include either - ath_rate_onoe or ath_rate_amrr when configuring the kernel. - -20041116: - Support for systems with an 80386 CPU has been removed. Please - use FreeBSD 5.x or earlier on systems with an 80386. - -20041110: - We have had a hack which would mount the root filesystem - R/W if the device were named 'md*'. As part of the vnode - work I'm doing I have had to remove this hack. People - building systems which use preloaded MD root filesystems - may need to insert a "/sbin/mount -u -o rw /dev/md0 /" in - their /etc/rc scripts. - -20041104: - FreeBSD 5.3 shipped here. - -20041102: - The size of struct tcpcb has changed again due to the removal - of RFC1644 T/TCP. You have to recompile userland programs that - read kmem for tcp sockets directly (netstat, sockstat, etc.) - -20041022: - The size of struct tcpcb has changed. You have to recompile - userland programs that read kmem for tcp sockets directly - (netstat, sockstat, etc.) - -20041016: - RELENG_5 branched here. For older entries, please see updating - in the RELENG_5 branch. - COMMON ITEMS: General Notes ------------- - Avoid using make -j when upgrading. From time to time in the - past there have been problems using -j with buildworld and/or - installworld. This is especially true when upgrading between - "distant" versions (eg one that cross a major release boundary - or several minor releases, or when several months have passed - on the -current branch). + Avoid using make -j when upgrading. While generally safe, there are + sometimes problems using -j to upgrade. If your upgrade fails with + -j, please try again wtihout -j. From time to time in the past there + have been problems using -j with buildworld and/or installworld. This + is especially true when upgrading between "distant" versions (eg one + that cross a major release boundary or several minor releases, or when + several months have passed on the -current branch). Sometimes, obscure build problems are the result of environment poisoning. This can happen because the make utility reads its - environment when searching for values for global variables. - To run your build attempts in an "environmental clean room", - prefix all make commands with 'env -i '. See the env(1) manual *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From dougb at FreeBSD.org Thu Sep 3 17:07:20 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Thu Sep 3 17:07:26 2009 Subject: svn commit: r196727 - head/share/man/man5 In-Reply-To: <86hbvli9tg.fsf@gmail.com> References: <200909010555.n815tAkx050140@svn.freebsd.org> <4A9D4A90.30700@FreeBSD.org> <20090902092054.Q27429@mp2.macomnet.net> <4A9E7718.1080503@andric.com> <86hbvli9tg.fsf@gmail.com> Message-ID: <4A9FF7BD.30104@FreeBSD.org> Anonymous wrote: > Dimitry Andric writes: > >> On 2009-09-02 07:21, Maxim Konovalov wrote: >>>> Unless I'm missing something this should be in the src.conf man page >>>> instead of make.conf. >>> Please explain why. >> make.conf(5): >> The file make.conf contains system-wide settings that will apply to every >> build using make(1) and the standard sys.mk file. >> >> src.conf(5): >> The src.conf file contains settings that will apply to every build >> involving the FreeBSD source tree; see build(7). >> >> The MALLOC_PRODUCTION define is used inside the FreeBSD source tree >> (actually only in jemalloc, it seems). >> >> You most likely don't want it to apply 'globally', since third-party >> programs (e.g. ports) might give a totally different meaning to this >> define -- or most likely: no meaning at all. :) > > Don't you think this affects not only MALLOC_PRODUCTION but all defines > under sections "BUILDING THE KERNEL" and "BUILDING THE WORLD"? Yes, those should probably be moved as well. I've cc'ed Ruslan since he's really taken the lead on the src.conf stuff. > For example, WITHOUT_MODULES conflicts with one in archivers/p7zip. Good point. You should probably bring that to the attention of the port's maintainer. Doug -- This .signature sanitized for your protection From ache at FreeBSD.org Thu Sep 3 17:12:46 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Thu Sep 3 17:12:52 2009 Subject: svn commit: r196790 - head/share/mklocale Message-ID: <200909031712.n83HCkCT039422@svn.freebsd.org> Author: ache Date: Thu Sep 3 17:12:45 2009 New Revision: 196790 URL: http://svn.freebsd.org/changeset/base/196790 Log: Add lv_LV, move lt_LT to common part Added: head/share/mklocale/la_LN.ISO8859-13.src - copied unchanged from r196789, head/share/mklocale/lt_LT.ISO8859-13.src Deleted: head/share/mklocale/lt_LT.ISO8859-13.src Modified: head/share/mklocale/Makefile Modified: head/share/mklocale/Makefile ============================================================================== --- head/share/mklocale/Makefile Thu Sep 3 17:04:42 2009 (r196789) +++ head/share/mklocale/Makefile Thu Sep 3 17:12:45 2009 (r196790) @@ -13,11 +13,11 @@ LOCALES= UTF-8 \ ko_KR.CP949 \ ko_KR.eucKR \ la_LN.ISO8859-1 \ + la_LN.ISO8859-13 \ la_LN.ISO8859-15 \ la_LN.ISO8859-2 \ la_LN.ISO8859-4 \ la_LN.US-ASCII \ - lt_LT.ISO8859-13 \ ru_RU.CP866 \ ru_RU.ISO8859-5 \ ru_RU.KOI8-R \ @@ -47,7 +47,7 @@ FILESDIR_${locale}.out= ${LOCALEDIR}/${l CLEANFILES= ${FILES} ENCODINGS= CP1251 ISO8859-1 ISO8859-2 ISO8859-4 ISO8859-5 \ - ISO8859-15 US-ASCII UTF-8 + ISO8859-13 ISO8859-15 US-ASCII UTF-8 ASCIILINKS= en_AU en_CA en_GB en_NZ en_US US-ASCII_US-ASCII= ${ASCIILINKS:C/^/la_LN:/} @@ -71,6 +71,9 @@ ISO8859-4_ISO8859-4= ${LATIN4LINKS:C/^/l LATIN5LINKS= sr_YU uk_UA be_BY ISO8859-5_ISO8859-5= ${LATIN5LINKS:C/^/ru_RU:/} +LATIN13LINKS= lt_LT lv_LV +ISO8859-13_ISO8859-13= ${LATIN13LINKS:C/^/la_LN:/} + CP1251LINKS= ru_RU be_BY uk_UA CP1251_CP1251= ${CP1251LINKS:C/^/bg_BG:/} @@ -79,7 +82,7 @@ UTF8LINKS= af_ZA be_BY bg_BG ca_AD ca_ES en_AU en_CA en_GB en_IE en_NZ en_US es_ES et_EE eu_ES fi_FI \ fr_BE \ fr_CA fr_CH fr_FR he_IL hr_HR hu_HU hy_AM is_IS it_CH it_IT \ - ja_JP kk_KZ ko_KR lt_LT mn_MN \ + ja_JP kk_KZ ko_KR lt_LT lv_LV mn_MN \ nb_NO nl_BE nl_NL nn_NO no_NO pl_PL pt_BR pt_PT \ ro_RO ru_RU sk_SK sl_SI sr_YU sv_SE tr_TR uk_UA zh_CN zh_HK \ zh_TW Copied: head/share/mklocale/la_LN.ISO8859-13.src (from r196789, head/share/mklocale/lt_LT.ISO8859-13.src) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/mklocale/la_LN.ISO8859-13.src Thu Sep 3 17:12:45 2009 (r196790, copy of r196789, head/share/mklocale/lt_LT.ISO8859-13.src) @@ -0,0 +1,49 @@ +/* + * LOCALE_CTYPE for the iso_8859_13 Locale + * + * $FreeBSD$ + */ + +ENCODING "NONE" +VARIABLE ISO 8859-13 Latin-7 character set + +# +# This is a comment +# +ALPHA 'A' - 'Z' 'a' - 'z' +ALPHA 0xaa 0xba 0xc0 - 0xd6 0xd8 - 0xde 0xe0 - 0xf6 0xf8 - 0xfe +CONTROL 0x00 - 0x1f 0x7f - 0x9f +DIGIT '0' - '9' +GRAPH 0x21 - 0x7e 0xa1 - 0xff +LOWER 'a' - 'z' +LOWER 0xba 0xdf - 0xf6 0xf8 - 0xfe +PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e +PUNCT 0xa1 - 0xa9 0xab - 0xb9 0xbb -0xbf 0xd7 0xdf 0xf7 0xff +SPACE 0x09 - 0x0d 0x20 0xa0 +UPPER 'A' - 'Z' +UPPER 0xaa 0xc0 - 0xd6 0xd8 - 0xde +XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F' +BLANK ' ' '\t' 0xa0 +PRINT 0x20 - 0x7e 0xa0 - 0xff + +MAPLOWER <'A' - 'Z' : 'a'> +MAPLOWER <'a' - 'z' : 'a'> +MAPLOWER <0xaa 0xba> +MAPLOWER <0xba 0xba> +MAPLOWER <0xc0 - 0xd6 : 0xe0> +MAPLOWER <0xd8 - 0xde : 0xf8> +MAPLOWER <0xe0 - 0xf6 : 0xe0> +MAPLOWER <0xf8 - 0xfe : 0xf8> + +MAPUPPER <'A' - 'Z' : 'A'> +MAPUPPER <'a' - 'z' : 'A'> +MAPUPPER <0xaa 0xaa> +MAPUPPER <0xba 0xaa> +MAPUPPER <0xc0 - 0xd6 : 0xc0> +MAPUPPER <0xd8 - 0xdf : 0xd8> +MAPUPPER <0xe0 - 0xf6 : 0xc0> +MAPUPPER <0xf8 - 0xfe : 0xd8> + +TODIGIT <'0' - '9' : 0> +TODIGIT <'A' - 'F' : 10> +TODIGIT <'a' - 'f' : 10> From imp at FreeBSD.org Thu Sep 3 17:13:54 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Sep 3 17:14:01 2009 Subject: svn commit: r196791 - head Message-ID: <200909031713.n83HDsFc039487@svn.freebsd.org> Author: imp Date: Thu Sep 3 17:13:54 2009 New Revision: 196791 URL: http://svn.freebsd.org/changeset/base/196791 Log: Actually, stable/8 is what was created... Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Thu Sep 3 17:12:45 2009 (r196790) +++ head/UPDATING Thu Sep 3 17:13:54 2009 (r196791) @@ -28,7 +28,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. maintain stop_cpus() to just use a normal IPI_STOP on ia32 and amd64. 20090803: - RELENG_8 branched. + stable/8 branch created in subversion. 20090719: Bump the shared library version numbers for all libraries that do not From ache at FreeBSD.org Thu Sep 3 17:37:23 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Thu Sep 3 17:37:29 2009 Subject: svn commit: r196792 - head/share/numericdef Message-ID: <200909031737.n83HbNYr040047@svn.freebsd.org> Author: ache Date: Thu Sep 3 17:37:23 2009 New Revision: 196792 URL: http://svn.freebsd.org/changeset/base/196792 Log: Add lv_LV Modified: head/share/numericdef/Makefile Modified: head/share/numericdef/Makefile ============================================================================== --- head/share/numericdef/Makefile Thu Sep 3 17:13:54 2009 (r196791) +++ head/share/numericdef/Makefile Thu Sep 3 17:37:23 2009 (r196792) @@ -107,7 +107,8 @@ ISO8859-5_CP1251= uk_UA ISO8859-7_UTF-8= el_GR ISO8859-9_UTF-8= tr_TR ISO8859-13_ISO8859-4= lt_LT -ISO8859-13_UTF-8= lt_LT +ISO8859-13_ISO8859-13= lt_LT:lv_LV +ISO8859-13_UTF-8= lt_LT lt_LT:lv_LV ISO8859-15_UTF-8= et_EE KOI8-R_CP1251= ru_RU KOI8-R_CP866= ru_RU From ivoras at freebsd.org Thu Sep 3 17:38:08 2009 From: ivoras at freebsd.org (Ivan Voras) Date: Thu Sep 3 17:39:55 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <20090903095224.N20031@pooker.samsco.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> <20090903095224.N20031@pooker.samsco.org> Message-ID: <9bbcef730909031037y4aecd692t4812718b1fd7e78e@mail.gmail.com> 2009/9/3 Scott Long : > On Thu, 3 Sep 2009, Alexander Motin wrote: >> It would be nice if every level would do it's own job. > > It's the job of the driver to handle the limitations of the hardware, yes. > Again, if you want to experiment with pushing this functionality into GEOM, > be my guest. ?But until then, consider following my advice. Speaking as an user who goes "huh, well" every time he sees a RAID card with a GB of cache talking to the OS in 64 kB chunks, eventually removing this limitation seems a Nice Thing to Have. I don't know how things look at the driver side, but GEOM by itself has no problems passing around requests of at least "long" in length. Specifically, it cares about struct bio, where bio_bcount is a "long" and bio_length and bio_completed are off_t. So, ssize_t looks ok as a high boundary. There was a time (apparently much of it was a bug in reporting and is now fixed :( ) when MAXPHYS could be manually redefined to be 256K or more and iostat would nicely state the higher value. I think the concern raised at the topic was that it doesn't play nice with bufcache, and I think the specific problem was possible out-of-memory situations. Now that kernel limits on AMD64 are much increased (to values not longer fitting in uint32_t) I wonder if the problem is so serious? I also remember BSDCan 2008: http://wiki.freebsd.org/Buf0x :) -- f+rEnSIBITAhITAhLR1nM9F4cIs5KJrhbcsVtUIt7K1MhWJy1A== From scottl at samsco.org Thu Sep 3 17:51:00 2009 From: scottl at samsco.org (Scott Long) Date: Thu Sep 3 17:51:06 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <9bbcef730909031037y4aecd692t4812718b1fd7e78e@mail.gmail.com> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> <20090903095224.N20031@pooker.samsco.org> <9bbcef730909031037y4aecd692t4812718b1fd7e78e@mail.gmail.com> Message-ID: <20090903114121.C20031@pooker.samsco.org> On Thu, 3 Sep 2009, Ivan Voras wrote: > 2009/9/3 Scott Long : >> On Thu, 3 Sep 2009, Alexander Motin wrote: > >>> It would be nice if every level would do it's own job. >> >> It's the job of the driver to handle the limitations of the hardware, yes. >> Again, if you want to experiment with pushing this functionality into GEOM, >> be my guest. ?But until then, consider following my advice. > > Speaking as an user who goes "huh, well" every time he sees a RAID > card with a GB of cache talking to the OS in 64 kB chunks, eventually > removing this limitation seems a Nice Thing to Have. > > I don't know how things look at the driver side, but GEOM by itself > has no problems passing around requests of at least "long" in length. > Specifically, it cares about struct bio, where bio_bcount is a "long" > and bio_length and bio_completed are off_t. So, ssize_t looks ok as a > high boundary. > > There was a time (apparently much of it was a bug in reporting and is > now fixed :( ) when MAXPHYS could be manually redefined to be 256K or > more and iostat would nicely state the higher value. I think the > concern raised at the topic was that it doesn't play nice with > bufcache, and I think the specific problem was possible out-of-memory > situations. Now that kernel limits on AMD64 are much increased (to > values not longer fitting in uint32_t) I wonder if the problem is so > serious? > The problem is lack of kernel address space, not lack of RAM, but that's just semantics in this discussion. I've tested with increasing MAXPHYS in increments to 1M. Performance increases logrithmically, and effectively hits a max at 512K for the variety of controllers that I tested. The gain from 64K to 128K is huge, the gain from 128K to 256K is ok, the gain from 256k to 512k is measurable but less significant, and the gain from 512k to 1m is almost not measurable. I have simple patches to increase MAXPHYS. The introduction of the the maxio paramter in the CAM SIM interface is there in preparation for this. However, a _LOT_LOT_LOT_ of drivers in the tree falsely assume that MAXPHYS and DEFLTPHYS are 128k and 64k respectively, and size their data structures accordingly. Changing these values will cause the drivers to fail in bad ways. So an audit needs to be done. Also, MAXPHYS is abused by the swapper in the struct-buf, so that needs to be reviewed as well. Even though kernel address space is less restricted on 64bit platforms, it's still not free and limitless. Large I/O's requires more work in the VM to assign address space, and in turn causes more lock contention. I haven't done any practical measurements of this on common workloads, but I can anecdotally say that I see increased lock contention from it in locking profiles. If FreeBSD wants to seriously increase MAXPHYS, this needs to be looked at and either proven to not be important, or fixed. Scott From jhb at freebsd.org Thu Sep 3 18:38:41 2009 From: jhb at freebsd.org (John Baldwin) Date: Thu Sep 3 18:38:48 2009 Subject: svn commit: r196791 - head In-Reply-To: <200909031713.n83HDsFc039487@svn.freebsd.org> References: <200909031713.n83HDsFc039487@svn.freebsd.org> Message-ID: <200909031356.52226.jhb@freebsd.org> On Thursday 03 September 2009 1:13:54 pm Warner Losh wrote: > Author: imp > Date: Thu Sep 3 17:13:54 2009 > New Revision: 196791 > URL: http://svn.freebsd.org/changeset/base/196791 > > Log: > Actually, stable/8 is what was created... Technically both were done: RELENG_8 in CVS and stable/8 in SVN. That said, it is probably better to document SVN rather than CVS going forward. -- John Baldwin From mav at FreeBSD.org Thu Sep 3 19:02:18 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Thu Sep 3 19:02:29 2009 Subject: svn commit: r196796 - head/sys/dev/ahci Message-ID: <200909031902.n83J2HZC042128@svn.freebsd.org> Author: mav Date: Thu Sep 3 19:02:17 2009 New Revision: 196796 URL: http://svn.freebsd.org/changeset/base/196796 Log: Round maxio for ATI SB600 to 64K. Submitted by: scottl@ Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Thu Sep 3 18:27:55 2009 (r196795) +++ head/sys/dev/ahci/ahci.c Thu Sep 3 19:02:17 2009 (r196796) @@ -1944,7 +1944,7 @@ ahciaction(struct cam_sim *sim, union cc cpi->maxio = MAXPHYS; /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ if (pci_get_devid(device_get_parent(dev)) == 0x43801002) - cpi->maxio = min(cpi->maxio, 255 * 512); + cpi->maxio = min(cpi->maxio, 128 * 512); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; From kostikbel at gmail.com Thu Sep 3 19:15:55 2009 From: kostikbel at gmail.com (Kostik Belousov) Date: Thu Sep 3 19:16:07 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <200909031340.n83Defkv034013@svn.freebsd.org> References: <200909031340.n83Defkv034013@svn.freebsd.org> Message-ID: <20090903191548.GJ1881@deviant.kiev.zoral.com.ua> On Thu, Sep 03, 2009 at 01:40:41PM +0000, Attilio Rao wrote: > Author: attilio > Date: Thu Sep 3 13:40:41 2009 > New Revision: 196779 > URL: http://svn.freebsd.org/changeset/base/196779 > > Log: > Add intermediate states for attaching and detaching that will be > reused by the enhached newbus locking once it is checked in. > This change can be easilly MFCed to STABLE_8 at the appropriate moment. > > Reviewed by: jhb, scottl > Tested by: Giovanni Trematerra > .... > Modified: head/sys/sys/bus.h > ============================================================================== > --- head/sys/sys/bus.h Thu Sep 3 12:41:00 2009 (r196778) > +++ head/sys/sys/bus.h Thu Sep 3 13:40:41 2009 (r196779) > @@ -52,8 +52,11 @@ struct u_businfo { > typedef enum device_state { > DS_NOTPRESENT, /**< @brief not probed or probe failed */ > DS_ALIVE, /**< @brief probe succeeded */ > + DS_ATTACHING, /**< @brief attaching is in progress */ > DS_ATTACHED, /**< @brief attach method called */ > - DS_BUSY /**< @brief device is open */ > + DS_BUSY, /**< @brief device is open */ > + DS_DETACHING /**< @brief detaching is in progress */ > + > } device_state_t; Since device_state_t is exposed to consumers and started to be modified, would it make sense to add explicit values for enumeration members, with enough gap in between ? It seems to give more freedom for newbus locking work with regard to backward-compatible ABI changes. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090903/edac1b1a/attachment.pgp From ivoras at freebsd.org Thu Sep 3 19:45:29 2009 From: ivoras at freebsd.org (Ivan Voras) Date: Thu Sep 3 19:45:41 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <20090903114121.C20031@pooker.samsco.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <1872D962-9297-4C45-9F73-4BB823C49D74@samsco.org> <4A9FD8B4.2080605@FreeBSD.org> <20090903095224.N20031@pooker.samsco.org> <9bbcef730909031037y4aecd692t4812718b1fd7e78e@mail.gmail.com> <20090903114121.C20031@pooker.samsco.org> Message-ID: <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> 2009/9/3 Scott Long : > The problem is lack of kernel address space, not lack of RAM, but that's Yes. > just semantics in this discussion. ?I've tested with increasing MAXPHYS in > increments to 1M. ?Performance increases logrithmically, and effectively > hits a max at 512K for the variety of controllers that I tested. ?The gain > from 64K to 128K is huge, the gain from 128K to 256K is ok, the gain from > 256k to 512k is measurable but less significant, and the gain from 512k to > 1m is almost not measurable. >From what I've seen with iostat, all machines I can currently test (SATA, various SCSI-like RAID, QLogic FC HBA), 64 k is the maximum transfer size, which I assume is DFLTPHYS. From your tests it's apparent it is suboptimal... > I have simple patches to increase MAXPHYS. ?The introduction of the the > maxio paramter in the CAM SIM interface is there in preparation for this. > However, a _LOT_LOT_LOT_ of drivers in the tree falsely assume that MAXPHYS > and DEFLTPHYS are 128k and 64k respectively, and size their data structures > accordingly. ?Changing these values will cause the drivers to fail in bad > ways. ?So an audit needs to be done. ?Also, MAXPHYS is abused by the swapper > in the struct-buf, so that needs to be reviewed as well. Since GEOM is ok with it, couldn't a migration path be to introduce a new tunable, something like LARGE_MAXPHYS (or to rename it completely to MAX_IO) or whatever and use it (after reviewing cases of abuses) in new and better maintained drivers? If the new size is larger than the old one, maybe the maximum damage would be a little bit of wasted space now and then? I can test mostly ciss and mfi. I see mfi uses it in one place that looks kind of logical: 334 /* 335 * Get information needed for sizing the contiguous memory for the 336 * frame pool. Size down the sgl parameter since we know that 337 * we will never need more than what's required for MAXPHYS. 338 * It would be nice if these constants were available at runtime 339 * instead of compile time. 340 */ 341 status = sc->mfi_read_fw_status(sc); 342 sc->mfi_max_fw_cmds = status & MFI_FWSTATE_MAXCMD_MASK; 343 max_fw_sge = (status & MFI_FWSTATE_MAXSGL_MASK) >> 16; 344 sc->mfi_max_sge = min(max_fw_sge, ((MAXPHYS / PAGE_SIZE) + 1)); But ciss doesn't reference it at all so either it deviously assumes it or is independent of it. > Even though kernel address space is less restricted on 64bit platforms, it's > still not free and limitless. ?Large I/O's requires more work in the VM to > assign address space, and in turn causes more lock contention. ?I haven't > done any practical measurements of this on common workloads, but I can > anecdotally say that I see increased lock contention from it in locking > profiles. ?If FreeBSD wants to seriously increase MAXPHYS, this needs to be > looked at and either proven to not be important, or fixed. I think the major benefits would be for the server-side crowd using RAID modes with some kind of striping. -- f+rEnSIBITAhITAhLR1nM9F4cIs5KJrhbcsVtUIt7K1MhWJy1A== From jhb at freebsd.org Thu Sep 3 20:10:01 2009 From: jhb at freebsd.org (John Baldwin) Date: Thu Sep 3 20:10:12 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <20090903114121.C20031@pooker.samsco.org> <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> Message-ID: <200909031602.01222.jhb@freebsd.org> On Thursday 03 September 2009 3:45:07 pm Ivan Voras wrote: > But ciss doesn't reference it at all so either it deviously assumes it > or is independent of it. Actually, it may be much worse, it may be that the author of ciss(4) new that ciss(4)'s largest supported I/O size was larger than 128k so they didn't bother handling the limit at all giving the false impression the hardware has no limit. -- John Baldwin From zec at icir.org Thu Sep 3 20:26:05 2009 From: zec at icir.org (Marko Zec) Date: Thu Sep 3 20:26:21 2009 Subject: svn commit: r196769 - in head/sys: amd64/amd64 i386/i386 In-Reply-To: <200909021602.n82G2mpE000812@svn.freebsd.org> References: <200909021602.n82G2mpE000812@svn.freebsd.org> Message-ID: <200909032225.50210.zec@icir.org> On Wednesday 02 September 2009 18:02:48 Jung-uk Kim wrote: > Author: jkim > Date: Wed Sep 2 16:02:48 2009 > New Revision: 196769 > URL: http://svn.freebsd.org/changeset/base/196769 > > Log: > - Work around ACPI mode transition problem for recent NVIDIA 9400M > chipset based Intel Macs. Since r189055, these platforms started freezing > when ACPI is being initialized for unknown reason. For these platforms, we > just use the old PAT layout. Note this change is not enough to boot fully > on these platforms because of other problems but it makes debugging > possible. Note MacBook5,2 may be affected as well but it was not added here > because of lack of hardware to test. > - Initialize PAT MSR fully instead of reading and modifying it for > safety. Perhaps I'm missing something, but I fail to understand what is the purpose / use of variable pat_tested here? Marko > Reported by: rpaulo, hps, Eygene Ryabinkin (rea-fbsd at codelabs dot ru) > Reviewed by: jhb > > Modified: > head/sys/amd64/amd64/pmap.c > head/sys/i386/i386/pmap.c > > Modified: head/sys/amd64/amd64/pmap.c > =========================================================================== >=== --- head/sys/amd64/amd64/pmap.c Wed Sep 2 14:56:23 2009 (r196768) +++ > head/sys/amd64/amd64/pmap.c Wed Sep 2 16:02:48 2009 (r196769) @@ -178,6 > +178,8 @@ static vm_paddr_t dmaplimit; > vm_offset_t kernel_vm_end = VM_MIN_KERNEL_ADDRESS; > pt_entry_t pg_nx; > > +static int pat_works = 0; /* Is page attribute table sane? */ > + > SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); > > static int pg_ps_enabled = 1; > @@ -590,20 +592,56 @@ void > pmap_init_pat(void) > { > uint64_t pat_msr; > + char *sysenv; > + static int pat_tested = 0; > > /* Bail if this CPU doesn't implement PAT. */ > if (!(cpu_feature & CPUID_PAT)) > panic("no PAT??"); > > /* > - * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. > - * Program 4 and 5 as WP and WC. > - * Leave 6 and 7 as UC and UC-. > - */ > - pat_msr = rdmsr(MSR_PAT); > - pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); > - pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | > - PAT_VALUE(5, PAT_WRITE_COMBINING); > + * Some Apple Macs based on nVidia chipsets cannot enter ACPI mode > + * via SMI# when we use upper 4 PAT entries for unknown reason. > + */ > + if (!pat_tested) { > + pat_works = 1; > + sysenv = getenv("smbios.system.product"); > + if (sysenv != NULL) { > + if (strncmp(sysenv, "MacBook5,1", 10) == 0 || > + strncmp(sysenv, "MacBookPro5,5", 13) == 0 || > + strncmp(sysenv, "Macmini3,1", 10) == 0) > + pat_works = 0; > + freeenv(sysenv); > + } > + pat_tested = 1; > + } > + > + /* Initialize default PAT entries. */ > + pat_msr = PAT_VALUE(0, PAT_WRITE_BACK) | > + PAT_VALUE(1, PAT_WRITE_THROUGH) | > + PAT_VALUE(2, PAT_UNCACHED) | > + PAT_VALUE(3, PAT_UNCACHEABLE) | > + PAT_VALUE(4, PAT_WRITE_BACK) | > + PAT_VALUE(5, PAT_WRITE_THROUGH) | > + PAT_VALUE(6, PAT_UNCACHED) | > + PAT_VALUE(7, PAT_UNCACHEABLE); > + > + if (pat_works) { > + /* > + * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. > + * Program 4 and 5 as WP and WC. > + * Leave 6 and 7 as UC and UC-. > + */ > + pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); > + pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | > + PAT_VALUE(5, PAT_WRITE_COMBINING); > + } else { > + /* > + * Just replace PAT Index 2 with WC instead of UC-. > + */ > + pat_msr &= ~PAT_MASK(2); > + pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); > + } > wrmsr(MSR_PAT, pat_msr); > } > > @@ -754,27 +792,48 @@ pmap_cache_bits(int mode, boolean_t is_p > pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT; > > /* Map the caching mode to a PAT index. */ > - switch (mode) { > - case PAT_UNCACHEABLE: > - pat_index = 3; > - break; > - case PAT_WRITE_THROUGH: > - pat_index = 1; > - break; > - case PAT_WRITE_BACK: > - pat_index = 0; > - break; > - case PAT_UNCACHED: > - pat_index = 2; > - break; > - case PAT_WRITE_COMBINING: > - pat_index = 5; > - break; > - case PAT_WRITE_PROTECTED: > - pat_index = 4; > - break; > - default: > - panic("Unknown caching mode %d\n", mode); > + if (pat_works) { > + switch (mode) { > + case PAT_UNCACHEABLE: > + pat_index = 3; > + break; > + case PAT_WRITE_THROUGH: > + pat_index = 1; > + break; > + case PAT_WRITE_BACK: > + pat_index = 0; > + break; > + case PAT_UNCACHED: > + pat_index = 2; > + break; > + case PAT_WRITE_COMBINING: > + pat_index = 5; > + break; > + case PAT_WRITE_PROTECTED: > + pat_index = 4; > + break; > + default: > + panic("Unknown caching mode %d\n", mode); > + } > + } else { > + switch (mode) { > + case PAT_UNCACHED: > + case PAT_UNCACHEABLE: > + case PAT_WRITE_PROTECTED: > + pat_index = 3; > + break; > + case PAT_WRITE_THROUGH: > + pat_index = 1; > + break; > + case PAT_WRITE_BACK: > + pat_index = 0; > + break; > + case PAT_WRITE_COMBINING: > + pat_index = 2; > + break; > + default: > + panic("Unknown caching mode %d\n", mode); > + } > } > > /* Map the 3-bit index value into the PAT, PCD, and PWT bits. */ > > Modified: head/sys/i386/i386/pmap.c > =========================================================================== >=== --- head/sys/i386/i386/pmap.c Wed Sep 2 14:56:23 2009 (r196768) > +++ head/sys/i386/i386/pmap.c Wed Sep 2 16:02:48 2009 (r196769) > @@ -212,7 +212,7 @@ pt_entry_t pg_nx; > static uma_zone_t pdptzone; > #endif > > -static int pat_works; /* Is page attribute table sane? */ > +static int pat_works = 0; /* Is page attribute table sane? */ > > SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); > > @@ -478,40 +478,69 @@ void > pmap_init_pat(void) > { > uint64_t pat_msr; > + char *sysenv; > + static int pat_tested = 0; > > /* Bail if this CPU doesn't implement PAT. */ > if (!(cpu_feature & CPUID_PAT)) > return; > > - if (cpu_vendor_id != CPU_VENDOR_INTEL || > - (I386_CPU_FAMILY(cpu_id) == 6 && I386_CPU_MODEL(cpu_id) >= 0xe)) { > + /* > + * Due to some Intel errata, we can only safely use the lower 4 > + * PAT entries. > + * > + * Intel Pentium III Processor Specification Update > + * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B > + * or Mode C Paging) > + * > + * Intel Pentium IV Processor Specification Update > + * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) > + * > + * Some Apple Macs based on nVidia chipsets cannot enter ACPI mode > + * via SMI# when we use upper 4 PAT entries for unknown reason. > + */ > + if (!pat_tested) { > + if (cpu_vendor_id != CPU_VENDOR_INTEL || > + (I386_CPU_FAMILY(cpu_id) == 6 && > + I386_CPU_MODEL(cpu_id) >= 0xe)) { > + pat_works = 1; > + sysenv = getenv("smbios.system.product"); > + if (sysenv != NULL) { > + if (strncmp(sysenv, "MacBook5,1", 10) == 0 || > + strncmp(sysenv, "MacBookPro5,5", 13) == 0 || > + strncmp(sysenv, "Macmini3,1", 10) == 0) > + pat_works = 0; > + freeenv(sysenv); > + } > + } > + pat_tested = 1; > + } > + > + /* Initialize default PAT entries. */ > + pat_msr = PAT_VALUE(0, PAT_WRITE_BACK) | > + PAT_VALUE(1, PAT_WRITE_THROUGH) | > + PAT_VALUE(2, PAT_UNCACHED) | > + PAT_VALUE(3, PAT_UNCACHEABLE) | > + PAT_VALUE(4, PAT_WRITE_BACK) | > + PAT_VALUE(5, PAT_WRITE_THROUGH) | > + PAT_VALUE(6, PAT_UNCACHED) | > + PAT_VALUE(7, PAT_UNCACHEABLE); > + > + if (pat_works) { > /* > * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. > * Program 4 and 5 as WP and WC. > * Leave 6 and 7 as UC and UC-. > */ > - pat_msr = rdmsr(MSR_PAT); > pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5)); > pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) | > PAT_VALUE(5, PAT_WRITE_COMBINING); > - pat_works = 1; > } else { > /* > - * Due to some Intel errata, we can only safely use the lower 4 > - * PAT entries. Thus, just replace PAT Index 2 with WC instead > - * of UC-. > - * > - * Intel Pentium III Processor Specification Update > - * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B > - * or Mode C Paging) > - * > - * Intel Pentium IV Processor Specification Update > - * Errata N46 (PAT Index MSB May Be Calculated Incorrectly) > + * Just replace PAT Index 2 with WC instead of UC-. > */ > - pat_msr = rdmsr(MSR_PAT); > pat_msr &= ~PAT_MASK(2); > pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); > - pat_works = 0; > } > wrmsr(MSR_PAT, pat_msr); > } From scottl at samsco.org Thu Sep 3 20:31:11 2009 From: scottl at samsco.org (Scott Long) Date: Thu Sep 3 20:31:28 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <200909031602.01222.jhb@freebsd.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <20090903114121.C20031@pooker.samsco.org> <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> <200909031602.01222.jhb@freebsd.org> Message-ID: On Sep 3, 2009, at 2:02 PM, John Baldwin wrote: > On Thursday 03 September 2009 3:45:07 pm Ivan Voras wrote: >> But ciss doesn't reference it at all so either it deviously assumes >> it >> or is independent of it. > > Actually, it may be much worse, it may be that the author of ciss(4) > new that > ciss(4)'s largest supported I/O size was larger than 128k so they > didn't > bother handling the limit at all giving the false impression the > hardware has > no limit. You're exactly right. The solution is to do a proper audit and fix the potential problems, not add yet another 1-off flag that avoids doing real work. If you want to help, keep in mind that I need help _generating_ patches, not testing them. I appreciate all of the testing goodwill out there, but analysis and fixing goodwill is needed at this phase. Scott From jkim at FreeBSD.org Thu Sep 3 20:52:01 2009 From: jkim at FreeBSD.org (Jung-uk Kim) Date: Thu Sep 3 20:52:13 2009 Subject: svn commit: r196769 - in head/sys: amd64/amd64 i386/i386 In-Reply-To: <200909032225.50210.zec@icir.org> References: <200909021602.n82G2mpE000812@svn.freebsd.org> <200909032225.50210.zec@icir.org> Message-ID: <200909031651.49575.jkim@FreeBSD.org> On Thursday 03 September 2009 04:25 pm, Marko Zec wrote: > On Wednesday 02 September 2009 18:02:48 Jung-uk Kim wrote: > > Author: jkim > > Date: Wed Sep 2 16:02:48 2009 > > New Revision: 196769 > > URL: http://svn.freebsd.org/changeset/base/196769 > > > > Log: > > - Work around ACPI mode transition problem for recent NVIDIA > > 9400M chipset based Intel Macs. Since r189055, these platforms > > started freezing when ACPI is being initialized for unknown > > reason. For these platforms, we just use the old PAT layout. > > Note this change is not enough to boot fully on these platforms > > because of other problems but it makes debugging possible. Note > > MacBook5,2 may be affected as well but it was not added here > > because of lack of hardware to test. > > - Initialize PAT MSR fully instead of reading and modifying it > > for safety. > > Perhaps I'm missing something, but I fail to understand what is the > purpose / use of variable pat_tested here? Without it, bad things may happen while APs are being initialized in SMP case. Jung-uk Kim From gnn at FreeBSD.org Thu Sep 3 21:10:57 2009 From: gnn at FreeBSD.org (George V. Neville-Neil) Date: Thu Sep 3 21:11:09 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat Message-ID: <200909032110.n83LAvUF044731@svn.freebsd.org> Author: gnn Date: Thu Sep 3 21:10:57 2009 New Revision: 196797 URL: http://svn.freebsd.org/changeset/base/196797 Log: Add ARP statistics to the kernel and netstat. New counters now exist for: requests sent replies sent requests received replies received packets received total packets dropped due to no ARP entry entrys timed out Duplicate IPs seen The new statistics are seen in the netstat command when it is given the -s command line switch. MFC after: 2 weeks In collaboration with: bz Modified: head/sys/net/if_arp.h head/sys/netinet/if_ether.c head/usr.bin/netstat/inet.c head/usr.bin/netstat/main.c head/usr.bin/netstat/netstat.h Modified: head/sys/net/if_arp.h ============================================================================== --- head/sys/net/if_arp.h Thu Sep 3 19:02:17 2009 (r196796) +++ head/sys/net/if_arp.h Thu Sep 3 21:10:57 2009 (r196797) @@ -108,6 +108,31 @@ struct arpcom { #define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) #define AC2IFP(ac) ((ac)->ac_ifp) -#endif +#endif /* _KERNEL */ + +struct arpstat { + /* Normal things that happen: */ + u_long txrequests; /* # of ARP requests sent by this host. */ + u_long txreplies; /* # of ARP replies sent by this host. */ + u_long rxrequests; /* # of ARP requests received by this host. */ + u_long rxreplies; /* # of ARP replies received by this host. */ + u_long received; /* # of ARP packets received by this host. */ + + u_long arp_spares[4]; /* For either the upper or lower half. */ + /* Abnormal event and error counting: */ + u_long dropped; /* # of packets dropped waiting for a reply. */ + u_long timeouts; /* # of times with entries removed */ + /* due to timeout. */ + u_long dupips; /* # of duplicate IPs detected. */ +}; + +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ +#define ARPSTAT_ADD(name, val) V_arpstat.name += (val) +#define ARPSTAT_SUB(name, val) V_arpstat.name -= (val) +#define ARPSTAT_INC(name) ARPSTAT_ADD(name, 1) +#define ARPSTAT_DEC(name) ARPSTAT_SUB(name, 1) #endif /* !_NET_IF_ARP_H_ */ Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Thu Sep 3 19:02:17 2009 (r196796) +++ head/sys/netinet/if_ether.c Thu Sep 3 21:10:57 2009 (r196797) @@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$"); SYSCTL_DECL(_net_link_ether); SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, ""); +SYSCTL_NODE(_net_link_ether, PF_ARP, arp, CTLFLAG_RW, 0, ""); VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for * local traffic */ @@ -89,10 +90,12 @@ static VNET_DEFINE(int, arpt_keep) = (20 * minutes */ static VNET_DEFINE(int, arp_maxtries) = 5; static VNET_DEFINE(int, arp_proxyall); +static VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ #define V_arpt_keep VNET(arpt_keep) #define V_arp_maxtries VNET(arp_maxtries) #define V_arp_proxyall VNET(arp_proxyall) +#define V_arpstat VNET(arpstat) SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW, &VNET_NAME(arpt_keep), 0, @@ -107,6 +110,9 @@ SYSCTL_VNET_INT(_net_link_ether_inet, OI SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW, &VNET_NAME(arp_proxyall), 0, "Enable proxy ARP for all suitable requests"); +SYSCTL_VNET_STRUCT(_net_link_ether_arp, OID_AUTO, stats, CTLFLAG_RW, + &VNET_NAME(arpstat), arpstat, + "ARP statistics (struct arpstat, net/if_arp.h)"); static void arp_init(void); void arprequest(struct ifnet *, @@ -163,20 +169,23 @@ arptimer(void *arg) return; } ifp = lle->lle_tbl->llt_ifp; + CURVNET_SET(ifp->if_vnet); IF_AFDATA_LOCK(ifp); LLE_WLOCK(lle); - if (((lle->la_flags & LLE_DELETED) - || (time_second >= lle->la_expire)) - && (!callout_pending(&lle->la_timer) && - callout_active(&lle->la_timer))) + if (((lle->la_flags & LLE_DELETED) || + (time_second >= lle->la_expire)) && + (!callout_pending(&lle->la_timer) && + callout_active(&lle->la_timer))) { (void) llentry_free(lle); - else { + ARPSTAT_INC(timeouts); + } else { /* * Still valid, just drop our reference */ LLE_FREE_LOCKED(lle); } IF_AFDATA_UNLOCK(ifp); + CURVNET_RESTORE(); } /* @@ -238,6 +247,7 @@ arprequest(struct ifnet *ifp, struct in_ sa.sa_len = 2; m->m_flags |= M_BCAST; (*ifp->if_output)(ifp, m, &sa, NULL); + ARPSTAT_INC(txrequests); } /* @@ -339,8 +349,10 @@ retry: * latest one. */ if (m != NULL) { - if (la->la_hold != NULL) + if (la->la_hold != NULL) { m_freem(la->la_hold); + ARPSTAT_INC(dropped); + } la->la_hold = m; if (renew == 0 && (flags & LLE_EXCLUSIVE)) { flags &= ~LLE_EXCLUSIVE; @@ -413,6 +425,7 @@ arpintr(struct mbuf *m) ar = mtod(m, struct arphdr *); } + ARPSTAT_INC(received); switch (ntohs(ar->ar_pro)) { #ifdef INET case ETHERTYPE_IP: @@ -493,6 +506,9 @@ in_arpinput(struct mbuf *m) (void)memcpy(&isaddr, ar_spa(ah), sizeof (isaddr)); (void)memcpy(&itaddr, ar_tpa(ah), sizeof (itaddr)); + if (op == ARPOP_REPLY) + ARPSTAT_INC(rxreplies); + /* * For a bridge, we want to check the address irrespective * of the receive interface. (This will change slightly @@ -603,6 +619,7 @@ match: ifp->if_addrlen, (u_char *)ar_sha(ah), ":", inet_ntoa(isaddr), ifp->if_xname); itaddr = myaddr; + ARPSTAT_INC(dupips); goto reply; } if (ifp->if_flags & IFF_STATICARP) @@ -686,6 +703,7 @@ match: reply: if (op != ARPOP_REQUEST) goto drop; + ARPSTAT_INC(rxrequests); if (itaddr.s_addr == myaddr.s_addr) { /* Shortcut.. the receiving interface is the target. */ @@ -774,6 +792,7 @@ reply: sa.sa_family = AF_ARP; sa.sa_len = 2; (*ifp->if_output)(ifp, m, &sa, NULL); + ARPSTAT_INC(txreplies); return; drop: Modified: head/usr.bin/netstat/inet.c ============================================================================== --- head/usr.bin/netstat/inet.c Thu Sep 3 19:02:17 2009 (r196796) +++ head/usr.bin/netstat/inet.c Thu Sep 3 21:10:57 2009 (r196797) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -871,6 +872,47 @@ ip_stats(u_long off, const char *name, i #undef p1a } +/* + * Dump ARP statistics structure. + */ +void +arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) +{ + struct arpstat arpstat, zerostat; + size_t len = sizeof(arpstat); + + if (live) { + if (zflag) + memset(&zerostat, 0, len); + if (sysctlbyname("net.link.ether.arp.stats", &arpstat, &len, + zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { + warn("sysctl: net.link.ether.arp.stats"); + return; + } + } else + kread(off, &arpstat, len); + + printf("%s:\n", name); + +#define p(f, m) if (arpstat.f || sflag <= 1) \ + printf(m, arpstat.f, plural(arpstat.f)) +#define p2(f, m) if (arpstat.f || sflag <= 1) \ + printf(m, arpstat.f, pluralies(arpstat.f)) + + p(txrequests, "\t%lu ARP request%s sent\n"); + p2(txreplies, "\t%lu ARP repl%s sent\n"); + p(rxrequests, "\t%lu ARP request%s received\n"); + p2(rxreplies, "\t%lu ARP repl%s received\n"); + p(received, "\t%lu ARP packet%s received\n"); + p(dropped, "\t%lu total packet%s dropped due to no ARP entry\n"); + p(timeouts, "\t%lu ARP entry%s timed out\n"); + p(dupips, "\t%lu Duplicate IP%s seen\n"); +#undef p +#undef p2 +} + + + static const char *icmpnames[ICMP_MAXTYPE + 1] = { "echo reply", /* RFC 792 */ "#1", Modified: head/usr.bin/netstat/main.c ============================================================================== --- head/usr.bin/netstat/main.c Thu Sep 3 19:02:17 2009 (r196796) +++ head/usr.bin/netstat/main.c Thu Sep 3 21:10:57 2009 (r196797) @@ -184,6 +184,8 @@ static struct nlist nl[] = { { .n_name = "_sctpstat" }, #define N_MFCTABLESIZE 54 { .n_name = "_mfctablesize" }, +#define N_ARPSTAT 55 + { .n_name = "_arpstat" }, { .n_name = NULL }, }; @@ -232,6 +234,8 @@ struct protox { carp_stats, NULL, "carp", 1, 0 }, { -1, N_PFSYNCSTAT, 1, NULL, pfsync_stats, NULL, "pfsync", 1, 0 }, + { -1, N_ARPSTAT, 1, NULL, + arp_stats, NULL, "arp", 1, 0 }, { -1, -1, 0, NULL, NULL, NULL, NULL, 0, 0 } }; Modified: head/usr.bin/netstat/netstat.h ============================================================================== --- head/usr.bin/netstat/netstat.h Thu Sep 3 19:02:17 2009 (r196796) +++ head/usr.bin/netstat/netstat.h Thu Sep 3 21:10:57 2009 (r196797) @@ -75,6 +75,7 @@ void udp_stats(u_long, const char *, int void sctp_protopr(u_long, const char *, int, int); void sctp_stats(u_long, const char *, int, int); #endif +void arp_stats(u_long, const char *, int, int); void ip_stats(u_long, const char *, int, int); void icmp_stats(u_long, const char *, int, int); void igmp_stats(u_long, const char *, int, int); From zec at icir.org Thu Sep 3 21:11:13 2009 From: zec at icir.org (Marko Zec) Date: Thu Sep 3 21:11:19 2009 Subject: svn commit: r196769 - in head/sys: amd64/amd64 i386/i386 In-Reply-To: <200909031651.49575.jkim@FreeBSD.org> References: <200909021602.n82G2mpE000812@svn.freebsd.org> <200909032225.50210.zec@icir.org> <200909031651.49575.jkim@FreeBSD.org> Message-ID: <200909032310.59837.zec@icir.org> On Thursday 03 September 2009 22:51:47 Jung-uk Kim wrote: > On Thursday 03 September 2009 04:25 pm, Marko Zec wrote: > > On Wednesday 02 September 2009 18:02:48 Jung-uk Kim wrote: > > > Author: jkim > > > Date: Wed Sep 2 16:02:48 2009 > > > New Revision: 196769 > > > URL: http://svn.freebsd.org/changeset/base/196769 > > > > > > Log: > > > - Work around ACPI mode transition problem for recent NVIDIA > > > 9400M chipset based Intel Macs. Since r189055, these platforms > > > started freezing when ACPI is being initialized for unknown > > > reason. For these platforms, we just use the old PAT layout. > > > Note this change is not enough to boot fully on these platforms > > > because of other problems but it makes debugging possible. Note > > > MacBook5,2 may be affected as well but it was not added here > > > because of lack of hardware to test. > > > - Initialize PAT MSR fully instead of reading and modifying it > > > for safety. > > > > Perhaps I'm missing something, but I fail to understand what is the > > purpose / use of variable pat_tested here? > > Without it, bad things may happen while APs are being initialized in > SMP case. Ouch, OK, only now I see that pat_tested is declared static - I thought it was reset to 0 at each pmap_init_pat() call... Sorry for the noise, Marko From jfv at FreeBSD.org Thu Sep 3 22:00:43 2009 From: jfv at FreeBSD.org (Jack F Vogel) Date: Thu Sep 3 22:00:49 2009 Subject: svn commit: r196798 - head/sys/dev/ixgbe Message-ID: <200909032200.n83M0gTK045771@svn.freebsd.org> Author: jfv Date: Thu Sep 3 22:00:42 2009 New Revision: 196798 URL: http://svn.freebsd.org/changeset/base/196798 Log: Stupid cut and paste error on a stats struct member, thanks to Ryan at Small Tree for finding this one. Modified: head/sys/dev/ixgbe/ixgbe.c Modified: head/sys/dev/ixgbe/ixgbe.c ============================================================================== --- head/sys/dev/ixgbe/ixgbe.c Thu Sep 3 21:10:57 2009 (r196797) +++ head/sys/dev/ixgbe/ixgbe.c Thu Sep 3 22:00:42 2009 (r196798) @@ -4507,7 +4507,7 @@ ixgbe_update_stats_counters(struct adapt adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC); /* 82598 only has a counter in the high register */ adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); - adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GOTCH); + adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH); adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH); } From pjd at FreeBSD.org Thu Sep 3 22:19:10 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Thu Sep 3 22:19:16 2009 Subject: svn commit: r196799 - head/usr.sbin/diskinfo Message-ID: <200909032219.n83MJ9cQ046173@svn.freebsd.org> Author: pjd Date: Thu Sep 3 22:19:09 2009 New Revision: 196799 URL: http://svn.freebsd.org/changeset/base/196799 Log: Don't bother obtaining the ident if we are not going to print it. Modified: head/usr.sbin/diskinfo/diskinfo.c Modified: head/usr.sbin/diskinfo/diskinfo.c ============================================================================== --- head/usr.sbin/diskinfo/diskinfo.c Thu Sep 3 22:00:42 2009 (r196798) +++ head/usr.sbin/diskinfo/diskinfo.c Thu Sep 3 22:19:09 2009 (r196799) @@ -104,9 +104,6 @@ main(int argc, char **argv) error = ioctl(fd, DIOCGFWHEADS, &fwheads); if (error) fwheads = 0; - error = ioctl(fd, DIOCGIDENT, ident); - if (error) - ident[0] = '\0'; if (!opt_v) { printf("%s", argv[i]); printf("\t%u", sectorsize); @@ -133,7 +130,7 @@ main(int argc, char **argv) printf("\t%-12u\t# Heads according to firmware.\n", fwheads); printf("\t%-12u\t# Sectors according to firmware.\n", fwsectors); } - if (ident[0] != '\0') + if (ioctl(fd, DIOCGIDENT, ident) == 0) printf("\t%-12s\t# Disk ident.\n", ident); } printf("\n"); From brde at optusnet.com.au Fri Sep 4 03:42:16 2009 From: brde at optusnet.com.au (Bruce Evans) Date: Fri Sep 4 03:42:27 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <86zl9c9z05.fsf@ds4.des.no> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> Message-ID: <20090904115255.Q48987@delplex.bde.org> On Thu, 3 Sep 2009, [utf-8] Dag-Erling Smørgrav wrote: > Andrey Chernov writes: >> Thanx for detailed explanation. > > np; I've made that mistake many times myself. Andrey doesn't make that mistake many times (at least this millenium), but fixes it a lot. > What do you think of the attached patch? Why not use the same text as POSIX? I don't like repeating this ad nauseum, but POSIX does. (In POSIX.1-2001-draft7, this repetition is responsible for 1/3 of the lines matching of "unsigned char".) C99 says this only once for ctype functions, at the beginning of the section on . The patch is missing the corresponding text for wctype functions (argmuments of type wint_t generally give undefined behaviour unless their value is representable as a wchar_t or equal to the value of WEOF). In FreeBSD, wint_t has the same type as wchar_t and that type is int, so bugs in this area are latent (unportable code might run on FreeBSD, and there might be problems with the sign bit and/or with WEOF being indistinguishable from a valid wide char encoding. gcc/config/i386 has some targets with 16-bit wide chars, and these have to be more careful about both. The non-broken ones use uint16_t for wchar_t and int for wint_t)> % Index: lib/libc/locale/iscntrl.3 % =================================================================== % --- lib/libc/locale/iscntrl.3 (revision 196695) % +++ lib/libc/locale/iscntrl.3 (working copy) % @@ -32,7 +32,7 @@ % .\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 % .\" $FreeBSD$ % .\" % -.Dd July 17, 2005 % +.Dd September 3, 2009 % .Dt ISCNTRL 3 % .Os % .Sh NAME % @@ -65,6 +65,15 @@ % .It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS" % .It "\&036\ RS \t037\ US \t177\ DEL" % .El % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn iscntrl % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. This wording is poor. It should be something like "if the value to be passed is represented as a signed char" ... I don't know a good easy way to fix "must be cast ... to avoid sign-extension errors". The value must be converted to one representable as an unsigned char to work, but that is not always possible, and blindly casting may give a wrong value. In most cases, it is an error to represent the value as a signed char to begin with, and better to cast a pointer from "char *" to "u_char": char *p; /* Already a bad type. */ ... isalpha(*p); /* Wrong since *p might be < 0. */ ... isalpha((u_char)*p); /* Mishandles exotic machines. */ ... isalpha(*(u_char *)p); /* Mishandles diff. exotic machines. */ "unsigned char" is spelled u_char in KNF. Here this makes the above lines barely fit in 80 columns before quoting. Exotic machines include: - simple ones complement with no trap representations, signed chars and CHAR_BIT = 8. I think '\xff' is -0. Casting this to u_char gives 0, which is probably not what is wanted, while casting the pointer to it gives 0xff (if the bits are there in the memory copy), which is probably what is wanted. - ones with chars being signed and signed chars having a larger range than unsigned ones, or with u_char of a different size than char (not sure if the latter is allowed). Then casting the pointer will give a reasonable value, though possibly not the wanted one (the difficulty is more in advancing the pointer), while blindly casting the value may corrupt many more values than -0. - ones with trap representations, instead of or in addition to the above complications. Now *p will trap on trap reps but there should be no trap reps in valid data, while casting the pointer will always give a reasonable value, possibly including trap bits. Sign extension for passing a signed char is not an error. The error is passing a negative value. Neither C99 nor POSIX gives any advice. They just say that the behaviour is undefined if the value is not representable as an unsigned char or equal to the value of EOF. % Index: lib/libc/locale/isrune.3 % =================================================================== % --- lib/libc/locale/isrune.3 (revision 196695) % +++ lib/libc/locale/isrune.3 (working copy) % @@ -25,7 +25,7 @@ % .\" % .\" $FreeBSD$ % .\" % -.Dd March 30, 2004 % +.Dd September 3, 2009 % .Dt ISRUNE 3 % .Os % .Sh NAME % @@ -46,6 +46,15 @@ % .Tn ASCII % character set, this is equivalent to % .Fn isascii . % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn isrune % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. % .Sh RETURN VALUES % The % .Fn isrune This seems to be wrong. isascii() works on all int args, so I assume isrune() does too. isrune.3 also misdescribes its arg as "the character" -- this prejudges the arg. % Index: lib/libc/locale/digittoint.3 % =================================================================== % --- lib/libc/locale/digittoint.3 (revision 196695) % +++ lib/libc/locale/digittoint.3 (working copy) % @@ -28,7 +28,7 @@ % .\" @(#)digittoint.3 8.1 (Berkeley) 6/4/93 % .\" $FreeBSD$ % .\" % -.Dd April 6, 2001 % +.Dd September 3, 2009 % .Dt DIGITTOINT 3 % .Os % .Sh NAME % @@ -46,6 +46,15 @@ % function converts a numeric character to its corresponding integer value. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ % The character can be any decimal digit or hexadecimal digit. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ % With hexadecimal characters, the case of the values does not matter. % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn digittoint % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. % .Sh RETURN VALUES % The % .Fn digittoint Here the behaviour already seems to be undefined unless the arg is a decimal or hex digit. Like isascii(), this function isn't in C99, so it can be more or less strict than other ctype functions. % Index: lib/libc/locale/isascii.3 % =================================================================== % --- lib/libc/locale/isascii.3 (revision 196695) % +++ lib/libc/locale/isascii.3 (working copy) % @@ -28,7 +28,7 @@ % .\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 % .\" $FreeBSD$ % .\" % -.Dd October 6, 2002 % +.Dd September 3, 2009 % .Dt ISASCII 3 % .Os % .Sh NAME % @@ -47,6 +47,15 @@ % .Tn ASCII % character, which is any character % between 0 and octal 0177 inclusive. % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn isascii % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. % .Sh SEE ALSO % .Xr ctype 3 , % .Xr iswascii 3 , This is wrong -- see above. POSIX specifically says that "The isascii() function is defined on all integer values". Please check POSIX for any other special cases -- I only remembered this one and passed most of your other changes since most of the functions are in C99. % Index: lib/libc/locale/toascii.3 % =================================================================== % --- lib/libc/locale/toascii.3 (revision 196695) % +++ lib/libc/locale/toascii.3 (working copy) % @@ -28,7 +28,7 @@ % .\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 % .\" $FreeBSD$ % .\" % -.Dd June 4, 1993 % +.Dd September 3, 2009 % .Dt TOASCII 3 % .Os % .Sh NAME % @@ -45,6 +45,15 @@ % .Fn toascii % function strips all but the low 7 bits from a letter, % including parity or other marker bits. % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn toascii % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. % .Sh RETURN VALUES % The % .Fn toascii This seems wrong too. POSIX doesn't say anything specific for it (neither the restriction nor lack of it). It just says that the result is and 0x7f where the above says "strips all but the low 7 bits from a letter". Another old bug is the above saying "letter" -- toascii() always worked on at least ASCII non-letters. % Index: lib/libc/locale/toupper.3 % =================================================================== % --- lib/libc/locale/toupper.3 (revision 196695) % +++ lib/libc/locale/toupper.3 (working copy) % @@ -32,7 +32,7 @@ % .\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 % .\" $FreeBSD$ % .\" % -.Dd July 17, 2005 % +.Dd September 3, 2009 % .Dt TOUPPER 3 % .Os % .Sh NAME % @@ -53,6 +53,15 @@ % .Vt "unsigned char" % or the value of % .Dv EOF . % +.Pp % +.Em NOTE : % +if the value passed to the % +.Fn toupper % +function is a % +.Vt signed char , % +as is usually the case, it must be cast to an % +.Vt unsigned char % +to avoid sign-extension errors. % .Sh RETURN VALUES % If the argument is a lower-case letter, the % .Fn toupper toupper.2 already says that "the value of the argument is representable as an unsigned char or the value EOF" (it should say "the argument is representable as an unsigned char or equal to the value of EOF"). The new text, if any, should be mixed with this. Presumably similarly for tolower (I didn't noticed these problems earlier). Bruce From bms at incunabulum.net Fri Sep 4 04:44:56 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Fri Sep 4 04:45:03 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: <200909032110.n83LAvUF044731@svn.freebsd.org> References: <200909032110.n83LAvUF044731@svn.freebsd.org> Message-ID: <4AA09B41.3040103@incunabulum.net> George V. Neville-Neil wrote: > Author: gnn > Date: Thu Sep 3 21:10:57 2009 > New Revision: 196797 > URL: http://svn.freebsd.org/changeset/base/196797 > > Log: > Add ARP statistics to the kernel and netstat. > Thanks very much for this change. Any chance this struct can get explicitly versioned (i.e. as for struct igmpstat) as it is a new struct? cheers, BMS From ache at nagual.pp.ru Fri Sep 4 05:16:33 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Fri Sep 4 05:16:41 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090904115255.Q48987@delplex.bde.org> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> <20090904115255.Q48987@delplex.bde.org> Message-ID: <20090904051629.GA88503@nagual.pp.ru> On Fri, Sep 04, 2009 at 01:42:04PM +1000, Bruce Evans wrote: > The patch is missing the corresponding text for wctype functions > (argmuments of type wint_t generally give undefined behaviour unless > their value is representable as a wchar_t or equal to the value of > WEOF). In FreeBSD, wint_t has the same type as wchar_t and that type > is int, so bugs in this area are latent (unportable code might run > on FreeBSD, and there might be problems with the sign bit and/or with > WEOF being indistinguishable from a valid wide char encoding. Yes, having the same note for wctype family will be nice too. > It should be something like "if the value to be > passed is represented as a signed char" ... I don't know a good easy > way to fix "must be cast ... to avoid sign-extension errors". The > value must be converted to one representable as an unsigned char to > work, but that is not always possible, and blindly casting may give > a wrong value. > Exotic machines include: I think, "exotic machines" examples you mention already brokes too many other aspects regarding to char manipulating, so nobody will really make such machines with standard-compliance C compiler on them :) > Sign extension for passing a signed char is not an error. The error is > passing a negative value. Yes. Perhaps 'Never pass negative arg there, including sign-extended char' or something alike. > Neither C99 nor POSIX gives any advice. They just say that the behaviour > is undefined if the value is not representable as an unsigned char or > equal to the value of EOF. Yes, I already mention that. > % Index: lib/libc/locale/isrune.3 > % Index: lib/libc/locale/digittoint.3 > % Index: lib/libc/locale/isascii.3 > % Index: lib/libc/locale/toascii.3 Yes, those ones works with int. I don't pay attention to them in the whole patch :( About other wording nuances mentioned in your reply, I don't have an opinion, everybody knows my English is poor :) -- http://ache.pp.ru/ From brde at optusnet.com.au Fri Sep 4 05:21:21 2009 From: brde at optusnet.com.au (Bruce Evans) Date: Fri Sep 4 05:21:33 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090904115255.Q48987@delplex.bde.org> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> <20090904115255.Q48987@delplex.bde.org> Message-ID: <20090904144214.O49099@delplex.bde.org> On Fri, 4 Sep 2009, Bruce Evans wrote: > On Thu, 3 Sep 2009, [utf-8] Dag-Erling Smørgrav wrote: > >> What do you think of the attached patch? Oops, it is more broken than I noticed. Almost all ctype man pages already documented the requirements in even more detail than POSIX, since Andrey fixed the missing documentation to almost catch up with C99 and POSIX in Y2K, and tjr added more details on 6 Oct 2002. E.g., in isalpha.3: % The value of the argument must be representable as an % .Vt "unsigned char" % or the value of % .Dv EOF . This is the same as in POSIX except the POSIX wording is better (e.g., the above only says implicitly that the behaviour is undefined if "must" is not satisfied). It took too many commits (revs 1.8-1.10) to get this far. % ... % .Sh COMPATIBILITY % The % .Bx 4.4 % extension of accepting arguments outside of the range of the % .Vt "unsigned char" % type in locales with large character sets is considered obsolete % and may not be supported in future releases. % The % .Fn iswalpha % function should be used instead. This was added in rev.1.16. It also has bugs from not being merged with the old documentation about this problem -- it contradicts the "must", yet still doesn't say what the behaviour is for args outside the range: - are they classified as non-alpha, or are characters with (positive) values outside the range actually possible in some locales, with these characters being classified as alpha by this function and handled correctly by all ctype functions - we now have future releases, and the above says that these releases are not permitted to support this behaviour, so why do we still have it ;-) - what happens for the corresponding problem with iswalpha -- will the FreeBSD extension of not having these problems ever be documented or not permitted or actually go away? > % Index: lib/libc/locale/iscntrl.3 > % =================================================================== > % --- lib/libc/locale/iscntrl.3 (revision 196695) > % +++ lib/libc/locale/iscntrl.3 (working copy) > % @@ -32,7 +32,7 @@ > % .\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 > % .\" $FreeBSD$ > % .\" > % -.Dd July 17, 2005 > % +.Dd September 3, 2009 > % .Dt ISCNTRL 3 > % .Os > % .Sh NAME > % @@ -65,6 +65,15 @@ > % .It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS" > % .It "\&036\ RS \t037\ US \t177\ DEL" > % .El > % +.Pp > % +.Em NOTE : > % +if the value passed to the > % +.Fn iscntrl > % +function is a > % +.Vt signed char , > % +as is usually the case, it must be cast to an > % +.Vt unsigned char > % +to avoid sign-extension errors. > > This wording is poor. It should be something like "if the value to be > passed is represented as a signed char" ... I don't know a good easy > way to fix "must be cast ... to avoid sign-extension errors". The "value to be passed" is wrong too, since the problematic negative values must not be passed. Anyway, teaching how to apply casts to satisfy the requirements of the API should be duplicated ad nauseum in man pages even less than the requirements of the API. Bruce From weongyo at FreeBSD.org Fri Sep 4 05:28:10 2009 From: weongyo at FreeBSD.org (Weongyo Jeong) Date: Fri Sep 4 05:28:22 2009 Subject: svn commit: r196809 - head/sys/dev/usb/wlan Message-ID: <200909040528.n845SAna054988@svn.freebsd.org> Author: weongyo Date: Fri Sep 4 05:28:09 2009 New Revision: 196809 URL: http://svn.freebsd.org/changeset/base/196809 Log: fix a TX issue on big endian machines like powerpc or sparc64. Now zyd(4) should work on all architectures. Obtained from: OpenBSD Modified: head/sys/dev/usb/wlan/if_zyd.c Modified: head/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- head/sys/dev/usb/wlan/if_zyd.c Fri Sep 4 05:06:15 2009 (r196808) +++ head/sys/dev/usb/wlan/if_zyd.c Fri Sep 4 05:28:09 2009 (r196809) @@ -2547,7 +2547,7 @@ zyd_tx_start(struct zyd_softc *sc, struc bits = (rate == 11) ? (totlen * 16) + 10 : ((rate == 22) ? (totlen * 8) + 10 : (totlen * 8)); - desc->plcp_length = bits / ratediv[phy]; + desc->plcp_length = htole16(bits / ratediv[phy]); desc->plcp_service = 0; if (rate == 22 && (bits % 11) > 0 && (bits % 11) <= 3) desc->plcp_service |= ZYD_PLCP_LENGEXT; From julian at FreeBSD.org Fri Sep 4 05:40:07 2009 From: julian at FreeBSD.org (Julian Elischer) Date: Fri Sep 4 05:40:13 2009 Subject: svn commit: r196811 - head/sys/i386/include Message-ID: <200909040540.n845e6nQ055325@svn.freebsd.org> Author: julian Date: Fri Sep 4 05:40:06 2009 New Revision: 196811 URL: http://svn.freebsd.org/changeset/base/196811 Log: Bring i386 up to date with amd64 and others. The macros for PCPU can be slightly simplified, which makes the resulting tangle qa lot easier to understand when trying to read them. MFC after: 4 weeks Modified: head/sys/i386/include/pcpu.h Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Fri Sep 4 05:37:49 2009 (r196810) +++ head/sys/i386/include/pcpu.h Fri Sep 4 05:40:06 2009 (r196811) @@ -152,7 +152,7 @@ extern struct pcpu *pcpup; #define __PCPU_GET(name) __extension__ ({ \ __pcpu_type(name) __res; \ struct __s { \ - u_char __b[MIN(sizeof(__pcpu_type(name)), 4)]; \ + u_char __b[MIN(sizeof(__res), 4)]; \ } __s; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ @@ -174,7 +174,7 @@ extern struct pcpu *pcpup; #define __PCPU_ADD(name, val) do { \ __pcpu_type(name) __val; \ struct __s { \ - u_char __b[MIN(sizeof(__pcpu_type(name)), 4)]; \ + u_char __b[MIN(sizeof(__val), 4)]; \ } __s; \ \ __val = (val); \ @@ -214,10 +214,10 @@ extern struct pcpu *pcpup; /* * Sets the value of the per-cpu variable name to value val. */ -#define __PCPU_SET(name, val) { \ +#define __PCPU_SET(name, val) do { \ __pcpu_type(name) __val; \ struct __s { \ - u_char __b[MIN(sizeof(__pcpu_type(name)), 4)]; \ + u_char __b[MIN(sizeof(__val), 4)]; \ } __s; \ \ __val = (val); \ @@ -230,7 +230,7 @@ extern struct pcpu *pcpup; } else { \ *__PCPU_PTR(name) = __val; \ } \ -} +} while (0) #define PCPU_GET(member) __PCPU_GET(pc_ ## member) #define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) From ache at FreeBSD.org Fri Sep 4 05:54:45 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Fri Sep 4 05:54:52 2009 Subject: svn commit: r196812 - head/share/monetdef Message-ID: <200909040554.n845sjlO055648@svn.freebsd.org> Author: ache Date: Fri Sep 4 05:54:45 2009 New Revision: 196812 URL: http://svn.freebsd.org/changeset/base/196812 Log: Add lv_LV PR: 105100 Submitted by: Aldis Berjoza Added: head/share/monetdef/lv_LV.ISO8859-13.src (contents, props changed) Modified: head/share/monetdef/Makefile Modified: head/share/monetdef/Makefile ============================================================================== --- head/share/monetdef/Makefile Fri Sep 4 05:40:06 2009 (r196811) +++ head/share/monetdef/Makefile Fri Sep 4 05:54:45 2009 (r196812) @@ -44,6 +44,7 @@ LOCALES= af_ZA.ISO8859-1 \ ko_KR.eucKR \ ko_KR.UTF-8 \ lt_LT.ISO8859-13 \ + lv_LV.ISO8859-13 \ mn_MN.UTF-8 \ nl_BE.ISO8859-1 \ nl_NL.ISO8859-1 \ @@ -117,7 +118,7 @@ ISO8859-2_UTF-8= hr_HR hu_HU ro_RO sk_SK ISO8859-7_UTF-8= el_GR ISO8859-9_UTF-8= tr_TR ISO8859-13_ISO8859-4= lt_LT -ISO8859-13_UTF-8= lt_LT +ISO8859-13_UTF-8= lt_LT lv_LV ISO8859-15_ISO8859-15= es_ES:eu_ES ISO8859-15_UTF-8= et_EE UTF-8_Big5HKSCS= zh_HK Added: head/share/monetdef/lv_LV.ISO8859-13.src ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/monetdef/lv_LV.ISO8859-13.src Fri Sep 4 05:54:45 2009 (r196812) @@ -0,0 +1,36 @@ +# $FreeBSD$ +# +# WARNING: spaces may be essential at the end of lines +# WARNING: empty lines are essential too +# +# int_curr_symbol (last character always SPACE) +LVL +# currency_symbol +Ls +# mon_decimal_point +, +# mon_thousands_sep + +# mon_grouping, separated by ; +3;3 +# positive_sign + +# negative_sign +- +# int_frac_digits +2 +# frac_digits +2 +# p_cs_precedes +0 +# p_sep_by_space +1 +# n_cs_precedes +0 +# n_sep_by_space +1 +# p_sign_posn +1 +# n_sign_posn +1 +# EOF From ache at FreeBSD.org Fri Sep 4 06:19:38 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Fri Sep 4 06:19:50 2009 Subject: svn commit: r196813 - head/share/msgdef Message-ID: <200909040619.n846Jbg8056322@svn.freebsd.org> Author: ache Date: Fri Sep 4 06:19:37 2009 New Revision: 196813 URL: http://svn.freebsd.org/changeset/base/196813 Log: Add lv_LV PR: 105100 Submitted by: Aldis Berjoza Added: head/share/msgdef/lv_LV.ISO8859-13.src (contents, props changed) head/share/msgdef/lv_LV.UTF-8.src (contents, props changed) Modified: head/share/msgdef/Makefile Modified: head/share/msgdef/Makefile ============================================================================== --- head/share/msgdef/Makefile Fri Sep 4 05:54:45 2009 (r196812) +++ head/share/msgdef/Makefile Fri Sep 4 06:19:37 2009 (r196813) @@ -40,6 +40,8 @@ LOCALES= af_ZA.ISO8859-1 \ ko_KR.UTF-8 \ ko_KR.eucKR \ lt_LT.ISO8859-13 \ + lv_LV.ISO8859-13 \ + lv_LV.UTF-8 \ mn_MN.UTF-8 \ nl_NL.ISO8859-1 \ no_NO.ISO8859-1 \ Added: head/share/msgdef/lv_LV.ISO8859-13.src ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/msgdef/lv_LV.ISO8859-13.src Fri Sep 4 06:19:37 2009 (r196813) @@ -0,0 +1,14 @@ +# $FreeBSD$ +# +# WARNING: spaces may be essential at the end of lines +# WARNING: empty lines are essential too +# +# yesexpr +^[jJyY].* +# noexpr +^[nN].* +# yesstr +jâ +# nostr +nç +# EOF Added: head/share/msgdef/lv_LV.UTF-8.src ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/msgdef/lv_LV.UTF-8.src Fri Sep 4 06:19:37 2009 (r196813) @@ -0,0 +1,14 @@ +# $FreeBSD$ +# +# WARNING: spaces may be essential at the end of lines +# WARNING: empty lines are essential too +# +# yesexpr +^[jJyY].* +# noexpr +^[nN].* +# yesstr +jÄ +# nostr +nÄ“ +# EOF From ache at FreeBSD.org Fri Sep 4 06:26:42 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Fri Sep 4 06:26:56 2009 Subject: svn commit: r196814 - head/share/timedef Message-ID: <200909040626.n846QfIo056506@svn.freebsd.org> Author: ache Date: Fri Sep 4 06:26:40 2009 New Revision: 196814 URL: http://svn.freebsd.org/changeset/base/196814 Log: Add lv_LV PR: 105100 Submitted by: Aldis Berjoza Added: head/share/timedef/lv_LV.ISO8859-13.src (contents, props changed) head/share/timedef/lv_LV.UTF-8.src (contents, props changed) Modified: head/share/timedef/Makefile Modified: head/share/timedef/Makefile ============================================================================== --- head/share/timedef/Makefile Fri Sep 4 06:19:37 2009 (r196813) +++ head/share/timedef/Makefile Fri Sep 4 06:26:40 2009 (r196814) @@ -53,6 +53,8 @@ LOCALES= am_ET.UTF-8 \ lt_LT.ISO8859-4 \ lt_LT.ISO8859-13 \ lt_LT.UTF-8 \ + lv_LV.ISO8859-13 \ + lv_LV.UTF-8 \ mn_MN.UTF-8 \ nb_NO.ISO8859-1 \ nb_NO.UTF-8 \ Added: head/share/timedef/lv_LV.ISO8859-13.src ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/timedef/lv_LV.ISO8859-13.src Fri Sep 4 06:26:40 2009 (r196814) @@ -0,0 +1,101 @@ +# $FreeBSD$ +# WARNING: spaces may be essential at the end of lines +# WARNING: empty lines are essential too +# +# Short month names +# +Jan +Feb +Mar +Apr +Mai +Jûn +Jûl +Aug +Sep +Okt +Nov +Dec +# +# Long month names +# +janvâris +februâris +marts +aprîlis +maijs +jûnijs +jûlijs +augusts +septembris +oktobris +novembris +decembris +# +# Short weekday names +# +Sv +Pr +Ot +Tr +Ct +Pk +Ss +# +# Long weekday names +# +Svçtdiena +Pirmdiena +Otrdiena +Treðdiena +Ceturtdiena +Piektdiena +Sestdiena +# +# X_fmt +# +%H:%M:%S +# +# x_fmt +# +%d/%m/%Y +# +# c_fmt +# %A, %Y m. %B %e d. %T +%e. %b, %Y. gads %X +# +# am +# + +# +# pm +# + +# +# date_fmt +# +%A, %Y. gada %e. %B %T %Z +# +# Long month names in alternative form +# +janvâris +februâris +marts +aprîlis +maijs +jûnijs +jûlijs +augusts +septembris +oktobris +novembris +decembris +# +# md_order +# +md +# +# ampm_fmt +# + +# EOF Added: head/share/timedef/lv_LV.UTF-8.src ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/timedef/lv_LV.UTF-8.src Fri Sep 4 06:26:40 2009 (r196814) @@ -0,0 +1,101 @@ +# $FreeBSD$ +# WARNING: spaces may be essential at the end of lines +# WARNING: empty lines are essential too +# +# Short month names +# +Jan +Feb +Mar +Apr +Mai +JÅ«n +JÅ«l +Aug +Sep +Okt +Nov +Dec +# +# Long month names +# +janvÄris +februÄris +marts +aprÄ«lis +maijs +jÅ«nijs +jÅ«lijs +augusts +septembris +oktobris +novembris +decembris +# +# Short weekday names +# +Sv +Pr +Ot +Tr +Ct +Pk +Ss +# +# Long weekday names +# +SvÄ“tdiena +Pirmdiena +Otrdiena +TreÅ¡diena +Ceturtdiena +Piektdiena +Sestdiena +# +# X_fmt +# +%H:%M:%S +# +# x_fmt +# +%d/%m/%Y +# +# c_fmt +# %A, %Y m. %B %e d. %T +%e. %b, %Y. gads %X +# +# am +# + +# +# pm +# + +# +# date_fmt +# +%A, %Y. gada %e. %B %T %Z +# +# Long month names in alternative form +# +janvÄris +februÄris +marts +aprÄ«lis +maijs +jÅ«nijs +jÅ«lijs +augusts +septembris +oktobris +novembris +decembris +# +# md_order +# +md +# +# ampm_fmt +# + +# EOF From julian at FreeBSD.org Fri Sep 4 07:29:25 2009 From: julian at FreeBSD.org (Julian Elischer) Date: Fri Sep 4 07:29:30 2009 Subject: svn commit: r196816 - head/sys/i386/include Message-ID: <200909040729.n847TPxD057926@svn.freebsd.org> Author: julian Date: Fri Sep 4 07:29:24 2009 New Revision: 196816 URL: http://svn.freebsd.org/changeset/base/196816 Log: whitespace commit Submitted by: bde@ Modified: head/sys/i386/include/pcpu.h Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Fri Sep 4 07:13:07 2009 (r196815) +++ head/sys/i386/include/pcpu.h Fri Sep 4 07:29:24 2009 (r196816) @@ -152,7 +152,7 @@ extern struct pcpu *pcpup; #define __PCPU_GET(name) __extension__ ({ \ __pcpu_type(name) __res; \ struct __s { \ - u_char __b[MIN(sizeof(__res), 4)]; \ + u_char __b[MIN(sizeof(__res), 4)]; \ } __s; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ @@ -174,7 +174,7 @@ extern struct pcpu *pcpup; #define __PCPU_ADD(name, val) do { \ __pcpu_type(name) __val; \ struct __s { \ - u_char __b[MIN(sizeof(__val), 4)]; \ + u_char __b[MIN(sizeof(__val), 4)]; \ } __s; \ \ __val = (val); \ From ache at FreeBSD.org Fri Sep 4 07:42:14 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Fri Sep 4 07:42:26 2009 Subject: svn commit: r196818 - head/contrib/ee Message-ID: <200909040742.n847gD62058267@svn.freebsd.org> Author: ache Date: Fri Sep 4 07:42:13 2009 New Revision: 196818 URL: http://svn.freebsd.org/changeset/base/196818 Log: 1) Remove single occurance of HAS_CTYPE ifdef, ctype functions used here for a long time and needs their header in anycase. 2) Add (unsigned char) casts to more ctype macros. 3) Simplify menu input handling using ctype instead of range unguarded hardcoded tricks. Modified: head/contrib/ee/ee.c Modified: head/contrib/ee/ee.c ============================================================================== --- head/contrib/ee/ee.c Fri Sep 4 07:33:17 2009 (r196817) +++ head/contrib/ee/ee.c Fri Sep 4 07:42:13 2009 (r196818) @@ -72,10 +72,7 @@ char *version = "@(#) ee, version " EE_ #include #endif -#ifdef HAS_CTYPE #include -#endif - #include #include #include @@ -1973,7 +1970,7 @@ int sensitive; } else { - if (toupper(*strng1) != toupper(*strng2)) + if (toupper((unsigned char)*strng1) != toupper((unsigned char)*strng2)) equal = FALSE; } strng1++; @@ -2445,7 +2442,7 @@ int noverify; if ((text_changes) && (!noverify)) { ans = get_string(changes_made_prompt, TRUE); - if (toupper(*ans) == toupper(*yes_char)) + if (toupper((unsigned char)*ans) == toupper((unsigned char)*yes_char)) text_changes = FALSE; else return(0); @@ -2522,7 +2519,7 @@ int warn_if_exists; if ((temp_fp = fopen(file_name, "r"))) { tmp_point = get_string(file_exists_prompt, TRUE); - if (toupper(*tmp_point) == toupper(*yes_char)) + if (toupper((unsigned char)*tmp_point) == toupper((unsigned char)*yes_char)) write_flag = TRUE; else write_flag = FALSE; @@ -3437,14 +3434,13 @@ struct menu_entries menu_list[]; if (input == -1) exit(0); - if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) || - ((input >= '0') && (input <= '9'))) + if (isascii(input) && isalnum(input)) { - if ((tolower(input) >= 'a') && (tolower(input) <= 'z')) + if (isalpha(input)) { temp = 1 + tolower(input) - 'a'; } - else if ((input >= '0') && (input <= '9')) + else if (isdigit(input)) { temp = (2 + 'z' - 'a') + (input - '0'); } From ache at FreeBSD.org Fri Sep 4 07:44:28 2009 From: ache at FreeBSD.org (Andrey A. Chernov) Date: Fri Sep 4 07:44:40 2009 Subject: svn commit: r196819 - head/usr.bin/ee Message-ID: <200909040744.n847iSMU058380@svn.freebsd.org> Author: ache Date: Fri Sep 4 07:44:27 2009 New Revision: 196819 URL: http://svn.freebsd.org/changeset/base/196819 Log: Remove single occurance of HAS_CTYPE ifdef, ctype functions used here for a long time and needs their header in anycase. Modified: head/usr.bin/ee/Makefile Modified: head/usr.bin/ee/Makefile ============================================================================== --- head/usr.bin/ee/Makefile Fri Sep 4 07:42:13 2009 (r196818) +++ head/usr.bin/ee/Makefile Fri Sep 4 07:44:27 2009 (r196819) @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../contrib/ee CFLAGS+= -DHAS_NCURSES -DHAS_UNISTD -DHAS_STDARG -DHAS_STDLIB \ - -DHAS_CTYPE -DHAS_SYS_WAIT + -DHAS_SYS_WAIT PROG= ee LINKS= ${BINDIR}/ee ${BINDIR}/ree ${BINDIR}/ee ${BINDIR}/edit From des at FreeBSD.org Fri Sep 4 07:44:58 2009 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Fri Sep 4 07:45:11 2009 Subject: svn commit: r196820 - head/lib/libc/locale Message-ID: <200909040744.n847iwFs058425@svn.freebsd.org> Author: des Date: Fri Sep 4 07:44:58 2009 New Revision: 196820 URL: http://svn.freebsd.org/changeset/base/196820 Log: Let the armchair generals handle this one. Modified: head/lib/libc/locale/ctype.3 head/lib/libc/locale/digittoint.3 head/lib/libc/locale/isalnum.3 head/lib/libc/locale/isalpha.3 head/lib/libc/locale/isascii.3 head/lib/libc/locale/isblank.3 head/lib/libc/locale/iscntrl.3 head/lib/libc/locale/isdigit.3 head/lib/libc/locale/isgraph.3 head/lib/libc/locale/isideogram.3 head/lib/libc/locale/islower.3 head/lib/libc/locale/isphonogram.3 head/lib/libc/locale/isprint.3 head/lib/libc/locale/ispunct.3 head/lib/libc/locale/isrune.3 head/lib/libc/locale/isspace.3 head/lib/libc/locale/isspecial.3 head/lib/libc/locale/isupper.3 head/lib/libc/locale/isxdigit.3 head/lib/libc/locale/toascii.3 head/lib/libc/locale/tolower.3 head/lib/libc/locale/toupper.3 Modified: head/lib/libc/locale/ctype.3 ============================================================================== --- head/lib/libc/locale/ctype.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/ctype.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -28,7 +28,7 @@ .\" @(#)ctype.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd March 30, 2004 .Dt CTYPE 3 .Os .Sh NAME @@ -111,13 +111,6 @@ They are available as macros, defined in .In ctype.h , or as true functions in the C library. See the specific manual pages for more information. -.Pp -.Em NOTE : -if the value passed to one of these functions is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh SEE ALSO .Xr digittoint 3 , .Xr isalnum 3 , Modified: head/lib/libc/locale/digittoint.3 ============================================================================== --- head/lib/libc/locale/digittoint.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/digittoint.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -28,7 +28,7 @@ .\" @(#)digittoint.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd April 6, 2001 .Dt DIGITTOINT 3 .Os .Sh NAME @@ -46,15 +46,6 @@ The function converts a numeric character to its corresponding integer value. The character can be any decimal digit or hexadecimal digit. With hexadecimal characters, the case of the values does not matter. -.Pp -.Em NOTE : -if the value passed to the -.Fn digittoint -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn digittoint Modified: head/lib/libc/locale/isalnum.3 ============================================================================== --- head/lib/libc/locale/isalnum.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isalnum.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISALNUM 3 .Os .Sh NAME @@ -75,15 +75,6 @@ In the ASCII character set, this include .It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" .It "\&171\ ``y'' \t172\ ``z''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn isalnum -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isalnum Modified: head/lib/libc/locale/isalpha.3 ============================================================================== --- head/lib/libc/locale/isalpha.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isalpha.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISALPHA 3 .Os .Sh NAME @@ -73,15 +73,6 @@ In the ASCII character set, this include .It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" .It "\&171\ ``y'' \t172\ ``z''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn isalpha -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isalpha Modified: head/lib/libc/locale/isascii.3 ============================================================================== --- head/lib/libc/locale/isascii.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isascii.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -28,7 +28,7 @@ .\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd October 6, 2002 .Dt ISASCII 3 .Os .Sh NAME @@ -47,15 +47,6 @@ function tests for an .Tn ASCII character, which is any character between 0 and octal 0177 inclusive. -.Pp -.Em NOTE : -if the value passed to the -.Fn isascii -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh SEE ALSO .Xr ctype 3 , .Xr iswascii 3 , Modified: head/lib/libc/locale/isblank.3 ============================================================================== --- head/lib/libc/locale/isblank.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isblank.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -28,7 +28,7 @@ .\" @(#)isblank.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISBLANK 3 .Os .Sh NAME @@ -57,15 +57,6 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn isblank -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isblank Modified: head/lib/libc/locale/iscntrl.3 ============================================================================== --- head/lib/libc/locale/iscntrl.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/iscntrl.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISCNTRL 3 .Os .Sh NAME @@ -65,15 +65,6 @@ In the ASCII character set, this include .It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS" .It "\&036\ RS \t037\ US \t177\ DEL" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn iscntrl -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn iscntrl Modified: head/lib/libc/locale/isdigit.3 ============================================================================== --- head/lib/libc/locale/isdigit.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isdigit.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd May 4, 2007 .Dt ISDIGIT 3 .Os .Sh NAME @@ -68,15 +68,6 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn isdigit -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isdigit Modified: head/lib/libc/locale/isgraph.3 ============================================================================== --- head/lib/libc/locale/isgraph.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isgraph.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISGRAPH 3 .Os .Sh NAME @@ -80,15 +80,6 @@ In the ASCII character set, this include .It "\&166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' \t172\ ``z''" .It "\&173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn isgraph -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isgraph Modified: head/lib/libc/locale/isideogram.3 ============================================================================== --- head/lib/libc/locale/isideogram.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isideogram.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd March 30, 2004 .Dt ISIDEOGRAM 3 .Os .Sh NAME @@ -41,15 +41,6 @@ The .Fn isideogram function tests for an ideographic character. -.Pp -.Em NOTE : -if the value passed to the -.Fn isideogram -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isideogram Modified: head/lib/libc/locale/islower.3 ============================================================================== --- head/lib/libc/locale/islower.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/islower.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)islower.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISLOWER 3 .Os .Sh NAME @@ -64,15 +64,6 @@ In the ASCII character set, this include .It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" .It "\&172\ ``z''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn islower -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn islower Modified: head/lib/libc/locale/isphonogram.3 ============================================================================== --- head/lib/libc/locale/isphonogram.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isphonogram.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd March 30, 2004 .Dt ISPHONOGRAM 3 .Os .Sh NAME @@ -41,15 +41,6 @@ The .Fn isphonogram function tests for a phonographic character. -.Pp -.Em NOTE : -if the value passed to the -.Fn isphonogram -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isphonogram Modified: head/lib/libc/locale/isprint.3 ============================================================================== --- head/lib/libc/locale/isprint.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isprint.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isprint.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISPRINT 3 .Os .Sh NAME @@ -78,15 +78,6 @@ In the ASCII character set, this include .It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" .It "\&172\ ``z'' \t173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn isprint -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isprint Modified: head/lib/libc/locale/ispunct.3 ============================================================================== --- head/lib/libc/locale/ispunct.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/ispunct.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISPUNCT 3 .Os .Sh NAME @@ -70,15 +70,6 @@ In the ASCII character set, this include .It "\&136\ ``^'' \t137\ ``_'' \t140\ ```'' \t173\ ``{'' \t174\ ``|''" .It "\&175\ ``}'' \t176\ ``~''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn ispunct -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn ispunct Modified: head/lib/libc/locale/isrune.3 ============================================================================== --- head/lib/libc/locale/isrune.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isrune.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd March 30, 2004 .Dt ISRUNE 3 .Os .Sh NAME @@ -46,15 +46,6 @@ In the .Tn ASCII character set, this is equivalent to .Fn isascii . -.Pp -.Em NOTE : -if the value passed to the -.Fn isrune -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isrune Modified: head/lib/libc/locale/isspace.3 ============================================================================== --- head/lib/libc/locale/isspace.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isspace.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISSPACE 3 .Os .Sh NAME @@ -61,15 +61,6 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn isspace -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isspace Modified: head/lib/libc/locale/isspecial.3 ============================================================================== --- head/lib/libc/locale/isspecial.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isspecial.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd March 30, 2004 .Dt ISSPECIAL 3 .Os .Sh NAME @@ -41,15 +41,6 @@ The .Fn isspecial function tests for a special character. -.Pp -.Em NOTE : -if the value passed to the -.Fn isspecial -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isspecial Modified: head/lib/libc/locale/isupper.3 ============================================================================== --- head/lib/libc/locale/isupper.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isupper.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isupper.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISUPPER 3 .Os .Sh NAME @@ -64,15 +64,6 @@ In the ASCII character set, this include .It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''" .It "\&132\ ``Z''" .El -.Pp -.Em NOTE : -if the value passed to the -.Fn isupper -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isupper Modified: head/lib/libc/locale/isxdigit.3 ============================================================================== --- head/lib/libc/locale/isxdigit.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/isxdigit.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt ISXDIGIT 3 .Os .Sh NAME @@ -71,15 +71,6 @@ The value of the argument must be repres .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn isxdigit -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn isxdigit Modified: head/lib/libc/locale/toascii.3 ============================================================================== --- head/lib/libc/locale/toascii.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/toascii.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -28,7 +28,7 @@ .\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd June 4, 1993 .Dt TOASCII 3 .Os .Sh NAME @@ -45,15 +45,6 @@ The .Fn toascii function strips all but the low 7 bits from a letter, including parity or other marker bits. -.Pp -.Em NOTE : -if the value passed to the -.Fn toascii -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES The .Fn toascii Modified: head/lib/libc/locale/tolower.3 ============================================================================== --- head/lib/libc/locale/tolower.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/tolower.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt TOLOWER 3 .Os .Sh NAME @@ -53,15 +53,6 @@ The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn tolower -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES If the argument is an upper-case letter, the .Fn tolower Modified: head/lib/libc/locale/toupper.3 ============================================================================== --- head/lib/libc/locale/toupper.3 Fri Sep 4 07:44:27 2009 (r196819) +++ head/lib/libc/locale/toupper.3 Fri Sep 4 07:44:58 2009 (r196820) @@ -32,7 +32,7 @@ .\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 3, 2009 +.Dd July 17, 2005 .Dt TOUPPER 3 .Os .Sh NAME @@ -53,15 +53,6 @@ The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . -.Pp -.Em NOTE : -if the value passed to the -.Fn toupper -function is a -.Vt signed char , -as is usually the case, it must be cast to an -.Vt unsigned char -to avoid sign-extension errors. .Sh RETURN VALUES If the argument is a lower-case letter, the .Fn toupper From ache at nagual.pp.ru Fri Sep 4 07:53:46 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Fri Sep 4 07:53:52 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090904144214.O49099@delplex.bde.org> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> <20090904115255.Q48987@delplex.bde.org> <20090904144214.O49099@delplex.bde.org> Message-ID: <20090904075338.GA90644@nagual.pp.ru> On Fri, Sep 04, 2009 at 03:21:09PM +1000, Bruce Evans wrote: > % The value of the argument must be representable as an > % .Vt "unsigned char" > % or the value of > % .Dv EOF . > > This is the same as in POSIX except the POSIX wording is better (e.g., > the above only says implicitly that the behaviour is undefined if > "must" is not satisfied). It took too many commits (revs 1.8-1.10) to > get this far. BTW, do we have permissions for direct POSIX quotes? -- http://ache.pp.ru/ From simon at FreeBSD.org Fri Sep 4 08:59:08 2009 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Fri Sep 4 08:59:14 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090904075338.GA90644@nagual.pp.ru> References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> <20090904115255.Q48987@delplex.bde.org> <20090904144214.O49099@delplex.bde.org> <20090904075338.GA90644@nagual.pp.ru> Message-ID: <20090904085854.GA1311@zaphod.nitro.dk> On 2009.09.04 11:53:39 +0400, Andrey Chernov wrote: > On Fri, Sep 04, 2009 at 03:21:09PM +1000, Bruce Evans wrote: > > % The value of the argument must be representable as an > > % .Vt "unsigned char" > > % or the value of > > % .Dv EOF . > > > > This is the same as in POSIX except the POSIX wording is better (e.g., > > the above only says implicitly that the behaviour is undefined if > > "must" is not satisfied). It took too many commits (revs 1.8-1.10) to > > get this far. > > BTW, do we have permissions for direct POSIX quotes? Yes. I thought I had made a web page about it, but I can't find it now, but see this: http://lists.freebsd.org/pipermail/freebsd-doc/2005-January/006862.html We haven't used it much AFAIK, but there are a few manual pages which does make use of POSIX text. -- Simon L. Nielsen From pjd at FreeBSD.org Fri Sep 4 09:33:51 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Fri Sep 4 09:34:02 2009 Subject: svn commit: r196822 - head/sys/dev/ata Message-ID: <200909040933.n849Xoh3060664@svn.freebsd.org> Author: pjd Date: Fri Sep 4 09:33:50 2009 New Revision: 196822 URL: http://svn.freebsd.org/changeset/base/196822 Log: Remove 'ad:' prefix from disk serial number. We don't want serial number to change when we reconnect the disk in a way that it is accessible through CAM for example. Discussed with: trasz Modified: head/sys/dev/ata/ata-disk.c Modified: head/sys/dev/ata/ata-disk.c ============================================================================== --- head/sys/dev/ata/ata-disk.c Fri Sep 4 08:21:49 2009 (r196821) +++ head/sys/dev/ata/ata-disk.c Fri Sep 4 09:33:50 2009 (r196822) @@ -136,8 +136,8 @@ ad_attach(device_t dev) if ((atadev->param.support.command2 & ATA_SUPPORT_CFA) || atadev->param.config == ATA_PROTO_CFA) adp->disk->d_flags = DISKFLAG_CANDELETE; - snprintf(adp->disk->d_ident, sizeof(adp->disk->d_ident), "ad:%s", - atadev->param.serial); + strlcpy(adp->disk->d_ident, atadev->param.serial, + sizeof(adp->disk->d_ident)); disk_create(adp->disk, DISK_VERSION); device_add_child(dev, "subdisk", device_get_unit(dev)); ad_firmware_geom_adjust(dev, adp->disk); From pjd at FreeBSD.org Fri Sep 4 09:39:06 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Fri Sep 4 09:39:13 2009 Subject: svn commit: r196823 - head/sys/geom Message-ID: <200909040939.n849d63V060800@svn.freebsd.org> Author: pjd Date: Fri Sep 4 09:39:06 2009 New Revision: 196823 URL: http://svn.freebsd.org/changeset/base/196823 Log: Simplify g_disk_ident_adjust() function and allow any printable character in serial number. Discussed with: trasz Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl) Modified: head/sys/geom/geom_disk.c Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Fri Sep 4 09:33:50 2009 (r196822) +++ head/sys/geom/geom_disk.c Fri Sep 4 09:39:06 2009 (r196823) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -400,39 +401,25 @@ g_disk_destroy(void *ptr, int flag) } /* - * We only allow [a-zA-Z0-9-_@#%.:] characters, the rest is converted to 'x'. + * We only allow printable characters in disk ident, + * the rest is converted to 'x'. */ static void g_disk_ident_adjust(char *ident, size_t size) { - char newid[DISK_IDENT_SIZE], tmp[4]; - size_t len; - char *p; - - bzero(newid, sizeof(newid)); - len = 0; - for (p = ident; *p != '\0' && len < sizeof(newid) - 1; p++) { - switch (*p) { - default: - if ((*p < 'a' || *p > 'z') && - (*p < 'A' || *p > 'Z') && - (*p < '0' || *p > '9')) { - snprintf(tmp, sizeof(tmp), "x%02hhx", *p); - strlcat(newid, tmp, sizeof(newid)); - len += 3; - break; - } - /* FALLTHROUGH */ - case '-': - case '_': - case '@': - case '#': - case '%': - case '.': - case ':': - newid[len++] = *p; - break; + char *p, tmp[4], newid[DISK_IDENT_SIZE]; + + newid[0] = '\0'; + for (p = ident; *p != '\0'; p++) { + if (isprint(*p)) { + tmp[0] = *p; + tmp[1] = '\0'; + } else { + snprintf(tmp, sizeof(tmp), "x%02hhx", + *(unsigned char *)p); } + if (strlcat(newid, tmp, sizeof(newid)) >= sizeof(newid)) + break; } bzero(ident, size); strlcpy(ident, newid, size); From pjd at FreeBSD.org Fri Sep 4 09:41:00 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Fri Sep 4 09:41:11 2009 Subject: svn commit: r196824 - head/sys/cam/scsi Message-ID: <200909040940.n849exab060884@svn.freebsd.org> Author: pjd Date: Fri Sep 4 09:40:59 2009 New Revision: 196824 URL: http://svn.freebsd.org/changeset/base/196824 Log: Make serial numbers of daX disks visible by GEOM. No objections from: scottl Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl) Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Fri Sep 4 09:39:06 2009 (r196823) +++ head/sys/cam/scsi/scsi_da.c Fri Sep 4 09:40:59 2009 (r196824) @@ -1266,6 +1266,8 @@ daregister(struct cam_periph *periph, vo softc->disk->d_flags = 0; if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; + strlcpy(softc->disk->d_ident, cgd->serial_num, + MIN(sizeof(softc->disk->d_ident), cgd->serial_num_len + 1)); disk_create(softc->disk, DISK_VERSION); mtx_lock(periph->sim->mtx); From pjd at FreeBSD.org Fri Sep 4 09:48:19 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Fri Sep 4 09:48:34 2009 Subject: svn commit: r196825 - head/sys/opencrypto Message-ID: <200909040948.n849mI3Y061075@svn.freebsd.org> Author: pjd Date: Fri Sep 4 09:48:18 2009 New Revision: 196825 URL: http://svn.freebsd.org/changeset/base/196825 Log: If crypto operation is finished with EAGAIN, don't repeat operation from the return context, but from the original context. Before repeating operation clear DONE flag and error. Reviewed by: sam Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl) Modified: head/sys/opencrypto/cryptodev.c Modified: head/sys/opencrypto/cryptodev.c ============================================================================== --- head/sys/opencrypto/cryptodev.c Fri Sep 4 09:40:59 2009 (r196824) +++ head/sys/opencrypto/cryptodev.c Fri Sep 4 09:48:18 2009 (r196825) @@ -496,6 +496,7 @@ cryptodev_op( goto bail; } +again: /* * Let the dispatch run unlocked, then, interlock against the * callback before checking if the operation completed and going @@ -512,6 +513,12 @@ cryptodev_op( if (error != 0) goto bail; + if (crp->crp_etype == EAGAIN) { + crp->crp_etype = 0; + crp->crp_flags &= ~CRYPTO_F_DONE; + goto again; + } + if (crp->crp_etype != 0) { error = crp->crp_etype; goto bail; @@ -545,16 +552,10 @@ cryptodev_cb(void *op) { struct cryptop *crp = (struct cryptop *) op; struct csession *cse = (struct csession *)crp->crp_opaque; - int error; - error = crp->crp_etype; - if (error == EAGAIN) - error = crypto_dispatch(crp); mtx_lock(&cse->lock); - if (error != 0 || (crp->crp_flags & CRYPTO_F_DONE)) { - cse->error = error; - wakeup_one(crp); - } + cse->error = crp->crp_etype; + wakeup_one(crp); mtx_unlock(&cse->lock); return (0); } From trasz at FreeBSD.org Fri Sep 4 09:57:03 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Sep 4 09:57:10 2009 Subject: svn commit: r196826 - head/sys/dev/usb/storage Message-ID: <200909040957.n849v3MZ061284@svn.freebsd.org> Author: trasz Date: Fri Sep 4 09:57:03 2009 New Revision: 196826 URL: http://svn.freebsd.org/changeset/base/196826 Log: Make umass(4) pass device USB serial number to CAM, making it possible to e.g. retrieve it using camcontrol(8). Reviewed by: scottl, hps (earlier version) Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl) Modified: head/sys/dev/usb/storage/umass.c Modified: head/sys/dev/usb/storage/umass.c ============================================================================== --- head/sys/dev/usb/storage/umass.c Fri Sep 4 09:48:18 2009 (r196825) +++ head/sys/dev/usb/storage/umass.c Fri Sep 4 09:57:03 2009 (r196826) @@ -124,6 +124,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "usbdevs.h" #include @@ -2978,6 +2979,28 @@ umass_cam_action(struct cam_sim *sim, un if (sc->sc_transfer.cmd_data[0] == INQUIRY) { /* + * Umass devices don't generally report their serial numbers + * in the usual SCSI way. Emulate it here. + */ + if ((sc->sc_transfer.cmd_data[1] & SI_EVPD) && + sc->sc_transfer.cmd_data[2] == SVPD_UNIT_SERIAL_NUMBER && + sc->sc_udev != NULL && + sc->sc_udev->serial != NULL && + sc->sc_udev->serial[0] != '\0') { + struct scsi_vpd_unit_serial_number *vpd_serial; + + vpd_serial = (struct scsi_vpd_unit_serial_number *)ccb->csio.data_ptr; + vpd_serial->length = strlen(sc->sc_udev->serial); + if (vpd_serial->length > sizeof(vpd_serial->serial_num)) + vpd_serial->length = sizeof(vpd_serial->serial_num); + memcpy(vpd_serial->serial_num, sc->sc_udev->serial, vpd_serial->length); + ccb->csio.scsi_status = SCSI_STATUS_OK; + ccb->ccb_h.status = CAM_REQ_CMP; + xpt_done(ccb); + goto done; + } + + /* * Handle EVPD inquiry for broken devices first * NO_INQUIRY also implies NO_INQUIRY_EVPD */ @@ -3193,6 +3216,29 @@ umass_cam_cb(struct umass_softc *sc, uni maxsector = scsi_4btoul(rcap->addr) - 1; scsi_ulto4b(maxsector, rcap->addr); } + /* + * We have to add SVPD_UNIT_SERIAL_NUMBER to the list + * of pages supported by the device - otherwise, CAM + * will never ask us for the serial number if the + * device cannot handle that by itself. + */ + if (ccb->ccb_h.func_code == XPT_SCSI_IO && + sc->sc_transfer.cmd_data[0] == INQUIRY && + (sc->sc_transfer.cmd_data[1] & SI_EVPD) && + sc->sc_transfer.cmd_data[2] == SVPD_SUPPORTED_PAGE_LIST && + sc->sc_udev != NULL && + sc->sc_udev->serial != NULL && + sc->sc_udev->serial[0] != '\0') { + struct ccb_scsiio *csio; + struct scsi_vpd_supported_page_list *page_list; + + csio = &ccb->csio; + page_list = (struct scsi_vpd_supported_page_list *)csio->data_ptr; + if (page_list->length + 1 < SVPD_SUPPORTED_PAGES_SIZE) { + page_list->list[page_list->length] = SVPD_UNIT_SERIAL_NUMBER; + page_list->length++; + } + } xpt_done(ccb); break; From trasz at FreeBSD.org Fri Sep 4 10:22:29 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Sep 4 10:22:35 2009 Subject: svn commit: r196827 - head/bin/getfacl Message-ID: <200909041022.n84AMTJD061884@svn.freebsd.org> Author: trasz Date: Fri Sep 4 10:22:29 2009 New Revision: 196827 URL: http://svn.freebsd.org/changeset/base/196827 Log: Add NFSv4 ACL support to getfacl(1). Reviewed by: rwatson Modified: head/bin/getfacl/getfacl.1 head/bin/getfacl/getfacl.c Modified: head/bin/getfacl/getfacl.1 ============================================================================== --- head/bin/getfacl/getfacl.1 Fri Sep 4 09:57:03 2009 (r196826) +++ head/bin/getfacl/getfacl.1 Fri Sep 4 10:22:29 2009 (r196827) @@ -30,7 +30,7 @@ .\" Developed by the TrustedBSD Project. .\" Support for POSIX.1e access control lists. .\" -.Dd March 13, 2006 +.Dd September 04, 2009 .Dt GETFACL 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd get ACL information .Sh SYNOPSIS .Nm -.Op Fl dhq +.Op Fl dhinqv .Op Ar .Sh DESCRIPTION The @@ -61,13 +61,25 @@ The operation applies to the default ACL access ACL. An error is generated if a default ACL cannot be associated with .Ar file . +This option is not valid for NFSv4 ACLs. .It Fl h If the target of the operation is a symbolic link, return the ACL from the symbolic link itself rather than following the link. +.It Fl i +For NFSv4 ACLs, append numerical ID at the end of each entry containing +user or group name. +Ignored for POSIX.1e ACLs. +.It Fl n +Display user and group IDs numerically rather than converting to +a user or group name. +Ignored for POSIX.1e ACLs. .It Fl q Do not write commented information about file name and ownership. This is useful when dealing with filenames with unprintable characters. +.It Fl v +For NFSv4 ACLs, display access mask and flags in a verbose form. +Ignored for POSIX.1e ACLs. .El .Pp The following operand is available: Modified: head/bin/getfacl/getfacl.c ============================================================================== --- head/bin/getfacl/getfacl.c Fri Sep 4 09:57:03 2009 (r196826) +++ head/bin/getfacl/getfacl.c Fri Sep 4 10:22:29 2009 (r196827) @@ -54,7 +54,7 @@ static void usage(void) { - fprintf(stderr, "getfacl [-dhq] [file ...]\n"); + fprintf(stderr, "getfacl [-dhnqv] [file ...]\n"); } static char * @@ -175,22 +175,39 @@ acl_from_stat(struct stat sb) } static int -print_acl(char *path, acl_type_t type, int hflag, int qflag) +print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, + int qflag, int vflag) { struct stat sb; acl_t acl; char *acl_text; - int error; + int error, flags = 0, ret; if (hflag) error = lstat(path, &sb); else error = stat(path, &sb); if (error == -1) { - warn("%s", path); + warn("%s: stat() failed", path); return(-1); } + if (hflag) + ret = lpathconf(path, _PC_ACL_NFS4); + else + ret = pathconf(path, _PC_ACL_NFS4); + if (ret > 0) { + if (type == ACL_TYPE_DEFAULT) { + warnx("%s: there are no default entries in NFSv4 ACLs", + path); + return (-1); + } + type = ACL_TYPE_NFS4; + } else if (ret < 0 && errno != EINVAL) { + warn("%s: pathconf(..., _PC_ACL_NFS4) failed", path); + return (-1); + } + if (more_than_one) printf("\n"); else @@ -210,18 +227,27 @@ print_acl(char *path, acl_type_t type, i return(-1); } errno = 0; - if (type != ACL_TYPE_ACCESS) + if (type == ACL_TYPE_DEFAULT) return(0); acl = acl_from_stat(sb); if (!acl) { - warn("acl_from_stat()"); + warn("%s: acl_from_stat() failed", path); return(-1); } } - acl_text = acl_to_text(acl, 0); + if (iflag) + flags |= ACL_TEXT_APPEND_ID; + + if (nflag) + flags |= ACL_TEXT_NUMERIC_IDS; + + if (vflag) + flags |= ACL_TEXT_VERBOSE; + + acl_text = acl_to_text_np(acl, 0, flags); if (!acl_text) { - warn("%s", path); + warn("%s: acl_to_text_np() failed", path); return(-1); } @@ -234,7 +260,8 @@ print_acl(char *path, acl_type_t type, i } static int -print_acl_from_stdin(acl_type_t type, int hflag, int qflag) +print_acl_from_stdin(acl_type_t type, int hflag, int iflag, int nflag, + int qflag, int vflag) { char *p, pathname[PATH_MAX]; int carried_error = 0; @@ -242,7 +269,8 @@ print_acl_from_stdin(acl_type_t type, in while (fgets(pathname, (int)sizeof(pathname), stdin)) { if ((p = strchr(pathname, '\n')) != NULL) *p = '\0'; - if (print_acl(pathname, type, hflag, qflag) == -1) { + if (print_acl(pathname, type, hflag, iflag, nflag, + qflag, vflag) == -1) { carried_error = -1; } } @@ -256,11 +284,14 @@ main(int argc, char *argv[]) acl_type_t type = ACL_TYPE_ACCESS; int carried_error = 0; int ch, error, i; - int hflag, qflag; + int hflag, iflag, qflag, nflag, vflag; hflag = 0; + iflag = 0; qflag = 0; - while ((ch = getopt(argc, argv, "dhq")) != -1) + nflag = 0; + vflag = 0; + while ((ch = getopt(argc, argv, "dhinqv")) != -1) switch(ch) { case 'd': type = ACL_TYPE_DEFAULT; @@ -268,9 +299,18 @@ main(int argc, char *argv[]) case 'h': hflag = 1; break; + case 'i': + iflag = 1; + break; + case 'n': + nflag = 1; + break; case 'q': qflag = 1; break; + case 'v': + vflag = 1; + break; default: usage(); return(-1); @@ -279,17 +319,20 @@ main(int argc, char *argv[]) argv += optind; if (argc == 0) { - error = print_acl_from_stdin(type, hflag, qflag); + error = print_acl_from_stdin(type, hflag, iflag, nflag, + qflag, vflag); return(error ? 1 : 0); } for (i = 0; i < argc; i++) { if (!strcmp(argv[i], "-")) { - error = print_acl_from_stdin(type, hflag, qflag); + error = print_acl_from_stdin(type, hflag, iflag, nflag, + qflag, vflag); if (error == -1) carried_error = -1; } else { - error = print_acl(argv[i], type, hflag, qflag); + error = print_acl(argv[i], type, hflag, iflag, nflag, + qflag, vflag); if (error == -1) carried_error = -1; } From ed at 80386.nl Fri Sep 4 10:32:16 2009 From: ed at 80386.nl (Ed Schouten) Date: Fri Sep 4 10:32:28 2009 Subject: svn commit: r196818 - head/contrib/ee In-Reply-To: <200909040742.n847gD62058267@svn.freebsd.org> References: <200909040742.n847gD62058267@svn.freebsd.org> Message-ID: <20090904103214.GW2829@hoeg.nl> Hello Andrey, * Andrey A. Chernov wrote: > 1) Remove single occurance of HAS_CTYPE ifdef, ctype functions > used here for a long time and needs their header in anycase. > 2) Add (unsigned char) casts to more ctype macros. > 3) Simplify menu input handling using ctype instead of range unguarded > hardcoded tricks. Even though I really appreciate fixes/cleanups to ee(1), I think changes like these should be sent to its maintainer as well. Have you done this? -- Ed Schouten WWW: http://80386.nl/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/0f69f70f/attachment.pgp From ache at nagual.pp.ru Fri Sep 4 14:02:28 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Fri Sep 4 14:02:39 2009 Subject: svn commit: r196818 - head/contrib/ee In-Reply-To: <20090904103214.GW2829@hoeg.nl> References: <200909040742.n847gD62058267@svn.freebsd.org> <20090904103214.GW2829@hoeg.nl> Message-ID: <20090904140219.GA3179@nagual.pp.ru> On Fri, Sep 04, 2009 at 12:32:14PM +0200, Ed Schouten wrote: > Even though I really appreciate fixes/cleanups to ee(1), I think changes > like these should be sent to its maintainer as well. Have you done this? Yes. -- http://ache.pp.ru/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/5bfd8111/attachment.pgp From ed at 80386.nl Fri Sep 4 14:50:07 2009 From: ed at 80386.nl (Ed Schouten) Date: Fri Sep 4 14:50:13 2009 Subject: svn commit: r196818 - head/contrib/ee In-Reply-To: <20090904140219.GA3179@nagual.pp.ru> References: <200909040742.n847gD62058267@svn.freebsd.org> <20090904103214.GW2829@hoeg.nl> <20090904140219.GA3179@nagual.pp.ru> Message-ID: <20090904145005.GX2829@hoeg.nl> * Andrey Chernov wrote: > On Fri, Sep 04, 2009 at 12:32:14PM +0200, Ed Schouten wrote: > > Even though I really appreciate fixes/cleanups to ee(1), I think changes > > like these should be sent to its maintainer as well. Have you done this? > > Yes. Great! The reason why I was being a little negative, is because I noticed the previous version of ee(1) we had, had a lot of local patches that were very hard to merge. It turned out most of the features were implemented upstream as well, albeit differently. It's nice to see someone step up to hunt down bugs in ee(1). -- Ed Schouten WWW: http://80386.nl/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/3abf04d8/attachment.pgp From kib at FreeBSD.org Fri Sep 4 14:53:12 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Fri Sep 4 14:53:23 2009 Subject: svn commit: r196829 - head/sys/i386/i386 Message-ID: <200909041453.n84ErCtU075966@svn.freebsd.org> Author: kib Date: Fri Sep 4 14:53:12 2009 New Revision: 196829 URL: http://svn.freebsd.org/changeset/base/196829 Log: Add missing ';'. Modified: head/sys/i386/i386/machdep.c Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Fri Sep 4 11:32:05 2009 (r196828) +++ head/sys/i386/i386/machdep.c Fri Sep 4 14:53:12 2009 (r196829) @@ -2570,7 +2570,7 @@ init386(first) default_proc_ldt.ldt_base = (caddr_t)ldt; default_proc_ldt.ldt_len = 6; _default_ldt = (int)&default_proc_ldt; - PCPU_SET(currentldt, _default_ldt) + PCPU_SET(currentldt, _default_ldt); PT_SET_MA(ldt, *vtopte((unsigned long)ldt) & ~PG_RW); xen_set_ldt((unsigned long) ldt, (sizeof ldt_segs / sizeof ldt_segs[0])); From bz at FreeBSD.org Fri Sep 4 15:00:08 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Fri Sep 4 15:00:19 2009 Subject: svn commit: r196829 - head/sys/i386/i386 In-Reply-To: <200909041453.n84ErCtU075966@svn.freebsd.org> References: <200909041453.n84ErCtU075966@svn.freebsd.org> Message-ID: <20090904145527.S68375@maildrop.int.zabbadoz.net> On Fri, 4 Sep 2009, Konstantin Belousov wrote: > Author: kib > Date: Fri Sep 4 14:53:12 2009 > New Revision: 196829 > URL: http://svn.freebsd.org/changeset/base/196829 > > Log: > Add missing ';'. This hadn't been noticed for a year as up to r196810 PCPU_SET was a { .. } block. With r196811 it was changed to do { .. } while (0) and thus the missing ';' immediately became a syntax error. > Modified: > head/sys/i386/i386/machdep.c > > Modified: head/sys/i386/i386/machdep.c > ============================================================================== > --- head/sys/i386/i386/machdep.c Fri Sep 4 11:32:05 2009 (r196828) > +++ head/sys/i386/i386/machdep.c Fri Sep 4 14:53:12 2009 (r196829) > @@ -2570,7 +2570,7 @@ init386(first) > default_proc_ldt.ldt_base = (caddr_t)ldt; > default_proc_ldt.ldt_len = 6; > _default_ldt = (int)&default_proc_ldt; > - PCPU_SET(currentldt, _default_ldt) > + PCPU_SET(currentldt, _default_ldt); > PT_SET_MA(ldt, *vtopte((unsigned long)ldt) & ~PG_RW); > xen_set_ldt((unsigned long) ldt, (sizeof ldt_segs / sizeof ldt_segs[0])); > > -- Bjoern A. Zeeb What was I talking about and who are you again? From ache at nagual.pp.ru Fri Sep 4 15:02:35 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Fri Sep 4 15:02:41 2009 Subject: svn commit: r196818 - head/contrib/ee In-Reply-To: <20090904145005.GX2829@hoeg.nl> References: <200909040742.n847gD62058267@svn.freebsd.org> <20090904103214.GW2829@hoeg.nl> <20090904140219.GA3179@nagual.pp.ru> <20090904145005.GX2829@hoeg.nl> Message-ID: <20090904150229.GA4007@nagual.pp.ru> On Fri, Sep 04, 2009 at 04:50:05PM +0200, Ed Schouten wrote: > * Andrey Chernov wrote: > > On Fri, Sep 04, 2009 at 12:32:14PM +0200, Ed Schouten wrote: > > > Even though I really appreciate fixes/cleanups to ee(1), I think changes > > > like these should be sent to its maintainer as well. Have you done this? > > > > Yes. > > Great! The reason why I was being a little negative, is because I > noticed the previous version of ee(1) we had, had a lot of local patches > that were very hard to merge. It turned out most of the features were > implemented upstream as well, albeit differently. > > It's nice to see someone step up to hunt down bugs in ee(1). I got no reply from the author yet, lets wait. Ctype stuff there was in pre-POSIX (and even pre-BSD4.3) old times state, but luckily enough it affect only several edge cases in FreeBSD. Most unpleasant bug which was the reason I start to look there was all 8bit chars highlighting due to passing negative chars to waddch(). -- http://ache.pp.ru/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/9f928454/attachment.pgp From gnn at hudson-trading.com Fri Sep 4 15:18:48 2009 From: gnn at hudson-trading.com (George Neville-Neil) Date: Fri Sep 4 15:19:00 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: <4AA09B41.3040103@incunabulum.net> References: <200909032110.n83LAvUF044731@svn.freebsd.org> <4AA09B41.3040103@incunabulum.net> Message-ID: <3C6607F2-D517-41EC-8681-33236EC6D20F@FreeBSD.org> On Sep 4, 2009, at 00:44 , Bruce Simpson wrote: > George V. Neville-Neil wrote: >> Author: gnn >> Date: Thu Sep 3 21:10:57 2009 >> New Revision: 196797 >> URL: http://svn.freebsd.org/changeset/base/196797 >> >> Log: >> Add ARP statistics to the kernel and netstat. >> > > Thanks very much for this change. > Any chance this struct can get explicitly versioned (i.e. as for > struct igmpstat) as it is a new struct? > bz@ and I will likely be tweaking this over time, so we can probably do that. Later, George From bz at FreeBSD.org Fri Sep 4 17:20:07 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Fri Sep 4 17:20:14 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: <3C6607F2-D517-41EC-8681-33236EC6D20F@FreeBSD.org> References: <200909032110.n83LAvUF044731@svn.freebsd.org> <4AA09B41.3040103@incunabulum.net> <3C6607F2-D517-41EC-8681-33236EC6D20F@FreeBSD.org> Message-ID: <20090904171511.Q68375@maildrop.int.zabbadoz.net> On Fri, 4 Sep 2009, George Neville-Neil wrote: Hi, > On Sep 4, 2009, at 00:44 , Bruce Simpson wrote: > >> George V. Neville-Neil wrote: >>> Author: gnn >>> Date: Thu Sep 3 21:10:57 2009 >>> New Revision: 196797 >>> URL: http://svn.freebsd.org/changeset/base/196797 >>> >>> Log: >>> Add ARP statistics to the kernel and netstat. >>> >> >> Thanks very much for this change. >> Any chance this struct can get explicitly versioned (i.e. as for struct >> igmpstat) as it is a new struct? >> > > bz@ and I will likely be tweaking this over time, so we can probably do that. I am not entirely sure what "versioning" that struct would help? ARP is from the early 80s, we've got 8 variables and 4 spares and I cannot forsee any major rewrite of the code or the protocoll to gather a lot more stats anymore. /bz -- Bjoern A. Zeeb What was I talking about and who are you again? From imp at bsdimp.com Fri Sep 4 17:31:05 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Fri Sep 4 17:31:11 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <200909031340.n83Defkv034013@svn.freebsd.org> References: <200909031340.n83Defkv034013@svn.freebsd.org> Message-ID: <20090904.112919.1521002024.imp@bsdimp.com> In message: <200909031340.n83Defkv034013@svn.freebsd.org> Attilio Rao writes: : Author: attilio : Date: Thu Sep 3 13:40:41 2009 : New Revision: 196779 : URL: http://svn.freebsd.org/changeset/base/196779 : : Log: : Add intermediate states for attaching and detaching that will be : reused by the enhached newbus locking once it is checked in. : This change can be easilly MFCed to STABLE_8 at the appropriate moment. That appropriate moment better be ASAP. At least for the change I've highlighed below, since it changes the ABI. Btw, this change also breaks devinfo. : Modified: head/sys/sys/bus.h : ============================================================================== : --- head/sys/sys/bus.h Thu Sep 3 12:41:00 2009 (r196778) : +++ head/sys/sys/bus.h Thu Sep 3 13:40:41 2009 (r196779) : @@ -52,8 +52,11 @@ struct u_businfo { : typedef enum device_state { : DS_NOTPRESENT, /**< @brief not probed or probe failed */ : DS_ALIVE, /**< @brief probe succeeded */ : + DS_ATTACHING, /**< @brief attaching is in progress */ : DS_ATTACHED, /**< @brief attach method called */ : - DS_BUSY /**< @brief device is open */ : + DS_BUSY, /**< @brief device is open */ : + DS_DETACHING /**< @brief detaching is in progress */ : + : } device_state_t; device_state_t is exported to userland via devctl. Well, that's not entirely true... It isn't used EXACTLY, but there's this in devinfo.h: /* * State of the device. */ /* XXX not sure if I want a copy here, or expose sys/bus.h */ typedef enum devinfo_state { DIS_NOTPRESENT, /* not probed or probe failed */ DIS_ALIVE, /* probe succeeded */ DIS_ATTACHED, /* attach method called */ DIS_BUSY /* device is open */ } devinfo_state_t; which is why devinfo is broken. Also, DS_BUSY is used in many drivers to PREVENT detaching. So the change is bad from that point of view, since DS_DETACHING is now > DS_BUSY. There's really a partial ordering relationship now where before there was a total ordering (DS_BUSY is > DS_ATTACHED and DS_DETACHING is > DS_ATTACH, but DS_DETACHING isn't > DS_BUSY and DS_BUSY isn't > DS_DETACHING). I think that you've destroyed information here by unconditionally setting it: - if ((error = DEVICE_DETACH(dev)) != 0) + dev->state = DS_DETACHING; + if ((error = DEVICE_DETACH(dev)) != 0) { + KASSERT(dev->state == DS_DETACHING, + ("%s: %p device state must not been changing", __func__, + dev)); + dev->state = DS_ATTACHED; return (error); + } + KASSERT(dev->state == DS_DETACHING, + ("%s: %p device state must not been changing", __func__, dev)); And this looks racy between the check earlier and this setting. Properly locked, this wouldn't destroy information... At the very least cardbus/cardbus.c and pccard/pccard.c need to be looked at since they both have code that looks like: for (tmp = 0; tmp < numdevs; tmp++) { struct cardbus_devinfo *dinfo = device_get_ivars(devlist[tmp]); int status = device_get_state(devlist[tmp]); if (dinfo->pci.cfg.dev != devlist[tmp]) device_printf(cbdev, "devinfo dev mismatch\n"); if (status == DS_ATTACHED || status == DS_BUSY) device_detach(devlist[tmp]); cardbus_release_all_resources(cbdev, dinfo); cardbus_device_destroy(dinfo); device_delete_child(cbdev, devlist[tmp]); pci_freecfg((struct pci_devinfo *)dinfo); } which does ignore errors returned by device_detach for the DS_BUSY case because there's not currently a good way to tell device_detach that it *MUST* detach the device *NOW* without any possibility of veto by the driver. The above code also isn't DS_DETACHING aware, and may be wrong in the face of this new state. Of course, grepping the tree does show one or two places where DS_BUSY is used inappropriately: rp.c: static int rp_pcidetach(device_t dev) { CONTROLLER_t *ctlp; if (device_get_state(dev) == DS_BUSY) return (EBUSY); is one example. The above check should just be removed (ditto for its SHUTDOWN) routine. So I think we should fix rp.c, but we need to talk through this change a little more. I'm surprised I wasn't even pinged about it, since it hits code that I maintain and a simple grep would have found... I'm not yet asking for it to be backed out, but I don't like it on its surface and want to talk about it in more detail. Warner From rwatson at FreeBSD.org Fri Sep 4 17:33:45 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Fri Sep 4 17:33:56 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: <4AA09B41.3040103@incunabulum.net> References: <200909032110.n83LAvUF044731@svn.freebsd.org> <4AA09B41.3040103@incunabulum.net> Message-ID: On Fri, 4 Sep 2009, Bruce Simpson wrote: > George V. Neville-Neil wrote: >> Author: gnn >> Date: Thu Sep 3 21:10:57 2009 >> New Revision: 196797 >> URL: http://svn.freebsd.org/changeset/base/196797 >> >> Log: >> Add ARP statistics to the kernel and netstat. > > Thanks very much for this change. Any chance this struct can get explicitly > versioned (i.e. as for struct igmpstat) as it is a new struct? For sysctls, explicit versioning doesn't help too much -- what I've been pondering for another structure was including spares and having a capabilities field in the structure where flags are set when fields are known by the kernel. That way userspace can tell if the kernel knows about the field it cares about and therefore whether they're worth looking at. Robert N M Watson Computer Laboratory University of Cambridge From imp at bsdimp.com Fri Sep 4 17:33:56 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Fri Sep 4 17:34:07 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> References: <200909031340.n83Defkv034013@svn.freebsd.org> <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> Message-ID: <20090904.113314.1979406201.imp@bsdimp.com> In message: <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> Attilio Rao writes: : 2009/9/3 Attilio Rao : : > Author: attilio : > Date: Thu Sep 3 13:40:41 2009 : > New Revision: 196779 : > URL: http://svn.freebsd.org/changeset/base/196779 : > : > Log: : > Add intermediate states for attaching and detaching that will be : > reused by the enhached newbus locking once it is checked in. : > This change can be easilly MFCed to STABLE_8 at the appropriate moment. : : About this commit, there are a few of things which worths nothing: : - This has been committed separately from the new-bus locking because : it is planned to be MFCed before 8.0 goes out in order to offer the : correct ABI compatibility for merging, while 8.1-REL, the newbus : locking I understand why the change is made here, but I don't think it is the right one. Or at least I don't think I adequately understand its motivation and need to understand that better since it doesn't make sense to me. : - Probabilly what we really wanted here is just a transitioning state : instead than both DS_ATTACHING and DS_DETACHING. Some consumers would : eventually understand what of the 2 is that and one of these consumers : is device_is_attached(). That function is used improperly by many : detach handlers in a construct like: I don't understand the point you are trying to make here... I'm not sure that piggybacking this information on the state is the right approach. : int : foo_attach(device_t dev) : { : ... : if (error != 0) : foo_detach(dev); : ... : } : : int : foo_detach(device_dev) : { : ... : if (device_is_attached(dev)) { : /* do some handover */ : } : ... : } : : That is an incorrect behaviour which needs to be discouraged and that : will be fixed during 9.0. Why is that bad? There are a lot of drivers that do that. I don't understand the point you are making here... The alternatives are likely worse. Please let me know what the plan here is. : In the while this semantic (used by many drivers) makes the : single-transition state impraticable and so we will need to stick with : that device states also in 9.0. A lot of drivers use that idiom today. Are you signing up to make sure they all work in the future? Again: I wasn't consulted on this change, don't like it, and want to talk more about it. It broke devinfo, and ignored code in cardbus and pccard that likely needs to change to cope. Warner From imp at bsdimp.com Fri Sep 4 17:41:46 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Fri Sep 4 17:41:54 2009 Subject: svn commit: r196752 - head/lib/libc/stdtime In-Reply-To: <20090904075338.GA90644@nagual.pp.ru> References: <20090904115255.Q48987@delplex.bde.org> <20090904144214.O49099@delplex.bde.org> <20090904075338.GA90644@nagual.pp.ru> Message-ID: <20090904.114040.-93208535.imp@bsdimp.com> In message: <20090904075338.GA90644@nagual.pp.ru> Andrey Chernov writes: : On Fri, Sep 04, 2009 at 03:21:09PM +1000, Bruce Evans wrote: : > % The value of the argument must be representable as an : > % .Vt "unsigned char" : > % or the value of : > % .Dv EOF . : > : > This is the same as in POSIX except the POSIX wording is better (e.g., : > the above only says implicitly that the behaviour is undefined if : > "must" is not satisfied). It took too many commits (revs 1.8-1.10) to : > get this far. : : BTW, do we have permissions for direct POSIX quotes? Yes. However, if we take more than a couple of words, we need to include the POSIX copyright headers. There was email from core on this about 6 years ago, iirc. Warner From julian at elischer.org Fri Sep 4 17:46:01 2009 From: julian at elischer.org (Julian Elischer) Date: Fri Sep 4 17:46:08 2009 Subject: svn commit: r196829 - head/sys/i386/i386 In-Reply-To: <20090904145527.S68375@maildrop.int.zabbadoz.net> References: <200909041453.n84ErCtU075966@svn.freebsd.org> <20090904145527.S68375@maildrop.int.zabbadoz.net> Message-ID: <4AA15257.4050305@elischer.org> Bjoern A. Zeeb wrote: > On Fri, 4 Sep 2009, Konstantin Belousov wrote: > >> Author: kib >> Date: Fri Sep 4 14:53:12 2009 >> New Revision: 196829 >> URL: http://svn.freebsd.org/changeset/base/196829 >> >> Log: >> Add missing ';'. > > This hadn't been noticed for a year as up to r196810 PCPU_SET was a > { > .. > } > block. With r196811 it was changed to > do { > .. > } while (0) > and thus the missing ';' immediately became a syntax error. so, why does my tree compile? > > >> Modified: >> head/sys/i386/i386/machdep.c >> >> Modified: head/sys/i386/i386/machdep.c >> ============================================================================== >> >> --- head/sys/i386/i386/machdep.c Fri Sep 4 11:32:05 2009 (r196828) >> +++ head/sys/i386/i386/machdep.c Fri Sep 4 14:53:12 2009 (r196829) >> @@ -2570,7 +2570,7 @@ init386(first) >> default_proc_ldt.ldt_base = (caddr_t)ldt; >> default_proc_ldt.ldt_len = 6; >> _default_ldt = (int)&default_proc_ldt; >> - PCPU_SET(currentldt, _default_ldt) >> + PCPU_SET(currentldt, _default_ldt); >> PT_SET_MA(ldt, *vtopte((unsigned long)ldt) & ~PG_RW); >> xen_set_ldt((unsigned long) ldt, (sizeof ldt_segs / sizeof >> ldt_segs[0])); >> >> > From jhb at freebsd.org Fri Sep 4 17:51:24 2009 From: jhb at freebsd.org (John Baldwin) Date: Fri Sep 4 17:51:35 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <20090904.113314.1979406201.imp@bsdimp.com> References: <200909031340.n83Defkv034013@svn.freebsd.org> <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> <20090904.113314.1979406201.imp@bsdimp.com> Message-ID: <200909041349.53872.jhb@freebsd.org> On Friday 04 September 2009 1:33:14 pm M. Warner Losh wrote: > In message: <3bbf2fe10909030646o2dc30166r303ee646572c741b@mail.gmail.com> > Attilio Rao writes: > : 2009/9/3 Attilio Rao : > : > Author: attilio > : > Date: Thu Sep 3 13:40:41 2009 > : > New Revision: 196779 > : > URL: http://svn.freebsd.org/changeset/base/196779 > : > > : > Log: > : > Add intermediate states for attaching and detaching that will be > : > reused by the enhached newbus locking once it is checked in. > : > This change can be easilly MFCed to STABLE_8 at the appropriate moment. > : > : About this commit, there are a few of things which worths nothing: > : - This has been committed separately from the new-bus locking because > : it is planned to be MFCed before 8.0 goes out in order to offer the > : correct ABI compatibility for merging, while 8.1-REL, the newbus > : locking > > I understand why the change is made here, but I don't think it is the > right one. Or at least I don't think I adequately understand its > motivation and need to understand that better since it doesn't make > sense to me. > > : - Probabilly what we really wanted here is just a transitioning state > : instead than both DS_ATTACHING and DS_DETACHING. Some consumers would > : eventually understand what of the 2 is that and one of these consumers > : is device_is_attached(). That function is used improperly by many > : detach handlers in a construct like: > > I don't understand the point you are trying to make here... I'm not > sure that piggybacking this information on the state is the right > approach. We need a single state (though not really 2 IMO) so we can run device attach and detach routines w/o holding the new-bus lock (which it turns out we need to do as attach and detach routines can do too many things that aren't safe to do while holding the new-bus lock). > : int > : foo_attach(device_t dev) > : { > : ... > : if (error != 0) > : foo_detach(dev); > : ... > : } > : > : int > : foo_detach(device_dev) > : { > : ... > : if (device_is_attached(dev)) { > : /* do some handover */ > : } > : ... > : } > : > : That is an incorrect behaviour which needs to be discouraged and that > : will be fixed during 9.0. > > Why is that bad? There are a lot of drivers that do that. I don't > understand the point you are making here... I think it is sloppy/lazy at best. A detach routine should really only be used for detaching. > The alternatives are likely worse. Please let me know what the plan > here is. I think a very sane alternative is to split these detach routines up. All the bits that aren't conditional on 'device_is_attached()' would move into a 'foo_release_resources()' that foo_attach() calls on error. foo_detach() would then do all the work that is currently conditional on 'device_is_attached()' unconditionally and then invoke foo_release_resources(). A larger demo: int foo_attach() { sc->ifp = if_alloc(); ... ether_ifattach(sc->ifp); return (0); error: foo_detach(); } int foo_detach() { if (device_is_attached()) { ether_ifdetach(sc->ifp); } ... if_free(sc->ifp); } would now become this: int foo_attach() { sc->ifp = if_alloc(); ... ether_ifattach(sc->ifp); return (0); error: foo_release_resources(); } int foo_detach() { ether_ifdetach(sc->ifp); foo_release_resources(); } int foo_release_resources() { ... if_free(sc->ifp); } -- John Baldwin From julian at elischer.org Fri Sep 4 17:51:50 2009 From: julian at elischer.org (Julian Elischer) Date: Fri Sep 4 17:51:56 2009 Subject: svn commit: r196829 - head/sys/i386/i386 In-Reply-To: <4AA15257.4050305@elischer.org> References: <200909041453.n84ErCtU075966@svn.freebsd.org> <20090904145527.S68375@maildrop.int.zabbadoz.net> <4AA15257.4050305@elischer.org> Message-ID: <4AA153B4.4050408@elischer.org> Julian Elischer wrote: > Bjoern A. Zeeb wrote: >> On Fri, 4 Sep 2009, Konstantin Belousov wrote: >> >>> Author: kib >>> Date: Fri Sep 4 14:53:12 2009 >>> New Revision: 196829 >>> URL: http://svn.freebsd.org/changeset/base/196829 >>> >>> Log: >>> Add missing ';'. >> >> This hadn't been noticed for a year as up to r196810 PCPU_SET was a >> { >> .. >> } >> block. With r196811 it was changed to >> do { >> .. >> } while (0) >> and thus the missing ';' immediately became a syntax error. > > so, why does my tree compile? I don't understand.. I've been running on that kernel for weeks > >> >> >>> Modified: >>> head/sys/i386/i386/machdep.c >>> >>> Modified: head/sys/i386/i386/machdep.c >>> ============================================================================== >>> >>> --- head/sys/i386/i386/machdep.c Fri Sep 4 11:32:05 2009 >>> (r196828) >>> +++ head/sys/i386/i386/machdep.c Fri Sep 4 14:53:12 2009 >>> (r196829) >>> @@ -2570,7 +2570,7 @@ init386(first) >>> default_proc_ldt.ldt_base = (caddr_t)ldt; >>> default_proc_ldt.ldt_len = 6; >>> _default_ldt = (int)&default_proc_ldt; >>> - PCPU_SET(currentldt, _default_ldt) >>> + PCPU_SET(currentldt, _default_ldt); >>> PT_SET_MA(ldt, *vtopte((unsigned long)ldt) & ~PG_RW); >>> xen_set_ldt((unsigned long) ldt, (sizeof ldt_segs / sizeof >>> ldt_segs[0])); >>> >>> >> From kostikbel at gmail.com Fri Sep 4 17:56:33 2009 From: kostikbel at gmail.com (Kostik Belousov) Date: Fri Sep 4 17:56:41 2009 Subject: svn commit: r196829 - head/sys/i386/i386 In-Reply-To: <4AA153B4.4050408@elischer.org> References: <200909041453.n84ErCtU075966@svn.freebsd.org> <20090904145527.S68375@maildrop.int.zabbadoz.net> <4AA15257.4050305@elischer.org> <4AA153B4.4050408@elischer.org> Message-ID: <20090904175621.GS1881@deviant.kiev.zoral.com.ua> On Fri, Sep 04, 2009 at 10:51:48AM -0700, Julian Elischer wrote: > Julian Elischer wrote: > >Bjoern A. Zeeb wrote: > >>On Fri, 4 Sep 2009, Konstantin Belousov wrote: > >> > >>>Author: kib > >>>Date: Fri Sep 4 14:53:12 2009 > >>>New Revision: 196829 > >>>URL: http://svn.freebsd.org/changeset/base/196829 > >>> > >>>Log: > >>> Add missing ';'. > >> > >>This hadn't been noticed for a year as up to r196810 PCPU_SET was a > >> { > >> .. > >> } > >>block. With r196811 it was changed to > >> do { > >> .. > >> } while (0) > >>and thus the missing ';' immediately became a syntax error. > > > >so, why does my tree compile? > > I don't understand.. I've been running on that kernel for weeks Do you run XEN ? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/ca797a3e/attachment.pgp From mav at FreeBSD.org Fri Sep 4 18:21:41 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Fri Sep 4 18:21:48 2009 Subject: svn commit: r196831 - head/sbin/camcontrol Message-ID: <200909041821.n84ILfWo092251@svn.freebsd.org> Author: mav Date: Fri Sep 4 18:21:40 2009 New Revision: 196831 URL: http://svn.freebsd.org/changeset/base/196831 Log: Add to `camcontrol cmd` support for sending arbitrary ATA commands. It could be used for broad range of tasks, such as configuring drive power management modes, caching, security and any other features and tasks, not supported by existing drivers. Modified: head/sbin/camcontrol/camcontrol.8 head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.8 ============================================================================== --- head/sbin/camcontrol/camcontrol.8 Fri Sep 4 16:41:17 2009 (r196830) +++ head/sbin/camcontrol/camcontrol.8 Fri Sep 4 18:21:40 2009 (r196831) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 29, 2009 +.Dd September 4, 2009 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -120,10 +120,12 @@ .Ic cmd .Op device id .Op generic args +.Aq Fl a Ar cmd Op args .Aq Fl c Ar cmd Op args .Op Fl i Ar len Ar fmt .Bk -words .Op Fl o Ar len Ar fmt Op args +.Op Fl r Ar fmt .Ek .Nm .Ic debug @@ -486,12 +488,14 @@ Saved values .El .El .It Ic cmd -Allows the user to send an arbitrary SCSI CDB to any device. +Allows the user to send an arbitrary ATA or SCSI CDB to any device. The .Ic cmd function requires the .Fl c -argument to specify the CDB. +argument to specify SCSI CDB or the +.Fl a +argument to specify ATA Command Block registers values. Other arguments are optional, depending on the command type. The command and data specification syntax is documented @@ -503,9 +507,13 @@ SCSI device in question, you MUST specif or .Fl o . .Bl -tag -width 17n +.It Fl a Ar cmd Op args +This specifies the content of 12 ATA Command Block registers (command, +features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp. +lba_high_exp, features_exp, sector_count, sector_count_exp). .It Fl c Ar cmd Op args This specifies the SCSI CDB. -CDBs may be 6, 10, 12 or 16 bytes. +SCSI CDBs may be 6, 10, 12 or 16 bytes. .It Fl i Ar len Ar fmt This specifies the amount of data to read, and how it should be displayed. If the format is @@ -519,6 +527,13 @@ If the format is .Sq - , .Ar len bytes of data will be read from standard input and written to the device. +.It Fl r Ar fmt +This specifies that 11 result ATA Command Block registers should be displayed +(status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp, +lba_high_exp, sector_count, sector_count_exp), and how. +If the format is +.Sq - , +11 result registers will be written to standard output in hex. .El .It Ic debug Turn on CAM debugging printfs in the kernel. Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Fri Sep 4 16:41:17 2009 (r196830) +++ head/sbin/camcontrol/camcontrol.c Fri Sep 4 18:21:40 2009 (r196831) @@ -120,7 +120,7 @@ struct camcontrol_opts { }; #ifndef MINIMALISTIC -static const char scsicmd_opts[] = "c:i:o:"; +static const char scsicmd_opts[] = "a:c:i:o:r"; static const char readdefect_opts[] = "f:GP"; static const char negotiate_opts[] = "acD:O:qR:T:UW:"; #endif @@ -2078,12 +2078,15 @@ scsicmd(struct cam_device *device, int a u_int32_t flags = CAM_DIR_NONE; u_int8_t *data_ptr = NULL; u_int8_t cdb[20]; + u_int8_t atacmd[12]; struct get_hook hook; int c, data_bytes = 0; int cdb_len = 0; - char *datastr = NULL, *tstr; + int atacmd_len = 0; + int need_res = 0; + char *datastr = NULL, *tstr, *resstr = NULL; int error = 0; - int fd_data = 0; + int fd_data = 0, fd_res = 0; int retval; ccb = cam_getccb(device); @@ -2094,10 +2097,32 @@ scsicmd(struct cam_device *device, int a } bzero(&(&ccb->ccb_h)[1], - sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + sizeof(union ccb) - sizeof(struct ccb_hdr)); while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c) { + case 'a': + tstr = optarg; + while (isspace(*tstr) && (*tstr != '\0')) + tstr++; + hook.argc = argc - optind; + hook.argv = argv + optind; + hook.got = 0; + atacmd_len = buff_encode_visit(atacmd, sizeof(atacmd), tstr, + iget, &hook); + /* + * Increment optind by the number of arguments the + * encoding routine processed. After each call to + * getopt(3), optind points to the argument that + * getopt should process _next_. In this case, + * that means it points to the first command string + * argument, if there is one. Once we increment + * this, it should point to either the next command + * line argument, or it should be past the end of + * the list. + */ + optind += hook.got; + break; case 'c': tstr = optarg; while (isspace(*tstr) && (*tstr != '\0')) @@ -2194,6 +2219,16 @@ scsicmd(struct cam_device *device, int a iget, &hook); optind += hook.got; break; + case 'r': + need_res = 1; + hook.argc = argc - optind; + hook.argv = argv + optind; + hook.got = 0; + resstr = cget(&hook, NULL); + if ((resstr != NULL) && (resstr[0] == '-')) + fd_res = 1; + optind += hook.got; + break; default: break; } @@ -2226,50 +2261,51 @@ scsicmd(struct cam_device *device, int a /* Disable freezing the device queue */ flags |= CAM_DEV_QFRZDIS; - /* - * This is taken from the SCSI-3 draft spec. - * (T10/1157D revision 0.3) - * The top 3 bits of an opcode are the group code. The next 5 bits - * are the command code. - * Group 0: six byte commands - * Group 1: ten byte commands - * Group 2: ten byte commands - * Group 3: reserved - * Group 4: sixteen byte commands - * Group 5: twelve byte commands - * Group 6: vendor specific - * Group 7: vendor specific - */ - switch((cdb[0] >> 5) & 0x7) { - case 0: - cdb_len = 6; - break; - case 1: - case 2: - cdb_len = 10; - break; - case 3: - case 6: - case 7: - /* computed by buff_encode_visit */ - break; - case 4: - cdb_len = 16; - break; - case 5: - cdb_len = 12; - break; - } + if (cdb_len) { + /* + * This is taken from the SCSI-3 draft spec. + * (T10/1157D revision 0.3) + * The top 3 bits of an opcode are the group code. + * The next 5 bits are the command code. + * Group 0: six byte commands + * Group 1: ten byte commands + * Group 2: ten byte commands + * Group 3: reserved + * Group 4: sixteen byte commands + * Group 5: twelve byte commands + * Group 6: vendor specific + * Group 7: vendor specific + */ + switch((cdb[0] >> 5) & 0x7) { + case 0: + cdb_len = 6; + break; + case 1: + case 2: + cdb_len = 10; + break; + case 3: + case 6: + case 7: + /* computed by buff_encode_visit */ + break; + case 4: + cdb_len = 16; + break; + case 5: + cdb_len = 12; + break; + } - /* - * We should probably use csio_build_visit or something like that - * here, but it's easier to encode arguments as you go. The - * alternative would be skipping the CDB argument and then encoding - * it here, since we've got the data buffer argument by now. - */ - bcopy(cdb, &ccb->csio.cdb_io.cdb_bytes, cdb_len); + /* + * We should probably use csio_build_visit or something like that + * here, but it's easier to encode arguments as you go. The + * alternative would be skipping the CDB argument and then encoding + * it here, since we've got the data buffer argument by now. + */ + bcopy(cdb, &ccb->csio.cdb_io.cdb_bytes, cdb_len); - cam_fill_csio(&ccb->csio, + cam_fill_csio(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, /*flags*/ flags, @@ -2279,6 +2315,21 @@ scsicmd(struct cam_device *device, int a /*sense_len*/ SSD_FULL_SIZE, /*cdb_len*/ cdb_len, /*timeout*/ timeout ? timeout : 5000); + } else { + atacmd_len = 12; + bcopy(atacmd, &ccb->ataio.cmd.command, atacmd_len); + if (need_res) + ccb->ataio.cmd.flags |= CAM_ATAIO_NEEDRESULT; + + cam_fill_ataio(&ccb->ataio, + /*retries*/ retry_count, + /*cbfcnp*/ NULL, + /*flags*/ flags, + /*tag_action*/ 0, + /*data_ptr*/ data_ptr, + /*dxfer_len*/ data_bytes, + /*timeout*/ timeout ? timeout : 5000); + } if (((retval = cam_send_ccb(device, ccb)) < 0) || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { @@ -2296,6 +2347,28 @@ scsicmd(struct cam_device *device, int a goto scsicmd_bailout; } + if (atacmd_len && need_res) { + if (fd_res == 0) { + buff_decode_visit(&ccb->ataio.res.status, 11, resstr, + arg_put, NULL); + fprintf(stdout, "\n"); + } else { + fprintf(stdout, + "%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", + ccb->ataio.res.status, + ccb->ataio.res.error, + ccb->ataio.res.lba_low, + ccb->ataio.res.lba_mid, + ccb->ataio.res.lba_high, + ccb->ataio.res.device, + ccb->ataio.res.lba_low_exp, + ccb->ataio.res.lba_mid_exp, + ccb->ataio.res.lba_high_exp, + ccb->ataio.res.sector_count, + ccb->ataio.res.sector_count_exp); + fflush(stdout); + } + } if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) && (arglist & CAM_ARG_CMD_IN) @@ -4029,8 +4102,9 @@ usage(int verbose) " camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n" " camcontrol modepage [dev_id][generic args] <-m page | -l>\n" " [-P pagectl][-e | -b][-d]\n" -" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n" -" [-i len fmt|-o len fmt [args]]\n" +" camcontrol cmd [dev_id][generic args]\n" +" <-a cmd [args] | -c cmd [args]>\n" +" [-i len fmt|-o len fmt [args]] [-r fmt]\n" " camcontrol debug [-I][-P][-T][-S][-X][-c]\n" " \n" " camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n" From kmacy at FreeBSD.org Fri Sep 4 18:52:27 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Fri Sep 4 18:52:38 2009 Subject: svn commit: r196833 - head/sbin/route Message-ID: <200909041852.n84IqRtF098222@svn.freebsd.org> Author: kmacy Date: Fri Sep 4 18:52:26 2009 New Revision: 196833 URL: http://svn.freebsd.org/changeset/base/196833 Log: remove stale references to RTF_CLONING and RTF_LLINFO MFC after: 3 days Modified: head/sbin/route/route.8 Modified: head/sbin/route/route.8 ============================================================================== --- head/sbin/route/route.8 Fri Sep 4 18:40:03 2009 (r196832) +++ head/sbin/route/route.8 Fri Sep 4 18:52:26 2009 (r196833) @@ -279,7 +279,6 @@ when sending to destinations matched by These flags may be set (or sometimes cleared) by indicating the following corresponding modifiers: .Bd -literal --cloning RTF_CLONING - generates a new route on use -xresolve RTF_XRESOLVE - emit mesg on use (for external lookup) -iface ~RTF_GATEWAY - destination is directly reachable -static RTF_STATIC - manually added route @@ -288,7 +287,6 @@ by indicating the following correspondin -blackhole RTF_BLACKHOLE - silently discard pkts (during updates) -proto1 RTF_PROTO1 - set protocol specific routing flag #1 -proto2 RTF_PROTO2 - set protocol specific routing flag #2 --llinfo RTF_LLINFO - validly translates proto addr to link addr .Ed .Pp The optional modifiers @@ -326,25 +324,6 @@ or .Fl ifa modifiers may be used to determine the interface or interface address. .Pp -The optional -.Fl proxy -modifier specifies that the -.Dv RTF_LLINFO -routing table entry is the -.Dq published (proxy-only) -.Tn ARP -entry, as reported by -.Xr arp 8 . -.Pp -The optional -.Fl genmask -modifier specifies that a cloning mask is present. -This specifies the mask applied when determining if a child route -should be created. -It is only applicable to network routes with the -.Dv RTF_CLONING -flag set. -.Pp All symbolic names specified for a .Ar destination or From jamie at FreeBSD.org Fri Sep 4 19:00:49 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Fri Sep 4 19:01:00 2009 Subject: svn commit: r196835 - head/sys/kern Message-ID: <200909041900.n84J0mx8099967@svn.freebsd.org> Author: jamie Date: Fri Sep 4 19:00:48 2009 New Revision: 196835 URL: http://svn.freebsd.org/changeset/base/196835 Log: Allow a jail's name to be the same as its jid (which is the default if no name is specified), but still disallow other numeric names. Reviewed by: zec Approved by: bz (mentor) MFC after: 3 days Modified: head/sys/kern/kern_jail.c Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Fri Sep 4 18:57:40 2009 (r196834) +++ head/sys/kern/kern_jail.c Fri Sep 4 19:00:48 2009 (r196835) @@ -478,7 +478,7 @@ kern_jail_set(struct thread *td, struct struct vfsoptlist *opts; struct prison *pr, *deadpr, *mypr, *ppr, *tpr; struct vnode *root; - char *domain, *errmsg, *host, *name, *p, *path, *uuid; + char *domain, *errmsg, *host, *name, *namelc, *p, *path, *uuid; #if defined(INET) || defined(INET6) struct prison *tppr; void *op; @@ -907,6 +907,13 @@ kern_jail_set(struct thread *td, struct goto done_unlock_list; } pr = NULL; + namelc = NULL; + if (cuflags == JAIL_CREATE && jid == 0 && name != NULL) { + namelc = strrchr(name, '.'); + jid = strtoul(namelc != NULL ? namelc + 1 : name, &p, 10); + if (*p != '\0') + jid = 0; + } if (jid != 0) { /* * See if a requested jid already exists. There is an @@ -973,17 +980,19 @@ kern_jail_set(struct thread *td, struct * because that is the jail being updated). */ if (name != NULL) { - p = strrchr(name, '.'); - if (p != NULL) { + namelc = strrchr(name, '.'); + if (namelc == NULL) + namelc = name; + else { /* * This is a hierarchical name. Split it into the * parent and child names, and make sure the parent * exists or matches an already found jail. */ - *p = '\0'; + *namelc = '\0'; if (pr != NULL) { - if (strncmp(name, ppr->pr_name, p - name) || - ppr->pr_name[p - name] != '\0') { + if (strncmp(name, ppr->pr_name, namelc - name) + || ppr->pr_name[namelc - name] != '\0') { mtx_unlock(&pr->pr_mtx); error = EINVAL; vfs_opterror(opts, @@ -1000,7 +1009,7 @@ kern_jail_set(struct thread *td, struct } mtx_unlock(&ppr->pr_mtx); } - name = p + 1; + name = ++namelc; } if (name[0] != '\0') { namelen = @@ -1412,9 +1421,11 @@ kern_jail_set(struct thread *td, struct /* Give a default name of the jid. */ if (name[0] == '\0') snprintf(name = numbuf, sizeof(numbuf), "%d", jid); - else if (strtoul(name, &p, 10) != jid && *p == '\0') { + else if (*namelc == '0' || (strtoul(namelc, &p, 10) != jid && + *p == '\0')) { error = EINVAL; - vfs_opterror(opts, "name cannot be numeric"); + vfs_opterror(opts, + "name cannot be numeric (unless it is the jid)"); goto done_deref_locked; } /* From mav at FreeBSD.org Fri Sep 4 19:20:47 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Fri Sep 4 19:20:53 2009 Subject: svn commit: r196837 - head/sys/geom/stripe Message-ID: <200909041920.n84JKlab004085@svn.freebsd.org> Author: mav Date: Fri Sep 4 19:20:46 2009 New Revision: 196837 URL: http://svn.freebsd.org/changeset/base/196837 Log: Remove artificial MAX_IO_SIZE constant, equal to DFLTPHYS * 2. Use MAXPHYS instead. It is NULL change for GENERIC kernel, but allows 'fast' mode to work on systems with increased MAXPHYS. Modified: head/sys/geom/stripe/g_stripe.c Modified: head/sys/geom/stripe/g_stripe.c ============================================================================== --- head/sys/geom/stripe/g_stripe.c Fri Sep 4 19:02:11 2009 (r196836) +++ head/sys/geom/stripe/g_stripe.c Fri Sep 4 19:20:46 2009 (r196837) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include -#define MAX_IO_SIZE (DFLTPHYS * 2) static MALLOC_DEFINE(M_STRIPE, "stripe_data", "GEOM_STRIPE Data"); static uma_zone_t g_stripe_zone; @@ -87,7 +86,7 @@ g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS } SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RW, NULL, 0, g_sysctl_stripe_fast, "I", "Fast, but memory-consuming, mode"); -static u_int g_stripe_maxmem = MAX_IO_SIZE * 100; +static u_int g_stripe_maxmem = MAXPHYS * 100; TUNABLE_INT("kern.geom.stripe.maxmem", &g_stripe_maxmem); SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RD, &g_stripe_maxmem, 0, "Maximum memory that can be allocated in \"fast\" mode (in bytes)"); @@ -125,10 +124,10 @@ static void g_stripe_init(struct g_class *mp __unused) { - g_stripe_zone = uma_zcreate("g_stripe_zone", MAX_IO_SIZE, NULL, NULL, + g_stripe_zone = uma_zcreate("g_stripe_zone", MAXPHYS, NULL, NULL, NULL, NULL, 0, 0); - g_stripe_maxmem -= g_stripe_maxmem % MAX_IO_SIZE; - uma_zone_set_max(g_stripe_zone, g_stripe_maxmem / MAX_IO_SIZE); + g_stripe_maxmem -= g_stripe_maxmem % MAXPHYS; + uma_zone_set_max(g_stripe_zone, g_stripe_maxmem / MAXPHYS); } static void @@ -613,14 +612,14 @@ g_stripe_start(struct bio *bp) * Do use "fast" mode when: * 1. "Fast" mode is ON. * and - * 2. Request size is less than or equal to MAX_IO_SIZE (128kB), + * 2. Request size is less than or equal to MAXPHYS, * which should always be true. * and * 3. Request size is bigger than stripesize * ndisks. If it isn't, * there will be no need to send more than one I/O request to * a provider, so there is nothing to optmize. */ - if (g_stripe_fast && bp->bio_length <= MAX_IO_SIZE && + if (g_stripe_fast && bp->bio_length <= MAXPHYS && bp->bio_length >= stripesize * sc->sc_ndisks) { fast = 1; } From mav at FreeBSD.org Fri Sep 4 19:41:39 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Fri Sep 4 19:41:46 2009 Subject: svn commit: r196831 - head/sbin/camcontrol In-Reply-To: <86iqfytsqe.fsf@srvbsdnanssv.interne.kisoft-services.com> References: <200909041821.n84ILfWo092251@svn.freebsd.org> <86iqfytsqe.fsf@srvbsdnanssv.interne.kisoft-services.com> Message-ID: <4AA16D68.3080908@FreeBSD.org> Eric Masson wrote: > Alexander Motin writes: >> Author: mav >> Date: Fri Sep 4 18:21:40 2009 >> New Revision: 196831 >> URL: http://svn.freebsd.org/changeset/base/196831 >> >> Log: >> Add to `camcontrol cmd` support for sending arbitrary ATA commands. >> >> It could be used for broad range of tasks, such as configuring drive >> power management modes, caching, security and any other features and tasks, >> not supported by existing drivers. > > Like controlling speed of DVD drives like this linux code snippet > (speedcontrol.c) seems to be able to : > http://ubuntuforums.org/archive/index.php/t-592513.html It looks like using SCSI/ATAPI command, not an ATA. So it is supported for long time. But the idea is right, it should be possible to control it from command line. -- Alexander Motin From trasz at FreeBSD.org Fri Sep 4 20:01:17 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Sep 4 20:01:57 2009 Subject: svn commit: r196839 - head/usr.bin/find Message-ID: <200909042001.n84K1HMe010090@svn.freebsd.org> Author: trasz Date: Fri Sep 4 20:01:16 2009 New Revision: 196839 URL: http://svn.freebsd.org/changeset/base/196839 Log: Add NFSv4 ACL support to find(1). Reviewed by: rwatson Modified: head/usr.bin/find/function.c Modified: head/usr.bin/find/function.c ============================================================================== --- head/usr.bin/find/function.c Fri Sep 4 19:59:32 2009 (r196838) +++ head/usr.bin/find/function.c Fri Sep 4 20:01:16 2009 (r196839) @@ -371,38 +371,48 @@ c_mXXdepth(OPTION *option, char ***argvp int f_acl(PLAN *plan __unused, FTSENT *entry) { - int match, entries; - acl_entry_t ae; acl_t facl; + acl_type_t acl_type; + int acl_supported = 0, ret, trivial; if (S_ISLNK(entry->fts_statp->st_mode)) return 0; - if ((match = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED)) <= 0) { - if (match < 0 && errno != EINVAL) - warn("%s", entry->fts_accpath); - else - return 0; + ret = pathconf(entry->fts_accpath, _PC_ACL_NFS4); + if (ret > 0) { + acl_supported = 1; + acl_type = ACL_TYPE_NFS4; + } else if (ret < 0 && errno != EINVAL) { + warn("%s", entry->fts_accpath); + return (0); } - match = 0; - if ((facl = acl_get_file(entry->fts_accpath,ACL_TYPE_ACCESS)) != NULL) { - if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) { - /* - * POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS - * must have at least three entries (owner, group, - * other). - */ - entries = 1; - while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1) { - if (++entries > 3) { - match = 1; - break; - } - } + if (acl_supported == 0) { + ret = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED); + if (ret > 0) { + acl_supported = 1; + acl_type = ACL_TYPE_ACCESS; + } else if (ret < 0 && errno != EINVAL) { + warn("%s", entry->fts_accpath); + return (0); } - acl_free(facl); - } else + } + if (acl_supported == 0) + return (0); + + facl = acl_get_file(entry->fts_accpath, acl_type); + if (facl == NULL) { warn("%s", entry->fts_accpath); - return match; + return (0); + } + ret = acl_is_trivial_np(facl, &trivial); + acl_free(facl); + if (ret) { + warn("%s", entry->fts_accpath); + acl_free(facl); + return (0); + } + if (trivial) + return (0); + return (1); } PLAN * From emss at free.fr Fri Sep 4 20:26:38 2009 From: emss at free.fr (Eric Masson) Date: Fri Sep 4 20:26:44 2009 Subject: svn commit: r196831 - head/sbin/camcontrol In-Reply-To: <4AA16D68.3080908@FreeBSD.org> (Alexander Motin's message of "Fri, 04 Sep 2009 22:41:28 +0300") References: <200909041821.n84ILfWo092251@svn.freebsd.org> <86iqfytsqe.fsf@srvbsdnanssv.interne.kisoft-services.com> <4AA16D68.3080908@FreeBSD.org> Message-ID: <86eiqmtq12.fsf@srvbsdnanssv.interne.kisoft-services.com> Alexander Motin writes: > It looks like using SCSI/ATAPI command, not an ATA. So it is supported > for long time. But the idea is right, it should be possible to control > it from command line. Ok, I'll dig this. atapicam & camcontrol will be my new friends ;) I've been using FreeBSD since 3.0 with scsi storage but never really dug into cam arcanes... Thanks a lot. -- Warning: file "/home/emss/misc/fortune/En_sig.dat" unreadable Warning: file "/home/emss/misc/fortune/Fr_sig.dat" unreadable Doh, I really need to fix the auto sig feature :) From emss at free.fr Fri Sep 4 20:32:11 2009 From: emss at free.fr (Eric Masson) Date: Fri Sep 4 20:32:17 2009 Subject: svn commit: r196831 - head/sbin/camcontrol In-Reply-To: <200909041821.n84ILfWo092251@svn.freebsd.org> (Alexander Motin's message of "Fri, 4 Sep 2009 18:21:41 +0000 (UTC)") References: <200909041821.n84ILfWo092251@svn.freebsd.org> Message-ID: <86iqfytsqe.fsf@srvbsdnanssv.interne.kisoft-services.com> Alexander Motin writes: Hi Alexander, > Author: mav > Date: Fri Sep 4 18:21:40 2009 > New Revision: 196831 > URL: http://svn.freebsd.org/changeset/base/196831 > > Log: > Add to `camcontrol cmd` support for sending arbitrary ATA commands. > > It could be used for broad range of tasks, such as configuring drive > power management modes, caching, security and any other features and tasks, > not supported by existing drivers. Like controlling speed of DVD drives like this linux code snippet (speedcontrol.c) seems to be able to : http://ubuntuforums.org/archive/index.php/t-592513.html Regards -- Ca fait d?j? plusieurs semaines que j"essaie de correspondre par l" interm?diaire d"un groupe de discussion. Ca ne fait que deux jour que je suis parvenu ? exp?dier un message -+- GM in GNU : Patience et longueur de temps.. -+- From jhb at FreeBSD.org Fri Sep 4 21:00:45 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Sep 4 21:00:51 2009 Subject: svn commit: r196840 - head/sys/dev/cxgb Message-ID: <200909042100.n84L0j6Z014735@svn.freebsd.org> Author: jhb Date: Fri Sep 4 21:00:45 2009 New Revision: 196840 URL: http://svn.freebsd.org/changeset/base/196840 Log: Fill the reverse RSS map with 0xff's so that the subsequent loop to calculate the values will work properly. Reviewed by: np MFC after: 1 month Modified: head/sys/dev/cxgb/cxgb_main.c Modified: head/sys/dev/cxgb/cxgb_main.c ============================================================================== --- head/sys/dev/cxgb/cxgb_main.c Fri Sep 4 20:01:16 2009 (r196839) +++ head/sys/dev/cxgb/cxgb_main.c Fri Sep 4 21:00:45 2009 (r196840) @@ -1456,7 +1456,10 @@ setup_rss(adapter_t *adap) rspq_map[i] = nq[0] ? i % nq[0] : 0; rspq_map[i + RSS_TABLE_SIZE / 2] = nq[1] ? i % nq[1] + nq[0] : 0; } + /* Calculate the reverse RSS map table */ + for (i = 0; i < SGE_QSETS; ++i) + adap->rrss_map[i] = 0xff; for (i = 0; i < RSS_TABLE_SIZE; ++i) if (adap->rrss_map[rspq_map[i]] == 0xff) adap->rrss_map[rspq_map[i]] = i; From trasz at FreeBSD.org Fri Sep 4 21:49:38 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Sep 4 21:49:49 2009 Subject: svn commit: r196841 - head/bin/mv Message-ID: <200909042149.n84LnbdE018523@svn.freebsd.org> Author: trasz Date: Fri Sep 4 21:49:37 2009 New Revision: 196841 URL: http://svn.freebsd.org/changeset/base/196841 Log: Add NFSv4 ACL support to mv(1). Reviewed by: rwatson Modified: head/bin/mv/mv.c Modified: head/bin/mv/mv.c ============================================================================== --- head/bin/mv/mv.c Fri Sep 4 21:00:45 2009 (r196840) +++ head/bin/mv/mv.c Fri Sep 4 21:49:37 2009 (r196841) @@ -74,6 +74,8 @@ static int copy(const char *, const char static int do_move(const char *, const char *); static int fastcopy(const char *, const char *, struct stat *); static void usage(void); +static void preserve_fd_acls(int source_fd, int dest_fd, const char *source_path, + const char *dest_path); int main(int argc, char *argv[]) @@ -260,7 +262,6 @@ fastcopy(const char *from, const char *t struct timeval tval[2]; static u_int blen; static char *bp; - acl_t acl; mode_t oldmode; int nread, from_fd, to_fd; @@ -311,23 +312,15 @@ err: if (unlink(to)) sbp->st_mode &= ~(S_ISUID | S_ISGID); } } + if (fchmod(to_fd, sbp->st_mode)) + warn("%s: set mode (was: 0%03o)", to, oldmode); /* * POSIX 1003.2c states that if _POSIX_ACL_EXTENDED is in effect * for dest_file, then its ACLs shall reflect the ACLs of the * source_file. */ - if (fpathconf(to_fd, _PC_ACL_EXTENDED) == 1 && - fpathconf(from_fd, _PC_ACL_EXTENDED) == 1) { - acl = acl_get_fd(from_fd); - if (acl == NULL) - warn("failed to get acl entries while setting %s", - from); - else if (acl_set_fd(to_fd, acl) < 0) - warn("failed to set acl entries for %s", to); - } + preserve_fd_acls(from_fd, to_fd, from, to); (void)close(from_fd); - if (fchmod(to_fd, sbp->st_mode)) - warn("%s: set mode (was: 0%03o)", to, oldmode); /* * XXX * NFS doesn't support chflags; ignore errors unless there's reason @@ -439,6 +432,59 @@ copy(const char *from, const char *to) } static void +preserve_fd_acls(int source_fd, int dest_fd, const char *source_path, + const char *dest_path) +{ + acl_t acl; + acl_type_t acl_type; + int acl_supported = 0, ret, trivial; + + ret = fpathconf(source_fd, _PC_ACL_NFS4); + if (ret > 0 ) { + acl_supported = 1; + acl_type = ACL_TYPE_NFS4; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_NFS4) failed for %s", + source_path); + return; + } + if (acl_supported == 0) { + ret = fpathconf(source_fd, _PC_ACL_EXTENDED); + if (ret > 0 ) { + acl_supported = 1; + acl_type = ACL_TYPE_ACCESS; + } else if (ret < 0 && errno != EINVAL) { + warn("fpathconf(..., _PC_ACL_EXTENDED) failed for %s", + source_path); + return; + } + } + if (acl_supported == 0) + return; + + acl = acl_get_fd_np(source_fd, acl_type); + if (acl == NULL) { + warn("failed to get acl entries for %s", source_path); + return; + } + if (acl_is_trivial_np(acl, &trivial)) { + warn("acl_is_trivial() failed for %s", source_path); + acl_free(acl); + return; + } + if (trivial) { + acl_free(acl); + return; + } + if (acl_set_fd_np(dest_fd, acl, acl_type) < 0) { + warn("failed to set acl entries for %s", dest_path); + acl_free(acl); + return; + } + acl_free(acl); +} + +static void usage(void) { From attilio at freebsd.org Fri Sep 4 21:55:54 2009 From: attilio at freebsd.org (Attilio Rao) Date: Fri Sep 4 21:56:00 2009 Subject: svn commit: r196779 - in head/sys: kern sys In-Reply-To: <20090904.112919.1521002024.imp@bsdimp.com> References: <200909031340.n83Defkv034013@svn.freebsd.org> <20090904.112919.1521002024.imp@bsdimp.com> Message-ID: <3bbf2fe10909041455u552b0dbdm1708ea0a26365149@mail.gmail.com> 2009/9/4 M. Warner Losh : > In message: <200909031340.n83Defkv034013@svn.freebsd.org> > Attilio Rao writes: > : Modified: head/sys/sys/bus.h > : ============================================================================== > : --- head/sys/sys/bus.h Thu Sep 3 12:41:00 2009 (r196778) > : +++ head/sys/sys/bus.h Thu Sep 3 13:40:41 2009 (r196779) > : @@ -52,8 +52,11 @@ struct u_businfo { > : typedef enum device_state { > : DS_NOTPRESENT, /**< @brief not probed or probe failed */ > : DS_ALIVE, /**< @brief probe succeeded */ > : + DS_ATTACHING, /**< @brief attaching is in progress */ > : DS_ATTACHED, /**< @brief attach method called */ > : - DS_BUSY /**< @brief device is open */ > : + DS_BUSY, /**< @brief device is open */ > : + DS_DETACHING /**< @brief detaching is in progress */ > : + > : } device_state_t; > > device_state_t is exported to userland via devctl. Well, that's not > entirely true... It isn't used EXACTLY, but there's this in > devinfo.h: > > /* > * State of the device. > */ > /* XXX not sure if I want a copy here, or expose sys/bus.h */ > typedef enum devinfo_state { > DIS_NOTPRESENT, /* not probed or probe failed */ > DIS_ALIVE, /* probe succeeded */ > DIS_ATTACHED, /* attach method called */ > DIS_BUSY /* device is open */ > } devinfo_state_t; > > which is why devinfo is broken. I think the right fix here is to maintain in sync devinfo.h and bus.h definition by just having one. I see that the devices states are redefined in devinfo.h in order to avoid namespace pollution and this is a good point. What I propose is to add a new header (_bus.h, to be included in both bus.h and devinfo.h) which just containst the device states. > Also, DS_BUSY is used in many drivers to PREVENT detaching. So the > change is bad from that point of view, since DS_DETACHING is now > > DS_BUSY. There's really a partial ordering relationship now where > before there was a total ordering (DS_BUSY is > DS_ATTACHED and > DS_DETACHING is > DS_ATTACH, but DS_DETACHING isn't > DS_BUSY and > DS_BUSY isn't > DS_DETACHING). I think that you've destroyed > information here by unconditionally setting it: > > - if ((error = DEVICE_DETACH(dev)) != 0) > + dev->state = DS_DETACHING; > + if ((error = DEVICE_DETACH(dev)) != 0) { > + KASSERT(dev->state == DS_DETACHING, > + ("%s: %p device state must not been changing", __func__, > + dev)); > + dev->state = DS_ATTACHED; > return (error); > + } > + KASSERT(dev->state == DS_DETACHING, > + ("%s: %p device state must not been changing", __func__, dev)); > > And this looks racy between the check earlier and this setting. > Properly locked, this wouldn't destroy information... Sorry, I really don't understand what point are you making here, and what the scaring words of "destroying", "racy", etc. means. Can you explain better that part? > At the very least cardbus/cardbus.c and pccard/pccard.c need to be > looked at since they both have code that looks like: > > for (tmp = 0; tmp < numdevs; tmp++) { > struct cardbus_devinfo *dinfo = device_get_ivars(devlist[tmp]); > int status = device_get_state(devlist[tmp]); > > if (dinfo->pci.cfg.dev != devlist[tmp]) > device_printf(cbdev, "devinfo dev mismatch\n"); > if (status == DS_ATTACHED || status == DS_BUSY) > device_detach(devlist[tmp]); > cardbus_release_all_resources(cbdev, dinfo); > cardbus_device_destroy(dinfo); > device_delete_child(cbdev, devlist[tmp]); > pci_freecfg((struct pci_devinfo *)dinfo); > } > > which does ignore errors returned by device_detach for the DS_BUSY > case because there's not currently a good way to tell device_detach > that it *MUST* detach the device *NOW* without any possibility of veto > by the driver. The above code also isn't DS_DETACHING aware, and may > be wrong in the face of this new state. How DS_DETACHING can cause problems here? device_detach() simply won't run if the state is DS_DETACHING as expected (another thread is alredy detaching and there is no need for it to detach). Also, please note that in this case, for the state == DS_BUSY he device_detach() won't do anything. You can't simply skip the return value and anything else, but the reality is still the operation won't happen. > Of course, grepping the tree does show one or two places where DS_BUSY > is used inappropriately: > > rp.c: > > static int > rp_pcidetach(device_t dev) > { > CONTROLLER_t *ctlp; > > if (device_get_state(dev) == DS_BUSY) > return (EBUSY); > > is one example. The above check should just be removed (ditto for its > SHUTDOWN) routine. > > So I think we should fix rp.c, but we need to talk through this change > a little more. I'm surprised I wasn't even pinged about it, since it > hits code that I maintain and a simple grep would have found... Still, I don't see a problem with the codes you mentioned (if not in the consumers, which were alredy "broken" before this change and which situation is not worse now), unless the devinfo breakage. Attilio -- Peace can only be achieved by understanding - A. Einstein From brooks at FreeBSD.org Fri Sep 4 22:15:26 2009 From: brooks at FreeBSD.org (Brooks Davis) Date: Fri Sep 4 22:15:33 2009 Subject: svn commit: r195843 - in head: lib/libkvm sys/kern sys/sys In-Reply-To: <20090829201228.00005860@unknown> References: <200907241503.n6OF3ATP013228@svn.freebsd.org> <20090829201228.00005860@unknown> Message-ID: <20090904221432.GC82231@lor.one-eyed-alien.net> On Sat, Aug 29, 2009 at 08:12:28PM +0100, Bruce Cran wrote: > On Fri, 24 Jul 2009 15:03:10 +0000 (UTC) > Brooks Davis wrote: > > > Author: brooks > > Date: Fri Jul 24 15:03:10 2009 > > New Revision: 195843 > > URL: http://svn.freebsd.org/changeset/base/195843 > > > > Log: > > Revert the changes to struct kinfo_proc in r194498. Instead, fill > > in up to 16 (KI_NGROUPS) values and steal a bit from ki_cr_flags > > (all bits currently unused) to indicate overflow with the new flag > > KI_CRF_GRP_OVERFLOW. > > > > This fixes procstat -s. > > > > Approved by: re (kib) > > Hi Brooks, > > This checkin appears to have broken crash dump support: the bcopy in > kvm_proc.c crashes when running "ps -ax -M /var/crash/vmcore.x > -N /boot/kernel/kernel", apparently because ucred.cr_groups isn't valid. > Does it need converted using KVM_READ first? Sorry for the delay, I believe you are correct we need to use kvm_read here instead of the bcopy. Do you still have a core handy you can test a patch against? The following should do it. -- Brooks Index: lib/libkvm/kvm_proc.c =================================================================== --- lib/libkvm/kvm_proc.c (revision 196736) +++ lib/libkvm/kvm_proc.c (working copy) @@ -151,7 +151,7 @@ kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; } kp->ki_ngroups = ucred.cr_ngroups; - bcopy(ucred.cr_groups, kp->ki_groups, + kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups, kp->ki_ngroups * sizeof(gid_t)); kp->ki_uid = ucred.cr_uid; if (ucred.cr_prison != NULL) { -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090904/7d4315e9/attachment.pgp From sam at FreeBSD.org Fri Sep 4 22:34:58 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Sep 4 22:35:03 2009 Subject: svn commit: r196842 - head/sys/dev/mwl Message-ID: <200909042234.n84MYvcJ022111@svn.freebsd.org> Author: sam Date: Fri Sep 4 22:34:57 2009 New Revision: 196842 URL: http://svn.freebsd.org/changeset/base/196842 Log: must also plumb static wep keys to the local sta db in sta mode; not sure when this became necessary and might be caused by some missing code to do auto-configuration of DWDS usage Noticed by: Felix Feng Modified: head/sys/dev/mwl/if_mwl.c Modified: head/sys/dev/mwl/if_mwl.c ============================================================================== --- head/sys/dev/mwl/if_mwl.c Fri Sep 4 21:49:37 2009 (r196841) +++ head/sys/dev/mwl/if_mwl.c Fri Sep 4 22:34:57 2009 (r196842) @@ -1738,6 +1738,10 @@ mwl_key_set(struct ieee80211vap *vap, co * WEP keys when the sta reaches AUTH state. */ macaddr = vap->iv_bss->ni_bssid; + if ((k->wk_flags & IEEE80211_KEY_GROUP) == 0) { + /* XXX plumb to local sta db too for static key wep */ + mwl_hal_keyset(hvap, &hk, vap->iv_myaddr); + } } else if (vap->iv_opmode == IEEE80211_M_WDS && vap->iv_state != IEEE80211_S_RUN) { /* From jfv at FreeBSD.org Fri Sep 4 22:45:08 2009 From: jfv at FreeBSD.org (Jack F Vogel) Date: Fri Sep 4 22:45:19 2009 Subject: svn commit: r196844 - head/sys/dev/ixgbe Message-ID: <200909042245.n84Mj709022969@svn.freebsd.org> Author: jfv Date: Fri Sep 4 22:45:07 2009 New Revision: 196844 URL: http://svn.freebsd.org/changeset/base/196844 Log: If an interface is brought up with no cable it will experience watchdog resets, this is due to a missing check for link in the new multiqueue start code. MFC: 3 days Modified: head/sys/dev/ixgbe/ixgbe.c Modified: head/sys/dev/ixgbe/ixgbe.c ============================================================================== --- head/sys/dev/ixgbe/ixgbe.c Fri Sep 4 22:37:03 2009 (r196843) +++ head/sys/dev/ixgbe/ixgbe.c Fri Sep 4 22:45:07 2009 (r196844) @@ -759,7 +759,8 @@ ixgbe_mq_start_locked(struct ifnet *ifp, struct mbuf *next; int err = 0; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + if (((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) || + (!adapter->link_active)) { err = drbr_enqueue(ifp, txr->br, m); return (err); } From bms at incunabulum.net Sat Sep 5 00:05:04 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Sat Sep 5 00:05:10 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: References: <200909032110.n83LAvUF044731@svn.freebsd.org> <4AA09B41.3040103@incunabulum.net> Message-ID: <4AA1AB29.9030704@incunabulum.net> Robert Watson wrote: > For sysctls, explicit versioning doesn't help too much -- what I've > been pondering for another structure was including spares and having a > capabilities field in the structure where flags are set when fields > are known by the kernel. That way userspace can tell if the kernel > knows about the field it cares about and therefore whether they're > worth looking at. One thing that Thrift did was to explicitly all number fields in their implementation of RPC. This is useful, because if anything changes over time, implementations can be updated to keep track of that. Whilst I agree that it's unlikely 'struct arpstat' would change, if it did, it would be great to have a length field, at a minimum, in front. sysctl can determine size at runtime, however, kmem interfaces cannot. That's the only real reason why I'd nudge about it. :-) For igmpstat, at least, the SSM drop adds a LOT of state to the network stack which wasn't there before, so having an explicit version field is warranted for backwards compatibility (and this is something Robert chewed me out about many months ago). Much respect, big yo'self up yo... From mav at FreeBSD.org Sat Sep 5 06:16:52 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sat Sep 5 06:17:04 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <200909031602.01222.jhb@freebsd.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <20090903114121.C20031@pooker.samsco.org> <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> <200909031602.01222.jhb@freebsd.org> Message-ID: <4AA20249.9000301@FreeBSD.org> John Baldwin wrote: > On Thursday 03 September 2009 3:45:07 pm Ivan Voras wrote: >> But ciss doesn't reference it at all so either it deviously assumes it >> or is independent of it. > > Actually, it may be much worse, it may be that the author of ciss(4) new that > ciss(4)'s largest supported I/O size was larger than 128k so they didn't > bother handling the limit at all giving the false impression the hardware has > no limit. In cases of ATA and CAM infrastructures it was is so, that if driver does not sets max_iosize or maxio respectively, it uses DFLTPHYS. So problem is only about non-ATA/CAM RAIDs or cases where wrong value could be specified explicitly. ciss(4) driver was explicitly limited to 64K, until somebody could review it's capabilities. -- Alexander Motin From imp at FreeBSD.org Sat Sep 5 08:08:14 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Sep 5 08:08:26 2009 Subject: svn commit: r196856 - head Message-ID: <200909050808.n8588EEO041434@svn.freebsd.org> Author: imp Date: Sat Sep 5 08:08:14 2009 New Revision: 196856 URL: http://svn.freebsd.org/changeset/base/196856 Log: Note migration of tunable from hw.bus.devctl_disable to hw.bus.devctl_queue. The sysctl interface provides legacys upport for the latter sysctl, but the tunable support was removed. MFC after: 1 day Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Sep 5 08:03:29 2009 (r196855) +++ head/UPDATING Sat Sep 5 08:08:14 2009 (r196856) @@ -22,6 +22,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20090825: + The old tunable hw.bus.devctl_disable has been superseded by + hw.bus.devctl_queue. hw.bus.devctl_disable=1 in loader.conf should be + replaced by hw.bus.devctl_queue=0. The default for this new tunable + is 1000. + 20090813: Remove the option STOP_NMI. The default action is now to use NMI only for KDB via the newly introduced function stop_cpus_hard() and From imp at FreeBSD.org Sat Sep 5 08:09:36 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Sep 5 08:09:42 2009 Subject: svn commit: r196857 - head Message-ID: <200909050809.n8589a9o041494@svn.freebsd.org> Author: imp Date: Sat Sep 5 08:09:35 2009 New Revision: 196857 URL: http://svn.freebsd.org/changeset/base/196857 Log: Go ahead and mention the CVS branch name as well as the svn branch name. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Sep 5 08:08:14 2009 (r196856) +++ head/UPDATING Sat Sep 5 08:09:35 2009 (r196857) @@ -34,7 +34,8 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. maintain stop_cpus() to just use a normal IPI_STOP on ia32 and amd64. 20090803: - stable/8 branch created in subversion. + The stable/8 branch created in subversion. This corresponds to the + RELENG_8 branch in CVS. 20090719: Bump the shared library version numbers for all libraries that do not From imp at FreeBSD.org Sat Sep 5 08:38:25 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Sep 5 08:38:37 2009 Subject: svn commit: r196858 - head/sys/dev/rp Message-ID: <200909050838.n858cP6f042100@svn.freebsd.org> Author: imp Date: Sat Sep 5 08:38:25 2009 New Revision: 196858 URL: http://svn.freebsd.org/changeset/base/196858 Log: These checks against BUSY aren't needed: the newbus layer does this already with the appropriate locks held... There's no need to do it here, so just delete the checks. Modified: head/sys/dev/rp/rp_pci.c Modified: head/sys/dev/rp/rp_pci.c ============================================================================== --- head/sys/dev/rp/rp_pci.c Sat Sep 5 08:09:35 2009 (r196857) +++ head/sys/dev/rp/rp_pci.c Sat Sep 5 08:38:25 2009 (r196858) @@ -225,11 +225,7 @@ rp_pcidetach(device_t dev) { CONTROLLER_t *ctlp; - if (device_get_state(dev) == DS_BUSY) - return (EBUSY); - ctlp = device_get_softc(dev); - rp_pcireleaseresource(ctlp); return (0); @@ -240,11 +236,7 @@ rp_pcishutdown(device_t dev) { CONTROLLER_t *ctlp; - if (device_get_state(dev) == DS_BUSY) - return (EBUSY); - ctlp = device_get_softc(dev); - rp_pcireleaseresource(ctlp); return (0); From pjd at FreeBSD.org Sat Sep 5 11:07:46 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sat Sep 5 11:07:58 2009 Subject: svn commit: r196797 - in head: sys/net sys/netinet usr.bin/netstat In-Reply-To: <20090904171511.Q68375@maildrop.int.zabbadoz.net> References: <200909032110.n83LAvUF044731@svn.freebsd.org> <4AA09B41.3040103@incunabulum.net> <3C6607F2-D517-41EC-8681-33236EC6D20F@FreeBSD.org> <20090904171511.Q68375@maildrop.int.zabbadoz.net> Message-ID: <20090905110740.GD1665@garage.freebsd.pl> On Fri, Sep 04, 2009 at 05:19:12PM +0000, Bjoern A. Zeeb wrote: > On Fri, 4 Sep 2009, George Neville-Neil wrote: > > Hi, > > >On Sep 4, 2009, at 00:44 , Bruce Simpson wrote: > > > >>George V. Neville-Neil wrote: > >>>Author: gnn > >>>Date: Thu Sep 3 21:10:57 2009 > >>>New Revision: 196797 > >>>URL: http://svn.freebsd.org/changeset/base/196797 > >>> > >>>Log: > >>>Add ARP statistics to the kernel and netstat. > >>> > >> > >>Thanks very much for this change. > >>Any chance this struct can get explicitly versioned (i.e. as for struct > >>igmpstat) as it is a new struct? > >> > > > >bz@ and I will likely be tweaking this over time, so we can probably do > >that. > > I am not entirely sure what "versioning" that struct would help? > > ARP is from the early 80s, we've got 8 variables and 4 spares and > I cannot forsee any major rewrite of the code or the protocoll to > gather a lot more stats anymore. If there is a way to version those structures it will be good to do it even if it isn't going to change in the future. This way it can be used as an example for others to follow. -- Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090905/2831f102/attachment.pgp From kib at FreeBSD.org Sat Sep 5 13:32:05 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sat Sep 5 13:32:12 2009 Subject: svn commit: r196861 - head/lib/libc/stdlib Message-ID: <200909051332.n85DW5Q1054296@svn.freebsd.org> Author: kib Date: Sat Sep 5 13:32:05 2009 New Revision: 196861 URL: http://svn.freebsd.org/changeset/base/196861 Log: Handle zero size for posix_memalign. Return NULL or unique address according to the 'V' option. PR: standards/138307 MFC after: 1 week Modified: head/lib/libc/stdlib/malloc.c Modified: head/lib/libc/stdlib/malloc.c ============================================================================== --- head/lib/libc/stdlib/malloc.c Sat Sep 5 13:31:16 2009 (r196860) +++ head/lib/libc/stdlib/malloc.c Sat Sep 5 13:32:05 2009 (r196861) @@ -5320,6 +5320,15 @@ posix_memalign(void **memptr, size_t ali goto RETURN; } + if (size == 0) { + if (opt_sysv == false) + size = 1; + else { + result = NULL; + ret = 0; + goto RETURN; + } + } result = ipalloc(alignment, size); } From trasz at FreeBSD.org Sat Sep 5 15:08:59 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sat Sep 5 15:09:04 2009 Subject: svn commit: r196863 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909051508.n85F8xnN056719@svn.freebsd.org> Author: trasz Date: Sat Sep 5 15:08:58 2009 New Revision: 196863 URL: http://svn.freebsd.org/changeset/base/196863 Log: Improve wording. Discussed with: pjd, cperciva, rink, wkoszek and des, in order of appearance. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Sep 5 15:01:56 2009 (r196862) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Sep 5 15:08:58 2009 (r196863) @@ -3557,15 +3557,19 @@ arc_init(void) #ifdef __i386__ if (prefetch_tunable_set == 0) { - printf("ZFS NOTICE: prefetch is disabled by default on i386" - " - add enable to tunable to change.\n" ); + printf("ZFS NOTICE: Prefetch is disabled by default on i386 " + "-- to enable,\n"); + printf(" add \"vfs.zfs.prefetch_disable=0\" " + "to /boot/loader.conf.\n"); zfs_prefetch_disable=1; } #else if ((((uint64_t)physmem * PAGESIZE) < (1ULL << 32)) && prefetch_tunable_set == 0) { - printf("ZFS NOTICE: system has less than 4GB and prefetch enable is not set" - "... disabling.\n"); + printf("ZFS NOTICE: Prefetch is disabled by default if less " + "than 4 GB of RAM is present;\n" + " to enable, add \"vfs.zfs.prefetch_disable=0\" " + "to /boot/loader.conf.\n"); zfs_prefetch_disable=1; } #endif From qingli at FreeBSD.org Sat Sep 5 16:43:17 2009 From: qingli at FreeBSD.org (Qing Li) Date: Sat Sep 5 16:43:29 2009 Subject: svn commit: r196864 - in head/sys: net netinet6 Message-ID: <200909051643.n85GhHkJ058525@svn.freebsd.org> Author: qingli Date: Sat Sep 5 16:43:16 2009 New Revision: 196864 URL: http://svn.freebsd.org/changeset/base/196864 Log: This patch fixes the following issues: - Interface link-local address is not reachable within the node that owns the interface, this is due to the mismatch in address scope as the result of the installed interface address loopback route. Therefore for each interface address loopback route, the rt_gateway field (of AF_LINK type) will be used to track which interface a given address belongs to. This will aid the address source to use the proper interface for address scope/zone validation. - The loopback address is not reachable. The root cause is the same as the above. - Empty nd6 entries are created for the IPv6 loopback addresses only for validation reason. Doing so will eliminate as much of the special case (loopback addresses) handling code as possible, however, these empty nd6 entries should not be returned to the userland applications such as the "ndp" command. Since both of the above issues contain common files, these files are committed together. Reviewed by: bz MFC after: immediately Modified: head/sys/net/if_llatbl.c head/sys/netinet6/in6.c head/sys/netinet6/in6_src.c head/sys/netinet6/ip6_output.c Modified: head/sys/net/if_llatbl.c ============================================================================== --- head/sys/net/if_llatbl.c Sat Sep 5 15:08:58 2009 (r196863) +++ head/sys/net/if_llatbl.c Sat Sep 5 16:43:16 2009 (r196864) @@ -263,6 +263,15 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl->sdl_index); return EINVAL; } + if (ifp->if_flags & IFF_LOOPBACK) { + struct ifaddr *ia; + ia = ifa_ifwithaddr(dst); + if (ia != NULL) { + ifp = ia->ifa_ifp; + ifa_free(ia); + } else + return EINVAL; + } switch (rtm->rtm_type) { case RTM_ADD: Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Sat Sep 5 15:08:58 2009 (r196863) +++ head/sys/netinet6/in6.c Sat Sep 5 16:43:16 2009 (r196864) @@ -1201,8 +1201,8 @@ in6_purgeaddr(struct ifaddr *ifa) bzero(&null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; - null_sdl.sdl_type = V_loif->if_type; - null_sdl.sdl_index = V_loif->if_index; + null_sdl.sdl_type = ia->ia_ifp->if_type; + null_sdl.sdl_index = ia->ia_ifp->if_index; bzero(&info, sizeof(info)); info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr; @@ -1782,9 +1782,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 if (error == 0 && rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type = - rt->rt_ifp->if_type; + ifp->if_type; ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index = - rt->rt_ifp->if_index; + ifp->if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) @@ -2495,6 +2495,9 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; + if (ifp->if_flags & IFF_LOOPBACK) + return 0; + LLTABLE_LOCK_ASSERT(); error = 0; Modified: head/sys/netinet6/in6_src.c ============================================================================== --- head/sys/netinet6/in6_src.c Sat Sep 5 15:08:58 2009 (r196863) +++ head/sys/netinet6/in6_src.c Sat Sep 5 16:43:16 2009 (r196864) @@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #ifdef RADIX_MPATH @@ -697,8 +698,25 @@ selectroute(struct sockaddr_in6 *dstsock if (error == EHOSTUNREACH) V_ip6stat.ip6s_noroute++; - if (retifp != NULL) + if (retifp != NULL) { *retifp = ifp; + + /* + * Adjust the "outgoing" interface. If we're going to loop + * the packet back to ourselves, the ifp would be the loopback + * interface. However, we'd rather know the interface associated + * to the destination address (which should probably be one of + * our own addresses.) + */ + if (rt) { + if ((rt->rt_ifp->if_flags & IFF_LOOPBACK) && + (rt->rt_gateway->sa_family == AF_LINK)) + *retifp = + ifnet_byindex(((struct sockaddr_dl *) + rt->rt_gateway)->sdl_index); + } + } + if (retrt != NULL) *retrt = rt; /* rt may be NULL */ @@ -750,16 +768,6 @@ in6_selectif(struct sockaddr_in6 *dstsoc return (flags); } - /* - * Adjust the "outgoing" interface. If we're going to loop the packet - * back to ourselves, the ifp would be the loopback interface. - * However, we'd rather know the interface associated to the - * destination address (which should probably be one of our own - * addresses.) - */ - if (rt && rt->rt_ifa && rt->rt_ifa->ifa_ifp) - *retifp = rt->rt_ifa->ifa_ifp; - if (ro == &sro && rt && rt == sro.ro_rt) RTFREE(rt); return (0); Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Sat Sep 5 15:08:58 2009 (r196863) +++ head/sys/netinet6/ip6_output.c Sat Sep 5 16:43:16 2009 (r196864) @@ -602,15 +602,12 @@ again: rt->rt_use++; } + /* * The outgoing interface must be in the zone of source and - * destination addresses. We should use ia_ifp to support the - * case of sending packets to an address of our own. + * destination addresses. */ - if (ia != NULL && ia->ia_ifp) - origifp = ia->ia_ifp; - else - origifp = ifp; + origifp = ifp; src0 = ip6->ip6_src; if (in6_setscope(&src0, origifp, &zone)) @@ -634,6 +631,12 @@ again: goto badscope; } + /* We should use ia_ifp to support the case of + * sending packets to an address of our own. + */ + if (ia != NULL && ia->ia_ifp) + ifp = ia->ia_ifp; + /* scope check is done. */ goto routefound; From qingli at FreeBSD.org Sat Sep 5 16:50:56 2009 From: qingli at FreeBSD.org (Qing Li) Date: Sat Sep 5 16:51:01 2009 Subject: svn commit: r196865 - head/sys/netinet6 Message-ID: <200909051650.n85GotlE058713@svn.freebsd.org> Author: qingli Date: Sat Sep 5 16:50:55 2009 New Revision: 196865 URL: http://svn.freebsd.org/changeset/base/196865 Log: This patch fixes an address scope violation. Considering the scenario where an anycast address is assigned on one interface, and a global address with the same scope is assigned on another interface. In other words, the interface owns the anycast address has only the link-local address as one other address. Without this patch, "ping6" the anycast address from another station will observe the source address of the returned ICMP6 echo reply has the link-local address, not the global address that exists on the other interface in the same node. Reviewed by: bz MFC after: immediately Modified: head/sys/netinet6/icmp6.c Modified: head/sys/netinet6/icmp6.c ============================================================================== --- head/sys/netinet6/icmp6.c Sat Sep 5 16:43:16 2009 (r196864) +++ head/sys/netinet6/icmp6.c Sat Sep 5 16:50:55 2009 (r196865) @@ -2170,6 +2170,10 @@ icmp6_reflect(struct mbuf *m, size_t off } } + if ((srcp != NULL) && + (in6_addrscope(srcp) != in6_addrscope(&ip6->ip6_src))) + srcp = NULL; + if (srcp == NULL) { int e; struct sockaddr_in6 sin6; From bz at FreeBSD.org Sat Sep 5 16:51:51 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Sat Sep 5 16:52:03 2009 Subject: svn commit: r196866 - head/usr.sbin/ndp Message-ID: <200909051651.n85GppUJ058766@svn.freebsd.org> Author: bz Date: Sat Sep 5 16:51:51 2009 New Revision: 196866 URL: http://svn.freebsd.org/changeset/base/196866 Log: In the NEXTADDR macro use SA_SIZE() rather than directly using sizeof(), as introduced in r186119, for advancing the current position into the buffer. See comment in net/route.h for a description of the difference. This makes ndp -s work again. Reviewed by: qingli X-MFC after: now Modified: head/usr.sbin/ndp/ndp.c Modified: head/usr.sbin/ndp/ndp.c ============================================================================== --- head/usr.sbin/ndp/ndp.c Sat Sep 5 16:50:55 2009 (r196865) +++ head/usr.sbin/ndp/ndp.c Sat Sep 5 16:51:51 2009 (r196866) @@ -116,7 +116,7 @@ #define NEXTADDR(w, s) \ if (rtm->rtm_addrs & (w)) { \ - bcopy((char *)&s, cp, sizeof(s)); cp += sizeof(s);} + bcopy((char *)&s, cp, sizeof(s)); cp += SA_SIZE(&s);} static pid_t pid; From scottl at samsco.org Sat Sep 5 19:05:18 2009 From: scottl at samsco.org (Scott Long) Date: Sat Sep 5 19:05:28 2009 Subject: svn commit: r196777 - head/sys/dev/ahci In-Reply-To: <4AA20249.9000301@FreeBSD.org> References: <200909031237.n83CbIgk032551@svn.freebsd.org> <20090903114121.C20031@pooker.samsco.org> <9bbcef730909031245o7c380925sd29b2cc976c4d7dd@mail.gmail.com> <200909031602.01222.jhb@freebsd.org> <4AA20249.9000301@FreeBSD.org> Message-ID: On Sep 5, 2009, at 12:16 AM, Alexander Motin wrote: > John Baldwin wrote: >> On Thursday 03 September 2009 3:45:07 pm Ivan Voras wrote: >>> But ciss doesn't reference it at all so either it deviously >>> assumes it >>> or is independent of it. >> >> Actually, it may be much worse, it may be that the author of ciss >> (4) new that >> ciss(4)'s largest supported I/O size was larger than 128k so they >> didn't >> bother handling the limit at all giving the false impression the >> hardware has >> no limit. > > In cases of ATA and CAM infrastructures it was is so, that if driver > does not sets max_iosize or maxio respectively, it uses DFLTPHYS. So > problem is only about non-ATA/CAM RAIDs or cases where wrong value > could > be specified explicitly. > > ciss(4) driver was explicitly limited to 64K, until somebody could > review it's capabilities. > Right, but I don't want people blindly changing this in any of the CAM drivers without understanding what is going on. Also, there are plenty of non-CAM block drivers that haven't been audited very well yet, if at all. Scott From qingli at FreeBSD.org Sat Sep 5 20:24:38 2009 From: qingli at FreeBSD.org (Qing Li) Date: Sat Sep 5 20:24:44 2009 Subject: svn commit: r196871 - in head/sys: net netinet6 Message-ID: <200909052024.n85KOcuh063182@svn.freebsd.org> Author: qingli Date: Sat Sep 5 20:24:37 2009 New Revision: 196871 URL: http://svn.freebsd.org/changeset/base/196871 Log: The addresses that are assigned to the loopback interface should be part of the kernel routing table. Reviewed by: bz MFC after: immediately Modified: head/sys/net/if_llatbl.c head/sys/netinet6/in6.c Modified: head/sys/net/if_llatbl.c ============================================================================== --- head/sys/net/if_llatbl.c Sat Sep 5 18:44:36 2009 (r196870) +++ head/sys/net/if_llatbl.c Sat Sep 5 20:24:37 2009 (r196871) @@ -263,15 +263,6 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl->sdl_index); return EINVAL; } - if (ifp->if_flags & IFF_LOOPBACK) { - struct ifaddr *ia; - ia = ifa_ifwithaddr(dst); - if (ia != NULL) { - ifp = ia->ifa_ifp; - ifa_free(ia); - } else - return EINVAL; - } switch (rtm->rtm_type) { case RTM_ADD: Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Sat Sep 5 18:44:36 2009 (r196870) +++ head/sys/netinet6/in6.c Sat Sep 5 20:24:37 2009 (r196871) @@ -1192,9 +1192,10 @@ in6_purgeaddr(struct ifaddr *ifa) /* * Remove the loopback route to the interface address. - * The check for the current setting of "nd6_useloopback" is not needed. + * The check for the current setting of "nd6_useloopback" + * is not needed. */ - if (!(ia->ia_ifp->if_flags & IFF_LOOPBACK)) { + { struct rt_addrinfo info; struct sockaddr_dl null_sdl; @@ -1767,7 +1768,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 /* * add a loopback route to self */ - if (V_nd6_useloopback && !(ifp->if_flags & IFF_LOOPBACK)) { + if (!(ia->ia_flags & IFA_ROUTE) + && (V_nd6_useloopback + || (ifp->if_flags & IFF_LOOPBACK))) { struct rt_addrinfo info; struct rtentry *rt = NULL; static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; @@ -1788,7 +1791,7 @@ in6_ifinit(struct ifnet *ifp, struct in6 RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) - log(LOG_INFO, "in6_ifinit: insertion failed\n"); + log(LOG_INFO, "in6_ifinit: error = %d, insertion failed\n", error); } /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */ From bruce at cran.org.uk Sun Sep 6 03:47:06 2009 From: bruce at cran.org.uk (Bruce Cran) Date: Sun Sep 6 03:47:17 2009 Subject: svn commit: r195843 - in head: lib/libkvm sys/kern sys/sys In-Reply-To: <20090904221432.GC82231@lor.one-eyed-alien.net> References: <200907241503.n6OF3ATP013228@svn.freebsd.org> <20090829201228.00005860@unknown> <20090904221432.GC82231@lor.one-eyed-alien.net> Message-ID: <20090906044700.5208ba62@gluon.draftnet> On Fri, 4 Sep 2009 17:14:32 -0500 Brooks Davis wrote: > On Sat, Aug 29, 2009 at 08:12:28PM +0100, Bruce Cran wrote: > > On Fri, 24 Jul 2009 15:03:10 +0000 (UTC) > > Brooks Davis wrote: > > > > > Author: brooks > > > Date: Fri Jul 24 15:03:10 2009 > > > New Revision: 195843 > > > URL: http://svn.freebsd.org/changeset/base/195843 > > > > > > Log: > > > Revert the changes to struct kinfo_proc in r194498. Instead, > > > fill in up to 16 (KI_NGROUPS) values and steal a bit from > > > ki_cr_flags (all bits currently unused) to indicate overflow with > > > the new flag KI_CRF_GRP_OVERFLOW. > > > > > > This fixes procstat -s. > > > > > > Approved by: re (kib) > > > > Hi Brooks, > > > > This checkin appears to have broken crash dump support: the bcopy in > > kvm_proc.c crashes when running "ps -ax -M /var/crash/vmcore.x > > -N /boot/kernel/kernel", apparently because ucred.cr_groups isn't > > valid. Does it need converted using KVM_READ first? > > Sorry for the delay, I believe you are correct we need to use kvm_read > here instead of the bcopy. Do you still have a core handy you can > test a patch against? The following should do it. The patch has fixed the crash, and data is now returned too. -- Bruce From pjd at FreeBSD.org Sun Sep 6 06:48:50 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 06:49:03 2009 Subject: svn commit: r196877 - head/sbin/geom/core Message-ID: <200909060648.n866mooB075520@svn.freebsd.org> Author: pjd Date: Sun Sep 6 06:48:50 2009 New Revision: 196877 URL: http://svn.freebsd.org/changeset/base/196877 Log: For any given subcommand allow to specify multi-line usage (separated by \n). Submitted by: Mel Flynn Modified: head/sbin/geom/core/geom.c Modified: head/sbin/geom/core/geom.c ============================================================================== --- head/sbin/geom/core/geom.c Sun Sep 6 06:05:23 2009 (r196876) +++ head/sbin/geom/core/geom.c Sun Sep 6 06:48:50 2009 (r196877) @@ -98,11 +98,21 @@ usage_command(struct g_command *cmd, con struct g_option *opt; unsigned i; - fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); if (cmd->gc_usage != NULL) { - fprintf(stderr, " %s\n", cmd->gc_usage); + char *pos, *ptr, *sptr; + + sptr = ptr = strdup(cmd->gc_usage); + while ((pos = strsep(&ptr, "\n")) != NULL) { + if (*pos == '\0') + continue; + fprintf(stderr, "%s %s %s %s\n", prefix, comm, + cmd->gc_name, pos); + } + free(sptr); return; } + + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) fprintf(stderr, " [-v]"); for (i = 0; ; i++) { From pjd at FreeBSD.org Sun Sep 6 06:49:59 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 06:50:10 2009 Subject: svn commit: r196878 - head/sbin/geom/core Message-ID: <200909060649.n866nxFC075586@svn.freebsd.org> Author: pjd Date: Sun Sep 6 06:49:59 2009 New Revision: 196878 URL: http://svn.freebsd.org/changeset/base/196878 Log: Update copyright years. Modified: head/sbin/geom/core/geom.c Modified: head/sbin/geom/core/geom.c ============================================================================== --- head/sbin/geom/core/geom.c Sun Sep 6 06:48:50 2009 (r196877) +++ head/sbin/geom/core/geom.c Sun Sep 6 06:49:59 2009 (r196878) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2004-2005 Pawel Jakub Dawidek + * Copyright (c) 2004-2009 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without From pjd at FreeBSD.org Sun Sep 6 06:52:07 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 06:52:19 2009 Subject: svn commit: r196879 - in head: sbin/geom/class/mirror sys/geom/mirror Message-ID: <200909060652.n866q71p075664@svn.freebsd.org> Author: pjd Date: Sun Sep 6 06:52:06 2009 New Revision: 196879 URL: http://svn.freebsd.org/changeset/base/196879 Log: Add support for changing providers priority. Submitted by: Mel Flynn Modified: head/sbin/geom/class/mirror/geom_mirror.c head/sbin/geom/class/mirror/gmirror.8 head/sys/geom/mirror/g_mirror_ctl.c Modified: head/sbin/geom/class/mirror/geom_mirror.c ============================================================================== --- head/sbin/geom/class/mirror/geom_mirror.c Sun Sep 6 06:49:59 2009 (r196878) +++ head/sbin/geom/class/mirror/geom_mirror.c Sun Sep 6 06:52:06 2009 (r196879) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2004-2005 Pawel Jakub Dawidek + * Copyright (c) 2004-2009 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,13 +41,12 @@ __FBSDID("$FreeBSD$"); #include #include - uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_MIRROR_VERSION; static char label_balance[] = "split", configure_balance[] = "none"; static intmax_t label_slice = 4096, configure_slice = -1; -static intmax_t insert_priority = 0; +static intmax_t insert_priority = 0, configure_priority = -1; static void mirror_main(struct gctl_req *req, unsigned flags); static void mirror_activate(struct gctl_req *req); @@ -71,10 +70,12 @@ struct g_command class_commands[] = { { 'F', "nofailsync", NULL, G_TYPE_BOOL }, { 'h', "hardcode", NULL, G_TYPE_BOOL }, { 'n', "noautosync", NULL, G_TYPE_BOOL }, + { 'p', "priority", &configure_priority, G_TYPE_NUMBER }, { 's', "slice", &configure_slice, G_TYPE_NUMBER }, G_OPT_SENTINEL }, - NULL, "[-adfFhnv] [-b balance] [-s slice] name" + NULL, "[-adfFhnv] [-b balance] [-s slice] name\n" + "[-v] -p priority name prov" }, { "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL, "[-v] name prov ..." Modified: head/sbin/geom/class/mirror/gmirror.8 ============================================================================== --- head/sbin/geom/class/mirror/gmirror.8 Sun Sep 6 06:49:59 2009 (r196878) +++ head/sbin/geom/class/mirror/gmirror.8 Sun Sep 6 06:52:06 2009 (r196879) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2004-2005 Pawel Jakub Dawidek +.\" Copyright (c) 2004-2009 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2006 +.Dd August 1, 2009 .Dt GMIRROR 8 .Os .Sh NAME @@ -49,6 +49,12 @@ .Op Fl s Ar slice .Ar name .Nm +.Cm configure +.Op Fl v +.Fl p Ar priority +.Ar name +.Ar prov +.Nm .Cm rebuild .Op Fl v .Ar name @@ -115,8 +121,8 @@ indicates an action to be performed: .It Cm label Create a mirror. The order of components is important, because a component's priority is based on its position -(starting from 0). -The component with the biggest priority is used by the +(starting from 0 to 255). +The component with the biggest priority (the lowest number) is used by the .Cm prefer balance algorithm and is also used as a master component when resynchronization is needed, @@ -159,7 +165,7 @@ Clear metadata on the given providers. Configure the given device. .Pp Additional options include: -.Bl -tag -width ".Fl b Ar balance" +.Bl -tag -width ".Fl p Ar priority" .It Fl a Turn on autosynchronization of stale components. .It Fl b Ar balance @@ -175,6 +181,9 @@ Assumes device is in consistent state. Hardcode providers' names in metadata. .It Fl n Turn off autosynchronization of stale components. +.It Fl p Ar priority +Specifies priority for the given component +.Ar prov . .It Fl s Ar slice Specifies slice size for .Cm split Modified: head/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- head/sys/geom/mirror/g_mirror_ctl.c Sun Sep 6 06:49:59 2009 (r196878) +++ head/sys/geom/mirror/g_mirror_ctl.c Sun Sep 6 06:52:06 2009 (r196879) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2004-2006 Pawel Jakub Dawidek + * Copyright (c) 2004-2009 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,19 +93,19 @@ g_mirror_ctl_configure(struct gctl_req * { struct g_mirror_softc *sc; struct g_mirror_disk *disk; - const char *name, *balancep; - intmax_t *slicep; + const char *name, *balancep, *prov; + intmax_t *slicep, *priority; uint32_t slice; uint8_t balance; int *autosync, *noautosync, *failsync, *nofailsync, *hardcode, *dynamic; - int *nargs, do_sync = 0, dirty = 1; + int *nargs, do_sync = 0, dirty = 1, do_priority = 0; nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); if (nargs == NULL) { gctl_error(req, "No '%s' argument.", "nargs"); return; } - if (*nargs != 1) { + if (*nargs != 1 && *nargs != 2) { gctl_error(req, "Invalid number of arguments."); return; } @@ -149,6 +149,29 @@ g_mirror_ctl_configure(struct gctl_req * gctl_error(req, "No '%s' argument.", "dynamic"); return; } + priority = gctl_get_paraml(req, "priority", sizeof(*priority)); + if (priority == NULL) { + gctl_error(req, "No '%s' argument.", "priority"); + return; + } + if (*priority < -1 || *priority > 255) { + gctl_error(req, "Priority range is 0 to 255, %jd given", + *priority); + return; + } + /* + * Since we have a priority, we also need a provider now. + * Note: be WARNS safe, by always assigning prov and only throw an + * error if *priority != -1. + */ + prov = gctl_get_asciiparam(req, "arg1"); + if (*priority > -1) { + if (prov == NULL) { + gctl_error(req, "Priority needs a disk name"); + return; + } + do_priority = 1; + } if (*autosync && *noautosync) { gctl_error(req, "'%s' and '%s' specified.", "autosync", "noautosync"); @@ -189,19 +212,32 @@ g_mirror_ctl_configure(struct gctl_req * slice = sc->sc_slice; else slice = *slicep; - if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) { + /* Enforce usage() of -p not allowing any other options. */ + if (do_priority && (*autosync || *noautosync || *failsync || + *nofailsync || *hardcode || *dynamic || *slicep != -1 || + strcmp(balancep, "none") != 0)) { sx_xunlock(&sc->sc_lock); - gctl_error(req, "Not all disks connected. Try 'forget' command " - "first."); + gctl_error(req, "only -p accepted when setting priority"); return; } if (sc->sc_balance == balance && sc->sc_slice == slice && !*autosync && !*noautosync && !*failsync && !*nofailsync && !*hardcode && - !*dynamic) { + !*dynamic && !do_priority) { sx_xunlock(&sc->sc_lock); gctl_error(req, "Nothing has changed."); return; } + if ((!do_priority && *nargs != 1) || (do_priority && *nargs != 2)) { + sx_xunlock(&sc->sc_lock); + gctl_error(req, "Invalid number of arguments."); + return; + } + if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) { + sx_xunlock(&sc->sc_lock); + gctl_error(req, "Not all disks connected. Try 'forget' command " + "first."); + return; + } sc->sc_balance = balance; sc->sc_slice = slice; if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOAUTOSYNC) != 0) { @@ -223,6 +259,23 @@ g_mirror_ctl_configure(struct gctl_req * } } LIST_FOREACH(disk, &sc->sc_disks, d_next) { + /* + * Handle priority first, since we only need one disk, do one + * operation on it and then we're done. No need to check other + * flags, as usage doesn't allow it. + */ + if (do_priority) { + if (strcmp(disk->d_name, prov) == 0) { + if (disk->d_priority == *priority) + gctl_error(req, "Nothing has changed."); + else { + disk->d_priority = *priority; + g_mirror_update_metadata(disk); + } + break; + } + continue; + } if (do_sync) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) disk->d_flags &= ~G_MIRROR_DISK_FLAG_FORCE_SYNC; From pjd at FreeBSD.org Sun Sep 6 07:22:10 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 07:22:22 2009 Subject: svn commit: r196880 - head/lib/libc/sys Message-ID: <200909060722.n867MAWM076318@svn.freebsd.org> Author: pjd Date: Sun Sep 6 07:22:09 2009 New Revision: 196880 URL: http://svn.freebsd.org/changeset/base/196880 Log: Synchornize description in manual page with strerror() output. Modified: head/lib/libc/sys/intro.2 Modified: head/lib/libc/sys/intro.2 ============================================================================== --- head/lib/libc/sys/intro.2 Sun Sep 6 06:52:06 2009 (r196879) +++ head/lib/libc/sys/intro.2 Sun Sep 6 07:22:09 2009 (r196880) @@ -302,7 +302,7 @@ Internet protocols. .It Er 48 EADDRINUSE Em "Address already in use" . Only one usage of each address is normally permitted. .Pp -.It Er 49 EADDRNOTAVAIL Em "Cannot assign requested address" . +.It Er 49 EADDRNOTAVAIL Em "Can't assign requested address" . Normally results from an attempt to create a socket with an address not on this machine. .It Er 50 ENETDOWN Em "Network is down" . @@ -335,7 +335,7 @@ when already connected. An request to send or receive data was disallowed because the socket was not connected and (when sending on a datagram socket) no address was supplied. -.It Er 58 ESHUTDOWN Em "Cannot send after socket shutdown" . +.It Er 58 ESHUTDOWN Em "Can't send after socket shutdown" . A request to send data was disallowed because the socket had already been shut down with a previous .Xr shutdown 2 From pjd at FreeBSD.org Sun Sep 6 07:29:24 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 07:29:30 2009 Subject: svn commit: r196881 - head/sys/netinet Message-ID: <200909060729.n867TNBa076478@svn.freebsd.org> Author: pjd Date: Sun Sep 6 07:29:22 2009 New Revision: 196881 URL: http://svn.freebsd.org/changeset/base/196881 Log: Correct comment. Modified: head/sys/netinet/ip_fastfwd.c Modified: head/sys/netinet/ip_fastfwd.c ============================================================================== --- head/sys/netinet/ip_fastfwd.c Sun Sep 6 07:22:09 2009 (r196880) +++ head/sys/netinet/ip_fastfwd.c Sun Sep 6 07:29:22 2009 (r196881) @@ -151,8 +151,8 @@ ip_findroute(struct route *ro, struct in /* * Try to forward a packet based on the destination address. * This is a fast path optimized for the plain forwarding case. - * If the packet is handled (and consumed) here then we return 1; - * otherwise 0 is returned and the packet should be delivered + * If the packet is handled (and consumed) here then we return NULL; + * otherwise mbuf is returned and the packet should be delivered * to ip_input for full processing. */ struct mbuf * From pjd at FreeBSD.org Sun Sep 6 07:30:21 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 07:30:28 2009 Subject: svn commit: r196882 - head/sys/netipsec Message-ID: <200909060730.n867ULKm076539@svn.freebsd.org> Author: pjd Date: Sun Sep 6 07:30:21 2009 New Revision: 196882 URL: http://svn.freebsd.org/changeset/base/196882 Log: Correct typo in comment. Modified: head/sys/netipsec/ipsec.h Modified: head/sys/netipsec/ipsec.h ============================================================================== --- head/sys/netipsec/ipsec.h Sun Sep 6 07:29:22 2009 (r196881) +++ head/sys/netipsec/ipsec.h Sun Sep 6 07:30:21 2009 (r196882) @@ -61,7 +61,7 @@ * specifies ICMPv6 type, and the port field in "dst" specifies ICMPv6 code. */ struct secpolicyindex { - u_int8_t dir; /* direction of packet flow, see blow */ + u_int8_t dir; /* direction of packet flow, see below */ union sockaddr_union src; /* IP src address for SP */ union sockaddr_union dst; /* IP dst address for SP */ u_int8_t prefs; /* prefix length in bits for src */ From pjd at FreeBSD.org Sun Sep 6 07:32:17 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 07:32:23 2009 Subject: svn commit: r196883 - head/sys/netipsec Message-ID: <200909060732.n867WGwc076608@svn.freebsd.org> Author: pjd Date: Sun Sep 6 07:32:16 2009 New Revision: 196883 URL: http://svn.freebsd.org/changeset/base/196883 Log: Improve code a bit by eliminating goto and having one unlock per lock. Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Sun Sep 6 07:30:21 2009 (r196882) +++ head/sys/netipsec/key.c Sun Sep 6 07:32:16 2009 (r196883) @@ -918,15 +918,14 @@ key_allocsa_policy(const struct secasind state_valid = saorder_state_valid_prefer_new; arraysize = N(saorder_state_valid_prefer_new); } - SAHTREE_UNLOCK(); - goto found; + break; } } SAHTREE_UNLOCK(); - return NULL; + if (sah == NULL) + return NULL; - found: /* search valid state */ for (stateidx = 0; stateidx < arraysize; stateidx++) { sav = key_do_allocsa_policy(sah, state_valid[stateidx]); From ed at FreeBSD.org Sun Sep 6 09:39:41 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Sun Sep 6 09:39:53 2009 Subject: svn commit: r196884 - head/sys/sys Message-ID: <200909060939.n869deVU079085@svn.freebsd.org> Author: ed Date: Sun Sep 6 09:39:40 2009 New Revision: 196884 URL: http://svn.freebsd.org/changeset/base/196884 Log: Perform cleanups to the TTY headers: - Properly sort the ioctls in ioctl_compat.h. Also perform some whitespace fixes. - Properly comment all the unused/compat ioctls in ttycom.h. Modified: head/sys/sys/ioctl_compat.h head/sys/sys/ttycom.h Modified: head/sys/sys/ioctl_compat.h ============================================================================== --- head/sys/sys/ioctl_compat.h Sun Sep 6 07:32:16 2009 (r196883) +++ head/sys/sys/ioctl_compat.h Sun Sep 6 09:39:40 2009 (r196884) @@ -73,12 +73,12 @@ struct sgttyb { #define OTIOCGETD _IOR('t', 0, int) /* get line discipline */ #define OTIOCSETD _IOW('t', 1, int) /* set line discipline */ -#define TIOCHPCL _IO('t', 2) /* hang up on last close */ -#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */ -#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */ -#define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/ -#define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */ -#define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */ +#define TIOCHPCL _IO('t', 2) /* hang up on last close */ +#define TIOCGETP _IOR('t', 8, struct sgttyb) /* get parameters */ +#define TIOCSETP _IOW('t', 9, struct sgttyb) /* set parameters */ +#define TIOCSETN _IOW('t',10, struct sgttyb) /* as above, but no flush */ +#define TIOCSETC _IOW('t',17, struct tchars) /* set special characters */ +#define TIOCGETC _IOR('t',18, struct tchars) /* get special characters */ #define TANDEM 0x00000001 /* send stopc on out q full */ #define CBREAK 0x00000002 /* half-cooked mode */ #define LCASE 0x00000004 /* simulate lower case */ @@ -126,9 +126,9 @@ struct sgttyb { #define PENDIN 0x20000000 /* tp->t_rawq needs reread */ #define DECCTQ 0x40000000 /* only ^Q starts after ^S */ #define NOFLSH 0x80000000 /* no output flush on signal */ -#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ -#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ -#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */ +#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */ +#define TIOCGLTC _IOR('t', 116,struct ltchars) /* get special chars */ +#define TIOCSLTC _IOW('t', 117,struct ltchars) /* set special chars */ #define TIOCLGET _IOR('t', 124, int) /* get local modes */ #define LCRTBS (CRTBS>>16) #define LPRTERA (PRTERA>>16) @@ -145,8 +145,8 @@ struct sgttyb { #define LPENDIN (PENDIN>>16) #define LDECCTQ (DECCTQ>>16) #define LNOFLSH (NOFLSH>>16) -#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/ -#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/ -#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */ +#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */ +#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ +#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ #endif /* !_SYS_IOCTL_COMPAT_H_ */ Modified: head/sys/sys/ttycom.h ============================================================================== --- head/sys/sys/ttycom.h Sun Sep 6 07:32:16 2009 (r196883) +++ head/sys/sys/ttycom.h Sun Sep 6 09:39:40 2009 (r196884) @@ -57,10 +57,9 @@ struct winsize { }; /* 0-2 compat */ - /* 3-4 obsolete */ - /* 5-7 obsolete or unused */ + /* 3-7 unused */ /* 8-10 compat */ - /* 11-12 obsolete or unused */ + /* 11-12 unused */ #define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */ #define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */ #define TIOCGPTN _IOR('t', 15, int) /* Get pts number. */ @@ -70,34 +69,34 @@ struct winsize { #define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */ #define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */ #define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */ - /* 23-25 obsolete or unused */ + /* 23-25 unused */ #define TIOCGETD _IOR('t', 26, int) /* get line discipline */ #define TIOCSETD _IOW('t', 27, int) /* set line discipline */ #define TIOCPTMASTER _IO('t', 28) /* pts master validation */ - /* 29-69 free */ - /* 80-84 slip */ + /* 29-85 unused */ #define TIOCGDRAINWAIT _IOR('t', 86, int) /* get ttywait timeout */ #define TIOCSDRAINWAIT _IOW('t', 87, int) /* set ttywait timeout */ - /* 88 slip, ppp; conflicts */ + /* 88 unused */ + /* 89-91 conflicts: tun and tap */ #define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp * of last input event */ - /* 70-90 ppp; many conflicts */ #define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */ #define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */ - /* 90-92 tap; some conflicts */ + /* 92-93 tun and tap */ + /* 94-97 conflicts: tun and tap */ #define TIOCDRAIN _IO('t', 94) /* wait till output drained */ #define TIOCSIG _IOWINT('t', 95) /* pty: generate signal */ #define TIOCEXT _IOW('t', 96, int) /* pty: external processing */ - /* 90-97 tun; some conflicts */ #define TIOCSCTTY _IO('t', 97) /* become controlling tty */ #define TIOCCONS _IOW('t', 98, int) /* become virtual console */ #define TIOCGSID _IOR('t', 99, int) /* get session id */ - /* 100 see consio.h */ + /* 100 unused */ #define TIOCSTAT _IO('t', 101) /* simulate ^T status message */ #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ + /* 105 unused */ #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ #define TIOCM_LE 0001 /* line enable */ #define TIOCM_DTR 0002 /* data terminal ready */ From ed at FreeBSD.org Sun Sep 6 09:59:02 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Sun Sep 6 09:59:14 2009 Subject: svn commit: r196885 - head/sys/dev/null Message-ID: <200909060959.n869x2Hu079517@svn.freebsd.org> Author: ed Date: Sun Sep 6 09:59:02 2009 New Revision: 196885 URL: http://svn.freebsd.org/changeset/base/196885 Log: Remove unneeded minor numbers from /dev/null and /dev/zero. Modified: head/sys/dev/null/null.c Modified: head/sys/dev/null/null.c ============================================================================== --- head/sys/dev/null/null.c Sun Sep 6 09:39:40 2009 (r196884) +++ head/sys/dev/null/null.c Sun Sep 6 09:59:02 2009 (r196885) @@ -49,9 +49,6 @@ static d_write_t null_write; static d_ioctl_t null_ioctl; static d_read_t zero_read; -#define NULL_MINOR 2 -#define ZERO_MINOR 12 - static struct cdevsw null_cdevsw = { .d_version = D_VERSION, .d_read = (d_read_t *)nullop, @@ -115,10 +112,10 @@ null_modevent(module_t mod __unused, int if (bootverbose) printf("null: \n"); zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO); - null_dev = make_dev(&null_cdevsw, NULL_MINOR, UID_ROOT, - GID_WHEEL, 0666, "null"); - zero_dev = make_dev(&zero_cdevsw, ZERO_MINOR, UID_ROOT, - GID_WHEEL, 0666, "zero"); + null_dev = make_dev(&null_cdevsw, 0, UID_ROOT, GID_WHEEL, + 0666, "null"); + zero_dev = make_dev(&zero_cdevsw, 0, UID_ROOT, GID_WHEEL, + 0666, "zero"); break; case MOD_UNLOAD: From ed at FreeBSD.org Sun Sep 6 10:27:46 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Sun Sep 6 10:27:57 2009 Subject: svn commit: r196886 - in head: share/man/man4 sys/dev/pty sys/kern sys/sys Message-ID: <200909061027.n86ARjvr080188@svn.freebsd.org> Author: ed Date: Sun Sep 6 10:27:45 2009 New Revision: 196886 URL: http://svn.freebsd.org/changeset/base/196886 Log: Move ptmx into pty(4). Now that pty(4) is a loadable kernel module, I'd better move /dev/ptmx in there as well. This means that pty(4) now provides almost all pseudo-terminal compatibility code. This means it's very easy to test whether applications use the proper library interfaces when allocating pseudo-terminals (namely posix_openpt and openpty). Modified: head/share/man/man4/pts.4 head/share/man/man4/pty.4 head/sys/dev/pty/pty.c head/sys/kern/tty_pts.c head/sys/sys/tty.h Modified: head/share/man/man4/pts.4 ============================================================================== --- head/share/man/man4/pts.4 Sun Sep 6 09:59:02 2009 (r196885) +++ head/share/man/man4/pts.4 Sun Sep 6 10:27:45 2009 (r196886) @@ -147,15 +147,6 @@ The files used by this pseudo-terminals implementation are: .Pp .Bl -tag -width ".Pa /dev/pts/[num]" -.It Pa /dev/ptmx -Control device, returns a file descriptor to a new master -pseudo-terminal when opened. -This device should not be opened directly. -It's only available for binary compatibility. -New devices should only be allocated with -.Xr posix_openpt 2 -and -.Xr openpty 3 . .It Pa /dev/pts/[num] Pseudo-terminal slave devices. .El Modified: head/share/man/man4/pty.4 ============================================================================== --- head/share/man/man4/pty.4 Sun Sep 6 09:59:02 2009 (r196885) +++ head/share/man/man4/pty.4 Sun Sep 6 10:27:45 2009 (r196886) @@ -32,7 +32,7 @@ .Os .Sh NAME .Nm pty -.Nd BSD-style compatibility pseudo-terminal driver +.Nd BSD-style and System V-style compatibility pseudo-terminal driver .Sh SYNOPSIS .Cd "device pty" .Sh DESCRIPTION @@ -48,6 +48,12 @@ driver. A device node for this terminal shall be created, which has the name .Pa /dev/ttyXX . .Pp +The +.Nm +driver also provides a cloning System V +.Pa /dev/ptmx +device. +.Pp New code should not try to allocate pseudo-terminals using this interface. It is only provided for compatibility with older C libraries @@ -63,6 +69,9 @@ device names: Pseudo-terminal master devices. .It Pa /dev/tty[l-sL-S][0-9a-v] Pseudo-terminal slave devices. +.It Pa /dev/ptmx +Control device, returns a file descriptor to a new master +pseudo-terminal when opened. .El .Sh DIAGNOSTICS None. @@ -75,7 +84,7 @@ A pseudo-terminal driver appeared in .Bx 4.2 . .Sh BUGS -Unlike previous implementations, the master slave device nodes are +Unlike previous implementations, the master and slave device nodes are destroyed when the PTY becomes unused. A call to .Xr stat 2 Modified: head/sys/dev/pty/pty.c ============================================================================== --- head/sys/dev/pty/pty.c Sun Sep 6 09:59:02 2009 (r196885) +++ head/sys/dev/pty/pty.c Sun Sep 6 10:27:45 2009 (r196886) @@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$"); * the pts(4) driver. We just call into pts(4) to create the actual PTY. * To make sure we don't use the same PTY multiple times, we abuse * si_drv1 inside the cdev to mark whether the PTY is in use. + * + * It also implements a /dev/ptmx device node, which is useful for Linux + * binary emulation. */ static unsigned int pty_warningcnt = 1; @@ -119,12 +122,27 @@ pty_clone(void *arg, struct ucred *cr, c } static int +ptmx_fdopen(struct cdev *dev __unused, int fflags, struct thread *td, + struct file *fp) +{ + + return (pts_alloc(fflags & (FREAD|FWRITE), td, fp)); +} + +static struct cdevsw ptmx_cdevsw = { + .d_version = D_VERSION, + .d_fdopen = ptmx_fdopen, + .d_name = "ptmx", +}; + +static int pty_modevent(module_t mod, int type, void *data) { switch(type) { case MOD_LOAD: EVENTHANDLER_REGISTER(dev_clone, pty_clone, 0, 1000); + make_dev(&ptmx_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666, "ptmx"); break; case MOD_SHUTDOWN: break; Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sun Sep 6 09:59:02 2009 (r196885) +++ head/sys/kern/tty_pts.c Sun Sep 6 10:27:45 2009 (r196886) @@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$"); /* Add compatibility bits for FreeBSD. */ #define PTS_COMPAT -/* Add /dev/ptyXX compat bits. */ +/* Add pty(4) compat bits. */ #define PTS_EXTERNAL /* Add bits to make Linux binaries work. */ #define PTS_LINUX @@ -694,7 +694,10 @@ static struct ttydevsw pts_class = { .tsw_free = ptsdrv_free, }; -static int +#ifndef PTS_EXTERNAL +static +#endif /* !PTS_EXTERNAL */ +int pts_alloc(int fflags, struct thread *td, struct file *fp) { int unit, ok; @@ -815,29 +818,11 @@ posix_openpt(struct thread *td, struct p return (0); } -#if defined(PTS_COMPAT) || defined(PTS_LINUX) -static int -ptmx_fdopen(struct cdev *dev, int fflags, struct thread *td, struct file *fp) -{ - - return (pts_alloc(fflags & (FREAD|FWRITE), td, fp)); -} - -static struct cdevsw ptmx_cdevsw = { - .d_version = D_VERSION, - .d_fdopen = ptmx_fdopen, - .d_name = "ptmx", -}; -#endif /* PTS_COMPAT || PTS_LINUX */ - static void pts_init(void *unused) { pts_pool = new_unrhdr(0, INT_MAX, NULL); -#if defined(PTS_COMPAT) || defined(PTS_LINUX) - make_dev(&ptmx_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666, "ptmx"); -#endif /* PTS_COMPAT || PTS_LINUX */ } SYSINIT(pts, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, pts_init, NULL); Modified: head/sys/sys/tty.h ============================================================================== --- head/sys/sys/tty.h Sun Sep 6 09:59:02 2009 (r196885) +++ head/sys/sys/tty.h Sun Sep 6 10:27:45 2009 (r196886) @@ -202,6 +202,7 @@ void tty_info(struct tty *tp); void ttyconsdev_select(const char *name); /* Pseudo-terminal hooks. */ +int pts_alloc(int fflags, struct thread *td, struct file *fp); int pts_alloc_external(int fd, struct thread *td, struct file *fp, struct cdev *dev, const char *name); From kib at FreeBSD.org Sun Sep 6 11:44:47 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Sep 6 11:44:53 2009 Subject: svn commit: r196887 - head/sys/kern Message-ID: <200909061144.n86BikcZ082916@svn.freebsd.org> Author: kib Date: Sun Sep 6 11:44:46 2009 New Revision: 196887 URL: http://svn.freebsd.org/changeset/base/196887 Log: In fhopen, vfs_ref() the mount point while vnode is unlocked, to prevent vn_start_write(NULL, &mp) from operating on potentially freed or reused struct mount *. Remove unmatched vfs_rel() in cleanup. Noted and reviewed by: tegge Tested by: pho MFC after: 3 days Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Sun Sep 6 10:27:45 2009 (r196886) +++ head/sys/kern/vfs_syscalls.c Sun Sep 6 11:44:46 2009 (r196887) @@ -4439,12 +4439,15 @@ fhopen(td, uap) goto bad; } if (fmode & O_TRUNC) { + vfs_ref(mp); VOP_UNLOCK(vp, 0); /* XXX */ if ((error = vn_start_write(NULL, &mp, V_WAIT | PCATCH)) != 0) { vrele(vp); + vfs_rel(mp); goto out; } vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* XXX */ + vfs_rel(mp); #ifdef MAC /* * We don't yet have fp->f_cred, so use td->td_ucred, which @@ -4516,7 +4519,6 @@ fhopen(td, uap) VOP_UNLOCK(vp, 0); fdrop(fp, td); - vfs_rel(mp); VFS_UNLOCK_GIANT(vfslocked); td->td_retval[0] = indx; return (0); From kib at FreeBSD.org Sun Sep 6 11:46:52 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Sep 6 11:46:57 2009 Subject: svn commit: r196888 - head/sys/ufs/ffs Message-ID: <200909061146.n86BkpXK082995@svn.freebsd.org> Author: kib Date: Sun Sep 6 11:46:51 2009 New Revision: 196888 URL: http://svn.freebsd.org/changeset/base/196888 Log: The clear_remove() and clear_inodedeps() call vn_start_write(NULL, &mp, V_NOWAIT) on the non-busied mount point. Unmount might free ufs-specific mp data, causing ffs_vgetf() to access freed memory. Busy mountpoint before dropping softdep lk. Noted and reviewed by: tegge Tested by: pho MFC after: 1 week Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sun Sep 6 11:44:46 2009 (r196887) +++ head/sys/ufs/ffs/ffs_softdep.c Sun Sep 6 11:46:51 2009 (r196888) @@ -5977,12 +5977,19 @@ clear_remove(td) if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) continue; FREE_LOCK(&lk); - if ((error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, - FFSV_FORCEINSMQ))) { + + /* + * Let unmount clear deps + */ + error = vfs_busy(mp, MBF_NOWAIT); + if (error != 0) + goto finish_write; + error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, + FFSV_FORCEINSMQ); + vfs_unbusy(mp); + if (error != 0) { softdep_error("clear_remove: vget", error); - vn_finished_write(mp); - ACQUIRE_LOCK(&lk); - return; + goto finish_write; } if ((error = ffs_syncvnode(vp, MNT_NOWAIT))) softdep_error("clear_remove: fsync", error); @@ -5991,6 +5998,7 @@ clear_remove(td) drain_output(vp); BO_UNLOCK(bo); vput(vp); + finish_write: vn_finished_write(mp); ACQUIRE_LOCK(&lk); return; @@ -6050,13 +6058,21 @@ clear_inodedeps(td) if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) continue; FREE_LOCK(&lk); + error = vfs_busy(mp, MBF_NOWAIT); /* Let unmount clear deps */ + if (error != 0) { + vn_finished_write(mp); + ACQUIRE_LOCK(&lk); + return; + } if ((error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, FFSV_FORCEINSMQ)) != 0) { softdep_error("clear_inodedeps: vget", error); + vfs_unbusy(mp); vn_finished_write(mp); ACQUIRE_LOCK(&lk); return; } + vfs_unbusy(mp); if (ino == lastino) { if ((error = ffs_syncvnode(vp, MNT_WAIT))) softdep_error("clear_inodedeps: fsync1", error); From nork at FreeBSD.org Sun Sep 6 12:01:30 2009 From: nork at FreeBSD.org (Norikatsu Shigemura) Date: Sun Sep 6 12:01:41 2009 Subject: svn commit: r196889 - head/sys/dev/coretemp Message-ID: <200909061201.n86C1Tw5083308@svn.freebsd.org> Author: nork Date: Sun Sep 6 12:01:29 2009 New Revision: 196889 URL: http://svn.freebsd.org/changeset/base/196889 Log: Change 'dev.cpu.N.temperature', sysctl I (degC) to IK (Kelvin). Approved by: re (rwatson) Reviewed by: rpaulo Suggested by: ume MFC After: 3 days Modified: head/sys/dev/coretemp/coretemp.c Modified: head/sys/dev/coretemp/coretemp.c ============================================================================== --- head/sys/dev/coretemp/coretemp.c Sun Sep 6 11:46:51 2009 (r196888) +++ head/sys/dev/coretemp/coretemp.c Sun Sep 6 12:01:29 2009 (r196889) @@ -48,6 +48,8 @@ __FBSDID("$FreeBSD$"); #include #include +#define TZ_ZEROC 2732 + struct coretemp_softc { device_t sc_dev; int sc_tjmax; @@ -193,8 +195,8 @@ coretemp_attach(device_t dev) SYSCTL_CHILDREN(device_get_sysctl_tree(pdev)), OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, - dev, 0, coretemp_get_temp_sysctl, "I", - "Current temperature in degC"); + dev, 0, coretemp_get_temp_sysctl, "IK", + "Current temperature"); return (0); } @@ -283,7 +285,7 @@ coretemp_get_temp_sysctl(SYSCTL_HANDLER_ device_t dev = (device_t) arg1; int temp; - temp = coretemp_get_temp(dev); + temp = coretemp_get_temp(dev) * 10 + TZ_ZEROC; return (sysctl_handle_int(oidp, &temp, 0, req)); } From antoine at FreeBSD.org Sun Sep 6 13:26:51 2009 From: antoine at FreeBSD.org (Antoine Brodin) Date: Sun Sep 6 13:26:58 2009 Subject: svn commit: r196890 - head/etc/mtree Message-ID: <200909061326.n86DQpOt084992@svn.freebsd.org> Author: antoine Date: Sun Sep 6 13:26:51 2009 New Revision: 196890 URL: http://svn.freebsd.org/changeset/base/196890 Log: Update etc/mtree/Makefile: There is no longer BSD.{local,x11-4,x11}.dist mtree files. There is a BSD.sendmail.dist mtree file. Modified: head/etc/mtree/Makefile Modified: head/etc/mtree/Makefile ============================================================================== --- head/etc/mtree/Makefile Sun Sep 6 12:01:29 2009 (r196889) +++ head/etc/mtree/Makefile Sun Sep 6 13:26:51 2009 (r196890) @@ -5,12 +5,10 @@ FILES= ${_BIND.chroot.dist} \ ${_BIND.include.dist} \ BSD.include.dist \ - BSD.local.dist \ BSD.root.dist \ + ${_BSD.sendmail.dist} \ BSD.usr.dist \ - BSD.var.dist \ - BSD.x11-4.dist \ - BSD.x11.dist + BSD.var.dist .if ${MK_BIND} != "no" _BIND.chroot.dist= BIND.chroot.dist @@ -18,6 +16,9 @@ _BIND.chroot.dist= BIND.chroot.dist _BIND.include.dist= BIND.include.dist .endif .endif +.if ${MK_SENDMAIL} != "no" +_BSD.sendmail.dist= BSD.sendmail.dist +.endif NO_OBJ= FILESDIR= /etc/mtree From antoine at FreeBSD.org Sun Sep 6 13:31:05 2009 From: antoine at FreeBSD.org (Antoine Brodin) Date: Sun Sep 6 13:31:11 2009 Subject: svn commit: r196891 - head/sys/kern Message-ID: <200909061331.n86DV5W2085110@svn.freebsd.org> Author: antoine Date: Sun Sep 6 13:31:05 2009 New Revision: 196891 URL: http://svn.freebsd.org/changeset/base/196891 Log: Change w_notrunning and w_stillcold from pointer to array so that sizeof returns what is expected. PR: kern/138557 Discussed with: brucec@ MFC after: 1 month Modified: head/sys/kern/subr_witness.c Modified: head/sys/kern/subr_witness.c ============================================================================== --- head/sys/kern/subr_witness.c Sun Sep 6 13:26:51 2009 (r196890) +++ head/sys/kern/subr_witness.c Sun Sep 6 13:31:05 2009 (r196891) @@ -469,8 +469,8 @@ static struct witness_lock_order_data *w static struct witness_lock_order_hash w_lohash; static int w_max_used_index = 0; static unsigned int w_generation = 0; -static const char *w_notrunning = "Witness not running\n"; -static const char *w_stillcold = "Witness is still cold\n"; +static const char w_notrunning[] = "Witness not running\n"; +static const char w_stillcold[] = "Witness is still cold\n"; static struct witness_order_list_entry order_lists[] = { From mav at FreeBSD.org Sun Sep 6 14:23:27 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 14:23:38 2009 Subject: svn commit: r196893 - head/sys/dev/ata Message-ID: <200909061423.n86ENQ0p086193@svn.freebsd.org> Author: mav Date: Sun Sep 6 14:23:26 2009 New Revision: 196893 URL: http://svn.freebsd.org/changeset/base/196893 Log: Remove constraint, requiring request data to fulfill controller's alignment requirements. It is busdma task, to manage proper alignment by loading data to bounce buffers. PR: kern/127316 Reviewed by: current@ Tested by: Ryan Rogers Modified: head/sys/dev/ata/ata-dma.c Modified: head/sys/dev/ata/ata-dma.c ============================================================================== --- head/sys/dev/ata/ata-dma.c Sun Sep 6 14:05:01 2009 (r196892) +++ head/sys/dev/ata/ata-dma.c Sun Sep 6 14:23:26 2009 (r196893) @@ -272,10 +272,10 @@ ata_dmaload(struct ata_request *request, "FAILURE - zero length DMA transfer attempted\n"); return EIO; } - if (((uintptr_t)(request->data) & (ch->dma.alignment - 1)) || - (request->bytecount & (ch->dma.alignment - 1))) { + if (request->bytecount & (ch->dma.alignment - 1)) { device_printf(request->dev, - "FAILURE - non aligned DMA transfer attempted\n"); + "FAILURE - odd-sized DMA transfer attempt %d %% %d\n", + request->bytecount, ch->dma.alignment); return EIO; } if (request->bytecount > ch->dma.max_iosize) { From bz at FreeBSD.org Sun Sep 6 16:25:08 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Sun Sep 6 16:25:20 2009 Subject: svn commit: r196883 - head/sys/netipsec In-Reply-To: <200909060732.n867WGwc076608@svn.freebsd.org> References: <200909060732.n867WGwc076608@svn.freebsd.org> Message-ID: <20090906162102.Q68375@maildrop.int.zabbadoz.net> On Sun, 6 Sep 2009, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Sun Sep 6 07:32:16 2009 > New Revision: 196883 > URL: http://svn.freebsd.org/changeset/base/196883 > > Log: > Improve code a bit by eliminating goto and having one unlock per lock. This does not coompile anymore: HEAD.svn/sys/netipsec/key.c: In function 'key_checkrequest': HEAD.svn/sys/netipsec/key.c: warning: 'state_valid' may be used uninitialized in this function HEAD.svn/sys/netipsec/key.c: note: 'state_valid' was declared here > Modified: > head/sys/netipsec/key.c > > Modified: head/sys/netipsec/key.c > ============================================================================== > --- head/sys/netipsec/key.c Sun Sep 6 07:30:21 2009 (r196882) > +++ head/sys/netipsec/key.c Sun Sep 6 07:32:16 2009 (r196883) > @@ -918,15 +918,14 @@ key_allocsa_policy(const struct secasind > state_valid = saorder_state_valid_prefer_new; > arraysize = N(saorder_state_valid_prefer_new); > } > - SAHTREE_UNLOCK(); > - goto found; > + break; > } > } > SAHTREE_UNLOCK(); > > - return NULL; > + if (sah == NULL) > + return NULL; > > - found: > /* search valid state */ > for (stateidx = 0; stateidx < arraysize; stateidx++) { > sav = key_do_allocsa_policy(sah, state_valid[stateidx]); > -- Bjoern A. Zeeb What was I talking about and who are you again? From pjd at FreeBSD.org Sun Sep 6 18:09:26 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 18:09:38 2009 Subject: svn commit: r196896 - head/sys/netipsec Message-ID: <200909061809.n86I9Q3m090683@svn.freebsd.org> Author: pjd Date: Sun Sep 6 18:09:25 2009 New Revision: 196896 URL: http://svn.freebsd.org/changeset/base/196896 Log: Initialize state_valid and arraysize variable so gcc won't complain. Reported by: bz Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Sun Sep 6 17:24:15 2009 (r196895) +++ head/sys/netipsec/key.c Sun Sep 6 18:09:25 2009 (r196896) @@ -906,6 +906,9 @@ key_allocsa_policy(const struct secasind u_int stateidx, arraysize; const u_int *state_valid; + state_valid = NULL; /* silent gcc */ + arraysize = 0; /* silent gcc */ + SAHTREE_LOCK(); LIST_FOREACH(sah, &V_sahtree, chain) { if (sah->state == SADB_SASTATE_DEAD) @@ -922,7 +925,6 @@ key_allocsa_policy(const struct secasind } } SAHTREE_UNLOCK(); - if (sah == NULL) return NULL; From mav at FreeBSD.org Sun Sep 6 18:40:49 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 18:41:01 2009 Subject: svn commit: r196897 - head/sys/cam Message-ID: <200909061840.n86IemhT091296@svn.freebsd.org> Author: mav Date: Sun Sep 6 18:40:48 2009 New Revision: 196897 URL: http://svn.freebsd.org/changeset/base/196897 Log: Avoid extra swi_sched() call, if this SIM is already queued. It reduces overhead for coalesced command completions. Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Sep 6 18:09:25 2009 (r196896) +++ head/sys/cam/cam_xpt.c Sun Sep 6 18:40:48 2009 (r196897) @@ -4198,12 +4198,12 @@ xpt_done(union ccb *done_ccb) mtx_lock(&cam_simq_lock); TAILQ_INSERT_TAIL(&cam_simq, sim, links); - sim->flags |= CAM_SIM_ON_DONEQ; mtx_unlock(&cam_simq_lock); + sim->flags |= CAM_SIM_ON_DONEQ; + if ((done_ccb->ccb_h.path->periph->flags & + CAM_PERIPH_POLLED) == 0) + swi_sched(cambio_ih, 0); } - if ((done_ccb->ccb_h.path->periph->flags & - CAM_PERIPH_POLLED) == 0) - swi_sched(cambio_ih, 0); break; default: panic("unknown periph type %d", @@ -4889,16 +4889,20 @@ camisr(void *dummy) mtx_lock(&cam_simq_lock); TAILQ_INIT(&queue); - TAILQ_CONCAT(&queue, &cam_simq, links); - mtx_unlock(&cam_simq_lock); - - while ((sim = TAILQ_FIRST(&queue)) != NULL) { - TAILQ_REMOVE(&queue, sim, links); - CAM_SIM_LOCK(sim); - sim->flags &= ~CAM_SIM_ON_DONEQ; - camisr_runqueue(&sim->sim_doneq); - CAM_SIM_UNLOCK(sim); + while (!TAILQ_EMPTY(&cam_simq)) { + TAILQ_CONCAT(&queue, &cam_simq, links); + mtx_unlock(&cam_simq_lock); + + while ((sim = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, sim, links); + CAM_SIM_LOCK(sim); + sim->flags &= ~CAM_SIM_ON_DONEQ; + camisr_runqueue(&sim->sim_doneq); + CAM_SIM_UNLOCK(sim); + } + mtx_lock(&cam_simq_lock); } + mtx_unlock(&cam_simq_lock); } static void From mav at FreeBSD.org Sun Sep 6 18:48:20 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 18:48:26 2009 Subject: svn commit: r196898 - head/sys/cam Message-ID: <200909061848.n86ImI08091537@svn.freebsd.org> Author: mav Date: Sun Sep 6 18:48:18 2009 New Revision: 196898 URL: http://svn.freebsd.org/changeset/base/196898 Log: MFp4: Report scbusX in xpt_announce_periph() to less confuse users by two different bus addressing schemes. Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Sep 6 18:40:48 2009 (r196897) +++ head/sys/cam/cam_xpt.c Sun Sep 6 18:48:18 2009 (r196898) @@ -1033,11 +1033,12 @@ xpt_announce_periph(struct cam_periph *p * To ensure that this is printed in one piece, * mask out CAM interrupts. */ - printf("%s%d at %s%d bus %d target %d lun %d\n", + printf("%s%d at %s%d bus %d scbus%d target %d lun %d\n", periph->periph_name, periph->unit_number, path->bus->sim->sim_name, path->bus->sim->unit_number, path->bus->sim->bus_id, + path->bus->path_id, path->target->target_id, path->device->lun_id); printf("%s%d: ", periph->periph_name, periph->unit_number); From mav at FreeBSD.org Sun Sep 6 18:56:08 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 18:56:19 2009 Subject: svn commit: r196900 - head/sys/cam Message-ID: <200909061856.n86Iu86d091765@svn.freebsd.org> Author: mav Date: Sun Sep 6 18:56:08 2009 New Revision: 196900 URL: http://svn.freebsd.org/changeset/base/196900 Log: s/bus %d/scbus%d/ in some messages to correct terminology. Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Sep 6 18:49:45 2009 (r196899) +++ head/sys/cam/cam_xpt.c Sun Sep 6 18:56:08 2009 (r196900) @@ -4605,7 +4605,7 @@ xptconfigfunc(struct cam_eb *bus, void * CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD)) !=CAM_REQ_CMP){ printf("xptconfigfunc: xpt_create_path failed with " - "status %#x for bus %d\n", status, bus->path_id); + "status %#x for scbus%d\n", status, bus->path_id); printf("xptconfigfunc: halting bus configuration\n"); xpt_free_ccb(work_ccb); busses_to_config--; @@ -4616,7 +4616,7 @@ xptconfigfunc(struct cam_eb *bus, void * work_ccb->ccb_h.func_code = XPT_PATH_INQ; xpt_action(work_ccb); if (work_ccb->ccb_h.status != CAM_REQ_CMP) { - printf("xptconfigfunc: CPI failed on bus %d " + printf("xptconfigfunc: CPI failed on scbus%d " "with status %d\n", bus->path_id, work_ccb->ccb_h.status); xpt_finishconfig(xpt_periph, work_ccb); From mav at FreeBSD.org Sun Sep 6 18:59:46 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 18:59:52 2009 Subject: svn commit: r196901 - head/sys/cam Message-ID: <200909061859.n86IxkrW091861@svn.freebsd.org> Author: mav Date: Sun Sep 6 18:59:46 2009 New Revision: 196901 URL: http://svn.freebsd.org/changeset/base/196901 Log: Remove unneeded CAM_SIM_MPSAFE check. Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Sep 6 18:56:08 2009 (r196900) +++ head/sys/cam/cam_xpt.c Sun Sep 6 18:59:46 2009 (r196901) @@ -4407,10 +4407,7 @@ xpt_alloc_device(struct cam_eb *bus, str device->tag_delay_count = 0; device->tag_saved_openings = 0; device->refcount = 1; - if (bus->sim->flags & CAM_SIM_MPSAFE) - callout_init_mtx(&device->callout, bus->sim->mtx, 0); - else - callout_init_mtx(&device->callout, &Giant, 0); + callout_init_mtx(&device->callout, bus->sim->mtx, 0); /* * Hold a reference to our parent target so it From pjd at FreeBSD.org Sun Sep 6 19:05:04 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Sun Sep 6 19:05:15 2009 Subject: svn commit: r196902 - head/sys/netipsec Message-ID: <200909061905.n86J53wQ092011@svn.freebsd.org> Author: pjd Date: Sun Sep 6 19:05:03 2009 New Revision: 196902 URL: http://svn.freebsd.org/changeset/base/196902 Log: Silent gcc? Yeah, you wish. What I ment was to silence gcc. Spotted by: julian Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Sun Sep 6 18:59:46 2009 (r196901) +++ head/sys/netipsec/key.c Sun Sep 6 19:05:03 2009 (r196902) @@ -906,8 +906,8 @@ key_allocsa_policy(const struct secasind u_int stateidx, arraysize; const u_int *state_valid; - state_valid = NULL; /* silent gcc */ - arraysize = 0; /* silent gcc */ + state_valid = NULL; /* silence gcc */ + arraysize = 0; /* silence gcc */ SAHTREE_LOCK(); LIST_FOREACH(sah, &V_sahtree, chain) { From mav at FreeBSD.org Sun Sep 6 19:06:51 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 19:06:57 2009 Subject: svn commit: r196903 - head/sys/cam Message-ID: <200909061906.n86J6oKC092073@svn.freebsd.org> Author: mav Date: Sun Sep 6 19:06:50 2009 New Revision: 196903 URL: http://svn.freebsd.org/changeset/base/196903 Log: MFp4: Remove duplicate qfrozen_cnt variable from struct cam_ed. ccbq.queue.qfrozen_cnt should be used instead. Modified: head/sys/cam/cam_xpt.c head/sys/cam/cam_xpt_internal.h Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Sep 6 19:05:03 2009 (r196902) +++ head/sys/cam/cam_xpt.c Sun Sep 6 19:06:50 2009 (r196903) @@ -2472,7 +2472,7 @@ xpt_action_default(union ccb *start_ccb) path = start_ccb->ccb_h.path; cam_ccbq_insert_ccb(&path->device->ccbq, start_ccb); - if (path->device->qfrozen_cnt == 0) + if (path->device->ccbq.queue.qfrozen_cnt == 0) runq = xpt_schedule_dev_sendq(path->bus, path->device); else runq = 0; @@ -2931,7 +2931,7 @@ xpt_action_default(union ccb *start_ccb) xpt_release_devq(crs->ccb_h.path, /*count*/1, /*run_queue*/TRUE); } - start_ccb->crs.qfrozen_cnt = dev->qfrozen_cnt; + start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt; start_ccb->ccb_h.status = CAM_REQ_CMP; break; } @@ -3227,7 +3227,7 @@ xpt_run_dev_sendq(struct cam_eb *bus) * If the device has been "frozen", don't attempt * to run it. */ - if (device->qfrozen_cnt > 0) { + if (device->ccbq.queue.qfrozen_cnt > 0) { continue; } @@ -3250,7 +3250,7 @@ xpt_run_dev_sendq(struct cam_eb *bus) * the device queue until we have a slot * available. */ - device->qfrozen_cnt++; + device->ccbq.queue.qfrozen_cnt++; STAILQ_INSERT_TAIL(&xsoftc.highpowerq, &work_ccb->ccb_h, xpt_links.stqe); @@ -3282,7 +3282,7 @@ xpt_run_dev_sendq(struct cam_eb *bus) * The client wants to freeze the queue * after this CCB is sent. */ - device->qfrozen_cnt++; + device->ccbq.queue.qfrozen_cnt++; } /* In Target mode, the peripheral driver knows best... */ @@ -4031,7 +4031,7 @@ xpt_freeze_devq(struct cam_path *path, u mtx_assert(path->bus->sim->mtx, MA_OWNED); - path->device->qfrozen_cnt += count; + path->device->ccbq.queue.qfrozen_cnt += count; /* * Mark the last CCB in the queue as needing @@ -4049,7 +4049,7 @@ xpt_freeze_devq(struct cam_path *path, u ccbh = TAILQ_LAST(&path->device->ccbq.active_ccbs, ccb_hdr_tailq); if (ccbh && ccbh->status == CAM_REQ_INPROG) ccbh->status = CAM_REQUEUE_REQ; - return (path->device->qfrozen_cnt); + return (path->device->ccbq.queue.qfrozen_cnt); } u_int32_t @@ -4093,11 +4093,12 @@ xpt_release_devq_device(struct cam_ed *d int rundevq; rundevq = 0; - if (dev->qfrozen_cnt > 0) { + if (dev->ccbq.queue.qfrozen_cnt > 0) { - count = (count > dev->qfrozen_cnt) ? dev->qfrozen_cnt : count; - dev->qfrozen_cnt -= count; - if (dev->qfrozen_cnt == 0) { + count = (count > dev->ccbq.queue.qfrozen_cnt) ? + dev->ccbq.queue.qfrozen_cnt : count; + dev->ccbq.queue.qfrozen_cnt -= count; + if (dev->ccbq.queue.qfrozen_cnt == 0) { /* * No longer need to wait for a successful @@ -4402,7 +4403,6 @@ xpt_alloc_device(struct cam_eb *bus, str SLIST_INIT(&device->periphs); device->generation = 0; device->owner = NULL; - device->qfrozen_cnt = 0; device->flags = CAM_DEV_UNCONFIGURED; device->tag_delay_count = 0; device->tag_saved_openings = 0; @@ -4971,7 +4971,7 @@ camisr_runqueue(void *V_queue) xpt_start_tags(ccb_h->path); if ((dev->ccbq.queue.entries > 0) - && (dev->qfrozen_cnt == 0) + && (dev->ccbq.queue.qfrozen_cnt == 0) && (device_is_send_queued(dev) == 0)) { runq = xpt_schedule_dev_sendq(ccb_h->path->bus, dev); Modified: head/sys/cam/cam_xpt_internal.h ============================================================================== --- head/sys/cam/cam_xpt_internal.h Sun Sep 6 19:05:03 2009 (r196902) +++ head/sys/cam/cam_xpt_internal.h Sun Sep 6 19:06:50 2009 (r196903) @@ -106,7 +106,6 @@ struct cam_ed { u_int8_t queue_flags; /* Queue flags from the control page */ u_int8_t serial_num_len; u_int8_t *serial_num; - u_int32_t qfrozen_cnt; u_int32_t flags; #define CAM_DEV_UNCONFIGURED 0x01 #define CAM_DEV_REL_TIMEOUT_PENDING 0x02 From mav at FreeBSD.org Sun Sep 6 19:33:13 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 19:33:19 2009 Subject: svn commit: r196904 - head/sys/geom Message-ID: <200909061933.n86JXD97092578@svn.freebsd.org> Author: mav Date: Sun Sep 6 19:33:13 2009 New Revision: 196904 URL: http://svn.freebsd.org/changeset/base/196904 Log: MFp4: Remove msleep() timeout from g_io_schedule_up/down(). It works fine without it, saving few percents of CPU on high request rates without need to rearm callout twice per request. Modified: head/sys/geom/geom_io.c Modified: head/sys/geom/geom_io.c ============================================================================== --- head/sys/geom/geom_io.c Sun Sep 6 19:06:50 2009 (r196903) +++ head/sys/geom/geom_io.c Sun Sep 6 19:33:13 2009 (r196904) @@ -567,7 +567,7 @@ g_io_schedule_down(struct thread *tp __u if (bp == NULL) { CTR0(KTR_GEOM, "g_down going to sleep"); msleep(&g_wait_down, &g_bio_run_down.bio_queue_lock, - PRIBIO | PDROP, "-", hz/10); + PRIBIO | PDROP, "-", 0); continue; } CTR0(KTR_GEOM, "g_down has work to do"); @@ -672,7 +672,7 @@ g_io_schedule_up(struct thread *tp __unu } CTR0(KTR_GEOM, "g_up going to sleep"); msleep(&g_wait_up, &g_bio_run_up.bio_queue_lock, - PRIBIO | PDROP, "-", hz/10); + PRIBIO | PDROP, "-", 0); } } From mav at FreeBSD.org Sun Sep 6 21:22:25 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Sep 6 21:22:37 2009 Subject: svn commit: r196907 - head/sys/dev/ahci Message-ID: <200909062122.n86LMOvK094808@svn.freebsd.org> Author: mav Date: Sun Sep 6 21:22:24 2009 New Revision: 196907 URL: http://svn.freebsd.org/changeset/base/196907 Log: To save small bit of CPU time, hide part of SNTF register read latency behind other reads. Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Sun Sep 6 20:32:16 2009 (r196906) +++ head/sys/dev/ahci/ahci.c Sun Sep 6 21:22:24 2009 (r196907) @@ -891,16 +891,12 @@ ahci_phy_check_events(device_t dev) } static void -ahci_notify_events(device_t dev) +ahci_notify_events(device_t dev, u_int32_t status) { struct ahci_channel *ch = device_get_softc(dev); struct cam_path *dpath; - u_int32_t status; int i; - status = ATA_INL(ch->r_mem, AHCI_P_SNTF); - if (status == 0) - return; ATA_OUTL(ch->r_mem, AHCI_P_SNTF, status); if (bootverbose) device_printf(dev, "SNTF 0x%04x\n", status); @@ -948,7 +944,7 @@ ahci_ch_intr(void *data) { device_t dev = (device_t)data; struct ahci_channel *ch = device_get_softc(dev); - uint32_t istatus, cstatus, sstatus, ok, err; + uint32_t istatus, sstatus, cstatus, sntf = 0, ok, err; enum ahci_err_type et; int i, ccs, ncq_err = 0; @@ -958,8 +954,10 @@ ahci_ch_intr(void *data) return; ATA_OUTL(ch->r_mem, AHCI_P_IS, istatus); /* Read command statuses. */ - cstatus = ATA_INL(ch->r_mem, AHCI_P_CI); sstatus = ATA_INL(ch->r_mem, AHCI_P_SACT); + cstatus = ATA_INL(ch->r_mem, AHCI_P_CI); + if ((istatus & AHCI_P_IX_SDB) && (ch->caps & AHCI_CAP_SSNTF)) + sntf = ATA_INL(ch->r_mem, AHCI_P_SNTF); /* Process PHY events */ if (istatus & (AHCI_P_IX_PRC | AHCI_P_IX_PC)) ahci_phy_check_events(dev); @@ -1023,8 +1021,8 @@ ahci_ch_intr(void *data) ahci_issue_read_log(dev); } /* Process NOTIFY events */ - if ((istatus & AHCI_P_IX_SDB) && (ch->caps & AHCI_CAP_SSNTF)) - ahci_notify_events(dev); + if (sntf) + ahci_notify_events(dev, sntf); } /* Must be called with channel locked. */ From pjd at FreeBSD.org Mon Sep 7 06:37:45 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 06:37:56 2009 Subject: svn commit: r196911 - head/usr.bin/tar Message-ID: <200909070637.n876bidG005754@svn.freebsd.org> Author: pjd Date: Mon Sep 7 06:37:44 2009 New Revision: 196911 URL: http://svn.freebsd.org/changeset/base/196911 Log: Make sure to use up-to-date libarchive header files from source tree when compiling tar and not the ones from /usr/include/. Reviewed by: kientzle Approved by: kientzle Modified: head/usr.bin/tar/Makefile Modified: head/usr.bin/tar/Makefile ============================================================================== --- head/usr.bin/tar/Makefile Mon Sep 7 00:49:00 2009 (r196910) +++ head/usr.bin/tar/Makefile Mon Sep 7 06:37:44 2009 (r196911) @@ -12,7 +12,7 @@ LDADD+= -lcrypto .endif CFLAGS+= -DBSDTAR_VERSION_STRING=\"${BSDTAR_VERSION_STRING}\" CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\" -CFLAGS+= -I${.CURDIR} +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../lib/libarchive SYMLINKS= bsdtar ${BINDIR}/tar MLINKS= bsdtar.1 tar.1 DEBUG_FLAGS=-g From attilio at FreeBSD.org Mon Sep 7 09:30:38 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Mon Sep 7 09:30:57 2009 Subject: svn commit: r196916 - head/contrib/gdtoa Message-ID: <200909070930.n879UcSC009647@svn.freebsd.org> Author: attilio Date: Mon Sep 7 09:30:37 2009 New Revision: 196916 URL: http://svn.freebsd.org/changeset/base/196916 Log: Import a vendor fix for a list overrun. This has been considered as a security hole on some specialized ml, but currently the secteam@ doesn't consider that way. Reviewed by: emaste, des Sponsored by: Sandvine Incorporated MFC after: 3 days Modified: head/contrib/gdtoa/gdtoaimp.h head/contrib/gdtoa/misc.c Modified: head/contrib/gdtoa/gdtoaimp.h ============================================================================== --- head/contrib/gdtoa/gdtoaimp.h Mon Sep 7 08:52:15 2009 (r196915) +++ head/contrib/gdtoa/gdtoaimp.h Mon Sep 7 09:30:37 2009 (r196916) @@ -485,7 +485,7 @@ extern pthread_mutex_t __gdtoa_locks[2]; _pthread_mutex_unlock(&__gdtoa_locks[n]); \ } while(0) -#define Kmax 15 +#define Kmax 9 struct Bigint { Modified: head/contrib/gdtoa/misc.c ============================================================================== --- head/contrib/gdtoa/misc.c Mon Sep 7 08:52:15 2009 (r196915) +++ head/contrib/gdtoa/misc.c Mon Sep 7 09:30:37 2009 (r196916) @@ -55,7 +55,9 @@ Balloc #endif ACQUIRE_DTOA_LOCK(0); - if ( (rv = freelist[k]) !=0) { + /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ + /* but this case seems very unlikely. */ + if (k <= Kmax && (rv = freelist[k]) !=0) { freelist[k] = rv->next; } else { @@ -65,7 +67,7 @@ Balloc #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) /sizeof(double); - if (pmem_next - private_mem + len <= PRIVATE_mem) { + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { rv = (Bigint*)pmem_next; pmem_next += len; } @@ -89,10 +91,14 @@ Bfree #endif { if (v) { - ACQUIRE_DTOA_LOCK(0); - v->next = freelist[v->k]; - freelist[v->k] = v; - FREE_DTOA_LOCK(0); + if (v->k > Kmax) + free((void*)v); + else { + ACQUIRE_DTOA_LOCK(0); + v->next = freelist[v->k]; + freelist[v->k] = v; + FREE_DTOA_LOCK(0); + } } } From pjd at FreeBSD.org Mon Sep 7 11:38:44 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 11:38:51 2009 Subject: svn commit: r196919 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909071138.n87BciEc013363@svn.freebsd.org> Author: pjd Date: Mon Sep 7 11:38:43 2009 New Revision: 196919 URL: http://svn.freebsd.org/changeset/base/196919 Log: bzero() on-stack argument, so mutex_init() won't misinterpret that the lock is already initialized if we have some garbage on the stack. PR: kern/135480 Reported by: Emil Mikulic MFC after: 3 days Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Mon Sep 7 10:15:50 2009 (r196918) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Mon Sep 7 11:38:43 2009 (r196919) @@ -1419,6 +1419,7 @@ dsl_dataset_drain_refs(dsl_dataset_t *ds { struct refsarg arg; + bzero(&arg, sizeof(arg)); mutex_init(&arg.lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&arg.cv, NULL, CV_DEFAULT, NULL); arg.gone = FALSE; From kib at FreeBSD.org Mon Sep 7 11:55:34 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Sep 7 11:55:40 2009 Subject: svn commit: r196920 - in head/sys: fs/pseudofs ufs/ffs Message-ID: <200909071155.n87BtYdV013765@svn.freebsd.org> Author: kib Date: Mon Sep 7 11:55:34 2009 New Revision: 196920 URL: http://svn.freebsd.org/changeset/base/196920 Log: insmntque_stddtr() clears vp->v_data and resets vp->v_op to dead_vnodeops before calling vgone(). Revert r189706 and corresponding part of the r186560. Noted and reviewed by: tegge Approved by: des (pseudofs part) MFC after: 3 days Modified: head/sys/fs/pseudofs/pseudofs_vncache.c head/sys/ufs/ffs/ffs_vfsops.c Modified: head/sys/fs/pseudofs/pseudofs_vncache.c ============================================================================== --- head/sys/fs/pseudofs/pseudofs_vncache.c Mon Sep 7 11:38:43 2009 (r196919) +++ head/sys/fs/pseudofs/pseudofs_vncache.c Mon Sep 7 11:55:34 2009 (r196920) @@ -193,6 +193,7 @@ retry: vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); error = insmntque(*vpp, mp); if (error != 0) { + free(pvd, M_PFSVNCACHE); *vpp = NULLVP; return (error); } Modified: head/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vfsops.c Mon Sep 7 11:38:43 2009 (r196919) +++ head/sys/ufs/ffs/ffs_vfsops.c Mon Sep 7 11:55:34 2009 (r196920) @@ -1467,6 +1467,7 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags vp->v_vflag |= VV_FORCEINSMQ; error = insmntque(vp, mp); if (error != 0) { + uma_zfree(uma_inode, ip); *vpp = NULL; return (error); } From kib at FreeBSD.org Mon Sep 7 12:10:41 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Sep 7 12:10:52 2009 Subject: svn commit: r196921 - head/sys/fs/pseudofs Message-ID: <200909071210.n87CAflU014082@svn.freebsd.org> Author: kib Date: Mon Sep 7 12:10:41 2009 New Revision: 196921 URL: http://svn.freebsd.org/changeset/base/196921 Log: If a race is detected, pfs_vncache_alloc() may reclaim a vnode that had never been inserted into the pfs_vncache list. Since pfs_vncache_free() does not anticipate this case, it decrements pfs_vncache_entries unconditionally; if the vnode was not in the list, pfs_vncache_entries will no longer reflect the actual number of list entries. This may cause size of the cache to exceed the configured maximum. It may also trigger a panic during module unload or system shutdown. Do not decrement pfs_vncache_entries for the vnode that was not in the list. Submitted by: tegge Reviewed by: des MFC after: 1 week Modified: head/sys/fs/pseudofs/pseudofs_vncache.c Modified: head/sys/fs/pseudofs/pseudofs_vncache.c ============================================================================== --- head/sys/fs/pseudofs/pseudofs_vncache.c Mon Sep 7 11:55:34 2009 (r196920) +++ head/sys/fs/pseudofs/pseudofs_vncache.c Mon Sep 7 12:10:41 2009 (r196921) @@ -246,11 +246,13 @@ pfs_vncache_free(struct vnode *vp) KASSERT(pvd != NULL, ("pfs_vncache_free(): no vnode data\n")); if (pvd->pvd_next) pvd->pvd_next->pvd_prev = pvd->pvd_prev; - if (pvd->pvd_prev) + if (pvd->pvd_prev) { pvd->pvd_prev->pvd_next = pvd->pvd_next; - else if (pfs_vncache == pvd) + --pfs_vncache_entries; + } else if (pfs_vncache == pvd) { pfs_vncache = pvd->pvd_next; - --pfs_vncache_entries; + --pfs_vncache_entries; + } mtx_unlock(&pfs_vncache_mutex); free(pvd, M_PFSVNCACHE); From pjd at FreeBSD.org Mon Sep 7 14:16:50 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 14:16:56 2009 Subject: svn commit: r196927 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909071416.n87EGoiV017087@svn.freebsd.org> Author: pjd Date: Mon Sep 7 14:16:50 2009 New Revision: 196927 URL: http://svn.freebsd.org/changeset/base/196927 Log: Changing provider size is not really supported by GEOM, but doing so when provider is closed should be ok. When administrator requests to change ZVOL size do it immediately if ZVOL is closed or do it on last ZVOL close. PR: kern/136942 Requested by: Bernard Buri MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Mon Sep 7 14:10:55 2009 (r196926) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Mon Sep 7 14:16:50 2009 (r196927) @@ -153,7 +153,22 @@ static int zvol_dump_init(zvol_state_t * static void zvol_size_changed(zvol_state_t *zv, major_t maj) { + struct g_provider *pp; + + g_topology_assert(); + pp = zv->zv_provider; + if (pp == NULL) + return; + if (zv->zv_volsize == pp->mediasize) + return; + /* + * Changing provider size is not really supported by GEOM, but it + * should be safe when provider is closed. + */ + if (zv->zv_total_opens > 0) + return; + pp->mediasize = zv->zv_volsize; } int @@ -263,6 +278,7 @@ zvol_access(struct g_provider *pp, int a } zv->zv_total_opens += acr + acw + ace; + zvol_size_changed(zv, 0); mutex_exit(&zvol_state_lock); @@ -1072,11 +1088,6 @@ zvol_set_volblocksize(const char *name, if (error == ENOTSUP) error = EBUSY; dmu_tx_commit(tx); - /* XXX: Not supported. */ -#if 0 - if (error == 0) - zv->zv_provider->sectorsize = zc->zc_volblocksize; -#endif } end: mutex_exit(&zvol_state_lock); From pjd at FreeBSD.org Mon Sep 7 14:44:05 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 14:44:11 2009 Subject: svn commit: r196928 - head/cddl/contrib/opensolaris/cmd/zdb Message-ID: <200909071444.n87Ei5ND017650@svn.freebsd.org> Author: pjd Date: Mon Sep 7 14:44:04 2009 New Revision: 196928 URL: http://svn.freebsd.org/changeset/base/196928 Log: Teach zdb(8) how to obtain GEOM provider size. PR: kern/133134 Reported by: Philipp Wuensche MFC after: 3 days Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Sep 7 14:16:50 2009 (r196927) +++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Sep 7 14:44:04 2009 (r196928) @@ -1322,6 +1322,14 @@ dump_label(const char *dev) exit(1); } + if (S_ISCHR(statbuf.st_mode)) { + if (ioctl(fd, DIOCGMEDIASIZE, &statbuf.st_size) == -1) { + (void) printf("failed to get size of '%s': %s\n", dev, + strerror(errno)); + exit(1); + } + } + psize = statbuf.st_size; psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t)); From ume at FreeBSD.org Mon Sep 7 15:22:54 2009 From: ume at FreeBSD.org (Hajimu UMEMOTO) Date: Mon Sep 7 15:23:05 2009 Subject: svn commit: r196929 - head/sbin/ifconfig Message-ID: <200909071522.n87FMs68018545@svn.freebsd.org> Author: ume Date: Mon Sep 7 15:22:54 2009 New Revision: 196929 URL: http://svn.freebsd.org/changeset/base/196929 Log: Suppress an options line when no bit is on. Reviewed by: hrs MFC after: 3 days Modified: head/sbin/ifconfig/ifgif.c Modified: head/sbin/ifconfig/ifgif.c ============================================================================== --- head/sbin/ifconfig/ifgif.c Mon Sep 7 14:44:04 2009 (r196928) +++ head/sbin/ifconfig/ifgif.c Mon Sep 7 15:22:54 2009 (r196929) @@ -71,6 +71,8 @@ gif_status(int s) ifr.ifr_data = (caddr_t)&opts; if (ioctl(s, GIFGOPTS, &ifr) == -1) return; + if (opts == 0) + return; printf("\toptions=%d<", opts); for (i=0; i < sizeof(gif_opts)/sizeof(gif_opts[0]); i++) { From hrs at FreeBSD.org Mon Sep 7 15:52:15 2009 From: hrs at FreeBSD.org (Hiroki Sato) Date: Mon Sep 7 15:53:28 2009 Subject: svn commit: r196931 - head/sbin/ifconfig Message-ID: <200909071552.n87FqFwD019220@svn.freebsd.org> Author: hrs Date: Mon Sep 7 15:52:15 2009 New Revision: 196931 URL: http://svn.freebsd.org/changeset/base/196931 Log: Use printb() instead of rolling its own routine to display bits in options=<>. Pointed out by: ume MFC after: 3 days Modified: head/sbin/ifconfig/ifgif.c Modified: head/sbin/ifconfig/ifgif.c ============================================================================== --- head/sbin/ifconfig/ifgif.c Mon Sep 7 15:43:09 2009 (r196930) +++ head/sbin/ifconfig/ifgif.c Mon Sep 7 15:52:15 2009 (r196931) @@ -51,38 +51,22 @@ static const char rcsid[] = #include "ifconfig.h" -static void gif_status(int); +#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER" -static struct { - const char *label; - u_int mask; -} gif_opts[] = { - { "ACCEPT_REV_ETHIP_VER", GIF_ACCEPT_REVETHIP }, - { "SEND_REV_ETHIP_VER", GIF_SEND_REVETHIP }, -}; +static void gif_status(int); static void gif_status(int s) { int opts; - int nopts = 0; - size_t i; ifr.ifr_data = (caddr_t)&opts; if (ioctl(s, GIFGOPTS, &ifr) == -1) return; if (opts == 0) return; - - printf("\toptions=%d<", opts); - for (i=0; i < sizeof(gif_opts)/sizeof(gif_opts[0]); i++) { - if (opts & gif_opts[i].mask) { - if (nopts++) - printf(","); - printf("%s", gif_opts[i].label); - } - } - printf(">\n"); + printb("\toptions", opts, GIFBITS); + putchar('\n'); } static void From syrinx at FreeBSD.org Mon Sep 7 16:00:33 2009 From: syrinx at FreeBSD.org (Shteryana Shopova) Date: Mon Sep 7 16:00:45 2009 Subject: svn commit: r196932 - head/sys/netinet Message-ID: <200909071600.n87G0XdT019506@svn.freebsd.org> Author: syrinx Date: Mon Sep 7 16:00:33 2009 New Revision: 196932 URL: http://svn.freebsd.org/changeset/base/196932 Log: When joining a multicast group, the inp_lookup_mcast_ifp call does a KASSERT that the group address is multicast, so the check if this is indeed true and eventually return a EINVAL if not, should be done before calling inp_lookup_mcast_ifp. This fixes a kernel crash when calling setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,...) with invalid group address. Reviewed by: bms Approved by: bms MFC after: 3 days Modified: head/sys/netinet/in_mcast.c Modified: head/sys/netinet/in_mcast.c ============================================================================== --- head/sys/netinet/in_mcast.c Mon Sep 7 15:52:15 2009 (r196931) +++ head/sys/netinet/in_mcast.c Mon Sep 7 16:00:33 2009 (r196932) @@ -1899,6 +1899,9 @@ inp_join_group(struct inpcb *inp, struct ssa->sin.sin_addr = mreqs.imr_sourceaddr; } + if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr))) + return (EINVAL); + ifp = inp_lookup_mcast_ifp(inp, &gsa->sin, mreqs.imr_interface); CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", @@ -1936,6 +1939,9 @@ inp_join_group(struct inpcb *inp, struct ssa->sin.sin_port = 0; } + if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr))) + return (EINVAL); + if (gsr.gsr_interface == 0 || V_if_index < gsr.gsr_interface) return (EADDRNOTAVAIL); ifp = ifnet_byindex(gsr.gsr_interface); @@ -1948,9 +1954,6 @@ inp_join_group(struct inpcb *inp, struct break; } - if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr))) - return (EINVAL); - if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0) return (EADDRNOTAVAIL); From sam at FreeBSD.org Mon Sep 7 16:08:22 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Mon Sep 7 16:08:27 2009 Subject: svn commit: r196933 - head/sys/dev/ath Message-ID: <200909071608.n87G8Lqq019727@svn.freebsd.org> Author: sam Date: Mon Sep 7 16:08:21 2009 New Revision: 196933 URL: http://svn.freebsd.org/changeset/base/196933 Log: correct typo that was a noop on 32-bit machines but a bug on 64-bit machines Submitted by: phk Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Sep 7 16:00:33 2009 (r196932) +++ head/sys/dev/ath/if_ath.c Mon Sep 7 16:08:21 2009 (r196933) @@ -1452,7 +1452,7 @@ ath_hal_gethangstate(struct ath_hal *ah, uint32_t rsize; void *sp; - if (!ath_hal_getdiagstate(ah, 32, &mask, sizeof(&mask), &sp, &rsize)) + if (!ath_hal_getdiagstate(ah, 32, &mask, sizeof(mask), &sp, &rsize)) return 0; KASSERT(rsize == sizeof(uint32_t), ("resultsize %u", rsize)); *hangs = *(uint32_t *)sp; From sam at FreeBSD.org Mon Sep 7 16:12:07 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Mon Sep 7 16:12:19 2009 Subject: svn commit: r196934 - head/sys/dev/ath/ath_hal Message-ID: <200909071612.n87GC7tW019850@svn.freebsd.org> Author: sam Date: Mon Sep 7 16:12:07 2009 New Revision: 196934 URL: http://svn.freebsd.org/changeset/base/196934 Log: fix extraneous return that can cause a memory leak Submitted by: phk MFC after: 1 week Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v3.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Mon Sep 7 16:08:21 2009 (r196933) +++ head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Mon Sep 7 16:12:07 2009 (r196934) @@ -1759,7 +1759,7 @@ legacyEepromDetach(struct ath_hal *ah) HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom; if (ee->ee_version >= AR_EEPROM_VER4_0 && ee->ee_eepMap == 1) - return freeEepromRawPowerCalInfo5112(ah, ee); + freeEepromRawPowerCalInfo5112(ah, ee); ath_hal_free(ee); AH_PRIVATE(ah)->ah_eeprom = AH_NULL; } From sam at FreeBSD.org Mon Sep 7 16:18:17 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Mon Sep 7 16:18:22 2009 Subject: svn commit: r196935 - head/sys/dev/ath Message-ID: <200909071618.n87GIGHh020046@svn.freebsd.org> Author: sam Date: Mon Sep 7 16:18:16 2009 New Revision: 196935 URL: http://svn.freebsd.org/changeset/base/196935 Log: remove extranous return Submitted by: phk MFC after: 1 week Modified: head/sys/dev/ath/ah_osdep.c Modified: head/sys/dev/ath/ah_osdep.c ============================================================================== --- head/sys/dev/ath/ah_osdep.c Mon Sep 7 16:12:07 2009 (r196934) +++ head/sys/dev/ath/ah_osdep.c Mon Sep 7 16:18:16 2009 (r196935) @@ -110,7 +110,7 @@ ath_hal_malloc(size_t size) void ath_hal_free(void* p) { - return free(p, M_ATH_HAL); + free(p, M_ATH_HAL); } void From trasz at FreeBSD.org Mon Sep 7 16:19:33 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 16:19:40 2009 Subject: svn commit: r196936 - head/bin/setfacl Message-ID: <200909071619.n87GJXwc020108@svn.freebsd.org> Author: trasz Date: Mon Sep 7 16:19:32 2009 New Revision: 196936 URL: http://svn.freebsd.org/changeset/base/196936 Log: Add NFSv4 support to setfacl(1). Reviewed by: rwatson Modified: head/bin/setfacl/mask.c head/bin/setfacl/merge.c head/bin/setfacl/remove.c head/bin/setfacl/setfacl.1 head/bin/setfacl/setfacl.c head/bin/setfacl/setfacl.h Modified: head/bin/setfacl/mask.c ============================================================================== --- head/bin/setfacl/mask.c Mon Sep 7 16:18:16 2009 (r196935) +++ head/bin/setfacl/mask.c Mon Sep 7 16:19:32 2009 (r196936) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); /* set the appropriate mask the given ACL's */ int -set_acl_mask(acl_t *prev_acl) +set_acl_mask(acl_t *prev_acl, const char *filename) { acl_entry_t entry; acl_t acl; @@ -59,7 +59,7 @@ set_acl_mask(acl_t *prev_acl) acl = acl_dup(*prev_acl); if (acl == NULL) - err(1, "acl_dup() failed"); + err(1, "%s: acl_dup() failed", filename); if (n_flag == 0) { /* @@ -70,7 +70,7 @@ set_acl_mask(acl_t *prev_acl) * class in the resulting ACL */ if (acl_calc_mask(&acl)) { - warn("acl_calc_mask() failed"); + warn("%s: acl_calc_mask() failed", filename); acl_free(acl); return (-1); } @@ -86,7 +86,8 @@ set_acl_mask(acl_t *prev_acl) while (acl_get_entry(acl, entry_id, &entry) == 1) { entry_id = ACL_NEXT_ENTRY; if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed"); + err(1, "%s: acl_get_tag_type() failed", + filename); if (tag == ACL_MASK) { acl_free(acl); @@ -100,7 +101,7 @@ set_acl_mask(acl_t *prev_acl) * file, then write an error message to standard error and * continue with the next file. */ - warnx("warning: no mask entry"); + warnx("%s: warning: no mask entry", filename); acl_free(acl); return (0); } Modified: head/bin/setfacl/merge.c ============================================================================== --- head/bin/setfacl/merge.c Mon Sep 7 16:18:16 2009 (r196935) +++ head/bin/setfacl/merge.c Mon Sep 7 16:19:32 2009 (r196936) @@ -36,12 +36,15 @@ __FBSDID("$FreeBSD$"); #include "setfacl.h" -static int merge_user_group(acl_entry_t *entry, acl_entry_t *entry_new); +static int merge_user_group(acl_entry_t *entry, acl_entry_t *entry_new, + int acl_brand); static int -merge_user_group(acl_entry_t *entry, acl_entry_t *entry_new) +merge_user_group(acl_entry_t *entry, acl_entry_t *entry_new, int acl_brand) { acl_permset_t permset; + acl_entry_type_t entry_type; + acl_flagset_t flagset; int have_entry; uid_t *id, *id_new; @@ -59,6 +62,18 @@ merge_user_group(acl_entry_t *entry, acl err(1, "acl_get_permset() failed"); if (acl_set_permset(*entry_new, permset) == -1) err(1, "acl_set_permset() failed"); + + if (acl_brand == ACL_BRAND_NFS4) { + if (acl_get_entry_type_np(*entry, &entry_type)) + err(1, "acl_get_entry_type_np() failed"); + if (acl_set_entry_type_np(*entry_new, entry_type)) + err(1, "acl_set_entry_type_np() failed"); + if (acl_get_flagset_np(*entry, &flagset)) + err(1, "acl_get_flagset_np() failed"); + if (acl_set_flagset_np(*entry_new, flagset)) + err(1, "acl_set_flagset_np() failed"); + } + have_entry = 1; } acl_free(id); @@ -71,20 +86,31 @@ merge_user_group(acl_entry_t *entry, acl * merge an ACL into existing file's ACL */ int -merge_acl(acl_t acl, acl_t *prev_acl) +merge_acl(acl_t acl, acl_t *prev_acl, const char *filename) { acl_entry_t entry, entry_new; acl_permset_t permset; acl_t acl_new; acl_tag_t tag, tag_new; - int entry_id, entry_id_new, have_entry; + acl_entry_type_t entry_type, entry_type_new; + acl_flagset_t flagset; + int entry_id, entry_id_new, have_entry, entry_number = 0; + int acl_brand, prev_acl_brand; + + acl_get_brand_np(acl, &acl_brand); + acl_get_brand_np(*prev_acl, &prev_acl_brand); + + if (acl_brand != prev_acl_brand) { + warnx("%s: branding mismatch; existing ACL is %s, " + "entry to be merged is %s", filename, + prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e", + acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e"); + return (-1); + } - if (acl_type == ACL_TYPE_ACCESS) - acl_new = acl_dup(prev_acl[ACCESS_ACL]); - else - acl_new = acl_dup(prev_acl[DEFAULT_ACL]); + acl_new = acl_dup(*prev_acl); if (acl_new == NULL) - err(1, "acl_dup() failed"); + err(1, "%s: acl_dup() failed", filename); entry_id = ACL_FIRST_ENTRY; @@ -94,28 +120,45 @@ merge_acl(acl_t acl, acl_t *prev_acl) /* keep track of existing ACL_MASK entries */ if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed - invalid ACL entry"); + err(1, "%s: acl_get_tag_type() failed - " + "invalid ACL entry", filename); if (tag == ACL_MASK) have_mask = 1; /* check against the existing ACL entries */ entry_id_new = ACL_FIRST_ENTRY; - while (have_entry == 0 && - acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) { + while (acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) { entry_id_new = ACL_NEXT_ENTRY; if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed"); + err(1, "%s: acl_get_tag_type() failed", + filename); if (acl_get_tag_type(entry_new, &tag_new) == -1) - err(1, "acl_get_tag_type() failed"); + err(1, "%s: acl_get_tag_type() failed", + filename); if (tag != tag_new) continue; + /* + * For NFSv4, in addition to "tag" and "id" we also + * compare "entry_type". + */ + if (acl_brand == ACL_BRAND_NFS4) { + if (acl_get_entry_type_np(entry, &entry_type)) + err(1, "%s: acl_get_entry_type_np() " + "failed", filename); + if (acl_get_entry_type_np(entry_new, &entry_type_new)) + err(1, "%s: acl_get_entry_type_np() " + "failed", filename); + if (entry_type != entry_type_new) + continue; + } + switch(tag) { case ACL_USER: case ACL_GROUP: have_entry = merge_user_group(&entry, - &entry_new); + &entry_new, acl_brand); if (have_entry == 0) break; /* FALLTHROUGH */ @@ -123,37 +166,127 @@ merge_acl(acl_t acl, acl_t *prev_acl) case ACL_GROUP_OBJ: case ACL_OTHER: case ACL_MASK: + case ACL_EVERYONE: if (acl_get_permset(entry, &permset) == -1) - err(1, "acl_get_permset() failed"); + err(1, "%s: acl_get_permset() failed", + filename); if (acl_set_permset(entry_new, permset) == -1) - err(1, "acl_set_permset() failed"); + err(1, "%s: acl_set_permset() failed", + filename); + + if (acl_brand == ACL_BRAND_NFS4) { + if (acl_get_entry_type_np(entry, &entry_type)) + err(1, "%s: acl_get_entry_type_np() failed", + filename); + if (acl_set_entry_type_np(entry_new, entry_type)) + err(1, "%s: acl_set_entry_type_np() failed", + filename); + if (acl_get_flagset_np(entry, &flagset)) + err(1, "%s: acl_get_flagset_np() failed", + filename); + if (acl_set_flagset_np(entry_new, flagset)) + err(1, "%s: acl_set_flagset_np() failed", + filename); + } have_entry = 1; break; default: /* should never be here */ - errx(1, "Invalid tag type: %i", tag); + errx(1, "%s: invalid tag type: %i", filename, tag); break; } } /* if this entry has not been found, it must be new */ if (have_entry == 0) { - if (acl_create_entry(&acl_new, &entry_new) == -1) { - acl_free(acl_new); - return (-1); + + /* + * NFSv4 ACL entries must be prepended to the ACL. + * Appending them at the end makes no sense, since + * in most cases they wouldn't even get evaluated. + */ + if (acl_brand == ACL_BRAND_NFS4) { + if (acl_create_entry_np(&acl_new, &entry_new, entry_number) == -1) { + warn("%s: acl_create_entry_np() failed", filename); + acl_free(acl_new); + return (-1); + } + /* + * Without this increment, adding several + * entries at once, for example + * "setfacl -m user:1:r:allow,user:2:r:allow", + * would make them appear in reverse order. + */ + entry_number++; + } else { + if (acl_create_entry(&acl_new, &entry_new) == -1) { + warn("%s: acl_create_entry() failed", filename); + acl_free(acl_new); + return (-1); + } } if (acl_copy_entry(entry_new, entry) == -1) - err(1, "acl_copy_entry() failed"); + err(1, "%s: acl_copy_entry() failed", filename); } } - if (acl_type == ACL_TYPE_ACCESS) { - acl_free(prev_acl[ACCESS_ACL]); - prev_acl[ACCESS_ACL] = acl_new; - } else { - acl_free(prev_acl[DEFAULT_ACL]); - prev_acl[DEFAULT_ACL] = acl_new; + acl_free(*prev_acl); + *prev_acl = acl_new; + + return (0); +} + +int +add_acl(acl_t acl, uint entry_number, acl_t *prev_acl, const char *filename) +{ + acl_entry_t entry, entry_new; + acl_t acl_new; + int entry_id, acl_brand, prev_acl_brand; + + acl_get_brand_np(acl, &acl_brand); + acl_get_brand_np(*prev_acl, &prev_acl_brand); + + if (prev_acl_brand != ACL_BRAND_NFS4) { + warnx("%s: the '-a' option is only applicable to NFSv4 ACLs", + filename); + return (-1); + } + + if (acl_brand != ACL_BRAND_NFS4) { + warnx("%s: branding mismatch; existing ACL is NFSv4, " + "entry to be added is POSIX.1e", filename); + return (-1); + } + + acl_new = acl_dup(*prev_acl); + if (acl_new == NULL) + err(1, "%s: acl_dup() failed", filename); + + entry_id = ACL_FIRST_ENTRY; + + while (acl_get_entry(acl, entry_id, &entry) == 1) { + entry_id = ACL_NEXT_ENTRY; + + if (acl_create_entry_np(&acl_new, &entry_new, entry_number) == -1) { + warn("%s: acl_create_entry_np() failed", filename); + acl_free(acl_new); + return (-1); + } + + /* + * Without this increment, adding several + * entries at once, for example + * "setfacl -m user:1:r:allow,user:2:r:allow", + * would make them appear in reverse order. + */ + entry_number++; + + if (acl_copy_entry(entry_new, entry) == -1) + err(1, "%s: acl_copy_entry() failed", filename); } + acl_free(*prev_acl); + *prev_acl = acl_new; + return (0); } Modified: head/bin/setfacl/remove.c ============================================================================== --- head/bin/setfacl/remove.c Mon Sep 7 16:18:16 2009 (r196935) +++ head/bin/setfacl/remove.c Mon Sep 7 16:19:32 2009 (r196936) @@ -41,21 +41,31 @@ __FBSDID("$FreeBSD$"); * remove ACL entries from an ACL */ int -remove_acl(acl_t acl, acl_t *prev_acl) +remove_acl(acl_t acl, acl_t *prev_acl, const char *filename) { acl_entry_t entry; acl_t acl_new; acl_tag_t tag; - int carried_error, entry_id; + int carried_error, entry_id, acl_brand, prev_acl_brand; + + carried_error = 0; + + acl_get_brand_np(acl, &acl_brand); + acl_get_brand_np(*prev_acl, &prev_acl_brand); + + if (acl_brand != prev_acl_brand) { + warnx("%s: branding mismatch; existing ACL is %s, " + "entry to be removed is %s", filename, + prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e", + acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e"); + return (-1); + } carried_error = 0; - if (acl_type == ACL_TYPE_ACCESS) - acl_new = acl_dup(prev_acl[ACCESS_ACL]); - else - acl_new = acl_dup(prev_acl[DEFAULT_ACL]); + acl_new = acl_dup(*prev_acl); if (acl_new == NULL) - err(1, "acl_dup() failed"); + err(1, "%s: acl_dup() failed", filename); tag = ACL_UNDEFINED_TAG; @@ -64,23 +74,68 @@ remove_acl(acl_t acl, acl_t *prev_acl) while (acl_get_entry(acl, entry_id, &entry) == 1) { entry_id = ACL_NEXT_ENTRY; if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed"); + err(1, "%s: acl_get_tag_type() failed", filename); if (tag == ACL_MASK) have_mask++; if (acl_delete_entry(acl_new, entry) == -1) { carried_error++; - warnx("cannot remove non-existent acl entry"); + warnx("%s: cannot remove non-existent ACL entry", + filename); } } - if (acl_type == ACL_TYPE_ACCESS) { - acl_free(prev_acl[ACCESS_ACL]); - prev_acl[ACCESS_ACL] = acl_new; - } else { - acl_free(prev_acl[DEFAULT_ACL]); - prev_acl[DEFAULT_ACL] = acl_new; + acl_free(*prev_acl); + *prev_acl = acl_new; + + if (carried_error) + return (-1); + + return (0); +} + +int +remove_by_number(uint entry_number, acl_t *prev_acl, const char *filename) +{ + acl_entry_t entry; + acl_t acl_new; + acl_tag_t tag; + int carried_error, entry_id; + uint i; + + carried_error = 0; + + acl_new = acl_dup(*prev_acl); + if (acl_new == NULL) + err(1, "%s: acl_dup() failed", filename); + + tag = ACL_UNDEFINED_TAG; + + /* + * Find out whether we're removing the mask entry, + * to behave the same as the routine above. + * + * XXX: Is this loop actually needed? + */ + entry_id = ACL_FIRST_ENTRY; + i = 0; + while (acl_get_entry(acl_new, entry_id, &entry) == 1) { + entry_id = ACL_NEXT_ENTRY; + if (i != entry_number) + continue; + if (acl_get_tag_type(entry, &tag) == -1) + err(1, "%s: acl_get_tag_type() failed", filename); + if (tag == ACL_MASK) + have_mask++; + } + + if (acl_delete_entry_np(acl_new, entry_number) == -1) { + carried_error++; + warn("%s: acl_delete_entry_np() failed", filename); } + acl_free(*prev_acl); + *prev_acl = acl_new; + if (carried_error) return (-1); @@ -91,18 +146,14 @@ remove_acl(acl_t acl, acl_t *prev_acl) * remove default entries */ int -remove_default(acl_t *prev_acl) +remove_default(acl_t *prev_acl, const char *filename) { - if (prev_acl[1]) { - acl_free(prev_acl[1]); - prev_acl[1] = acl_init(ACL_MAX_ENTRIES); - if (prev_acl[1] == NULL) - err(1, "acl_init() failed"); - } else { - warn("cannot remove default ACL"); - return (-1); - } + acl_free(*prev_acl); + *prev_acl = acl_init(ACL_MAX_ENTRIES); + if (*prev_acl == NULL) + err(1, "%s: acl_init() failed", filename); + return (0); } @@ -110,71 +161,14 @@ remove_default(acl_t *prev_acl) * remove extended entries */ void -remove_ext(acl_t *prev_acl) +remove_ext(acl_t *prev_acl, const char *filename) { - acl_t acl_new, acl_old; - acl_entry_t entry, entry_new; - acl_permset_t perm; - acl_tag_t tag; - int entry_id, have_mask_entry; - - if (acl_type == ACL_TYPE_ACCESS) - acl_old = acl_dup(prev_acl[ACCESS_ACL]); - else - acl_old = acl_dup(prev_acl[DEFAULT_ACL]); - if (acl_old == NULL) - err(1, "acl_dup() failed"); + acl_t acl_new; - have_mask_entry = 0; - acl_new = acl_init(ACL_MAX_ENTRIES); + acl_new = acl_strip_np(*prev_acl, !n_flag); if (acl_new == NULL) - err(1, "acl_init() failed"); - tag = ACL_UNDEFINED_TAG; - - /* only save the default user/group/other entries */ - entry_id = ACL_FIRST_ENTRY; - while (acl_get_entry(acl_old, entry_id, &entry) == 1) { - entry_id = ACL_NEXT_ENTRY; - - if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed"); - - switch(tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_OTHER: - if (acl_get_tag_type(entry, &tag) == -1) - err(1, "acl_get_tag_type() failed"); - if (acl_get_permset(entry, &perm) == -1) - err(1, "acl_get_permset() failed"); - if (acl_create_entry(&acl_new, &entry_new) == -1) - err(1, "acl_create_entry() failed"); - if (acl_set_tag_type(entry_new, tag) == -1) - err(1, "acl_set_tag_type() failed"); - if (acl_set_permset(entry_new, perm) == -1) - err(1, "acl_get_permset() failed"); - if (acl_copy_entry(entry_new, entry) == -1) - err(1, "acl_copy_entry() failed"); - break; - case ACL_MASK: - have_mask_entry = 1; - break; - default: - break; - } - } - if (have_mask_entry && n_flag == 0) { - if (acl_calc_mask(&acl_new) == -1) - err(1, "acl_calc_mask() failed"); - } else { - have_mask = 1; - } + err(1, "%s: acl_strip_np() failed", filename); - if (acl_type == ACL_TYPE_ACCESS) { - acl_free(prev_acl[ACCESS_ACL]); - prev_acl[ACCESS_ACL] = acl_new; - } else { - acl_free(prev_acl[DEFAULT_ACL]); - prev_acl[DEFAULT_ACL] = acl_new; - } + acl_free(*prev_acl); + *prev_acl = acl_new; } Modified: head/bin/setfacl/setfacl.1 ============================================================================== --- head/bin/setfacl/setfacl.1 Mon Sep 7 16:18:16 2009 (r196935) +++ head/bin/setfacl/setfacl.1 Mon Sep 7 16:19:32 2009 (r196936) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 2001 +.Dd September 5, 2009 .Dt SETFACL 1 .Os .Sh NAME @@ -34,9 +34,10 @@ .Sh SYNOPSIS .Nm .Op Fl bdhkn +.Op Fl a Ar position entries .Op Fl m Ar entries .Op Fl M Ar file -.Op Fl x Ar entries +.Op Fl x Ar entries | position .Op Fl X Ar file .Op Ar .Sh DESCRIPTION @@ -50,9 +51,19 @@ the file names are taken from the standa .Pp The following options are available: .Bl -tag -width indent +.It Fl a Ar position entries +Modify the ACL on the specified files by inserting new +ACL entries +specified in +.Ar entries , +starting at position +.Ar position , +counting from zero. +This option is only applicable to NFSv4 ACLs. .It Fl b -Remove all ACL entries except for the three required entries. -If the ACL contains a +Remove all ACL entries except for the three required entries +(POSIX.1e ACLs) or six "canonical" entries (NFSv4 ACLs). +If the POSIX.1e ACL contains a .Dq Li mask entry, the permissions of the .Dq Li group @@ -66,7 +77,7 @@ entries of the current ACL. The operations apply to the default ACL entries instead of access ACL entries. Currently only directories may have -default ACL's. +default ACL's. This option is not applicable to NFSv4 ACLs. .It Fl h If the target of the operation is a symbolic link, perform the operation on the symbolic link itself, rather than following the link. @@ -77,7 +88,7 @@ is not considered an error if the specif any default ACL entries. An error will be reported if any of the specified files cannot have a default entry (i.e.\& -non-directories). +non-directories). This option is not applicable to NFSv4 ACLs. .It Fl m Ar entries Modify the ACL entries on the specified files by adding new entries and modifying existing ACL entries with the ACL entries @@ -95,11 +106,15 @@ is the input is taken from stdin. .It Fl n Do not recalculate the permissions associated with the ACL -mask entry. -.It Fl x Ar entries -Remove the ACL entries specified in +mask entry. This option is not applicable to NFSv4 ACLs. +.It Fl x Ar entries | position +If .Ar entries +is specified, remove the ACL entries specified there from the access or default ACL of the specified files. +Otherwise, remove entry at index +.Ar position , +counting from zero. .It Fl X Ar file Remove the ACL entries specified in the file .Ar file @@ -108,8 +123,8 @@ from the access or default ACL of the sp .Pp The above options are evaluated in the order specified on the command-line. -.Sh ACL ENTRIES -An ACL entry contains three colon-separated fields: +.Sh POSIX.1e ACL ENTRIES +A POSIX.1E ACL entry contains three colon-separated fields: an ACL tag, an ACL qualifier, and discretionary access permissions: .Bl -tag -width indent @@ -223,7 +238,7 @@ previously specified; whitespace is igno .Ql # is ignored (comments). .Pp -When ACL entries are evaluated, the access check algorithm checks +When POSIX.1e ACL entries are evaluated, the access check algorithm checks the ACL entries in the following order: file owner, .Dq Li user ACL entries, file owning group, @@ -243,13 +258,135 @@ ACL entries for user, group, other and m For more details see the examples below. Default ACLs can be created by using .Fl d . +.Sh NFSv4 ACL ENTRIES +An NFSv4 ACL entry contains four or five colon-separated fields: an ACL tag, +an ACL qualifier (only for +.Dq Li user +and +.Dq Li group +tags), discretionary access permissions, ACL inheritance flags, and ACL type: +.Bl -tag -width indent +.It Ar "ACL tag" +The ACL tag specifies the ACL entry type and consists of +one of the following: +.Dq Li user +or +.Ql u +specifying the access +granted to the specified user; +.Dq Li group +or +.Ql g +specifying the access granted to the specified group; +.Dq Li owner@ +specifying the access granted to the owner of the file; +.Dq Li group@ +specifying the access granted to the file owning group; +.Dq Li everyone@ +specifying everyone. Note that +.Dq Li everyone@ +is not the same as traditional Unix +.Dq Li other +- it means, +literally, everyone, including file owner and owning group. +.It Ar "ACL qualifier" +The ACL qualifier field describes the user or group associated with +the ACL entry. +It may consist of one of the following: uid or +user name, or gid or group name. In entries whose tag type is +one of +.Dq Li owner@ , +.Dq Li group@ , +or +.Dq Li everyone@ , +this field is ommited altogether, including the trailing comma. +.It Ar "access permissions" +Access permissions may be specified in either short or long form. +Short and long forms may not be mixed. +Permissions in long form are separated by the +.Ql / +character; in short form, they are concatenated together. +Valid permissions are: +.Bl -tag -width ".Dv short" +.It Short +Long +.It r +read_data +.It w +write_data +.It x +execute +.It p +append_data +.It d +delete_child +.It D +delete +.It a +read_attributes +.It A +write_attributes +.It R +read_xattr +.It W +write_xattr +.It c +read_acl +.It C +write_acl +.It o +write_owner +.It S +synchronize +.El +.It Ar "ACL inheritance flags" +Inheritance flags may be specified in either short or long form. +Short and long forms may not be mixed. +Access flags in long form are separated by the +.Ql / +character; in short form, they are concatenated together. +Valid inheritance flags are: +.Bl -tag -width ".Dv short" +.It Short +Long +.It f +file_inherit +.It d +dir_inherit +.It i +inherit_only +.It n +no_propagate +.El +.Pp +Inheritance flags may be only set on directories. +.It Ar "ACL type" +The ACL type field is either +.Dq Li allow +or +.Dq Li deny . +.El +.Pp +ACL entries applied from a file using the +.Fl M +or +.Fl X +options shall be of the following form: one ACL entry per line, as +previously specified; whitespace is ignored; any text after a +.Ql # +is ignored (comments). +.Pp +NFSv4 ACL entries are evaluated in their visible order. +.Pp +Multiple ACL entries specified on the command line are +separated by commas. .Sh EXIT STATUS .Ex -std .Sh EXAMPLES .Dl setfacl -d -m u::rwx,g::rx,o::rx,mask::rwx dir .Dl setfacl -d -m g:admins:rwx dir .Pp -The first command sets the mandatory elements of the default ACL. +The first command sets the mandatory elements of the POSIX.1e default ACL. The second command specifies that users in group admins can have read, write, and execute permissions for directory named "dir". It should be noted that any files or directories created underneath "dir" will @@ -259,9 +396,13 @@ inherit these default ACLs upon creation .Pp Sets read, write, and execute permissions for the .Pa file -owner's ACL entry and read and write permissions for group mail on +owner's POSIX.1e ACL entry and read and write permissions for group mail on .Pa file . .Pp +.Dl setfacl -m owner@:rwxp::allow,g:mail:rwp::allow file +.Pp +Semantically equal to the example above, but for NFSv4 ACL. +.Pp .Dl setfacl -M file1 file2 .Pp Sets/updates the ACL entries contained in @@ -271,10 +412,15 @@ on .Pp .Dl setfacl -x g:mail:rw file .Pp -Remove the group mail ACL entry containing read/write permissions +Remove the group mail POSIX.1e ACL entry containing read/write permissions from .Pa file . .Pp +.Dl setfacl -x0 file +.Pp +Remove the first entry from the NFSv4 ACL from +.Pa file . +.Pp .Dl setfacl -bn file .Pp Remove all Modified: head/bin/setfacl/setfacl.c ============================================================================== --- head/bin/setfacl/setfacl.c Mon Sep 7 16:18:16 2009 (r196935) +++ head/bin/setfacl/setfacl.c Mon Sep 7 16:19:32 2009 (r196936) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -41,9 +42,8 @@ __FBSDID("$FreeBSD$"); #include "setfacl.h" -static void add_filename(const char *filename); -static acl_t *get_file_acls(const char *filename); -static void usage(void); +static void add_filename(const char *filename); +static void usage(void); static void add_filename(const char *filename) @@ -59,57 +59,28 @@ add_filename(const char *filename) TAILQ_INSERT_TAIL(&filelist, file, next); } -static acl_t * -get_file_acls(const char *filename) -{ - acl_t *acl; - struct stat sb; - - if (stat(filename, &sb) == -1) { - warn("stat() of %s failed", filename); - return (NULL); - } - - acl = zmalloc(sizeof(acl_t) * 2); - if (h_flag) - acl[ACCESS_ACL] = acl_get_link_np(filename, ACL_TYPE_ACCESS); - else - acl[ACCESS_ACL] = acl_get_file(filename, ACL_TYPE_ACCESS); - if (acl[ACCESS_ACL] == NULL) - err(1, "acl_get_file() failed"); - if (S_ISDIR(sb.st_mode)) { - if (h_flag) - acl[DEFAULT_ACL] = acl_get_link_np(filename, - ACL_TYPE_DEFAULT); - else - acl[DEFAULT_ACL] = acl_get_file(filename, - ACL_TYPE_DEFAULT); - if (acl[DEFAULT_ACL] == NULL) - err(1, "acl_get_file() failed"); - } else - acl[DEFAULT_ACL] = NULL; - - return (acl); -} - static void usage(void) { - fprintf(stderr, "usage: setfacl [-bdhkn] [-m entries] [-M file] " - "[-x entries] [-X file] [file ...]\n"); + fprintf(stderr, "usage: setfacl [-bdhkn] [-a position entries] " + "[-m entries] [-M file] [-x entries] [-X file] [file ...]\n"); exit(1); } int main(int argc, char *argv[]) { - acl_t *acl, final_acl; + acl_t acl; + acl_type_t acl_type; char filename[PATH_MAX]; - int local_error, carried_error, ch, i; + int local_error, carried_error, ch, i, entry_number, ret; + int h_flag; struct sf_file *file; struct sf_entry *entry; const char *fn_dup; + char *end; + struct stat sb; acl_type = ACL_TYPE_ACCESS; carried_error = local_error = 0; @@ -118,13 +89,13 @@ main(int argc, char *argv[]) TAILQ_INIT(&entrylist); TAILQ_INIT(&filelist); - while ((ch = getopt(argc, argv, "M:X:bdhkm:nx:")) != -1) + while ((ch = getopt(argc, argv, "M:X:a:bdhkm:nx:")) != -1) switch(ch) { case 'M': entry = zmalloc(sizeof(struct sf_entry)); entry->acl = get_acl_from_file(optarg); if (entry->acl == NULL) - err(1, "get_acl_from_file() failed"); + err(1, "%s: get_acl_from_file() failed", optarg); entry->op = OP_MERGE_ACL; TAILQ_INSERT_TAIL(&entrylist, entry, next); break; @@ -134,6 +105,25 @@ main(int argc, char *argv[]) entry->op = OP_REMOVE_ACL; TAILQ_INSERT_TAIL(&entrylist, entry, next); break; + case 'a': + entry = zmalloc(sizeof(struct sf_entry)); + + entry_number = strtol(optarg, &end, 10); + if (end - optarg != (int)strlen(optarg)) + errx(1, "%s: invalid entry number", optarg); + if (entry_number < 0) + errx(1, "%s: entry number cannot be less than zero", optarg); + entry->entry_number = entry_number; + + if (argv[optind] == NULL) + errx(1, "missing ACL"); + entry->acl = acl_from_text(argv[optind]); + if (entry->acl == NULL) + err(1, "%s", argv[optind]); + optind++; + entry->op = OP_ADD_ACL; + TAILQ_INSERT_TAIL(&entrylist, entry, next); + break; case 'b': entry = zmalloc(sizeof(struct sf_entry)); entry->op = OP_REMOVE_EXT; @@ -163,10 +153,18 @@ main(int argc, char *argv[]) break; case 'x': entry = zmalloc(sizeof(struct sf_entry)); - entry->acl = acl_from_text(optarg); - if (entry->acl == NULL) - err(1, "%s", optarg); - entry->op = OP_REMOVE_ACL; + entry_number = strtol(optarg, &end, 10); + if (end - optarg == (int)strlen(optarg)) { + if (entry_number < 0) + errx(1, "%s: entry number cannot be less than zero", optarg); + entry->entry_number = entry_number; + entry->op = OP_REMOVE_BY_NUMBER; + } else { + entry->acl = acl_from_text(optarg); + if (entry->acl == NULL) + err(1, "%s", optarg); + entry->op = OP_REMOVE_ACL; + } TAILQ_INSERT_TAIL(&entrylist, entry, next); break; default: @@ -199,16 +197,51 @@ main(int argc, char *argv[]) /* cycle through each file */ TAILQ_FOREACH(file, &filelist, next) { - /* get our initial access and default ACL's */ - acl = get_file_acls(file->filename); - if (acl == NULL) + local_error = 0; + + if (stat(file->filename, &sb) == -1) { + warn("%s: stat() failed", file->filename); continue; - if ((acl_type == ACL_TYPE_DEFAULT) && !acl[1]) { - warnx("Default ACL not valid for %s", file->filename); + } + + if (acl_type == ACL_TYPE_DEFAULT && S_ISDIR(sb.st_mode) == 0) { + warnx("%s: default ACL may only be set on a directory", + file->filename); continue; } - local_error = 0; + if (h_flag) + ret = lpathconf(file->filename, _PC_ACL_NFS4); + else + ret = pathconf(file->filename, _PC_ACL_NFS4); + if (ret > 0) { + if (acl_type == ACL_TYPE_DEFAULT) { + warnx("%s: there are no default entries " + "in NFSv4 ACLs", file->filename); + continue; + } + acl_type = ACL_TYPE_NFS4; + } else if (ret == 0) { + if (acl_type == ACL_TYPE_NFS4) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From trasz at FreeBSD.org Mon Sep 7 16:26:04 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 16:26:17 2009 Subject: svn commit: r196938 - head/tools/regression/acltools Message-ID: <200909071626.n87GQ3al020449@svn.freebsd.org> Author: trasz Date: Mon Sep 7 16:26:03 2009 New Revision: 196938 URL: http://svn.freebsd.org/changeset/base/196938 Log: Add regression tests for NFSv4 ACLs and update POSIX.1e tests to the changed error messages. Added: head/tools/regression/acltools/01.t (contents, props changed) head/tools/regression/acltools/tools-nfs4.test (contents, props changed) Modified: head/tools/regression/acltools/00.t head/tools/regression/acltools/tools-posix.test Modified: head/tools/regression/acltools/00.t ============================================================================== --- head/tools/regression/acltools/00.t Mon Sep 7 16:25:09 2009 (r196937) +++ head/tools/regression/acltools/00.t Mon Sep 7 16:26:03 2009 (r196938) @@ -1,5 +1,32 @@ #!/bin/sh # +# Copyright (c) 2008, 2009 Edward Tomasz Napiera?a +# 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$ +# + # This is a wrapper script to run tools-posix.test. # # If any of the tests fails, here is how to debug it: go to @@ -9,9 +36,6 @@ # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test # # Output should be obvious. -# -# $FreeBSD$ -# echo "1..4" @@ -59,4 +83,3 @@ rmdir $MNT mdconfig -du $MD echo "ok 4" - Added: head/tools/regression/acltools/01.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/acltools/01.t Mon Sep 7 16:26:03 2009 (r196938) @@ -0,0 +1,86 @@ +#!/bin/sh +# +# Copyright (c) 2008, 2009 Edward Tomasz Napiera?a +# 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$ +# + +# This is a wrapper script to run tools-nfs4.test on ZFS filesystem. +# +# WARNING: It uses hardcoded ZFS pool name "acltools" +# +# If any of the tests fails, here is how to debug it: go to +# the directory with problematic filesystem mounted on it, +# and do /path/to/test run /path/to/test tools-nfs4.test, e.g. +# +# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test +# +# Output should be obvious. + +echo "1..4" + +if [ `whoami` != "root" ]; then + echo "not ok 1 - you need to be root to run this test." + exit 1 +fi + +TESTDIR=`dirname $0` + +# Set up the test filesystem. +MD=`mdconfig -at swap -s 64m` +MNT=`mktemp -dt acltools` +zpool create -R $MNT acltools /dev/$MD +if [ $? -ne 0 ]; then + echo "not ok 1 - 'zpool create' failed." + exit 1 +fi + +echo "ok 1" + +cd $MNT + +# First, check whether we can crash the kernel by creating too many +# entries. For some reason this won't work in the test file. +touch xxx +setfacl -x5 xxx +while :; do setfacl -a0 u:42:rwx:allow xxx 2> /dev/null; if [ $? -ne 0 ]; then break; fi; done +chmod 600 xxx +rm xxx +echo "ok 2" + +perl $TESTDIR/run $TESTDIR/tools-nfs4.test > /dev/null + +if [ $? -eq 0 ]; then + echo "ok 3" +else + echo "not ok 3" +fi + +cd / +zpool destroy -f acltools +rmdir $MNT +mdconfig -du $MD + +echo "ok 4" Added: head/tools/regression/acltools/tools-nfs4.test ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/acltools/tools-nfs4.test Mon Sep 7 16:26:03 2009 (r196938) @@ -0,0 +1,829 @@ +# Copyright (c) 2008, 2009 Edward Tomasz Napiera?a +# 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$ +# + +# This is a tools-level test for NFSv4 ACL functionality. Run it as root +# using ACL-enabled kernel: +# +# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test +# +# WARNING: Creates files in unsafe way. + +$ whoami +> root +$ umask 022 + +# Smoke test for getfacl(1). +$ touch xxx +$ getfacl xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ getfacl -q xxx +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Check verbose mode formatting. +$ getfacl -v xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:execute::deny +> owner@:read_data/write_data/append_data/write_attributes/write_xattr/write_acl/write_owner::allow +> group@:write_data/execute/append_data::deny +> group@:read_data::allow +> everyone@:write_data/execute/append_data/write_attributes/write_xattr/write_acl/write_owner::deny +> everyone@:read_data/read_attributes/read_xattr/read_acl/synchronize::allow + +# Test setfacl -a. +$ setfacl -a2 u:0:write_acl:allow,g:1:read_acl:deny xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:0:-----------C--:------:allow +> group:1:----------c---:------:deny +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Test user and group name resolving. +$ rm xxx +$ touch xxx +$ setfacl -a2 u:root:write_acl:allow,g:daemon:read_acl:deny xxx +$ getfacl xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:root:-----------C--:------:allow +> group:daemon:----------c---:------:deny +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Check whether ls correctly marks files with "+". +$ ls -l xxx | cut -d' ' -f1 +> -rw-r--r--+ + +# Test removing entries by number. +$ setfacl -x 4 xxx +$ setfacl -x 4 xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:0:-----------C--:------:allow +> group:1:----------c---:------:deny +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Test setfacl -m. +$ setfacl -a0 everyone@:rwx:deny xxx +$ setfacl -a0 everyone@:rwx:deny xxx +$ setfacl -a0 everyone@:rwx:deny xxx +$ setfacl -m everyone@::deny xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:0:-----------C--:------:allow +> group:1:----------c---:------:deny +> everyone@:--------------:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Test getfacl -i. +$ getfacl -i xxx +> # file: xxx +> # owner: root +> # group: wheel +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:root:-----------C--:------:allow:0 +> group:daemon:----------c---:------:deny:1 +> everyone@:--------------:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Make sure cp without any flags does not copy copy the ACL. +$ cp xxx yyy +$ ls -l yyy | cut -d' ' -f1 +> -rw-r--r-- + +# Make sure it does with the "-p" flag. +$ rm yyy +$ cp -p xxx yyy +$ getfacl -n yyy +> # file: yyy +> # owner: root +> # group: wheel +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> everyone@:--------------:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:0:-----------C--:------:allow +> group:1:----------c---:------:deny +> everyone@:--------------:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ rm yyy + +# Test removing entries by... by example? +$ setfacl -x everyone@::deny xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> user:0:-----------C--:------:allow +> group:1:----------c---:------:deny +> everyone@:r-----a-R-c--s:------:allow + +# Test setfacl -b. +$ setfacl -b xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ ls -l xxx | cut -d' ' -f1 +> -rw-r--r-- + +# Check setfacl(1) and getfacl(1) with multiple files. +$ touch xxx yyy zzz + +$ ls -l xxx yyy zzz | cut -d' ' -f1 +> -rw-r--r-- +> -rw-r--r-- +> -rw-r--r-- + +$ setfacl -m u:42:x:allow,g:43:w:allow nnn xxx yyy zzz +> setfacl: nnn: stat() failed: No such file or directory + +$ ls -l nnn xxx yyy zzz | cut -d' ' -f1 +> ls: nnn: No such file or directory +> -rw-r--r--+ +> -rw-r--r--+ +> -rw-r--r--+ + +$ getfacl -nq nnn xxx yyy zzz +> getfacl: nnn: stat() failed: No such file or directory +> user:42:--x-----------:------:allow +> group:43:-w------------:------:allow +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow +> +> user:42:--x-----------:------:allow +> group:43:-w------------:------:allow +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow +> +> user:42:--x-----------:------:allow +> group:43:-w------------:------:allow +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ setfacl -b nnn xxx yyy zzz +> setfacl: nnn: stat() failed: No such file or directory + +$ ls -l nnn xxx yyy zzz | cut -d' ' -f1 +> ls: nnn: No such file or directory +> -rw-r--r-- +> -rw-r--r-- +> -rw-r--r-- + +$ rm xxx yyy zzz + +# Test applying mode to an ACL. +$ touch xxx +$ setfacl -a0 user:42:r:allow,user:43:w:deny,user:43:w:allow,user:44:x:allow -x everyone@::allow xxx +$ chmod 600 xxx +$ getfacl -n xxx +> # file: xxx +> # owner: root +> # group: wheel +> user:42:r-------------:------:deny +> user:42:r-------------:------:allow +> user:43:-w------------:------:deny +> user:43:-w------------:------:allow +> user:44:--x-----------:------:deny +> user:44:--x-----------:------:allow +> owner@:--------------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow +$ ls -l xxx | cut -d' ' -f1 +> -rw-------+ + +$ rm xxx +$ touch xxx +$ chown 42 xxx +$ setfacl -a0 user:42:r:allow,user:43:w:deny,user:43:w:allow,user:44:x:allow xxx +$ chmod 600 xxx +$ getfacl -n xxx +> # file: xxx +> # owner: 42 +> # group: wheel +> user:42:--------------:------:deny +> user:42:r-------------:------:allow +> user:43:-w------------:------:deny +> user:43:-w------------:------:allow +> user:44:--x-----------:------:deny +> user:44:--x-----------:------:allow +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow +$ ls -l xxx | cut -d' ' -f1 +> -rw-------+ + +$ rm xxx +$ touch xxx +$ chown 43 xxx +$ setfacl -a0 user:42:r:allow,user:43:w:deny,user:43:w:allow,user:44:x:allow xxx +$ chmod 124 xxx +$ getfacl -n xxx +> # file: xxx +> # owner: 43 +> # group: wheel +> user:42:r-------------:------:deny +> user:42:r-------------:------:allow +> user:43:-w------------:------:deny +> user:43:-w------------:------:allow +> user:44:--x-----------:------:deny +> user:44:--x-----------:------:allow +> owner@:rw-p----------:------:deny +> owner@:--x----A-W-Co-:------:allow +> group@:r-x-----------:------:deny +> group@:-w-p----------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow +$ ls -l xxx | cut -d' ' -f1 +> ---x-w-r--+ + +$ rm xxx +$ touch xxx +$ chown 43 xxx +$ setfacl -a0 user:42:r:allow,user:43:w:deny,user:43:w:allow,user:44:x:allow xxx +$ chmod 412 xxx +$ getfacl -n xxx +> # file: xxx +> # owner: 43 +> # group: wheel +> user:42:r-------------:------:deny +> user:42:r-------------:------:allow +> user:43:-w------------:------:deny +> user:43:-w------------:------:allow +> user:44:--------------:------:deny +> user:44:--x-----------:------:allow +> owner@:-wxp----------:------:deny +> owner@:r------A-W-Co-:------:allow +> group@:rw-p----------:------:deny +> group@:--x-----------:------:allow +> everyone@:r-x----A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:------:allow +$ ls -l xxx | cut -d' ' -f1 +> -r----x-w-+ + +$ mkdir ddd +$ setfacl -a0 group:44:rwapd:allow ddd +$ setfacl -a0 group:43:write_data/delete_child:d:deny,group@:ad:allow ddd +$ setfacl -a0 user:42:rx:fi:allow,group:42:write_data/delete_child:d:allow ddd +$ setfacl -m everyone@:-w-p--a-R-c--s:fi:allow ddd +$ getfacl -n ddd +> # file: ddd +> # owner: root +> # group: wheel +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-d----:allow +> group:43:-w--D---------:-d----:deny +> group@:-----da-------:------:allow +> group:44:rw-p-da-------:------:allow +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:-w-p----------:------:deny +> group@:r-x-----------:------:allow +> everyone@:-w-p---A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:f-i---:allow +$ chmod 777 ddd +$ getfacl -n ddd +> # file: ddd +> # owner: root +> # group: wheel +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-di---:allow +> group:42:--------------:------:deny +> group:42:-w--D---------:------:allow +> group:43:-w--D---------:-di---:deny +> group:43:-w--D---------:------:deny +> group@:-----da-------:------:allow +> group:44:--------------:------:deny +> group:44:rw-p-da-------:------:allow +> owner@:--------------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:f-i---:allow +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:rwxp----------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:rwxp--a-R-c--s:------:allow + +$ rmdir ddd +$ mkdir ddd +$ setfacl -a0 group:44:rwapd:allow ddd +$ setfacl -a0 group:43:write_data/delete_child:d:deny,group@:ad:allow ddd +$ setfacl -a0 user:42:rx:fi:allow,group:42:write_data/delete_child:d:allow ddd +$ setfacl -m everyone@:-w-p--a-R-c--s:fi:allow ddd +$ chmod 124 ddd +$ getfacl -n ddd +> # file: ddd +> # owner: root +> # group: wheel +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-di---:allow +> group:42:--------------:------:deny +> group:42:----D---------:------:allow +> group:43:-w--D---------:-di---:deny +> group:43:-w--D---------:------:deny +> group@:-----da-------:------:allow +> group:44:r-------------:------:deny +> group:44:r----da-------:------:allow +> owner@:--------------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:f-i---:allow +> owner@:rw-p----------:------:deny +> owner@:--x----A-W-Co-:------:allow +> group@:r-x-----------:------:deny +> group@:-w-p----------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ rmdir ddd +$ mkdir ddd +$ setfacl -a0 group:44:rwapd:allow ddd +$ setfacl -a0 group:43:write_data/delete_child:d:deny,group@:ad:allow ddd +$ setfacl -a0 user:42:rx:allow,user:42:rx:fi:allow,group:42:write_data/delete_child:d:allow ddd +$ setfacl -m everyone@:-w-p--a-R-c--s:fi:allow ddd +$ chmod 412 ddd +$ getfacl -n ddd +> # file: ddd +> # owner: root +> # group: wheel +> user:42:r-------------:------:deny +> user:42:r-x-----------:------:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-di---:allow +> group:42:-w------------:------:deny +> group:42:-w--D---------:------:allow +> group:43:-w--D---------:-di---:deny +> group:43:-w--D---------:------:deny +> group@:-----da-------:------:allow +> group:44:rw-p----------:------:deny +> group:44:rw-p-da-------:------:allow +> owner@:--------------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:f-i---:allow +> owner@:-wxp----------:------:deny +> owner@:r------A-W-Co-:------:allow +> group@:rw-p----------:------:deny +> group@:--x-----------:------:allow +> everyone@:r-x----A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:------:allow + +$ rmdir ddd +$ mkdir ddd +$ setfacl -a0 group:44:rwapd:allow ddd +$ setfacl -a0 group:43:write_data/delete_child:d:deny,group@:ad:allow ddd +$ setfacl -a0 user:42:rx:allow,user:42:rx:fi:allow,group:42:write_data/delete_child:d:allow ddd +$ setfacl -m everyone@:-w-p--a-R-c--s:fi:allow ddd +$ chown 42 ddd +$ chmod 412 ddd +$ getfacl -n ddd +> # file: ddd +> # owner: 42 +> # group: wheel +> user:42:--x-----------:------:deny +> user:42:r-x-----------:------:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-di---:allow +> group:42:-w------------:------:deny +> group:42:-w--D---------:------:allow +> group:43:-w--D---------:-di---:deny +> group:43:-w--D---------:------:deny +> group@:-----da-------:------:allow +> group:44:rw-p----------:------:deny +> group:44:rw-p-da-------:------:allow +> owner@:--------------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:f-i---:allow +> owner@:-wxp----------:------:deny +> owner@:r------A-W-Co-:------:allow +> group@:rw-p----------:------:deny +> group@:--x-----------:------:allow +> everyone@:r-x----A-W-Co-:------:deny +> everyone@:-w-p--a-R-c--s:------:allow + +# Test applying ACL to mode. +$ rmdir ddd +$ mkdir ddd +$ setfacl -a0 u:42:rwx:fi:allow ddd +$ ls -ld ddd | cut -d' ' -f1 +> drwxr-xr-x+ + +$ rmdir ddd +$ mkdir ddd +$ chmod 0 ddd +$ setfacl -a0 owner@:r:allow,group@:w:deny,group@:wx:allow ddd +$ ls -ld ddd | cut -d' ' -f1 +> dr----x---+ + +# XXX: This one is fishy. Shouldn't it be "dr---wx---+"? +$ rmdir ddd +$ mkdir ddd +$ chmod 0 ddd +$ setfacl -a0 owner@:r:allow,group@:w:fi:deny,group@:wx:allow ddd +$ ls -ld ddd | cut -d' ' -f1 +> dr---wx---+ + +$ rmdir ddd +$ mkdir ddd +$ chmod 0 ddd +$ setfacl -a0 owner@:r:allow,group:43:w:deny,group:43:wx:allow ddd +$ ls -ld ddd | cut -d' ' -f1 +> dr--------+ + +$ rmdir ddd +$ mkdir ddd +$ chmod 0 ddd +$ setfacl -a0 owner@:r:allow,user:43:w:deny,user:43:wx:allow ddd +$ ls -ld ddd | cut -d' ' -f1 +> dr--------+ + +# Test inheritance. +$ rmdir ddd +$ mkdir ddd +$ setfacl -a0 group:43:write_data/write_acl:fin:deny,u:43:rwxp:allow ddd +$ setfacl -a0 user:42:rx:fi:allow,group:42:write_data/delete_child:dn:deny ddd +$ setfacl -a0 user:42:write_acl/write_owner:fi:allow ddd +$ setfacl -a0 group:41:read_data/read_attributes:dni:allow ddd +$ setfacl -a0 user:41:write_data/write_attributes:fn:allow ddd +$ getfacl -qn ddd +> user:41:-w-----A------:f--n--:allow +> group:41:r-----a-------:-din--:allow +> user:42:-----------Co-:f-i---:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:-d-n--:deny +> group:43:-w---------C--:f-in--:deny +> user:43:rwxp----------:------:allow +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:-w-p----------:------:deny +> group@:r-x-----------:------:allow +> everyone@:-w-p---A-W-Co-:------:deny +> everyone@:r-x---a-R-c--s:------:allow + +$ cd ddd +$ touch xxx +$ getfacl -qn xxx +> user:41:-w------------:------:deny +> user:41:-w-----A------:------:allow +> user:42:--------------:------:deny +> user:42:--------------:------:allow +> user:42:--x-----------:------:deny +> user:42:r-x-----------:------:allow +> group:43:-w---------C--:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ rm xxx +$ umask 077 +$ touch xxx +$ getfacl -qn xxx +> user:41:-w------------:------:deny +> user:41:-w-----A------:------:allow +> user:42:--------------:------:deny +> user:42:--------------:------:allow +> user:42:r-x-----------:------:deny +> user:42:r-x-----------:------:allow +> group:43:-w---------C--:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow + +$ rm xxx +$ umask 770 +$ touch xxx +$ getfacl -qn xxx +> user:41:-w------------:------:deny +> user:41:-w-----A------:------:allow +> user:42:--------------:------:deny +> user:42:--------------:------:allow +> user:42:r-x-----------:------:deny +> user:42:r-x-----------:------:allow +> group:43:-w---------C--:------:deny +> owner@:rwxp----------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:--x----A-W-Co-:------:deny +> everyone@:rw-p--a-R-c--s:------:allow + +$ rm xxx +$ umask 707 +$ touch xxx +$ getfacl -qn xxx +> user:41:--------------:------:deny +> user:41:-w-----A------:------:allow +> user:42:--------------:------:deny +> user:42:--------------:------:allow +> user:42:--x-----------:------:deny +> user:42:r-x-----------:------:allow +> group:43:-w---------C--:------:deny +> owner@:rwxp----------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--x-----------:------:deny +> group@:rw-p----------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow + +$ umask 077 +$ mkdir yyy +$ getfacl -qn yyy +> group:41:r-------------:------:deny +> group:41:r-----a-------:------:allow +> user:42:-----------Co-:f-i---:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:------:deny +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow + +$ rmdir yyy +$ umask 770 +$ mkdir yyy +$ getfacl -qn yyy +> group:41:r-------------:------:deny +> group:41:r-----a-------:------:allow +> user:42:-----------Co-:f-i---:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:------:deny +> owner@:rwxp----------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:rwxp----------:------:deny +> group@:--------------:------:allow +> everyone@:-------A-W-Co-:------:deny +> everyone@:rwxp--a-R-c--s:------:allow + +$ rmdir yyy +$ umask 707 +$ mkdir yyy +$ getfacl -qn yyy +> group:41:--------------:------:deny +> group:41:------a-------:------:allow +> user:42:-----------Co-:f-i---:allow +> user:42:r-x-----------:f-i---:allow +> group:42:-w--D---------:------:deny +> owner@:rwxp----------:------:deny +> owner@:-------A-W-Co-:------:allow +> group@:--------------:------:deny +> group@:rwxp----------:------:allow +> everyone@:rwxp---A-W-Co-:------:deny +> everyone@:------a-R-c--s:------:allow + +# There is some complication regarding how write_acl and write_owner flags +# get inherited. Make sure we got it right. +$ setfacl -b . +$ setfacl -a0 u:42:Co:f:allow . +$ setfacl -a0 u:43:Co:d:allow . +$ setfacl -a0 u:44:Co:fd:allow . +$ setfacl -a0 u:45:Co:fi:allow . +$ setfacl -a0 u:46:Co:di:allow . +$ setfacl -a0 u:47:Co:fdi:allow . +$ setfacl -a0 u:48:Co:fn:allow . +$ setfacl -a0 u:49:Co:dn:allow . +$ setfacl -a0 u:50:Co:fdn:allow . +$ setfacl -a0 u:51:Co:fni:allow . +$ setfacl -a0 u:52:Co:dni:allow . +$ setfacl -a0 u:53:Co:fdni:allow . +$ umask 022 +$ rm xxx +$ touch xxx +$ getfacl -nq xxx +> user:53:--------------:------:deny +> user:53:--------------:------:allow +> user:51:--------------:------:deny +> user:51:--------------:------:allow +> user:50:--------------:------:deny +> user:50:--------------:------:allow +> user:48:--------------:------:deny +> user:48:--------------:------:allow +> user:47:--------------:------:deny +> user:47:--------------:------:allow +> user:45:--------------:------:deny +> user:45:--------------:------:allow +> user:44:--------------:------:deny +> user:44:--------------:------:allow +> user:42:--------------:------:deny +> user:42:--------------:------:allow +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ rmdir yyy +$ mkdir yyy +$ getfacl -nq yyy +> user:53:--------------:------:deny +> user:53:--------------:------:allow +> user:52:--------------:------:deny +> user:52:--------------:------:allow +> user:50:--------------:------:deny +> user:50:--------------:------:allow +> user:49:--------------:------:deny +> user:49:--------------:------:allow +> user:47:-----------Co-:fdi---:allow +> user:47:--------------:------:deny +> user:47:--------------:------:allow +> user:46:-----------Co-:-di---:allow +> user:46:--------------:------:deny +> user:46:--------------:------:allow +> user:45:-----------Co-:f-i---:allow +> user:44:-----------Co-:fdi---:allow +> user:44:--------------:------:deny +> user:44:--------------:------:allow +> user:43:-----------Co-:-di---:allow +> user:43:--------------:------:deny +> user:43:--------------:------:allow +> user:42:-----------Co-:f-i---:allow +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:-w-p----------:------:deny +> group@:r-x-----------:------:allow +> everyone@:-w-p---A-W-Co-:------:deny +> everyone@:r-x---a-R-c--s:------:allow + +$ setfacl -b . +$ setfacl -a0 u:42:Co:f:deny . +$ setfacl -a0 u:43:Co:d:deny . +$ setfacl -a0 u:44:Co:fd:deny . +$ setfacl -a0 u:45:Co:fi:deny . +$ setfacl -a0 u:46:Co:di:deny . +$ setfacl -a0 u:47:Co:fdi:deny . +$ setfacl -a0 u:48:Co:fn:deny . +$ setfacl -a0 u:49:Co:dn:deny . +$ setfacl -a0 u:50:Co:fdn:deny . +$ setfacl -a0 u:51:Co:fni:deny . +$ setfacl -a0 u:52:Co:dni:deny . +$ setfacl -a0 u:53:Co:fdni:deny . +$ umask 022 +$ rm xxx +$ touch xxx +$ getfacl -nq xxx +> user:53:-----------Co-:------:deny +> user:51:-----------Co-:------:deny +> user:50:-----------Co-:------:deny +> user:48:-----------Co-:------:deny +> user:47:-----------Co-:------:deny +> user:45:-----------Co-:------:deny +> user:44:-----------Co-:------:deny +> user:42:-----------Co-:------:deny +> owner@:--x-----------:------:deny +> owner@:rw-p---A-W-Co-:------:allow +> group@:-wxp----------:------:deny +> group@:r-------------:------:allow +> everyone@:-wxp---A-W-Co-:------:deny +> everyone@:r-----a-R-c--s:------:allow + +$ rmdir yyy +$ mkdir yyy +$ getfacl -nq yyy +> user:53:-----------Co-:------:deny +> user:52:-----------Co-:------:deny +> user:50:-----------Co-:------:deny +> user:49:-----------Co-:------:deny +> user:47:-----------Co-:fdi---:deny +> user:47:-----------Co-:------:deny +> user:46:-----------Co-:-di---:deny +> user:46:-----------Co-:------:deny +> user:45:-----------Co-:f-i---:deny +> user:44:-----------Co-:fdi---:deny +> user:44:-----------Co-:------:deny +> user:43:-----------Co-:-di---:deny +> user:43:-----------Co-:------:deny +> user:42:-----------Co-:f-i---:deny +> owner@:--------------:------:deny +> owner@:rwxp---A-W-Co-:------:allow +> group@:-w-p----------:------:deny +> group@:r-x-----------:------:allow +> everyone@:-w-p---A-W-Co-:------:deny +> everyone@:r-x---a-R-c--s:------:allow + +$ rmdir yyy +$ rm xxx +$ cd .. +$ rmdir ddd + +$ rm xxx + Modified: head/tools/regression/acltools/tools-posix.test ============================================================================== --- head/tools/regression/acltools/tools-posix.test Mon Sep 7 16:25:09 2009 (r196937) +++ head/tools/regression/acltools/tools-posix.test Mon Sep 7 16:26:03 2009 (r196938) @@ -1,11 +1,36 @@ +# Copyright (c) 2008, 2009 Edward Tomasz Napiera?a +# 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$ +# *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From trasz at FreeBSD.org Mon Sep 7 16:56:41 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 16:56:56 2009 Subject: svn commit: r196941 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909071656.n87GufHG021183@svn.freebsd.org> Author: trasz Date: Mon Sep 7 16:56:41 2009 New Revision: 196941 URL: http://svn.freebsd.org/changeset/base/196941 Log: Prevent the line from wrapping. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Mon Sep 7 16:41:18 2009 (r196940) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Mon Sep 7 16:56:41 2009 (r196941) @@ -3567,7 +3567,7 @@ arc_init(void) if ((((uint64_t)physmem * PAGESIZE) < (1ULL << 32)) && prefetch_tunable_set == 0) { printf("ZFS NOTICE: Prefetch is disabled by default if less " - "than 4 GB of RAM is present;\n" + "than 4GB of RAM is present;\n" " to enable, add \"vfs.zfs.prefetch_disable=0\" " "to /boot/loader.conf.\n"); zfs_prefetch_disable=1; From kensmith at FreeBSD.org Mon Sep 7 17:54:20 2009 From: kensmith at FreeBSD.org (Ken Smith) Date: Mon Sep 7 17:54:31 2009 Subject: svn commit: r196942 - head/release/scripts Message-ID: <200909071754.n87HsKIJ022310@svn.freebsd.org> Author: kensmith Date: Mon Sep 7 17:54:20 2009 New Revision: 196942 URL: http://svn.freebsd.org/changeset/base/196942 Log: Bring the layout of package-split.py more in line with where we're going with packages on the release media. It looks like we'll be putting just the doc packages on the new "memory stick" image as well as disc1. There will be no other packages on the CDROM-sized media. The DVD sized media will include the doc packages plus whatever other packages we decide to make part of the release. This commit just brings the basic structure in line with being able to do this. We still need to discuss with various people exactly which packages will be included on the DVD. If the environement variable "PKG_DVD" is set a tree suitable for the DVD media is generated. Otherwise a tree suitable for the "memory stick" and disc1 is generated. MFC after: 3 days Modified: head/release/scripts/package-split.py Modified: head/release/scripts/package-split.py ============================================================================== --- head/release/scripts/package-split.py Mon Sep 7 16:56:41 2009 (r196941) +++ head/release/scripts/package-split.py Mon Sep 7 17:54:20 2009 (r196942) @@ -23,71 +23,14 @@ if 'PKG_VERBOSE' in os.environ: else: verbose = 0 -# List of packages for disc1. This just includes packages sysinstall can -# install as a distribution -def disc1_packages(): - pkgs = ['lang/perl5.8'] - pkgs.extend(['x11/xorg', - 'devel/imake']) - if arch == 'i386': - pkgs.append('emulators/linux_base-fc4') - return pkgs - -# List of packages for disc2. This includes packages that the X desktop -# menu depends on (if it still exists) and other "nice to have" packages. -# For architectures that use a separate livefs, this is actually disc3. -def disc2_packages(): - # X Desktops - if arch == 'ia64': - pkgs = ['x11/gnome2-lite', - 'x11/kde-lite'] - else: - pkgs = ['x11/gnome2', - 'x11/kde3'] - pkgs.extend(['x11-wm/afterstep', - 'x11-wm/windowmaker', - 'x11-wm/fvwm2', - # "Nice to have" - 'archivers/unzip', - 'astro/xearth', - 'devel/gmake', - 'editors/emacs', - 'editors/vim-lite', - 'emulators/mtools', - 'graphics/png', - 'graphics/xv', - 'irc/xchat', - 'mail/exim', - 'mail/fetchmail', - 'mail/mutt', - 'mail/pine4', - 'mail/popd', - 'mail/xfmail', - 'mail/postfix', - 'net/cvsup-without-gui', - 'net/rsync', - 'net/samba3', - 'news/slrn', - 'news/tin', - 'ports-mgmt/portupgrade', - 'print/a2ps-letter', - 'print/apsfilter', - 'print/ghostscript-gnu-nox11', - 'print/gv', - 'print/psutils-letter', - 'shells/bash', - 'shells/pdksh', - 'shells/zsh', - 'security/sudo', - 'www/links', - 'www/lynx', - 'x11/rxvt', - # Formerly on disc3 - 'ports-mgmt/portaudit']) - return pkgs +if 'PKG_DVD' in os.environ: + doing_dvd = 1 +else: + doing_dvd = 0 -def docs_packages(): - pkgs = ['misc/freebsd-doc-bn', +# List of packages for disc1. +def disc1_packages(): + pkgs = ['misc/freebsd-doc-bn', 'misc/freebsd-doc-da', 'misc/freebsd-doc-de', 'misc/freebsd-doc-el', @@ -106,14 +49,58 @@ def docs_packages(): 'misc/freebsd-doc-tr', 'misc/freebsd-doc-zh_cn', 'misc/freebsd-doc-zh_tw'] + + if doing_dvd: + pkgs.extend(['lang/perl5.8', + 'x11/xorg', + 'devel/imake', + 'emulators/linux_base-fc4', + 'x11/gnome2', + 'x11/kde4', + 'x11-wm/afterstep', + 'x11-wm/windowmaker', + 'x11-wm/fvwm2', + 'archivers/unzip', + 'astro/xearth', + 'devel/gmake', + 'editors/emacs', + 'editors/vim-lite', + 'emulators/mtools', + 'graphics/png', + 'graphics/xv', + 'irc/xchat', + 'mail/exim', + 'mail/fetchmail', + 'mail/mutt', + 'mail/alpine', + 'mail/popd', + 'mail/xfmail', + 'mail/postfix', + 'net/cvsup-without-gui', + 'net/rsync', + 'net/samba3', + 'news/slrn', + 'news/tin', + 'ports-mgmt/portupgrade', + 'print/a2ps-letter', + 'print/apsfilter', + 'print/ghostscript7-nox11', + 'print/gv', + 'print/psutils-letter', + 'shells/bash', + 'shells/pdksh', + 'shells/zsh', + 'security/sudo', + 'www/links', + 'www/lynx', + 'x11/rxvt', + 'ports-mgmt/portaudit']) return pkgs # The list of desired packages def desired_packages(): disc1 = disc1_packages() - disc2 = disc2_packages() - docs = docs_packages() - return [disc1, disc2, docs] + return [disc1] # Suck the entire INDEX file into a two different dictionaries. The first # dictionary maps port names (origins) to package names. The second From pjd at FreeBSD.org Mon Sep 7 18:23:27 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 18:23:39 2009 Subject: svn commit: r196943 - head/sys/cddl/compat/opensolaris/kern Message-ID: <200909071823.n87INQpL022930@svn.freebsd.org> Author: pjd Date: Mon Sep 7 18:23:26 2009 New Revision: 196943 URL: http://svn.freebsd.org/changeset/base/196943 Log: - Avoid holding mutex around M_WAITOK allocations. - Add locking for mnt_opt field. MFC after: 1 week Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c ============================================================================== --- head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Mon Sep 7 17:54:20 2009 (r196942) +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Mon Sep 7 18:23:26 2009 (r196943) @@ -45,20 +45,33 @@ vfs_setmntopt(vfs_t *vfsp, const char *n { struct vfsopt *opt; size_t namesize; + int locked; + + if (!(locked = mtx_owned(MNT_MTX(vfsp)))) + MNT_ILOCK(vfsp); if (vfsp->mnt_opt == NULL) { - vfsp->mnt_opt = malloc(sizeof(*vfsp->mnt_opt), M_MOUNT, M_WAITOK); - TAILQ_INIT(vfsp->mnt_opt); + void *opts; + + MNT_IUNLOCK(vfsp); + opts = malloc(sizeof(*vfsp->mnt_opt), M_MOUNT, M_WAITOK); + MNT_ILOCK(vfsp); + if (vfsp->mnt_opt == NULL) { + vfsp->mnt_opt = opts; + TAILQ_INIT(vfsp->mnt_opt); + } else { + free(opts, M_MOUNT); + } } - opt = malloc(sizeof(*opt), M_MOUNT, M_WAITOK); + MNT_IUNLOCK(vfsp); + opt = malloc(sizeof(*opt), M_MOUNT, M_WAITOK); namesize = strlen(name) + 1; opt->name = malloc(namesize, M_MOUNT, M_WAITOK); strlcpy(opt->name, name, namesize); opt->pos = -1; opt->seen = 1; - if (arg == NULL) { opt->value = NULL; opt->len = 0; @@ -67,16 +80,23 @@ vfs_setmntopt(vfs_t *vfsp, const char *n opt->value = malloc(opt->len, M_MOUNT, M_WAITOK); bcopy(arg, opt->value, opt->len); } - /* TODO: Locking. */ + + MNT_ILOCK(vfsp); TAILQ_INSERT_TAIL(vfsp->mnt_opt, opt, link); + if (!locked) + MNT_IUNLOCK(vfsp); } void vfs_clearmntopt(vfs_t *vfsp, const char *name) { + int locked; - /* TODO: Locking. */ + if (!(locked = mtx_owned(MNT_MTX(vfsp)))) + MNT_ILOCK(vfsp); vfs_deleteopt(vfsp->mnt_opt, name); + if (!locked) + MNT_IUNLOCK(vfsp); } int From pjd at FreeBSD.org Mon Sep 7 18:54:55 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 18:55:05 2009 Subject: svn commit: r196944 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909071854.n87IstZ7023617@svn.freebsd.org> Author: pjd Date: Mon Sep 7 18:54:55 2009 New Revision: 196944 URL: http://svn.freebsd.org/changeset/base/196944 Log: Don't recheck ownership on update mount. This will eliminate LOR between vfs_busy() and mount mutex. We check ownership in vfs_domount() anyway. Noticed by: kib Reviewed by: kib MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Mon Sep 7 18:23:26 2009 (r196943) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Mon Sep 7 18:54:55 2009 (r196944) @@ -719,7 +719,10 @@ zfs_mount(vfs_t *vfsp) error = secpolicy_fs_mount(cr, mvp, vfsp); if (error) { error = dsl_deleg_access(osname, ZFS_DELEG_PERM_MOUNT, cr); - if (error == 0) { + if (error != 0) + goto out; + + if (!(vfsp->vfs_flag & MS_REMOUNT)) { vattr_t vattr; /* @@ -753,11 +756,9 @@ zfs_mount(vfs_t *vfsp) } VOP_UNLOCK(mvp, 0); #endif - - secpolicy_fs_mount_clearopts(cr, vfsp); - } else { - goto out; } + + secpolicy_fs_mount_clearopts(cr, vfsp); } /* From pjd at FreeBSD.org Mon Sep 7 19:22:45 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 19:22:56 2009 Subject: svn commit: r196947 - head/sys/cddl/compat/opensolaris/sys Message-ID: <200909071922.n87JMjYV024270@svn.freebsd.org> Author: pjd Date: Mon Sep 7 19:22:44 2009 New Revision: 196947 URL: http://svn.freebsd.org/changeset/base/196947 Log: Defer thread start until we set priority. Reviewed by: kib MFC after: 3 days Modified: head/sys/cddl/compat/opensolaris/sys/proc.h Modified: head/sys/cddl/compat/opensolaris/sys/proc.h ============================================================================== --- head/sys/cddl/compat/opensolaris/sys/proc.h Mon Sep 7 19:15:07 2009 (r196946) +++ head/sys/cddl/compat/opensolaris/sys/proc.h Mon Sep 7 19:22:44 2009 (r196947) @@ -37,6 +37,7 @@ #include #include #include +#include #include #ifdef _KERNEL @@ -74,11 +75,12 @@ thread_create(caddr_t stk, size_t stksiz ASSERT(state == TS_RUN); ASSERT(pp == &p0); - error = kproc_kthread_add(proc, arg, &zfsproc, &td, 0, + error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED, stksize / PAGE_SIZE, "zfskern", "solthread %p", proc); if (error == 0) { thread_lock(td); sched_prio(td, pri); + sched_add(td, SRQ_BORING); thread_unlock(td); } return (td); From trasz at FreeBSD.org Mon Sep 7 19:40:22 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 19:40:47 2009 Subject: svn commit: r196948 - in head/tools/regression/fstest: . tests/chmod tests/granular Message-ID: <200909071940.n87JeMXk024638@svn.freebsd.org> Author: trasz Date: Mon Sep 7 19:40:22 2009 New Revision: 196948 URL: http://svn.freebsd.org/changeset/base/196948 Log: Add regression tests for NFSv4 ACL granular permission enforcement. Added: head/tools/regression/fstest/tests/chmod/12.t (contents, props changed) head/tools/regression/fstest/tests/granular/ head/tools/regression/fstest/tests/granular/00.t (contents, props changed) head/tools/regression/fstest/tests/granular/01.t (contents, props changed) head/tools/regression/fstest/tests/granular/02.t (contents, props changed) head/tools/regression/fstest/tests/granular/03.t (contents, props changed) head/tools/regression/fstest/tests/granular/04.t (contents, props changed) head/tools/regression/fstest/tests/granular/05.t (contents, props changed) Modified: head/tools/regression/fstest/Makefile head/tools/regression/fstest/fstest.c Modified: head/tools/regression/fstest/Makefile ============================================================================== --- head/tools/regression/fstest/Makefile Mon Sep 7 19:22:44 2009 (r196947) +++ head/tools/regression/fstest/Makefile Mon Sep 7 19:40:22 2009 (r196948) @@ -4,7 +4,7 @@ OSTYPE=$(shell uname) ifeq "${OSTYPE}" "FreeBSD" CFLAGS += -D__OS_FreeBSD__ -CFLAGS += -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS +CFLAGS += -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL endif ifeq "${OSTYPE}" "SunOS" Modified: head/tools/regression/fstest/fstest.c ============================================================================== --- head/tools/regression/fstest/fstest.c Mon Sep 7 19:22:44 2009 (r196947) +++ head/tools/regression/fstest/fstest.c Mon Sep 7 19:40:22 2009 (r196948) @@ -45,6 +45,9 @@ #define stat64 stat #define lstat64 lstat #endif +#ifdef HAS_FREEBSD_ACL +#include +#endif #ifndef ALLPERMS #define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) @@ -75,7 +78,12 @@ enum action { ACTION_TRUNCATE, ACTION_STAT, ACTION_LSTAT, - ACTION_PATHCONF + ACTION_PATHCONF, +#ifdef HAS_FREEBSD_ACL + ACTION_PREPENDACL, + ACTION_READACL, +#endif + ACTION_WRITE, }; #define TYPE_NONE 0x0000 @@ -118,6 +126,11 @@ static struct syscall_desc syscalls[] = { "stat", ACTION_STAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "lstat", ACTION_LSTAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "pathconf", ACTION_PATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, +#ifdef HAS_FREEBSD_ACL + { "prependacl", ACTION_PREPENDACL, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "readacl", ACTION_READACL, { TYPE_STRING, TYPE_NONE } }, +#endif + { "write", ACTION_WRITE, { TYPE_STRING, TYPE_NONE } }, { NULL, -1, { TYPE_NONE } } }; @@ -397,6 +410,11 @@ call_syscall(struct syscall_desc *scall, char *str; long long num; } args[MAX_ARGS]; +#ifdef HAS_FREEBSD_ACL + int entry_id = ACL_FIRST_ENTRY; + acl_t acl, newacl; + acl_entry_t entry, newentry; +#endif /* * Verify correctness of the arguments. @@ -540,6 +558,48 @@ call_syscall(struct syscall_desc *scall, rval = -1; break; } +#ifdef HAS_FREEBSD_ACL + case ACTION_PREPENDACL: + rval = -1; + + acl = acl_get_file(STR(0), ACL_TYPE_NFS4); + if (acl == NULL) + break; + + newacl = acl_from_text(STR(1)); + if (acl == NULL) + break; + + while (acl_get_entry(newacl, entry_id, &newentry) == 1) { + entry_id = ACL_NEXT_ENTRY; + + if (acl_create_entry_np(&acl, &entry, 0)) + break; + + if (acl_copy_entry(entry, newentry)) + break; + } + + rval = acl_set_file(STR(0), ACL_TYPE_NFS4, acl); + break; + + case ACTION_READACL: + acl = acl_get_file(STR(0), ACL_TYPE_NFS4); + if (acl == NULL) + rval = -1; + else + rval = 0; + break; +#endif + + case ACTION_WRITE: + rval = open(STR(0), O_WRONLY); + if (rval < 0) + break; + + rval = write(rval, "x", 1); + break; + default: fprintf(stderr, "unsupported syscall\n"); exit(1); Added: head/tools/regression/fstest/tests/chmod/12.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/chmod/12.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD$ + +desc="verify SUID/SGID bit behaviour" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Check whether writing to the file by non-owner clears the SUID. +expect 0 create ${n0} 04777 +expect 0 -u 65534 -g 65534 write ${n0} +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether writing to the file by non-owner clears the SGID. +expect 0 create ${n0} 02777 +expect 0 -u 65534 -g 65534 write ${n0} +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} Added: head/tools/regression/fstest/tests/granular/00.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/00.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,110 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..49" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Tests 2..7 - check out whether root user can do stuff. +# Can create files? +expect 0 create ${n0} 0644 + +# Can create symlinks? +expect 0 link ${n0} ${n1} +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +# Can create directories? +expect 0 mkdir ${n0} 0755 +expect 0 rmdir ${n0} + +# Check whether user 65534 is permitted to create and remove +# files, but not subdirectories. +expect 0 prependacl . user:65534:write_data::allow,user:65534:append_data::deny + +# Can create files? +expect 0 -u 65534 -g 65534 create ${n0} 0644 + +# Can create symlinks? +expect 0 -u 65534 -g 65534 link ${n0} ${n1} +expect 0 -u 65534 -g 65534 unlink ${n1} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Can create directories? +expect EACCES -u 65534 -g 65534 mkdir ${n0} 0755 +expect ENOENT -u 65534 -g 65534 rmdir ${n0} +expect 0 mkdir ${n0} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Can move files from other directory? +expect 0 create ../${n3}/${n1} 0644 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move files from other directory overwriting existing files? +expect 0 create ../${n3}/${n1} 0644 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Can move directories from other directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move directories from other directory overwriting existing directory? +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 rmdir ../${n3}/${n1} + +# Check whether user 65534 is permitted to create +# subdirectories, but not files - and to remove neither of them. +expect 0 prependacl . user:65534:write_data::deny,user:65534:append_data::allow + +# Can create files? +expect EACCES -u 65534 -g 65534 create ${n0} 0644 + +# Can create symlinks? +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 link ${n0} ${n1} +expect ENOENT -u 65534 -g 65534 unlink ${n1} +expect EACCES -u 65534 -g 65534 unlink ${n0} +expect 0 unlink ${n0} + +# Can create directories? +expect 0 -u 65534 -g 65534 mkdir ${n0} 0755 +expect EACCES -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# Can move files from other directory? +expect 0 create ../${n3}/${n1} 0644 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move files from other directory overwriting existing files? +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 unlink ../${n3}/${n1} + +# Can move directories from other directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move directories from other directory overwriting existing directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} +expect 0 rmdir ${n3} Added: head/tools/regression/fstest/tests/granular/01.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/01.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,35 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - ACL_READ_ATTRIBUTES and ACL_WRITE_ATTRIBUTES" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Tests 1..12 - check out whether user 65534 is permitted to read attributes. +expect 0 create ${n0} 0644 +expect 0 lstat ${n0} size +expect 0 -u 65534 -g 65534 stat ${n0} size +expect 0 prependacl ${n0} user:65534:read_attributes::deny +expect 0 lstat ${n0} size +expect EACCES -u 65534 -g 65534 stat ${n0} size +expect 0 prependacl ${n0} user:65534:read_attributes::allow +expect 0 -u 65534 -g 65534 stat ${n0} size +expect 0 lstat ${n0} size +expect 0 unlink ${n0} + +# Tests 12..12 - check out whether user 65534 is permitted to write attributes. +# XXX: Check if ACL_WRITE_ATTRIBUTES allows for modifying access times. + +cd ${cdir} +expect 0 rmdir ${n2} Added: head/tools/regression/fstest/tests/granular/02.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/02.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,142 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - ACL_READ_ACL and ACL_WRITE_ACL" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..83" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Check whether user 65534 is permitted to read ACL. +expect 0 create ${n0} 0644 +expect 0 readacl ${n0} +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0 prependacl ${n0} user:65534:read_acl::deny +expect 0 readacl ${n0} +expect EACCES -u 65534 -g 65534 readacl ${n0} +expect 0 prependacl ${n0} user:65534:read_acl::allow +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0 readacl ${n0} +expect 0 unlink ${n0} + +# Check whether user 65534 is permitted to write ACL. +expect 0 create ${n0} 0644 +expect EPERM -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow +expect 0 unlink ${n0} + +# Check whether user 65534 is permitted to write mode. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 unlink ${n0} + +# There is an interesting problem with interaction between ACL_WRITE_ACL +# and SUID/SGID bits. In case user does have ACL_WRITE_ACL, but is not +# a file owner, Solaris does the following: +# 1. Setting SUID fails with EPERM. +# 2. Setting SGID succeeds, but mode is not changed. +# 3. Modifying ACL does not clear SUID nor SGID bits. +# 4. Writing the file does clear both SUID and SGID bits. +# +# What we are doing is the following: +# 1. Setting SUID or SGID fails with EPERM. +# 2. Modifying ACL does not clear SUID nor SGID bits. +# 3. Writing the file does clear both SUID and SGID bits. +# +# Check whether user 65534 is denied to write mode with SUID bit. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 04777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect EPERM -u 65534 -g 65534 chmod ${n0} 04777 +expect 0 unlink ${n0} + +# Check whether user 65534 is denied to write mode with SGID bit. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 02777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect EPERM -u 65534 -g 65534 chmod ${n0} 02777 +expect 0 unlink ${n0} + +# Check whether user 65534 is allowed to write mode with sticky bit. +expect 0 mkdir ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 01777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 chmod ${n0} 01777 +expect 0 rmdir ${n0} + +# Check whether modifying the ACL by not-owner preserves the SUID. +expect 0 create ${n0} 04755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 04755 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether modifying the ACL by not-owner preserves the SGID. +expect 0 create ${n0} 02755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 02755 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether modifying the ACL by not-owner preserves the sticky bit. +expect 0 mkdir ${n0} 0755 +expect 0 chmod ${n0} 01755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 01755 stat ${n0} mode +expect 0 rmdir ${n0} + +# Clearing the SUID and SGID bits when being written to by non-owner +# is checked in chmod/12.t. + +# Check whether the file owner is always permitted to get and set +# ACL and file mode, even if ACL_{READ,WRITE}_ACL would deny it. +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65534 create ${n0} 0600 +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0600 -u 65534 -g 65534 stat ${n0} mode +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 unlink ${n0} + +expect 0 -u 65534 -g 65534 mkdir ${n0} 0600 +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0600 -u 65534 -g 65534 stat ${n0} mode +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 rmdir ${n0} + +# Check whether the root is allowed for these as well. +expect 0 -u 65534 -g 65534 create ${n0} 0600 +expect 0 prependacl ${n0} everyone@:write_acl::deny +expect 0 prependacl ${n0} everyone@:read_acl::deny +expect 0 readacl ${n0} +expect 0600 stat ${n0} mode +expect 0 chmod ${n0} 0777 +expect 0 unlink ${n0} + +expect 0 -u 65534 -g 65534 mkdir ${n0} 0600 +expect 0 prependacl ${n0} everyone@:write_acl::deny +expect 0 prependacl ${n0} everyone@:read_acl::deny +expect 0600 stat ${n0} mode +expect 0 readacl ${n0} +expect 0600 stat ${n0} mode +expect 0 chmod ${n0} 0777 +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} Added: head/tools/regression/fstest/tests/granular/03.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/03.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,132 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..65" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Unlink allowed on writable directory. +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 unlink ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving file elsewhere allowed on writable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Moving file from elsewhere allowed on writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving file from elsewhere overwriting local file allowed +# on writable directory. +expect 0 create ${n0} 0644 +expect 0 create ../${n3}/${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere. +expect 0 create ${n0} 0644 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# DELETE_CHILD denies unlink on writable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 unlink ${n0} +expect 0 unlink ${n0} + +# DELETE_CHILD denies moving file elsewhere. +expect 0 create ${n0} 0644 +expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 rename ${n0} ../${n3}/${n0} + +# DELETE_CHILD does not deny moving file from elsewhere +# to a writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE_CHILD denies moving file from elsewhere +# to a writable directory overwriting local file. +expect 0 create ../${n3}/${n0} 0644 +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE allowed on file allows for unlinking, no matter +# what permissions on containing directory are. +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Same for moving the file elsewhere. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Same for moving the file from elsewhere into a writable +# directory with DELETE_CHILD denied. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 unlink ${n0} + +# DELETE does not allow for overwriting a file in a unwritable +# directory with DELETE_CHILD denied. +expect 0 create ${n0} 0644 +expect 0 create ../${n3}/${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl ${n0} user:65534:delete::allow +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# But it allows for plain deletion. +expect 0 -u 65534 -g 65534 unlink ${n0} + +# DELETE_CHILD allowed on unwritable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving things elsewhere is allowed. +expect 0 create ${n0} 0644 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Moving things back is not. +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we're overwriting. +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we have DELETE on the existing file. +expect 0 prependacl ${n0} user:65534:delete::allow +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} Added: head/tools/regression/fstest/tests/granular/04.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/04.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,78 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - ACL_WRITE_OWNER" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..52" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# ACL_WRITE_OWNER permits to set gid to our own only. +expect 0 create ${n0} 0644 +expect 0,0 lstat ${n0} uid,gid +expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65532 +expect 0,0 lstat ${n0} uid,gid +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65530 +expect 0,0 lstat ${n0} uid,gid +expect 0 -u 65534 -g 65532,65531 chown ${n0} -1 65532 +expect 0,65532 lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# ACL_WRITE_OWNER permits to set uid to our own only. +expect 0 create ${n0} 0644 +expect 0,0 lstat ${n0} uid,gid +expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65534 65531 +expect 0,0 lstat ${n0} uid,gid +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65530 65531 +expect 0,0 lstat ${n0} uid,gid +expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531 +expect 65534,65531 lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# When non-owner calls chown(2) successfully, set-uid and set-gid bits are +# removed, except when both uid and gid are equal to -1. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 +expect 0555,65534,65532 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 +expect 0555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 +expect 06555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 unlink ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 +expect 0555,65534,65532 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 +expect 0555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 +expect 06555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} Added: head/tools/regression/fstest/tests/granular/05.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/fstest/tests/granular/05.t Mon Sep 7 19:40:22 2009 (r196948) @@ -0,0 +1,147 @@ +#!/bin/sh +# $FreeBSD$ + +desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD with directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..68" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Unlink allowed on writable directory. +expect 0 mkdir ${n0} 0755 +expect EACCES -u 65534 -g 65534 rmdir ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving directory elsewhere allowed on writable directory. +expect 0 mkdir ${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 12 +# Moving directory from elsewhere allowed on writable directory. +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:append_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving directory from elsewhere overwriting local directory allowed +# on writable directory. +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# 23 +# Denied DELETE changes nothing wrt removing. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere. +expect 0 mkdir ${n0} 0777 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# DELETE_CHILD denies unlink on writable directory. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# 35 +# DELETE_CHILD denies moving directory elsewhere. +expect 0 mkdir ${n0} 0777 +expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 rename ${n0} ../${n3}/${n0} + +# DELETE_CHILD does not deny moving directory from elsewhere +# to a writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE_CHILD denies moving directory from elsewhere +# to a writable directory overwriting local directory. +expect 0 mkdir ../${n3}/${n0} 0755 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE allowed on directory allows for unlinking, no matter +# what permissions on containing directory are. +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Same for moving the directory elsewhere. +expect 0 mkdir ${n0} 0777 +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 46 +# Same for moving the directory from elsewhere into a writable +# directory with DELETE_CHILD denied. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 rmdir ${n0} + +# DELETE does not allow for overwriting a directory in a unwritable +# directory with DELETE_CHILD denied. +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl ${n0} user:65534:delete::allow +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# 54 +# But it allows for plain deletion. +# XXX: expect 0 -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# DELETE_CHILD allowed on unwritable directory. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving things elsewhere is allowed. +expect 0 mkdir ${n0} 0777 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 60 +# Moving things back is not. +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we're overwriting. +# XXX: expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 mkdir ../${n3}/${n0} 0777 + +# Even if we have DELETE on the existing directory. +expect 0 prependacl ${n0} user:65534:delete::allow +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} From trasz at FreeBSD.org Mon Sep 7 19:43:14 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 19:43:26 2009 Subject: svn commit: r196949 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909071943.n87JhDYk024743@svn.freebsd.org> Author: trasz Date: Mon Sep 7 19:43:13 2009 New Revision: 196949 URL: http://svn.freebsd.org/changeset/base/196949 Log: Enable NFSv4 ACL support in ZFS. Reviewed by: pjd Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Mon Sep 7 19:40:22 2009 (r196948) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Mon Sep 7 19:43:13 2009 (r196949) @@ -3834,7 +3834,15 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong #endif case _PC_ACL_EXTENDED: - *valp = 0; /* TODO */ + *valp = 0; + return (0); + + case _PC_ACL_NFS4: + *valp = 1; + return (0); + + case _PC_ACL_PATH_MAX: + *valp = ACL_MAX_ENTRIES; return (0); case _PC_MIN_HOLE_SIZE: @@ -4425,6 +4433,26 @@ zfs_freebsd_pathconf(ap) return (error); } +static int +zfs_freebsd_fifo_pathconf(ap) + struct vop_pathconf_args /* { + struct vnode *a_vp; + int a_name; + register_t *a_retval; + } */ *ap; +{ + + switch (ap->a_name) { + case _PC_ACL_EXTENDED: + case _PC_ACL_NFS4: + case _PC_ACL_PATH_MAX: + case _PC_MAC_PRESENT: + return (zfs_freebsd_pathconf(ap)); + default: + return (fifo_specops.vop_pathconf(ap)); + } +} + /* * FreeBSD's extended attributes namespace defines file name prefix for ZFS' * extended attribute name: @@ -4854,7 +4882,7 @@ zfs_freebsd_setacl(ap) return (EINVAL); /* - * With NFS4 ACLs, chmod(2) may need to add additional entries, + * With NFSv4 ACLs, chmod(2) may need to add additional entries, * splitting every entry into two and appending "canonical six" * entries at the end. Don't allow for setting an ACL that would * cause chmod(2) to run out of ACL entries. @@ -4928,11 +4956,9 @@ struct vop_vector zfs_vnodeops = { .vop_deleteextattr = zfs_deleteextattr, .vop_setextattr = zfs_setextattr, .vop_listextattr = zfs_listextattr, -#ifdef notyet .vop_getacl = zfs_freebsd_getacl, .vop_setacl = zfs_freebsd_setacl, .vop_aclcheck = zfs_freebsd_aclcheck, -#endif }; struct vop_vector zfs_fifoops = { @@ -4945,10 +4971,9 @@ struct vop_vector zfs_fifoops = { .vop_reclaim = zfs_freebsd_reclaim, .vop_setattr = zfs_freebsd_setattr, .vop_write = VOP_PANIC, + .vop_pathconf = zfs_freebsd_fifo_pathconf, .vop_fid = zfs_freebsd_fid, -#ifdef notyet .vop_getacl = zfs_freebsd_getacl, .vop_setacl = zfs_freebsd_setacl, .vop_aclcheck = zfs_freebsd_aclcheck, -#endif }; From pjd at FreeBSD.org Mon Sep 7 20:10:33 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 20:10:45 2009 Subject: svn commit: r196950 - head/cddl/contrib/opensolaris/lib/libzfs/common Message-ID: <200909072010.n87KAXa7025628@svn.freebsd.org> Author: pjd Date: Mon Sep 7 20:10:33 2009 New Revision: 196950 URL: http://svn.freebsd.org/changeset/base/196950 Log: Fix detection of file system being shared. After this change commands like: # zfs unshare -a # zfs destroy foo/bar # zfs rename foo/bar foo/baz should properly remove exported file systems. MFC after: 3 days Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Mon Sep 7 19:43:13 2009 (r196949) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Mon Sep 7 20:10:33 2009 (r196950) @@ -172,6 +172,7 @@ is_shared(libzfs_handle_t *hdl, const ch *tab = '\0'; if (strcmp(buf, mountpoint) == 0) { +#if defined(sun) /* * the protocol field is the third field * skip over second field @@ -194,6 +195,10 @@ is_shared(libzfs_handle_t *hdl, const ch return (0); } } +#else + if (proto == PROTO_NFS) + return (SHARED_NFS); +#endif } } From trasz at FreeBSD.org Mon Sep 7 20:57:02 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Mon Sep 7 20:57:08 2009 Subject: svn commit: r196952 - head/share/man/man4 Message-ID: <200909072057.n87Kv1Jx026703@svn.freebsd.org> Author: trasz Date: Mon Sep 7 20:57:01 2009 New Revision: 196952 URL: http://svn.freebsd.org/changeset/base/196952 Log: Some of the controllers sold as ServeRAID (IBM ServeRAID-MR10i, in particular) are actually mfi(4) devices. Provide hints. Submitted by: Modified: head/share/man/man4/ips.4 Modified: head/share/man/man4/ips.4 ============================================================================== --- head/share/man/man4/ips.4 Mon Sep 7 20:39:04 2009 (r196951) +++ head/share/man/man4/ips.4 Mon Sep 7 20:57:01 2009 (r196952) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 4, 2006 +.Dd August 7, 2009 .Dt IPS 4 .Os .Sh NAME @@ -95,6 +95,8 @@ ServeRAID 7t/7k/7M .Pp Newer ServeRAID controllers are supported by the .Xr aac 4 +or +.Xr mfi 4 driver. .Sh DIAGNOSTICS Several error codes may be shown when the card initializes the @@ -185,6 +187,7 @@ driver does not use the subsystem. .Sh SEE ALSO .Xr aac 4 , +.Xr mfi 4 , .Xr ch 4 , .Xr da 4 , .Xr sysctl 8 From pjd at FreeBSD.org Mon Sep 7 21:46:52 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 21:47:04 2009 Subject: svn commit: r196953 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909072146.n87Lkpw6027675@svn.freebsd.org> Author: pjd Date: Mon Sep 7 21:46:51 2009 New Revision: 196953 URL: http://svn.freebsd.org/changeset/base/196953 Log: When snapshot mount point is busy (for example we are still in it) we will fail to unmount it, but it won't be removed from the tree, so in that case there is no need to reinsert it. This fixes a panic reproducable in the following steps: # zfs create tank/foo # zfs snapshot tank/foo@snap # cd /tank/foo/.zfs/snapshot/snap # umount /tank/foo panic: avl_find() succeeded inside avl_add() Reported by: trasz MFC after: 3 days Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Sep 7 20:57:01 2009 (r196952) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Sep 7 21:46:51 2009 (r196953) @@ -1344,7 +1344,15 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int if (vn_ismntpt(sep->se_root)) { error = zfsctl_unmount_snap(sep, fflags, cr); if (error) { - avl_add(&sdp->sd_snaps, sep); + /* + * Before reinserting snapshot to the tree, + * check if it was actually removed. For example + * when snapshot mount point is busy, we will + * have an error here, but there will be no need + * to reinsert snapshot. + */ + if (avl_find(&sdp->sd_snaps, sep, NULL) == NULL) + avl_add(&sdp->sd_snaps, sep); break; } } From pjd at FreeBSD.org Mon Sep 7 21:58:55 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Mon Sep 7 21:59:01 2009 Subject: svn commit: r196954 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909072158.n87LwsQR027945@svn.freebsd.org> Author: pjd Date: Mon Sep 7 21:58:54 2009 New Revision: 196954 URL: http://svn.freebsd.org/changeset/base/196954 Log: If we have to use avl_find(), optimize a bit and use avl_insert() instead of avl_add() (the latter is actually a wrapper around avl_find() + avl_insert()). Fix similar case in the code that is currently commented out. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Sep 7 21:46:51 2009 (r196953) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Mon Sep 7 21:58:54 2009 (r196954) @@ -669,9 +669,12 @@ zfsctl_snapdir_remove(vnode_t *dvp, char if (sep) { avl_remove(&sdp->sd_snaps, sep); err = zfsctl_unmount_snap(sep, MS_FORCE, cr); - if (err) - avl_add(&sdp->sd_snaps, sep); - else + if (err) { + avl_index_t where; + + if (avl_find(&sdp->sd_snaps, sep, &where) == NULL) + avl_insert(&sdp->sd_snaps, sep, where); + } else err = dmu_objset_destroy(snapname); } else { err = ENOENT; @@ -1344,6 +1347,8 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int if (vn_ismntpt(sep->se_root)) { error = zfsctl_unmount_snap(sep, fflags, cr); if (error) { + avl_index_t where; + /* * Before reinserting snapshot to the tree, * check if it was actually removed. For example @@ -1351,8 +1356,8 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int * have an error here, but there will be no need * to reinsert snapshot. */ - if (avl_find(&sdp->sd_snaps, sep, NULL) == NULL) - avl_add(&sdp->sd_snaps, sep); + if (avl_find(&sdp->sd_snaps, sep, &where) == NULL) + avl_insert(&sdp->sd_snaps, sep, where); break; } } From marck at rinet.ru Mon Sep 7 22:59:18 2009 From: marck at rinet.ru (Dmitry Morozovsky) Date: Mon Sep 7 22:59:24 2009 Subject: svn commit: r196954 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs In-Reply-To: <200909072158.n87LwsQR027945@svn.freebsd.org> References: <200909072158.n87LwsQR027945@svn.freebsd.org> Message-ID: Pawel, On Mon, 7 Sep 2009, Pawel Jakub Dawidek wrote: PJD> Author: pjd PJD> Date: Mon Sep 7 21:58:54 2009 PJD> New Revision: 196954 PJD> URL: http://svn.freebsd.org/changeset/base/196954 PJD> PJD> Log: PJD> If we have to use avl_find(), optimize a bit and use avl_insert() instead of PJD> avl_add() (the latter is actually a wrapper around avl_find() + avl_insert()). PJD> PJD> Fix similar case in the code that is currently commented out. Any chance it would fix my panic reported this spring? Thanks! -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From sbruno at FreeBSD.org Mon Sep 7 23:16:28 2009 From: sbruno at FreeBSD.org (Sean Bruno) Date: Mon Sep 7 23:17:20 2009 Subject: svn commit: r196955 - head/share/examples/scsi_target Message-ID: <200909072316.n87NGRRm029450@svn.freebsd.org> Author: sbruno Date: Mon Sep 7 23:16:27 2009 New Revision: 196955 URL: http://svn.freebsd.org/changeset/base/196955 Log: A few enhancements I made while working on the Firewire target (sbp_targ). Update the error handling in a couple of cases to exit gracefully if certain mandatory conditions aren't met. Reduce the maximum number of initiators to 8 for this example code. While 1024 is more correct, this example code would act like it was stalled out even though it was merely allocating the needed structures in init_ccbs() Reviewed by: scottl@freebsd.org Modified: head/share/examples/scsi_target/scsi_target.c head/share/examples/scsi_target/scsi_target.h Modified: head/share/examples/scsi_target/scsi_target.c ============================================================================== --- head/share/examples/scsi_target/scsi_target.c Mon Sep 7 21:58:54 2009 (r196954) +++ head/share/examples/scsi_target/scsi_target.c Mon Sep 7 23:16:27 2009 (r196955) @@ -226,7 +226,7 @@ main(int argc, char *argv[]) /* Open backing store for IO */ file_fd = open(file_name, O_RDWR); if (file_fd < 0) - err(1, "open backing store file"); + errx(EX_NOINPUT, "open backing store file"); /* Check backing store size or use the size user gave us */ if (user_size == 0) { @@ -291,7 +291,9 @@ main(int argc, char *argv[]) } while (targ_fd < 0 && errno == EBUSY); if (targ_fd < 0) - err(1, "Tried to open %d devices, none available", unit); + errx(1, "Tried to open %d devices, none available", unit); + else + warnx("opened /dev/targ%d", unit); /* The first three are handled by kevent() later */ signal(SIGHUP, SIG_IGN); @@ -318,6 +320,7 @@ main(int argc, char *argv[]) /* Set up inquiry data according to what SIM supports */ if (get_sim_flags(&sim_flags) != CAM_REQ_CMP) errx(1, "get_sim_flags"); + if (tcmd_init(req_flags, sim_flags) != 0) errx(1, "Initializing tcmd subsystem failed"); @@ -327,6 +330,7 @@ main(int argc, char *argv[]) if (debug) warnx("main loop beginning"); + request_loop(); exit(0); Modified: head/share/examples/scsi_target/scsi_target.h ============================================================================== --- head/share/examples/scsi_target/scsi_target.h Mon Sep 7 21:58:54 2009 (r196954) +++ head/share/examples/scsi_target/scsi_target.h Mon Sep 7 23:16:27 2009 (r196955) @@ -35,7 +35,7 @@ * Maximum number of parallel commands to accept, * 1024 for Fibre Channel (SPI is 16). */ -#define MAX_INITIATORS 1024 +#define MAX_INITIATORS 8 #define SECTOR_SIZE 512 #define MAX_EVENTS (MAX_INITIATORS + 5) /* kqueue for AIO, signals */ From delphij at FreeBSD.org Tue Sep 8 01:11:23 2009 From: delphij at FreeBSD.org (Xin LI) Date: Tue Sep 8 01:11:30 2009 Subject: svn commit: r196956 - head/usr.bin/w Message-ID: <200909080111.n881BNxQ031626@svn.freebsd.org> Author: delphij Date: Tue Sep 8 01:11:23 2009 New Revision: 196956 URL: http://svn.freebsd.org/changeset/base/196956 Log: Constify format string pointer, otherwise this would trigger warning when higher warning level is enabled. Modified: head/usr.bin/w/pr_time.c Modified: head/usr.bin/w/pr_time.c ============================================================================== --- head/usr.bin/w/pr_time.c Mon Sep 7 23:16:27 2009 (r196955) +++ head/usr.bin/w/pr_time.c Tue Sep 8 01:11:23 2009 (r196956) @@ -58,7 +58,7 @@ pr_attime(time_t *started, time_t *now) static wchar_t buf[256]; struct tm tp, tm; time_t diff; - wchar_t *fmt; + const wchar_t *fmt; int len, width, offset = 0; tp = *localtime(started); From kientzle at FreeBSD.org Tue Sep 8 04:52:13 2009 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Tue Sep 8 04:52:28 2009 Subject: svn commit: r196961 - in head/lib/libarchive: . test Message-ID: <200909080452.n884qC2n036193@svn.freebsd.org> Author: kientzle Date: Tue Sep 8 04:52:12 2009 New Revision: 196961 URL: http://svn.freebsd.org/changeset/base/196961 Log: Update tests to match r195873, which corrected how hardlinked files on iso9660 images were returned. While I'm poking around, update some comments around this area to try to clarify what's going on and what still remains to be improved. Modified: head/lib/libarchive/archive_read_support_format_iso9660.c head/lib/libarchive/test/test_read_format_isojoliet_bz2.c head/lib/libarchive/test/test_read_format_isorr_bz2.c Modified: head/lib/libarchive/archive_read_support_format_iso9660.c ============================================================================== --- head/lib/libarchive/archive_read_support_format_iso9660.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/archive_read_support_format_iso9660.c Tue Sep 8 04:52:12 2009 (r196961) @@ -571,9 +571,13 @@ archive_read_format_iso9660_read_header( if (file->symlink.s != NULL) archive_entry_copy_symlink(entry, file->symlink.s); - /* If this entry points to the same data as the previous - * entry, convert this into a hardlink to that entry. - * But don't bother for zero-length files. */ + /* Note: If the input isn't seekable, we can't rewind to + * return the same body again, so if the next entry refers to + * the same data, we have to return it as a hardlink to the + * original entry. */ + /* TODO: We have enough information here to compute an + * accurate value for nlinks. We should do so and ignore + * nlinks from the RR extensions. */ if (file->offset == iso9660->previous_offset && file->size == iso9660->previous_size && file->size > 0) { @@ -586,8 +590,21 @@ archive_read_format_iso9660_read_header( return (ARCHIVE_OK); } - /* If the offset is before our current position, we can't - * seek backwards to extract it, so issue a warning. */ + /* Except for the hardlink case above, if the offset of the + * next entry is before our current position, we can't seek + * backwards to extract it, so issue a warning. Note that + * this can only happen if this entry was added to the heap + * after we passed this offset, that is, only if the directory + * mentioning this entry is later than the body of the entry. + * Such layouts are very unusual; most ISO9660 writers lay out + * and record all directory information first, then store + * all file bodies. */ + /* TODO: Someday, libarchive's I/O core will support optional + * seeking. When that day comes, this code should attempt to + * seek and only return the error if the seek fails. That + * will give us support for whacky ISO images that require + * seeking while retaining the ability to read almost all ISO + * images in a streaming fashion. */ if (file->offset < iso9660->current_position) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Ignoring out-of-order file @%x (%s) %jd < %jd", @@ -628,7 +645,7 @@ archive_read_format_iso9660_read_header( struct file_info *child; /* N.B.: these special directory identifiers - * are 8 bit "values" even on a + * are 8 bit "values" even on a * Joliet CD with UCS-2 (16bit) encoding. */ Modified: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c ============================================================================== --- head/lib/libarchive/test/test_read_format_isojoliet_bz2.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/test/test_read_format_isojoliet_bz2.c Tue Sep 8 04:52:12 2009 (r196961) @@ -107,14 +107,12 @@ joliettest(int withrr) assertEqualInt(2, archive_entry_gid(ae)); } - /* A hardlink to the regular file. */ + /* A regular file with two names ("hardlink" gets returned + * first, so it's not marked as a hardlink). */ assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("hardlink", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); - if (withrr) { - assertEqualString("long-joliet-file-name.textfile", - archive_entry_hardlink(ae)); - } + assert(archive_entry_hardlink(ae) == NULL); assertEqualInt(6, archive_entry_size(ae)); assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset)); assertEqualInt(6, (int)size); @@ -123,20 +121,27 @@ joliettest(int withrr) if (withrr) { assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + /* TODO: Actually, libarchive should be able to + * compute nlinks correctly even without RR + * extensions. See comments in libarchive source. */ + assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } - /* A regular file. */ + /* Second name for the same regular file (this happens to be + * returned second, so does get marked as a hardlink). */ assertEqualInt(0, archive_read_next_header(a, &ae)); - assertEqualString("long-joliet-file-name.textfile", archive_entry_pathname(ae)); + assertEqualString("long-joliet-file-name.textfile", + archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); - assertEqualInt(6, archive_entry_size(ae)); + assertEqualString("hardlink", archive_entry_hardlink(ae)); + assert(!archive_entry_size_is_set(ae)); if (withrr) { assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + /* TODO: See above. */ + assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } @@ -153,7 +158,7 @@ joliettest(int withrr) assertEqualInt(172802, archive_entry_mtime(ae)); assertEqualInt(172802, archive_entry_atime(ae)); if (withrr) { - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } Modified: head/lib/libarchive/test/test_read_format_isorr_bz2.c ============================================================================== --- head/lib/libarchive/test/test_read_format_isorr_bz2.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/test/test_read_format_isorr_bz2.c Tue Sep 8 04:52:12 2009 (r196961) @@ -111,7 +111,7 @@ DEFINE_TEST(test_read_format_isorr_bz2) assertEqualString("hardlink", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); assertEqualString("file", archive_entry_hardlink(ae)); - assertEqualInt(12345684, archive_entry_size(ae)); + assert(!archive_entry_size_is_set(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); assertEqualInt(2, archive_entry_stat(ae)->st_nlink); From kientzle at FreeBSD.org Tue Sep 8 05:02:42 2009 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Tue Sep 8 05:02:49 2009 Subject: svn commit: r196962 - in head/lib/libarchive: . test Message-ID: <200909080502.n8852gH4036454@svn.freebsd.org> Author: kientzle Date: Tue Sep 8 05:02:41 2009 New Revision: 196962 URL: http://svn.freebsd.org/changeset/base/196962 Log: Fiz /usr/bin/unzip: A bug deep in libarchive's read-ahead logic (incorrect handling of zero-length reads before the copy buffer is allocated) is masked by the iso9660 taster. Tar and cpio both enable that taster so were protected from the bug; unzip is susceptible. This both fixes the bug and updates the test harness to exercise this case. Submitted by: Ed Schouten diagnosed the bug and drafted a patch MFC after: 7 days Modified: head/lib/libarchive/archive_read.c head/lib/libarchive/test/test_compat_zip.c Modified: head/lib/libarchive/archive_read.c ============================================================================== --- head/lib/libarchive/archive_read.c Tue Sep 8 04:52:12 2009 (r196961) +++ head/lib/libarchive/archive_read.c Tue Sep 8 05:02:41 2009 (r196962) @@ -928,9 +928,12 @@ __archive_read_filter_ahead(struct archi for (;;) { /* - * If we can satisfy from the copy buffer, we're done. + * If we can satisfy from the copy buffer (and the + * copy buffer isn't empty), we're done. In particular, + * note that min == 0 is a perfectly well-defined + * request. */ - if (filter->avail >= min) { + if (filter->avail >= min && filter->avail > 0) { if (avail != NULL) *avail = filter->avail; return (filter->next); Modified: head/lib/libarchive/test/test_compat_zip.c ============================================================================== --- head/lib/libarchive/test/test_compat_zip.c Tue Sep 8 04:52:12 2009 (r196961) +++ head/lib/libarchive/test/test_compat_zip.c Tue Sep 8 05:02:41 2009 (r196962) @@ -36,7 +36,7 @@ test_compat_zip_1(void) assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); extract_reference_file(name); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); From pjd at FreeBSD.org Tue Sep 8 05:03:38 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 05:03:44 2009 Subject: svn commit: r196954 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs In-Reply-To: References: <200909072158.n87LwsQR027945@svn.freebsd.org> Message-ID: <20090908050330.GE1574@garage.freebsd.pl> On Tue, Sep 08, 2009 at 02:59:15AM +0400, Dmitry Morozovsky wrote: > > Pawel, > > > On Mon, 7 Sep 2009, Pawel Jakub Dawidek wrote: > > PJD> Author: pjd > PJD> Date: Mon Sep 7 21:58:54 2009 > PJD> New Revision: 196954 > PJD> URL: http://svn.freebsd.org/changeset/base/196954 > PJD> > PJD> Log: > PJD> If we have to use avl_find(), optimize a bit and use avl_insert() instead of > PJD> avl_add() (the latter is actually a wrapper around avl_find() + avl_insert()). > PJD> > PJD> Fix similar case in the code that is currently commented out. > > Any chance it would fix my panic reported this spring? I'm sorry, but no. Your panic was related to ZAP code. We can still try to debug it further if you still have this file system somewhere, but last I remember your mail server was refusing e-mails from me. If that's still the case and you read this e-mail from the mailing list could you check logs of your e-mail server and whitelist my? I have many problems because reverse DNS for my IP has *dsl* in it, which is often interpreted as dynamic IP address. -- Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090908/817f6366/attachment.pgp From mav at FreeBSD.org Tue Sep 8 05:46:39 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Tue Sep 8 05:46:47 2009 Subject: svn commit: r196964 - head/sys/geom Message-ID: <200909080546.n885kcHx037457@svn.freebsd.org> Author: mav Date: Tue Sep 8 05:46:38 2009 New Revision: 196964 URL: http://svn.freebsd.org/changeset/base/196964 Log: Do not check proper request alignment here in geom_dev in production. It will be checked any way later by g_io_check() in g_io_schedule_down(). It is only needed here to not trigger panic from additional check, when INVARIANTS enabled. So cover it with #ifdef INVARIANTS. It saves two 64bit divisions per request. Modified: head/sys/geom/geom_dev.c Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Tue Sep 8 05:24:09 2009 (r196963) +++ head/sys/geom/geom_dev.c Tue Sep 8 05:46:38 2009 (r196964) @@ -371,14 +371,14 @@ g_dev_strategy(struct bio *bp) cp = dev->si_drv2; KASSERT(cp->acr || cp->acw, ("Consumer with zero access count in g_dev_strategy")); - +#ifdef INVARIANTS if ((bp->bio_offset % cp->provider->sectorsize) != 0 || (bp->bio_bcount % cp->provider->sectorsize) != 0) { bp->bio_resid = bp->bio_bcount; biofinish(bp, NULL, EINVAL); return; } - +#endif for (;;) { /* * XXX: This is not an ideal solution, but I belive it to From pjd at FreeBSD.org Tue Sep 8 08:54:15 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 08:54:32 2009 Subject: svn commit: r196965 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909080854.n888sFGR041201@svn.freebsd.org> Author: pjd Date: Tue Sep 8 08:54:15 2009 New Revision: 196965 URL: http://svn.freebsd.org/changeset/base/196965 Log: Fix reference count leak for a case where snapshot's mount point is updated. Such situation is not supported. This problem was triggered by something like this: # zpool create tank da0 # zfs snapshot tank@snap # cd /tank/.zfs/snapshot/snap (this will mount the snapshot) # cd # mount -u nosuid /tank/.zfs/snapshot/snap (refcount leak) # zpool export tank cannot export 'tank': pool is busy MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 05:46:38 2009 (r196964) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 08:54:15 2009 (r196965) @@ -337,6 +337,13 @@ zfs_register_callbacks(vfs_t *vfsp) os = zfsvfs->z_os; /* + * This function can be called for a snapshot when we update snapshot's + * mount point, which isn't really supported. + */ + if (dmu_objset_is_snapshot(os)) + return (EOPNOTSUPP); + + /* * The act of registering our callbacks will destroy any mount * options we may have. In order to enable temporary overrides * of mount options, we stash away the current values and From kib at FreeBSD.org Tue Sep 8 09:17:34 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Tue Sep 8 09:17:40 2009 Subject: svn commit: r196966 - head/sys/cddl/compat/opensolaris/kern Message-ID: <200909080917.n889HYI1041726@svn.freebsd.org> Author: kib Date: Tue Sep 8 09:17:34 2009 New Revision: 196966 URL: http://svn.freebsd.org/changeset/base/196966 Log: Lock Giant around vn_open_cred(). Remove innocent unnecessary call to NDFREE(). Reported by: marcel Reviewed and tested by: pjd MFC after: 3 days Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_kobj.c Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_kobj.c ============================================================================== --- head/sys/cddl/compat/opensolaris/kern/opensolaris_kobj.c Tue Sep 8 08:54:15 2009 (r196965) +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_kobj.c Tue Sep 8 09:17:34 2009 (r196966) @@ -69,7 +69,7 @@ kobj_open_file_vnode(const char *file) struct thread *td = curthread; struct filedesc *fd; struct nameidata nd; - int error, flags; + int error, flags, vfslocked; fd = td->td_proc->p_fd; FILEDESC_XLOCK(fd); @@ -86,11 +86,13 @@ kobj_open_file_vnode(const char *file) flags = FREAD | O_NOFOLLOW; NDINIT(&nd, LOOKUP, MPSAFE, UIO_SYSSPACE, file, td); error = vn_open_cred(&nd, &flags, 0, 0, curthread->td_ucred, NULL); - NDFREE(&nd, NDF_ONLY_PNBUF); if (error != 0) return (NULL); + vfslocked = NDHASGIANT(&nd); + NDFREE(&nd, NDF_ONLY_PNBUF); /* We just unlock so we hold a reference. */ VOP_UNLOCK(nd.ni_vp, 0); + VFS_UNLOCK_GIANT(vfslocked); return (nd.ni_vp); } From phk at FreeBSD.org Tue Sep 8 10:39:38 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 10:39:45 2009 Subject: svn commit: r196967 - in head/sys: netinet sys Message-ID: <200909081039.n88AdcNU045214@svn.freebsd.org> Author: phk Date: Tue Sep 8 10:39:38 2009 New Revision: 196967 URL: http://svn.freebsd.org/changeset/base/196967 Log: Move the duplicate definition of struct sockaddr_storage to its own include file, and include this where the previous duplicate definitions were. Static program checkers like FlexeLint rightfully take a dim view of duplicate definitions, even if they currently are identical. Added: head/sys/sys/_sockaddr_storage.h (contents, props changed) Modified: head/sys/netinet/in.h head/sys/sys/socket.h Modified: head/sys/netinet/in.h ============================================================================== --- head/sys/netinet/in.h Tue Sep 8 09:17:34 2009 (r196966) +++ head/sys/netinet/in.h Tue Sep 8 10:39:38 2009 (r196967) @@ -89,27 +89,7 @@ typedef __socklen_t socklen_t; #define _SOCKLEN_T_DECLARED #endif -/* Avoid collision with original definition in sys/socket.h. */ -#ifndef _STRUCT_SOCKADDR_STORAGE_DECLARED -/* - * RFC 2553: protocol-independent placeholder for socket addresses - */ -#define _SS_MAXSIZE 128U -#define _SS_ALIGNSIZE (sizeof(__int64_t)) -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) - -struct sockaddr_storage { - unsigned char ss_len; /* address length */ - sa_family_t ss_family; /* address family */ - char __ss_pad1[_SS_PAD1SIZE]; - __int64_t __ss_align; /* force desired struct alignment */ - char __ss_pad2[_SS_PAD2SIZE]; -}; -#define _STRUCT_SOCKADDR_STORAGE_DECLARED -#endif +#include /* Socket address, internet style. */ struct sockaddr_in { Added: head/sys/sys/_sockaddr_storage.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sys/_sockaddr_storage.h Tue Sep 8 10:39:38 2009 (r196967) @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 + * The Regents of the University of California. 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. + * 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 REGENTS 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 REGENTS 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. + * + * @(#)socket.h 8.4 (Berkeley) 2/21/94 + * $FreeBSD$ + */ + +#ifndef _SYS__SOCKADDR_STORAGE_H_ +#define _SYS__SOCKADDR_STORAGE_H_ + +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128U +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { + unsigned char ss_len; /* address length */ + sa_family_t ss_family; /* address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; /* force desired struct alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + +#endif /* !_SYS__SOCKADDR_STORAGE_H_ */ Modified: head/sys/sys/socket.h ============================================================================== --- head/sys/sys/socket.h Tue Sep 8 09:17:34 2009 (r196966) +++ head/sys/sys/socket.h Tue Sep 8 10:39:38 2009 (r196967) @@ -290,26 +290,7 @@ struct sockproto { }; #endif -#ifndef _STRUCT_SOCKADDR_STORAGE_DECLARED -/* - * RFC 2553: protocol-independent placeholder for socket addresses - */ -#define _SS_MAXSIZE 128U -#define _SS_ALIGNSIZE (sizeof(__int64_t)) -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) - -struct sockaddr_storage { - unsigned char ss_len; /* address length */ - sa_family_t ss_family; /* address family */ - char __ss_pad1[_SS_PAD1SIZE]; - __int64_t __ss_align; /* force desired struct alignment */ - char __ss_pad2[_SS_PAD2SIZE]; -}; -#define _STRUCT_SOCKADDR_STORAGE_DECLARED -#endif +#include #if __BSD_VISIBLE /* From phk at FreeBSD.org Tue Sep 8 12:59:57 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 13:00:10 2009 Subject: svn commit: r196968 - head/sys/amd64/include Message-ID: <200909081259.n88Cxvan048046@svn.freebsd.org> Author: phk Date: Tue Sep 8 12:59:56 2009 New Revision: 196968 URL: http://svn.freebsd.org/changeset/base/196968 Log: Move multi-include protection back up to the top of the file and name after the physical file rather than the aliased name. Modified: head/sys/amd64/include/param.h Modified: head/sys/amd64/include/param.h ============================================================================== --- head/sys/amd64/include/param.h Tue Sep 8 10:39:38 2009 (r196967) +++ head/sys/amd64/include/param.h Tue Sep 8 12:59:56 2009 (r196968) @@ -39,6 +39,9 @@ * $FreeBSD$ */ +#ifndef _AMD64_INCLUDE_PARAM_H_ +#define _AMD64_INCLUDE_PARAM_H_ + /* * Machine dependent constants for AMD64. */ @@ -60,9 +63,6 @@ #define __HAVE_ACPI #define __PCI_REROUTE_INTERRUPT -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "amd64" #endif @@ -150,5 +150,5 @@ #define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ #endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_AMD64_INCLUDE_PARAM_H_ */ From phk at FreeBSD.org Tue Sep 8 13:16:56 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 13:17:24 2009 Subject: svn commit: r196969 - in head/sys: cam/scsi contrib/dev/acpica/executer dev/aac dev/ae dev/amr dev/ata dev/ata/chipsets dev/ath dev/ath/ath_hal dev/bce dev/e1000 dev/ep dev/firewire dev/fxp dev/hpt... Message-ID: <200909081316.n88DGtVn048461@svn.freebsd.org> Author: phk Date: Tue Sep 8 13:16:55 2009 New Revision: 196969 URL: http://svn.freebsd.org/changeset/base/196969 Log: Add necessary include. Modified: head/sys/cam/scsi/scsi_cd.c head/sys/contrib/dev/acpica/executer/exfldio.c head/sys/dev/aac/aac.c head/sys/dev/ae/if_ae.c head/sys/dev/amr/amr.c head/sys/dev/ata/ata-raid.c head/sys/dev/ata/chipsets/ata-acerlabs.c head/sys/dev/ata/chipsets/ata-marvell.c head/sys/dev/ath/ah_osdep.c head/sys/dev/ath/ath_hal/ah.c head/sys/dev/ath/ath_hal/ah_eeprom_v3.c head/sys/dev/bce/if_bce.c head/sys/dev/e1000/if_em.c head/sys/dev/ep/if_ep.c head/sys/dev/ep/if_epreg.h head/sys/dev/firewire/fwcrom.c head/sys/dev/firewire/fwdev.c head/sys/dev/fxp/if_fxp.c head/sys/dev/hptiop/hptiop.c head/sys/dev/iir/iir.c head/sys/dev/mpt/mpt_raid.c head/sys/dev/msk/if_msk.c head/sys/dev/usb/wlan/if_rum.c head/sys/dev/usb/wlan/if_rumreg.h head/sys/dev/usb/wlan/if_urtw.c head/sys/dev/wi/if_wi.c head/sys/fs/msdosfs/msdosfs_conv.c head/sys/kern/kern_jail.c head/sys/kern/kern_linker.c head/sys/kern/kern_lock.c head/sys/kern/kern_mutex.c head/sys/net80211/ieee80211_action.c head/sys/net80211/ieee80211_proto.h head/sys/security/audit/audit_bsm_token.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/cam/scsi/scsi_cd.c Tue Sep 8 13:16:55 2009 (r196969) @@ -2528,7 +2528,7 @@ cdioctl(struct disk *dp, u_long cmd, voi error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(¶ms, M_SCSICD); + free(¶ms.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } Modified: head/sys/contrib/dev/acpica/executer/exfldio.c ============================================================================== --- head/sys/contrib/dev/acpica/executer/exfldio.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/contrib/dev/acpica/executer/exfldio.c Tue Sep 8 13:16:55 2009 (r196969) @@ -992,6 +992,7 @@ AcpiExInsertIntoField ( /* Get initial Datum from the input buffer */ + /* XXX: Flexelint sees arg 9 for bufferlen 8 */ ACPI_MEMCPY (&RawDatum, Buffer, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); Modified: head/sys/dev/aac/aac.c ============================================================================== --- head/sys/dev/aac/aac.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/aac/aac.c Tue Sep 8 13:16:55 2009 (r196969) @@ -3556,7 +3556,7 @@ aac_supported_features(struct aac_softc * associated with the feature in the data field or perform whatever * action needed indicates in the data field. */ - if (f.feat.fValue == 0) { + if (f.feat.fValue == 0) { f.feat.fBits.largeLBA = (sc->flags & AAC_FLAGS_LBA_64BIT) ? 1 : 0; /* TODO: In the future, add other features state here as well */ Modified: head/sys/dev/ae/if_ae.c ============================================================================== --- head/sys/dev/ae/if_ae.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ae/if_ae.c Tue Sep 8 13:16:55 2009 (r196969) @@ -1662,6 +1662,7 @@ ae_stop_rxmac(ae_softc_t *sc) /* * Wait for IDLE state. */ + /* XXX: Flexelint "<" test with -- */ for (i = 0; i < AE_IDLE_TIMEOUT; i--) { val = AE_READ_4(sc, AE_IDLE_REG); if ((val & (AE_IDLE_RXMAC | AE_IDLE_DMAWRITE)) == 0) @@ -1698,6 +1699,7 @@ ae_stop_txmac(ae_softc_t *sc) /* * Wait for IDLE state. */ + /* XXX: Flexelint "<" test with -- */ for (i = 0; i < AE_IDLE_TIMEOUT; i--) { val = AE_READ_4(sc, AE_IDLE_REG); if ((val & (AE_IDLE_TXMAC | AE_IDLE_DMAREAD)) == 0) Modified: head/sys/dev/amr/amr.c ============================================================================== --- head/sys/dev/amr/amr.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/amr/amr.c Tue Sep 8 13:16:55 2009 (r196969) @@ -527,7 +527,7 @@ amr_rescan_drives(struct cdev *dev) sc->amr_drive[i].al_disk)) != 0) goto shutdown_out; - sc->amr_drive[i].al_disk = 0; + sc->amr_drive[i].al_disk = 0; } } Modified: head/sys/dev/ata/ata-raid.c ============================================================================== --- head/sys/dev/ata/ata-raid.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ata/ata-raid.c Tue Sep 8 13:16:55 2009 (r196969) @@ -407,7 +407,7 @@ ata_raid_strategy(struct bio *bp) if (rdp->status & AR_S_REBUILDING) blk = ((lba / rdp->interleave) * rdp->width) * rdp->interleave + (rdp->interleave * (drv % rdp->width)) + - lba % rdp->interleave;; + lba % rdp->interleave; if (bp->bio_cmd == BIO_READ) { int src_online = @@ -1138,6 +1138,7 @@ ata_raid_create(struct ata_ioc_raid_conf rdp->type == AR_T_RAID5) { int bit = 0; + /* XXX: Flexelint not happy */ while (config->interleave >>= 1) bit++; rdp->interleave = 1 << bit; Modified: head/sys/dev/ata/chipsets/ata-acerlabs.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-acerlabs.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ata/chipsets/ata-acerlabs.c Tue Sep 8 13:16:55 2009 (r196969) @@ -127,6 +127,7 @@ ata_ali_chipinit(device_t dev) RF_ACTIVE); if (res->bars[i] == NULL) { device_printf(dev, "Failed to allocate BAR %d\n", i); + /* XXX: Flexelint: Reuse of for loop variable 'i' at 'line 124' could cause chaos */ for (i--; i >=0; i--) bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(i), res->bars[i]); Modified: head/sys/dev/ata/chipsets/ata-marvell.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-marvell.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ata/chipsets/ata-marvell.c Tue Sep 8 13:16:55 2009 (r196969) @@ -153,7 +153,7 @@ ata_marvell_pata_ch_attach(device_t dev) return ENXIO; /* dont use 32 bit PIO transfers */ - ch->flags |= ATA_USE_16BIT; + ch->flags |= ATA_USE_16BIT; return 0; } Modified: head/sys/dev/ath/ah_osdep.c ============================================================================== --- head/sys/dev/ath/ah_osdep.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ath/ah_osdep.c Tue Sep 8 13:16:55 2009 (r196969) @@ -107,6 +107,7 @@ ath_hal_malloc(size_t size) return malloc(size, M_ATH_HAL, M_NOWAIT | M_ZERO); } +/* XXX: FlexeLint return in void function ? */ void ath_hal_free(void* p) { Modified: head/sys/dev/ath/ath_hal/ah.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ath/ath_hal/ah.c Tue Sep 8 13:16:55 2009 (r196969) @@ -566,6 +566,7 @@ ath_hal_getregdump(struct ath_hal *ah, c uint32_t *dp = dstbuf; int i; + /* XXX: FlexeLint: ">" test with ++ */ for (i = 0; space >= 2*sizeof(uint32_t); i++) { u_int r = regs[i].start; u_int e = regs[i].end; Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v3.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Tue Sep 8 13:16:55 2009 (r196969) @@ -1753,6 +1753,8 @@ legacyEepromGetSpurChan(struct ath_hal * /* * Reclaim any EEPROM-related storage. */ + +/* XXX: FlexeLint: return in void function */ static void legacyEepromDetach(struct ath_hal *ah) { Modified: head/sys/dev/bce/if_bce.c ============================================================================== --- head/sys/dev/bce/if_bce.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/bce/if_bce.c Tue Sep 8 13:16:55 2009 (r196969) @@ -608,17 +608,17 @@ bce_print_adapter_info(struct bce_softc #endif if (sc->bce_flags & BCE_USING_MSI_FLAG) { if (i > 0) printf("|"); - printf("MSI"); i++; + printf("MSI"); i++; } if (sc->bce_flags & BCE_USING_MSIX_FLAG) { if (i > 0) printf("|"); - printf("MSI-X "); i++; + printf("MSI-X "); i++; } if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) { if (i > 0) printf("|"); - printf("2.5G"); i++; + printf("2.5G"); i++; } if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) { @@ -628,7 +628,7 @@ bce_print_adapter_info(struct bce_softc printf(")\n"); } - DBEXIT(BCE_VERBOSE_LOAD); + DBEXIT(BCE_VERBOSE_LOAD); } Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/e1000/if_em.c Tue Sep 8 13:16:55 2009 (r196969) @@ -2826,7 +2826,7 @@ em_allocate_pci_resources(struct adapter * Setup the Legacy or MSI Interrupt handler * **********************************************************************/ -int +static int em_allocate_legacy(struct adapter *adapter) { device_t dev = adapter->dev; Modified: head/sys/dev/ep/if_ep.c ============================================================================== --- head/sys/dev/ep/if_ep.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ep/if_ep.c Tue Sep 8 13:16:55 2009 (r196969) @@ -666,6 +666,7 @@ rescan: sc->tx_underrun++; #endif } else { + /* XXX: FlexeLint doesn't like ; */ if (status & TXS_JABBER); else ++ifp->if_collisions; Modified: head/sys/dev/ep/if_epreg.h ============================================================================== --- head/sys/dev/ep/if_epreg.h Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/ep/if_epreg.h Tue Sep 8 13:16:55 2009 (r196969) @@ -315,7 +315,11 @@ S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY) #define S_COMMAND_IN_PROGRESS (u_short) (0x1000) -#define EP_BUSY_WAIT(sc) while (CSR_READ_2(sc, EP_STATUS) & S_COMMAND_IN_PROGRESS) +#define EP_BUSY_WAIT(sc) \ + do { \ + while (CSR_READ_2(sc, EP_STATUS) & S_COMMAND_IN_PROGRESS) \ + continue; \ + } while (0) /* Address Config. Register. * Window 0/Port 06 Modified: head/sys/dev/firewire/fwcrom.c ============================================================================== --- head/sys/dev/firewire/fwcrom.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/firewire/fwcrom.c Tue Sep 8 13:16:55 2009 (r196969) @@ -454,9 +454,9 @@ crom_add_simple_text(struct crom_src *sr len = strlen(buf); if (len > MAX_TEXT) { #if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("text(%d) trancated to %d.\n", len, MAX_TEXT); + printf("text(%d) truncated to %d.\n", len, MAX_TEXT); #else - printf("text(%d) trancated to %td.\n", len, MAX_TEXT); + printf("text(%d) truncated to %td.\n", len, MAX_TEXT); #endif len = MAX_TEXT; } Modified: head/sys/dev/firewire/fwdev.c ============================================================================== --- head/sys/dev/firewire/fwdev.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/firewire/fwdev.c Tue Sep 8 13:16:55 2009 (r196969) @@ -844,6 +844,7 @@ out: err = copyout(ptr, crom_buf->ptr, len); if (fwdev == NULL) /* myself */ + /* XXX: Flexelint no sure about modified pointer */ free(ptr, M_FW); break; default: Modified: head/sys/dev/fxp/if_fxp.c ============================================================================== --- head/sys/dev/fxp/if_fxp.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/fxp/if_fxp.c Tue Sep 8 13:16:55 2009 (r196969) @@ -1597,6 +1597,7 @@ fxp_encap(struct fxp_softc *sc, struct m cbp->tbd_number = nseg; /* Configure TSO. */ if (m->m_pkthdr.csum_flags & CSUM_TSO) { + /* XXX: FlexeLint: negative subscript */ cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16); cbp->tbd[1].tb_size |= htole32(tcp_payload << 16); cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | Modified: head/sys/dev/hptiop/hptiop.c ============================================================================== --- head/sys/dev/hptiop/hptiop.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/hptiop/hptiop.c Tue Sep 8 13:16:55 2009 (r196969) @@ -432,6 +432,7 @@ srb_complete: sg_list), (u_int8_t *)&ccb->csio.sense_data, MIN(dxfer, sizeof(ccb->csio.sense_data))); } else { + /* XXX: Flexelint arg2 is 16 bytes, arg3 is 32 */ memcpy(&ccb->csio.sense_data, &req->sg_list, MIN(dxfer, sizeof(ccb->csio.sense_data))); } @@ -575,6 +576,7 @@ static void hptiop_request_callback_mv(s ccb->ccb_h.status = CAM_BUSY; break; case IOP_RESULT_CHECK_CONDITION: + /* XXX: FlexeLint: arg2=16b arg3=32 */ memcpy(&ccb->csio.sense_data, &req->sg_list, MIN(req->dataxfer_length, sizeof(ccb->csio.sense_data))); ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; Modified: head/sys/dev/iir/iir.c ============================================================================== --- head/sys/dev/iir/iir.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/iir/iir.c Tue Sep 8 13:16:55 2009 (r196969) @@ -1203,6 +1203,7 @@ gdt_internal_cache_cmd(struct gdt_softc bzero( ccb->csio.data_ptr+copylen, ccb->csio.dxfer_len - copylen ); page=((struct scsi_mode_sense_6 *)ccb->csio.cdb_io.cdb_bytes)->page; + /* XXX: FlexeLint: why ?? */ switch (page) { default: GDT_DPRINTF(GDT_D_MISC, ("MODE_SENSE_6: page 0x%x\n", page)); Modified: head/sys/dev/mpt/mpt_raid.c ============================================================================== --- head/sys/dev/mpt/mpt_raid.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/mpt/mpt_raid.c Tue Sep 8 13:16:55 2009 (r196969) @@ -562,6 +562,7 @@ mpt_raid_reply_frame_handler(struct mpt_ break; } action_result = REQ_TO_RAID_ACTION_RESULT(req); + /* XXX: FlexeLint: ActionData is only 4 bytes */ memcpy(&action_result->action_data, &reply->ActionData, sizeof(action_result->action_data)); action_result->action_status = le16toh(reply->ActionStatus); Modified: head/sys/dev/msk/if_msk.c ============================================================================== --- head/sys/dev/msk/if_msk.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/msk/if_msk.c Tue Sep 8 13:16:55 2009 (r196969) @@ -118,26 +118,21 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include #include #include -#include #include #include -#include #include #include #include #include -#include #include -#include #include #include Modified: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/usb/wlan/if_rum.c Tue Sep 8 13:16:55 2009 (r196969) @@ -42,12 +42,9 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include -#include #include #include #include @@ -1489,7 +1486,7 @@ rum_rf_write(struct rum_softc *sc, uint8 return; } - tmp = RT2573_RF_BUSY | RT2573_RF_20BIT | (val & 0xfffff) << 2 | + tmp = RT2573_RF_BUSY | RT2573_RF_20BIT | ((val & 0xfffff) << 2) | (reg & 3); rum_write(sc, RT2573_PHY_CSR4, tmp); Modified: head/sys/dev/usb/wlan/if_rumreg.h ============================================================================== --- head/sys/dev/usb/wlan/if_rumreg.h Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/usb/wlan/if_rumreg.h Tue Sep 8 13:16:55 2009 (r196969) @@ -139,7 +139,7 @@ #define RT2573_BBP_BUSY (1 << 16) /* possible flags for register PHY_CSR4 */ #define RT2573_RF_20BIT (20 << 24) -#define RT2573_RF_BUSY (1 << 31) +#define RT2573_RF_BUSY (1U << 31) /* LED values */ #define RT2573_LED_RADIO (1 << 8) Modified: head/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- head/sys/dev/usb/wlan/if_urtw.c Tue Sep 8 12:59:56 2009 (r196968) +++ head/sys/dev/usb/wlan/if_urtw.c Tue Sep 8 13:16:55 2009 (r196969) @@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$"); #include #include +#define nitems(a) (sizeof(a) / sizeof((a)[0])) + SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; @@ -175,6 +177,46 @@ struct urtw_pair { uint32_t val; }; +static const uint8_t urtw_8187b_reg_table[][3] = { + { 0xf0, 0x32, 0 }, { 0xf1, 0x32, 0 }, { 0xf2, 0x00, 0 }, + { 0xf3, 0x00, 0 }, { 0xf4, 0x32, 0 }, { 0xf5, 0x43, 0 }, + { 0xf6, 0x00, 0 }, { 0xf7, 0x00, 0 }, { 0xf8, 0x46, 0 }, + { 0xf9, 0xa4, 0 }, { 0xfa, 0x00, 0 }, { 0xfb, 0x00, 0 }, + { 0xfc, 0x96, 0 }, { 0xfd, 0xa4, 0 }, { 0xfe, 0x00, 0 }, + { 0xff, 0x00, 0 }, + + { 0x58, 0x4b, 1 }, { 0x59, 0x00, 1 }, { 0x5a, 0x4b, 1 }, + { 0x5b, 0x00, 1 }, { 0x60, 0x4b, 1 }, { 0x61, 0x09, 1 }, + { 0x62, 0x4b, 1 }, { 0x63, 0x09, 1 }, { 0xce, 0x0f, 1 }, + { 0xcf, 0x00, 1 }, { 0xe0, 0xff, 1 }, { 0xe1, 0x0f, 1 }, + { 0xe2, 0x00, 1 }, { 0xf0, 0x4e, 1 }, { 0xf1, 0x01, 1 }, + { 0xf2, 0x02, 1 }, { 0xf3, 0x03, 1 }, { 0xf4, 0x04, 1 }, + { 0xf5, 0x05, 1 }, { 0xf6, 0x06, 1 }, { 0xf7, 0x07, 1 }, + { 0xf8, 0x08, 1 }, + + { 0x4e, 0x00, 2 }, { 0x0c, 0x04, 2 }, { 0x21, 0x61, 2 }, + { 0x22, 0x68, 2 }, { 0x23, 0x6f, 2 }, { 0x24, 0x76, 2 }, + { 0x25, 0x7d, 2 }, { 0x26, 0x84, 2 }, { 0x27, 0x8d, 2 }, + { 0x4d, 0x08, 2 }, { 0x50, 0x05, 2 }, { 0x51, 0xf5, 2 }, + { 0x52, 0x04, 2 }, { 0x53, 0xa0, 2 }, { 0x54, 0x1f, 2 }, + { 0x55, 0x23, 2 }, { 0x56, 0x45, 2 }, { 0x57, 0x67, 2 }, + { 0x58, 0x08, 2 }, { 0x59, 0x08, 2 }, { 0x5a, 0x08, 2 }, + { 0x5b, 0x08, 2 }, { 0x60, 0x08, 2 }, { 0x61, 0x08, 2 }, + { 0x62, 0x08, 2 }, { 0x63, 0x08, 2 }, { 0x64, 0xcf, 2 }, + { 0x72, 0x56, 2 }, { 0x73, 0x9a, 2 }, + + { 0x34, 0xf0, 0 }, { 0x35, 0x0f, 0 }, { 0x5b, 0x40, 0 }, + { 0x84, 0x88, 0 }, { 0x85, 0x24, 0 }, { 0x88, 0x54, 0 }, + { 0x8b, 0xb8, 0 }, { 0x8c, 0x07, 0 }, { 0x8d, 0x00, 0 }, + { 0x94, 0x1b, 0 }, { 0x95, 0x12, 0 }, { 0x96, 0x00, 0 }, + { 0x97, 0x06, 0 }, { 0x9d, 0x1a, 0 }, { 0x9f, 0x10, 0 }, + { 0xb4, 0x22, 0 }, { 0xbe, 0x80, 0 }, { 0xdb, 0x00, 0 }, + { 0xee, 0x00, 0 }, { 0x91, 0x03, 0 }, + + { 0x4c, 0x00, 2 }, { 0x9f, 0x00, 3 }, { 0x8c, 0x01, 0 }, + { 0x8d, 0x10, 0 }, { 0x8e, 0x08, 0 }, { 0x8f, 0x00, 0 } +}; + static uint8_t urtw_8225_agc[] = { 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, @@ -190,21 +232,6 @@ static uint8_t urtw_8225_agc[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; -static uint8_t urtw_8225z2_agc[] = { - 0x5e, 0x5e, 0x5e, 0x5e, 0x5d, 0x5b, 0x59, 0x57, 0x55, 0x53, 0x51, - 0x4f, 0x4d, 0x4b, 0x49, 0x47, 0x45, 0x43, 0x41, 0x3f, 0x3d, 0x3b, - 0x39, 0x37, 0x35, 0x33, 0x31, 0x2f, 0x2d, 0x2b, 0x29, 0x27, 0x25, - 0x23, 0x21, 0x1f, 0x1d, 0x1b, 0x19, 0x17, 0x15, 0x13, 0x11, 0x0f, - 0x0d, 0x0b, 0x09, 0x07, 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2a, - 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 -}; - static uint32_t urtw_8225_channel[] = { 0x0000, /* dummy channel 0 */ 0x085c, /* 1 */ @@ -237,7 +264,7 @@ static struct urtw_pair urtw_8225_rf_par { 0x00, 0x0067 }, { 0x01, 0x0fe0 }, { 0x02, 0x044d }, { 0x03, 0x0441 }, { 0x04, 0x0486 }, { 0x05, 0x0bc0 }, { 0x06, 0x0ae6 }, { 0x07, 0x082a }, { 0x08, 0x001f }, { 0x09, 0x0334 }, { 0x0a, 0x0fd4 }, { 0x0b, 0x0391 }, - { 0x0c, 0x0050 }, { 0x0d, 0x06db }, { 0x0e, 0x0029 }, { 0x0f, 0x0914 }, + { 0x0c, 0x0050 }, { 0x0d, 0x06db }, { 0x0e, 0x0029 }, { 0x0f, 0x0914 } }; static struct urtw_pair urtw_8225_rf_part2[] = { @@ -279,7 +306,7 @@ static uint16_t urtw_8225_rxgain[] = { }; static uint8_t urtw_8225_threshold[] = { - 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd, + 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd }; static uint8_t urtw_8225_tx_gain_cck_ofdm[] = { @@ -304,10 +331,29 @@ static uint8_t urtw_8225_txpwr_cck_ch14[ 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00 }; -static uint8_t urtw_8225_txpwr_ofdm[]={ +static uint8_t urtw_8225_txpwr_ofdm[] = { 0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4 }; +static uint8_t urtw_8225z2_agc[] = { + 0x5e, 0x5e, 0x5e, 0x5e, 0x5d, 0x5b, 0x59, 0x57, + 0x55, 0x53, 0x51, 0x4f, 0x4d, 0x4b, 0x49, 0x47, + 0x45, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x39, 0x37, + 0x35, 0x33, 0x31, 0x2f, 0x2d, 0x2b, 0x29, 0x27, + 0x25, 0x23, 0x21, 0x1f, 0x1d, 0x1b, 0x19, 0x17, + 0x15, 0x13, 0x11, 0x0f, 0x0d, 0x0b, 0x09, 0x07, + 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, + 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2a, + 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, + 0x2f, 0x2f, 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 +}; + static uint8_t urtw_8225v2_gain_bg[]={ 0x23, 0x15, 0xa5, /* -82-1dbm */ 0x23, 0x15, 0xb5, /* -82-2dbm */ @@ -410,11 +456,7 @@ static uint8_t urtw_8225v2_tx_gain_cck_o 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, - 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, -}; - -static uint8_t urtw_8225v2_txpwr_cck[] = { - 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 + 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23 }; static uint8_t urtw_8225v2_txpwr_cck_ch14[] = { @@ -428,6 +470,10 @@ static uint8_t urtw_8225v2b_txpwr_cck[] 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03 }; +static uint8_t urtw_8225v2_txpwr_cck[] = { + 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 +}; + static uint8_t urtw_8225v2b_txpwr_cck_ch14[] = { 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x30, 0x2f, 0x29, 0x15, 0x00, 0x00, 0x00, 0x00, @@ -441,40 +487,6 @@ static struct urtw_pair urtw_ratetable[] { 96, 10 }, { 108, 11 } }; -static const uint8_t urtw_8187b_reg_table[][3] = { - { 0xf0, 0x32, 0 }, { 0xf1, 0x32, 0 }, { 0xf2, 0x00, 0 }, - { 0xf3, 0x00, 0 }, { 0xf4, 0x32, 0 }, { 0xf5, 0x43, 0 }, - { 0xf6, 0x00, 0 }, { 0xf7, 0x00, 0 }, { 0xf8, 0x46, 0 }, - { 0xf9, 0xa4, 0 }, { 0xfa, 0x00, 0 }, { 0xfb, 0x00, 0 }, - { 0xfc, 0x96, 0 }, { 0xfd, 0xa4, 0 }, { 0xfe, 0x00, 0 }, - { 0xff, 0x00, 0 }, { 0x58, 0x4b, 1 }, { 0x59, 0x00, 1 }, - { 0x5a, 0x4b, 1 }, { 0x5b, 0x00, 1 }, { 0x60, 0x4b, 1 }, - { 0x61, 0x09, 1 }, { 0x62, 0x4b, 1 }, { 0x63, 0x09, 1 }, - { 0xce, 0x0f, 1 }, { 0xcf, 0x00, 1 }, { 0xe0, 0xff, 1 }, - { 0xe1, 0x0f, 1 }, { 0xe2, 0x00, 1 }, { 0xf0, 0x4e, 1 }, - { 0xf1, 0x01, 1 }, { 0xf2, 0x02, 1 }, { 0xf3, 0x03, 1 }, - { 0xf4, 0x04, 1 }, { 0xf5, 0x05, 1 }, { 0xf6, 0x06, 1 }, - { 0xf7, 0x07, 1 }, { 0xf8, 0x08, 1 }, { 0x4e, 0x00, 2 }, - { 0x0c, 0x04, 2 }, { 0x21, 0x61, 2 }, { 0x22, 0x68, 2 }, - { 0x23, 0x6f, 2 }, { 0x24, 0x76, 2 }, { 0x25, 0x7d, 2 }, - { 0x26, 0x84, 2 }, { 0x27, 0x8d, 2 }, { 0x4d, 0x08, 2 }, - { 0x50, 0x05, 2 }, { 0x51, 0xf5, 2 }, { 0x52, 0x04, 2 }, - { 0x53, 0xa0, 2 }, { 0x54, 0x1f, 2 }, { 0x55, 0x23, 2 }, - { 0x56, 0x45, 2 }, { 0x57, 0x67, 2 }, { 0x58, 0x08, 2 }, - { 0x59, 0x08, 2 }, { 0x5a, 0x08, 2 }, { 0x5b, 0x08, 2 }, - { 0x60, 0x08, 2 }, { 0x61, 0x08, 2 }, { 0x62, 0x08, 2 }, - { 0x63, 0x08, 2 }, { 0x64, 0xcf, 2 }, { 0x72, 0x56, 2 }, - { 0x73, 0x9a, 2 }, { 0x34, 0xf0, 0 }, { 0x35, 0x0f, 0 }, - { 0x5b, 0x40, 0 }, { 0x84, 0x88, 0 }, { 0x85, 0x24, 0 }, - { 0x88, 0x54, 0 }, { 0x8b, 0xb8, 0 }, { 0x8c, 0x07, 0 }, - { 0x8d, 0x00, 0 }, { 0x94, 0x1b, 0 }, { 0x95, 0x12, 0 }, - { 0x96, 0x00, 0 }, { 0x97, 0x06, 0 }, { 0x9d, 0x1a, 0 }, - { 0x9f, 0x10, 0 }, { 0xb4, 0x22, 0 }, { 0xbe, 0x80, 0 }, - { 0xdb, 0x00, 0 }, { 0xee, 0x00, 0 }, { 0x91, 0x03, 0 }, - { 0x4c, 0x00, 2 }, { 0x9f, 0x00, 3 }, { 0x8c, 0x01, 0 }, - { 0x8d, 0x10, 0 }, { 0x8e, 0x08, 0 }, { 0x8f, 0x00, 0 } -}; - static usb_callback_t urtw_bulk_rx_callback; static usb_callback_t urtw_bulk_tx_callback; @@ -1034,7 +1046,6 @@ urtw_init(void *arg) static usb_error_t urtw_adapter_start_b(struct urtw_softc *sc) { -#define N(a) (sizeof(a) / sizeof((a)[0])) int i; uint8_t data8; usb_error_t error; @@ -1098,7 +1109,7 @@ urtw_adapter_start_b(struct urtw_softc * goto fail; urtw_write8_m(sc, URTW_WPA_CONFIG, 0); - for (i = 0; i < N(urtw_8187b_reg_table); i++) { + for (i = 0; i < nitems(urtw_8187b_reg_table); i++) { error = urtw_write8_i(sc, urtw_8187b_reg_table[i][0], urtw_8187b_reg_table[i][1], urtw_8187b_reg_table[i][2]); if (error) @@ -1208,7 +1219,6 @@ urtw_adapter_start_b(struct urtw_softc * fail: return (error); -#undef N } static usb_error_t @@ -1273,19 +1283,6 @@ fail: return (error); } -static usb_error_t -urtw_set_mode(struct urtw_softc *sc, uint32_t mode) -{ - uint8_t data; - usb_error_t error; - - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - data = (data & ~URTW_EPROM_CMD_MASK) | (mode << URTW_EPROM_CMD_SHIFT); - data = data & ~(URTW_EPROM_CS | URTW_EPROM_CK); - urtw_write8_m(sc, URTW_EPROM_CMD, data); -fail: - return (error); -} static usb_error_t urtw_8187b_cmd_reset(struct urtw_softc *sc) @@ -1395,56 +1392,6 @@ urtw_write32_i(struct urtw_softc *sc, in } static void -urtw_stop_locked(struct ifnet *ifp, int disable) -{ - struct urtw_softc *sc = ifp->if_softc; - uint8_t data8; - usb_error_t error; - - (void)disable; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - - error = urtw_intr_disable(sc); - if (error) - goto fail; - urtw_read8_m(sc, URTW_CMD, &data8); - data8 &= ~(URTW_CMD_RX_ENABLE | URTW_CMD_TX_ENABLE); - urtw_write8_m(sc, URTW_CMD, data8); - - error = sc->sc_rf_stop(sc); - if (error != 0) - goto fail; - - error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG); - if (error) - goto fail; - urtw_read8_m(sc, URTW_CONFIG4, &data8); - urtw_write8_m(sc, URTW_CONFIG4, data8 | URTW_CONFIG4_VCOOFF); - error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); - if (error) - goto fail; -fail: - if (error) - device_printf(sc->sc_dev, "failed to stop (%s)\n", - usbd_errstr(error)); - - usb_callout_stop(&sc->sc_led_ch); - callout_stop(&sc->sc_watchdog_ch); - - urtw_abort_xfers(sc); -} - -static void -urtw_stop(struct ifnet *ifp, int disable) -{ - struct urtw_softc *sc = ifp->if_softc; - - URTW_LOCK(sc); - urtw_stop_locked(ifp, disable); - URTW_UNLOCK(sc); -} - -static void urtw_abort_xfers(struct urtw_softc *sc) { int i, max; @@ -1949,105 +1896,198 @@ urtw_set_multi(void *arg) ifp->if_flags |= IFF_ALLMULTI; } + static usb_error_t -urtw_set_rate(struct urtw_softc *sc) +urtw_get_macaddr(struct urtw_softc *sc) { - int i, basic_rate, min_rr_rate, max_rr_rate; - uint16_t data; + uint32_t data; usb_error_t error; - basic_rate = urtw_rate2rtl(48); - min_rr_rate = urtw_rate2rtl(12); - max_rr_rate = urtw_rate2rtl(48); - - urtw_write8_m(sc, URTW_RESP_RATE, - max_rr_rate << URTW_RESP_MAX_RATE_SHIFT | - min_rr_rate << URTW_RESP_MIN_RATE_SHIFT); - - urtw_read16_m(sc, URTW_BRSR, &data); - data &= ~URTW_BRSR_MBR_8185; - - for (i = 0; i <= basic_rate; i++) - data |= (1 << i); - - urtw_write16_m(sc, URTW_BRSR, data); + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR, &data); + if (error != 0) + goto fail; + sc->sc_bssid[0] = data & 0xff; + sc->sc_bssid[1] = (data & 0xff00) >> 8; + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 1, &data); + if (error != 0) + goto fail; + sc->sc_bssid[2] = data & 0xff; + sc->sc_bssid[3] = (data & 0xff00) >> 8; + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 2, &data); + if (error != 0) + goto fail; + sc->sc_bssid[4] = data & 0xff; + sc->sc_bssid[5] = (data & 0xff00) >> 8; fail: return (error); } -static uint16_t -urtw_rate2rtl(int rate) +static usb_error_t +urtw_eprom_read32(struct urtw_softc *sc, uint32_t addr, uint32_t *data) { -#define N(a) (sizeof(a) / sizeof((a)[0])) - int i; +#define URTW_READCMD_LEN 3 + int addrlen, i; + int16_t addrstr[8], data16, readcmd[] = { 1, 1, 0 }; + usb_error_t error; - for (i = 0; i < N(urtw_ratetable); i++) { - if (rate == urtw_ratetable[i].reg) - return urtw_ratetable[i].val; + /* NB: make sure the buffer is initialized */ + *data = 0; + + /* enable EPROM programming */ + urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_PROGRAM_MODE); + DELAY(URTW_EPROM_DELAY); + + error = urtw_eprom_cs(sc, URTW_EPROM_ENABLE); + if (error != 0) + goto fail; + error = urtw_eprom_ck(sc); + if (error != 0) + goto fail; + error = urtw_eprom_sendbits(sc, readcmd, URTW_READCMD_LEN); + if (error != 0) + goto fail; + if (sc->sc_epromtype == URTW_EEPROM_93C56) { + addrlen = 8; + addrstr[0] = addr & (1 << 7); + addrstr[1] = addr & (1 << 6); + addrstr[2] = addr & (1 << 5); + addrstr[3] = addr & (1 << 4); + addrstr[4] = addr & (1 << 3); + addrstr[5] = addr & (1 << 2); + addrstr[6] = addr & (1 << 1); + addrstr[7] = addr & (1 << 0); + } else { + addrlen=6; + addrstr[0] = addr & (1 << 5); + addrstr[1] = addr & (1 << 4); + addrstr[2] = addr & (1 << 3); + addrstr[3] = addr & (1 << 2); + addrstr[4] = addr & (1 << 1); + addrstr[5] = addr & (1 << 0); } + error = urtw_eprom_sendbits(sc, addrstr, addrlen); + if (error != 0) + goto fail; - return (3); -#undef N -} + error = urtw_eprom_writebit(sc, 0); + if (error != 0) + goto fail; -static uint16_t -urtw_rtl2rate(int rate) -{ -#define N(a) (sizeof(a) / sizeof((a)[0])) - int i; + for (i = 0; i < 16; i++) { + error = urtw_eprom_ck(sc); + if (error != 0) + goto fail; + error = urtw_eprom_readbit(sc, &data16); + if (error != 0) + goto fail; - for (i = 0; i < N(urtw_ratetable); i++) { - if (rate == urtw_ratetable[i].val) - return urtw_ratetable[i].reg; + (*data) |= (data16 << (15 - i)); } - return (0); -#undef N + error = urtw_eprom_cs(sc, URTW_EPROM_DISABLE); + if (error != 0) + goto fail; + error = urtw_eprom_ck(sc); + if (error != 0) + goto fail; + + /* now disable EPROM programming */ + urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_NORMAL_MODE); +fail: + return (error); +#undef URTW_READCMD_LEN } static usb_error_t -urtw_update_msr(struct urtw_softc *sc) +urtw_eprom_readbit(struct urtw_softc *sc, int16_t *data) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; - uint8_t data; + uint8_t data8; usb_error_t error; - urtw_read8_m(sc, URTW_MSR, &data); - data &= ~URTW_MSR_LINK_MASK; - - if (sc->sc_state == IEEE80211_S_RUN) { - switch (ic->ic_opmode) { - case IEEE80211_M_STA: - case IEEE80211_M_MONITOR: - data |= URTW_MSR_LINK_STA; - if (sc->sc_flags & URTW_RTL8187B) - data |= URTW_MSR_LINK_ENEDCA; - break; - case IEEE80211_M_IBSS: - data |= URTW_MSR_LINK_ADHOC; - break; - case IEEE80211_M_HOSTAP: - data |= URTW_MSR_LINK_HOSTAP; - break; - default: - panic("unsupported operation mode 0x%x\n", - ic->ic_opmode); - /* never reach */ - } - } else - data |= URTW_MSR_LINK_NONE; + urtw_read8_m(sc, URTW_EPROM_CMD, &data8); + *data = (data8 & URTW_EPROM_READBIT) ? 1 : 0; + DELAY(URTW_EPROM_DELAY); - urtw_write8_m(sc, URTW_MSR, data); fail: return (error); } static usb_error_t -urtw_read8_c(struct urtw_softc *sc, int val, uint8_t *data) +urtw_eprom_sendbits(struct urtw_softc *sc, int16_t *buf, int buflen) { - struct usb_device_request req; - usb_error_t error; + int i = 0; + usb_error_t error = 0; + + for (i = 0; i < buflen; i++) { + error = urtw_eprom_writebit(sc, buf[i]); + if (error != 0) + goto fail; + error = urtw_eprom_ck(sc); + if (error != 0) + goto fail; + } +fail: + return (error); +} + +static usb_error_t +urtw_eprom_writebit(struct urtw_softc *sc, int16_t bit) +{ + uint8_t data; + usb_error_t error; + + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + if (bit != 0) + urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_WRITEBIT); + else + urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_WRITEBIT); + DELAY(URTW_EPROM_DELAY); +fail: + return (error); +} + +static usb_error_t +urtw_eprom_ck(struct urtw_softc *sc) +{ + uint8_t data; + usb_error_t error; + + /* masking */ + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_CK); + DELAY(URTW_EPROM_DELAY); + /* unmasking */ + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_CK); + DELAY(URTW_EPROM_DELAY); +fail: + return (error); +} + + +static usb_error_t +urtw_eprom_cs(struct urtw_softc *sc, int able) +{ + uint8_t data; + usb_error_t error; + + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + if (able == URTW_EPROM_ENABLE) + urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_CS); + else + urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_CS); + DELAY(URTW_EPROM_DELAY); +fail: + return (error); +} + + + +static usb_error_t +urtw_read8_c(struct urtw_softc *sc, int val, uint8_t *data) +{ + struct usb_device_request req; + usb_error_t error; URTW_ASSERT_LOCKED(sc); @@ -2062,6 +2102,22 @@ urtw_read8_c(struct urtw_softc *sc, int } static usb_error_t +urtw_read8e(struct urtw_softc *sc, int val, uint8_t *data) +{ + struct usb_device_request req; + usb_error_t error; + + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = URTW_8187_GETREGS_REQ; + USETW(req.wValue, val | 0xfe00); + USETW(req.wIndex, 0); + USETW(req.wLength, sizeof(uint8_t)); + + error = urtw_do_request(sc, &req, data); + return (error); +} + +static usb_error_t urtw_read16_c(struct urtw_softc *sc, int val, uint16_t *data) { struct usb_device_request req; @@ -2114,6 +2170,20 @@ urtw_write8_c(struct urtw_softc *sc, int } static usb_error_t +urtw_write8e(struct urtw_softc *sc, int val, uint8_t data) +{ + struct usb_device_request req; + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = URTW_8187_SETREGS_REQ; + USETW(req.wValue, val | 0xfe00); + USETW(req.wIndex, 0); + USETW(req.wLength, sizeof(uint8_t)); + + return (urtw_do_request(sc, &req, &data)); +} + +static usb_error_t urtw_write16_c(struct urtw_softc *sc, int val, uint16_t data) { struct usb_device_request req; @@ -2146,308 +2216,180 @@ urtw_write32_c(struct urtw_softc *sc, in } static usb_error_t -urtw_get_macaddr(struct urtw_softc *sc) +urtw_set_mode(struct urtw_softc *sc, uint32_t mode) { - uint32_t data; + uint8_t data; usb_error_t error; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR, &data); - if (error != 0) - goto fail; - sc->sc_bssid[0] = data & 0xff; - sc->sc_bssid[1] = (data & 0xff00) >> 8; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 1, &data); - if (error != 0) - goto fail; - sc->sc_bssid[2] = data & 0xff; - sc->sc_bssid[3] = (data & 0xff00) >> 8; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 2, &data); - if (error != 0) - goto fail; - sc->sc_bssid[4] = data & 0xff; - sc->sc_bssid[5] = (data & 0xff00) >> 8; + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + data = (data & ~URTW_EPROM_CMD_MASK) | (mode << URTW_EPROM_CMD_SHIFT); + data = data & ~(URTW_EPROM_CS | URTW_EPROM_CK); + urtw_write8_m(sc, URTW_EPROM_CMD, data); fail: return (error); } static usb_error_t -urtw_eprom_read32(struct urtw_softc *sc, uint32_t addr, uint32_t *data) +urtw_8180_set_anaparam(struct urtw_softc *sc, uint32_t val) { -#define URTW_READCMD_LEN 3 - int addrlen, i; - int16_t addrstr[8], data16, readcmd[] = { 1, 1, 0 }; + uint8_t data; usb_error_t error; - /* NB: make sure the buffer is initialized */ - *data = 0; - - /* enable EPROM programming */ - urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_PROGRAM_MODE); - DELAY(URTW_EPROM_DELAY); - - error = urtw_eprom_cs(sc, URTW_EPROM_ENABLE); - if (error != 0) - goto fail; - error = urtw_eprom_ck(sc); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From phk at FreeBSD.org Tue Sep 8 13:19:05 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 13:19:19 2009 Subject: svn commit: r196970 - in head/sys: cam/scsi contrib/dev/acpica/executer dev/aac dev/ae dev/amr dev/ata dev/ata/chipsets dev/ath dev/ath/ath_hal dev/bce dev/e1000 dev/ep dev/firewire dev/fxp dev/hpt... Message-ID: <200909081319.n88DJ5ne048573@svn.freebsd.org> Author: phk Date: Tue Sep 8 13:19:05 2009 New Revision: 196970 URL: http://svn.freebsd.org/changeset/base/196970 Log: Revert previous commit and add myself to the list of people who should know better than to commit with a cat in the area. Modified: head/sys/cam/scsi/scsi_cd.c head/sys/contrib/dev/acpica/executer/exfldio.c head/sys/dev/aac/aac.c head/sys/dev/ae/if_ae.c head/sys/dev/amr/amr.c head/sys/dev/ata/ata-raid.c head/sys/dev/ata/chipsets/ata-acerlabs.c head/sys/dev/ata/chipsets/ata-marvell.c head/sys/dev/ath/ah_osdep.c head/sys/dev/ath/ath_hal/ah.c head/sys/dev/ath/ath_hal/ah_eeprom_v3.c head/sys/dev/bce/if_bce.c head/sys/dev/e1000/if_em.c head/sys/dev/ep/if_ep.c head/sys/dev/ep/if_epreg.h head/sys/dev/firewire/fwcrom.c head/sys/dev/firewire/fwdev.c head/sys/dev/fxp/if_fxp.c head/sys/dev/hptiop/hptiop.c head/sys/dev/iir/iir.c head/sys/dev/mpt/mpt_raid.c head/sys/dev/msk/if_msk.c head/sys/dev/usb/wlan/if_rum.c head/sys/dev/usb/wlan/if_rumreg.h head/sys/dev/usb/wlan/if_urtw.c head/sys/dev/wi/if_wi.c head/sys/fs/msdosfs/msdosfs_conv.c head/sys/kern/kern_jail.c head/sys/kern/kern_linker.c head/sys/kern/kern_lock.c head/sys/kern/kern_mutex.c head/sys/net80211/ieee80211_action.c head/sys/net80211/ieee80211_proto.h head/sys/security/audit/audit_bsm_token.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/cam/scsi/scsi_cd.c Tue Sep 8 13:19:05 2009 (r196970) @@ -2528,7 +2528,7 @@ cdioctl(struct disk *dp, u_long cmd, voi error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(¶ms.mode_buf, M_SCSICD); + free(¶ms, M_SCSICD); cam_periph_unlock(periph); break; } Modified: head/sys/contrib/dev/acpica/executer/exfldio.c ============================================================================== --- head/sys/contrib/dev/acpica/executer/exfldio.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/contrib/dev/acpica/executer/exfldio.c Tue Sep 8 13:19:05 2009 (r196970) @@ -992,7 +992,6 @@ AcpiExInsertIntoField ( /* Get initial Datum from the input buffer */ - /* XXX: Flexelint sees arg 9 for bufferlen 8 */ ACPI_MEMCPY (&RawDatum, Buffer, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, BufferLength - BufferOffset)); Modified: head/sys/dev/aac/aac.c ============================================================================== --- head/sys/dev/aac/aac.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/aac/aac.c Tue Sep 8 13:19:05 2009 (r196970) @@ -3556,7 +3556,7 @@ aac_supported_features(struct aac_softc * associated with the feature in the data field or perform whatever * action needed indicates in the data field. */ - if (f.feat.fValue == 0) { + if (f.feat.fValue == 0) { f.feat.fBits.largeLBA = (sc->flags & AAC_FLAGS_LBA_64BIT) ? 1 : 0; /* TODO: In the future, add other features state here as well */ Modified: head/sys/dev/ae/if_ae.c ============================================================================== --- head/sys/dev/ae/if_ae.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ae/if_ae.c Tue Sep 8 13:19:05 2009 (r196970) @@ -1662,7 +1662,6 @@ ae_stop_rxmac(ae_softc_t *sc) /* * Wait for IDLE state. */ - /* XXX: Flexelint "<" test with -- */ for (i = 0; i < AE_IDLE_TIMEOUT; i--) { val = AE_READ_4(sc, AE_IDLE_REG); if ((val & (AE_IDLE_RXMAC | AE_IDLE_DMAWRITE)) == 0) @@ -1699,7 +1698,6 @@ ae_stop_txmac(ae_softc_t *sc) /* * Wait for IDLE state. */ - /* XXX: Flexelint "<" test with -- */ for (i = 0; i < AE_IDLE_TIMEOUT; i--) { val = AE_READ_4(sc, AE_IDLE_REG); if ((val & (AE_IDLE_TXMAC | AE_IDLE_DMAREAD)) == 0) Modified: head/sys/dev/amr/amr.c ============================================================================== --- head/sys/dev/amr/amr.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/amr/amr.c Tue Sep 8 13:19:05 2009 (r196970) @@ -527,7 +527,7 @@ amr_rescan_drives(struct cdev *dev) sc->amr_drive[i].al_disk)) != 0) goto shutdown_out; - sc->amr_drive[i].al_disk = 0; + sc->amr_drive[i].al_disk = 0; } } Modified: head/sys/dev/ata/ata-raid.c ============================================================================== --- head/sys/dev/ata/ata-raid.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ata/ata-raid.c Tue Sep 8 13:19:05 2009 (r196970) @@ -407,7 +407,7 @@ ata_raid_strategy(struct bio *bp) if (rdp->status & AR_S_REBUILDING) blk = ((lba / rdp->interleave) * rdp->width) * rdp->interleave + (rdp->interleave * (drv % rdp->width)) + - lba % rdp->interleave; + lba % rdp->interleave;; if (bp->bio_cmd == BIO_READ) { int src_online = @@ -1138,7 +1138,6 @@ ata_raid_create(struct ata_ioc_raid_conf rdp->type == AR_T_RAID5) { int bit = 0; - /* XXX: Flexelint not happy */ while (config->interleave >>= 1) bit++; rdp->interleave = 1 << bit; Modified: head/sys/dev/ata/chipsets/ata-acerlabs.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-acerlabs.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ata/chipsets/ata-acerlabs.c Tue Sep 8 13:19:05 2009 (r196970) @@ -127,7 +127,6 @@ ata_ali_chipinit(device_t dev) RF_ACTIVE); if (res->bars[i] == NULL) { device_printf(dev, "Failed to allocate BAR %d\n", i); - /* XXX: Flexelint: Reuse of for loop variable 'i' at 'line 124' could cause chaos */ for (i--; i >=0; i--) bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(i), res->bars[i]); Modified: head/sys/dev/ata/chipsets/ata-marvell.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-marvell.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ata/chipsets/ata-marvell.c Tue Sep 8 13:19:05 2009 (r196970) @@ -153,7 +153,7 @@ ata_marvell_pata_ch_attach(device_t dev) return ENXIO; /* dont use 32 bit PIO transfers */ - ch->flags |= ATA_USE_16BIT; + ch->flags |= ATA_USE_16BIT; return 0; } Modified: head/sys/dev/ath/ah_osdep.c ============================================================================== --- head/sys/dev/ath/ah_osdep.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ath/ah_osdep.c Tue Sep 8 13:19:05 2009 (r196970) @@ -107,7 +107,6 @@ ath_hal_malloc(size_t size) return malloc(size, M_ATH_HAL, M_NOWAIT | M_ZERO); } -/* XXX: FlexeLint return in void function ? */ void ath_hal_free(void* p) { Modified: head/sys/dev/ath/ath_hal/ah.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ath/ath_hal/ah.c Tue Sep 8 13:19:05 2009 (r196970) @@ -566,7 +566,6 @@ ath_hal_getregdump(struct ath_hal *ah, c uint32_t *dp = dstbuf; int i; - /* XXX: FlexeLint: ">" test with ++ */ for (i = 0; space >= 2*sizeof(uint32_t); i++) { u_int r = regs[i].start; u_int e = regs[i].end; Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v3.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ath/ath_hal/ah_eeprom_v3.c Tue Sep 8 13:19:05 2009 (r196970) @@ -1753,8 +1753,6 @@ legacyEepromGetSpurChan(struct ath_hal * /* * Reclaim any EEPROM-related storage. */ - -/* XXX: FlexeLint: return in void function */ static void legacyEepromDetach(struct ath_hal *ah) { Modified: head/sys/dev/bce/if_bce.c ============================================================================== --- head/sys/dev/bce/if_bce.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/bce/if_bce.c Tue Sep 8 13:19:05 2009 (r196970) @@ -608,17 +608,17 @@ bce_print_adapter_info(struct bce_softc #endif if (sc->bce_flags & BCE_USING_MSI_FLAG) { if (i > 0) printf("|"); - printf("MSI"); i++; + printf("MSI"); i++; } if (sc->bce_flags & BCE_USING_MSIX_FLAG) { if (i > 0) printf("|"); - printf("MSI-X "); i++; + printf("MSI-X "); i++; } if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) { if (i > 0) printf("|"); - printf("2.5G"); i++; + printf("2.5G"); i++; } if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) { @@ -628,7 +628,7 @@ bce_print_adapter_info(struct bce_softc printf(")\n"); } - DBEXIT(BCE_VERBOSE_LOAD); + DBEXIT(BCE_VERBOSE_LOAD); } Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/e1000/if_em.c Tue Sep 8 13:19:05 2009 (r196970) @@ -2826,7 +2826,7 @@ em_allocate_pci_resources(struct adapter * Setup the Legacy or MSI Interrupt handler * **********************************************************************/ -static int +int em_allocate_legacy(struct adapter *adapter) { device_t dev = adapter->dev; Modified: head/sys/dev/ep/if_ep.c ============================================================================== --- head/sys/dev/ep/if_ep.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ep/if_ep.c Tue Sep 8 13:19:05 2009 (r196970) @@ -666,7 +666,6 @@ rescan: sc->tx_underrun++; #endif } else { - /* XXX: FlexeLint doesn't like ; */ if (status & TXS_JABBER); else ++ifp->if_collisions; Modified: head/sys/dev/ep/if_epreg.h ============================================================================== --- head/sys/dev/ep/if_epreg.h Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/ep/if_epreg.h Tue Sep 8 13:19:05 2009 (r196970) @@ -315,11 +315,7 @@ S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY) #define S_COMMAND_IN_PROGRESS (u_short) (0x1000) -#define EP_BUSY_WAIT(sc) \ - do { \ - while (CSR_READ_2(sc, EP_STATUS) & S_COMMAND_IN_PROGRESS) \ - continue; \ - } while (0) +#define EP_BUSY_WAIT(sc) while (CSR_READ_2(sc, EP_STATUS) & S_COMMAND_IN_PROGRESS) /* Address Config. Register. * Window 0/Port 06 Modified: head/sys/dev/firewire/fwcrom.c ============================================================================== --- head/sys/dev/firewire/fwcrom.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/firewire/fwcrom.c Tue Sep 8 13:19:05 2009 (r196970) @@ -454,9 +454,9 @@ crom_add_simple_text(struct crom_src *sr len = strlen(buf); if (len > MAX_TEXT) { #if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("text(%d) truncated to %d.\n", len, MAX_TEXT); + printf("text(%d) trancated to %d.\n", len, MAX_TEXT); #else - printf("text(%d) truncated to %td.\n", len, MAX_TEXT); + printf("text(%d) trancated to %td.\n", len, MAX_TEXT); #endif len = MAX_TEXT; } Modified: head/sys/dev/firewire/fwdev.c ============================================================================== --- head/sys/dev/firewire/fwdev.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/firewire/fwdev.c Tue Sep 8 13:19:05 2009 (r196970) @@ -844,7 +844,6 @@ out: err = copyout(ptr, crom_buf->ptr, len); if (fwdev == NULL) /* myself */ - /* XXX: Flexelint no sure about modified pointer */ free(ptr, M_FW); break; default: Modified: head/sys/dev/fxp/if_fxp.c ============================================================================== --- head/sys/dev/fxp/if_fxp.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/fxp/if_fxp.c Tue Sep 8 13:19:05 2009 (r196970) @@ -1597,7 +1597,6 @@ fxp_encap(struct fxp_softc *sc, struct m cbp->tbd_number = nseg; /* Configure TSO. */ if (m->m_pkthdr.csum_flags & CSUM_TSO) { - /* XXX: FlexeLint: negative subscript */ cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16); cbp->tbd[1].tb_size |= htole32(tcp_payload << 16); cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | Modified: head/sys/dev/hptiop/hptiop.c ============================================================================== --- head/sys/dev/hptiop/hptiop.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/hptiop/hptiop.c Tue Sep 8 13:19:05 2009 (r196970) @@ -432,7 +432,6 @@ srb_complete: sg_list), (u_int8_t *)&ccb->csio.sense_data, MIN(dxfer, sizeof(ccb->csio.sense_data))); } else { - /* XXX: Flexelint arg2 is 16 bytes, arg3 is 32 */ memcpy(&ccb->csio.sense_data, &req->sg_list, MIN(dxfer, sizeof(ccb->csio.sense_data))); } @@ -576,7 +575,6 @@ static void hptiop_request_callback_mv(s ccb->ccb_h.status = CAM_BUSY; break; case IOP_RESULT_CHECK_CONDITION: - /* XXX: FlexeLint: arg2=16b arg3=32 */ memcpy(&ccb->csio.sense_data, &req->sg_list, MIN(req->dataxfer_length, sizeof(ccb->csio.sense_data))); ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; Modified: head/sys/dev/iir/iir.c ============================================================================== --- head/sys/dev/iir/iir.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/iir/iir.c Tue Sep 8 13:19:05 2009 (r196970) @@ -1203,7 +1203,6 @@ gdt_internal_cache_cmd(struct gdt_softc bzero( ccb->csio.data_ptr+copylen, ccb->csio.dxfer_len - copylen ); page=((struct scsi_mode_sense_6 *)ccb->csio.cdb_io.cdb_bytes)->page; - /* XXX: FlexeLint: why ?? */ switch (page) { default: GDT_DPRINTF(GDT_D_MISC, ("MODE_SENSE_6: page 0x%x\n", page)); Modified: head/sys/dev/mpt/mpt_raid.c ============================================================================== --- head/sys/dev/mpt/mpt_raid.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/mpt/mpt_raid.c Tue Sep 8 13:19:05 2009 (r196970) @@ -562,7 +562,6 @@ mpt_raid_reply_frame_handler(struct mpt_ break; } action_result = REQ_TO_RAID_ACTION_RESULT(req); - /* XXX: FlexeLint: ActionData is only 4 bytes */ memcpy(&action_result->action_data, &reply->ActionData, sizeof(action_result->action_data)); action_result->action_status = le16toh(reply->ActionStatus); Modified: head/sys/dev/msk/if_msk.c ============================================================================== --- head/sys/dev/msk/if_msk.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/msk/if_msk.c Tue Sep 8 13:19:05 2009 (r196970) @@ -118,21 +118,26 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include +#include #include #include +#include #include #include #include #include +#include #include +#include #include #include Modified: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/usb/wlan/if_rum.c Tue Sep 8 13:19:05 2009 (r196970) @@ -42,9 +42,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include +#include #include #include #include @@ -1486,7 +1489,7 @@ rum_rf_write(struct rum_softc *sc, uint8 return; } - tmp = RT2573_RF_BUSY | RT2573_RF_20BIT | ((val & 0xfffff) << 2) | + tmp = RT2573_RF_BUSY | RT2573_RF_20BIT | (val & 0xfffff) << 2 | (reg & 3); rum_write(sc, RT2573_PHY_CSR4, tmp); Modified: head/sys/dev/usb/wlan/if_rumreg.h ============================================================================== --- head/sys/dev/usb/wlan/if_rumreg.h Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/usb/wlan/if_rumreg.h Tue Sep 8 13:19:05 2009 (r196970) @@ -139,7 +139,7 @@ #define RT2573_BBP_BUSY (1 << 16) /* possible flags for register PHY_CSR4 */ #define RT2573_RF_20BIT (20 << 24) -#define RT2573_RF_BUSY (1U << 31) +#define RT2573_RF_BUSY (1 << 31) /* LED values */ #define RT2573_LED_RADIO (1 << 8) Modified: head/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- head/sys/dev/usb/wlan/if_urtw.c Tue Sep 8 13:16:55 2009 (r196969) +++ head/sys/dev/usb/wlan/if_urtw.c Tue Sep 8 13:19:05 2009 (r196970) @@ -61,8 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define nitems(a) (sizeof(a) / sizeof((a)[0])) - SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; @@ -177,46 +175,6 @@ struct urtw_pair { uint32_t val; }; -static const uint8_t urtw_8187b_reg_table[][3] = { - { 0xf0, 0x32, 0 }, { 0xf1, 0x32, 0 }, { 0xf2, 0x00, 0 }, - { 0xf3, 0x00, 0 }, { 0xf4, 0x32, 0 }, { 0xf5, 0x43, 0 }, - { 0xf6, 0x00, 0 }, { 0xf7, 0x00, 0 }, { 0xf8, 0x46, 0 }, - { 0xf9, 0xa4, 0 }, { 0xfa, 0x00, 0 }, { 0xfb, 0x00, 0 }, - { 0xfc, 0x96, 0 }, { 0xfd, 0xa4, 0 }, { 0xfe, 0x00, 0 }, - { 0xff, 0x00, 0 }, - - { 0x58, 0x4b, 1 }, { 0x59, 0x00, 1 }, { 0x5a, 0x4b, 1 }, - { 0x5b, 0x00, 1 }, { 0x60, 0x4b, 1 }, { 0x61, 0x09, 1 }, - { 0x62, 0x4b, 1 }, { 0x63, 0x09, 1 }, { 0xce, 0x0f, 1 }, - { 0xcf, 0x00, 1 }, { 0xe0, 0xff, 1 }, { 0xe1, 0x0f, 1 }, - { 0xe2, 0x00, 1 }, { 0xf0, 0x4e, 1 }, { 0xf1, 0x01, 1 }, - { 0xf2, 0x02, 1 }, { 0xf3, 0x03, 1 }, { 0xf4, 0x04, 1 }, - { 0xf5, 0x05, 1 }, { 0xf6, 0x06, 1 }, { 0xf7, 0x07, 1 }, - { 0xf8, 0x08, 1 }, - - { 0x4e, 0x00, 2 }, { 0x0c, 0x04, 2 }, { 0x21, 0x61, 2 }, - { 0x22, 0x68, 2 }, { 0x23, 0x6f, 2 }, { 0x24, 0x76, 2 }, - { 0x25, 0x7d, 2 }, { 0x26, 0x84, 2 }, { 0x27, 0x8d, 2 }, - { 0x4d, 0x08, 2 }, { 0x50, 0x05, 2 }, { 0x51, 0xf5, 2 }, - { 0x52, 0x04, 2 }, { 0x53, 0xa0, 2 }, { 0x54, 0x1f, 2 }, - { 0x55, 0x23, 2 }, { 0x56, 0x45, 2 }, { 0x57, 0x67, 2 }, - { 0x58, 0x08, 2 }, { 0x59, 0x08, 2 }, { 0x5a, 0x08, 2 }, - { 0x5b, 0x08, 2 }, { 0x60, 0x08, 2 }, { 0x61, 0x08, 2 }, - { 0x62, 0x08, 2 }, { 0x63, 0x08, 2 }, { 0x64, 0xcf, 2 }, - { 0x72, 0x56, 2 }, { 0x73, 0x9a, 2 }, - - { 0x34, 0xf0, 0 }, { 0x35, 0x0f, 0 }, { 0x5b, 0x40, 0 }, - { 0x84, 0x88, 0 }, { 0x85, 0x24, 0 }, { 0x88, 0x54, 0 }, - { 0x8b, 0xb8, 0 }, { 0x8c, 0x07, 0 }, { 0x8d, 0x00, 0 }, - { 0x94, 0x1b, 0 }, { 0x95, 0x12, 0 }, { 0x96, 0x00, 0 }, - { 0x97, 0x06, 0 }, { 0x9d, 0x1a, 0 }, { 0x9f, 0x10, 0 }, - { 0xb4, 0x22, 0 }, { 0xbe, 0x80, 0 }, { 0xdb, 0x00, 0 }, - { 0xee, 0x00, 0 }, { 0x91, 0x03, 0 }, - - { 0x4c, 0x00, 2 }, { 0x9f, 0x00, 3 }, { 0x8c, 0x01, 0 }, - { 0x8d, 0x10, 0 }, { 0x8e, 0x08, 0 }, { 0x8f, 0x00, 0 } -}; - static uint8_t urtw_8225_agc[] = { 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, @@ -232,6 +190,21 @@ static uint8_t urtw_8225_agc[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; +static uint8_t urtw_8225z2_agc[] = { + 0x5e, 0x5e, 0x5e, 0x5e, 0x5d, 0x5b, 0x59, 0x57, 0x55, 0x53, 0x51, + 0x4f, 0x4d, 0x4b, 0x49, 0x47, 0x45, 0x43, 0x41, 0x3f, 0x3d, 0x3b, + 0x39, 0x37, 0x35, 0x33, 0x31, 0x2f, 0x2d, 0x2b, 0x29, 0x27, 0x25, + 0x23, 0x21, 0x1f, 0x1d, 0x1b, 0x19, 0x17, 0x15, 0x13, 0x11, 0x0f, + 0x0d, 0x0b, 0x09, 0x07, 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2a, + 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 +}; + static uint32_t urtw_8225_channel[] = { 0x0000, /* dummy channel 0 */ 0x085c, /* 1 */ @@ -264,7 +237,7 @@ static struct urtw_pair urtw_8225_rf_par { 0x00, 0x0067 }, { 0x01, 0x0fe0 }, { 0x02, 0x044d }, { 0x03, 0x0441 }, { 0x04, 0x0486 }, { 0x05, 0x0bc0 }, { 0x06, 0x0ae6 }, { 0x07, 0x082a }, { 0x08, 0x001f }, { 0x09, 0x0334 }, { 0x0a, 0x0fd4 }, { 0x0b, 0x0391 }, - { 0x0c, 0x0050 }, { 0x0d, 0x06db }, { 0x0e, 0x0029 }, { 0x0f, 0x0914 } + { 0x0c, 0x0050 }, { 0x0d, 0x06db }, { 0x0e, 0x0029 }, { 0x0f, 0x0914 }, }; static struct urtw_pair urtw_8225_rf_part2[] = { @@ -306,7 +279,7 @@ static uint16_t urtw_8225_rxgain[] = { }; static uint8_t urtw_8225_threshold[] = { - 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd + 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd, }; static uint8_t urtw_8225_tx_gain_cck_ofdm[] = { @@ -331,29 +304,10 @@ static uint8_t urtw_8225_txpwr_cck_ch14[ 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00 }; -static uint8_t urtw_8225_txpwr_ofdm[] = { +static uint8_t urtw_8225_txpwr_ofdm[]={ 0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4 }; -static uint8_t urtw_8225z2_agc[] = { - 0x5e, 0x5e, 0x5e, 0x5e, 0x5d, 0x5b, 0x59, 0x57, - 0x55, 0x53, 0x51, 0x4f, 0x4d, 0x4b, 0x49, 0x47, - 0x45, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x39, 0x37, - 0x35, 0x33, 0x31, 0x2f, 0x2d, 0x2b, 0x29, 0x27, - 0x25, 0x23, 0x21, 0x1f, 0x1d, 0x1b, 0x19, 0x17, - 0x15, 0x13, 0x11, 0x0f, 0x0d, 0x0b, 0x09, 0x07, - 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2a, - 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, - 0x2f, 0x2f, 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 -}; - static uint8_t urtw_8225v2_gain_bg[]={ 0x23, 0x15, 0xa5, /* -82-1dbm */ 0x23, 0x15, 0xb5, /* -82-2dbm */ @@ -456,7 +410,11 @@ static uint8_t urtw_8225v2_tx_gain_cck_o 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, - 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23 + 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, +}; + +static uint8_t urtw_8225v2_txpwr_cck[] = { + 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 }; static uint8_t urtw_8225v2_txpwr_cck_ch14[] = { @@ -470,10 +428,6 @@ static uint8_t urtw_8225v2b_txpwr_cck[] 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03 }; -static uint8_t urtw_8225v2_txpwr_cck[] = { - 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04 -}; - static uint8_t urtw_8225v2b_txpwr_cck_ch14[] = { 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x30, 0x2f, 0x29, 0x15, 0x00, 0x00, 0x00, 0x00, @@ -487,6 +441,40 @@ static struct urtw_pair urtw_ratetable[] { 96, 10 }, { 108, 11 } }; +static const uint8_t urtw_8187b_reg_table[][3] = { + { 0xf0, 0x32, 0 }, { 0xf1, 0x32, 0 }, { 0xf2, 0x00, 0 }, + { 0xf3, 0x00, 0 }, { 0xf4, 0x32, 0 }, { 0xf5, 0x43, 0 }, + { 0xf6, 0x00, 0 }, { 0xf7, 0x00, 0 }, { 0xf8, 0x46, 0 }, + { 0xf9, 0xa4, 0 }, { 0xfa, 0x00, 0 }, { 0xfb, 0x00, 0 }, + { 0xfc, 0x96, 0 }, { 0xfd, 0xa4, 0 }, { 0xfe, 0x00, 0 }, + { 0xff, 0x00, 0 }, { 0x58, 0x4b, 1 }, { 0x59, 0x00, 1 }, + { 0x5a, 0x4b, 1 }, { 0x5b, 0x00, 1 }, { 0x60, 0x4b, 1 }, + { 0x61, 0x09, 1 }, { 0x62, 0x4b, 1 }, { 0x63, 0x09, 1 }, + { 0xce, 0x0f, 1 }, { 0xcf, 0x00, 1 }, { 0xe0, 0xff, 1 }, + { 0xe1, 0x0f, 1 }, { 0xe2, 0x00, 1 }, { 0xf0, 0x4e, 1 }, + { 0xf1, 0x01, 1 }, { 0xf2, 0x02, 1 }, { 0xf3, 0x03, 1 }, + { 0xf4, 0x04, 1 }, { 0xf5, 0x05, 1 }, { 0xf6, 0x06, 1 }, + { 0xf7, 0x07, 1 }, { 0xf8, 0x08, 1 }, { 0x4e, 0x00, 2 }, + { 0x0c, 0x04, 2 }, { 0x21, 0x61, 2 }, { 0x22, 0x68, 2 }, + { 0x23, 0x6f, 2 }, { 0x24, 0x76, 2 }, { 0x25, 0x7d, 2 }, + { 0x26, 0x84, 2 }, { 0x27, 0x8d, 2 }, { 0x4d, 0x08, 2 }, + { 0x50, 0x05, 2 }, { 0x51, 0xf5, 2 }, { 0x52, 0x04, 2 }, + { 0x53, 0xa0, 2 }, { 0x54, 0x1f, 2 }, { 0x55, 0x23, 2 }, + { 0x56, 0x45, 2 }, { 0x57, 0x67, 2 }, { 0x58, 0x08, 2 }, + { 0x59, 0x08, 2 }, { 0x5a, 0x08, 2 }, { 0x5b, 0x08, 2 }, + { 0x60, 0x08, 2 }, { 0x61, 0x08, 2 }, { 0x62, 0x08, 2 }, + { 0x63, 0x08, 2 }, { 0x64, 0xcf, 2 }, { 0x72, 0x56, 2 }, + { 0x73, 0x9a, 2 }, { 0x34, 0xf0, 0 }, { 0x35, 0x0f, 0 }, + { 0x5b, 0x40, 0 }, { 0x84, 0x88, 0 }, { 0x85, 0x24, 0 }, + { 0x88, 0x54, 0 }, { 0x8b, 0xb8, 0 }, { 0x8c, 0x07, 0 }, + { 0x8d, 0x00, 0 }, { 0x94, 0x1b, 0 }, { 0x95, 0x12, 0 }, + { 0x96, 0x00, 0 }, { 0x97, 0x06, 0 }, { 0x9d, 0x1a, 0 }, + { 0x9f, 0x10, 0 }, { 0xb4, 0x22, 0 }, { 0xbe, 0x80, 0 }, + { 0xdb, 0x00, 0 }, { 0xee, 0x00, 0 }, { 0x91, 0x03, 0 }, + { 0x4c, 0x00, 2 }, { 0x9f, 0x00, 3 }, { 0x8c, 0x01, 0 }, + { 0x8d, 0x10, 0 }, { 0x8e, 0x08, 0 }, { 0x8f, 0x00, 0 } +}; + static usb_callback_t urtw_bulk_rx_callback; static usb_callback_t urtw_bulk_tx_callback; @@ -1046,6 +1034,7 @@ urtw_init(void *arg) static usb_error_t urtw_adapter_start_b(struct urtw_softc *sc) { +#define N(a) (sizeof(a) / sizeof((a)[0])) int i; uint8_t data8; usb_error_t error; @@ -1109,7 +1098,7 @@ urtw_adapter_start_b(struct urtw_softc * goto fail; urtw_write8_m(sc, URTW_WPA_CONFIG, 0); - for (i = 0; i < nitems(urtw_8187b_reg_table); i++) { + for (i = 0; i < N(urtw_8187b_reg_table); i++) { error = urtw_write8_i(sc, urtw_8187b_reg_table[i][0], urtw_8187b_reg_table[i][1], urtw_8187b_reg_table[i][2]); if (error) @@ -1219,6 +1208,7 @@ urtw_adapter_start_b(struct urtw_softc * fail: return (error); +#undef N } static usb_error_t @@ -1283,6 +1273,19 @@ fail: return (error); } +static usb_error_t +urtw_set_mode(struct urtw_softc *sc, uint32_t mode) +{ + uint8_t data; + usb_error_t error; + + urtw_read8_m(sc, URTW_EPROM_CMD, &data); + data = (data & ~URTW_EPROM_CMD_MASK) | (mode << URTW_EPROM_CMD_SHIFT); + data = data & ~(URTW_EPROM_CS | URTW_EPROM_CK); + urtw_write8_m(sc, URTW_EPROM_CMD, data); +fail: + return (error); +} static usb_error_t urtw_8187b_cmd_reset(struct urtw_softc *sc) @@ -1392,6 +1395,56 @@ urtw_write32_i(struct urtw_softc *sc, in } static void +urtw_stop_locked(struct ifnet *ifp, int disable) +{ + struct urtw_softc *sc = ifp->if_softc; + uint8_t data8; + usb_error_t error; + + (void)disable; + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + + error = urtw_intr_disable(sc); + if (error) + goto fail; + urtw_read8_m(sc, URTW_CMD, &data8); + data8 &= ~(URTW_CMD_RX_ENABLE | URTW_CMD_TX_ENABLE); + urtw_write8_m(sc, URTW_CMD, data8); + + error = sc->sc_rf_stop(sc); + if (error != 0) + goto fail; + + error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG); + if (error) + goto fail; + urtw_read8_m(sc, URTW_CONFIG4, &data8); + urtw_write8_m(sc, URTW_CONFIG4, data8 | URTW_CONFIG4_VCOOFF); + error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); + if (error) + goto fail; +fail: + if (error) + device_printf(sc->sc_dev, "failed to stop (%s)\n", + usbd_errstr(error)); + + usb_callout_stop(&sc->sc_led_ch); + callout_stop(&sc->sc_watchdog_ch); + + urtw_abort_xfers(sc); +} + +static void +urtw_stop(struct ifnet *ifp, int disable) +{ + struct urtw_softc *sc = ifp->if_softc; + + URTW_LOCK(sc); + urtw_stop_locked(ifp, disable); + URTW_UNLOCK(sc); +} + +static void urtw_abort_xfers(struct urtw_softc *sc) { int i, max; @@ -1896,198 +1949,105 @@ urtw_set_multi(void *arg) ifp->if_flags |= IFF_ALLMULTI; } - static usb_error_t -urtw_get_macaddr(struct urtw_softc *sc) +urtw_set_rate(struct urtw_softc *sc) { - uint32_t data; + int i, basic_rate, min_rr_rate, max_rr_rate; + uint16_t data; usb_error_t error; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR, &data); - if (error != 0) - goto fail; - sc->sc_bssid[0] = data & 0xff; - sc->sc_bssid[1] = (data & 0xff00) >> 8; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 1, &data); - if (error != 0) - goto fail; - sc->sc_bssid[2] = data & 0xff; - sc->sc_bssid[3] = (data & 0xff00) >> 8; - error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 2, &data); - if (error != 0) - goto fail; - sc->sc_bssid[4] = data & 0xff; - sc->sc_bssid[5] = (data & 0xff00) >> 8; + basic_rate = urtw_rate2rtl(48); + min_rr_rate = urtw_rate2rtl(12); + max_rr_rate = urtw_rate2rtl(48); + + urtw_write8_m(sc, URTW_RESP_RATE, + max_rr_rate << URTW_RESP_MAX_RATE_SHIFT | + min_rr_rate << URTW_RESP_MIN_RATE_SHIFT); + + urtw_read16_m(sc, URTW_BRSR, &data); + data &= ~URTW_BRSR_MBR_8185; + + for (i = 0; i <= basic_rate; i++) + data |= (1 << i); + + urtw_write16_m(sc, URTW_BRSR, data); fail: return (error); } -static usb_error_t -urtw_eprom_read32(struct urtw_softc *sc, uint32_t addr, uint32_t *data) +static uint16_t +urtw_rate2rtl(int rate) { -#define URTW_READCMD_LEN 3 - int addrlen, i; - int16_t addrstr[8], data16, readcmd[] = { 1, 1, 0 }; - usb_error_t error; - - /* NB: make sure the buffer is initialized */ - *data = 0; - - /* enable EPROM programming */ - urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_PROGRAM_MODE); - DELAY(URTW_EPROM_DELAY); +#define N(a) (sizeof(a) / sizeof((a)[0])) + int i; - error = urtw_eprom_cs(sc, URTW_EPROM_ENABLE); - if (error != 0) - goto fail; - error = urtw_eprom_ck(sc); - if (error != 0) - goto fail; - error = urtw_eprom_sendbits(sc, readcmd, URTW_READCMD_LEN); - if (error != 0) - goto fail; - if (sc->sc_epromtype == URTW_EEPROM_93C56) { - addrlen = 8; - addrstr[0] = addr & (1 << 7); - addrstr[1] = addr & (1 << 6); - addrstr[2] = addr & (1 << 5); - addrstr[3] = addr & (1 << 4); - addrstr[4] = addr & (1 << 3); - addrstr[5] = addr & (1 << 2); - addrstr[6] = addr & (1 << 1); - addrstr[7] = addr & (1 << 0); - } else { - addrlen=6; - addrstr[0] = addr & (1 << 5); - addrstr[1] = addr & (1 << 4); - addrstr[2] = addr & (1 << 3); - addrstr[3] = addr & (1 << 2); - addrstr[4] = addr & (1 << 1); - addrstr[5] = addr & (1 << 0); + for (i = 0; i < N(urtw_ratetable); i++) { + if (rate == urtw_ratetable[i].reg) + return urtw_ratetable[i].val; } - error = urtw_eprom_sendbits(sc, addrstr, addrlen); - if (error != 0) - goto fail; - error = urtw_eprom_writebit(sc, 0); - if (error != 0) - goto fail; + return (3); +#undef N +} - for (i = 0; i < 16; i++) { - error = urtw_eprom_ck(sc); - if (error != 0) - goto fail; - error = urtw_eprom_readbit(sc, &data16); - if (error != 0) - goto fail; +static uint16_t +urtw_rtl2rate(int rate) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + int i; - (*data) |= (data16 << (15 - i)); + for (i = 0; i < N(urtw_ratetable); i++) { + if (rate == urtw_ratetable[i].val) + return urtw_ratetable[i].reg; } - error = urtw_eprom_cs(sc, URTW_EPROM_DISABLE); - if (error != 0) - goto fail; - error = urtw_eprom_ck(sc); - if (error != 0) - goto fail; - - /* now disable EPROM programming */ - urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_NORMAL_MODE); -fail: - return (error); -#undef URTW_READCMD_LEN + return (0); +#undef N } static usb_error_t -urtw_eprom_readbit(struct urtw_softc *sc, int16_t *data) +urtw_update_msr(struct urtw_softc *sc) { - uint8_t data8; + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211com *ic = ifp->if_l2com; + uint8_t data; usb_error_t error; - urtw_read8_m(sc, URTW_EPROM_CMD, &data8); - *data = (data8 & URTW_EPROM_READBIT) ? 1 : 0; - DELAY(URTW_EPROM_DELAY); + urtw_read8_m(sc, URTW_MSR, &data); + data &= ~URTW_MSR_LINK_MASK; + + if (sc->sc_state == IEEE80211_S_RUN) { + switch (ic->ic_opmode) { + case IEEE80211_M_STA: + case IEEE80211_M_MONITOR: + data |= URTW_MSR_LINK_STA; + if (sc->sc_flags & URTW_RTL8187B) + data |= URTW_MSR_LINK_ENEDCA; + break; + case IEEE80211_M_IBSS: + data |= URTW_MSR_LINK_ADHOC; + break; + case IEEE80211_M_HOSTAP: + data |= URTW_MSR_LINK_HOSTAP; + break; + default: + panic("unsupported operation mode 0x%x\n", + ic->ic_opmode); + /* never reach */ + } + } else + data |= URTW_MSR_LINK_NONE; + urtw_write8_m(sc, URTW_MSR, data); fail: return (error); } static usb_error_t -urtw_eprom_sendbits(struct urtw_softc *sc, int16_t *buf, int buflen) +urtw_read8_c(struct urtw_softc *sc, int val, uint8_t *data) { - int i = 0; - usb_error_t error = 0; - - for (i = 0; i < buflen; i++) { - error = urtw_eprom_writebit(sc, buf[i]); - if (error != 0) - goto fail; - error = urtw_eprom_ck(sc); - if (error != 0) - goto fail; - } -fail: - return (error); -} - -static usb_error_t -urtw_eprom_writebit(struct urtw_softc *sc, int16_t bit) -{ - uint8_t data; - usb_error_t error; - - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - if (bit != 0) - urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_WRITEBIT); - else - urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_WRITEBIT); - DELAY(URTW_EPROM_DELAY); -fail: - return (error); -} - -static usb_error_t -urtw_eprom_ck(struct urtw_softc *sc) -{ - uint8_t data; - usb_error_t error; - - /* masking */ - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_CK); - DELAY(URTW_EPROM_DELAY); - /* unmasking */ - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_CK); - DELAY(URTW_EPROM_DELAY); -fail: - return (error); -} - - -static usb_error_t -urtw_eprom_cs(struct urtw_softc *sc, int able) -{ - uint8_t data; - usb_error_t error; - - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - if (able == URTW_EPROM_ENABLE) - urtw_write8_m(sc, URTW_EPROM_CMD, data | URTW_EPROM_CS); - else - urtw_write8_m(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_CS); - DELAY(URTW_EPROM_DELAY); -fail: - return (error); -} - - - -static usb_error_t -urtw_read8_c(struct urtw_softc *sc, int val, uint8_t *data) -{ - struct usb_device_request req; - usb_error_t error; + struct usb_device_request req; + usb_error_t error; URTW_ASSERT_LOCKED(sc); @@ -2102,22 +2062,6 @@ urtw_read8_c(struct urtw_softc *sc, int } static usb_error_t -urtw_read8e(struct urtw_softc *sc, int val, uint8_t *data) -{ - struct usb_device_request req; - usb_error_t error; - - req.bmRequestType = UT_READ_VENDOR_DEVICE; - req.bRequest = URTW_8187_GETREGS_REQ; - USETW(req.wValue, val | 0xfe00); - USETW(req.wIndex, 0); - USETW(req.wLength, sizeof(uint8_t)); - - error = urtw_do_request(sc, &req, data); - return (error); -} - -static usb_error_t urtw_read16_c(struct urtw_softc *sc, int val, uint16_t *data) { struct usb_device_request req; @@ -2170,20 +2114,6 @@ urtw_write8_c(struct urtw_softc *sc, int } static usb_error_t -urtw_write8e(struct urtw_softc *sc, int val, uint8_t data) -{ - struct usb_device_request req; - - req.bmRequestType = UT_WRITE_VENDOR_DEVICE; - req.bRequest = URTW_8187_SETREGS_REQ; - USETW(req.wValue, val | 0xfe00); - USETW(req.wIndex, 0); - USETW(req.wLength, sizeof(uint8_t)); - - return (urtw_do_request(sc, &req, &data)); -} - -static usb_error_t urtw_write16_c(struct urtw_softc *sc, int val, uint16_t data) { struct usb_device_request req; @@ -2216,180 +2146,308 @@ urtw_write32_c(struct urtw_softc *sc, in } static usb_error_t -urtw_set_mode(struct urtw_softc *sc, uint32_t mode) +urtw_get_macaddr(struct urtw_softc *sc) { - uint8_t data; + uint32_t data; usb_error_t error; - urtw_read8_m(sc, URTW_EPROM_CMD, &data); - data = (data & ~URTW_EPROM_CMD_MASK) | (mode << URTW_EPROM_CMD_SHIFT); - data = data & ~(URTW_EPROM_CS | URTW_EPROM_CK); - urtw_write8_m(sc, URTW_EPROM_CMD, data); + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR, &data); + if (error != 0) + goto fail; + sc->sc_bssid[0] = data & 0xff; + sc->sc_bssid[1] = (data & 0xff00) >> 8; + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 1, &data); + if (error != 0) + goto fail; + sc->sc_bssid[2] = data & 0xff; + sc->sc_bssid[3] = (data & 0xff00) >> 8; + error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 2, &data); + if (error != 0) + goto fail; + sc->sc_bssid[4] = data & 0xff; + sc->sc_bssid[5] = (data & 0xff00) >> 8; fail: return (error); } static usb_error_t -urtw_8180_set_anaparam(struct urtw_softc *sc, uint32_t val) +urtw_eprom_read32(struct urtw_softc *sc, uint32_t addr, uint32_t *data) { - uint8_t data; +#define URTW_READCMD_LEN 3 + int addrlen, i; + int16_t addrstr[8], data16, readcmd[] = { 1, 1, 0 }; usb_error_t error; - error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG); - if (error) + /* NB: make sure the buffer is initialized */ + *data = 0; + + /* enable EPROM programming */ + urtw_write8_m(sc, URTW_EPROM_CMD, URTW_EPROM_CMD_PROGRAM_MODE); + DELAY(URTW_EPROM_DELAY); + + error = urtw_eprom_cs(sc, URTW_EPROM_ENABLE); + if (error != 0) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From phk at FreeBSD.org Tue Sep 8 13:24:36 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 13:24:43 2009 Subject: svn commit: r196971 - head/sys/security/audit Message-ID: <200909081324.n88DOaE6048785@svn.freebsd.org> Author: phk Date: Tue Sep 8 13:24:36 2009 New Revision: 196971 URL: http://svn.freebsd.org/changeset/base/196971 Log: Having thrown the cat out of the house, add a necessary include. Modified: head/sys/security/audit/audit_bsm_token.c Modified: head/sys/security/audit/audit_bsm_token.c ============================================================================== --- head/sys/security/audit/audit_bsm_token.c Tue Sep 8 13:19:05 2009 (r196970) +++ head/sys/security/audit/audit_bsm_token.c Tue Sep 8 13:24:36 2009 (r196971) @@ -36,6 +36,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include From phk at phk.freebsd.dk Tue Sep 8 13:28:03 2009 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue Sep 8 13:28:15 2009 Subject: svn commit: r196969 - in head/sys: cam/scsi contrib/dev/acpica/executer dev/aac dev/ae dev/amr dev/ata dev/ata/chipsets dev/ath dev/ath/ath_hal dev/bce dev/e1000 dev/ep dev/firewire dev/fxp dev/hpt... In-Reply-To: Your message of "Tue, 08 Sep 2009 13:16:55 GMT." <200909081316.n88DGtVn048461@svn.freebsd.org> Message-ID: <31624.1252416492@critter.freebsd.dk> Hep! Pointy hat over here! Thanks... So, anyway, I spent a hour stuck in a train yesterday and ran flexelint on the kernel. Apart from if_urtw.c, all the stuff below was flagged by FlexeLint and if any of your files were included, please take a peek and see if it is only smoke or if there is a fire. Poul-Henning >Modified: > head/sys/cam/scsi/scsi_cd.c > head/sys/contrib/dev/acpica/executer/exfldio.c > head/sys/dev/aac/aac.c [...] -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From phk at FreeBSD.org Tue Sep 8 15:18:25 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 15:18:32 2009 Subject: svn commit: r196976 - head/lib/libc/net Message-ID: <200909081518.n88FIPOZ051348@svn.freebsd.org> Author: phk Date: Tue Sep 8 15:18:25 2009 New Revision: 196976 URL: http://svn.freebsd.org/changeset/base/196976 Log: Add necessary include Modified: head/lib/libc/net/getifaddrs.c Modified: head/lib/libc/net/getifaddrs.c ============================================================================== --- head/lib/libc/net/getifaddrs.c Tue Sep 8 15:13:49 2009 (r196975) +++ head/lib/libc/net/getifaddrs.c Tue Sep 8 15:18:25 2009 (r196976) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" +#include #include #include #include From pjd at FreeBSD.org Tue Sep 8 15:37:01 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 15:37:14 2009 Subject: svn commit: r196978 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909081537.n88Fb1HQ051893@svn.freebsd.org> Author: pjd Date: Tue Sep 8 15:37:01 2009 New Revision: 196978 URL: http://svn.freebsd.org/changeset/base/196978 Log: Call ZFS_EXIT() after locking the vnode. MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:31:23 2009 (r196977) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:37:01 2009 (r196978) @@ -1173,9 +1173,8 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vno } else { VN_HOLD(*vpp); } - ZFS_EXIT(zfsvfs); - /* XXX: LK_RETRY? */ vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + ZFS_EXIT(zfsvfs); return (0); } @@ -1197,7 +1196,6 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vno } *vpp = ZTOV(zp); - /* XXX: LK_RETRY? */ vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); vnode_create_vobject(*vpp, zp->z_phys->zp_size, curthread); ZFS_EXIT(zfsvfs); From pjd at FreeBSD.org Tue Sep 8 15:42:56 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 15:43:07 2009 Subject: svn commit: r196979 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909081542.n88FgtUw052042@svn.freebsd.org> Author: pjd Date: Tue Sep 8 15:42:55 2009 New Revision: 196979 URL: http://svn.freebsd.org/changeset/base/196979 Log: On FreeBSD we don't have to look for snapshot's mount point, because fhtovp method is already called with proper mount point. MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:37:01 2009 (r196978) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:42:55 2009 (r196979) @@ -1130,6 +1130,11 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vno ZFS_ENTER(zfsvfs); + /* + * On FreeBSD we are already called with snapshot's mount point + * and not the mount point of its parent. + */ +#ifndef __FreeBSD__ if (fidp->fid_len == LONG_FID_LEN) { zfid_long_t *zlfid = (zfid_long_t *)fidp; uint64_t objsetid = 0; @@ -1148,6 +1153,7 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vno return (EINVAL); ZFS_ENTER(zfsvfs); } +#endif if (fidp->fid_len == SHORT_FID_LEN || fidp->fid_len == LONG_FID_LEN) { zfid_short_t *zfid = (zfid_short_t *)fidp; From pjd at FreeBSD.org Tue Sep 8 15:51:40 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 15:52:00 2009 Subject: svn commit: r196980 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909081551.n88Fpeta052400@svn.freebsd.org> Author: pjd Date: Tue Sep 8 15:51:40 2009 New Revision: 196980 URL: http://svn.freebsd.org/changeset/base/196980 Log: When we automatically mount snapshot we want to return vnode of the mount point from the lookup and not covered vnode. This is one of the fixes for using .zfs/ over NFS. MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Tue Sep 8 15:42:55 2009 (r196979) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Tue Sep 8 15:51:40 2009 (r196980) @@ -882,9 +882,25 @@ domount: dvp->v_vfsp->mnt_stat.f_mntonname, nm); err = domount(curthread, *vpp, "zfs", mountpoint, snapname, 0); kmem_free(mountpoint, mountpoint_len); - /* FreeBSD: This line was moved from below to avoid a lock recursion. */ - if (err == 0) - vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + if (err == 0) { + vnode_t *mvp; + + ASSERT((*vpp)->v_mountedhere != NULL); + err = VFS_ROOT((*vpp)->v_mountedhere, LK_EXCLUSIVE, &mvp); + ASSERT(err == 0); + VN_RELE(*vpp); + *vpp = mvp; + + /* + * Fix up the root vnode mounted on .zfs/snapshot/. + * + * This is where we lie about our v_vfsp in order to + * make .zfs/snapshot/ accessible over NFS + * without requiring manual mounts of . + */ + ASSERT(VTOZ(*vpp)->z_zfsvfs != zfsvfs); + VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs; + } mutex_exit(&sdp->sd_lock); /* * If we had an error, drop our hold on the vnode and From rdivacky at FreeBSD.org Tue Sep 8 15:55:14 2009 From: rdivacky at FreeBSD.org (Roman Divacky) Date: Tue Sep 8 15:55:21 2009 Subject: svn commit: r196981 - head/usr.bin/unzip Message-ID: <200909081555.n88FtDwe052523@svn.freebsd.org> Author: rdivacky Date: Tue Sep 8 15:55:13 2009 New Revision: 196981 URL: http://svn.freebsd.org/changeset/base/196981 Log: Add C/c/f/p/v switches plus a bunch of minor fixes and cleanups. Obtained from: NetBSD Approved by: des (maintainer) Approved by: ed (mentor, implicit) Modified: head/usr.bin/unzip/unzip.1 head/usr.bin/unzip/unzip.c Modified: head/usr.bin/unzip/unzip.1 ============================================================================== --- head/usr.bin/unzip/unzip.1 Tue Sep 8 15:51:40 2009 (r196980) +++ head/usr.bin/unzip/unzip.1 Tue Sep 8 15:55:13 2009 (r196981) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 30, 2008 +.Dd September 7, 2009 .Dt UNZIP 1 .Os .Sh NAME @@ -33,7 +33,7 @@ .Nd extract files from a ZIP archive .Sh SYNOPSIS .Nm -.Op Fl ajLlnoqtu +.Op Fl aCcfjLlnopqtuv .Op Fl d Ar dir .Ar zipfile .Sh DESCRIPTION @@ -44,9 +44,22 @@ The following options are available: .It Fl a When extracting a text file, convert DOS-style line endings to Unix-style line endings. +.It Fl C +Match file names case-insensitively. +.It Fl c +Extract to stdout/screen. +When extracting files from the zipfile, they are written to stdout. +This is similar to +.Fl p , +but doesn't suppress normal output. .It Fl d Ar dir Extract files into the specified directory rather than the current directory. +.It Fl f +Update existing. +Extract only files from the zipfile if a file with the same name +already exists on disk and is older than the former. +Otherwise, the file is silently skipped. .It Fl j Ignore directories stored in the zipfile; instead, extract all files directly into the extraction directory. @@ -56,13 +69,19 @@ Convert the names of the extracted files List, rather than extract, the contents of the zipfile. .It Fl n No overwrite. -When extacting a file from the zipfile, if a file with the same name +When extracting a file from the zipfile, if a file with the same name already exists on disk, the file is silently skipped. .It Fl o Overwrite. -When extacting a file from the zipfile, if a file with the same name +When extracting a file from the zipfile, if a file with the same name already exists on disk, the existing file is replaced with the file from the zipfile. +.It Fl p +Extract to stdout. +When extracting files from the zipfile, they are written to stdout. +The normal output is suppressed as if +.Fl q +was specified. .It Fl q Quiet: print less information while extracting. .It Fl t @@ -70,15 +89,25 @@ Test: do not extract anything, but verif in the archive. .It Fl u Update. -When extacting a file from the zipfile, if a file with the same name +When extracting a file from the zipfile, if a file with the same name already exists on disk, the existing file is replaced with the file from the zipfile if and only if the latter is newer than the former. Otherwise, the file is silently skipped. +.It Fl v +List verbosely, rather than extract, the contents of the zipfile. +This differs from +.Fl l +by using the long listing. +Note that most of the data is currently fake and does not reflect the +content of the archive. +.It Fl x Ar pattern +Exclude files matching the pattern +.Ar pattern . .El .Pp Note that only one of .Fl n , -.Fl o +.Fl o , and .Fl u may be specified. Modified: head/usr.bin/unzip/unzip.c ============================================================================== --- head/usr.bin/unzip/unzip.c Tue Sep 8 15:51:40 2009 (r196980) +++ head/usr.bin/unzip/unzip.c Tue Sep 8 15:55:13 2009 (r196981) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2009 Joerg Sonnenberger * Copyright (c) 2007-2008 Dag-Erling Coïdan Smørgrav * All rights reserved. * @@ -51,15 +52,19 @@ /* command-line options */ static int a_opt; /* convert EOL */ +static int C_opt; /* match case-insensitively */ +static int c_opt; /* extract to stdout */ static const char *d_arg; /* directory */ +static int f_opt; /* update existing files only */ static int j_opt; /* junk directories */ static int L_opt; /* lowercase names */ -static int l_opt; /* list */ static int n_opt; /* never overwrite */ static int o_opt; /* always overwrite */ +static int p_opt; /* extract to stdout, quiet */ static int q_opt; /* quiet */ static int t_opt; /* test */ static int u_opt; /* update */ +static int v_opt; /* verbose/list */ /* time when unzip started */ static time_t now; @@ -70,9 +75,6 @@ static int unzip_debug; /* running on tty? */ static int tty; -/* error flag for -t */ -static int test_failed; - /* convenience macro */ /* XXX should differentiate between ARCHIVE_{WARN,FAIL,RETRY} */ #define ac(call) \ @@ -162,7 +164,6 @@ static void info(const char *fmt, ...) { va_list ap; - int i; if (q_opt && !unzip_debug) return; @@ -171,9 +172,10 @@ info(const char *fmt, ...) va_end(ap); fflush(stdout); - for (i = 0; fmt[i] != '\0'; ++i) - /* nothing */ ; - noeol = !(i && fmt[i - 1] == '\n'); + if (*fmt == '\0') + noeol = 1; + else + noeol = fmt[strlen(fmt) - 1] != '\n'; } /* debug message (if unzip_debug) */ @@ -181,7 +183,6 @@ static void debug(const char *fmt, ...) { va_list ap; - int i; if (!unzip_debug) return; @@ -190,9 +191,10 @@ debug(const char *fmt, ...) va_end(ap); fflush(stderr); - for (i = 0; fmt[i] != '\0'; ++i) - /* nothing */ ; - noeol = !(i && fmt[i - 1] == '\n'); + if (*fmt == '\0') + noeol = 1; + else + noeol = fmt[strlen(fmt) - 1] != '\n'; } /* duplicate a path name, possibly converting to lower case */ @@ -200,7 +202,7 @@ static char * pathdup(const char *path) { char *str; - int len; + size_t i, len; len = strlen(path); while (len && path[len - 1] == '/') @@ -209,8 +211,12 @@ pathdup(const char *path) errno = ENOMEM; error("malloc()"); } - for (int i = 0; i < len; ++i) - str[i] = L_opt ? tolower(path[i]) : path[i]; + if (L_opt) { + for (i = 0; i < len; ++i) + str[i] = tolower((unsigned char)path[i]); + } else { + memcpy(str, path, len); + } str[len] = '\0'; return (str); @@ -221,7 +227,7 @@ static char * pathcat(const char *prefix, const char *path) { char *str; - int prelen, len; + size_t prelen, len; prelen = prefix ? strlen(prefix) + 1 : 0; len = strlen(path) + 1; @@ -257,7 +263,7 @@ static void add_pattern(struct pattern_list *list, const char *pattern) { struct pattern *entry; - int len; + size_t len; debug("adding pattern '%s'\n", pattern); len = strlen(pattern); @@ -265,7 +271,6 @@ add_pattern(struct pattern_list *list, c errno = ENOMEM; error("malloc()"); } - memset(&entry->link, 0, sizeof entry->link); memcpy(entry->pattern, pattern, len + 1); STAILQ_INSERT_TAIL(list, entry, link); } @@ -279,7 +284,7 @@ match_pattern(struct pattern_list *list, struct pattern *entry; STAILQ_FOREACH(entry, list, link) { - if (fnmatch(entry->pattern, str, 0) == 0) + if (fnmatch(entry->pattern, str, C_opt ? FNM_CASEFOLD : 0) == 0) return (1); } return (0); @@ -427,9 +432,9 @@ extract_file(struct archive *a, struct a /* look for existing file of same name */ if (lstat(path, &sb) == 0) { - if (u_opt) { + if (u_opt || f_opt) { /* check if up-to-date */ - if (S_ISREG(sb.st_mode) && sb.st_mtime > mtime) + if (S_ISREG(sb.st_mode) && sb.st_mtime >= mtime) return; (void)unlink(path); } else if (o_opt) { @@ -442,13 +447,16 @@ extract_file(struct archive *a, struct a /* XXX ask user */ errorx("not implemented"); } + } else { + if (f_opt) + return; } if ((fd = open(path, O_RDWR|O_CREAT|O_TRUNC, mode)) < 0) error("open('%s')", path); /* loop over file contents and write to disk */ - info("x %s", path); + info(" extracting: %s", path); text = a_opt; warn = 0; cr = 0; @@ -618,40 +626,172 @@ extract(struct archive *a, struct archiv free(pathname); } +static void +extract_stdout(struct archive *a, struct archive_entry *e) +{ + char *pathname; + mode_t filetype; + int cr, text, warn; + ssize_t len; + unsigned char *p, *q, *end; + + pathname = pathdup(archive_entry_pathname(e)); + filetype = archive_entry_filetype(e); + + /* I don't think this can happen in a zipfile.. */ + if (!S_ISDIR(filetype) && !S_ISREG(filetype)) { + warningx("skipping non-regular entry '%s'", pathname); + ac(archive_read_data_skip(a)); + free(pathname); + return; + } + + /* skip directories in -j case */ + if (S_ISDIR(filetype)) { + ac(archive_read_data_skip(a)); + free(pathname); + return; + } + + /* apply include / exclude patterns */ + if (!accept_pathname(pathname)) { + ac(archive_read_data_skip(a)); + free(pathname); + return; + } + + if (c_opt) + info("x %s\n", pathname); + + text = a_opt; + warn = 0; + cr = 0; + for (int n = 0; ; n++) { + len = archive_read_data(a, buffer, sizeof buffer); + + if (len < 0) + ac(len); + + /* left over CR from previous buffer */ + if (a_opt && cr) { + if (len == 0 || buffer[0] != '\n') { + if (fwrite("\r", 1, 1, stderr) != 1) + error("write('%s')", pathname); + } + cr = 0; + } + + /* EOF */ + if (len == 0) + break; + end = buffer + len; + + /* + * Detect whether this is a text file. The correct way to + * do this is to check the least significant bit of the + * "internal file attributes" field of the corresponding + * file header in the central directory, but libarchive + * does not read the central directory, so we have to + * guess by looking for non-ASCII characters in the + * buffer. Hopefully we won't guess wrong. If we do + * guess wrong, we print a warning message later. + */ + if (a_opt && n == 0) { + for (p = buffer; p < end; ++p) { + if (!isascii((unsigned char)*p)) { + text = 0; + break; + } + } + } + + /* simple case */ + if (!a_opt || !text) { + if (fwrite(buffer, 1, len, stdout) != (size_t)len) + error("write('%s')", pathname); + continue; + } + + /* hard case: convert \r\n to \n (sigh...) */ + for (p = buffer; p < end; p = q + 1) { + for (q = p; q < end; q++) { + if (!warn && !isascii(*q)) { + warningx("%s may be corrupted due" + " to weak text file detection" + " heuristic", pathname); + warn = 1; + } + if (q[0] != '\r') + continue; + if (&q[1] == end) { + cr = 1; + break; + } + if (q[1] == '\n') + break; + } + if (fwrite(p, 1, q - p, stdout) != (size_t)(q - p)) + error("write('%s')", pathname); + } + } + + free(pathname); +} + /* * Print the name of an entry to stdout. */ static void list(struct archive *a, struct archive_entry *e) { + char buf[20]; + time_t mtime; + + mtime = archive_entry_mtime(e); + strftime(buf, sizeof(buf), "%m-%d-%g %R", localtime(&mtime)); - printf("%s\n", archive_entry_pathname(e)); + if (v_opt == 1) { + printf(" %8ju %s %s\n", + (uintmax_t)archive_entry_size(e), + buf, archive_entry_pathname(e)); + } else if (v_opt == 2) { + printf("%8ju Stored %7ju 0%% %s %08x %s\n", + (uintmax_t)archive_entry_size(e), + (uintmax_t)archive_entry_size(e), + buf, + 0U, + archive_entry_pathname(e)); + } ac(archive_read_data_skip(a)); } /* * Extract to memory to check CRC */ -static void +static int test(struct archive *a, struct archive_entry *e) { ssize_t len; + int error_count; + error_count = 0; if (S_ISDIR(archive_entry_filetype(e))) - return; + return 0; - info("%s ", archive_entry_pathname(e)); + info(" testing: %s\t", archive_entry_pathname(e)); while ((len = archive_read_data(a, buffer, sizeof buffer)) > 0) /* nothing */; if (len < 0) { - info("%s\n", archive_error_string(a)); - ++test_failed; + info(" %s\n", archive_error_string(a)); + ++error_count; } else { - info("OK\n"); + info(" OK\n"); } /* shouldn't be necessary, but it doesn't hurt */ ac(archive_read_data_skip(a)); + + return error_count; } @@ -665,6 +805,7 @@ unzip(const char *fn) struct archive *a; struct archive_entry *e; int fd, ret; + uintmax_t total_size, file_count, error_count; if ((fd = open(fn, O_RDONLY)) < 0) error("%s", fn); @@ -673,33 +814,69 @@ unzip(const char *fn) ac(archive_read_support_format_zip(a)); ac(archive_read_open_fd(a, fd, 8192)); + printf("Archive: %s\n", fn); + if (v_opt == 1) { + printf(" Length Date Time Name\n"); + printf(" -------- ---- ---- ----\n"); + } else if (v_opt == 2) { + printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); + printf("-------- ------ ------- ----- ---- ---- ------ ----\n"); + } + + total_size = 0; + file_count = 0; + error_count = 0; for (;;) { ret = archive_read_next_header(a, &e); if (ret == ARCHIVE_EOF) break; ac(ret); if (t_opt) - test(a, e); - else if (l_opt) + error_count += test(a, e); + else if (v_opt) list(a, e); + else if (p_opt || c_opt) + extract_stdout(a, e); else extract(a, e); + + total_size += archive_entry_size(e); + ++file_count; + } + + if (v_opt == 1) { + printf(" -------- -------\n"); + printf(" %8ju %ju file%s\n", + total_size, file_count, file_count != 1 ? "s" : ""); + } else if (v_opt == 2) { + printf("-------- ------- --- -------\n"); + printf("%8ju %7ju 0%% %ju file%s\n", + total_size, total_size, file_count, + file_count != 1 ? "s" : ""); } ac(archive_read_close(a)); (void)archive_read_finish(a); + if (close(fd) != 0) error("%s", fn); - if (t_opt && test_failed) - errorx("%d checksum error(s) found.", test_failed); + if (t_opt) { + if (error_count > 0) { + errorx("%d checksum error(s) found.", error_count); + } + else { + printf("No errors detected in compressed data of %s.\n", + fn); + } + } } static void usage(void) { - fprintf(stderr, "usage: unzip [-ajLlnoqtu] [-d dir] zipfile\n"); + fprintf(stderr, "usage: unzip [-aCcfjLlnopqtuv] [-d dir] [-x pattern] zipfile\n"); exit(1); } @@ -709,14 +886,23 @@ getopts(int argc, char *argv[]) int opt; optreset = optind = 1; - while ((opt = getopt(argc, argv, "ad:jLlnoqtux:")) != -1) + while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:")) != -1) switch (opt) { case 'a': a_opt = 1; break; + case 'C': + C_opt = 1; + break; + case 'c': + c_opt = 1; + break; case 'd': d_arg = optarg; break; + case 'f': + f_opt = 1; + break; case 'j': j_opt = 1; break; @@ -724,13 +910,18 @@ getopts(int argc, char *argv[]) L_opt = 1; break; case 'l': - l_opt = 1; + if (v_opt == 0) + v_opt = 1; break; case 'n': n_opt = 1; break; case 'o': o_opt = 1; + q_opt = 1; + break; + case 'p': + p_opt = 1; break; case 'q': q_opt = 1; @@ -741,6 +932,9 @@ getopts(int argc, char *argv[]) case 'u': u_opt = 1; break; + case 'v': + v_opt = 2; + break; case 'x': add_pattern(&exclude, optarg); break; From pjd at FreeBSD.org Tue Sep 8 15:57:03 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 15:57:14 2009 Subject: svn commit: r196982 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909081557.n88Fv3Pg052597@svn.freebsd.org> Author: pjd Date: Tue Sep 8 15:57:03 2009 New Revision: 196982 URL: http://svn.freebsd.org/changeset/base/196982 Log: We don't export individual snapshots, so mnt_export field in snapshot's mount point is NULL. That's why when we try to access snapshots over NFS use mnt_export field from the parent file system. MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:55:13 2009 (r196981) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Sep 8 15:57:03 2009 (r196982) @@ -97,6 +97,8 @@ static int zfs_root(vfs_t *vfsp, int fla static int zfs_statfs(vfs_t *vfsp, struct statfs *statp); static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp); static int zfs_sync(vfs_t *vfsp, int waitfor); +static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, + struct ucred **credanonp, int *numsecflavors, int **secflavors); static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp); static void zfs_objset_close(zfsvfs_t *zfsvfs); static void zfs_freevfs(vfs_t *vfsp); @@ -108,6 +110,7 @@ static struct vfsops zfs_vfsops = { .vfs_statfs = zfs_statfs, .vfs_vget = zfs_vget, .vfs_sync = zfs_sync, + .vfs_checkexp = zfs_checkexp, .vfs_fhtovp = zfs_fhtovp, }; @@ -1116,6 +1119,26 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int fla } static int +zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, + struct ucred **credanonp, int *numsecflavors, int **secflavors) +{ + zfsvfs_t *zfsvfs = vfsp->vfs_data; + + /* + * If this is regular file system vfsp is the same as + * zfsvfs->z_parent->z_vfs, but if it is snapshot, + * zfsvfs->z_parent->z_vfs represents parent file system + * which we have to use here, because only this file system + * has mnt_export configured. + */ + vfsp = zfsvfs->z_parent->z_vfs; + + return (vfs_stdcheckexp(zfsvfs->z_parent->z_vfs, nam, extflagsp, + credanonp, numsecflavors, secflavors)); +} + + +static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp) { zfsvfs_t *zfsvfs = vfsp->vfs_data; From pjd at FreeBSD.org Tue Sep 8 15:58:56 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 15:59:08 2009 Subject: svn commit: r196976 - head/lib/libc/net In-Reply-To: <200909081518.n88FIPOZ051348@svn.freebsd.org> References: <200909081518.n88FIPOZ051348@svn.freebsd.org> Message-ID: <20090908155850.GM1577@garage.freebsd.pl> On Tue, Sep 08, 2009 at 03:18:25PM +0000, Poul-Henning Kamp wrote: > Author: phk > Date: Tue Sep 8 15:18:25 2009 > New Revision: 196976 > URL: http://svn.freebsd.org/changeset/base/196976 > > Log: > Add necessary include > > Modified: > head/lib/libc/net/getifaddrs.c > > Modified: head/lib/libc/net/getifaddrs.c > ============================================================================== > --- head/lib/libc/net/getifaddrs.c Tue Sep 8 15:13:49 2009 (r196975) > +++ head/lib/libc/net/getifaddrs.c Tue Sep 8 15:18:25 2009 (r196976) > @@ -33,6 +33,7 @@ > __FBSDID("$FreeBSD$"); > > #include "namespace.h" > +#include > #include style(9) seems to advice to include either types.h or param.h, but not both. -- Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090908/507410a2/attachment-0001.pgp From des at des.no Tue Sep 8 16:00:45 2009 From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=) Date: Tue Sep 8 16:00:52 2009 Subject: svn commit: r196976 - head/lib/libc/net In-Reply-To: <20090908155850.GM1577@garage.freebsd.pl> (Pawel Jakub Dawidek's message of "Tue, 8 Sep 2009 17:58:50 +0200") References: <200909081518.n88FIPOZ051348@svn.freebsd.org> <20090908155850.GM1577@garage.freebsd.pl> Message-ID: <86d461juj7.fsf@ds4.des.no> Pawel Jakub Dawidek writes: > style(9) seems to advice to include either types.h or param.h, but not both. correct, already includes . DES -- Dag-Erling Sm?rgrav - des@des.no From scottl at FreeBSD.org Tue Sep 8 16:09:29 2009 From: scottl at FreeBSD.org (Scott Long) Date: Tue Sep 8 16:09:35 2009 Subject: svn commit: r196983 - head/sys/cam/scsi Message-ID: <200909081609.n88G9Sxa052994@svn.freebsd.org> Author: scottl Date: Tue Sep 8 16:09:28 2009 New Revision: 196983 URL: http://svn.freebsd.org/changeset/base/196983 Log: Free the correct buffer in an error case. Submitted by: phk Modified: head/sys/cam/scsi/scsi_cd.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Tue Sep 8 15:57:03 2009 (r196982) +++ head/sys/cam/scsi/scsi_cd.c Tue Sep 8 16:09:28 2009 (r196983) @@ -2528,7 +2528,7 @@ cdioctl(struct disk *dp, u_long cmd, voi error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(¶ms, M_SCSICD); + free(¶ms.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } From imp at FreeBSD.org Tue Sep 8 16:37:19 2009 From: imp at FreeBSD.org (Warner Losh) Date: Tue Sep 8 16:37:30 2009 Subject: svn commit: r196984 - head/sys/dev/ep Message-ID: <200909081637.n88GbJeq053589@svn.freebsd.org> Author: imp Date: Tue Sep 8 16:37:18 2009 New Revision: 196984 URL: http://svn.freebsd.org/changeset/base/196984 Log: Cleanup tortured logic a big. Noticed by FlexLint, per phk. # My reading of the docs suggests this can only happen on 10Base5 and # 10Base2 setups (and maybe only the former), which I can't test # adequately since I have nothing but 10BaseT, etc here. Modified: head/sys/dev/ep/if_ep.c Modified: head/sys/dev/ep/if_ep.c ============================================================================== --- head/sys/dev/ep/if_ep.c Tue Sep 8 16:09:28 2009 (r196983) +++ head/sys/dev/ep/if_ep.c Tue Sep 8 16:37:18 2009 (r196984) @@ -665,14 +665,13 @@ rescan: #ifdef EP_LOCAL_STATS sc->tx_underrun++; #endif - } else { - if (status & TXS_JABBER); - else - ++ifp->if_collisions; - /* TXS_MAX_COLLISION - * we shouldn't get - * here - */ + } + if (status & TXS_MAX_COLLISION) { + /* + * TXS_MAX_COLLISION we + * shouldn't get here + */ + ++ifp->if_collisions; } ++ifp->if_oerrors; CSR_WRITE_2(sc, EP_COMMAND, TX_ENABLE); From pjd at FreeBSD.org Tue Sep 8 16:40:08 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 16:40:15 2009 Subject: svn commit: r196985 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <200909081640.n88Ge8BL053691@svn.freebsd.org> Author: pjd Date: Tue Sep 8 16:40:08 2009 New Revision: 196985 URL: http://svn.freebsd.org/changeset/base/196985 Log: Only log successful commands! Without this fix we log even unsuccessful commands executed by unprivileged users. Action is not really taken, but it is logged to pool history, which might be confusing. Reported by: Denis Ahrens MFC after: 3 days Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Sep 8 16:37:18 2009 (r196984) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Sep 8 16:40:08 2009 (r196985) @@ -3021,8 +3021,10 @@ zfsdev_ioctl(struct cdev *dev, u_long cm if (error == 0) error = zfs_ioc_vec[vec].zvec_func(zc); - if (zfs_ioc_vec[vec].zvec_his_log == B_TRUE) - zfs_log_history(zc); + if (error == 0) { + if (zfs_ioc_vec[vec].zvec_his_log == B_TRUE) + zfs_log_history(zc); + } return (error); } From phk at phk.freebsd.dk Tue Sep 8 17:14:15 2009 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue Sep 8 17:14:27 2009 Subject: svn commit: r196976 - head/lib/libc/net In-Reply-To: Your message of "Tue, 08 Sep 2009 17:58:50 +0200." <20090908155850.GM1577@garage.freebsd.pl> Message-ID: <32053.1252430065@critter.freebsd.dk> >> @@ -33,6 +33,7 @@ >> __FBSDID("$FreeBSD$"); >> >> #include "namespace.h" >> +#include >> #include > >style(9) seems to advice to include either types.h or param.h, but not both. yeah, I had to dig deeper and found the _NO_NAMESPACE_POLLUTION hack which makes a mess of . I'm trying to do that stuff the right way, but it is cross-platform so my universe needs to complete before commit. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From trasz at FreeBSD.org Tue Sep 8 17:20:17 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Tue Sep 8 17:20:23 2009 Subject: svn commit: r196986 - head/sys/geom Message-ID: <200909081720.n88HKHE9054563@svn.freebsd.org> Author: trasz Date: Tue Sep 8 17:20:17 2009 New Revision: 196986 URL: http://svn.freebsd.org/changeset/base/196986 Log: Remove unused variable. Modified: head/sys/geom/geom_vfs.c Modified: head/sys/geom/geom_vfs.c ============================================================================== --- head/sys/geom/geom_vfs.c Tue Sep 8 16:40:08 2009 (r196985) +++ head/sys/geom/geom_vfs.c Tue Sep 8 17:20:17 2009 (r196986) @@ -134,12 +134,10 @@ static void g_vfs_orphan(struct g_consumer *cp) { struct g_geom *gp; - struct bufobj *bo; g_topology_assert(); gp = cp->geom; - bo = gp->softc; g_trace(G_T_TOPOLOGY, "g_vfs_orphan(%p(%s))", cp, gp->name); if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) g_access(cp, -cp->acr, -cp->acw, -cp->ace); From trasz at FreeBSD.org Tue Sep 8 17:23:33 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Tue Sep 8 17:23:45 2009 Subject: svn commit: r196987 - head/sys/ufs/ufs Message-ID: <200909081723.n88HNXfl054664@svn.freebsd.org> Author: trasz Date: Tue Sep 8 17:23:32 2009 New Revision: 196987 URL: http://svn.freebsd.org/changeset/base/196987 Log: Remove useless variable assignment. Modified: head/sys/ufs/ufs/ufs_acl.c Modified: head/sys/ufs/ufs/ufs_acl.c ============================================================================== --- head/sys/ufs/ufs/ufs_acl.c Tue Sep 8 17:20:17 2009 (r196986) +++ head/sys/ufs/ufs/ufs_acl.c Tue Sep 8 17:23:32 2009 (r196987) @@ -255,9 +255,6 @@ ufs_getacl_posix1e(struct vop_getacl_arg old->acl_cnt = 0; break; } - - error = 0; - /* FALLTHROUGH */ case 0: error = acl_copy_oldacl_into_acl(old, ap->a_aclp); From brooks at FreeBSD.org Tue Sep 8 19:38:00 2009 From: brooks at FreeBSD.org (Brooks Davis) Date: Tue Sep 8 19:38:06 2009 Subject: svn commit: r196990 - head/lib/libkvm Message-ID: <200909081937.n88Jbxqj057662@svn.freebsd.org> Author: brooks Date: Tue Sep 8 19:37:59 2009 New Revision: 196990 URL: http://svn.freebsd.org/changeset/base/196990 Log: cr_groups is no longer embedded in struct ucred and is instead stored in a seperate array. As such we need to use kvm_read rather than bcopy to populate the ki_groups field. This fixes a crash when running ps -ax on a coredump. Reported by: brucec Tested by: brucec MFC after: 3 days Modified: head/lib/libkvm/kvm_proc.c Modified: head/lib/libkvm/kvm_proc.c ============================================================================== --- head/lib/libkvm/kvm_proc.c Tue Sep 8 19:18:02 2009 (r196989) +++ head/lib/libkvm/kvm_proc.c Tue Sep 8 19:37:59 2009 (r196990) @@ -151,7 +151,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcn kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; } kp->ki_ngroups = ucred.cr_ngroups; - bcopy(ucred.cr_groups, kp->ki_groups, + kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups, kp->ki_ngroups * sizeof(gid_t)); kp->ki_uid = ucred.cr_uid; if (ucred.cr_prison != NULL) { From brooks at FreeBSD.org Tue Sep 8 19:44:05 2009 From: brooks at FreeBSD.org (Brooks Davis) Date: Tue Sep 8 19:44:11 2009 Subject: svn commit: r195843 - in head: lib/libkvm sys/kern sys/sys In-Reply-To: <20090906044700.5208ba62@gluon.draftnet> References: <200907241503.n6OF3ATP013228@svn.freebsd.org> <20090829201228.00005860@unknown> <20090904221432.GC82231@lor.one-eyed-alien.net> <20090906044700.5208ba62@gluon.draftnet> Message-ID: <20090908194311.GB32690@lor.one-eyed-alien.net> On Sun, Sep 06, 2009 at 04:47:00AM +0100, Bruce Cran wrote: > On Fri, 4 Sep 2009 17:14:32 -0500 > Brooks Davis wrote: > > > On Sat, Aug 29, 2009 at 08:12:28PM +0100, Bruce Cran wrote: > > > On Fri, 24 Jul 2009 15:03:10 +0000 (UTC) > > > Brooks Davis wrote: > > > > > > > Author: brooks > > > > Date: Fri Jul 24 15:03:10 2009 > > > > New Revision: 195843 > > > > URL: http://svn.freebsd.org/changeset/base/195843 > > > > > > > > Log: > > > > Revert the changes to struct kinfo_proc in r194498. Instead, > > > > fill in up to 16 (KI_NGROUPS) values and steal a bit from > > > > ki_cr_flags (all bits currently unused) to indicate overflow with > > > > the new flag KI_CRF_GRP_OVERFLOW. > > > > > > > > This fixes procstat -s. > > > > > > > > Approved by: re (kib) > > > > > > Hi Brooks, > > > > > > This checkin appears to have broken crash dump support: the bcopy in > > > kvm_proc.c crashes when running "ps -ax -M /var/crash/vmcore.x > > > -N /boot/kernel/kernel", apparently because ucred.cr_groups isn't > > > valid. Does it need converted using KVM_READ first? > > > > Sorry for the delay, I believe you are correct we need to use kvm_read > > here instead of the bcopy. Do you still have a core handy you can > > test a patch against? The following should do it. > > The patch has fixed the crash, and data is now returned too. Thanks for testing! I've committed the patch and will MFC in the next week or so. -- Brooks -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090908/df0c8b0d/attachment.pgp From pjd at FreeBSD.org Tue Sep 8 20:06:35 2009 From: pjd at FreeBSD.org (Pawel Jakub Dawidek) Date: Tue Sep 8 20:06:47 2009 Subject: svn commit: r196992 - in head/cddl: compat/opensolaris/include contrib/opensolaris/head Message-ID: <200909082006.n88K6Z3F058431@svn.freebsd.org> Author: pjd Date: Tue Sep 8 20:06:35 2009 New Revision: 196992 URL: http://svn.freebsd.org/changeset/base/196992 Log: Implement __assert() for Solaris-specific code. Until now Solaris code was using Solaris prototype for __assert(), but FreeBSD's implementation. Both take different arguments, so we were either core-dumping in assert() or printing garbage. Reported by: avg MFC after: 1 week Added: head/cddl/compat/opensolaris/include/assert.h (contents, props changed) Deleted: head/cddl/contrib/opensolaris/head/assert.h Added: head/cddl/compat/opensolaris/include/assert.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/compat/opensolaris/include/assert.h Tue Sep 8 20:06:35 2009 (r196992) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2009 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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$ + */ + +#undef assert +#undef _assert + +#ifdef NDEBUG +#define assert(e) ((void)0) +#define _assert(e) ((void)0) +#else +#define _assert(e) assert(e) + +#define assert(e) ((e) ? (void)0 : __assert(#e, __FILE__, __LINE__)) +#endif /* NDEBUG */ + +#ifndef _ASSERT_H_ +#define _ASSERT_H_ +#include +#include + +static __inline void +__assert(const char *expr, const char *file, int line) +{ + + (void)fprintf(stderr, "Assertion failed: (%s), file %s, line %d.\n", + expr, file, line); + abort(); + /* NOTREACHED */ +} +#endif /* !_ASSERT_H_ */ From nwhitehorn at FreeBSD.org Tue Sep 8 20:12:26 2009 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Tue Sep 8 20:12:33 2009 Subject: svn commit: r196993 - head/sys/powerpc/conf Message-ID: <200909082012.n88KCQbh058608@svn.freebsd.org> Author: nwhitehorn Date: Tue Sep 8 20:12:26 2009 New Revision: 196993 URL: http://svn.freebsd.org/changeset/base/196993 Log: Remove some debugging (KTR_VERBOSE) that crept into ppc GENERIC long ago and is present on no other architectures by default. MFC after: 4 days Modified: head/sys/powerpc/conf/GENERIC Modified: head/sys/powerpc/conf/GENERIC ============================================================================== --- head/sys/powerpc/conf/GENERIC Tue Sep 8 20:06:35 2009 (r196992) +++ head/sys/powerpc/conf/GENERIC Tue Sep 8 20:12:26 2009 (r196993) @@ -170,7 +170,3 @@ device pmu device iicbus # I2C bus code device kiic # Keywest I2C -options KTR -options KTR_COMPILE=0xffffffff -#options KTR_MASK=KTR_SIG -options KTR_VERBOSE From phk at FreeBSD.org Tue Sep 8 20:45:40 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue Sep 8 20:45:48 2009 Subject: svn commit: r196994 - in head/sys: amd64/include arm/include i386/include ia64/include mips/include pc98/include powerpc/include sparc64/include sun4v/include sys Message-ID: <200909082045.n88KjenF059468@svn.freebsd.org> Author: phk Date: Tue Sep 8 20:45:40 2009 New Revision: 196994 URL: http://svn.freebsd.org/changeset/base/196994 Log: Get rid of the _NO_NAMESPACE_POLLUTION kludge by creating an architecture specific include file containing the _ALIGN* stuff which needs. Added: head/sys/amd64/include/_align.h (contents, props changed) head/sys/arm/include/_align.h (contents, props changed) head/sys/i386/include/_align.h (contents, props changed) head/sys/ia64/include/_align.h (contents, props changed) head/sys/mips/include/_align.h (contents, props changed) head/sys/pc98/include/_align.h (contents, props changed) head/sys/powerpc/include/_align.h (contents, props changed) head/sys/sparc64/include/_align.h (contents, props changed) head/sys/sun4v/include/_align.h (contents, props changed) Modified: head/sys/amd64/include/param.h head/sys/arm/include/param.h head/sys/i386/include/param.h head/sys/ia64/include/param.h head/sys/mips/include/param.h head/sys/powerpc/include/param.h head/sys/sparc64/include/param.h head/sys/sun4v/include/param.h head/sys/sys/param.h head/sys/sys/socket.h Added: head/sys/amd64/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/amd64/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2002 David E. O'Brien. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Ralph Campbell. + * + * 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. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * @(#)param.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _AMD64_INCLUDE__ALIGN_H_ +#define _AMD64_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is u_long and + * must be cast to any desired pointer type. + */ +#define _ALIGNBYTES (sizeof(long) - 1) +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) + +#endif /* !_AMD64_INCLUDE__ALIGN_H_ */ Modified: head/sys/amd64/include/param.h ============================================================================== --- head/sys/amd64/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/amd64/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -39,26 +39,16 @@ * $FreeBSD$ */ + #ifndef _AMD64_INCLUDE_PARAM_H_ #define _AMD64_INCLUDE_PARAM_H_ -/* - * Machine dependent constants for AMD64. - */ +#include /* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is u_long and - * must be cast to any desired pointer type. + * Machine dependent constants for AMD64. */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES (sizeof(long) - 1) -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) -#endif -#ifndef _NO_NAMESPACE_POLLUTION #define __HAVE_ACPI #define __PCI_REROUTE_INTERRUPT @@ -150,5 +140,4 @@ #define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) -#endif /* !_NO_NAMESPACE_POLLUTION */ #endif /* !_AMD64_INCLUDE_PARAM_H_ */ Added: head/sys/arm/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + +#ifndef _ARM_INCLUDE__ALIGN_H_ +#define _ARM_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES (sizeof(int) - 1) +#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_ARM_INCLUDE__ALIGN_H_ */ Modified: head/sys/arm/include/param.h ============================================================================== --- head/sys/arm/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/arm/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -38,32 +38,20 @@ * $FreeBSD$ */ +#ifndef _ARM_INCLUDE_PARAM_H_ +#define _ARM_INCLUDE_PARAM_H_ + /* * Machine dependent constants for StrongARM */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES (sizeof(int) - 1) -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) -#endif +#include #define STACKALIGNBYTES (8 - 1) #define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES) -#ifndef _NO_NAMESPACE_POLLUTION - #define __PCI_REROUTE_INTERRUPT -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "arm" #endif @@ -136,5 +124,4 @@ #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_ARM_INCLUDE_PARAM_H_ */ Added: head/sys/i386/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/i386/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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. + * 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 REGENTS 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 REGENTS 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. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + +#ifndef _I386_INCLUDE__ALIGN_H_ +#define _I386_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES (sizeof(int) - 1) +#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_I386_INCLUDE__ALIGN_H_ */ Modified: head/sys/i386/include/param.h ============================================================================== --- head/sys/i386/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/i386/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -33,6 +33,11 @@ * $FreeBSD$ */ +#include + +#ifndef _I386_INCLUDE_PARAM_H_ +#define _I386_INCLUDE_PARAM_H_ + /* * Machine dependent constants for Intel 386. */ @@ -49,14 +54,10 @@ #define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) #endif -#ifndef _NO_NAMESPACE_POLLUTION #define __HAVE_ACPI #define __PCI_REROUTE_INTERRUPT -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "i386" #endif @@ -149,5 +150,4 @@ #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_I386_INCLUDE_PARAM_H_ */ Added: head/sys/ia64/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/ia64/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,53 @@ +/* $FreeBSD$ */ +/* From: NetBSD: param.h,v 1.20 1997/09/19 13:52:53 leo Exp */ + +/*- + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Ralph Campbell. + * + * 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. + * 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 REGENTS 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 REGENTS 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. + * + * from: Utah $Hdr: machparam.h 1.11 89/08/14$ + * + * @(#)param.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _IA64_INCLUDE__ALIGN_H_ +#define _IA64_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is u_long and must be cast to + * any desired pointer type. + */ +#define _ALIGNBYTES 15 +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) + +#endif /* !_IA64_INCLUDE__ALIGN_H_ */ Modified: head/sys/ia64/include/param.h ============================================================================== --- head/sys/ia64/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/ia64/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -39,29 +39,18 @@ * @(#)param.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _IA64_INCLUDE_PARAM_H_ +#define _IA64_INCLUDE_PARAM_H_ + /* * Machine dependent constants for the IA64. */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value for all - * data types (int, long, ...). The result is u_long and must be cast to - * any desired pointer type. - */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES 15 -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) -#endif -#ifndef _NO_NAMESPACE_POLLUTION +#include #define __HAVE_ACPI #define __PCI_REROUTE_INTERRUPT -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "ia64" #endif @@ -119,5 +108,4 @@ #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_IA64_INCLUDE_PARAM_H_ */ Added: head/sys/mips/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,53 @@ +/* $OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */ + +/*- + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Ralph Campbell. + * + * 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. + * 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 REGENTS 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 REGENTS 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. + * + * from: Utah Hdr: machparam.h 1.11 89/08/14 + * from: @(#)param.h 8.1 (Berkeley) 6/10/93 + * JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish + * $FreeBSD$ + */ + +#ifndef _MIPS_INCLUDE__ALIGN_H_ +#define _MIPS_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is u_int and must be cast to + * any desired pointer type. + */ +#define _ALIGNBYTES 7 +#define _ALIGN(p) (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) + +#endif /* !_MIPS_INCLUDE__ALIGN_H_ */ Modified: head/sys/mips/include/param.h ============================================================================== --- head/sys/mips/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/mips/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -39,8 +39,10 @@ * $FreeBSD$ */ -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ +#ifndef _MIPS_INCLUDE_PARAM_H_ +#define _MIPS_INCLUDE_PARAM_H_ + +#include #include #ifdef _KERNEL @@ -82,8 +84,6 @@ * data types (int, long, ...). The result is u_int and must be cast to * any desired pointer type. */ -#define _ALIGNBYTES 7 -#define _ALIGN(p) (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) @@ -167,4 +167,4 @@ #define DELAY(n) { register int N = (n); while (--N > 0); } #endif /* !_KERNEL */ -#endif /* !_MACHINE_PARAM_H_ */ +#endif /* !_MIPS_INCLUDE_PARAM_H_ */ Added: head/sys/pc98/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/pc98/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,29 @@ +/*- + * Copyright (c) 2005 TAKAHASHI Yoshihiro. + * 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 Added: head/sys/powerpc/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/powerpc/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + +#ifndef _POWERPC_INCLUDE__ALIGN_H_ +#define _POWERPC_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES (sizeof(int) - 1) +#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_POWERPC_INCLUDE__ALIGN_H_ */ Modified: head/sys/powerpc/include/param.h ============================================================================== --- head/sys/powerpc/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/powerpc/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -38,30 +38,18 @@ * $FreeBSD$ */ +#ifndef _POWERPC_INCLUDE_PARAM_H_ +#define _POWERPC_INCLUDE_PARAM_H_ + /* * Machine dependent constants for PowerPC (32-bit only currently) */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES (sizeof(int) - 1) -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) -#endif - -#ifndef _NO_NAMESPACE_POLLUTION +#include /* Needed to display interrupts on OFW PCI */ #define __PCI_REROUTE_INTERRUPT -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "powerpc" #endif @@ -120,5 +108,4 @@ #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_POWERPC_INCLUDE_PARAM_H_ */ Added: head/sys/sparc64/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sparc64/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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 REGENTS 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 REGENTS 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. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + +#ifndef _SPARC64_INCLUDE__ALIGN_H_ +#define _SPARC64_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES 0xf +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_SPARC64_INCLUDE__ALIGN_H_ */ Modified: head/sys/sparc64/include/param.h ============================================================================== --- head/sys/sparc64/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/sparc64/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -30,29 +30,17 @@ * $FreeBSD$ */ +#ifndef _SPARC64_INCLUDE_PARAM_H_ +#define _SPARC64_INCLUDE_PARAM_H_ + /* * Machine dependent constants for sparc64. */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES 0xf -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) -#endif - -#ifndef _NO_NAMESPACE_POLLUTION +#include #define __PCI_BAR_ZERO_VALID -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - #ifndef MACHINE #define MACHINE "sparc64" #endif @@ -150,5 +138,4 @@ #define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_SPARC64_INCLUDE_PARAM_H_ */ Added: head/sys/sun4v/include/_align.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sun4v/include/_align.h Tue Sep 8 20:45:40 2009 (r196994) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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 REGENTS 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 REGENTS 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. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * $FreeBSD$ + */ + +#ifndef _SUN4V_INCLUDE__ALIGN_H_ +#define _SUN4V_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES 0xf +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_SUN4V_INCLUDE__ALIGN_H_ */ Modified: head/sys/sun4v/include/param.h ============================================================================== --- head/sys/sun4v/include/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/sun4v/include/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -30,26 +30,14 @@ * $FreeBSD$ */ +#ifndef _SUN4V_INCLUDE_PARAM_H_ +#define _SUN4V_INCLUDE_PARAM_H_ + /* * Machine dependent constants for sparc64. */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#ifndef _ALIGNBYTES -#define _ALIGNBYTES 0xf -#endif -#ifndef _ALIGN -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) -#endif - -#ifndef _NO_NAMESPACE_POLLUTION - -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ +#include #ifndef MACHINE #define MACHINE "sun4v" @@ -147,7 +135,4 @@ #define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) #endif /* LOCORE */ - - -#endif /* !_MACHINE_PARAM_H_ */ -#endif /* !_NO_NAMESPACE_POLLUTION */ +#endif /* !_SUN4V_INCLUDE_PARAM_H_ */ Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/sys/param.h Tue Sep 8 20:45:40 2009 (r196994) @@ -112,8 +112,6 @@ #include #endif -#ifndef _NO_NAMESPACE_POLLUTION - #ifndef DEV_BSHIFT #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ #endif @@ -182,8 +180,6 @@ ((off_t)(db) << DEV_BSHIFT) #endif -#endif /* _NO_NAMESPACE_POLLUTION */ - #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ Modified: head/sys/sys/socket.h ============================================================================== --- head/sys/sys/socket.h Tue Sep 8 20:12:26 2009 (r196993) +++ head/sys/sys/socket.h Tue Sep 8 20:45:40 2009 (r196994) @@ -36,9 +36,7 @@ #include #include #include -#define _NO_NAMESPACE_POLLUTION -#include -#undef _NO_NAMESPACE_POLLUTION +#include /* * Definitions related to sockets: types, address families, options. From np at FreeBSD.org Tue Sep 8 21:17:18 2009 From: np at FreeBSD.org (Navdeep Parhar) Date: Tue Sep 8 21:17:24 2009 Subject: svn commit: r196995 - in head/sys: net netinet Message-ID: <200909082117.n88LHIeZ060345@svn.freebsd.org> Author: np Date: Tue Sep 8 21:17:17 2009 New Revision: 196995 URL: http://svn.freebsd.org/changeset/base/196995 Log: Add arp_update_event. This replaces route_arp_update_event, which has not worked since the arp-v2 rewrite. The event handler will be called with the llentry write-locked and can examine la_flags to determine whether the entry is being added or removed. Reviewed by: gnn, kmacy Approved by: gnn (mentor) MFC after: 1 month Modified: head/sys/net/route.h head/sys/netinet/if_ether.c head/sys/netinet/if_ether.h head/sys/netinet/in.c Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Tue Sep 8 20:45:40 2009 (r196994) +++ head/sys/net/route.h Tue Sep 8 21:17:17 2009 (r196995) @@ -435,6 +435,7 @@ int rtrequest1_fib(int, struct rt_addri #include typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *); typedef void (*rtevent_redirect_fn)(void *, struct rtentry *, struct rtentry *, struct sockaddr *); +/* route_arp_update_event is no longer generated; see arp_update_event */ EVENTHANDLER_DECLARE(route_arp_update_event, rtevent_arp_update_fn); EVENTHANDLER_DECLARE(route_redirect_event, rtevent_redirect_fn); #endif Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Tue Sep 8 20:45:40 2009 (r196994) +++ head/sys/netinet/if_ether.c Tue Sep 8 21:17:17 2009 (r196995) @@ -684,6 +684,8 @@ match: (void)memcpy(&la->ll_addr, ar_sha(ah), ifp->if_addrlen); la->la_flags |= LLE_VALID; + EVENTHANDLER_INVOKE(arp_update_event, la); + if (!(la->la_flags & LLE_STATIC)) { la->la_expire = time_uptime + V_arpt_keep; callout_reset(&la->la_timer, hz * V_arpt_keep, Modified: head/sys/netinet/if_ether.h ============================================================================== --- head/sys/netinet/if_ether.h Tue Sep 8 20:45:40 2009 (r196994) +++ head/sys/netinet/if_ether.h Tue Sep 8 21:17:17 2009 (r196995) @@ -117,6 +117,11 @@ int arpresolve(struct ifnet *ifp, struct struct llentry **lle); void arp_ifinit(struct ifnet *, struct ifaddr *); void arp_ifinit2(struct ifnet *, struct ifaddr *, u_char *); + +#include +typedef void (*llevent_arp_update_fn)(void *, struct llentry *); +EVENTHANDLER_DECLARE(arp_update_event, llevent_arp_update_fn); + #endif #endif Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Tue Sep 8 20:45:40 2009 (r196994) +++ head/sys/netinet/in.c Tue Sep 8 21:17:17 2009 (r196995) @@ -1418,6 +1418,7 @@ in_lltable_lookup(struct lltable *llt, u if (!(lle->la_flags & LLE_IFADDR) || (flags & LLE_IFADDR)) { LLE_WLOCK(lle); lle->la_flags = LLE_DELETED; + EVENTHANDLER_INVOKE(arp_update_event, lle); LLE_WUNLOCK(lle); #ifdef DIAGNOSTICS log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); From edwin at FreeBSD.org Wed Sep 9 00:07:05 2009 From: edwin at FreeBSD.org (Edwin Groothuis) Date: Wed Sep 9 00:07:12 2009 Subject: svn commit: r197000 - head/share/zoneinfo Message-ID: <200909090007.n89075V0065884@svn.freebsd.org> Author: edwin Date: Wed Sep 9 00:07:05 2009 New Revision: 197000 URL: http://svn.freebsd.org/changeset/base/197000 Log: MFV of r196998. Import of tzdata2008m Samoa will go in DST on 4 October 2009 till 28 March 2010 Palestine will go back from DST on 4 September 2009 Modified: head/share/zoneinfo/ (props changed) head/share/zoneinfo/asia head/share/zoneinfo/australasia Modified: head/share/zoneinfo/asia ============================================================================== --- head/share/zoneinfo/asia Wed Sep 9 00:03:15 2009 (r196999) +++ head/share/zoneinfo/asia Wed Sep 9 00:07:05 2009 (r197000) @@ -1,5 +1,5 @@ #
-# @(#)asia	8.36
+# @(#)asia	8.40
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -1836,6 +1836,42 @@ Zone	Asia/Karachi	4:28:12 -	LMT	1907
 # http://www.worldtimezone.com/dst_news/dst_news_westbank01.html
 # 
 
+# From Steffen Thorsen (2009-08-31):
+# Palestine's Council of Ministers announced that they will revert back to
+# winter time on Friday, 2009-09-04.
+#
+# One news source:
+# 
+# http://www.safa.ps/ara/?action=showdetail&seid=4158
+# 
+# (Palestinian press agency, Arabic),
+# Google translate: "Decided that the Palestinian government in Ramallah
+# headed by Salam Fayyad, the start of work in time for the winter of
+# 2009, starting on Friday approved the fourth delay Sept. clock sixty
+# minutes per hour as of Friday morning."
+#
+# We are not sure if Gaza will do the same, last year they had a different
+# end date, we will keep this page updated:
+# 
+# http://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html
+# 
+
+# From Alexander Krivenyshev (2009-09-02):
+# Seems that Gaza Strip will go back to Winter Time same date as West Bank.
+#
+# According to Palestinian Ministry Of Interior, West Bank and Gaza Strip plan
+# to change time back to Standard time on September 4, 2009.
+#
+# "Winter time unite the West Bank and Gaza"
+# (from Palestinian National Authority):
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_gazastrip02.html
+# 
+
 # The rules for Egypt are stolen from the `africa' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
@@ -1854,7 +1890,7 @@ Rule Palestine	2006	only	-	Sep	22	0:00	0
 Rule Palestine	2007	only	-	Sep	Thu>=8	2:00	0	-
 Rule Palestine	2008	only	-	Aug	lastFri	2:00	0	-
 Rule Palestine	2009	max	-	Mar	lastFri	0:00	1:00	S
-Rule Palestine	2009	max	-	Sep	lastMon	2:00	0	-
+Rule Palestine	2009	max	-	Sep	Fri>=1	2:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct

Modified: head/share/zoneinfo/australasia
==============================================================================
--- head/share/zoneinfo/australasia	Wed Sep  9 00:03:15 2009	(r196999)
+++ head/share/zoneinfo/australasia	Wed Sep  9 00:07:05 2009	(r197000)
@@ -1,5 +1,5 @@
 # 
-# @(#)australasia	8.12
+# @(#)australasia	8.13
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -443,10 +443,26 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 # http://www.worldtimezone.com/dst_news/dst_news_samoa01.html
 # 
 
+# From Steffen Thorsen (2009-08-27):
+# Samoa's parliament passed the Daylight Saving Bill 2009, and will start 
+# daylight saving time on the first Sunday of October 2009 and end on the 
+# last Sunday of March 2010. We hope that the full text will be published 
+# soon, but we believe that the bill is only valid for 2009-2010. Samoa's 
+# Daylight Saving Act 2009 will be enforced as soon as the Head of State 
+# executes a proclamation publicizing this Act.
+#
+# Some background information here, which will be updated once we have 
+# more details:
+# 
+# http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
+# 
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
-			-11:00	-	WST			# Samoa Time
+			-11:00	-	WST	2009 Oct 4
+			-11:00	1:00	WSDT	2010 Mar 28
+			-11:00	-	WST
 
 # Solomon Is
 # excludes Bougainville, for which see Papua New Guinea
From delphij at FreeBSD.org  Wed Sep  9 01:19:26 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Wed Sep  9 01:19:51 2009
Subject: svn commit: r197009 - head/sys/contrib/x86emu
Message-ID: <200909090119.n891JQV4068056@svn.freebsd.org>

Author: delphij
Date: Wed Sep  9 01:19:26 2009
New Revision: 197009
URL: http://svn.freebsd.org/changeset/base/197009

Log:
  Import x86emu from OpenBSD as of OPENBSD_4_6.

Added:
  head/sys/contrib/x86emu/
     - copied from r197008, vendor-sys/x86emu/dist/
From emaste at FreeBSD.org  Wed Sep  9 03:36:44 2009
From: emaste at FreeBSD.org (Ed Maste)
Date: Wed Sep  9 03:37:14 2009
Subject: svn commit: r197010 - head/sys/net
Message-ID: <200909090336.n893aiiM071255@svn.freebsd.org>

Author: emaste
Date: Wed Sep  9 03:36:43 2009
New Revision: 197010
URL: http://svn.freebsd.org/changeset/base/197010

Log:
  Compare pointer with NULL, not 0.

Modified:
  head/sys/net/if_vlan.c

Modified: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c	Wed Sep  9 01:19:26 2009	(r197009)
+++ head/sys/net/if_vlan.c	Wed Sep  9 03:36:43 2009	(r197010)
@@ -1364,7 +1364,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
 			break;
 		}
 		p = ifunit(vlr.vlr_parent);
-		if (p == 0) {
+		if (p == NULL) {
 			error = ENOENT;
 			break;
 		}
From emaste at FreeBSD.org  Wed Sep  9 03:41:41 2009
From: emaste at FreeBSD.org (Ed Maste)
Date: Wed Sep  9 03:41:47 2009
Subject: svn commit: r197011 - head/sys/dev/aac
Message-ID: <200909090341.n893feU8071377@svn.freebsd.org>

Author: emaste
Date: Wed Sep  9 03:41:40 2009
New Revision: 197011
URL: http://svn.freebsd.org/changeset/base/197011

Log:
  Increase AAC_CMD_TIMEOUT from 30s to 120s to help avoid spurious
  "COMMAND 0x........ TIMEOUT AFTER .. SECONDS" messages.  Any commands
  that get truly stuck will still trigger the warning and the hardware
  health check, just a little bit later.

Modified:
  head/sys/dev/aac/aacvar.h

Modified: head/sys/dev/aac/aacvar.h
==============================================================================
--- head/sys/dev/aac/aacvar.h	Wed Sep  9 03:36:43 2009	(r197010)
+++ head/sys/dev/aac/aacvar.h	Wed Sep  9 03:41:40 2009	(r197011)
@@ -88,7 +88,7 @@
 /*
  * Timeout for normal commands
  */
-#define AAC_CMD_TIMEOUT		30		/* seconds */
+#define AAC_CMD_TIMEOUT		120		/* seconds */
 
 /*
  * Rate at which we periodically check for timed out commands and kick the
From emaste at FreeBSD.org  Wed Sep  9 04:04:10 2009
From: emaste at FreeBSD.org (Ed Maste)
Date: Wed Sep  9 04:04:21 2009
Subject: svn commit: r197016 - head/sys/dev/aac
Message-ID: <200909090404.n894498B072009@svn.freebsd.org>

Author: emaste
Date: Wed Sep  9 04:04:09 2009
New Revision: 197016
URL: http://svn.freebsd.org/changeset/base/197016

Log:
  Whitespace tweak.
  
  Submitted by:	phk, via accidental commit in r196969.

Modified:
  head/sys/dev/aac/aac.c

Modified: head/sys/dev/aac/aac.c
==============================================================================
--- head/sys/dev/aac/aac.c	Wed Sep  9 03:59:46 2009	(r197015)
+++ head/sys/dev/aac/aac.c	Wed Sep  9 04:04:09 2009	(r197016)
@@ -3556,7 +3556,7 @@ aac_supported_features(struct aac_softc 
 	 * associated with the feature in the data field or perform whatever
 	 * action needed indicates in the data field.
 	 */
-	 if (f.feat.fValue == 0) {
+	if (f.feat.fValue == 0) {
 		f.feat.fBits.largeLBA =
 		    (sc->flags & AAC_FLAGS_LBA_64BIT) ? 1 : 0;
 		/* TODO: In the future, add other features state here as well */
From mav at FreeBSD.org  Wed Sep  9 04:36:57 2009
From: mav at FreeBSD.org (Alexander Motin)
Date: Wed Sep  9 04:37:03 2009
Subject: svn commit: r197017 - head/sys/dev/sound/pci/hda
Message-ID: <200909090436.n894auVG072643@svn.freebsd.org>

Author: mav
Date: Wed Sep  9 04:36:56 2009
New Revision: 197017
URL: http://svn.freebsd.org/changeset/base/197017

Log:
  Add Intel 82801JD (one more ICH10) HDA controller ID.
  
  Submitted by:	yongari

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Wed Sep  9 04:04:09 2009	(r197016)
+++ head/sys/dev/sound/pci/hda/hdac.c	Wed Sep  9 04:36:56 2009	(r197017)
@@ -146,7 +146,8 @@ SND_DECLARE_FILE("$FreeBSD$");
 #define HDA_INTEL_82801G	HDA_MODEL_CONSTRUCT(INTEL, 0x27d8)
 #define HDA_INTEL_82801H	HDA_MODEL_CONSTRUCT(INTEL, 0x284b)
 #define HDA_INTEL_82801I	HDA_MODEL_CONSTRUCT(INTEL, 0x293e)
-#define HDA_INTEL_82801J	HDA_MODEL_CONSTRUCT(INTEL, 0x3a3e)
+#define HDA_INTEL_82801JI	HDA_MODEL_CONSTRUCT(INTEL, 0x3a3e)
+#define HDA_INTEL_82801JD	HDA_MODEL_CONSTRUCT(INTEL, 0x3a6e)
 #define HDA_INTEL_PCH		HDA_MODEL_CONSTRUCT(INTEL, 0x3b56)
 #define HDA_INTEL_SCH		HDA_MODEL_CONSTRUCT(INTEL, 0x811b)
 #define HDA_INTEL_ALL		HDA_MODEL_CONSTRUCT(INTEL, 0xffff)
@@ -486,7 +487,8 @@ static const struct {
 	{ HDA_INTEL_82801G,  "Intel 82801G",	0 },
 	{ HDA_INTEL_82801H,  "Intel 82801H",	0 },
 	{ HDA_INTEL_82801I,  "Intel 82801I",	0 },
-	{ HDA_INTEL_82801J,  "Intel 82801J",	0 },
+	{ HDA_INTEL_82801JI, "Intel 82801JI",	0 },
+	{ HDA_INTEL_82801JD, "Intel 82801JD",	0 },
 	{ HDA_INTEL_PCH,     "Intel PCH",	0 },
 	{ HDA_INTEL_SCH,     "Intel SCH",	0 },
 	{ HDA_NVIDIA_MCP51,  "NVidia MCP51",	HDAC_NO_MSI },
From mav at FreeBSD.org  Wed Sep  9 04:48:42 2009
From: mav at FreeBSD.org (Alexander Motin)
Date: Wed Sep  9 04:48:48 2009
Subject: svn commit: r197018 - head/sys/dev/sound/pci/hda
Message-ID: <200909090448.n894mfWi072943@svn.freebsd.org>

Author: mav
Date: Wed Sep  9 04:48:41 2009
New Revision: 197018
URL: http://svn.freebsd.org/changeset/base/197018

Log:
  Add NVidia MCP89 HDA controller IDs.

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Wed Sep  9 04:36:56 2009	(r197017)
+++ head/sys/dev/sound/pci/hda/hdac.c	Wed Sep  9 04:48:41 2009	(r197018)
@@ -172,6 +172,10 @@ SND_DECLARE_FILE("$FreeBSD$");
 #define HDA_NVIDIA_MCP79_2	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0ac1)
 #define HDA_NVIDIA_MCP79_3	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0ac2)
 #define HDA_NVIDIA_MCP79_4	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0ac3)
+#define HDA_NVIDIA_MCP89_1	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0d94)
+#define HDA_NVIDIA_MCP89_2	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0d95)
+#define HDA_NVIDIA_MCP89_3	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0d96)
+#define HDA_NVIDIA_MCP89_4	HDA_MODEL_CONSTRUCT(NVIDIA, 0x0d97)
 #define HDA_NVIDIA_ALL		HDA_MODEL_CONSTRUCT(NVIDIA, 0xffff)
 
 /* ATI */
@@ -509,6 +513,10 @@ static const struct {
 	{ HDA_NVIDIA_MCP79_2, "NVidia MCP79",	0 },
 	{ HDA_NVIDIA_MCP79_3, "NVidia MCP79",	0 },
 	{ HDA_NVIDIA_MCP79_4, "NVidia MCP79",	0 },
+	{ HDA_NVIDIA_MCP89_1, "NVidia MCP89",	0 },
+	{ HDA_NVIDIA_MCP89_2, "NVidia MCP89",	0 },
+	{ HDA_NVIDIA_MCP89_3, "NVidia MCP89",	0 },
+	{ HDA_NVIDIA_MCP89_4, "NVidia MCP89",	0 },
 	{ HDA_ATI_SB450,     "ATI SB450",	0 },
 	{ HDA_ATI_SB600,     "ATI SB600",	0 },
 	{ HDA_ATI_RS600,     "ATI RS600",	0 },
From delphij at FreeBSD.org  Wed Sep  9 05:53:26 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Wed Sep  9 05:53:39 2009
Subject: svn commit: r197019 - in head/sys: conf contrib/x86emu modules
	modules/x86emu sys
Message-ID: <200909090553.n895rQhv074197@svn.freebsd.org>

Author: delphij
Date: Wed Sep  9 05:53:26 2009
New Revision: 197019
URL: http://svn.freebsd.org/changeset/base/197019

Log:
   - Port x86emu to FreeBSD.
   - Connect x86emu to build.
  
  Tested with:	make universe
  Submitted by:	swell.k at gmail com

Added:
  head/sys/modules/x86emu/
  head/sys/modules/x86emu/Makefile   (contents, props changed)
Modified:
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/sys/contrib/x86emu/x86emu.c   (contents, props changed)
  head/sys/contrib/x86emu/x86emu.h   (contents, props changed)
  head/sys/contrib/x86emu/x86emu_util.c   (contents, props changed)
  head/sys/modules/Makefile
  head/sys/sys/param.h

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/conf/NOTES	Wed Sep  9 05:53:26 2009	(r197019)
@@ -2756,3 +2756,6 @@ options 	AAC_DEBUG	# Debugging levels:
 ##options 	BKTR_ALLOC_PAGES=(217*4+1)
 options 	BROOKTREE_ALLOC_PAGES=(217*4+1)
 options 	MAXFILES=999
+
+# x86 real mode emulator
+options		X86EMU

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/conf/files	Wed Sep  9 05:53:26 2009	(r197019)
@@ -2826,4 +2826,6 @@ dev/xen/netfront/netfront.c	optional xen
 dev/xen/xenpci/xenpci.c		optional xenpci
 dev/xen/xenpci/evtchn.c         optional xenpci
 dev/xen/xenpci/machine_reboot.c optional xenpci
+contrib/x86emu/x86emu.c		optional x86emu
+contrib/x86emu/x86emu_util.c	optional x86emu
 

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/conf/options	Wed Sep  9 05:53:26 2009	(r197019)
@@ -836,3 +836,5 @@ SND_FEEDER_FULL_MULTIFORMAT	opt_snd.h
 SND_FEEDER_RATE_HP	opt_snd.h
 SND_PCM_64		opt_snd.h
 SND_OLDSTEREO		opt_snd.h
+
+X86EMU

Modified: head/sys/contrib/x86emu/x86emu.c
==============================================================================
--- head/sys/contrib/x86emu/x86emu.c	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/contrib/x86emu/x86emu.c	Wed Sep  9 05:53:26 2009	(r197019)
@@ -1,5 +1,6 @@
 /*	$OpenBSD: x86emu.c,v 1.4 2009/06/18 14:19:21 pirofti Exp $	*/
 /*	$NetBSD: x86emu.c,v 1.7 2009/02/03 19:26:29 joerg Exp $	*/
+/*	$FreeBSD$	*/
 
 /*
  *
@@ -32,8 +33,12 @@
  *
  */
 
-#include 
-#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
 
 static void 	x86emu_intr_raise (struct x86emu *, uint8_t type);
 
@@ -45,7 +50,7 @@ static uint8_t	fetch_byte_imm (struct x8
 static uint16_t	fetch_word_imm (struct x86emu *);
 static uint32_t	fetch_long_imm (struct x86emu *);
 static uint8_t	fetch_data_byte (struct x86emu *, uint32_t offset);
-static uint8_t	fetch_byte (struct x86emu *, uint segment, uint32_t offset);
+static uint8_t	fetch_byte (struct x86emu *, u_int segment, uint32_t offset);
 static uint16_t	fetch_data_word (struct x86emu *, uint32_t offset);
 static uint16_t	fetch_word (struct x86emu *, uint32_t segment, uint32_t offset);
 static uint32_t	fetch_data_long (struct x86emu *, uint32_t offset);
@@ -227,13 +232,8 @@ x86emu_exec(struct x86emu *emu)
 {
 	emu->x86.intr = 0;
 
-#ifdef _KERNEL
-	if (setjmp(&emu->exec_state))
-		return;
-#else
 	if (setjmp(emu->exec_state))
 		return;
-#endif
 
 	for (;;) {
 		if (emu->x86.intr) {
@@ -282,11 +282,7 @@ x86emu_exec_intr(struct x86emu *emu, uin
 void 
 x86emu_halt_sys(struct x86emu *emu)
 {
-#ifdef _KERNEL
-	longjmp(&emu->exec_state);
-#else
 	longjmp(emu->exec_state, 1);
-#endif
 }
 
 /*
@@ -8339,3 +8335,32 @@ pop_long(struct x86emu *emu)
 	emu->x86.R_SP += 4;
 	return res;
 }
+
+static int
+x86emu_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int err = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		break;
+
+	case MOD_UNLOAD:
+		break;
+
+	default:
+		err = ENOTSUP;
+		break;
+
+	}
+	return (err);
+}
+
+static moduledata_t x86emu_mod = {
+	"x86emu",
+	x86emu_modevent,
+	NULL,
+};
+
+DECLARE_MODULE(x86emu, x86emu_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
+MODULE_VERSION(x86emu, 1);

Modified: head/sys/contrib/x86emu/x86emu.h
==============================================================================
--- head/sys/contrib/x86emu/x86emu.h	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/contrib/x86emu/x86emu.h	Wed Sep  9 05:53:26 2009	(r197019)
@@ -1,5 +1,6 @@
 /*	$NetBSD: x86emu.h,v 1.1 2007/12/01 20:14:10 joerg Exp $	*/
 /*	$OpenBSD: x86emu.h,v 1.3 2009/06/06 03:45:05 matthieu Exp $ */
+/*	$FreeBSD$	*/
 
 /****************************************************************************
 *
@@ -40,6 +41,7 @@
 
 #ifdef _KERNEL
 #include 
+#include 
 #else
 #include 
 #endif
@@ -140,11 +142,7 @@ struct x86emu {
 	void        		*sys_private;
 	struct x86emu_regs	x86;
 
-#ifdef _KERNEL
-	label_t		exec_state;
-#else
 	jmp_buf		exec_state;
-#endif
 
 	uint64_t	cur_cycles;
 
@@ -179,7 +177,7 @@ void	x86emu_init_default(struct x86emu *
 void 	x86emu_exec(struct x86emu *);
 void	x86emu_exec_call(struct x86emu *, uint16_t, uint16_t);
 void	x86emu_exec_intr(struct x86emu *, uint8_t);
-void 	x86emu_halt_sys(struct x86emu *) __dead;
+void 	x86emu_halt_sys(struct x86emu *) __dead2;
 
 __END_DECLS
 

Modified: head/sys/contrib/x86emu/x86emu_util.c
==============================================================================
--- head/sys/contrib/x86emu/x86emu_util.c	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/contrib/x86emu/x86emu_util.c	Wed Sep  9 05:53:26 2009	(r197019)
@@ -1,5 +1,6 @@
 /*	$OpenBSD: x86emu_util.c,v 1.5 2009/06/18 14:19:21 pirofti Exp $	*/
 /*	$NetBSD: x86emu_util.c,v 1.2 2007/12/04 17:32:22 joerg Exp $	*/
+/*	$FreeBSD$	*/
 
 /*
  *
@@ -35,8 +36,8 @@
 #include 
 #include 
 
-#include 
-#include 
+#include 
+#include 
 
 
 
@@ -82,9 +83,9 @@ rdw(struct x86emu *emu, uint32_t addr)
 		    ((*(a + 1) << 8) & 0xff00);
 		return r;
 	} else
-		return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+		return le32toh(*(u_int32_t *)(emu->mem_base + addr));
 #else
-	return letoh16(*(u_int16_t *)(emu->mem_base + addr));
+	return le16toh(*(u_int16_t *)(emu->mem_base + addr));
 #endif
 }
 
@@ -113,9 +114,9 @@ rdl(struct x86emu *emu, uint32_t addr)
 		    ((*(a + 3) << 24) & 0xff000000);
 		return r;
 	} else
-		return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+		return le32toh(*(u_int32_t *)(emu->mem_base + addr));
 #else
-	return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+	return le32toh(*(u_int32_t *)(emu->mem_base + addr));
 #endif
 }
 

Modified: head/sys/modules/Makefile
==============================================================================
--- head/sys/modules/Makefile	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/modules/Makefile	Wed Sep  9 05:53:26 2009	(r197019)
@@ -298,6 +298,7 @@ SUBDIR=	${_3dfx} \
 	wlan_xauth \
 	${_wpi} \
 	${_wpifw} \
+	x86emu \
 	${_xe} \
 	xfs \
 	xl \

Added: head/sys/modules/x86emu/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/modules/x86emu/Makefile	Wed Sep  9 05:53:26 2009	(r197019)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH:	${.CURDIR}/../../contrib/x86emu
+
+KMOD=	x86emu
+SRCS=	x86emu.c x86emu_util.c
+
+.include 

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h	Wed Sep  9 04:48:41 2009	(r197018)
+++ head/sys/sys/param.h	Wed Sep  9 05:53:26 2009	(r197019)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 900000	/* Master, propagated to newvers */
+#define __FreeBSD_version 900001	/* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include 
From imp at FreeBSD.org  Wed Sep  9 06:49:50 2009
From: imp at FreeBSD.org (Warner Losh)
Date: Wed Sep  9 06:49:56 2009
Subject: svn commit: r197020 - head/sys/sys
Message-ID: <200909090649.n896nngA075336@svn.freebsd.org>

Author: imp
Date: Wed Sep  9 06:49:49 2009
New Revision: 197020
URL: http://svn.freebsd.org/changeset/base/197020

Log:
  kern_execve.c hasn't been around in ages, so update the file(s) where
  a_magic is used instead of the a_midmag....
  
  # maybe we can retire this hack soon...

Modified:
  head/sys/sys/imgact_aout.h

Modified: head/sys/sys/imgact_aout.h
==============================================================================
--- head/sys/sys/imgact_aout.h	Wed Sep  9 05:53:26 2009	(r197019)
+++ head/sys/sys/imgact_aout.h	Wed Sep  9 06:49:49 2009	(r197020)
@@ -119,7 +119,7 @@ struct exec {
      uint32_t	a_trsize;	/* text relocation size */
      uint32_t	a_drsize;	/* data relocation size */
 };
-#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
+#define a_magic a_midmag /* XXX Hack to work with imgact_{aout,gzip}.c */
 
 /* a_magic */
 #define	OMAGIC		0407	/* old impure format */
From delphij at FreeBSD.org  Wed Sep  9 07:42:05 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Wed Sep  9 07:42:12 2009
Subject: svn commit: r197021 - head/sys/dev/dpms
Message-ID: <200909090742.n897g5A4076994@svn.freebsd.org>

Author: delphij
Date: Wed Sep  9 07:42:04 2009
New Revision: 197021
URL: http://svn.freebsd.org/changeset/base/197021

Log:
  Add a directory to hold dpms stuff separated from i386/isa/.

Added:
  head/sys/dev/dpms/
From delphij at FreeBSD.org  Wed Sep  9 07:45:09 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Wed Sep  9 07:45:16 2009
Subject: svn commit: r197022 - in head/sys/dev: dpms fb
Message-ID: <200909090745.n897j876077117@svn.freebsd.org>

Author: delphij
Date: Wed Sep  9 07:45:08 2009
New Revision: 197022
URL: http://svn.freebsd.org/changeset/base/197022

Log:
  Copy the following files to new places, a subsequent commit would remove
  them from the old place.  This commit necessary so that the tree would not
  enter a broken state.
  
  	sys/i386/isa/vesa.c -> dev/fb/vesa.c
  	sys/i386/include/pc/vesa.h -> dev/fb/vesa.h
  	sys/i386/isa/dpms.c -> dev/dpms/dpms.c

Added:
  head/sys/dev/dpms/dpms.c
     - copied unchanged from r197019, head/sys/i386/isa/dpms.c
  head/sys/dev/fb/vesa.c
     - copied unchanged from r197019, head/sys/i386/isa/vesa.c
  head/sys/dev/fb/vesa.h
     - copied unchanged from r197019, head/sys/i386/include/pc/vesa.h

Copied: head/sys/dev/dpms/dpms.c (from r197019, head/sys/i386/isa/dpms.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/dpms/dpms.c	Wed Sep  9 07:45:08 2009	(r197022, copy of r197019, head/sys/i386/isa/dpms.c)
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 2008 Yahoo!, Inc.
+ * All rights reserved.
+ * Written by: John Baldwin 
+ *
+ * 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.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 2004 Benjamin Close 
+ * 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.
+ */
+
+/*
+ * Support for managing the display via DPMS for suspend/resume.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/*
+ * VESA DPMS States 
+ */
+#define DPMS_ON		0x00
+#define DPMS_STANDBY	0x01
+#define DPMS_SUSPEND	0x02
+#define DPMS_OFF	0x04
+#define DPMS_REDUCEDON	0x08
+
+#define	VBE_DPMS_FUNCTION	0x4F10
+#define	VBE_DPMS_GET_SUPPORTED_STATES 0x00
+#define	VBE_DPMS_GET_STATE	0x02
+#define	VBE_DPMS_SET_STATE	0x01
+#define VBE_MAJORVERSION_MASK	0x0F
+#define VBE_MINORVERSION_MASK	0xF0
+
+struct dpms_softc {
+	int	dpms_supported_states;
+	int	dpms_initial_state;
+};
+
+static int	dpms_attach(device_t);
+static int	dpms_detach(device_t);
+static int	dpms_get_supported_states(int *);
+static int	dpms_get_current_state(int *);
+static void	dpms_identify(driver_t *, device_t);
+static int	dpms_probe(device_t);
+static int	dpms_resume(device_t);
+static int	dpms_set_state(int);
+static int	dpms_suspend(device_t);
+
+static device_method_t dpms_methods[] = {
+	DEVMETHOD(device_identify,	dpms_identify),
+	DEVMETHOD(device_probe,		dpms_probe),
+	DEVMETHOD(device_attach,	dpms_attach),
+	DEVMETHOD(device_detach,	dpms_detach),
+	DEVMETHOD(device_suspend,	dpms_suspend),
+	DEVMETHOD(device_resume,	dpms_resume),
+	{ 0, 0 }
+};
+
+static driver_t dpms_driver = {
+	"dpms",
+	dpms_methods,
+	sizeof(struct dpms_softc),
+};
+
+static devclass_t dpms_devclass;
+
+DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL);
+
+static void
+dpms_identify(driver_t *driver, device_t parent)
+{
+
+	/*
+	 * XXX: The DPMS VBE only allows for manipulating a single
+	 * monitor, but we don't know which one.  Just attach to the
+	 * first vgapci(4) device we encounter and hope it is the
+	 * right one.
+	 */
+	if (devclass_get_device(dpms_devclass, 0) == NULL)
+		device_add_child(parent, "dpms", 0);
+}
+
+static int
+dpms_probe(device_t dev)
+{
+	int error, states;
+
+	error = dpms_get_supported_states(&states);
+	if (error)
+		return (error);
+	device_set_desc(dev, "DPMS suspend/resume");
+	device_quiet(dev);
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+dpms_attach(device_t dev)
+{
+	struct dpms_softc *sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	error = dpms_get_supported_states(&sc->dpms_supported_states);
+	if (error)
+		return (error);
+	error = dpms_get_current_state(&sc->dpms_initial_state);
+	return (error);
+}
+
+static int
+dpms_detach(device_t dev)
+{
+
+	return (0);
+}
+
+static int
+dpms_suspend(device_t dev)
+{
+
+	dpms_set_state(DPMS_OFF);
+	return (0);
+}
+
+static int
+dpms_resume(device_t dev)
+{
+	struct dpms_softc *sc;
+
+	sc = device_get_softc(dev);
+	dpms_set_state(sc->dpms_initial_state);
+	return (0);
+}
+
+static int
+dpms_call_bios(int subfunction, int *bh)
+{
+	struct vm86frame vmf;
+	int error;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_ax = VBE_DPMS_FUNCTION;
+	vmf.vmf_bl = subfunction;
+	vmf.vmf_bh = *bh;
+	vmf.vmf_es = 0;
+	vmf.vmf_di = 0;
+	error = vm86_intcall(0x10, &vmf);
+	if (error == 0 && (vmf.vmf_eax & 0xffff) != 0x004f)
+		error = ENXIO;
+	if (error == 0)
+		*bh = vmf.vmf_bh;
+	return (error);
+}
+
+static int
+dpms_get_supported_states(int *states)
+{
+
+	*states = 0;
+	return (dpms_call_bios(VBE_DPMS_GET_SUPPORTED_STATES, states));
+}
+
+static int
+dpms_get_current_state(int *state)
+{
+
+	*state = 0;
+	return (dpms_call_bios(VBE_DPMS_GET_STATE, state));
+}
+
+static int
+dpms_set_state(int state)
+{
+
+	return (dpms_call_bios(VBE_DPMS_SET_STATE, &state));
+}

Copied: head/sys/dev/fb/vesa.c (from r197019, head/sys/i386/isa/vesa.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/fb/vesa.c	Wed Sep  9 07:45:08 2009	(r197022, copy of r197019, head/sys/i386/isa/vesa.c)
@@ -0,0 +1,1696 @@
+/*-
+ * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith
+ * 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 as
+ *    the first lines of this file unmodified.
+ * 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 AUTHORS ``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 AUTHORS 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 "opt_vga.h"
+#include "opt_vesa.h"
+
+#ifndef VGA_NO_MODE_CHANGE
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#ifndef __i386__
+#include 
+#else
+#include 
+#endif
+
+#define	VESA_VIA_CLE266		"VIA CLE266\r\n"
+
+#ifndef VESA_DEBUG
+#define VESA_DEBUG	0
+#endif
+
+/* VESA video adapter state buffer stub */
+struct adp_state {
+	int		sig;
+#define V_STATE_SIG	0x61736576
+	u_char		regs[1];
+};
+typedef struct adp_state adp_state_t;
+
+/* VESA video adapter */
+static video_adapter_t *vesa_adp = NULL;
+static int vesa_state_buf_size = 0;
+#define VESA_VM86_BUFSIZE	(3 * PAGE_SIZE)
+static void *vesa_vm86_buf;
+
+/* VESA functions */
+#if 0
+static int			vesa_nop(void);
+#endif
+static int			vesa_error(void);
+static vi_probe_t		vesa_probe;
+static vi_init_t		vesa_init;
+static vi_get_info_t		vesa_get_info;
+static vi_query_mode_t		vesa_query_mode;
+static vi_set_mode_t		vesa_set_mode;
+static vi_save_font_t		vesa_save_font;
+static vi_load_font_t		vesa_load_font;
+static vi_show_font_t		vesa_show_font;
+static vi_save_palette_t	vesa_save_palette;
+static vi_load_palette_t	vesa_load_palette;
+static vi_set_border_t		vesa_set_border;
+static vi_save_state_t		vesa_save_state;
+static vi_load_state_t		vesa_load_state;
+static vi_set_win_org_t		vesa_set_origin;
+static vi_read_hw_cursor_t	vesa_read_hw_cursor;
+static vi_set_hw_cursor_t	vesa_set_hw_cursor;
+static vi_set_hw_cursor_shape_t	vesa_set_hw_cursor_shape;
+static vi_blank_display_t	vesa_blank_display;
+static vi_mmap_t		vesa_mmap;
+static vi_ioctl_t		vesa_ioctl;
+static vi_clear_t		vesa_clear;
+static vi_fill_rect_t		vesa_fill_rect;
+static vi_bitblt_t		vesa_bitblt;
+static vi_diag_t		vesa_diag;
+static int			vesa_bios_info(int level);
+static struct vm86context	vesa_vmcontext;
+
+static video_switch_t vesavidsw = {
+	vesa_probe,
+	vesa_init,
+	vesa_get_info,
+	vesa_query_mode,
+	vesa_set_mode,
+	vesa_save_font,
+	vesa_load_font,
+	vesa_show_font,
+	vesa_save_palette,
+	vesa_load_palette,
+	vesa_set_border,
+	vesa_save_state,
+	vesa_load_state,
+	vesa_set_origin,
+	vesa_read_hw_cursor,
+	vesa_set_hw_cursor,
+	vesa_set_hw_cursor_shape,
+	vesa_blank_display,
+	vesa_mmap,
+	vesa_ioctl,
+	vesa_clear,
+	vesa_fill_rect,
+	vesa_bitblt,
+	vesa_error,
+	vesa_error,
+	vesa_diag,
+};
+
+static video_switch_t *prevvidsw;
+
+/* VESA BIOS video modes */
+#define VESA_MAXMODES	64
+#define EOT		(-1)
+#define NA		(-2)
+
+#define MODE_TABLE_DELTA 8
+
+static int vesa_vmode_max = 0;
+static video_info_t vesa_vmode_empty = { EOT };
+static video_info_t *vesa_vmode = &vesa_vmode_empty;
+
+static int vesa_init_done = FALSE;
+static int has_vesa_bios = FALSE;
+static struct vesa_info *vesa_adp_info = NULL;
+static u_int16_t *vesa_vmodetab = NULL;
+static char *vesa_oemstr = NULL;
+static char *vesa_venderstr = NULL;
+static char *vesa_prodstr = NULL;
+static char *vesa_revstr = NULL;
+
+/* local macros and functions */
+#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
+
+static int int10_set_mode(int mode);
+static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode);
+static int vesa_bios_set_mode(int mode);
+static int vesa_bios_get_dac(void);
+static int vesa_bios_set_dac(int bits);
+static int vesa_bios_save_palette(int start, int colors, u_char *palette,
+				  int bits);
+static int vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g,
+				   u_char *b, int bits);
+static int vesa_bios_load_palette(int start, int colors, u_char *palette,
+				  int bits);
+#ifdef notyet
+static int vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g,
+				   u_char *b, int bits);
+#endif
+#define STATE_SIZE	0
+#define STATE_SAVE	1
+#define STATE_LOAD	2
+#define STATE_HW	(1<<0)
+#define STATE_DATA	(1<<1)
+#define STATE_DAC	(1<<2)
+#define STATE_REG	(1<<3)
+#define STATE_MOST	(STATE_HW | STATE_DATA | STATE_REG)
+#define STATE_ALL	(STATE_HW | STATE_DATA | STATE_DAC | STATE_REG)
+static int vesa_bios_state_buf_size(void);
+static int vesa_bios_save_restore(int code, void *p, size_t size);
+static int vesa_bios_get_line_length(void);
+static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines);
+#if 0
+static int vesa_bios_get_start(int *x, int *y);
+#endif
+static int vesa_bios_set_start(int x, int y);
+static int vesa_map_gen_mode_num(int type, int color, int mode);
+static int vesa_translate_flags(u_int16_t vflags);
+static int vesa_translate_mmodel(u_int8_t vmodel);
+static void *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, 
+			  u_char *buf);
+static int vesa_bios_init(void);
+static void vesa_clear_modes(video_info_t *info, int color);
+static vm_offset_t vesa_map_buffer(u_int paddr, size_t size);
+static void vesa_unmap_buffer(vm_offset_t vaddr, size_t size);
+
+#if 0
+static int vesa_get_origin(video_adapter_t *adp, off_t *offset);
+#endif
+
+static void
+dump_buffer(u_char *buf, size_t len)
+{
+    int i;
+
+    for(i = 0; i < len;) {
+	printf("%02x ", buf[i]);
+	if ((++i % 16) == 0)
+	    printf("\n");
+    }
+}
+
+/* INT 10 BIOS calls */
+static int
+int10_set_mode(int mode)
+{
+	struct vm86frame vmf;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x0000 | mode;
+	vm86_intcall(0x10, &vmf);
+	return 0;
+}
+
+/* VESA BIOS calls */
+static int
+vesa_bios_get_mode(int mode, struct vesa_mode *vmode)
+{
+	struct vm86frame vmf;
+	u_char *buf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f01; 
+	vmf.vmf_ecx = mode;
+	buf = vesa_vm86_buf;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 1;
+	bcopy(buf, vmode, sizeof(*vmode));
+	return 0;
+}
+
+static int
+vesa_bios_set_mode(int mode)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f02;
+	vmf.vmf_ebx = mode;
+	err = vm86_intcall(0x10, &vmf);
+	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+}
+
+static int
+vesa_bios_get_dac(void)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f08;
+	vmf.vmf_ebx = 1;	/* get DAC width */
+	err = vm86_intcall(0x10, &vmf);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 6;	/* XXX */
+	return ((vmf.vmf_ebx >> 8) & 0x00ff);
+}
+
+static int
+vesa_bios_set_dac(int bits)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f08;
+	vmf.vmf_ebx = (bits << 8);
+	err = vm86_intcall(0x10, &vmf);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 6;	/* XXX */
+	return ((vmf.vmf_ebx >> 8) & 0x00ff);
+}
+
+static int
+vesa_bios_save_palette(int start, int colors, u_char *palette, int bits)
+{
+	struct vm86frame vmf;
+	u_char *p;
+	int err;
+	int i;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f09;
+	vmf.vmf_ebx = 1;	/* get primary palette data */
+	vmf.vmf_ecx = colors;
+	vmf.vmf_edx = start;
+	p = vesa_vm86_buf;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 1;
+
+	bits = 8 - bits;
+	for (i = 0; i < colors; ++i) {
+		palette[i*3]     = p[i*4 + 2] << bits;
+		palette[i*3 + 1] = p[i*4 + 1] << bits;
+		palette[i*3 + 2] = p[i*4] << bits;
+	}
+	return 0;
+}
+
+static int
+vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
+			int bits)
+{
+	struct vm86frame vmf;
+	u_char *p;
+	int err;
+	int i;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f09;
+	vmf.vmf_ebx = 1;	/* get primary palette data */
+	vmf.vmf_ecx = colors;
+	vmf.vmf_edx = start;
+	p = vesa_vm86_buf;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 1;
+
+	bits = 8 - bits;
+	for (i = 0; i < colors; ++i) {
+		r[i] = p[i*4 + 2] << bits;
+		g[i] = p[i*4 + 1] << bits;
+		b[i] = p[i*4] << bits;
+	}
+	return 0;
+}
+
+static int
+vesa_bios_load_palette(int start, int colors, u_char *palette, int bits)
+{
+	struct vm86frame vmf;
+	u_char *p;
+	int err;
+	int i;
+
+	p = vesa_vm86_buf;
+	bits = 8 - bits;
+	for (i = 0; i < colors; ++i) {
+		p[i*4]	   = palette[i*3 + 2] >> bits;
+		p[i*4 + 1] = palette[i*3 + 1] >> bits;
+		p[i*4 + 2] = palette[i*3] >> bits;
+		p[i*4 + 3] = 0;
+	}
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f09;
+	vmf.vmf_ebx = 0;	/* set primary palette data */
+	vmf.vmf_ecx = colors;
+	vmf.vmf_edx = start;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+}
+
+#ifdef notyet
+static int
+vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
+			int bits)
+{
+	struct vm86frame vmf;
+	u_char *p;
+	int err;
+	int i;
+
+	p = vesa_vm86_buf;
+	bits = 8 - bits;
+	for (i = 0; i < colors; ++i) {
+		p[i*4]	   = b[i] >> bits;
+		p[i*4 + 1] = g[i] >> bits;
+		p[i*4 + 2] = r[i] >> bits;
+		p[i*4 + 3] = 0;
+	}
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f09;
+	vmf.vmf_ebx = 0;	/* set primary palette data */
+	vmf.vmf_ecx = colors;
+	vmf.vmf_edx = start;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+}
+#endif
+
+static int
+vesa_bios_state_buf_size(void)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f04; 
+	vmf.vmf_ecx = STATE_ALL;
+	vmf.vmf_edx = STATE_SIZE;
+	err = vm86_intcall(0x10, &vmf);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 0;
+	return vmf.vmf_bx*64;
+}
+
+static int
+vesa_bios_save_restore(int code, void *p, size_t size)
+{
+	struct vm86frame vmf;
+	u_char *buf;
+	int err;
+
+	if (size > VESA_VM86_BUFSIZE)
+		return (1);
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f04; 
+	vmf.vmf_ecx = STATE_ALL;
+	vmf.vmf_edx = code;	/* STATE_SAVE/STATE_LOAD */
+	buf = vesa_vm86_buf;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_bx);
+	bcopy(p, buf, size);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	bcopy(buf, p, size);
+	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+}
+
+static int
+vesa_bios_get_line_length(void)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f06; 
+	vmf.vmf_ebx = 1;	/* get scan line length */
+	err = vm86_intcall(0x10, &vmf);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return -1;
+	return vmf.vmf_bx;	/* line length in bytes */
+}
+
+static int
+vesa_bios_set_line_length(int pixel, int *bytes, int *lines)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f06; 
+	vmf.vmf_ebx = 0;	/* set scan line length in pixel */
+	vmf.vmf_ecx = pixel;
+	err = vm86_intcall(0x10, &vmf);
+#if VESA_DEBUG > 1
+	printf("bx:%d, cx:%d, dx:%d\n", vmf.vmf_bx, vmf.vmf_cx, vmf.vmf_dx); 
+#endif
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 1;
+	if (bytes)
+		*bytes = vmf.vmf_bx;
+	if (lines)
+		*lines = vmf.vmf_dx;
+	return 0;
+}
+
+#if 0
+static int
+vesa_bios_get_start(int *x, int *y)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f07; 
+	vmf.vmf_ebx = 1;	/* get display start */
+	err = vm86_intcall(0x10, &vmf);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+		return 1;
+	*x = vmf.vmf_cx;
+	*y = vmf.vmf_dx;
+	return 0;
+}
+#endif
+
+static int
+vesa_bios_set_start(int x, int y)
+{
+	struct vm86frame vmf;
+	int err;
+
+	bzero(&vmf, sizeof(vmf));
+	vmf.vmf_eax = 0x4f07; 
+	vmf.vmf_ebx = 0x80;	/* set display start */
+	vmf.vmf_edx = y;
+	vmf.vmf_ecx = x;
+	err = vm86_intcall(0x10, &vmf);
+	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+}
+
+/* map a generic video mode to a known mode */
+static int
+vesa_map_gen_mode_num(int type, int color, int mode)
+{
+    static struct {
+	int from;
+	int to;
+    } mode_map[] = {
+	{ M_TEXT_132x25, M_VESA_C132x25 },
+	{ M_TEXT_132x43, M_VESA_C132x43 },
+	{ M_TEXT_132x50, M_VESA_C132x50 },
+	{ M_TEXT_132x60, M_VESA_C132x60 },
+    };
+    int i;
+
+    for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
+        if (mode_map[i].from == mode)
+            return mode_map[i].to;
+    }
+    return mode;
+}
+
+static int
+vesa_translate_flags(u_int16_t vflags)
+{
+	static struct {
+		u_int16_t mask;
+		int set;
+		int reset;
+	} ftable[] = {
+		{ V_MODECOLOR, V_INFO_COLOR, 0 },
+		{ V_MODEGRAPHICS, V_INFO_GRAPHICS, 0 },
+		{ V_MODELFB, V_INFO_LINEAR, 0 },
+	};
+	int flags;
+	int i;
+
+	for (flags = 0, i = 0; i < sizeof(ftable)/sizeof(ftable[0]); ++i) {
+		flags |= (vflags & ftable[i].mask) ? 
+			 ftable[i].set : ftable[i].reset;
+	}
+	return flags;
+}
+
+static int
+vesa_translate_mmodel(u_int8_t vmodel)
+{
+	static struct {
+		u_int8_t vmodel;
+		int mmodel;
+	} mtable[] = {
+		{ V_MMTEXT,	V_INFO_MM_TEXT },
+		{ V_MMCGA,	V_INFO_MM_CGA },
+		{ V_MMHGC,	V_INFO_MM_HGC },
+		{ V_MMEGA,	V_INFO_MM_PLANAR },
+		{ V_MMPACKED,	V_INFO_MM_PACKED },
+		{ V_MMDIRCOLOR,	V_INFO_MM_DIRECT },
+	};
+	int i;
+
+	for (i = 0; mtable[i].mmodel >= 0; ++i) {
+		if (mtable[i].vmodel == vmodel)
+			return mtable[i].mmodel;
+	}
+	return V_INFO_MM_OTHER;
+}
+
+static void
+*vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, u_char *buf)
+{
+	if (p == 0)
+		return NULL;
+	if (((p >> 16) == seg) && ((p & 0xffff) >= off))
+		return (void *)(buf + ((p & 0xffff) - off));
+	else {
+		p = BIOS_SADDRTOLADDR(p);
+		return (void *)BIOS_PADDRTOVADDR(p);
+	}
+}
+
+static int
+vesa_bios_init(void)
+{
+	static u_char buf[512];
+	struct vm86frame vmf;
+	struct vesa_mode vmode;
+	video_info_t *p;
+	u_char *vmbuf;
+	int is_via_cle266;
+	int modes;
+	int err;
+	int i;
+
+	if (vesa_init_done)
+		return 0;
+
+	has_vesa_bios = FALSE;
+	vesa_adp_info = NULL;
+	vesa_vmode_max = 0;
+	vesa_vmode[0].vi_mode = EOT;
+
+	/* Allocate a buffer and add each page to the vm86 context. */
+	vesa_vm86_buf = malloc(VESA_VM86_BUFSIZE, M_DEVBUF, M_WAITOK | M_ZERO);
+	KASSERT(((vm_offset_t)vesa_vm86_buf & PAGE_MASK) == 0,
+	    ("bad vesa_vm86_buf alignment"));
+	for (i = 0; i < howmany(VESA_VM86_BUFSIZE, PAGE_SIZE); i++)
+		vm86_addpage(&vesa_vmcontext, i + 1,
+		    (vm_offset_t)vesa_vm86_buf + PAGE_SIZE * i);
+
+	vmbuf = vesa_vm86_buf;
+	bzero(&vmf, sizeof(vmf));	/* paranoia */
+	bcopy("VBE2", vmbuf, 4);	/* try for VBE2 data */
+	vmf.vmf_eax = 0x4f00;
+	vm86_getptr(&vesa_vmcontext, (vm_offset_t)vmbuf, &vmf.vmf_es, &vmf.vmf_di);
+
+	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	if ((err != 0) || (vmf.vmf_ax != 0x4f) || bcmp("VESA", vmbuf, 4))
+		return 1;
+	bcopy(vmbuf, buf, sizeof(buf));
+	vesa_adp_info = (struct vesa_info *)buf;
+	if (bootverbose) {
+		printf("VESA: information block\n");
+		dump_buffer(buf, 64);
+	}
+	if (vesa_adp_info->v_version < 0x0102) {
+		printf("VESA: VBE version %d.%d is not supported; "
+		       "version 1.2 or later is required.\n",
+		       ((vesa_adp_info->v_version & 0xf000) >> 12) * 10 
+			   + ((vesa_adp_info->v_version & 0x0f00) >> 8),
+		       ((vesa_adp_info->v_version & 0x00f0) >> 4) * 10 
+			   + (vesa_adp_info->v_version & 0x000f));
+		return 1;
+	}
+
+	/* fix string ptrs */
+	vesa_oemstr = (char *)vesa_fix_ptr(vesa_adp_info->v_oemstr,
+					   vmf.vmf_es, vmf.vmf_di, buf);
+	is_via_cle266 = strcmp(vesa_oemstr, VESA_VIA_CLE266) == 0;
+
+	if (vesa_adp_info->v_version >= 0x0200) {
+		vesa_venderstr = 
+		    (char *)vesa_fix_ptr(vesa_adp_info->v_venderstr,
+					 vmf.vmf_es, vmf.vmf_di, buf);
+		vesa_prodstr = 
+		    (char *)vesa_fix_ptr(vesa_adp_info->v_prodstr,
+					 vmf.vmf_es, vmf.vmf_di, buf);
+		vesa_revstr = 
+		    (char *)vesa_fix_ptr(vesa_adp_info->v_revstr,
+					 vmf.vmf_es, vmf.vmf_di, buf);
+	}
+
+	/* obtain video mode information */
+	vesa_vmodetab = (u_int16_t *)vesa_fix_ptr(vesa_adp_info->v_modetable,
+						  vmf.vmf_es, vmf.vmf_di, buf);
+	if (vesa_vmodetab == NULL)
+		return 1;
+	for (i = 0, modes = 0; 
+		(i < (M_VESA_MODE_MAX - M_VESA_BASE + 1))
+		&& (vesa_vmodetab[i] != 0xffff); ++i) {
+		if (vesa_bios_get_mode(vesa_vmodetab[i], &vmode))
+			continue;
+
+		/* reject unsupported modes */
+#if 0
+		if ((vmode.v_modeattr & (V_MODESUPP | V_MODEOPTINFO 
+					| V_MODENONVGA))
+		    != (V_MODESUPP | V_MODEOPTINFO))
+			continue;
+#else
+		if ((vmode.v_modeattr & V_MODEOPTINFO) == 0) {
+#if VESA_DEBUG > 1
+			printf(
+		"Rejecting VESA %s mode: %d x %d x %d bpp  attr = %x\n",
+			    vmode.v_modeattr & V_MODEGRAPHICS ? "graphics" : "text",
+			    vmode.v_width, vmode.v_height, vmode.v_bpp,
+			    vmode.v_modeattr);
+#endif
+			continue;
+		}
+#endif
+
+		/* expand the array if necessary */
+		if (modes >= vesa_vmode_max) {
+			vesa_vmode_max += MODE_TABLE_DELTA;
+			p = malloc(sizeof(*vesa_vmode)*(vesa_vmode_max + 1),
+				   M_DEVBUF, M_WAITOK);
+#if VESA_DEBUG > 1
+			printf("vesa_bios_init(): modes:%d, vesa_mode_max:%d\n",
+			       modes, vesa_vmode_max);
+#endif
+			if (modes > 0) {
+				bcopy(vesa_vmode, p, sizeof(*vesa_vmode)*modes);
+				free(vesa_vmode, M_DEVBUF);
+			}
+			vesa_vmode = p;
+		}
+
+#if VESA_DEBUG > 1
+		printf("Found VESA %s mode: %d x %d x %d bpp\n",
+		    vmode.v_modeattr & V_MODEGRAPHICS ? "graphics" : "text",
+		    vmode.v_width, vmode.v_height, vmode.v_bpp);
+#endif
+		if (is_via_cle266) {
+		    if ((vmode.v_width & 0xff00) >> 8 == vmode.v_height - 1) {
+			vmode.v_width &= 0xff;
+			vmode.v_waseg = 0xb8000 >> 4;
+		    }
+		}
+
+		/* copy some fields */
+		bzero(&vesa_vmode[modes], sizeof(vesa_vmode[modes]));
+		vesa_vmode[modes].vi_mode = vesa_vmodetab[i];
+		vesa_vmode[modes].vi_width = vmode.v_width;
+		vesa_vmode[modes].vi_height = vmode.v_height;
+		vesa_vmode[modes].vi_depth = vmode.v_bpp;
+		vesa_vmode[modes].vi_planes = vmode.v_planes;
+		vesa_vmode[modes].vi_cwidth = vmode.v_cwidth;
+		vesa_vmode[modes].vi_cheight = vmode.v_cheight;
+		vesa_vmode[modes].vi_window = (u_int)vmode.v_waseg << 4;
+		/* XXX window B */
+		vesa_vmode[modes].vi_window_size = vmode.v_wsize*1024;
+		vesa_vmode[modes].vi_window_gran = vmode.v_wgran*1024;
+		if (vmode.v_modeattr & V_MODELFB)
+			vesa_vmode[modes].vi_buffer = vmode.v_lfb;
+		else
+			vesa_vmode[modes].vi_buffer = 0;
+		/* XXX */
+		vesa_vmode[modes].vi_buffer_size
+			= vesa_adp_info->v_memsize*64*1024;
+#if 0
+		if (vmode.v_offscreen > vmode.v_lfb)
+			vesa_vmode[modes].vi_buffer_size
+				= vmode.v_offscreen + vmode.v_offscreensize*1024
+				      - vmode.v_lfb;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From delphij at FreeBSD.org  Wed Sep  9 09:50:32 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Wed Sep  9 09:50:45 2009
Subject: svn commit: r197025 - in head: lib share/man/man4
	share/man/man4/man4.i386 sys/amd64/conf sys/conf sys/dev/dpms
	sys/dev/fb sys/dev/syscons sys/i386/conf sys/i386/include/pc
	sys/i386/isa sys/modules...
Message-ID: <200909090950.n899oWOC079768@svn.freebsd.org>

Author: delphij
Date: Wed Sep  9 09:50:31 2009
New Revision: 197025
URL: http://svn.freebsd.org/changeset/base/197025

Log:
   - Teach vesa(4) and dpms(4) about x86emu. [1]
   - Add vesa kernel options for amd64.
   - Connect libvgl library and splash kernel modules to amd64 build.
   - Connect manual page dpms(4) to amd64 build.
   - Remove old vesa/dpms files.
  
  Submitted by:	paradox  [1], swell k at gmail.com
  		(with some minor tweaks)

Added:
  head/share/man/man4/dpms.4
     - copied unchanged from r197022, head/share/man/man4/man4.i386/dpms.4
Deleted:
  head/share/man/man4/man4.i386/dpms.4
  head/sys/i386/include/pc/vesa.h
  head/sys/i386/isa/dpms.c
  head/sys/i386/isa/vesa.c
Modified:
  head/lib/Makefile
  head/share/man/man4/Makefile
  head/sys/amd64/conf/NOTES
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/conf/options.amd64
  head/sys/dev/dpms/dpms.c
  head/sys/dev/fb/s3_pci.c
  head/sys/dev/fb/vesa.c
  head/sys/dev/fb/vesa.h
  head/sys/dev/fb/vga.c
  head/sys/dev/syscons/scvesactl.c
  head/sys/i386/conf/NOTES
  head/sys/modules/Makefile
  head/sys/modules/dpms/Makefile
  head/sys/modules/vesa/Makefile

Modified: head/lib/Makefile
==============================================================================
--- head/lib/Makefile	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/lib/Makefile	Wed Sep  9 09:50:31 2009	(r197025)
@@ -112,6 +112,7 @@ _libsmb=	libsmb
 _libncp=	libncp
 .endif
 _libsmb=	libsmb
+_libvgl=	libvgl
 .endif
 
 .if ${MACHINE_ARCH} == "powerpc"

Modified: head/share/man/man4/Makefile
==============================================================================
--- head/share/man/man4/Makefile	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/share/man/man4/Makefile	Wed Sep  9 09:50:31 2009	(r197025)
@@ -85,6 +85,7 @@ MAN=	aac.4 \
 	digi.4 \
 	disc.4 \
 	divert.4 \
+	${_dpms.4} \
 	dpt.4 \
 	dummynet.4 \
 	ed.4 \
@@ -611,6 +612,7 @@ _amdtemp.4=	amdtemp.4
 _asmc.4=	asmc.4
 _coretemp.4=	coretemp.4
 _cpuctl.4=	cpuctl.4
+_dpms.4=	dpms.4
 _hptiop.4=	hptiop.4
 _hptmv.4=	hptmv.4
 _hptrr.4=	hptrr.4

Copied: head/share/man/man4/dpms.4 (from r197022, head/share/man/man4/man4.i386/dpms.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/share/man/man4/dpms.4	Wed Sep  9 09:50:31 2009	(r197025, copy of r197022, head/share/man/man4/man4.i386/dpms.4)
@@ -0,0 +1,58 @@
+.\" Copyright (c) 2008 Yahoo!, Inc.
+.\" All rights reserved.
+.\" Written by: John Baldwin 
+.\"
+.\" 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.
+.\" 3. Neither the name of the author nor the names of any co-contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" 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$
+.\"
+.Dd August 23, 2008
+.Dt DPMS 4
+.Os
+.Sh NAME
+.Nm dpms
+.Nd VESA BIOS DPMS driver
+.Sh SYNOPSIS
+.Cd "device dpms"
+.Sh DESCRIPTION
+The
+.Nm
+driver uses the VESA BIOS to manage an external display during suspend and
+resume.
+When the machine suspends,
+the
+.Nm
+driver turns the external display off.
+When the machine resumes,
+it restores the display to its state when the driver was first loaded.
+.Sh SEE ALSO
+.Xr acpi_video 4
+.Sh BUGS
+.Pp
+The VESA BIOS DPMS calls do not provide any way to identify a particular
+display or adapter to manipulate.
+As a result,
+this driver may have unexpected results on systems with multiple displays
+and/or adapters.

Modified: head/sys/amd64/conf/NOTES
==============================================================================
--- head/sys/amd64/conf/NOTES	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/amd64/conf/NOTES	Wed Sep  9 09:50:31 2009	(r197025)
@@ -154,6 +154,12 @@ options 	AGP_DEBUG
 #####################################################################
 # HARDWARE DEVICE CONFIGURATION
 
+# To include support for VGA VESA video modes (depends on X86EMU)
+options 	VESA
+
+# Turn on extra debugging checks and output for VESA support.
+options 	VESA_DEBUG
+
 #
 # Optional devices:
 #

Modified: head/sys/conf/files.amd64
==============================================================================
--- head/sys/conf/files.amd64	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/conf/files.amd64	Wed Sep  9 09:50:31 2009	(r197025)
@@ -162,6 +162,7 @@ dev/atkbdc/atkbdc_subr.c	optional	atkbdc
 dev/atkbdc/psm.c		optional	psm atkbdc
 dev/coretemp/coretemp.c		optional	coretemp
 dev/cpuctl/cpuctl.c		optional	cpuctl
+dev/dpms/dpms.c			optional	dpms x86emu
 # There are no systems with isa slots, so all ed isa entries should go..
 dev/ed/if_ed_3c503.c		optional	ed isa ed_3c503
 dev/ed/if_ed_isa.c		optional	ed isa
@@ -169,6 +170,7 @@ dev/ed/if_ed_wd80x3.c		optional	ed isa
 dev/ed/if_ed_hpp.c		optional	ed isa ed_hpp
 dev/ed/if_ed_sic.c		optional	ed isa ed_sic
 dev/fb/fb.c			optional	fb | vga
+dev/fb/vesa.c			optional	vga vesa x86emu
 dev/fb/vga.c			optional	vga
 dev/ichwd/ichwd.c		optional	ichwd
 dev/if_ndis/if_ndis.c		optional	ndis
@@ -217,6 +219,7 @@ dev/sio/sio_puc.c		optional	sio puc
 dev/speaker/spkr.c		optional	speaker
 dev/syscons/apm/apm_saver.c	optional	apm_saver apm
 dev/syscons/scterm-teken.c	optional	sc
+dev/syscons/scvesactl.c		optional	sc vga vesa x86emu
 dev/syscons/scvgarndr.c		optional	sc vga
 dev/syscons/scvtb.c		optional	sc
 dev/uart/uart_cpu_amd64.c	optional	uart

Modified: head/sys/conf/files.i386
==============================================================================
--- head/sys/conf/files.i386	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/conf/files.i386	Wed Sep  9 09:50:31 2009	(r197025)
@@ -150,12 +150,14 @@ dev/ctau/if_ct.c		optional ctau
 dev/cx/csigma.c			optional cx
 dev/cx/cxddk.c			optional cx
 dev/cx/if_cx.c			optional cx
+dev/dpms/dpms.c			optional dpms x86emu
 dev/ed/if_ed_3c503.c		optional ed isa ed_3c503
 dev/ed/if_ed_isa.c		optional ed isa
 dev/ed/if_ed_wd80x3.c		optional ed isa
 dev/ed/if_ed_hpp.c		optional ed isa ed_hpp
 dev/ed/if_ed_sic.c		optional ed isa ed_sic
 dev/fb/fb.c			optional fb | vga
+dev/fb/vesa.c			optional vga vesa x86emu
 dev/fb/vga.c			optional vga
 dev/fdc/fdc.c			optional fdc
 dev/fdc/fdc_acpi.c		optional fdc
@@ -217,7 +219,7 @@ dev/sio/sio_puc.c		optional sio puc
 dev/speaker/spkr.c		optional speaker
 dev/syscons/apm/apm_saver.c	optional apm_saver apm
 dev/syscons/scterm-teken.c	optional sc
-dev/syscons/scvesactl.c		optional sc vga vesa
+dev/syscons/scvesactl.c		optional sc vga vesa x86emu
 dev/syscons/scvgarndr.c		optional sc vga
 dev/syscons/scvtb.c		optional sc
 dev/uart/uart_cpu_i386.c	optional uart
@@ -329,7 +331,6 @@ i386/isa/clock.c		optional native
 i386/xen/clock.c		optional xen
 i386/xen/xen_clock_util.c	optional xen
 i386/xen/xen_rtc.c		optional xen
-i386/isa/dpms.c			optional dpms
 i386/isa/elcr.c			standard
 i386/isa/elink.c		optional ep | ie
 i386/isa/isa.c			optional isa
@@ -339,7 +340,6 @@ i386/isa/npx.c			optional npx
 i386/isa/pmtimer.c		optional pmtimer
 i386/isa/prof_machdep.c		optional profiling-routine
 i386/isa/spic.c			optional spic
-i386/isa/vesa.c			optional vga vesa
 i386/linux/imgact_linux.c	optional compat_linux
 i386/linux/linux_dummy.c	optional compat_linux
 i386/linux/linux_locore.s	optional compat_linux	\

Modified: head/sys/conf/options.amd64
==============================================================================
--- head/sys/conf/options.amd64	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/conf/options.amd64	Wed Sep  9 09:50:31 2009	(r197025)
@@ -37,6 +37,9 @@ VGA_NO_MODE_CHANGE	opt_vga.h
 VGA_SLOW_IOACCESS	opt_vga.h
 VGA_WIDTH90		opt_vga.h
 
+VESA
+VESA_DEBUG		opt_vesa.h
+
 # AGP debugging support
 AGP_DEBUG		opt_agp.h
 

Modified: head/sys/dev/dpms/dpms.c
==============================================================================
--- head/sys/dev/dpms/dpms.c	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/dev/dpms/dpms.c	Wed Sep  9 09:50:31 2009	(r197025)
@@ -67,7 +67,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
+#include 
+
+#include 
+#include 
 
 /*
  * VESA DPMS States 
@@ -90,6 +94,9 @@ struct dpms_softc {
 	int	dpms_initial_state;
 };
 
+static struct x86emu vesa_emu;
+static unsigned char *emumem = NULL;
+
 static int	dpms_attach(device_t);
 static int	dpms_detach(device_t);
 static int	dpms_get_supported_states(int *);
@@ -119,6 +126,59 @@ static driver_t dpms_driver = {
 static devclass_t dpms_devclass;
 
 DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL);
+MODULE_DEPEND(dpms, x86emu, 1, 1, 1);
+
+static uint8_t
+vm86_emu_inb(struct x86emu *emu, uint16_t port)
+{
+	if (port == 0xb2) /* APM scratch register */
+		return 0;
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inb(port);
+}
+
+static uint16_t
+vm86_emu_inw(struct x86emu *emu, uint16_t port)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inw(port);
+}
+
+static uint32_t
+vm86_emu_inl(struct x86emu *emu, uint16_t port)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inl(port);
+}
+
+static void
+vm86_emu_outb(struct x86emu *emu, uint16_t port, uint8_t val)
+{
+	if (port == 0xb2) /* APM scratch register */
+		return;
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outb(port, val);
+}
+
+static void
+vm86_emu_outw(struct x86emu *emu, uint16_t port, uint16_t val)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outw(port, val);
+}
+
+static void
+vm86_emu_outl(struct x86emu *emu, uint16_t port, uint32_t val)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outl(port, val);
+}
 
 static void
 dpms_identify(driver_t *driver, device_t parent)
@@ -132,6 +192,7 @@ dpms_identify(driver_t *driver, device_t
 	 */
 	if (devclass_get_device(dpms_devclass, 0) == NULL)
 		device_add_child(parent, "dpms", 0);
+
 }
 
 static int
@@ -139,6 +200,21 @@ dpms_probe(device_t dev)
 {
 	int error, states;
 
+	emumem = pmap_mapbios(0x0, 0xc00000);
+
+	memset(&vesa_emu, 0, sizeof(vesa_emu));
+	x86emu_init_default(&vesa_emu);
+
+	vesa_emu.emu_inb = vm86_emu_inb;
+	vesa_emu.emu_inw = vm86_emu_inw;
+	vesa_emu.emu_inl = vm86_emu_inl;
+	vesa_emu.emu_outb = vm86_emu_outb;
+	vesa_emu.emu_outw = vm86_emu_outw;
+	vesa_emu.emu_outl = vm86_emu_outl;
+
+	vesa_emu.mem_base = (char *)emumem;
+	vesa_emu.mem_size = 1024 * 1024;
+
 	error = dpms_get_supported_states(&states);
 	if (error)
 		return (error);
@@ -164,6 +240,8 @@ dpms_attach(device_t dev)
 static int
 dpms_detach(device_t dev)
 {
+	if (emumem)
+		pmap_unmapdev((vm_offset_t)emumem, 0xc00000);
 
 	return (0);
 }
@@ -189,21 +267,19 @@ dpms_resume(device_t dev)
 static int
 dpms_call_bios(int subfunction, int *bh)
 {
-	struct vm86frame vmf;
-	int error;
+	vesa_emu.x86.R_AX = VBE_DPMS_FUNCTION;
+	vesa_emu.x86.R_BL = subfunction;
+	vesa_emu.x86.R_BH = *bh;
+	vesa_emu.x86.R_ES = 0;
+	vesa_emu.x86.R_DI = 0;
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_ax = VBE_DPMS_FUNCTION;
-	vmf.vmf_bl = subfunction;
-	vmf.vmf_bh = *bh;
-	vmf.vmf_es = 0;
-	vmf.vmf_di = 0;
-	error = vm86_intcall(0x10, &vmf);
-	if (error == 0 && (vmf.vmf_eax & 0xffff) != 0x004f)
-		error = ENXIO;
-	if (error == 0)
-		*bh = vmf.vmf_bh;
-	return (error);
+	if ((vesa_emu.x86.R_EAX & 0xffff) != 0x004f)
+		return (ENXIO);
+
+	*bh = vesa_emu.x86.R_BH;
+
+	return (0);
 }
 
 static int

Modified: head/sys/dev/fb/s3_pci.c
==============================================================================
--- head/sys/dev/fb/s3_pci.c	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/dev/fb/s3_pci.c	Wed Sep  9 09:50:31 2009	(r197025)
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 

Modified: head/sys/dev/fb/vesa.c
==============================================================================
--- head/sys/dev/fb/vesa.c	Wed Sep  9 09:34:13 2009	(r197024)
+++ head/sys/dev/fb/vesa.c	Wed Sep  9 09:50:31 2009	(r197025)
@@ -45,19 +45,16 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
 #include 
 
-#ifndef __i386__
 #include 
-#else
-#include 
-#endif
+#include 
+
+#include 
+#include 
 
 #define	VESA_VIA_CLE266		"VIA CLE266\r\n"
 
@@ -76,8 +73,7 @@ typedef struct adp_state adp_state_t;
 /* VESA video adapter */
 static video_adapter_t *vesa_adp = NULL;
 static int vesa_state_buf_size = 0;
-#define VESA_VM86_BUFSIZE	(3 * PAGE_SIZE)
-static void *vesa_vm86_buf;
+#define VESA_X86EMU_BUFSIZE	(3 * PAGE_SIZE)
 
 /* VESA functions */
 #if 0
@@ -109,7 +105,8 @@ static vi_fill_rect_t		vesa_fill_rect;
 static vi_bitblt_t		vesa_bitblt;
 static vi_diag_t		vesa_diag;
 static int			vesa_bios_info(int level);
-static struct vm86context	vesa_vmcontext;
+
+static struct x86emu		vesa_emu;
 
 static video_switch_t vesavidsw = {
 	vesa_probe,
@@ -200,8 +197,6 @@ static int vesa_bios_set_start(int x, in
 static int vesa_map_gen_mode_num(int type, int color, int mode);
 static int vesa_translate_flags(u_int16_t vflags);
 static int vesa_translate_mmodel(u_int8_t vmodel);
-static void *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, 
-			  u_char *buf);
 static int vesa_bios_init(void);
 static void vesa_clear_modes(video_info_t *info, int color);
 static vm_offset_t vesa_map_buffer(u_int paddr, size_t size);
@@ -211,6 +206,77 @@ static void vesa_unmap_buffer(vm_offset_
 static int vesa_get_origin(video_adapter_t *adp, off_t *offset);
 #endif
 
+#define SEG_ADDR(x)	(((x) >> 4) & 0x00F000)
+#define SEG_OFF(x)	((x) & 0x0FFFF)
+
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define B_O16(x)	(x)
+#define B_O32(x)	(x)
+#else
+#define B_O16(x)	((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
+#define B_O32(x)	((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
+		| (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
+#endif
+
+#define L_ADD(x)	(B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
+#define FARP(p)		(((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
+
+#define REALOFF(x)	(x*4096)
+
+static unsigned char *emumem = NULL;
+
+static uint8_t
+vm86_emu_inb(struct x86emu *emu, uint16_t port)
+{
+	if (port == 0xb2) /* APM scratch register */
+		return 0;
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inb(port);
+}
+
+static uint16_t
+vm86_emu_inw(struct x86emu *emu, uint16_t port)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inw(port);
+}
+
+static uint32_t
+vm86_emu_inl(struct x86emu *emu, uint16_t port)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return 0;
+	return inl(port);
+}
+
+static void
+vm86_emu_outb(struct x86emu *emu, uint16_t port, uint8_t val)
+{
+	if (port == 0xb2) /* APM scratch register */
+		return;
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outb(port, val);
+}
+
+static void
+vm86_emu_outw(struct x86emu *emu, uint16_t port, uint16_t val)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outw(port, val);
+}
+
+static void
+vm86_emu_outl(struct x86emu *emu, uint16_t port, uint32_t val)
+{
+	if (port >= 0x80 && port < 0x88) /* POST status register */
+		return;
+	outl(port, val);
+}
+
 static void
 dump_buffer(u_char *buf, size_t len)
 {
@@ -227,11 +293,9 @@ dump_buffer(u_char *buf, size_t len)
 static int
 int10_set_mode(int mode)
 {
-	struct vm86frame vmf;
+	vesa_emu.x86.R_EAX = 0x0000 | mode;
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x0000 | mode;
-	vm86_intcall(0x10, &vmf);
 	return 0;
 }
 
@@ -239,84 +303,83 @@ int10_set_mode(int mode)
 static int
 vesa_bios_get_mode(int mode, struct vesa_mode *vmode)
 {
-	struct vm86frame vmf;
 	u_char *buf;
-	int err;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f01; 
-	vmf.vmf_ecx = mode;
-	buf = vesa_vm86_buf;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_di);
+	vesa_emu.x86.R_EAX = 0x4f01;
+	vesa_emu.x86.R_ECX = mode;
+
+	buf = (emumem + REALOFF(3));
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(3));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(3));
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 		return 1;
+
 	bcopy(buf, vmode, sizeof(*vmode));
+
 	return 0;
 }
 
 static int
 vesa_bios_set_mode(int mode)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f02;
+	vesa_emu.x86.R_EBX = mode;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f02;
-	vmf.vmf_ebx = mode;
-	err = vm86_intcall(0x10, &vmf);
-	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	return ((vesa_emu.x86.R_AX & 0xff) != 0x4f);
 }
 
 static int
 vesa_bios_get_dac(void)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f08;
+	vesa_emu.x86.R_EBX = 1;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
+		return 6;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f08;
-	vmf.vmf_ebx = 1;	/* get DAC width */
-	err = vm86_intcall(0x10, &vmf);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
-		return 6;	/* XXX */
-	return ((vmf.vmf_ebx >> 8) & 0x00ff);
+	return ((vesa_emu.x86.R_EBX >> 8) & 0x00ff);
 }
 
 static int
 vesa_bios_set_dac(int bits)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f08;
+	vesa_emu.x86.R_EBX = (bits << 8);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f08;
-	vmf.vmf_ebx = (bits << 8);
-	err = vm86_intcall(0x10, &vmf);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
-		return 6;	/* XXX */
-	return ((vmf.vmf_ebx >> 8) & 0x00ff);
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
+		return 6;
+
+	return ((vesa_emu.x86.R_EBX >> 8) & 0x00ff);
 }
 
 static int
 vesa_bios_save_palette(int start, int colors, u_char *palette, int bits)
 {
-	struct vm86frame vmf;
 	u_char *p;
-	int err;
 	int i;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f09;
-	vmf.vmf_ebx = 1;	/* get primary palette data */
-	vmf.vmf_ecx = colors;
-	vmf.vmf_edx = start;
-	p = vesa_vm86_buf;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+	vesa_emu.x86.R_EAX = 0x4f09;
+	vesa_emu.x86.R_EBX = 1;
+	vesa_emu.x86.R_ECX = colors;
+	vesa_emu.x86.R_EDX = start;
+
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+	p = emumem + REALOFF(2);
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 		return 1;
 
 	bits = 8 - bits;
@@ -332,21 +395,22 @@ static int
 vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
 			int bits)
 {
-	struct vm86frame vmf;
 	u_char *p;
-	int err;
 	int i;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f09;
-	vmf.vmf_ebx = 1;	/* get primary palette data */
-	vmf.vmf_ecx = colors;
-	vmf.vmf_edx = start;
-	p = vesa_vm86_buf;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+	vesa_emu.x86.R_EAX = 0x4f09;
+	vesa_emu.x86.R_EBX = 1;
+	vesa_emu.x86.R_ECX = colors;
+	vesa_emu.x86.R_EDX = start;
+
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+	p = emumem + REALOFF(2);
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 		return 1;
 
 	bits = 8 - bits;
@@ -361,12 +425,11 @@ vesa_bios_save_palette2(int start, int c
 static int
 vesa_bios_load_palette(int start, int colors, u_char *palette, int bits)
 {
-	struct vm86frame vmf;
 	u_char *p;
-	int err;
 	int i;
 
-	p = vesa_vm86_buf;
+	p = (emumem + REALOFF(2));
+
 	bits = 8 - bits;
 	for (i = 0; i < colors; ++i) {
 		p[i*4]	   = palette[i*3 + 2] >> bits;
@@ -375,15 +438,17 @@ vesa_bios_load_palette(int start, int co
 		p[i*4 + 3] = 0;
 	}
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f09;
-	vmf.vmf_ebx = 0;	/* set primary palette data */
-	vmf.vmf_ecx = colors;
-	vmf.vmf_edx = start;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+	vesa_emu.x86.R_EAX = 0x4f09;
+	vesa_emu.x86.R_EBX = 0;
+	vesa_emu.x86.R_ECX = colors;
+	vesa_emu.x86.R_EDX = start;
+
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	return ((vesa_emu.x86.R_AX & 0xff) != 0x4f);
 }
 
 #ifdef notyet
@@ -391,12 +456,11 @@ static int
 vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, u_char *b,
 			int bits)
 {
-	struct vm86frame vmf;
 	u_char *p;
-	int err;
 	int i;
 
-	p = vesa_vm86_buf;
+	p = (emumem + REALOFF(2));
+
 	bits = 8 - bits;
 	for (i = 0; i < colors; ++i) {
 		p[i*4]	   = b[i] >> bits;
@@ -405,92 +469,94 @@ vesa_bios_load_palette2(int start, int c
 		p[i*4 + 3] = 0;
 	}
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f09;
-	vmf.vmf_ebx = 0;	/* set primary palette data */
-	vmf.vmf_ecx = colors;
-	vmf.vmf_edx = start;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)p, &vmf.vmf_es, &vmf.vmf_di);
+	vesa_emu.x86.R_EAX = 0x4f09;
+	vesa_emu.x86.R_EBX = 0;
+	vesa_emu.x86.R_ECX = colors;
+	vesa_emu.x86.R_EDX = start;
+
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	return ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 }
 #endif
 
 static int
 vesa_bios_state_buf_size(void)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f04;
+	vesa_emu.x86.R_ECX = STATE_ALL;
+	vesa_emu.x86.R_EDX = STATE_SIZE;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f04; 
-	vmf.vmf_ecx = STATE_ALL;
-	vmf.vmf_edx = STATE_SIZE;
-	err = vm86_intcall(0x10, &vmf);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 		return 0;
-	return vmf.vmf_bx*64;
+
+	return vesa_emu.x86.R_BX*64;
 }
 
 static int
 vesa_bios_save_restore(int code, void *p, size_t size)
 {
-	struct vm86frame vmf;
 	u_char *buf;
-	int err;
 
-	if (size > VESA_VM86_BUFSIZE)
+	if (size > VESA_X86EMU_BUFSIZE)
 		return (1);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f04; 
-	vmf.vmf_ecx = STATE_ALL;
-	vmf.vmf_edx = code;	/* STATE_SAVE/STATE_LOAD */
-	buf = vesa_vm86_buf;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)buf, &vmf.vmf_es, &vmf.vmf_bx);
+	vesa_emu.x86.R_EAX = 0x4f04;
+	vesa_emu.x86.R_ECX = STATE_ALL;
+	vesa_emu.x86.R_EDX = code;
+
+	buf = emumem + REALOFF(2);
+
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
+
 	bcopy(p, buf, size);
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
 	bcopy(buf, p, size);
-	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+
+	return ((vesa_emu.x86.R_AX & 0xff) != 0x4f);
 }
 
 static int
 vesa_bios_get_line_length(void)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f06;
+	vesa_emu.x86.R_EBX = 1;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f06; 
-	vmf.vmf_ebx = 1;	/* get scan line length */
-	err = vm86_intcall(0x10, &vmf);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
 		return -1;
-	return vmf.vmf_bx;	/* line length in bytes */
+	return vesa_emu.x86.R_BX;
 }
 
 static int
 vesa_bios_set_line_length(int pixel, int *bytes, int *lines)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f06;
+	vesa_emu.x86.R_EBX = 0;
+	vesa_emu.x86.R_ECX = pixel;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f06; 
-	vmf.vmf_ebx = 0;	/* set scan line length in pixel */
-	vmf.vmf_ecx = pixel;
-	err = vm86_intcall(0x10, &vmf);
 #if VESA_DEBUG > 1
-	printf("bx:%d, cx:%d, dx:%d\n", vmf.vmf_bx, vmf.vmf_cx, vmf.vmf_dx); 
+	printf("bx:%d, cx:%d, dx:%d\n", vesa_emu.x86.R_BX, vesa_emu.x86.R_CX, vesa_emu.x86.R_DX);
 #endif
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
-		return 1;
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
+		return -1;
+
 	if (bytes)
-		*bytes = vmf.vmf_bx;
+		*bytes = vesa_emu.x86.R_BX;
 	if (lines)
-		*lines = vmf.vmf_dx;
+		*lines = vesa_emu.x86.R_DX;
+
 	return 0;
 }
 
@@ -498,17 +564,17 @@ vesa_bios_set_line_length(int pixel, int
 static int
 vesa_bios_get_start(int *x, int *y)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f07;
+	vesa_emu.x86.R_EBX = 1;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if ((vesa_emu.x86.R_AX & 0xff) != 0x4f)
+		return -1;
+
+	*x = vesa_emu.x86.R_CX;
+	*y = vesa_emu.x86.R_DX;
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f07; 
-	vmf.vmf_ebx = 1;	/* get display start */
-	err = vm86_intcall(0x10, &vmf);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f))
-		return 1;
-	*x = vmf.vmf_cx;
-	*y = vmf.vmf_dx;
 	return 0;
 }
 #endif
@@ -516,16 +582,14 @@ vesa_bios_get_start(int *x, int *y)
 static int
 vesa_bios_set_start(int x, int y)
 {
-	struct vm86frame vmf;
-	int err;
+	vesa_emu.x86.R_EAX = 0x4f07;
+	vesa_emu.x86.R_EBX = 0x80;
+	vesa_emu.x86.R_EDX = y;
+	vesa_emu.x86.R_ECX = x;
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
 
-	bzero(&vmf, sizeof(vmf));
-	vmf.vmf_eax = 0x4f07; 
-	vmf.vmf_ebx = 0x80;	/* set display start */
-	vmf.vmf_edx = y;
-	vmf.vmf_ecx = x;
-	err = vm86_intcall(0x10, &vmf);
-	return ((err != 0) || (vmf.vmf_ax != 0x4f));
+	return ((vesa_emu.x86.R_AX & 0xff) != 0x4f);
 }
 
 /* map a generic video mode to a known mode */
@@ -595,30 +659,15 @@ vesa_translate_mmodel(u_int8_t vmodel)
 	return V_INFO_MM_OTHER;
 }
 
-static void
-*vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off, u_char *buf)
-{
-	if (p == 0)
-		return NULL;
-	if (((p >> 16) == seg) && ((p & 0xffff) >= off))
-		return (void *)(buf + ((p & 0xffff) - off));
-	else {
-		p = BIOS_SADDRTOLADDR(p);
-		return (void *)BIOS_PADDRTOVADDR(p);
-	}
-}
-
 static int
 vesa_bios_init(void)
 {
-	static u_char buf[512];
-	struct vm86frame vmf;
+	static struct vesa_info buf;
 	struct vesa_mode vmode;
 	video_info_t *p;
 	u_char *vmbuf;
 	int is_via_cle266;
 	int modes;
-	int err;
 	int i;
 
 	if (vesa_init_done)
@@ -629,28 +678,24 @@ vesa_bios_init(void)
 	vesa_vmode_max = 0;
 	vesa_vmode[0].vi_mode = EOT;
 
-	/* Allocate a buffer and add each page to the vm86 context. */
-	vesa_vm86_buf = malloc(VESA_VM86_BUFSIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	KASSERT(((vm_offset_t)vesa_vm86_buf & PAGE_MASK) == 0,
-	    ("bad vesa_vm86_buf alignment"));
-	for (i = 0; i < howmany(VESA_VM86_BUFSIZE, PAGE_SIZE); i++)
-		vm86_addpage(&vesa_vmcontext, i + 1,
-		    (vm_offset_t)vesa_vm86_buf + PAGE_SIZE * i);
-
-	vmbuf = vesa_vm86_buf;
-	bzero(&vmf, sizeof(vmf));	/* paranoia */
+	vmbuf = (emumem + REALOFF(2));
 	bcopy("VBE2", vmbuf, 4);	/* try for VBE2 data */
-	vmf.vmf_eax = 0x4f00;
-	vm86_getptr(&vesa_vmcontext, (vm_offset_t)vmbuf, &vmf.vmf_es, &vmf.vmf_di);
 
-	err = vm86_datacall(0x10, &vmf, &vesa_vmcontext);
-	if ((err != 0) || (vmf.vmf_ax != 0x4f) || bcmp("VESA", vmbuf, 4))
+	vesa_emu.x86.R_EAX = 0x4f00;
+	vesa_emu.x86.R_ES = SEG_ADDR(REALOFF(2));
+	vesa_emu.x86.R_DI = SEG_OFF(REALOFF(2));
+
+	x86emu_exec_intr(&vesa_emu, 0x10);
+
+	if (((vesa_emu.x86.R_AX & 0xff) != 0x4f) || bcmp("VESA", vmbuf, 4))
 		return 1;
-	bcopy(vmbuf, buf, sizeof(buf));
-	vesa_adp_info = (struct vesa_info *)buf;
+
+	bcopy(vmbuf, &buf, sizeof(buf));
+
+	vesa_adp_info = &buf;
 	if (bootverbose) {
 		printf("VESA: information block\n");
-		dump_buffer(buf, 64);
+		dump_buffer((u_char *)&buf, sizeof(buf));
 	}
 	if (vesa_adp_info->v_version < 0x0102) {
 		printf("VESA: VBE version %d.%d is not supported; "
@@ -662,28 +707,21 @@ vesa_bios_init(void)
 		return 1;
 	}
 
-	/* fix string ptrs */
-	vesa_oemstr = (char *)vesa_fix_ptr(vesa_adp_info->v_oemstr,
-					   vmf.vmf_es, vmf.vmf_di, buf);
+	vesa_oemstr = (char *)(emumem + L_ADD(vesa_adp_info->v_oemstr));
+
 	is_via_cle266 = strcmp(vesa_oemstr, VESA_VIA_CLE266) == 0;
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From nyan at FreeBSD.org  Wed Sep  9 10:05:51 2009
From: nyan at FreeBSD.org (Takahashi Yoshihiro)
Date: Wed Sep  9 10:05:57 2009
Subject: svn commit: r197026 - head/sys/pc98/include/pc
Message-ID: <200909091005.n89A5oxj080183@svn.freebsd.org>

Author: nyan
Date: Wed Sep  9 10:05:50 2009
New Revision: 197026
URL: http://svn.freebsd.org/changeset/base/197026

Log:
  MFi386: Remove old file.

Deleted:
  head/sys/pc98/include/pc/vesa.h
From phk at FreeBSD.org  Wed Sep  9 10:31:21 2009
From: phk at FreeBSD.org (Poul-Henning Kamp)
Date: Wed Sep  9 10:31:33 2009
Subject: svn commit: r197029 - head/lib/libc/net
Message-ID: <200909091031.n89AVLUQ082762@svn.freebsd.org>

Author: phk
Date: Wed Sep  9 10:31:20 2009
New Revision: 197029
URL: http://svn.freebsd.org/changeset/base/197029

Log:
  Revert r196976, now that  behaves predictably.

Modified:
  head/lib/libc/net/getifaddrs.c

Modified: head/lib/libc/net/getifaddrs.c
==============================================================================
--- head/lib/libc/net/getifaddrs.c	Wed Sep  9 10:31:09 2009	(r197028)
+++ head/lib/libc/net/getifaddrs.c	Wed Sep  9 10:31:20 2009	(r197029)
@@ -33,7 +33,6 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
-#include 
 #include 
 #include 
 #include 
From kib at FreeBSD.org  Wed Sep  9 10:51:52 2009
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Wed Sep  9 10:51:59 2009
Subject: svn commit: r197030 - head/sys/kern
Message-ID: <200909091051.n89Appfs083217@svn.freebsd.org>

Author: kib
Date: Wed Sep  9 10:51:50 2009
New Revision: 197030
URL: http://svn.freebsd.org/changeset/base/197030

Log:
  In vfs_mark_atime(9), be resistent against reclaimed vnodes.
  Assert that neccessary locks are taken, since vop might not be called.
  
  Tested by:	pho
  MFC after:	3 days

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Wed Sep  9 10:31:20 2009	(r197029)
+++ head/sys/kern/vfs_subr.c	Wed Sep  9 10:51:50 2009	(r197030)
@@ -4269,8 +4269,12 @@ vfs_read_dirent(struct vop_readdir_args 
 void
 vfs_mark_atime(struct vnode *vp, struct ucred *cred)
 {
+	struct mount *mp;
 
-	if ((vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0)
+	mp = vp->v_mount;
+	VFS_ASSERT_GIANT(mp);
+	ASSERT_VOP_LOCKED(vp, "vfs_mark_atime");
+	if (mp != NULL && (mp->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0)
 		(void)VOP_MARKATIME(vp);
 }
 
From kib at FreeBSD.org  Wed Sep  9 10:52:36 2009
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Wed Sep  9 10:52:48 2009
Subject: svn commit: r197031 - head/sys/kern
Message-ID: <200909091052.n89Aqar0083267@svn.freebsd.org>

Author: kib
Date: Wed Sep  9 10:52:36 2009
New Revision: 197031
URL: http://svn.freebsd.org/changeset/base/197031

Log:
  Unlock the image vnode around the call of pmc PMC_FN_PROCESS_EXEC hook.
  The hook calls vn_fullpath(9), that should not be executed with a vnode
  lock held.
  
  Reported by:	Bruce Cran 
  Tested by:	pho
  MFC after:	3 days

Modified:
  head/sys/kern/kern_exec.c

Modified: head/sys/kern/kern_exec.c
==============================================================================
--- head/sys/kern/kern_exec.c	Wed Sep  9 10:51:50 2009	(r197030)
+++ head/sys/kern/kern_exec.c	Wed Sep  9 10:52:36 2009	(r197031)
@@ -786,10 +786,12 @@ interpret:
 	 */
 	if (PMC_SYSTEM_SAMPLING_ACTIVE() || PMC_PROC_IS_USING_PMCS(p)) {
 		PROC_UNLOCK(p);
+		VOP_UNLOCK(imgp->vp, 0);
 		pe.pm_credentialschanged = credential_changing;
 		pe.pm_entryaddr = imgp->entry_addr;
 
 		PMC_CALL_HOOK_X(td, PMC_FN_PROCESS_EXEC, (void *) &pe);
+		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
 	} else
 		PROC_UNLOCK(p);
 #else  /* !HWPMC_HOOKS */
From pjd at FreeBSD.org  Wed Sep  9 12:56:05 2009
From: pjd at FreeBSD.org (Pawel Jakub Dawidek)
Date: Wed Sep  9 12:56:16 2009
Subject: svn commit: r197039 - head/sys/nfsserver
Message-ID: <200909091256.n89Cu5Pn086130@svn.freebsd.org>

Author: pjd
Date: Wed Sep  9 12:56:05 2009
New Revision: 197039
URL: http://svn.freebsd.org/changeset/base/197039

Log:
  Fix usecount leak in mknod(2) on file system exported over NFS.
  
  While I'm here, correct typo in comment.
  
  Reviewed by:	kan, kib
  MFC after:	3 days

Modified:
  head/sys/nfsserver/nfs_serv.c

Modified: head/sys/nfsserver/nfs_serv.c
==============================================================================
--- head/sys/nfsserver/nfs_serv.c	Wed Sep  9 12:19:43 2009	(r197038)
+++ head/sys/nfsserver/nfs_serv.c	Wed Sep  9 12:56:05 2009	(r197039)
@@ -1686,7 +1686,7 @@ out:
 	if (dirp) {
 		vn_lock(dirp, LK_EXCLUSIVE | LK_RETRY);
 		diraft_ret = VOP_GETATTR(dirp, &diraft, cred);
-		VOP_UNLOCK(dirp, 0);
+		vput(drip);
 	}
 ereply:
 	nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
@@ -3825,7 +3825,7 @@ nfsmout:
  *     what the heck.
  *
  * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS()
- * will return EPERM instead of EACCESS. EPERM is always an error.
+ * will return EPERM instead of EACCES. EPERM is always an error.
  */
 static int
 nfsrv_access(struct vnode *vp, accmode_t accmode, struct ucred *cred,
From pjd at FreeBSD.org  Wed Sep  9 13:23:26 2009
From: pjd at FreeBSD.org (Pawel Jakub Dawidek)
Date: Wed Sep  9 13:23:33 2009
Subject: svn commit: r197040 - head/sys/nfsserver
Message-ID: <200909091323.n89DNQ3B086714@svn.freebsd.org>

Author: pjd
Date: Wed Sep  9 13:23:26 2009
New Revision: 197040
URL: http://svn.freebsd.org/changeset/base/197040

Log:
  Correct typo after manual patching.
  
  Noticed by:	b. f.

Modified:
  head/sys/nfsserver/nfs_serv.c

Modified: head/sys/nfsserver/nfs_serv.c
==============================================================================
--- head/sys/nfsserver/nfs_serv.c	Wed Sep  9 12:56:05 2009	(r197039)
+++ head/sys/nfsserver/nfs_serv.c	Wed Sep  9 13:23:26 2009	(r197040)
@@ -1686,7 +1686,7 @@ out:
 	if (dirp) {
 		vn_lock(dirp, LK_EXCLUSIVE | LK_RETRY);
 		diraft_ret = VOP_GETATTR(dirp, &diraft, cred);
-		vput(drip);
+		vput(dirp);
 	}
 ereply:
 	nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
From ache at nagual.pp.ru  Wed Sep  9 13:26:19 2009
From: ache at nagual.pp.ru (Andrey Chernov)
Date: Wed Sep  9 13:26:30 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <200909081555.n88FtDwe052523@svn.freebsd.org>
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
Message-ID: <20090909132616.GA35808@nagual.pp.ru>

On Tue, Sep 08, 2009 at 03:55:13PM +0000, Roman Divacky wrote:
> +		 * Detect whether this is a text file.  The correct way to
> +		 * do this is to check the least significant bit of the
> +		 * "internal file attributes" field of the corresponding
> +		 * file header in the central directory, but libarchive
> +		 * does not read the central directory, so we have to
> +		 * guess by looking for non-ASCII characters in the
> +		 * buffer.  Hopefully we won't guess wrong.  If we do
> +		 * guess wrong, we print a warning message later.
> +		 */
> +		if (a_opt && n == 0) {
> +			for (p = buffer; p < end; ++p) {
> +				if (!isascii((unsigned char)*p)) {
> +					text = 0;
> +					break;
> +				}
> +			}
> +		}
> +

If I understand the purpose of this code right, better use
isalnum()+ispunct()+ispace()
combination to count non-ASCII people too.
Also setlocale() call must be added to the main() for that.

-- 
http://ache.pp.ru/
From bz at FreeBSD.org  Wed Sep  9 14:17:08 2009
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Wed Sep  9 14:17:19 2009
Subject: svn commit: r197042 - head/share/man/man4/man4.i386
Message-ID: <200909091417.n89EH7RT087958@svn.freebsd.org>

Author: bz
Date: Wed Sep  9 14:17:07 2009
New Revision: 197042
URL: http://svn.freebsd.org/changeset/base/197042

Log:
  Remove dpms.4 missed in r197025.

Modified:
  head/share/man/man4/man4.i386/Makefile

Modified: head/share/man/man4/man4.i386/Makefile
==============================================================================
--- head/share/man/man4/man4.i386/Makefile	Wed Sep  9 13:28:18 2009	(r197041)
+++ head/share/man/man4/man4.i386/Makefile	Wed Sep  9 14:17:07 2009	(r197042)
@@ -10,7 +10,6 @@ MAN=	aic.4 \
 	cs.4 \
 	ct.4 \
 	ctau.4 \
-	dpms.4 \
 	cx.4 \
 	ep.4 \
 	ex.4 \
From des at des.no  Wed Sep  9 15:14:33 2009
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Wed Sep  9 15:14:40 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <20090909132616.GA35808@nagual.pp.ru> (Andrey Chernov's message
	of "Wed, 9 Sep 2009 17:26:16 +0400")
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
	<20090909132616.GA35808@nagual.pp.ru>
Message-ID: <86d460kv53.fsf@ds4.des.no>

Andrey Chernov  writes:
> If I understand the purpose of this code right, better use
> isalnum()+ispunct()+ispace()
> combination to count non-ASCII people too.

uh, isprint() perhaps?

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From kientzle at freebsd.org  Wed Sep  9 15:16:11 2009
From: kientzle at freebsd.org (Tim Kientzle)
Date: Wed Sep  9 15:16:22 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <20090909132616.GA35808@nagual.pp.ru>
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
	<20090909132616.GA35808@nagual.pp.ru>
Message-ID: <4AA7C6B9.1020600@freebsd.org>

Andrey Chernov wrote:
> On Tue, Sep 08, 2009 at 03:55:13PM +0000, Roman Divacky wrote:
>> +	 * Detect whether this is a text file.  ...  but libarchive
>> +	 * does not read the central directory, so we have to
>> +	 * guess ...
>> +	 */
>> +	if (a_opt && n == 0) {
>> +		for (p = buffer; p < end; ++p) {
>> +			if (!isascii((unsigned char)*p)) {
>> +				text = 0;
>> +				break;
>> +			}
>> +		}
>> +	}
>> +
> 
> If I understand the purpose of this code right, better use
> isalnum()+ispunct()+ispace()
> combination to count non-ASCII people too.
> Also setlocale() call must be added to the main() for that.

Personally, I would rather see unzip just ignore the -a
option entirely, but I suppose that's probably infeasible.

Since this is only to support -a (which does end-of-line
conversions), I would suggest using a rather different
set of heuristics that examines end-of-line sequences
and control characters only:
   * Any byte value <31 that's not CR or LF: not text
   * LF not preceded by CR: not text
   * CR not followed by LF: not text (or at least, not DOS text)
   * Otherwise, it is text.

At a minimum, this dodges the locale issue.

Someday, I'll get around to filling in the seek support
that libarchive needs for reading central directories,
then unzip can look at the "text file" bit (which
is no more reliable than anything described above) and
this code can just go away.

Tim
From ache at nagual.pp.ru  Wed Sep  9 16:31:50 2009
From: ache at nagual.pp.ru (Andrey Chernov)
Date: Wed Sep  9 16:31:57 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <86d460kv53.fsf@ds4.des.no>
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
	<20090909132616.GA35808@nagual.pp.ru> <86d460kv53.fsf@ds4.des.no>
Message-ID: <20090909163144.GA37924@nagual.pp.ru>

On Wed, Sep 09, 2009 at 05:14:32PM +0200, Dag-Erling Sm??rgrav wrote:
> Andrey Chernov  writes:
> > If I understand the purpose of this code right, better use
> > isalnum()+ispunct()+ispace()
> > combination to count non-ASCII people too.
> 
> uh, isprint() perhaps?

In some charsets there are a lots of printable characters which are rarely 
part of the regular text, i.e. pseudographics. isprint() looks too greedy.

-- 
http://ache.pp.ru/
From ache at nagual.pp.ru  Wed Sep  9 16:39:41 2009
From: ache at nagual.pp.ru (Andrey Chernov)
Date: Wed Sep  9 16:39:53 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <4AA7C6B9.1020600@freebsd.org>
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
	<20090909132616.GA35808@nagual.pp.ru>
	<4AA7C6B9.1020600@freebsd.org>
Message-ID: <20090909163937.GB37924@nagual.pp.ru>

On Wed, Sep 09, 2009 at 08:16:09AM -0700, Tim Kientzle wrote:
> Since this is only to support -a (which does end-of-line
> conversions), I would suggest using a rather different
> set of heuristics that examines end-of-line sequences
> and control characters only:
>    * Any byte value <31 that's not CR or LF: not text

More carefully - <32, TAB and ^Z (MSDOS EOT) must be 
allowed too and perhaps ^L.

-- 
http://ache.pp.ru/
From np at FreeBSD.org  Wed Sep  9 18:55:18 2009
From: np at FreeBSD.org (Navdeep Parhar)
Date: Wed Sep  9 18:55:24 2009
Subject: svn commit: r197043 - head/sys/dev/cxgb
Message-ID: <200909091855.n89ItIe8093950@svn.freebsd.org>

Author: np
Date: Wed Sep  9 18:55:18 2009
New Revision: 197043
URL: http://svn.freebsd.org/changeset/base/197043

Log:
  There is no need to log anything for a ctrlq stall or restart.  These are
  normal events.
  
  Approved by:	gnn (mentor)
  MFC after:	1 month

Modified:
  head/sys/dev/cxgb/cxgb_sge.c

Modified: head/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_sge.c	Wed Sep  9 14:17:07 2009	(r197042)
+++ head/sys/dev/cxgb/cxgb_sge.c	Wed Sep  9 18:55:18 2009	(r197043)
@@ -1942,7 +1942,6 @@ again:	reclaim_completed_tx_imm(q);
 	if (__predict_false(ret)) {
 		if (ret == 1) {
 			TXQ_UNLOCK(qs);
-			log(LOG_ERR, "no desc available\n");
 			return (ENOSPC);
 		}
 		goto again;
@@ -1955,6 +1954,7 @@ again:	reclaim_completed_tx_imm(q);
 		q->gen ^= 1;
 	}
 	TXQ_UNLOCK(qs);
+	wmb();
 	t3_write_reg(adap, A_SG_KDOORBELL,
 		     F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
 	return (0);
@@ -1975,8 +1975,6 @@ restart_ctrlq(void *data, int npending)
 	struct sge_txq *q = &qs->txq[TXQ_CTRL];
 	adapter_t *adap = qs->port->adapter;
 
-	log(LOG_WARNING, "Restart_ctrlq in_use=%d\n", q->in_use);
-	
 	TXQ_LOCK(qs);
 again:	reclaim_completed_tx_imm(q);
 
@@ -2928,9 +2926,9 @@ handle_rsp_cntrl_info(struct sge_qset *q
 	credits = G_RSPD_TXQ0_CR(flags);
 	if (credits) 
 		qs->txq[TXQ_ETH].processed += credits;
-	
+
 	credits = G_RSPD_TXQ2_CR(flags);
-	if (credits) 
+	if (credits)
 		qs->txq[TXQ_CTRL].processed += credits;
 
 # if USE_GTS
@@ -3133,12 +3131,9 @@ process_responses(adapter_t *adap, struc
 		check_ring_db(adap, qs, sleeping);
 
 	mb();  /* commit Tx queue processed updates */
-	if (__predict_false(qs->txq_stopped > 1)) {
-		printf("restarting tx on %p\n", qs);
-		
+	if (__predict_false(qs->txq_stopped > 1))
 		restart_tx(qs);
-	}
-	
+
 	__refill_fl_lt(adap, &qs->fl[0], 512);
 	__refill_fl_lt(adap, &qs->fl[1], 512);
 	budget -= budget_left;
From pjd at FreeBSD.org  Wed Sep  9 19:06:01 2009
From: pjd at FreeBSD.org (Pawel Jakub Dawidek)
Date: Wed Sep  9 19:06:12 2009
Subject: svn commit: r197044 - head/sbin/geom/class/mirror
Message-ID: <200909091906.n89J61nd094276@svn.freebsd.org>

Author: pjd
Date: Wed Sep  9 19:06:01 2009
New Revision: 197044
URL: http://svn.freebsd.org/changeset/base/197044

Log:
  Actually component with the greatest priority is used by the prefer balance
  algorithm.

Modified:
  head/sbin/geom/class/mirror/gmirror.8

Modified: head/sbin/geom/class/mirror/gmirror.8
==============================================================================
--- head/sbin/geom/class/mirror/gmirror.8	Wed Sep  9 18:55:18 2009	(r197043)
+++ head/sbin/geom/class/mirror/gmirror.8	Wed Sep  9 19:06:01 2009	(r197044)
@@ -122,7 +122,7 @@ indicates an action to be performed:
 Create a mirror.
 The order of components is important, because a component's priority is based on its position
 (starting from 0 to 255).
-The component with the biggest priority (the lowest number) is used by the
+The component with the biggest priority is used by the
 .Cm prefer
 balance algorithm
 and is also used as a master component when resynchronization is needed,
From ed at FreeBSD.org  Wed Sep  9 19:38:20 2009
From: ed at FreeBSD.org (Ed Schouten)
Date: Wed Sep  9 19:38:31 2009
Subject: svn commit: r197045 - head/lib/libc/stdio
Message-ID: <200909091938.n89JcJnM094972@svn.freebsd.org>

Author: ed
Date: Wed Sep  9 19:38:19 2009
New Revision: 197045
URL: http://svn.freebsd.org/changeset/base/197045

Log:
  Make the description of `b' a little better.
  
  If you have a one-byte sequence, `w', `b' is the second character. Not
  the third.
  
  Submitted by:	Christoph Mallon

Modified:
  head/lib/libc/stdio/fopen.3

Modified: head/lib/libc/stdio/fopen.3
==============================================================================
--- head/lib/libc/stdio/fopen.3	Wed Sep  9 19:06:01 2009	(r197044)
+++ head/lib/libc/stdio/fopen.3	Wed Sep  9 19:38:19 2009	(r197045)
@@ -96,7 +96,7 @@ or similar.
 .Pp
 The
 .Fa mode
-string can also include the letter ``b'' either as a third character or
+string can also include the letter ``b'' either as last character or
 as a character between the characters in any of the two-character strings
 described above.
 This is strictly for compatibility with
From kib at FreeBSD.org  Wed Sep  9 19:40:55 2009
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Wed Sep  9 19:41:22 2009
Subject: svn commit: r197046 - head/sys/i386/xen
Message-ID: <200909091940.n89Jessi095063@svn.freebsd.org>

Author: kib
Date: Wed Sep  9 19:40:54 2009
New Revision: 197046
URL: http://svn.freebsd.org/changeset/base/197046

Log:
  As was done in r196643 for i386 and amd64, swap the start/end virtual
  addresses in pmap_invalidate_cache_range().
  
  Reported by:	Vincent Hoffman 
  Reviewed by:	jhb
  MFC after:	3 days

Modified:
  head/sys/i386/xen/pmap.c

Modified: head/sys/i386/xen/pmap.c
==============================================================================
--- head/sys/i386/xen/pmap.c	Wed Sep  9 19:38:19 2009	(r197045)
+++ head/sys/i386/xen/pmap.c	Wed Sep  9 19:40:54 2009	(r197046)
@@ -1004,8 +1004,8 @@ pmap_invalidate_cache_range(vm_offset_t 
 		 * coherence domain.
 		 */
 		mfence();
-		for (; eva < sva; eva += cpu_clflush_line_size)
-			clflush(eva);
+		for (; sva < eva; sva += cpu_clflush_line_size)
+			clflush(sva);
 		mfence();
 	} else {
 
From brooks at FreeBSD.org  Wed Sep  9 20:28:58 2009
From: brooks at FreeBSD.org (Brooks Davis)
Date: Wed Sep  9 20:29:04 2009
Subject: svn commit: r197047 - head/share/man/man4
Message-ID: <200909092028.n89KSw1N096254@svn.freebsd.org>

Author: brooks
Date: Wed Sep  9 20:28:58 2009
New Revision: 197047
URL: http://svn.freebsd.org/changeset/base/197047

Log:
  Mention that a few ed(4) devices don't emit link state change notices
  and a workaround for dhclient.
  
  Reviewed by:	 thierry
  MFC after:	3 days

Modified:
  head/share/man/man4/ed.4

Modified: head/share/man/man4/ed.4
==============================================================================
--- head/share/man/man4/ed.4	Wed Sep  9 19:40:54 2009	(r197046)
+++ head/share/man/man4/ed.4	Wed Sep  9 20:28:58 2009	(r197047)
@@ -425,3 +425,21 @@ driver is slow by today's standards.
 .Pp
 PC Card attachment supports the D-Link DMF650TX LAN/Modem card's Ethernet
 port only at this time.
+.Pp
+Some devices supported by
+.Nm
+do no generate the link state change events used by
+.Xr devd 8
+to start
+.Xr dhclinet 8 .
+If you have problems with
+.Xr dhclient 8
+not starting and the device is always attached to the network it may
+be possible to work around this by changing
+.Dq Li DHCP
+to
+.Dq Li SYNCDHCP
+in the
+.Va ifconfig_ed0
+entry in
+.Pa /etc/rc.conf .
From rmacklem at FreeBSD.org  Wed Sep  9 20:37:49 2009
From: rmacklem at FreeBSD.org (Rick Macklem)
Date: Wed Sep  9 20:37:56 2009
Subject: svn commit: r197048 - in head/sys: fs/nfsclient nfsclient
Message-ID: <200909092037.n89Kbnwi096782@svn.freebsd.org>

Author: rmacklem
Date: Wed Sep  9 20:37:49 2009
New Revision: 197048
URL: http://svn.freebsd.org/changeset/base/197048

Log:
  Add LK_NOWITNESS to the vn_lock() calls done on newly created nfs
  vnodes, since these nodes are not linked into the mount queue and,
  as such, the vn_lock() cannot cause a deadlock so LORs are harmless.
  
  Suggested by:	kib
  Approved by:	kib (mentor)
  MFC after:	3 days

Modified:
  head/sys/fs/nfsclient/nfs_clnode.c
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/nfsclient/nfs_node.c

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c	Wed Sep  9 20:28:58 2009	(r197047)
+++ head/sys/fs/nfsclient/nfs_clnode.c	Wed Sep  9 20:37:49 2009	(r197048)
@@ -157,7 +157,7 @@ ncl_nget(struct mount *mntp, u_int8_t *f
 	    M_NFSFH, M_WAITOK);
 	bcopy(fhp, np->n_fhp->nfh_fh, fhsize);
 	np->n_fhp->nfh_len = fhsize;
-	lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
+	lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_NOWITNESS, NULL);
 	error = insmntque(vp, mntp);
 	if (error != 0) {
 		*npp = NULL;

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Wed Sep  9 20:28:58 2009	(r197047)
+++ head/sys/fs/nfsclient/nfs_clport.c	Wed Sep  9 20:37:49 2009	(r197048)
@@ -232,7 +232,7 @@ nfscl_nget(struct mount *mntp, struct vn
 	 */
 	VN_LOCK_AREC(vp);
 	VN_LOCK_ASHARE(vp);
-	lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
+	lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_NOWITNESS, NULL);
 	error = insmntque(vp, mntp);
 	if (error != 0) {
 		*npp = NULL;

Modified: head/sys/nfsclient/nfs_node.c
==============================================================================
--- head/sys/nfsclient/nfs_node.c	Wed Sep  9 20:28:58 2009	(r197047)
+++ head/sys/nfsclient/nfs_node.c	Wed Sep  9 20:37:49 2009	(r197048)
@@ -158,7 +158,7 @@ nfs_nget(struct mount *mntp, nfsfh_t *fh
 		np->n_fhp = &np->n_fh;
 	bcopy((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize);
 	np->n_fhsize = fhsize;
-	lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
+	lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_NOWITNESS, NULL);
 	error = insmntque(vp, mntp);
 	if (error != 0) {
 		*npp = NULL;
From kib at FreeBSD.org  Wed Sep  9 20:59:02 2009
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Wed Sep  9 20:59:08 2009
Subject: svn commit: r197049 - in head/sys: compat/freebsd32 compat/linux
	kern sys
Message-ID: <200909092059.n89Kx1Oh097291@svn.freebsd.org>

Author: kib
Date: Wed Sep  9 20:59:01 2009
New Revision: 197049
URL: http://svn.freebsd.org/changeset/base/197049

Log:
  kern_select(9) copies fd_set in and out of userspace in quantities of
  longs. Since 32bit processes longs are 4 bytes, 64bit kernel may copy in
  or out 4 bytes more then the process expected.
  
  Calculate the amount of bytes to copy taking into account size of fd_set
  for the current process ABI.
  
  Diagnosed and tested by:	Peter Jeremy 
  Reviewed by:	jhb
  MFC after:	1 week

Modified:
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/linux/linux_misc.c
  head/sys/kern/sys_generic.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c	Wed Sep  9 20:37:49 2009	(r197048)
+++ head/sys/compat/freebsd32/freebsd32_misc.c	Wed Sep  9 20:59:01 2009	(r197049)
@@ -589,7 +589,8 @@ freebsd32_select(struct thread *td, stru
 	 * XXX big-endian needs to convert the fd_sets too.
 	 * XXX Do pointers need PTRIN()?
 	 */
-	return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp));
+	return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
+	    sizeof(int32_t) * 8));
 }
 
 /*

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Wed Sep  9 20:37:49 2009	(r197048)
+++ head/sys/compat/linux/linux_misc.c	Wed Sep  9 20:59:01 2009	(r197049)
@@ -522,7 +522,7 @@ linux_select(struct thread *td, struct l
 		tvp = NULL;
 
 	error = kern_select(td, args->nfds, args->readfds, args->writefds,
-	    args->exceptfds, tvp);
+	    args->exceptfds, tvp, sizeof(l_int) * 8);
 
 #ifdef DEBUG
 	if (ldebug(select))

Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c	Wed Sep  9 20:37:49 2009	(r197048)
+++ head/sys/kern/sys_generic.c	Wed Sep  9 20:59:01 2009	(r197049)
@@ -774,12 +774,13 @@ select(td, uap)
 	} else
 		tvp = NULL;
 
-	return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp));
+	return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
+	    NFDBITS));
 }
 
 int
 kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
-    fd_set *fd_ex, struct timeval *tvp)
+    fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits)
 {
 	struct filedesc *fdp;
 	/*
@@ -792,7 +793,7 @@ kern_select(struct thread *td, int nd, f
 	fd_mask *ibits[3], *obits[3], *selbits, *sbp;
 	struct timeval atv, rtv, ttv;
 	int error, timo;
-	u_int nbufbytes, ncpbytes, nfdbits;
+	u_int nbufbytes, ncpbytes, ncpubytes, nfdbits;
 
 	if (nd < 0)
 		return (EINVAL);
@@ -806,6 +807,7 @@ kern_select(struct thread *td, int nd, f
 	 */
 	nfdbits = roundup(nd, NFDBITS);
 	ncpbytes = nfdbits / NBBY;
+	ncpubytes = roundup(nd, abi_nfdbits) / NBBY;
 	nbufbytes = 0;
 	if (fd_in != NULL)
 		nbufbytes += 2 * ncpbytes;
@@ -832,9 +834,11 @@ kern_select(struct thread *td, int nd, f
 			ibits[x] = sbp + nbufbytes / 2 / sizeof *sbp;	\
 			obits[x] = sbp;					\
 			sbp += ncpbytes / sizeof *sbp;			\
-			error = copyin(name, ibits[x], ncpbytes);	\
+			error = copyin(name, ibits[x], ncpubytes);	\
 			if (error != 0)					\
 				goto done;				\
+			bzero((char *)ibits[x] + ncpubytes,		\
+			    ncpbytes - ncpubytes);			\
 		}							\
 	} while (0)
 	getbits(fd_in, 0);
@@ -888,7 +892,7 @@ done:
 	if (error == EWOULDBLOCK)
 		error = 0;
 #define	putbits(name, x) \
-	if (name && (error2 = copyout(obits[x], name, ncpbytes))) \
+	if (name && (error2 = copyout(obits[x], name, ncpubytes))) \
 		error = error2;
 	if (error == 0) {
 		int error2;

Modified: head/sys/sys/syscallsubr.h
==============================================================================
--- head/sys/sys/syscallsubr.h	Wed Sep  9 20:37:49 2009	(r197048)
+++ head/sys/sys/syscallsubr.h	Wed Sep  9 20:59:01 2009	(r197049)
@@ -170,7 +170,7 @@ int	kern_sched_rr_get_interval(struct th
 int	kern_semctl(struct thread *td, int semid, int semnum, int cmd,
 	    union semun *arg, register_t *rval);
 int	kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
-	    fd_set *fd_ex, struct timeval *tvp);
+	    fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits);
 int	kern_sendfile(struct thread *td, struct sendfile_args *uap,
 	    struct uio *hdr_uio, struct uio *trl_uio, int compat);
 int	kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
From brooks at FreeBSD.org  Wed Sep  9 21:51:55 2009
From: brooks at FreeBSD.org (Brooks Davis)
Date: Wed Sep  9 21:52:01 2009
Subject: svn commit: r197050 - head/share/man/man4
Message-ID: <200909092151.n89LpsIr098469@svn.freebsd.org>

Author: brooks
Date: Wed Sep  9 21:51:54 2009
New Revision: 197050
URL: http://svn.freebsd.org/changeset/base/197050

Log:
  Change one no to not in r197047
  
  Submitted by:	John Nielsen 

Modified:
  head/share/man/man4/ed.4

Modified: head/share/man/man4/ed.4
==============================================================================
--- head/share/man/man4/ed.4	Wed Sep  9 20:59:01 2009	(r197049)
+++ head/share/man/man4/ed.4	Wed Sep  9 21:51:54 2009	(r197050)
@@ -428,7 +428,7 @@ port only at this time.
 .Pp
 Some devices supported by
 .Nm
-do no generate the link state change events used by
+do not generate the link state change events used by
 .Xr devd 8
 to start
 .Xr dhclinet 8 .
From imp at FreeBSD.org  Thu Sep 10 00:47:33 2009
From: imp at FreeBSD.org (Warner Losh)
Date: Thu Sep 10 00:47:39 2009
Subject: svn commit: r197051 - head/usr.sbin/btxld
Message-ID: <200909100047.n8A0lWwR002368@svn.freebsd.org>

Author: imp
Date: Thu Sep 10 00:47:32 2009
New Revision: 197051
URL: http://svn.freebsd.org/changeset/base/197051

Log:
  The boot loader is a FreeBSD a.out binary for x86, not a VAX binary.
  Rather than writing out a MID of '0', write a MID of 0x86 (aka
  MID_I386) so that file gets it right.
  
  This is a nop for boot2.  It just checks the MAGIC part of the field,
  ignoring the MID.  boot2 is the only thing that loads this file, and
  only on x86 so the MID_i386 is always the right value (the rest of the
  code is already x86 specific).
  
  Reviewed by:	bde@, jhb@
  MFC after:	8.0 is out the door :)

Modified:
  head/usr.sbin/btxld/btxld.c

Modified: head/usr.sbin/btxld/btxld.c
==============================================================================
--- head/usr.sbin/btxld/btxld.c	Wed Sep  9 21:51:54 2009	(r197050)
+++ head/usr.sbin/btxld/btxld.c	Thu Sep 10 00:47:32 2009	(r197051)
@@ -407,7 +407,7 @@ puthdr(int fd, struct hdr *hdr)
     switch (hdr->fmt) {
     case F_AOUT:
 	memset(&ex, 0, sizeof(ex));
-	N_SETMAGIC(ex, ZMAGIC, MID_ZERO, 0);
+	N_SETMAGIC(ex, ZMAGIC, MID_I386, 0);
 	hdr->text = N_ALIGN(ex, hdr->text);
 	ex.a_text = htole32(hdr->text);
 	hdr->data = N_ALIGN(ex, hdr->data);
From edwin at FreeBSD.org  Thu Sep 10 01:26:46 2009
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Thu Sep 10 01:26:56 2009
Subject: svn commit: r197052 - head/release/doc/en_US.ISO8859-1/relnotes
Message-ID: <200909100126.n8A1Qj2q003231@svn.freebsd.org>

Author: edwin
Date: Thu Sep 10 01:26:45 2009
New Revision: 197052
URL: http://svn.freebsd.org/changeset/base/197052

Log:
  Mention update to tzdata2009m.

Modified:
  head/release/doc/en_US.ISO8859-1/relnotes/article.sgml

Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.sgml
==============================================================================
--- head/release/doc/en_US.ISO8859-1/relnotes/article.sgml	Thu Sep 10 00:47:32 2009	(r197051)
+++ head/release/doc/en_US.ISO8859-1/relnotes/article.sgml	Thu Sep 10 01:26:45 2009	(r197052)
@@ -472,7 +472,7 @@
 
     The timezone database has been updated from
       the tzdata2008h release to
-      the tzdata2009j release.
+      the tzdata2009m release.
 
     The stdtime part of libc, &man.zdump.8 and &man.zic.8
       have been updated from the tzcode2004a
From kientzle at freebsd.org  Thu Sep 10 03:47:29 2009
From: kientzle at freebsd.org (Tim Kientzle)
Date: Thu Sep 10 03:47:41 2009
Subject: svn commit: r196981 - head/usr.bin/unzip
In-Reply-To: <20090909163937.GB37924@nagual.pp.ru>
References: <200909081555.n88FtDwe052523@svn.freebsd.org>
	<20090909132616.GA35808@nagual.pp.ru>
	<4AA7C6B9.1020600@freebsd.org>
	<20090909163937.GB37924@nagual.pp.ru>
Message-ID: <4AA876CF.8000903@freebsd.org>

Andrey Chernov wrote:
> On Wed, Sep 09, 2009 at 08:16:09AM -0700, Tim Kientzle wrote:
>> Since this is only to support -a (which does end-of-line
>> conversions), I would suggest using a rather different
>> set of heuristics that examines end-of-line sequences
>> and control characters only:
>>    * Any byte value <31 that's not CR or LF: not text
> 
> More carefully - <32, TAB and ^Z (MSDOS EOT) must be 
> allowed too and perhaps ^L.

Yes, but be careful.  Remember that -a processing
is destructive; it's better to err on the side of
marking something binary.

Tim

From des at FreeBSD.org  Thu Sep 10 07:37:37 2009
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Thu Sep 10 07:37:43 2009
Subject: svn commit: r197056 - head
Message-ID: <200909100737.n8A7baad010801@svn.freebsd.org>

Author: des
Date: Thu Sep 10 07:37:36 2009
New Revision: 197056
URL: http://svn.freebsd.org/changeset/base/197056

Log:
  Fix comment about KERNFAST.

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Thu Sep 10 02:23:55 2009	(r197055)
+++ head/Makefile.inc1	Thu Sep 10 07:37:36 2009	(r197056)
@@ -5,7 +5,7 @@
 #	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
 #	-DNO_CLEAN do not clean at all
 #	-DNO_SHARE do not go into share subdir
-#	-DKERNFAST define NO_KERNELCONFIG, NO_KERNELCLEAN and NO_KERNELCONFIG
+#	-DKERNFAST define NO_KERNELCONFIG, NO_KERNELCLEAN and NO_KERNELDEPEND
 #	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
 #	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
 #	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
From des at FreeBSD.org  Thu Sep 10 08:33:28 2009
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Thu Sep 10 08:33:47 2009
Subject: svn commit: r197057 - in head/sys: compat/freebsd32 sys
Message-ID: <200909100833.n8A8XSIc011874@svn.freebsd.org>

Author: des
Date: Thu Sep 10 08:33:28 2009
New Revision: 197057
URL: http://svn.freebsd.org/changeset/base/197057

Log:
  If a certain feature that was present in FreeBSD 7 was removed or changed in
  FreeBSD 8, the compatibility shims should be built not just when FreeBSD 7
  compatibility is requested, but also when compatibility with any older
  FreeBSD version where that feature was present is requested.o
  
  Without this patch, a kernel config that sets COMPAT_FREEBSD6 but not *7
  would fail to build due to inconsistencies between the declaration of the
  compatibility shims and their use in the SysV code.
  
  There are similar errors in other *proto.h headers in the tree.
  
  MFC after:	3 weeks

Modified:
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/sys/sysproto.h

Modified: head/sys/compat/freebsd32/freebsd32_proto.h
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_proto.h	Thu Sep 10 07:37:36 2009	(r197056)
+++ head/sys/compat/freebsd32/freebsd32_proto.h	Thu Sep 10 08:33:28 2009	(r197057)
@@ -626,7 +626,8 @@ int	freebsd4_freebsd32_sigreturn(struct 
 #endif /* COMPAT_FREEBSD4 */
 
 
-#ifdef COMPAT_FREEBSD6
+#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
+	defined(COMPAT_FREEBSD6)
 
 struct freebsd6_freebsd32_pread_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
@@ -680,10 +681,11 @@ int	freebsd6_freebsd32_lseek(struct thre
 int	freebsd6_freebsd32_truncate(struct thread *, struct freebsd6_freebsd32_truncate_args *);
 int	freebsd6_freebsd32_ftruncate(struct thread *, struct freebsd6_freebsd32_ftruncate_args *);
 
-#endif /* COMPAT_FREEBSD6 */
+#endif /* COMPAT_FREEBSD[456] */
 
 
-#ifdef COMPAT_FREEBSD7
+#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
+	defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 
 struct freebsd7_freebsd32_semctl_args {
 	char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)];
@@ -705,7 +707,7 @@ int	freebsd7_freebsd32_semctl(struct thr
 int	freebsd7_freebsd32_msgctl(struct thread *, struct freebsd7_freebsd32_msgctl_args *);
 int	freebsd7_freebsd32_shmctl(struct thread *, struct freebsd7_freebsd32_shmctl_args *);
 
-#endif /* COMPAT_FREEBSD7 */
+#endif /* COMPAT_FREEBSD[4567] */
 
 #define	FREEBSD32_SYS_AUE_freebsd32_wait4	AUE_WAIT4
 #define	FREEBSD32_SYS_AUE_freebsd4_freebsd32_getfsstat	AUE_GETFSSTAT

Modified: head/sys/sys/sysproto.h
==============================================================================
--- head/sys/sys/sysproto.h	Thu Sep 10 07:37:36 2009	(r197056)
+++ head/sys/sys/sysproto.h	Thu Sep 10 08:33:28 2009	(r197057)
@@ -2233,13 +2233,21 @@ int	freebsd4_sigreturn(struct thread *, 
 #endif /* COMPAT_FREEBSD4 */
 
 
-#ifdef COMPAT_FREEBSD6
+#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5)
 
 
-#endif /* COMPAT_FREEBSD6 */
+#endif /* COMPAT_FREEBSD[45] */
 
 
-#ifdef COMPAT_FREEBSD7
+#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
+	defined(COMPAT_FREEBSD6)
+
+
+#endif /* COMPAT_FREEBSD[456] */
+
+
+#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
+	defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 
 struct freebsd7___semctl_args {
 	char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)];
@@ -2261,7 +2269,7 @@ int	freebsd7___semctl(struct thread *, s
 int	freebsd7_msgctl(struct thread *, struct freebsd7_msgctl_args *);
 int	freebsd7_shmctl(struct thread *, struct freebsd7_shmctl_args *);
 
-#endif /* COMPAT_FREEBSD7 */
+#endif /* COMPAT_FREEBSD[4567] */
 
 #define	SYS_AUE_syscall	AUE_NULL
 #define	SYS_AUE_exit	AUE_EXIT
From jhb at freebsd.org  Thu Sep 10 12:48:30 2009
From: jhb at freebsd.org (John Baldwin)
Date: Thu Sep 10 12:48:38 2009
Subject: svn commit: r197057 - in head/sys: compat/freebsd32 sys
In-Reply-To: <200909100833.n8A8XSIc011874@svn.freebsd.org>
References: <200909100833.n8A8XSIc011874@svn.freebsd.org>
Message-ID: <200909100833.22353.jhb@freebsd.org>

On Thursday 10 September 2009 4:33:28 am Dag-Erling Smorgrav wrote:
> Author: des
> Date: Thu Sep 10 08:33:28 2009
> New Revision: 197057
> URL: http://svn.freebsd.org/changeset/base/197057
> 
> Log:
>   If a certain feature that was present in FreeBSD 7 was removed or changed 
in
>   FreeBSD 8, the compatibility shims should be built not just when FreeBSD 7
>   compatibility is requested, but also when compatibility with any older
>   FreeBSD version where that feature was present is requested.o
>   
>   Without this patch, a kernel config that sets COMPAT_FREEBSD6 but not *7
>   would fail to build due to inconsistencies between the declaration of the
>   compatibility shims and their use in the SysV code.
>   
>   There are similar errors in other *proto.h headers in the tree.
>   
>   MFC after:	3 weeks

These are auto-generated files.  Please revert.  If you want to try to fix 
this, you will have to patch makesyscalls.sh.  However, this is rather 
complicated.  The SYSV IPC case is simpler because the system calls aren't 
enabled in init_sysent.c but use SYSCALL_MODULE() instead.  However, other 
compat syscalls are enabled in init_sysent.c.

One possible fix is that makesyscalls.sh could be futher extended so that 
compat system calls can be tagged with multiple compat versions perhaps such 
as 'COMPAT4|COMPAT5'.  However, this would not be a trivial change to 
makesyscalls.sh.

When this issue first came up, the consensus among other developers I talked 
to was that it was ok to simply mandate that 'COMPAT_FREEBSD[456]' 
require 'COMPAT_FREEBSD7' which has been noted in src/UPDATING.

I could take a look at the makesyscalls.sh changes perhaps.

-- 
John Baldwin
From jhb at FreeBSD.org  Thu Sep 10 12:58:38 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Sep 10 12:58:53 2009
Subject: svn commit: r197062 - head/sys/dev/syscons/daemon
Message-ID: <200909101258.n8ACwcqC020098@svn.freebsd.org>

Author: jhb
Date: Thu Sep 10 12:58:37 2009
New Revision: 197062
URL: http://svn.freebsd.org/changeset/base/197062

Log:
  Don't malloc a buffer while holding the prison0 mutex.  Instead, use a loop
  where we figure out the hostname length under the lock, malloc the buffer
  with the lock dropped, then recheck the length under the lock and loop again
  if the buffer is now too small.
  
  Tested by:	Norbert Koch  nkoch  demig de
  MFC after:	3 days

Modified:
  head/sys/dev/syscons/daemon/daemon_saver.c

Modified: head/sys/dev/syscons/daemon/daemon_saver.c
==============================================================================
--- head/sys/dev/syscons/daemon/daemon_saver.c	Thu Sep 10 12:55:09 2009	(r197061)
+++ head/sys/dev/syscons/daemon/daemon_saver.c	Thu Sep 10 12:58:37 2009	(r197062)
@@ -351,11 +351,23 @@ daemon_saver(video_adapter_t *adp, int b
 static int
 daemon_init(video_adapter_t *adp)
 {
+	size_t hostlen;
 
 	mtx_lock(&prison0.pr_mtx);
-	messagelen = strlen(prison0.pr_hostname) + 3 + strlen(ostype) + 1 + 
-	    strlen(osrelease);
-	message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
+	for (;;) {
+		hostlen = strlen(prison0.pr_hostname);
+		mtx_unlock(&prison0.pr_mtx);
+	
+		messagelen = hostlen + 3 + strlen(ostype) + 1 +
+		    strlen(osrelease);
+		message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
+		mtx_lock(&prison0.pr_mtx);
+		if (hostlen < strlen(prison0.pr_hostname)) {
+			free(message, M_DEVBUF);
+			continue;
+		}
+		break;
+	}
 	sprintf(message, "%s - %s %s", prison0.pr_hostname, ostype, osrelease);
 	mtx_unlock(&prison0.pr_mtx);
 	blanked = 0;
From des at FreeBSD.org  Thu Sep 10 13:20:27 2009
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Thu Sep 10 13:20:39 2009
Subject: svn commit: r197064 - in head/sys: amd64/linux32 compat/svr4
	i386/ibcs2 i386/linux
Message-ID: <200909101320.n8ADKRp0020669@svn.freebsd.org>

Author: des
Date: Thu Sep 10 13:20:27 2009
New Revision: 197064
URL: http://svn.freebsd.org/changeset/base/197064

Log:
  As jhb@ pointed out to me, r197057 was incorrect, not least because these
  are generated files.

Modified:
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/compat/svr4/svr4_proto.h
  head/sys/i386/ibcs2/ibcs2_proto.h
  head/sys/i386/linux/linux_proto.h

Modified: head/sys/amd64/linux32/linux32_proto.h
==============================================================================
--- head/sys/amd64/linux32/linux32_proto.h	Thu Sep 10 13:01:23 2009	(r197063)
+++ head/sys/amd64/linux32/linux32_proto.h	Thu Sep 10 13:20:27 2009	(r197064)
@@ -1257,6 +1257,13 @@ int	linux_vmsplice(struct thread *, stru
 
 #endif /* COMPAT_FREEBSD6 */
 
+
+#ifdef COMPAT_FREEBSD7
+
+#define	nosys	linux_nosys
+
+#endif /* COMPAT_FREEBSD7 */
+
 #define	LINUX_SYS_AUE_linux_fork	AUE_FORK
 #define	LINUX_SYS_AUE_linux_open	AUE_OPEN_RWTC
 #define	LINUX_SYS_AUE_linux_waitpid	AUE_WAIT4

Modified: head/sys/compat/svr4/svr4_proto.h
==============================================================================
--- head/sys/compat/svr4/svr4_proto.h	Thu Sep 10 13:01:23 2009	(r197063)
+++ head/sys/compat/svr4/svr4_proto.h	Thu Sep 10 13:20:27 2009	(r197064)
@@ -503,6 +503,12 @@ int	svr4_sys_sendto(struct thread *, str
 
 #endif /* COMPAT_FREEBSD6 */
 
+
+#ifdef COMPAT_FREEBSD7
+
+
+#endif /* COMPAT_FREEBSD7 */
+
 #define	SVR4_SYS_AUE_svr4_sys_open	AUE_NULL
 #define	SVR4_SYS_AUE_svr4_sys_wait	AUE_NULL
 #define	SVR4_SYS_AUE_svr4_sys_creat	AUE_NULL

Modified: head/sys/i386/ibcs2/ibcs2_proto.h
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_proto.h	Thu Sep 10 13:01:23 2009	(r197063)
+++ head/sys/i386/ibcs2/ibcs2_proto.h	Thu Sep 10 13:20:27 2009	(r197064)
@@ -345,6 +345,12 @@ int	ibcs2_isc(struct thread *, struct ib
 
 #endif /* COMPAT_FREEBSD6 */
 
+
+#ifdef COMPAT_FREEBSD7
+
+
+#endif /* COMPAT_FREEBSD7 */
+
 #define	IBCS2_SYS_AUE_ibcs2_read	AUE_NULL
 #define	IBCS2_SYS_AUE_ibcs2_open	AUE_OPEN_RWTC
 #define	IBCS2_SYS_AUE_ibcs2_wait	AUE_WAIT4

Modified: head/sys/i386/linux/linux_proto.h
==============================================================================
--- head/sys/i386/linux/linux_proto.h	Thu Sep 10 13:01:23 2009	(r197063)
+++ head/sys/i386/linux/linux_proto.h	Thu Sep 10 13:20:27 2009	(r197064)
@@ -1277,6 +1277,13 @@ int	linux_vmsplice(struct thread *, stru
 
 #endif /* COMPAT_FREEBSD6 */
 
+
+#ifdef COMPAT_FREEBSD7
+
+#define	nosys	linux_nosys
+
+#endif /* COMPAT_FREEBSD7 */
+
 #define	LINUX_SYS_AUE_linux_fork	AUE_FORK
 #define	LINUX_SYS_AUE_linux_open	AUE_OPEN_RWTC
 #define	LINUX_SYS_AUE_linux_waitpid	AUE_WAIT4
From des at des.no  Thu Sep 10 13:21:21 2009
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Thu Sep 10 13:21:33 2009
Subject: svn commit: r197057 - in head/sys: compat/freebsd32 sys
In-Reply-To: <200909100833.22353.jhb@freebsd.org> (John Baldwin's message of
	"Thu, 10 Sep 2009 08:33:21 -0400")
References: <200909100833.n8A8XSIc011874@svn.freebsd.org>
	<200909100833.22353.jhb@freebsd.org>
Message-ID: <86eiqflyun.fsf@ds4.des.no>

John Baldwin  writes:
> These are auto-generated files.  Please revert.

Done.  Next time, I will try to remember to turn my brain on before
committing...

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From jkim at FreeBSD.org  Thu Sep 10 17:27:37 2009
From: jkim at FreeBSD.org (Jung-uk Kim)
Date: Thu Sep 10 17:27:43 2009
Subject: svn commit: r197070 - in head/sys: amd64/amd64 amd64/include
	i386/cpufreq i386/i386 i386/include i386/xen
Message-ID: <200909101727.n8AHRa8L026099@svn.freebsd.org>

Author: jkim
Date: Thu Sep 10 17:27:36 2009
New Revision: 197070
URL: http://svn.freebsd.org/changeset/base/197070

Log:
  Consolidate CPUID to CPU family/model macros for amd64 and i386 to reduce
  unnecessary #ifdef's for shared code between them.

Modified:
  head/sys/amd64/amd64/identcpu.c
  head/sys/amd64/amd64/initcpu.c
  head/sys/amd64/amd64/msi.c
  head/sys/amd64/include/specialreg.h
  head/sys/i386/cpufreq/hwpstate.c
  head/sys/i386/i386/identcpu.c
  head/sys/i386/i386/msi.c
  head/sys/i386/i386/pmap.c
  head/sys/i386/include/specialreg.h
  head/sys/i386/xen/pmap.c

Modified: head/sys/amd64/amd64/identcpu.c
==============================================================================
--- head/sys/amd64/amd64/identcpu.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/amd64/amd64/identcpu.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -371,21 +371,21 @@ printcpuinfo(void)
 			switch (cpu_vendor_id) {
 			case CPU_VENDOR_AMD:
 				if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
-				    AMD64_CPU_FAMILY(cpu_id) >= 0x10 ||
+				    CPUID_TO_FAMILY(cpu_id) >= 0x10 ||
 				    cpu_id == 0x60fb2)
 					tsc_is_invariant = 1;
 				break;
 			case CPU_VENDOR_INTEL:
 				if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
-				    (AMD64_CPU_FAMILY(cpu_id) == 0x6 &&
-				    AMD64_CPU_MODEL(cpu_id) >= 0xe) ||
-				    (AMD64_CPU_FAMILY(cpu_id) == 0xf &&
-				    AMD64_CPU_MODEL(cpu_id) >= 0x3))
+				    (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+				    CPUID_TO_MODEL(cpu_id) >= 0xe) ||
+				    (CPUID_TO_FAMILY(cpu_id) == 0xf &&
+				    CPUID_TO_MODEL(cpu_id) >= 0x3))
 					tsc_is_invariant = 1;
 				break;
 			case CPU_VENDOR_CENTAUR:
-				if (AMD64_CPU_FAMILY(cpu_id) == 0x6 &&
-				    AMD64_CPU_MODEL(cpu_id) >= 0xf &&
+				if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+				    CPUID_TO_MODEL(cpu_id) >= 0xf &&
 				    (rdmsr(0x1203) & 0x100000000ULL) == 0)
 					tsc_is_invariant = 1;
 				break;

Modified: head/sys/amd64/amd64/initcpu.c
==============================================================================
--- head/sys/amd64/amd64/initcpu.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/amd64/amd64/initcpu.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -154,8 +154,8 @@ initializecpu(void)
 		pg_nx = PG_NX;
 	}
 	if (cpu_vendor_id == CPU_VENDOR_CENTAUR &&
-	    AMD64_CPU_FAMILY(cpu_id) == 0x6 &&
-	    AMD64_CPU_MODEL(cpu_id) >= 0xf)
+	    CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+	    CPUID_TO_MODEL(cpu_id) >= 0xf)
 		init_via();
 
 	/*

Modified: head/sys/amd64/amd64/msi.c
==============================================================================
--- head/sys/amd64/amd64/msi.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/amd64/amd64/msi.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -275,8 +275,8 @@ msi_init(void)
 	case CPU_VENDOR_AMD:
 		break;
 	case CPU_VENDOR_CENTAUR:
-		if (AMD64_CPU_FAMILY(cpu_id) == 0x6 &&
-		    AMD64_CPU_MODEL(cpu_id) >= 0xf)
+		if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+		    CPUID_TO_MODEL(cpu_id) >= 0xf)
 			break;
 		/* FALLTHROUGH */
 	default:

Modified: head/sys/amd64/include/specialreg.h
==============================================================================
--- head/sys/amd64/include/specialreg.h	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/amd64/include/specialreg.h	Thu Sep 10 17:27:36 2009	(r197070)
@@ -168,10 +168,10 @@
 #define	CPUID_FAMILY		0x00000f00
 #define	CPUID_EXT_MODEL		0x000f0000
 #define	CPUID_EXT_FAMILY	0x0ff00000
-#define	AMD64_CPU_MODEL(id) \
+#define	CPUID_TO_MODEL(id) \
     ((((id) & CPUID_MODEL) >> 4) | \
     (((id) & CPUID_EXT_MODEL) >> 12))
-#define	AMD64_CPU_FAMILY(id) \
+#define	CPUID_TO_FAMILY(id) \
     ((((id) & CPUID_FAMILY) >> 8) + \
     (((id) & CPUID_EXT_FAMILY) >> 20))
 

Modified: head/sys/i386/cpufreq/hwpstate.c
==============================================================================
--- head/sys/i386/cpufreq/hwpstate.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/cpufreq/hwpstate.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -83,12 +83,6 @@ __FBSDID("$FreeBSD$");
 #define	AMD_10H_11H_CUR_DID(msr)		(((msr) >> 6) & 0x07)
 #define	AMD_10H_11H_CUR_FID(msr)		((msr) & 0x3F)
 
-#if defined(__amd64__)
-#define CPU_FAMILY(id)	AMD64_CPU_FAMILY(id)
-#elif defined(__i386__)
-#define CPU_FAMILY(id)	I386_CPU_FAMILY(id)
-#endif
-
 #define	HWPSTATE_DEBUG(dev, msg...)			\
 	do{						\
 		if(hwpstate_verbose)			\
@@ -302,7 +296,7 @@ hwpstate_identify(driver_t *driver, devi
 	if (device_find_child(parent, "hwpstate", -1) != NULL)
 		return;
 
-	if (cpu_vendor_id != CPU_VENDOR_AMD || CPU_FAMILY(cpu_id) < 0x10)
+	if (cpu_vendor_id != CPU_VENDOR_AMD || CPUID_TO_FAMILY(cpu_id) < 0x10)
 		return;
 
 	/*
@@ -405,7 +399,7 @@ hwpstate_get_info_from_msr(device_t dev)
 	uint64_t msr;
 	int family, i, fid, did;
 
-	family = CPU_FAMILY(cpu_id);
+	family = CPUID_TO_FAMILY(cpu_id);
 	sc = device_get_softc(dev);
 	/* Get pstate count */
 	msr = rdmsr(MSR_AMD_10H_11H_LIMIT);

Modified: head/sys/i386/i386/identcpu.c
==============================================================================
--- head/sys/i386/i386/identcpu.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/i386/identcpu.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -858,21 +858,21 @@ printcpuinfo(void)
 			switch (cpu_vendor_id) {
 			case CPU_VENDOR_AMD:
 				if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
-				    I386_CPU_FAMILY(cpu_id) >= 0x10 ||
+				    CPUID_TO_FAMILY(cpu_id) >= 0x10 ||
 				    cpu_id == 0x60fb2)
 					tsc_is_invariant = 1;
 				break;
 			case CPU_VENDOR_INTEL:
 				if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
-				    (I386_CPU_FAMILY(cpu_id) == 0x6 &&
-				    I386_CPU_MODEL(cpu_id) >= 0xe) ||
-				    (I386_CPU_FAMILY(cpu_id) == 0xf &&
-				    I386_CPU_MODEL(cpu_id) >= 0x3))
+				    (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+				    CPUID_TO_MODEL(cpu_id) >= 0xe) ||
+				    (CPUID_TO_FAMILY(cpu_id) == 0xf &&
+				    CPUID_TO_MODEL(cpu_id) >= 0x3))
 					tsc_is_invariant = 1;
 				break;
 			case CPU_VENDOR_CENTAUR:
-				if (I386_CPU_FAMILY(cpu_id) == 0x6 &&
-				    I386_CPU_MODEL(cpu_id) >= 0xf &&
+				if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+				    CPUID_TO_MODEL(cpu_id) >= 0xf &&
 				    (rdmsr(0x1203) & 0x100000000ULL) == 0)
 					tsc_is_invariant = 1;
 				break;
@@ -1106,8 +1106,8 @@ finishidentcpu(void)
 	 * XXX This is only done on the BSP package.
 	 */
 	if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4 &&
-	    ((I386_CPU_FAMILY(cpu_id) == 0xf && I386_CPU_MODEL(cpu_id) >= 0x3) ||
-	    (I386_CPU_FAMILY(cpu_id) == 0x6 && I386_CPU_MODEL(cpu_id) >= 0xe))) {
+	    ((CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x3) ||
+	    (CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) >= 0xe))) {
 		uint64_t msr;
 		msr = rdmsr(MSR_IA32_MISC_ENABLE);
 		if ((msr & 0x400000ULL) != 0) {

Modified: head/sys/i386/i386/msi.c
==============================================================================
--- head/sys/i386/i386/msi.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/i386/msi.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -275,8 +275,8 @@ msi_init(void)
 	case CPU_VENDOR_AMD:
 		break;
 	case CPU_VENDOR_CENTAUR:
-		if (I386_CPU_FAMILY(cpu_id) == 0x6 &&
-		    I386_CPU_MODEL(cpu_id) >= 0xf)
+		if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+		    CPUID_TO_MODEL(cpu_id) >= 0xf)
 			break;
 		/* FALLTHROUGH */
 	default:

Modified: head/sys/i386/i386/pmap.c
==============================================================================
--- head/sys/i386/i386/pmap.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/i386/pmap.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -501,8 +501,8 @@ pmap_init_pat(void)
 	 */
 	if (!pat_tested) {
 		if (cpu_vendor_id != CPU_VENDOR_INTEL ||
-		    (I386_CPU_FAMILY(cpu_id) == 6 &&
-		    I386_CPU_MODEL(cpu_id) >= 0xe)) {
+		    (CPUID_TO_FAMILY(cpu_id) == 6 &&
+		    CPUID_TO_MODEL(cpu_id) >= 0xe)) {
 			pat_works = 1;
 			sysenv = getenv("smbios.system.product");
 			if (sysenv != NULL) {

Modified: head/sys/i386/include/specialreg.h
==============================================================================
--- head/sys/i386/include/specialreg.h	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/include/specialreg.h	Thu Sep 10 17:27:36 2009	(r197070)
@@ -165,11 +165,11 @@
 #define	CPUID_FAMILY		0x00000f00
 #define	CPUID_EXT_MODEL		0x000f0000
 #define	CPUID_EXT_FAMILY	0x0ff00000
-#define	I386_CPU_MODEL(id) \
+#define	CPUID_TO_MODEL(id) \
     ((((id) & CPUID_MODEL) >> 4) | \
     ((((id) & CPUID_FAMILY) >= 0x600) ? \
     (((id) & CPUID_EXT_MODEL) >> 12) : 0))
-#define	I386_CPU_FAMILY(id) \
+#define	CPUID_TO_FAMILY(id) \
     ((((id) & CPUID_FAMILY) >> 8) + \
     ((((id) & CPUID_FAMILY) == 0xf00) ? \
     (((id) & CPUID_EXT_FAMILY) >> 20) : 0))

Modified: head/sys/i386/xen/pmap.c
==============================================================================
--- head/sys/i386/xen/pmap.c	Thu Sep 10 16:03:11 2009	(r197069)
+++ head/sys/i386/xen/pmap.c	Thu Sep 10 17:27:36 2009	(r197070)
@@ -517,7 +517,7 @@ pmap_init_pat(void)
 		return;
 
 	if (cpu_vendor_id != CPU_VENDOR_INTEL ||
-	    (I386_CPU_FAMILY(cpu_id) == 6 && I386_CPU_MODEL(cpu_id) >= 0xe)) {
+	    (CPUID_TO_FAMILY(cpu_id) == 6 && CPUID_TO_MODEL(cpu_id) >= 0xe)) {
 		/*
 		 * Leave the indices 0-3 at the default of WB, WT, UC, and UC-.
 		 * Program 4 and 5 as WP and WC.
From n_hibma at FreeBSD.org  Thu Sep 10 18:24:59 2009
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Thu Sep 10 18:25:06 2009
Subject: svn commit: r197071 - head/sys/kern
Message-ID: <200909101824.n8AIOxJI027277@svn.freebsd.org>

Author: n_hibma
Date: Thu Sep 10 18:24:59 2009
New Revision: 197071
URL: http://svn.freebsd.org/changeset/base/197071

Log:
  Add a comment on the consequences of reducing the poweroff delay

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==============================================================================
--- head/sys/kern/kern_shutdown.c	Thu Sep 10 17:27:36 2009	(r197070)
+++ head/sys/kern/kern_shutdown.c	Thu Sep 10 18:24:59 2009	(r197071)
@@ -581,6 +581,10 @@ panic(const char *fmt, ...)
 
 /*
  * Support for poweroff delay.
+ *
+ * Please note that setting this delay too short might power off your machine
+ * before the write cache on your hard disk has been flushed, leading to
+ * soft-updates inconsistencies.
  */
 #ifndef POWEROFF_DELAY
 # define POWEROFF_DELAY 5000
From n_hibma at FreeBSD.org  Thu Sep 10 18:33:09 2009
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Thu Sep 10 18:33:20 2009
Subject: svn commit: r197072 - in head/sys: dev/ichwd netsmb
Message-ID: <200909101833.n8AIX8p6027487@svn.freebsd.org>

Author: n_hibma
Date: Thu Sep 10 18:33:08 2009
New Revision: 197072
URL: http://svn.freebsd.org/changeset/base/197072

Log:
  Don't print out a message on loading a module.  'kldload -v' and 'kldstat
  | grep ' can be used instead.
  
  Put a message behind bootverbose as
  
  	ichwd0:  on isa0
  	ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent)
  
  does not make a lot of sense.
  
  MFC after:	1 week

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/netsmb/smb_dev.c

Modified: head/sys/dev/ichwd/ichwd.c
==============================================================================
--- head/sys/dev/ichwd/ichwd.c	Thu Sep 10 18:24:59 2009	(r197071)
+++ head/sys/dev/ichwd/ichwd.c	Thu Sep 10 18:33:08 2009	(r197072)
@@ -465,7 +465,7 @@ ichwd_attach(device_t dev)
 	if (ichwd_clear_noreboot(sc) != 0)
 		goto fail;
 
-	device_printf(dev, "%s (ICH%d or equivalent)\n",
+	ichwd_verbose_printf(dev, "%s (ICH%d or equivalent)\n",
 	    device_get_desc(dev), sc->ich_version);
 
 	/*
@@ -553,23 +553,4 @@ static driver_t ichwd_driver = {
 	sizeof(struct ichwd_softc),
 };
 
-static int
-ichwd_modevent(module_t mode, int type, void *data)
-{
-	int error = 0;
-
-	switch (type) {
-	case MOD_LOAD:
-		printf("ichwd module loaded\n");
-		break;
-	case MOD_UNLOAD:
-		printf("ichwd module unloaded\n");
-		break;
-	case MOD_SHUTDOWN:
-		printf("ichwd module shutting down\n");
-		break;
-	}
-	return (error);
-}
-
-DRIVER_MODULE(ichwd, isa, ichwd_driver, ichwd_devclass, ichwd_modevent, NULL);
+DRIVER_MODULE(ichwd, isa, ichwd_driver, ichwd_devclass, NULL, NULL);

Modified: head/sys/netsmb/smb_dev.c
==============================================================================
--- head/sys/netsmb/smb_dev.c	Thu Sep 10 18:24:59 2009	(r197071)
+++ head/sys/netsmb/smb_dev.c	Thu Sep 10 18:33:08 2009	(r197072)
@@ -352,7 +352,6 @@ nsmb_dev_load(module_t mod, int cmd, voi
 		}
 		clone_setup(&nsmb_clones);
 		nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000);
-		printf("netsmb_dev: loaded\n");
 		break;
 	    case MOD_UNLOAD:
 		smb_iod_done();
@@ -363,7 +362,6 @@ nsmb_dev_load(module_t mod, int cmd, voi
 		drain_dev_clone_events();
 		clone_cleanup(&nsmb_clones);
 		destroy_dev_drain(&nsmb_cdevsw);
-		printf("netsmb_dev: unloaded\n");
 		break;
 	    default:
 		error = EINVAL;
From jfv at FreeBSD.org  Thu Sep 10 18:53:34 2009
From: jfv at FreeBSD.org (Jack F Vogel)
Date: Thu Sep 10 18:53:46 2009
Subject: svn commit: r197073 - head/sys/dev/e1000
Message-ID: <200909101853.n8AIrYpb028056@svn.freebsd.org>

Author: jfv
Date: Thu Sep 10 18:53:34 2009
New Revision: 197073
URL: http://svn.freebsd.org/changeset/base/197073

Log:
  Fix for pr 138516
  An mbuf is not requeued when a xmit fails.
  
  MFC: 3 days

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==============================================================================
--- head/sys/dev/e1000/if_em.c	Thu Sep 10 18:33:08 2009	(r197072)
+++ head/sys/dev/e1000/if_em.c	Thu Sep 10 18:53:34 2009	(r197073)
@@ -1034,9 +1034,10 @@ em_mq_start_locked(struct ifnet *ifp, st
 		return (error);
 	} else if (drbr_empty(ifp, adapter->br) &&
 	    (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) {
-		if (em_xmit(adapter, &m)) {
-			if (m && (error = drbr_enqueue(ifp, adapter->br, m)) != 0)
-				return (error);
+		if (error = em_xmit(adapter, &m)) {
+			if (m != NULL)
+				error = drbr_enqueue(ifp, adapter->br, m);
+			return (error);
 		} else {
 			/*
 			 * We've bypassed the buf ring so we need to update
@@ -1063,8 +1064,12 @@ process:
                 next = drbr_dequeue(ifp, adapter->br);
                 if (next == NULL)
                         break;
-                if (em_xmit(adapter, &next))
+                if (error = em_xmit(adapter, &next)) {
+			if (next != NULL)
+				error = drbr_enqueue(ifp, adapter->br, next);
                         break;
+		}
+		drbr_stats_update(ifp, next->m_pkthdr.len, next->m_flags);
                 ETHER_BPF_MTAP(ifp, next);
                 /* Set the watchdog */
                 adapter->watchdog_timer = EM_TX_TIMEOUT;
@@ -1073,7 +1078,7 @@ process:
         if (adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)
                 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 
-	return (0);
+	return (error);
 }
 
 /*
From jfv at FreeBSD.org  Thu Sep 10 18:56:45 2009
From: jfv at FreeBSD.org (Jack F Vogel)
Date: Thu Sep 10 18:56:52 2009
Subject: svn commit: r197074 - head/sys/dev/e1000
Message-ID: <200909101856.n8AIujec028172@svn.freebsd.org>

Author: jfv
Date: Thu Sep 10 18:56:45 2009
New Revision: 197074
URL: http://svn.freebsd.org/changeset/base/197074

Log:
  Fix an xmit mbuf leak, when transmit failed but you
  still have an mbuf it was not being requeued.
  
  MFC: 3 days

Modified:
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/if_igb.c
==============================================================================
--- head/sys/dev/e1000/if_igb.c	Thu Sep 10 18:53:34 2009	(r197073)
+++ head/sys/dev/e1000/if_igb.c	Thu Sep 10 18:56:45 2009	(r197074)
@@ -854,9 +854,10 @@ igb_mq_start_locked(struct ifnet *ifp, s
 
 	/* If nothing queued go right to xmit */
 	if (drbr_empty(ifp, txr->br)) {
-		if (igb_xmit(txr, &m)) {
-			if (m && (err = drbr_enqueue(ifp, txr->br, m)) != 0)
-                                return (err);
+		if (err = igb_xmit(txr, &m)) {
+			if (m != NULL)
+				err = drbr_enqueue(ifp, txr->br, m);
+			return (err);
 		} else {
 			/* Success, update stats */
 			drbr_stats_update(ifp, m->m_pkthdr.len, m->m_flags);
@@ -880,8 +881,12 @@ process:
 		next = drbr_dequeue(ifp, txr->br);
 		if (next == NULL)
 			break;
-		if (igb_xmit(txr, &next))
+		if (err = igb_xmit(txr, &next)) {
+			if (next != NULL)
+				err = drbr_enqueue(ifp, txr->br, next);
 			break;
+		}
+		drbr_stats_update(ifp, next->m_pkthdr.len, next->m_flags);
 		ETHER_BPF_MTAP(ifp, next);
 		/* Set the watchdog */
 		txr->watchdog_timer = IGB_TX_TIMEOUT;
@@ -1531,8 +1536,11 @@ igb_update_aim(struct rx_ring *rxr)
 	if (olditr != newitr) {
 		/* Change interrupt rate */
 		rxr->eitr_setting = newitr;
-		E1000_WRITE_REG(&adapter->hw, E1000_EITR(rxr->me),
-		    newitr | (newitr << 16));
+		if (adapter->hw.mac.type == e1000_82575)
+			newitr |= newitr << 16;
+		else
+			newitr |= 0x8000000;
+		E1000_WRITE_REG(&adapter->hw, E1000_EITR(rxr->me), newitr);
 	}
 
 	rxr->bytes = 0;
From avg at freebsd.org  Thu Sep 10 18:56:53 2009
From: avg at freebsd.org (Andriy Gapon)
Date: Thu Sep 10 18:57:02 2009
Subject: svn commit: r197072 - in head/sys: dev/ichwd netsmb
In-Reply-To: <200909101833.n8AIX8p6027487@svn.freebsd.org>
References: <200909101833.n8AIX8p6027487@svn.freebsd.org>
Message-ID: <4AA947FA.8040404@freebsd.org>

on 10/09/2009 21:33 Nick Hibma said the following:
> Author: n_hibma
> Date: Thu Sep 10 18:33:08 2009
> New Revision: 197072
> URL: http://svn.freebsd.org/changeset/base/197072
> 
> Log:
>   Don't print out a message on loading a module.  'kldload -v' and 'kldstat
>   | grep ' can be used instead.
>   
>   Put a message behind bootverbose as
>   
>   	ichwd0:  on isa0
>   	ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent)
>   
>   does not make a lot of sense.
>   
>   MFC after:	1 week

Looks like you have committed an unrelated change in netsmb.


-- 
Andriy Gapon
From des at des.no  Thu Sep 10 19:11:24 2009
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Thu Sep 10 19:11:35 2009
Subject: svn commit: r197072 - in head/sys: dev/ichwd netsmb
In-Reply-To: <200909101833.n8AIX8p6027487@svn.freebsd.org> (Nick Hibma's
	message of "Thu, 10 Sep 2009 18:33:08 +0000 (UTC)")
References: <200909101833.n8AIX8p6027487@svn.freebsd.org>
Message-ID: <86iqfq8vja.fsf@ds4.des.no>

Nick Hibma  writes:
> Log:
>   Don't print out a message on loading a module.  'kldload -v' and 'kldstat
>   | grep ' can be used instead.
>   
>   Put a message behind bootverbose as
>   
>   	ichwd0:  on isa0
>   	ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent)
>   
>   does not make a lot of sense.

Why doesn't it make sense?  Every other device announces itself when it
attaches; why shouldn't ichwd0 do so?

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From n_hibma at FreeBSD.org  Thu Sep 10 19:12:09 2009
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Thu Sep 10 19:12:14 2009
Subject: svn commit: r197075 - head/sys/modules/dtrace/lockstat
Message-ID: <200909101912.n8AJC9mq028555@svn.freebsd.org>

Author: n_hibma
Date: Thu Sep 10 19:12:08 2009
New Revision: 197075
URL: http://svn.freebsd.org/changeset/base/197075

Log:
  Missing opt_*.h file reference for make depend in sys/modules
  
  MFC after:	1 week

Modified:
  head/sys/modules/dtrace/lockstat/Makefile

Modified: head/sys/modules/dtrace/lockstat/Makefile
==============================================================================
--- head/sys/modules/dtrace/lockstat/Makefile	Thu Sep 10 18:56:45 2009	(r197074)
+++ head/sys/modules/dtrace/lockstat/Makefile	Thu Sep 10 19:12:08 2009	(r197075)
@@ -5,7 +5,7 @@
 KMOD=		lockstat
 SRCS=		lockstat.c 
 
-SRCS+=		vnode_if.h
+SRCS+=		vnode_if.h opt_kdtrace.h
 
 CFLAGS+=	-I${.CURDIR}/../../../cddl/compat/opensolaris \
 		-I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \
From avg at freebsd.org  Thu Sep 10 19:15:26 2009
From: avg at freebsd.org (Andriy Gapon)
Date: Thu Sep 10 19:15:39 2009
Subject: svn commit: r197072 - in head/sys: dev/ichwd netsmb
In-Reply-To: <86iqfq8vja.fsf@ds4.des.no>
References: <200909101833.n8AIX8p6027487@svn.freebsd.org>
	<86iqfq8vja.fsf@ds4.des.no>
Message-ID: <4AA95049.4090104@freebsd.org>

on 10/09/2009 22:11 Dag-Erling Sm?rgrav said the following:
> Nick Hibma  writes:
>> Log:
>>   Don't print out a message on loading a module.  'kldload -v' and 'kldstat
>>   | grep ' can be used instead.
>>   
>>   Put a message behind bootverbose as
>>   
>>   	ichwd0:  on isa0

I think the above line is printed by newbus code automatically.

>>   	ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent)

And this line kind of duplicates it.

>>   does not make a lot of sense.
> 
> Why doesn't it make sense?  Every other device announces itself when it
> attaches; why shouldn't ichwd0 do so?

So, a possible answer is above :)

-- 
Andriy Gapon
From n_hibma at FreeBSD.org  Thu Sep 10 19:24:47 2009
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Thu Sep 10 19:24:59 2009
Subject: svn commit: r197076 - head/sys/dev/agp
Message-ID: <200909101924.n8AJOkKB028848@svn.freebsd.org>

Author: n_hibma
Date: Thu Sep 10 19:24:46 2009
New Revision: 197076
URL: http://svn.freebsd.org/changeset/base/197076

Log:
  Move the printing of aperture size and stolen memory behind bootverbose.
  None of the other AGP drivers actually displays this information at all,
  
  MFC after:	1 week

Modified:
  head/sys/dev/agp/agp_i810.c

Modified: head/sys/dev/agp/agp_i810.c
==============================================================================
--- head/sys/dev/agp/agp_i810.c	Thu Sep 10 19:12:08 2009	(r197075)
+++ head/sys/dev/agp/agp_i810.c	Thu Sep 10 19:24:46 2009	(r197076)
@@ -474,12 +474,6 @@ agp_i810_attach(device_t dev)
 				agp_generic_detach(dev);
 				return EINVAL;
 		}
-		if (sc->stolen > 0) {
-			device_printf(dev, "detected %dk stolen memory\n",
-			    sc->stolen * 4);
-		}
-		device_printf(dev, "aperture size is %dM\n",
-		    sc->initial_aperture / 1024 / 1024);
 
 		/* GATT address is already in there, make sure it's enabled */
 		pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL);
@@ -664,9 +658,6 @@ agp_i810_attach(device_t dev)
 		gtt_size += 4;
 
 		sc->stolen = (stolen - gtt_size) * 1024 / 4096;
-		if (sc->stolen > 0)
-			device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4);
-		device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024);
 
 		/* GATT address is already in there, make sure it's enabled */
 		pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL);
@@ -676,6 +667,15 @@ agp_i810_attach(device_t dev)
 		gatt->ag_physical = pgtblctl & ~1;
 	}
 
+	if (bootverbose) {
+		device_printf(dev, "aperture size is %dM",
+		    sc->initial_aperture / 1024 / 1024);
+		if (sc->stolen > 0)
+			printf(", detected %dk stolen memory\n", sc->stolen * 4);
+		else
+			printf("\n");
+	}
+
 	if (0)
 		agp_i810_dump_regs(dev);
 
From avg at FreeBSD.org  Thu Sep 10 19:27:53 2009
From: avg at FreeBSD.org (Andriy Gapon)
Date: Thu Sep 10 19:28:05 2009
Subject: svn commit: r197077 - head/sys/dev/pci
Message-ID: <200909101927.n8AJRraJ028936@svn.freebsd.org>

Author: avg
Date: Thu Sep 10 19:27:53 2009
New Revision: 197077
URL: http://svn.freebsd.org/changeset/base/197077

Log:
  pci: remove definitions of duplicate constants
  
  Suggested by:	jhb
  Reviewed by:	jhb
  MFC after:	1 week

Modified:
  head/sys/dev/pci/pcireg.h
  head/sys/dev/pci/pcivar.h

Modified: head/sys/dev/pci/pcireg.h
==============================================================================
--- head/sys/dev/pci/pcireg.h	Thu Sep 10 19:24:46 2009	(r197076)
+++ head/sys/dev/pci/pcireg.h	Thu Sep 10 19:27:53 2009	(r197077)
@@ -39,11 +39,11 @@
  */
 
 /* some PCI bus constants */
-
-#define	PCI_BUSMAX	255
-#define	PCI_SLOTMAX	31
-#define	PCI_FUNCMAX	7
-#define	PCI_REGMAX	255
+#define	PCI_DOMAINMAX	65535	/* highest supported domain number */
+#define	PCI_BUSMAX	255	/* highest supported bus number */
+#define	PCI_SLOTMAX	31	/* highest supported slot number */
+#define	PCI_FUNCMAX	7	/* highest supported function number */
+#define	PCI_REGMAX	255	/* highest supported config register addr. */
 #define	PCI_MAXHDRTYPE	2
 
 /* PCI config header registers for all devices */

Modified: head/sys/dev/pci/pcivar.h
==============================================================================
--- head/sys/dev/pci/pcivar.h	Thu Sep 10 19:24:46 2009	(r197076)
+++ head/sys/dev/pci/pcivar.h	Thu Sep 10 19:27:53 2009	(r197077)
@@ -33,13 +33,6 @@
 #include 
 
 /* some PCI bus constants */
-
-#define	PCI_DOMAINMAX	65535	/* highest supported domain number */
-#define	PCI_BUSMAX	255	/* highest supported bus number */
-#define	PCI_SLOTMAX	31	/* highest supported slot number */
-#define	PCI_FUNCMAX	7	/* highest supported function number */
-#define	PCI_REGMAX	255	/* highest supported config register addr. */
-
 #define	PCI_MAXMAPS_0	6	/* max. no. of memory/port maps */
 #define	PCI_MAXMAPS_1	2	/* max. no. of maps for PCI to PCI bridge */
 #define	PCI_MAXMAPS_2	1	/* max. no. of maps for CardBus bridge */
From rnoland at FreeBSD.org  Thu Sep 10 19:31:55 2009
From: rnoland at FreeBSD.org (Robert Noland)
Date: Thu Sep 10 19:32:07 2009
Subject: svn commit: r197076 - head/sys/dev/agp
In-Reply-To: <200909101924.n8AJOkKB028848@svn.freebsd.org>
References: <200909101924.n8AJOkKB028848@svn.freebsd.org>
Message-ID: <1252611107.1899.10.camel@balrog.2hip.net>

On Thu, 2009-09-10 at 19:24 +0000, Nick Hibma wrote:
> Author: n_hibma
> Date: Thu Sep 10 19:24:46 2009
> New Revision: 197076
> URL: http://svn.freebsd.org/changeset/base/197076
> 
> Log:
>   Move the printing of aperture size and stolen memory behind bootverbose.
>   None of the other AGP drivers actually displays this information at all,

None of the agp drivers are quite as special as agp_i810.  Please revert
this change.

robert.

>   MFC after:	1 week
> 
> Modified:
>   head/sys/dev/agp/agp_i810.c
> 
> Modified: head/sys/dev/agp/agp_i810.c
> ==============================================================================
> --- head/sys/dev/agp/agp_i810.c	Thu Sep 10 19:12:08 2009	(r197075)
> +++ head/sys/dev/agp/agp_i810.c	Thu Sep 10 19:24:46 2009	(r197076)
> @@ -474,12 +474,6 @@ agp_i810_attach(device_t dev)
>  				agp_generic_detach(dev);
>  				return EINVAL;
>  		}
> -		if (sc->stolen > 0) {
> -			device_printf(dev, "detected %dk stolen memory\n",
> -			    sc->stolen * 4);
> -		}
> -		device_printf(dev, "aperture size is %dM\n",
> -		    sc->initial_aperture / 1024 / 1024);
>  
>  		/* GATT address is already in there, make sure it's enabled */
>  		pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL);
> @@ -664,9 +658,6 @@ agp_i810_attach(device_t dev)
>  		gtt_size += 4;
>  
>  		sc->stolen = (stolen - gtt_size) * 1024 / 4096;
> -		if (sc->stolen > 0)
> -			device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4);
> -		device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024);
>  
>  		/* GATT address is already in there, make sure it's enabled */
>  		pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL);
> @@ -676,6 +667,15 @@ agp_i810_attach(device_t dev)
>  		gatt->ag_physical = pgtblctl & ~1;
>  	}
>  
> +	if (bootverbose) {
> +		device_printf(dev, "aperture size is %dM",
> +		    sc->initial_aperture / 1024 / 1024);
> +		if (sc->stolen > 0)
> +			printf(", detected %dk stolen memory\n", sc->stolen * 4);
> +		else
> +			printf("\n");
> +	}
> +
>  	if (0)
>  		agp_i810_dump_regs(dev);
>  
-- 
Robert Noland 
FreeBSD

From jhb at freebsd.org  Thu Sep 10 20:09:48 2009
From: jhb at freebsd.org (John Baldwin)
Date: Thu Sep 10 20:10:00 2009
Subject: svn commit: r197076 - head/sys/dev/agp
In-Reply-To: <200909101924.n8AJOkKB028848@svn.freebsd.org>
References: <200909101924.n8AJOkKB028848@svn.freebsd.org>
Message-ID: <200909101606.54441.jhb@freebsd.org>

On Thursday 10 September 2009 3:24:46 pm Nick Hibma wrote:
> Author: n_hibma
> Date: Thu Sep 10 19:24:46 2009
> New Revision: 197076
> URL: http://svn.freebsd.org/changeset/base/197076
> 
> Log:
>   Move the printing of aperture size and stolen memory behind bootverbose.
>   None of the other AGP drivers actually displays this information at all,

Note that agp_i810 is different in that it is used for the on-board integrated 
Intel graphics and attaches to the display adapter (vgapciX) not to the AGP 
bridge (hostbX).  That is why other AGP drivers do not display the 
information; it is not relevant since AGP bridge drivers do not "steal" 
system RAM for a video frame buffer.

-- 
John Baldwin
From imp at bsdimp.com  Thu Sep 10 20:37:06 2009
From: imp at bsdimp.com (Warner Losh)
Date: Thu Sep 10 20:37:17 2009
Subject: svn commit: r197047 - head/share/man/man4
In-Reply-To: <200909092028.n89KSw1N096254@svn.freebsd.org>
References: <200909092028.n89KSw1N096254@svn.freebsd.org>
Message-ID: <20090910.143327.74744740.imp@bsdimp.com>

From: Brooks Davis 
Subject: svn commit: r197047 - head/share/man/man4
Date: Wed, 9 Sep 2009 20:28:58 +0000 (UTC)

> Author: brooks
> Date: Wed Sep  9 20:28:58 2009
> New Revision: 197047
> URL: http://svn.freebsd.org/changeset/base/197047
> 
> Log:
>   Mention that a few ed(4) devices don't emit link state change notices
>   and a workaround for dhclient.

I thought that I'd made it so that we report the link as active always
for those devices that don't support reporting the link status in the
hardware.  Is this really necessary still?

Warner

>   Reviewed by:	 thierry
>   MFC after:	3 days
> 
> Modified:
>   head/share/man/man4/ed.4
> 
> Modified: head/share/man/man4/ed.4
> ==============================================================================
> --- head/share/man/man4/ed.4	Wed Sep  9 19:40:54 2009	(r197046)
> +++ head/share/man/man4/ed.4	Wed Sep  9 20:28:58 2009	(r197047)
> @@ -425,3 +425,21 @@ driver is slow by today's standards.
>  .Pp
>  PC Card attachment supports the D-Link DMF650TX LAN/Modem card's Ethernet
>  port only at this time.
> +.Pp
> +Some devices supported by
> +.Nm
> +do no generate the link state change events used by
> +.Xr devd 8
> +to start
> +.Xr dhclinet 8 .
> +If you have problems with
> +.Xr dhclient 8
> +not starting and the device is always attached to the network it may
> +be possible to work around this by changing
> +.Dq Li DHCP
> +to
> +.Dq Li SYNCDHCP
> +in the
> +.Va ifconfig_ed0
> +entry in
> +.Pa /etc/rc.conf .
> 
From brooks at FreeBSD.org  Thu Sep 10 20:42:28 2009
From: brooks at FreeBSD.org (Brooks Davis)
Date: Thu Sep 10 20:42:40 2009
Subject: svn commit: r197047 - head/share/man/man4
In-Reply-To: <20090910.143327.74744740.imp@bsdimp.com>
References: <200909092028.n89KSw1N096254@svn.freebsd.org>
	<20090910.143327.74744740.imp@bsdimp.com>
Message-ID: <20090910204249.GB55545@lor.one-eyed-alien.net>

On Thu, Sep 10, 2009 at 02:33:27PM -0600, Warner Losh wrote:
> From: Brooks Davis 
> Subject: svn commit: r197047 - head/share/man/man4
> Date: Wed, 9 Sep 2009 20:28:58 +0000 (UTC)
> 
> > Author: brooks
> > Date: Wed Sep  9 20:28:58 2009
> > New Revision: 197047
> > URL: http://svn.freebsd.org/changeset/base/197047
> > 
> > Log:
> >   Mention that a few ed(4) devices don't emit link state change notices
> >   and a workaround for dhclient.
> 
> I thought that I'd made it so that we report the link as active always
> for those devices that don't support reporting the link status in the
> hardware.  Is this really necessary still?

That fixes the case where dhclient never sees a link, but apparently
doesn't deal with the fact that in 8.0 dhclient never starts without
a link-up event.  It may be that we need to generate a single link-up
event at startup to provide an equivalent workaround.

-- Brooks

> Warner
> 
> >   Reviewed by:	 thierry
> >   MFC after:	3 days
> > 
> > Modified:
> >   head/share/man/man4/ed.4
> > 
> > Modified: head/share/man/man4/ed.4
> > ==============================================================================
> > --- head/share/man/man4/ed.4	Wed Sep  9 19:40:54 2009	(r197046)
> > +++ head/share/man/man4/ed.4	Wed Sep  9 20:28:58 2009	(r197047)
> > @@ -425,3 +425,21 @@ driver is slow by today's standards.
> >  .Pp
> >  PC Card attachment supports the D-Link DMF650TX LAN/Modem card's Ethernet
> >  port only at this time.
> > +.Pp
> > +Some devices supported by
> > +.Nm
> > +do no generate the link state change events used by
> > +.Xr devd 8
> > +to start
> > +.Xr dhclinet 8 .
> > +If you have problems with
> > +.Xr dhclient 8
> > +not starting and the device is always attached to the network it may
> > +be possible to work around this by changing
> > +.Dq Li DHCP
> > +to
> > +.Dq Li SYNCDHCP
> > +in the
> > +.Va ifconfig_ed0
> > +entry in
> > +.Pa /etc/rc.conf .
> > 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090910/d7a6e45e/attachment.pgp
From jfv at FreeBSD.org  Thu Sep 10 21:14:56 2009
From: jfv at FreeBSD.org (Jack F Vogel)
Date: Thu Sep 10 21:15:02 2009
Subject: svn commit: r197078 - head/sys/dev/e1000
Message-ID: <200909102114.n8ALEtAr031324@svn.freebsd.org>

Author: jfv
Date: Thu Sep 10 21:14:55 2009
New Revision: 197078
URL: http://svn.freebsd.org/changeset/base/197078

Log:
  Fix build complaint from previous checkin

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==============================================================================
--- head/sys/dev/e1000/if_em.c	Thu Sep 10 19:27:53 2009	(r197077)
+++ head/sys/dev/e1000/if_em.c	Thu Sep 10 21:14:55 2009	(r197078)
@@ -1034,7 +1034,7 @@ em_mq_start_locked(struct ifnet *ifp, st
 		return (error);
 	} else if (drbr_empty(ifp, adapter->br) &&
 	    (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) {
-		if (error = em_xmit(adapter, &m)) {
+		if ((error = em_xmit(adapter, &m)) != 0) {
 			if (m != NULL)
 				error = drbr_enqueue(ifp, adapter->br, m);
 			return (error);
@@ -1064,7 +1064,7 @@ process:
                 next = drbr_dequeue(ifp, adapter->br);
                 if (next == NULL)
                         break;
-                if (error = em_xmit(adapter, &next)) {
+                if ((error = em_xmit(adapter, &next)) != 0) {
 			if (next != NULL)
 				error = drbr_enqueue(ifp, adapter->br, next);
                         break;
From jfv at FreeBSD.org  Thu Sep 10 21:16:26 2009
From: jfv at FreeBSD.org (Jack F Vogel)
Date: Thu Sep 10 21:16:33 2009
Subject: svn commit: r197079 - head/sys/dev/e1000
Message-ID: <200909102116.n8ALGQ64031395@svn.freebsd.org>

Author: jfv
Date: Thu Sep 10 21:16:26 2009
New Revision: 197079
URL: http://svn.freebsd.org/changeset/base/197079

Log:
  Fix build issue with last commit.

Modified:
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/if_igb.c
==============================================================================
--- head/sys/dev/e1000/if_igb.c	Thu Sep 10 21:14:55 2009	(r197078)
+++ head/sys/dev/e1000/if_igb.c	Thu Sep 10 21:16:26 2009	(r197079)
@@ -854,7 +854,7 @@ igb_mq_start_locked(struct ifnet *ifp, s
 
 	/* If nothing queued go right to xmit */
 	if (drbr_empty(ifp, txr->br)) {
-		if (err = igb_xmit(txr, &m)) {
+		if ((err = igb_xmit(txr, &m)) != 0) {
 			if (m != NULL)
 				err = drbr_enqueue(ifp, txr->br, m);
 			return (err);
@@ -881,7 +881,7 @@ process:
 		next = drbr_dequeue(ifp, txr->br);
 		if (next == NULL)
 			break;
-		if (err = igb_xmit(txr, &next)) {
+		if ((err = igb_xmit(txr, &next)) != 0) {
 			if (next != NULL)
 				err = drbr_enqueue(ifp, txr->br, next);
 			break;
From nwhitehorn at FreeBSD.org  Thu Sep 10 21:25:06 2009
From: nwhitehorn at FreeBSD.org (Nathan Whitehorn)
Date: Thu Sep 10 21:25:13 2009
Subject: svn commit: r197080 - head/sys/powerpc/conf
Message-ID: <200909102125.n8ALP6j4031634@svn.freebsd.org>

Author: nwhitehorn
Date: Thu Sep 10 21:25:05 2009
New Revision: 197080
URL: http://svn.freebsd.org/changeset/base/197080

Log:
  Add a few SCSI controllers to GENERIC that can be found on Powermacs.
  This allows installation onto SCSI disks as shipped, for example,
  with the Powermac G3.
  
  PR:		powerpc/138543
  Obtained from:	sparc64
  MFC after:	3 days

Modified:
  head/sys/powerpc/conf/GENERIC

Modified: head/sys/powerpc/conf/GENERIC
==============================================================================
--- head/sys/powerpc/conf/GENERIC	Thu Sep 10 21:16:26 2009	(r197079)
+++ head/sys/powerpc/conf/GENERIC	Thu Sep 10 21:25:05 2009	(r197080)
@@ -91,6 +91,16 @@ device		atapicd		# ATAPI CDROM drives
 #device		atapifd		# ATAPI floppy drives
 #device		atapist		# ATAPI tape drives
 
+# SCSI Controllers
+device		ahc		# AHA2940 and onboard AIC7xxx devices
+options 	AHC_ALLOW_MEMIO	# Attempt to use memory mapped I/O
+options 	AHC_REG_PRETTY_PRINT	# Print register bitfields in debug
+					# output.  Adds ~128k to driver.
+device		isp		# Qlogic family
+device		ispfw		# Firmware module for Qlogic host adapters
+device		mpt		# LSI-Logic MPT-Fusion
+device		sym		# NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D
+
 # SCSI peripherals
 device		scbus		# SCSI bus (required for SCSI)
 device		da		# Direct Access (disks)
@@ -127,6 +137,7 @@ device		md		# Memory "disks"
 device		ofwd		# Open Firmware disks
 device		gif		# IPv6 and IPv4 tunneling
 device		faith		# IPv6-to-IPv4 relaying/(translation)
+device		firmware	# firmware assist module
 
 # The `bpf' device enables the Berkeley Packet Filter.
 # Be aware of the administrative consequences of enabling this!
From delphij at FreeBSD.org  Thu Sep 10 21:42:00 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Thu Sep 10 21:42:11 2009
Subject: svn commit: r197081 - head
Message-ID: <200909102142.n8ALg0lV032087@svn.freebsd.org>

Author: delphij
Date: Thu Sep 10 21:42:00 2009
New Revision: 197081
URL: http://svn.freebsd.org/changeset/base/197081

Log:
  Add entries for moved files during vesa/dpms promotion.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Thu Sep 10 21:25:05 2009	(r197080)
+++ head/ObsoleteFiles.inc	Thu Sep 10 21:42:00 2009	(r197081)
@@ -14,6 +14,9 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20090909: vesa and dpms promoted to be i386/amd64 common
+OLD_FILES+=usr/include/machine/pc/vesa.h
+OLD_FILES+=usr/share/man/man4/i386/dpms.4.gz
 # 20090904: remove lukemftpd
 OLD_FILES+=usr/libexec/lukemftpd
 OLD_FILES+=usr/share/man/man5/ftpd.conf.5.gz
From emaste at FreeBSD.org  Thu Sep 10 22:05:44 2009
From: emaste at FreeBSD.org (Ed Maste)
Date: Thu Sep 10 22:05:50 2009
Subject: svn commit: r197082 - head/sys/boot/i386/libi386
Message-ID: <200909102205.n8AM5hT5032715@svn.freebsd.org>

Author: emaste
Date: Thu Sep 10 22:05:43 2009
New Revision: 197082
URL: http://svn.freebsd.org/changeset/base/197082

Log:
  If the pxe client is told to use / as the root path, honour that rather
  of trying to mount /pxeroot instead.
  
  PR:		i386/106493
  Submitted by:	Andrey Russev
  MFC after:	1 month

Modified:
  head/sys/boot/i386/libi386/pxe.c

Modified: head/sys/boot/i386/libi386/pxe.c
==============================================================================
--- head/sys/boot/i386/libi386/pxe.c	Thu Sep 10 21:42:00 2009	(r197081)
+++ head/sys/boot/i386/libi386/pxe.c	Thu Sep 10 22:05:43 2009	(r197082)
@@ -282,7 +282,7 @@ pxe_open(struct open_file *f, ...)
 		bootp(pxe_sock, BOOTP_PXE);
 		if (rootip.s_addr == 0)
 			rootip.s_addr = bootplayer.sip;
-		if (!rootpath[1])
+		if (!rootpath[0])
 			strcpy(rootpath, PXENFSROOTPATH);
 
 		for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
From emax at FreeBSD.org  Thu Sep 10 23:30:13 2009
From: emax at FreeBSD.org (Maksim Yevmenkin)
Date: Thu Sep 10 23:30:19 2009
Subject: svn commit: r197083 - head/sys/netgraph/bluetooth/include
Message-ID: <200909102330.n8ANUDWt034537@svn.freebsd.org>

Author: emax
Date: Thu Sep 10 23:30:13 2009
New Revision: 197083
URL: http://svn.freebsd.org/changeset/base/197083

Log:
  Get those pesky RFCOMM RPM data bits right. This is likely a noop.
  
  MFC after:	1 month

Modified:
  head/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h

Modified: head/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h
==============================================================================
--- head/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h	Thu Sep 10 22:05:43 2009	(r197082)
+++ head/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h	Thu Sep 10 23:30:13 2009	(r197083)
@@ -85,8 +85,8 @@
 
 /* RPN parameters - data bits */
 #define RFCOMM_RPN_DATA_5		0x0
-#define RFCOMM_RPN_DATA_6		0x1
-#define RFCOMM_RPN_DATA_7		0x2
+#define RFCOMM_RPN_DATA_6		0x2
+#define RFCOMM_RPN_DATA_7		0x1
 #define RFCOMM_RPN_DATA_8		0x3
 
 /* RPN parameters - stop bit */
From jfv at FreeBSD.org  Fri Sep 11 00:00:23 2009
From: jfv at FreeBSD.org (Jack F Vogel)
Date: Fri Sep 11 00:00:34 2009
Subject: svn commit: r197084 - head/sys/dev/ixgbe
Message-ID: <200909110000.n8B00N5C035175@svn.freebsd.org>

Author: jfv
Date: Fri Sep 11 00:00:23 2009
New Revision: 197084
URL: http://svn.freebsd.org/changeset/base/197084

Log:
  Stats missed packet handling was still not quite
  right, thanks to Dmitrij Tejblum for the correction,
  need a variable with scope only within the for loop
  for all queues.
  
  MFC: 3 days

Modified:
  head/sys/dev/ixgbe/ixgbe.c

Modified: head/sys/dev/ixgbe/ixgbe.c
==============================================================================
--- head/sys/dev/ixgbe/ixgbe.c	Thu Sep 10 23:30:13 2009	(r197083)
+++ head/sys/dev/ixgbe/ixgbe.c	Fri Sep 11 00:00:23 2009	(r197084)
@@ -4480,9 +4480,11 @@ ixgbe_update_stats_counters(struct adapt
 	adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
 
 	for (int i = 0; i < 8; i++) {
+		u32 mp;
+		mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
 		/* missed_rx tallies misses for the gprc workaround */
-		missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(i));
-        	adapter->stats.mpc[i] += missed_rx;
+		missed_rx += mp;
+        	adapter->stats.mpc[i] += mp;
 		/* Running comprehensive total for stats display */
 		total_missed_rx += adapter->stats.mpc[i];
 		if (hw->mac.type == ixgbe_mac_82598EB)
From delphij at FreeBSD.org  Fri Sep 11 02:07:25 2009
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Sep 11 02:07:31 2009
Subject: svn commit: r197085 - in head: share/man/man4 sys/dev/syscons
Message-ID: <200909110207.n8B27PjH037758@svn.freebsd.org>

Author: delphij
Date: Fri Sep 11 02:07:24 2009
New Revision: 197085
URL: http://svn.freebsd.org/changeset/base/197085

Log:
  Extend the usage of sc(4)'s hint variable 'flag'.  Bit 0x80 now means
  "set vesa mode" and higher 16bits of the flag would be the desired mode.
  
  One can now set, for instance, hint.sc.0.flags=0x01680180, which means
  that the system should set VESA mode 0x168 upon boot.
  
  Submitted by:	paradox , swell k at gmail.com with
  		some minor changes.

Modified:
  head/share/man/man4/syscons.4
  head/sys/dev/syscons/syscons.c
  head/sys/dev/syscons/syscons.h

Modified: head/share/man/man4/syscons.4
==============================================================================
--- head/share/man/man4/syscons.4	Fri Sep 11 00:00:23 2009	(r197084)
+++ head/share/man/man4/syscons.4	Fri Sep 11 02:07:24 2009	(r197085)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 22, 2006
+.Dd September 10, 2009
 .Dt SYSCONS 4
 .Os
 .Sh NAME
@@ -325,7 +325,7 @@ This mode is useful on some laptop compu
 most other systems, and it adds substantial amount of code to syscons.
 If this option is NOT defined, you can reduce the kernel size a lot.
 See the
-.Dv VESA800X600
+.Dv VESAMODE
 flag below.
 .It Dv SC_TWOBUTTON_MOUSE
 If you have a two button mouse, you may want to add this option
@@ -426,15 +426,15 @@ or else at the loader prompt (see
 .\".It bit 6 (QUIET_BELL)
 .\"This option suppresses the bell, whether audible or visual,
 .\"if it is rung in a background virtual terminal.
-.It 0x0080 (VESA800X600)
-This option puts the video card in the VESA 800x600 pixel, 16 color
-mode.
-It may be useful for laptop computers for which the 800x600 mode
-is otherwise unsupported by the X server.
+.It 0x0080 (VESAMODE)
+This option puts the video card in the VESA mode specified by higher
+16 bits of the flags during kernel initialization.
 Note that in order for this flag to work, the kernel must be
 compiled with the
 .Dv SC_PIXEL_MODE
 option explained above.
+A list of the available mode can be obtained via
+.Xr vidcontrol 1 .
 .\"Note also that the ``copy-and-paste'' function is not currently supported
 .\"in this mode and the mouse pointer will not be displayed.
 .It 0x0100 (AUTODETECT_KBD)

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Fri Sep 11 00:00:23 2009	(r197084)
+++ head/sys/dev/syscons/syscons.c	Fri Sep 11 02:07:24 2009	(r197085)
@@ -352,6 +352,7 @@ sc_attach_unit(int unit, int flags)
 #endif
     int vc;
     struct cdev *dev;
+    u_int16_t vmode;
 
     flags &= ~SC_KERNEL_CONSOLE;
 
@@ -372,16 +373,20 @@ sc_attach_unit(int unit, int flags)
     if (sc_console == NULL)	/* sc_console_unit < 0 */
 	sc_console = scp;
 
+    vmode = (flags >> 16) & 0x1fff;
+    if (vmode < M_VESA_BASE || vmode > M_VESA_MODE_MAX)
+	vmode = M_VESA_FULL_800;
+
 #ifdef SC_PIXEL_MODE
-    if ((sc->config & SC_VESA800X600)
-	&& (vidd_get_info(sc->adp, M_VESA_800x600, &info) == 0)) {
+    if ((sc->config & SC_VESAMODE)
+	&& (vidd_get_info(sc->adp, vmode, &info) == 0)) {
 #ifdef DEV_SPLASH
 	if (sc->flags & SC_SPLASH_SCRN)
 	    splash_term(sc->adp);
 #endif
-	sc_set_graphics_mode(scp, NULL, M_VESA_800x600);
-	sc_set_pixel_mode(scp, NULL, COL, ROW, 16, 8);
-	sc->initial_mode = M_VESA_800x600;
+	sc_set_graphics_mode(scp, NULL, vmode);
+	sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
+	sc->initial_mode = vmode;
 #ifdef DEV_SPLASH
 	/* put up the splash again! */
 	if (sc->flags & SC_SPLASH_SCRN)
@@ -517,7 +522,7 @@ sctty_open(struct tty *tp)
     if (scp == NULL) {
 	scp = SC_STAT(tp) = alloc_scp(sc, SC_VTY(tp));
 	if (ISGRAPHSC(scp))
-	    sc_set_pixel_mode(scp, NULL, COL, ROW, 16, 8);
+	    sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
     }
     if (!tp->t_winsize.ws_col && !tp->t_winsize.ws_row) {
 	tp->t_winsize.ws_col = scp->xsize;
@@ -2995,6 +3000,8 @@ init_scp(sc_softc_t *sc, int vty, scr_st
 	scp->ysize = info.vi_height;
 	scp->xpixel = scp->xsize*info.vi_cwidth;
 	scp->ypixel = scp->ysize*info.vi_cheight;
+    }
+
 	scp->font_size = info.vi_cheight;
 	scp->font_width = info.vi_cwidth;
 	if (info.vi_cheight < 14) {
@@ -3016,7 +3023,7 @@ init_scp(sc_softc_t *sc, int vty, scr_st
 	    scp->font = NULL;
 #endif
 	}
-    }
+
     sc_vtb_init(&scp->vtb, VTB_MEMORY, 0, 0, NULL, FALSE);
 #ifndef __sparc64__
     sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, 0, 0, NULL, FALSE);

Modified: head/sys/dev/syscons/syscons.h
==============================================================================
--- head/sys/dev/syscons/syscons.h	Fri Sep 11 00:00:23 2009	(r197084)
+++ head/sys/dev/syscons/syscons.h	Fri Sep 11 02:07:24 2009	(r197085)
@@ -191,7 +191,7 @@ struct tty;
 typedef struct sc_softc {
 	int		unit;			/* unit # */
 	int		config;			/* configuration flags */
-#define SC_VESA800X600	(1 << 7)
+#define SC_VESAMODE	(1 << 7)
 #define SC_AUTODETECT_KBD (1 << 8)
 #define SC_KERNEL_CONSOLE (1 << 9)
 
From des at des.no  Fri Sep 11 07:09:30 2009
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Fri Sep 11 07:09:42 2009
Subject: svn commit: r197072 - in head/sys: dev/ichwd netsmb
In-Reply-To: <4AA95049.4090104@freebsd.org> (Andriy Gapon's message of "Thu,
	10 Sep 2009 22:15:21 +0300")
References: <200909101833.n8AIX8p6027487@svn.freebsd.org>
	<86iqfq8vja.fsf@ds4.des.no> <4AA95049.4090104@freebsd.org>
Message-ID: <86eiqe7yaf.fsf@ds4.des.no>

Andriy Gapon  writes:
> Dag-Erling Sm?rgrav  writes:
>> Nick Hibma  writes:
>>>   Put a message behind bootverbose as
>>>   
>>>   	ichwd0:  on isa0
>
> I think the above line is printed by newbus code automatically.
>
>>>   	ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent)
>
> And this line kind of duplicates it.

Thanks, that explains it.  Nick: might as well remove that printf
altogether...

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From mav at FreeBSD.org  Fri Sep 11 11:42:57 2009
From: mav at FreeBSD.org (Alexander Motin)
Date: Fri Sep 11 11:43:10 2009
Subject: svn commit: r197086 - head/lib/libradius
Message-ID: <200909111142.n8BBgvIV051117@svn.freebsd.org>

Author: mav
Date: Fri Sep 11 11:42:56 2009
New Revision: 197086
URL: http://svn.freebsd.org/changeset/base/197086

Log:
  Add simple embedded RADIUS server support to libradius, by extending existing
  API, keeping backward compatibility.
  
  First consumer for this functionality is going to become forthcoming MPD-5.4,
  supporting CoA and DR of RFC 3576: Dynamic Authorization Extensions to RADIUS.
  
  MFC after:	1 month

Modified:
  head/lib/libradius/libradius.3
  head/lib/libradius/radlib.c
  head/lib/libradius/radlib.h
  head/lib/libradius/radlib_private.h

Modified: head/lib/libradius/libradius.3
==============================================================================
--- head/lib/libradius/libradius.3	Fri Sep 11 02:07:24 2009	(r197085)
+++ head/lib/libradius/libradius.3	Fri Sep 11 11:42:56 2009	(r197086)
@@ -1,4 +1,5 @@
 .\" Copyright 1998 Juniper Networks, Inc.
+.\" Copyright 2009 Alexander Motin .
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,12 +25,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 27, 2004
+.Dd August 5, 2009
 .Dt LIBRADIUS 3
 .Os
 .Sh NAME
 .Nm libradius
-.Nd RADIUS client library
+.Nd RADIUS client/server library
 .Sh SYNOPSIS
 .In radlib.h
 .Ft "struct rad_handle *"
@@ -46,6 +47,8 @@
 .Fn rad_continue_send_request "struct rad_handle *h" "int selected" "int *fd" "struct timeval *tv"
 .Ft int
 .Fn rad_create_request "struct rad_handle *h" "int code"
+.Ft int
+.Fn rad_create_response "struct rad_handle *h" "int code"
 .Ft "struct in_addr"
 .Fn rad_cvt_addr "const void *data"
 .Ft u_int32_t
@@ -79,7 +82,13 @@
 .Ft ssize_t
 .Fn rad_request_authenticator "struct rad_handle *h" "char *buf" "size_t len"
 .Ft int
+.Fn rad_receive_request "struct rad_handle *h"
+.Ft int
 .Fn rad_send_request "struct rad_handle *h"
+.Ft int
+.Fn rad_send_response "struct rad_handle *h"
+.Ft "struct rad_handle *"
+.Fn rad_server_open "int fd"
 .Ft "const char *"
 .Fn rad_server_secret "struct rad_handle *h"
 .Ft u_char *
@@ -91,16 +100,17 @@
 .Sh DESCRIPTION
 The
 .Nm
-library implements the client side of the Remote Authentication Dial
-In User Service (RADIUS).
+library implements the Remote Authentication Dial In User Service (RADIUS).
 RADIUS, defined in RFCs 2865 and 2866,
 allows clients to perform authentication and accounting by means of
 network requests to remote servers.
 .Ss Initialization
 To use the library, an application must first call
 .Fn rad_auth_open
-or
+,
 .Fn rad_acct_open
+or
+.Fn rad_server_open
 to obtain a
 .Vt "struct rad_handle *" ,
 which provides the context for subsequent operations.
@@ -108,8 +118,10 @@ The former function is used for RADIUS a
 latter is used for RADIUS accounting.
 Calls to
 .Fn rad_auth_open
-and
+,
 .Fn rad_acct_open
+and
+.Fn rad_server_open
 always succeed unless insufficient virtual memory is available.
 If
 the necessary memory cannot be allocated, the functions return
@@ -451,6 +463,25 @@ subsequent library calls using the same 
 .Ss Cleanup
 To free the resources used by the RADIUS library, call
 .Fn rad_close .
+.Ss Server operation
+Server mode operates much alike to client mode, except packet send and receieve
+steps are swapped. To operate as server you should obtain server context with
+.Fn rad_server_open
+function, passing opened and bound UDP socket file descriptor as argument.
+You should define allowed clients and their secrets using
+.Fn rad_add_server
+function. port, timeout and max_tries arguments are ignored in server mode.
+You should call
+.Fn rad_receive_request
+function to receive request from client. If you do not want to block on socket
+read, you are free to use any poll(), select() or non-blocking sockets for
+the socket.
+Received request can be parsed with same parsing functions as for client.
+To respond to the request you should call
+.Fn rad_create_response
+and fill response content with same packet writing functions as for client.
+When packet is ready, it should be sent with
+.Fn rad_send_response
 .Sh RETURN VALUES
 The following functions return a non-negative value on success.
 If
@@ -466,6 +497,8 @@ which can be retrieved using
 .It
 .Fn rad_create_request
 .It
+.Fn rad_create_response
+.It
 .Fn rad_get_attr
 .It
 .Fn rad_put_addr
@@ -483,6 +516,8 @@ which can be retrieved using
 .Fn rad_continue_send_request
 .It
 .Fn rad_send_request
+.It
+.Fn rad_send_response
 .El
 .Pp
 The following functions return a
@@ -499,6 +534,8 @@ without recording an error message.
 .It
 .Fn rad_auth_open
 .It
+.Fn rad_server_open
+.It
 .Fn rad_cvt_string
 .El
 .Pp
@@ -553,3 +590,5 @@ subsequently added the ability to perfor
 accounting.
 Later additions and changes by
 .An Michael Bretterklieber .
+Server mode support was added by
+.An Alexander Motin .

Modified: head/lib/libradius/radlib.c
==============================================================================
--- head/lib/libradius/radlib.c	Fri Sep 11 02:07:24 2009	(r197085)
+++ head/lib/libradius/radlib.c	Fri Sep 11 11:42:56 2009	(r197086)
@@ -103,7 +103,7 @@ insert_scrambled_password(struct rad_han
 	srvp = &h->servers[srv];
 	padded_len = h->pass_len == 0 ? 16 : (h->pass_len+15) & ~0xf;
 
-	memcpy(md5, &h->request[POS_AUTH], LEN_AUTH);
+	memcpy(md5, &h->out[POS_AUTH], LEN_AUTH);
 	for (pos = 0;  pos < padded_len;  pos += 16) {
 		int i;
 
@@ -120,49 +120,55 @@ insert_scrambled_password(struct rad_han
 		 * in calculating the scrambler for next time.
 		 */
 		for (i = 0;  i < 16;  i++)
-			h->request[h->pass_pos + pos + i] =
+			h->out[h->pass_pos + pos + i] =
 			    md5[i] ^= h->pass[pos + i];
 	}
 }
 
 static void
-insert_request_authenticator(struct rad_handle *h, int srv)
+insert_request_authenticator(struct rad_handle *h, int resp)
 {
 	MD5_CTX ctx;
 	const struct rad_server *srvp;
 
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	/* Create the request authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, memset(&h->request[POS_AUTH], 0, LEN_AUTH), LEN_AUTH);
-	MD5Update(&ctx, &h->request[POS_ATTRS], h->req_len - POS_ATTRS);
+	MD5Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+	if (resp)
+	    MD5Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+	else
+	    MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->out[POS_ATTRS], h->out_len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
-	MD5Final(&h->request[POS_AUTH], &ctx);
+	MD5Final(&h->out[POS_AUTH], &ctx);
 }
 
 static void
-insert_message_authenticator(struct rad_handle *h, int srv)
+insert_message_authenticator(struct rad_handle *h, int resp)
 {
 #ifdef WITH_SSL
 	u_char md[EVP_MAX_MD_SIZE];
 	u_int md_len;
 	const struct rad_server *srvp;
 	HMAC_CTX ctx;
-	srvp = &h->servers[srv];
+	srvp = &h->servers[h->srv];
 
 	if (h->authentic_pos != 0) {
 		HMAC_CTX_init(&ctx);
 		HMAC_Init(&ctx, srvp->secret, strlen(srvp->secret), EVP_md5());
-		HMAC_Update(&ctx, &h->request[POS_CODE], POS_AUTH - POS_CODE);
-		HMAC_Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-		HMAC_Update(&ctx, &h->request[POS_ATTRS],
-		    h->req_len - POS_ATTRS);
+		HMAC_Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+		if (resp)
+		    HMAC_Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+		else
+		    HMAC_Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+		HMAC_Update(&ctx, &h->out[POS_ATTRS],
+		    h->out_len - POS_ATTRS);
 		HMAC_Final(&ctx, md, &md_len);
 		HMAC_CTX_cleanup(&ctx);
 		HMAC_cleanup(&ctx);
-		memcpy(&h->request[h->authentic_pos + 2], md, md_len);
+		memcpy(&h->out[h->authentic_pos + 2], md, md_len);
 	}
 #endif
 }
@@ -195,20 +201,20 @@ is_valid_response(struct rad_handle *h, 
 		return 0;
 
 	/* Check the message length */
-	if (h->resp_len < POS_ATTRS)
+	if (h->in_len < POS_ATTRS)
 		return 0;
-	len = h->response[POS_LENGTH] << 8 | h->response[POS_LENGTH+1];
-	if (len > h->resp_len)
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
 		return 0;
 
 	/* Check the response authenticator */
 	MD5Init(&ctx);
-	MD5Update(&ctx, &h->response[POS_CODE], POS_AUTH - POS_CODE);
-	MD5Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
-	MD5Update(&ctx, &h->response[POS_ATTRS], len - POS_ATTRS);
+	MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+	MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
+	MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
 	MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
 	MD5Final(md5, &ctx);
-	if (memcmp(&h->response[POS_AUTH], md5, sizeof md5) != 0)
+	if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
 		return 0;
 
 #ifdef WITH_SSL
@@ -216,42 +222,111 @@ is_valid_response(struct rad_handle *h, 
 	 * For non accounting responses check the message authenticator,
 	 * if any.
 	 */
-	if (h->response[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
+	if (h->in[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
 
-		memcpy(resp, h->response, MSGSIZE);
+		memcpy(resp, h->in, MSGSIZE);
 		pos = POS_ATTRS;
 
 		/* Search and verify the Message-Authenticator */
 		while (pos < len - 2) {
 
-			if (h->response[pos] == RAD_MESSAGE_AUTHENTIC) {
+			if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
 				/* zero fill the Message-Authenticator */
 				memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
 
 				HMAC_CTX_init(&hctx);
 				HMAC_Init(&hctx, srvp->secret,
 				    strlen(srvp->secret), EVP_md5());
-				HMAC_Update(&hctx, &h->response[POS_CODE],
+				HMAC_Update(&hctx, &h->in[POS_CODE],
 				    POS_AUTH - POS_CODE);
-				HMAC_Update(&hctx, &h->request[POS_AUTH],
+				HMAC_Update(&hctx, &h->out[POS_AUTH],
 				    LEN_AUTH);
 				HMAC_Update(&hctx, &resp[POS_ATTRS],
-				    h->resp_len - POS_ATTRS);
+				    h->in_len - POS_ATTRS);
 				HMAC_Final(&hctx, md, &md_len);
 				HMAC_CTX_cleanup(&hctx);
 				HMAC_cleanup(&hctx);
-				if (memcmp(md, &h->response[pos + 2],
+				if (memcmp(md, &h->in[pos + 2],
 				    MD5_DIGEST_LENGTH) != 0)
 					return 0;
 				break;
 			}
-			pos += h->response[pos + 1];
+			pos += h->in[pos + 1];
 		}
 	}
 #endif
 	return 1;
 }
 
+/*
+ * Return true if the current request is valid for the specified server.
+ */
+static int
+is_valid_request(struct rad_handle *h)
+{
+	MD5_CTX ctx;
+	unsigned char md5[MD5_DIGEST_LENGTH];
+	const struct rad_server *srvp;
+	int len;
+#ifdef WITH_SSL
+	HMAC_CTX hctx;
+	u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
+	u_int md_len;
+	int pos;
+#endif
+
+	srvp = &h->servers[h->srv];
+
+	/* Check the message length */
+	if (h->in_len < POS_ATTRS)
+		return (0);
+	len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
+	if (len > h->in_len)
+		return (0);
+
+	if (h->in[POS_CODE] != RAD_ACCESS_REQUEST) {
+		uint32_t zeroes[4] = { 0, 0, 0, 0 };
+		/* Check the request authenticator */
+		MD5Init(&ctx);
+		MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
+		MD5Update(&ctx, zeroes, LEN_AUTH);
+		MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
+		MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
+		MD5Final(md5, &ctx);
+		if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
+			return (0);
+	}
+
+#ifdef WITH_SSL
+	/* Search and verify the Message-Authenticator */
+	pos = POS_ATTRS;
+	while (pos < len - 2) {
+		if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
+			memcpy(resp, h->in, MSGSIZE);
+			/* zero fill the Request-Authenticator */
+			if (h->in[POS_CODE] != RAD_ACCESS_REQUEST)
+				memset(&resp[POS_AUTH], 0, LEN_AUTH);
+			/* zero fill the Message-Authenticator */
+			memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
+
+			HMAC_CTX_init(&hctx);
+			HMAC_Init(&hctx, srvp->secret,
+			    strlen(srvp->secret), EVP_md5());
+			HMAC_Update(&hctx, resp, h->in_len);
+			HMAC_Final(&hctx, md, &md_len);
+			HMAC_CTX_cleanup(&hctx);
+			HMAC_cleanup(&hctx);
+			if (memcmp(md, &h->in[pos + 2],
+			    MD5_DIGEST_LENGTH) != 0)
+				return (0);
+			break;
+		}
+		pos += h->in[pos + 1];
+	}
+#endif
+	return (1);
+}
+
 static int
 put_password_attr(struct rad_handle *h, int type, const void *value, size_t len)
 {
@@ -273,7 +348,7 @@ put_password_attr(struct rad_handle *h, 
 	 */
 	clear_password(h);
 	put_raw_attr(h, type, h->pass, padded_len);
-	h->pass_pos = h->req_len - padded_len;
+	h->pass_pos = h->out_len - padded_len;
 
 	/* Save the cleartext password, padded as necessary */
 	memcpy(h->pass, value, len);
@@ -289,14 +364,14 @@ put_raw_attr(struct rad_handle *h, int t
 		generr(h, "Attribute too long");
 		return -1;
 	}
-	if (h->req_len + 2 + len > MSGSIZE) {
+	if (h->out_len + 2 + len > MSGSIZE) {
 		generr(h, "Maximum message length exceeded");
 		return -1;
 	}
-	h->request[h->req_len++] = type;
-	h->request[h->req_len++] = len + 2;
-	memcpy(&h->request[h->req_len], value, len);
-	h->req_len += len;
+	h->out[h->out_len++] = type;
+	h->out[h->out_len++] = len + 2;
+	memcpy(&h->out[h->out_len], value, len);
+	h->out_len += len;
 	return 0;
 }
 
@@ -523,22 +598,26 @@ rad_continue_send_request(struct rad_han
 {
 	int n;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	if (selected) {
 		struct sockaddr_in from;
 		socklen_t fromlen;
 
 		fromlen = sizeof from;
-		h->resp_len = recvfrom(h->fd, h->response,
+		h->in_len = recvfrom(h->fd, h->in,
 		    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
-		if (h->resp_len == -1) {
+		if (h->in_len == -1) {
 			generr(h, "recvfrom: %s", strerror(errno));
 			return -1;
 		}
 		if (is_valid_response(h, h->srv, &from)) {
-			h->resp_len = h->response[POS_LENGTH] << 8 |
-			    h->response[POS_LENGTH+1];
-			h->resp_pos = POS_ATTRS;
-			return h->response[POS_CODE];
+			h->in_len = h->in[POS_LENGTH] << 8 |
+			    h->in[POS_LENGTH+1];
+			h->in_pos = POS_ATTRS;
+			return h->in[POS_CODE];
 		}
 	}
 
@@ -556,21 +635,22 @@ rad_continue_send_request(struct rad_han
 		if (++h->srv >= h->num_servers)
 			h->srv = 0;
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST)
-		/* Insert the request authenticator into the request */
-		insert_request_authenticator(h, h->srv);
-	else
+	if (h->out[POS_CODE] == RAD_ACCESS_REQUEST) {
 		/* Insert the scrambled password into the request */
 		if (h->pass_pos != 0)
 			insert_scrambled_password(h, h->srv);
-
-	insert_message_authenticator(h, h->srv);
+	}
+	insert_message_authenticator(h, 0);
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
+		/* Insert the request authenticator into the request */
+		insert_request_authenticator(h, h->srv);
+	}
 
 	/* Send the request */
-	n = sendto(h->fd, h->request, h->req_len, 0,
+	n = sendto(h->fd, h->out, h->out_len, 0,
 	    (const struct sockaddr *)&h->servers[h->srv].addr,
 	    sizeof h->servers[h->srv].addr);
-	if (n != h->req_len) {
+	if (n != h->out_len) {
 		if (n == -1)
 			generr(h, "sendto: %s", strerror(errno));
 		else
@@ -588,22 +668,117 @@ rad_continue_send_request(struct rad_han
 }
 
 int
+rad_receive_request(struct rad_handle *h)
+{
+	struct sockaddr_in from;
+	socklen_t fromlen;
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->srv = -1;
+	fromlen = sizeof(from);
+	h->in_len = recvfrom(h->fd, h->in,
+	    MSGSIZE, MSG_WAITALL, (struct sockaddr *)&from, &fromlen);
+	if (h->in_len == -1) {
+		generr(h, "recvfrom: %s", strerror(errno));
+		return (-1);
+	}
+	for (n = 0; n < h->num_servers; n++) {
+		if (h->servers[n].addr.sin_addr.s_addr == from.sin_addr.s_addr) {
+			h->servers[n].addr.sin_port = from.sin_port;
+			h->srv = n;
+			break;
+		}
+	}
+	if (h->srv == -1)
+		return (-2);
+	if (is_valid_request(h)) {
+		h->in_len = h->in[POS_LENGTH] << 8 |
+		    h->in[POS_LENGTH+1];
+		h->in_pos = POS_ATTRS;
+		return (h->in[POS_CODE]);
+	}
+	return (-3);
+}
+
+int
+rad_send_response(struct rad_handle *h)
+{
+	int n;
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	/* Fill in the length field in the message */
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
+
+	insert_message_authenticator(h,
+	    (h->in[POS_CODE] == RAD_ACCESS_REQUEST) ? 1 : 0);
+	insert_request_authenticator(h, 1);
+
+	/* Send the request */
+	n = sendto(h->fd, h->out, h->out_len, 0,
+	    (const struct sockaddr *)&h->servers[h->srv].addr,
+	    sizeof h->servers[h->srv].addr);
+	if (n != h->out_len) {
+		if (n == -1)
+			generr(h, "sendto: %s", strerror(errno));
+		else
+			generr(h, "sendto: short write");
+		return -1;
+	}
+
+	return 0;
+}
+
+int
 rad_create_request(struct rad_handle *h, int code)
 {
 	int i;
 
-	h->request[POS_CODE] = code;
-	h->request[POS_IDENT] = ++h->ident;
-	/* Create a random authenticator */
-	for (i = 0;  i < LEN_AUTH;  i += 2) {
-		long r;
-		r = random();
-		h->request[POS_AUTH+i] = (u_char)r;
-		h->request[POS_AUTH+i+1] = (u_char)(r >> 8);
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = ++h->ident;
+	if (code == RAD_ACCESS_REQUEST) {
+		/* Create a random authenticator */
+		for (i = 0;  i < LEN_AUTH;  i += 2) {
+			long r;
+			r = random();
+			h->out[POS_AUTH+i] = (u_char)r;
+			h->out[POS_AUTH+i+1] = (u_char)(r >> 8);
+		}
+	} else
+		memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
+	clear_password(h);
+	h->authentic_pos = 0;
+	h->out_created = 1;
+	return 0;
+}
+
+int
+rad_create_response(struct rad_handle *h, int code)
+{
+
+	if (h->type != RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
 	}
-	h->req_len = POS_ATTRS;
+	h->out[POS_CODE] = code;
+	h->out[POS_IDENT] = h->in[POS_IDENT];
+	memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+	h->out_len = POS_ATTRS;
 	clear_password(h);
-	h->request_created = 1;
+	h->authentic_pos = 0;
+	h->out_created = 1;
 	return 0;
 }
 
@@ -647,20 +822,20 @@ rad_get_attr(struct rad_handle *h, const
 {
 	int type;
 
-	if (h->resp_pos >= h->resp_len)
+	if (h->in_pos >= h->in_len)
 		return 0;
-	if (h->resp_pos + 2 > h->resp_len) {
+	if (h->in_pos + 2 > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	type = h->response[h->resp_pos++];
-	*len = h->response[h->resp_pos++] - 2;
-	if (h->resp_pos + (int)*len > h->resp_len) {
+	type = h->in[h->in_pos++];
+	*len = h->in[h->in_pos++] - 2;
+	if (h->in_pos + (int)*len > h->in_len) {
 		generr(h, "Malformed attribute in response");
 		return -1;
 	}
-	*value = &h->response[h->resp_pos];
-	h->resp_pos += *len;
+	*value = &h->in[h->in_pos];
+	h->in_pos += *len;
 	return type;
 }
 
@@ -672,6 +847,10 @@ rad_init_send_request(struct rad_handle 
 {
 	int srv;
 
+	if (h->type == RADIUS_SERVER) {
+		generr(h, "denied function call");
+		return (-1);
+	}
 	/* Make sure we have a socket to use */
 	if (h->fd == -1) {
 		struct sockaddr_in sin;
@@ -694,7 +873,7 @@ rad_init_send_request(struct rad_handle 
 		}
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
 		/* Make sure no password given */
 		if (h->pass_pos || h->chap_pass) {
 			generr(h, "User or Chap Password"
@@ -718,8 +897,8 @@ rad_init_send_request(struct rad_handle 
 	}
 
 	/* Fill in the length field in the message */
-	h->request[POS_LENGTH] = h->req_len >> 8;
-	h->request[POS_LENGTH+1] = h->req_len;
+	h->out[POS_LENGTH] = h->out_len >> 8;
+	h->out[POS_LENGTH+1] = h->out_len;
 
 	/*
 	 * Count the total number of tries we will make, and zero the
@@ -763,7 +942,7 @@ rad_auth_open(void)
 		h->chap_pass = 0;
 		h->authentic_pos = 0;
 		h->type = RADIUS_AUTH;
-		h->request_created = 0;
+		h->out_created = 0;
 		h->eap_msg = 0;
 	}
 	return h;
@@ -781,6 +960,19 @@ rad_acct_open(void)
 }
 
 struct rad_handle *
+rad_server_open(int fd)
+{
+	struct rad_handle *h;
+
+	h = rad_open();
+	if (h != NULL) {
+	        h->type = RADIUS_SERVER;
+	        h->fd = fd;
+	}
+	return h;
+}
+
+struct rad_handle *
 rad_open(void)
 {
     return rad_auth_open();
@@ -797,13 +989,13 @@ rad_put_attr(struct rad_handle *h, int t
 {
 	int result;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
 	}
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		if (type == RAD_EAP_MESSAGE) {
 			generr(h, "EAP-Message attribute is not valid"
 			    " in accounting requests");
@@ -858,14 +1050,14 @@ rad_put_message_authentic(struct rad_han
 #ifdef WITH_SSL
 	u_char md_zero[MD5_DIGEST_LENGTH];
 
-	if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
+	if (h->out[POS_CODE] == RAD_ACCOUNTING_REQUEST) {
 		generr(h, "Message-Authenticator is not valid"
 		    " in accounting requests");
 		return -1;
 	}
 
 	if (h->authentic_pos == 0) {
-		h->authentic_pos = h->req_len;
+		h->authentic_pos = h->out_len;
 		memset(md_zero, 0, sizeof(md_zero));
 		return (put_raw_attr(h, RAD_MESSAGE_AUTHENTIC, md_zero,
 		    sizeof(md_zero)));
@@ -1041,7 +1233,7 @@ rad_put_vendor_attr(struct rad_handle *h
 	struct vendor_attribute *attr;
 	int res;
 
-	if (!h->request_created) {
+	if (!h->out_created) {
 		generr(h, "Please call rad_create_request()"
 		    " before putting attributes");
 		return -1;
@@ -1088,7 +1280,7 @@ rad_request_authenticator(struct rad_han
 {
 	if (len < LEN_AUTH)
 		return (-1);
-	memcpy(buf, h->request + POS_AUTH, LEN_AUTH);
+	memcpy(buf, h->out + POS_AUTH, LEN_AUTH);
 	if (len > LEN_AUTH)
 		buf[LEN_AUTH] = '\0';
 	return (LEN_AUTH);

Modified: head/lib/libradius/radlib.h
==============================================================================
--- head/lib/libradius/radlib.h	Fri Sep 11 02:07:24 2009	(r197085)
+++ head/lib/libradius/radlib.h	Fri Sep 11 11:42:56 2009	(r197086)
@@ -42,6 +42,12 @@
 #define RAD_ACCOUNTING_REQUEST		4
 #define RAD_ACCOUNTING_RESPONSE		5
 #define RAD_ACCESS_CHALLENGE		11
+#define RAD_DISCONNECT_REQUEST		40
+#define RAD_DISCONNECT_ACK		41
+#define RAD_DISCONNECT_NAK		42
+#define RAD_COA_REQUEST			43
+#define RAD_COA_ACK			44
+#define RAD_COA_NAK			45
 
 /* Attribute types and values */
 #define RAD_USER_NAME			1	/* String */
@@ -179,6 +185,8 @@
 #define	RAD_ACCT_MULTI_SESSION_ID	50	/* String */
 #define	RAD_ACCT_LINK_COUNT		51	/* Integer */
 
+#define	RAD_ERROR_CAUSE			101	/* Integer */
+
 struct rad_handle;
 struct timeval;
 
@@ -192,6 +200,7 @@ int			 rad_config(struct rad_handle *, c
 int			 rad_continue_send_request(struct rad_handle *, int,
 			    int *, struct timeval *);
 int			 rad_create_request(struct rad_handle *, int);
+int			 rad_create_response(struct rad_handle *, int);
 struct in_addr		 rad_cvt_addr(const void *);
 u_int32_t		 rad_cvt_int(const void *);
 char			*rad_cvt_string(const void *, size_t);
@@ -209,7 +218,10 @@ int			 rad_put_string(struct rad_handle 
 int			 rad_put_message_authentic(struct rad_handle *);
 ssize_t			 rad_request_authenticator(struct rad_handle *, char *,
 			    size_t);
+int			 rad_receive_request(struct rad_handle *);
 int			 rad_send_request(struct rad_handle *);
+int			 rad_send_response(struct rad_handle *);
+struct rad_handle	*rad_server_open(int fd);
 const char		*rad_server_secret(struct rad_handle *);
 const char		*rad_strerror(struct rad_handle *);
 u_char			*rad_demangle(struct rad_handle *, const void *,

Modified: head/lib/libradius/radlib_private.h
==============================================================================
--- head/lib/libradius/radlib_private.h	Fri Sep 11 02:07:24 2009	(r197085)
+++ head/lib/libradius/radlib_private.h	Fri Sep 11 11:42:56 2009	(r197086)
@@ -38,6 +38,7 @@
 /* Handle types */
 #define RADIUS_AUTH		0   /* RADIUS authentication, default */
 #define RADIUS_ACCT		1   /* RADIUS accounting */
+#define RADIUS_SERVER		2   /* RADIUS server */
 
 /* Defaults */
 #define MAXTRIES		3
@@ -75,18 +76,18 @@ struct rad_handle {
 	int		 num_servers;	/* Number of valid server entries */
 	int		 ident;		/* Current identifier value */
 	char		 errmsg[ERRSIZE];	/* Most recent error message */
-	unsigned char	 request[MSGSIZE];	/* Request to send */
-	char	 	 request_created; /* rad_create_request() called? */
-	int		 req_len;	/* Length of request */
+	unsigned char	 out[MSGSIZE];	/* Request to send */
+	char		 out_created;	/* rad_create_request() called? */
+	int		 out_len;	/* Length of request */
 	char		 pass[PASSSIZE];	/* Cleartext password */
 	int		 pass_len;	/* Length of cleartext password */
 	int		 pass_pos;	/* Position of scrambled password */
-	char	 	 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
+	char		 chap_pass;	/* Have we got a CHAP_PASSWORD ? */
 	int		 authentic_pos;	/* Position of message authenticator */
 	char		 eap_msg;	/* Are we an EAP Proxy? */
-	unsigned char	 response[MSGSIZE];	/* Response received */
-	int		 resp_len;	/* Length of response */
-	int		 resp_pos;	/* Current position scanning attrs */
+	unsigned char	 in[MSGSIZE];	/* Response received */
+	int		 in_len;	/* Length of response */
+	int		 in_pos;	/* Current position scanning attrs */
 	int		 total_tries;	/* How many requests we'll send */
 	int		 try;		/* How many requests we've sent */
 	int		 srv;		/* Server number we did last */
From jhb at freebsd.org  Fri Sep 11 14:56:22 2009
From: jhb at freebsd.org (John Baldwin)
Date: Fri Sep 11 14:56:33 2009
Subject: svn commit: r197085 - in head: share/man/man4 sys/dev/syscons
In-Reply-To: <200909110207.n8B27PjH037758@svn.freebsd.org>
References: <200909110207.n8B27PjH037758@svn.freebsd.org>
Message-ID: <200909111055.14845.jhb@freebsd.org>

On Thursday 10 September 2009 10:07:25 pm Xin LI wrote:
> Author: delphij
> Date: Fri Sep 11 02:07:24 2009
> New Revision: 197085
> URL: http://svn.freebsd.org/changeset/base/197085
> 
> Log:
>   Extend the usage of sc(4)'s hint variable 'flag'.  Bit 0x80 now means
>   "set vesa mode" and higher 16bits of the flag would be the desired mode.
>   
>   One can now set, for instance, hint.sc.0.flags=0x01680180, which means
>   that the system should set VESA mode 0x168 upon boot.
>   
>   Submitted by:	paradox , swell k at gmail.com with
>   		some minor changes.

Ugh, I don't like overloading flags this much.  The historical usage of flags 
was due to userconfig only letting one set a single flags property for a 
given device.  Since moving to hints we now support free-form text 
properties.  I would much prefer this be implemented by 
setting 'hint.sc.0.vesa_mode=XXX' instead.

-- 
John Baldwin
From avg at FreeBSD.org  Fri Sep 11 18:48:50 2009
From: avg at FreeBSD.org (Andriy Gapon)
Date: Fri Sep 11 18:49:01 2009
Subject: svn commit: r197099 - head/sys/dev/pci
Message-ID: <200909111848.n8BImnRM060314@svn.freebsd.org>

Author: avg
Date: Fri Sep 11 18:48:49 2009
New Revision: 197099
URL: http://svn.freebsd.org/changeset/base/197099

Log:
  pci(4): don't perform maximum register number check
  
  Different sub-kinds of PCI buses may have different rules and
  thus it is up for the bus backends to do proper input checks.
  For example, PCIe allows configuration register numbers < 0x1000,
  while for PCI proper the limit is 0x100.
  And, in fact, the buses already do the checks.
  
  Reviewed by:	jhb
  MFC after:	1 week
  X-ToDo:		add check for negative value to bus backends
  X-ToDo:		use named constant for maximum PCIe register

Modified:
  head/sys/dev/pci/pci_user.c

Modified: head/sys/dev/pci/pci_user.c
==============================================================================
--- head/sys/dev/pci/pci_user.c	Fri Sep 11 17:25:24 2009	(r197098)
+++ head/sys/dev/pci/pci_user.c	Fri Sep 11 18:48:49 2009	(r197099)
@@ -605,9 +605,8 @@ getconfexit:
 		case 4:
 		case 2:
 		case 1:
-			/* Make sure register is in bounds and aligned. */
+			/* Make sure register is not negative and aligned. */
 			if (io->pi_reg < 0 ||
-			    io->pi_reg + io->pi_width > PCI_REGMAX + 1 ||
 			    io->pi_reg & (io->pi_width - 1)) {
 				error = EINVAL;
 				break;
From imp at bsdimp.com  Fri Sep 11 18:52:49 2009
From: imp at bsdimp.com (M. Warner Losh)
Date: Fri Sep 11 18:52:56 2009
Subject: svn commit: r197047 - head/share/man/man4
In-Reply-To: <20090910204249.GB55545@lor.one-eyed-alien.net>
References: <200909092028.n89KSw1N096254@svn.freebsd.org>
	<20090910.143327.74744740.imp@bsdimp.com>
	<20090910204249.GB55545@lor.one-eyed-alien.net>
Message-ID: <20090911.125002.-108775446.imp@bsdimp.com>

In message: <20090910204249.GB55545@lor.one-eyed-alien.net>
            Brooks Davis  writes:
: On Thu, Sep 10, 2009 at 02:33:27PM -0600, Warner Losh wrote:
: > From: Brooks Davis 
: > Subject: svn commit: r197047 - head/share/man/man4
: > Date: Wed, 9 Sep 2009 20:28:58 +0000 (UTC)
: > 
: > > Author: brooks
: > > Date: Wed Sep  9 20:28:58 2009
: > > New Revision: 197047
: > > URL: http://svn.freebsd.org/changeset/base/197047
: > > 
: > > Log:
: > >   Mention that a few ed(4) devices don't emit link state change notices
: > >   and a workaround for dhclient.
: > 
: > I thought that I'd made it so that we report the link as active always
: > for those devices that don't support reporting the link status in the
: > hardware.  Is this really necessary still?
: 
: That fixes the case where dhclient never sees a link, but apparently
: doesn't deal with the fact that in 8.0 dhclient never starts without
: a link-up event.  It may be that we need to generate a single link-up
: event at startup to provide an equivalent workaround.

I thought the way that I did it does this...  How is it not doing that?

Warner


: > Warner
: > 
: > >   Reviewed by:	 thierry
: > >   MFC after:	3 days
: > > 
: > > Modified:
: > >   head/share/man/man4/ed.4
: > > 
: > > Modified: head/share/man/man4/ed.4
: > > ==============================================================================
: > > --- head/share/man/man4/ed.4	Wed Sep  9 19:40:54 2009	(r197046)
: > > +++ head/share/man/man4/ed.4	Wed Sep  9 20:28:58 2009	(r197047)
: > > @@ -425,3 +425,21 @@ driver is slow by today's standards.
: > >  .Pp
: > >  PC Card attachment supports the D-Link DMF650TX LAN/Modem card's Ethernet
: > >  port only at this time.
: > > +.Pp
: > > +Some devices supported by
: > > +.Nm
: > > +do no generate the link state change events used by
: > > +.Xr devd 8
: > > +to start
: > > +.Xr dhclinet 8 .
: > > +If you have problems with
: > > +.Xr dhclient 8
: > > +not starting and the device is always attached to the network it may
: > > +be possible to work around this by changing
: > > +.Dq Li DHCP
: > > +to
: > > +.Dq Li SYNCDHCP
: > > +in the
: > > +.Va ifconfig_ed0
: > > +entry in
: > > +.Pa /etc/rc.conf .
: > > 
: > 
From jkim at FreeBSD.org  Fri Sep 11 21:47:45 2009
From: jkim at FreeBSD.org (Jung-uk Kim)
Date: Fri Sep 11 21:49:19 2009
Subject: svn commit: r197102 - head/sys/dev/amdtemp
Message-ID: <200909112147.n8BLlind064388@svn.freebsd.org>

Author: jkim
Date: Fri Sep 11 21:47:44 2009
New Revision: 197102
URL: http://svn.freebsd.org/changeset/base/197102

Log:
  Improve amdtemp(4) significantly:
  
  - Improve newer AMD processor support (Family 0Fh Revision F and later).
  - Adjust offset if DiodeOffet is set and valid.  Note it is experimental
  but it seems to give us more realistic temperatures.  Newer Linux driver
  blindly adds 21C for Family 0Fh desktop processors, however.
  - Always populate dev.cpu and dev.amdtemp sysctl trees regardless of probe
  order for consistency.  Previously, dev.cpu.N.temperature was not populated
  if amdtemp was loaded later than ACPI CPU driver and temperatures were not
  accessible from dev.amdtemp.N.sensor0 tree for Family 10h/11h processors.
  - Read the CPUID from PCI register instead of CPUID instruction to prevent
  possible revision mismatches on multi-socket system.
  - Change macros and variables to make them closer to AMD documents.
  - Fix style(9) nits and improve comments.

Modified:
  head/sys/dev/amdtemp/amdtemp.c

Modified: head/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- head/sys/dev/amdtemp/amdtemp.c	Fri Sep 11 21:09:59 2009	(r197101)
+++ head/sys/dev/amdtemp/amdtemp.c	Fri Sep 11 21:47:44 2009	(r197102)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2008, 2009 Rui Paulo 
  * Copyright (c) 2009 Norikatsu Shigemura 
+ * Copyright (c) 2009 Jung-uk Kim 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,8 +27,8 @@
  */
 
 /*
- * Driver for the AMD K8/K10/K11 thermal sensors. Initially based on the
- * k8temp Linux driver.
+ * Driver for the AMD CPU on-die thermal sensors for Family 0Fh/10h/11h procs.
+ * Initially based on the k8temp Linux driver.
  */
 
 #include 
@@ -35,18 +36,15 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
-#include 
-#include 
 #include 
+#include 
 
-#include 
 #include 
 
 typedef enum {
@@ -60,18 +58,19 @@ typedef enum {
 
 struct amdtemp_softc {
 	device_t	sc_dev;
-	int		sc_temps[4];
+	uint32_t	sc_mask;
+	int		sc_ncores;
 	int		sc_ntemps;
-	struct sysctl_oid *sc_oid;
-	struct sysctl_oid *sc_sysctl_cpu[2];
+	int		sc_swap;
+	int32_t		(*sc_gettemp)(device_t, amdsensor_t);
+	struct sysctl_oid *sc_sysctl_cpu[MAXCPU];
 	struct intr_config_hook sc_ich;
-	int32_t (*sc_gettemp)(device_t, amdsensor_t);
 };
 
-#define VENDORID_AMD		0x1022
-#define DEVICEID_AMD_MISC0F	0x1103
-#define DEVICEID_AMD_MISC10	0x1203
-#define DEVICEID_AMD_MISC11	0x1303
+#define	VENDORID_AMD		0x1022
+#define	DEVICEID_AMD_MISC0F	0x1103
+#define	DEVICEID_AMD_MISC10	0x1203
+#define	DEVICEID_AMD_MISC11	0x1303
 
 static struct amdtemp_product {
 	uint16_t	amdtemp_vendorid;
@@ -84,22 +83,21 @@ static struct amdtemp_product {
 };
 
 /*
- * Register control (K8 family)
+ * Reported Temperature Control Register (Family 10h/11h only)
  */
-#define	AMDTEMP_REG0F		0xe4
-#define	AMDTEMP_REG_SELSENSOR	0x40
-#define	AMDTEMP_REG_SELCORE	0x04
+#define	AMDTEMP_REPTMP_CTRL	0xa4
 
 /*
- * Register control (K10 & K11) family
+ * Thermaltrip Status Register
  */
-#define	AMDTEMP_REG		0xa4
-
-#define	TZ_ZEROC		2732
+#define	AMDTEMP_THERMTP_STAT	0xe4
+#define	AMDTEMP_TTSR_SELCORE	0x04	/* Family 0Fh only */
+#define	AMDTEMP_TTSR_SELSENSOR	0x40	/* Family 0Fh only */
 
-					/* -49 C is the mininum temperature */
-#define	AMDTEMP_OFFSET0F	(TZ_ZEROC-490)
-#define	AMDTEMP_OFFSET		(TZ_ZEROC)
+/*
+ * CPU Family/Model Register
+ */
+#define	AMDTEMP_CPUID		0xfc
 
 /*
  * Device methods.
@@ -138,8 +136,8 @@ amdtemp_match(device_t dev)
 {
 	int i;
 	uint16_t vendor, devid;
-	
-        vendor = pci_get_vendor(dev);
+
+	vendor = pci_get_vendor(dev);
 	devid = pci_get_device(dev);
 
 	for (i = 0; amdtemp_products[i].amdtemp_vendorid != 0; i++) {
@@ -159,32 +157,47 @@ amdtemp_identify(driver_t *driver, devic
 	/* Make sure we're not being doubly invoked. */
 	if (device_find_child(parent, "amdtemp", -1) != NULL)
 		return;
-	
+
 	if (amdtemp_match(parent)) {
 		child = device_add_child(parent, "amdtemp", -1);
 		if (child == NULL)
 			device_printf(parent, "add amdtemp child failed\n");
 	}
-    
 }
 
 static int
 amdtemp_probe(device_t dev)
 {
-	uint32_t regs[4];
-	
+	uint32_t cpuid, family, model, temp;
+
 	if (resource_disabled("amdtemp", 0))
 		return (ENXIO);
 
-	do_cpuid(1, regs);
-	switch (regs[0]) {
-	case 0xf40:
-	case 0xf50:
-	case 0xf51:
+	cpuid = pci_read_config(dev, AMDTEMP_CPUID, 4);
+	family = CPUID_TO_FAMILY(cpuid);
+	model = CPUID_TO_MODEL(cpuid);
+
+	switch (family) {
+	case 0x0f:
+		if ((model == 0x04 && (cpuid & CPUID_STEPPING) == 0) ||
+		    (model == 0x05 && (cpuid & CPUID_STEPPING) <= 1))
+			return (ENXIO);
+		break;
+	case 0x10:
+	case 0x11:
+		/*
+		 * DiodeOffset must be non-zero if thermal diode is supported.
+		 */
+		temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
+		temp = (temp >> 8) & 0x7f;
+		if (temp == 0)
+			return (ENXIO);
+		break;
+	default:
 		return (ENXIO);
 	}
-	device_set_desc(dev, "AMD K8 Thermal Sensors");
-	
+	device_set_desc(dev, "AMD CPU On-Die Thermal Sensors");
+
 	return (BUS_PROBE_GENERIC);
 }
 
@@ -194,63 +207,119 @@ amdtemp_attach(device_t dev)
 	struct amdtemp_softc *sc = device_get_softc(dev);
 	struct sysctl_ctx_list *sysctlctx;
 	struct sysctl_oid *sysctlnode;
+	uint32_t cpuid, family, model;
 
+	cpuid = pci_read_config(dev, AMDTEMP_CPUID, 4);
+	family = CPUID_TO_FAMILY(cpuid);
+	model = CPUID_TO_MODEL(cpuid);
+
+	switch (family) {
+	case 0x0f:
+		/*
+		 * Thermaltrip Status Register - CurTmp
+		 *
+		 * Revision G:		bits 23-14
+		 * Earlier:		bits 23-16
+		 */
+		if (model >= 0x60 && model != 0xc1)
+			sc->sc_mask = 0x3ff << 14;
+		else
+			sc->sc_mask = 0xff << 16;
+
+		/*
+		 * Thermaltrip Status Register - ThermSenseCoreSel
+		 *
+		 * Revision F:		0 - Core1, 1 - Core0
+		 * Earlier:		0 - Core0, 1 - Core1
+		 */
+		sc->sc_swap = (model >= 0x40);
+
+		/*
+		 * There are two sensors per core.
+		 */
+		sc->sc_ntemps = 2;
 
-	/*
-	 * Setup intrhook function to create dev.cpu sysctl entries. This is
-	 * needed because the cpu driver may be loaded late on boot, after
-	 * us.
-	 */
-	sc->sc_ich.ich_func = amdtemp_intrhook;
-	sc->sc_ich.ich_arg = dev;
-	if (config_intrhook_establish(&sc->sc_ich) != 0) {
-		device_printf(dev, "config_intrhook_establish "
-		    "failed!\n");
-		return (ENXIO);
-	}
-	
-	if (pci_get_device(dev) == DEVICEID_AMD_MISC0F)
 		sc->sc_gettemp = amdtemp_gettemp0f;
-	else {
+		break;
+	case 0x10:
+	case 0x11:
+		/*
+		 * Reported Temperature Control Register - Curtmp
+		 */
+		sc->sc_mask = 0x3ff << 21;
+
+		/*
+		 * There is only one sensor per package.
+		 */
+		sc->sc_ntemps = 1;
+
 		sc->sc_gettemp = amdtemp_gettemp;
-		return (0);
+		break;
 	}
 
+	/* Find number of cores per package. */
+	sc->sc_ncores = (amd_feature2 & AMDID2_CMP) != 0 ?
+	    (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1;
+	if (sc->sc_ncores > MAXCPU)
+		return (ENXIO);
+
+	if (bootverbose)
+		device_printf(dev, "Found %d cores and %d sensors.\n",
+		    sc->sc_ncores,
+		    sc->sc_ntemps > 1 ? sc->sc_ntemps * sc->sc_ncores : 1);
+
 	/*
 	 * dev.amdtemp.N tree.
 	 */
 	sysctlctx = device_get_sysctl_ctx(dev);
 	sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor0",
-	    CTLFLAG_RD, 0, "Sensor 0");
-	
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
+	    "sensor0", CTLFLAG_RD, 0, "Sensor 0");
+
 	SYSCTL_ADD_PROC(sysctlctx,
 	    SYSCTL_CHILDREN(sysctlnode),
 	    OID_AUTO, "core0", CTLTYPE_INT | CTLFLAG_RD,
 	    dev, SENSOR0_CORE0, amdtemp_sysctl, "IK",
 	    "Sensor 0 / Core 0 temperature");
-	
-	SYSCTL_ADD_PROC(sysctlctx,
-	    SYSCTL_CHILDREN(sysctlnode),
-	    OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
-	    dev, SENSOR0_CORE1, amdtemp_sysctl, "IK",
-	    "Sensor 0 / Core 1 temperature");
-	
-	sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor1",
-	    CTLFLAG_RD, 0, "Sensor 1");
-	
-	SYSCTL_ADD_PROC(sysctlctx,
-	    SYSCTL_CHILDREN(sysctlnode),
-	    OID_AUTO, "core0", CTLTYPE_INT | CTLFLAG_RD,
-	    dev, SENSOR1_CORE0, amdtemp_sysctl, "IK",
-	    "Sensor 1 / Core 0 temperature");
-	
-	SYSCTL_ADD_PROC(sysctlctx,
-	    SYSCTL_CHILDREN(sysctlnode),
-	    OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
-	    dev, SENSOR1_CORE1, amdtemp_sysctl, "IK",
-	    "Sensor 1 / Core 1 temperature");
+
+	if (sc->sc_ntemps > 1) {
+		if (sc->sc_ncores > 1)
+			SYSCTL_ADD_PROC(sysctlctx,
+			    SYSCTL_CHILDREN(sysctlnode),
+			    OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
+			    dev, SENSOR0_CORE1, amdtemp_sysctl, "IK",
+			    "Sensor 0 / Core 1 temperature");
+
+		sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
+		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
+		    "sensor1", CTLFLAG_RD, 0, "Sensor 1");
+
+		SYSCTL_ADD_PROC(sysctlctx,
+		    SYSCTL_CHILDREN(sysctlnode),
+		    OID_AUTO, "core0", CTLTYPE_INT | CTLFLAG_RD,
+		    dev, SENSOR1_CORE0, amdtemp_sysctl, "IK",
+		    "Sensor 1 / Core 0 temperature");
+
+		if (sc->sc_ncores > 1)
+			SYSCTL_ADD_PROC(sysctlctx,
+			    SYSCTL_CHILDREN(sysctlnode),
+			    OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
+			    dev, SENSOR1_CORE1, amdtemp_sysctl, "IK",
+			    "Sensor 1 / Core 1 temperature");
+	}
+
+	/*
+	 * Try to create dev.cpu sysctl entries and setup intrhook function.
+	 * This is needed because the cpu driver may be loaded late on boot,
+	 * after us.
+	 */
+	amdtemp_intrhook(dev);
+	sc->sc_ich.ich_func = amdtemp_intrhook;
+	sc->sc_ich.ich_arg = dev;
+	if (config_intrhook_establish(&sc->sc_ich) != 0) {
+		device_printf(dev, "config_intrhook_establish failed!\n");
+		return (ENXIO);
+	}
 
 	return (0);
 }
@@ -258,61 +327,67 @@ amdtemp_attach(device_t dev)
 void
 amdtemp_intrhook(void *arg)
 {
-	int i;
-	device_t nexus, acpi, cpu;
-	device_t dev = (device_t) arg;
 	struct amdtemp_softc *sc;
 	struct sysctl_ctx_list *sysctlctx;
+	device_t dev = (device_t)arg;
+	device_t acpi, cpu, nexus;
+	amdsensor_t sensor;
+	int i;
 
 	sc = device_get_softc(dev);
-	
+
 	/*
 	 * dev.cpu.N.temperature.
 	 */
 	nexus = device_find_child(root_bus, "nexus", 0);
 	acpi = device_find_child(nexus, "acpi", 0);
 
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < sc->sc_ncores; i++) {
+		if (sc->sc_sysctl_cpu[i] != NULL)
+			continue;
 		cpu = device_find_child(acpi, "cpu",
-		    device_get_unit(dev) * 2 + i);
-		if (cpu) {
+		    device_get_unit(dev) * sc->sc_ncores + i);
+		if (cpu != NULL) {
 			sysctlctx = device_get_sysctl_ctx(cpu);
 
+			sensor = sc->sc_ntemps > 1 ?
+			    (i == 0 ? CORE0 : CORE1) : SENSOR0_CORE0;
 			sc->sc_sysctl_cpu[i] = SYSCTL_ADD_PROC(sysctlctx,
 			    SYSCTL_CHILDREN(device_get_sysctl_tree(cpu)),
 			    OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD,
-			    dev, CORE0, amdtemp_sysctl, "IK",
-			    "Max of sensor 0 / 1");
+			    dev, sensor, amdtemp_sysctl, "IK",
+			    "Current temparature");
 		}
 	}
-	config_intrhook_disestablish(&sc->sc_ich);
+	if (sc->sc_ich.ich_arg != NULL)
+		config_intrhook_disestablish(&sc->sc_ich);
 }
 
 int
 amdtemp_detach(device_t dev)
 {
-	int i;
 	struct amdtemp_softc *sc = device_get_softc(dev);
-	
-	for (i = 0; i < 2; i++) {
-		if (sc->sc_sysctl_cpu[i])
+	int i;
+
+	for (i = 0; i < sc->sc_ncores; i++)
+		if (sc->sc_sysctl_cpu[i] != NULL)
 			sysctl_remove_oid(sc->sc_sysctl_cpu[i], 1, 0);
-	}
 
 	/* NewBus removes the dev.amdtemp.N tree by itself. */
-	
+
 	return (0);
 }
 
 static int
 amdtemp_sysctl(SYSCTL_HANDLER_ARGS)
 {
-	device_t dev = (device_t) arg1;
+	device_t dev = (device_t)arg1;
 	struct amdtemp_softc *sc = device_get_softc(dev);
+	amdsensor_t sensor = (amdsensor_t)arg2;
+	int32_t auxtemp[2], temp;
 	int error;
-	int32_t temp, auxtemp[2];
 
-	switch (arg2) {
+	switch (sensor) {
 	case CORE0:
 		auxtemp[0] = sc->sc_gettemp(dev, SENSOR0_CORE0);
 		auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE0);
@@ -324,54 +399,80 @@ amdtemp_sysctl(SYSCTL_HANDLER_ARGS)
 		temp = imax(auxtemp[0], auxtemp[1]);
 		break;
 	default:
-		temp = sc->sc_gettemp(dev, arg2);
+		temp = sc->sc_gettemp(dev, sensor);
 		break;
 	}
 	error = sysctl_handle_int(oidp, &temp, 0, req);
-	
+
 	return (error);
 }
 
+#define	AMDTEMP_ZERO_C_TO_K	2732
+
 static int32_t
 amdtemp_gettemp0f(device_t dev, amdsensor_t sensor)
 {
-	uint8_t cfg;
+	struct amdtemp_softc *sc = device_get_softc(dev);
 	uint32_t temp;
-	
-	cfg = pci_read_config(dev, AMDTEMP_REG0F, 1);
+	int32_t diode_offset, offset;
+	uint8_t cfg, sel;
+
+	/* Set Sensor/Core selector. */
+	sel = 0;
 	switch (sensor) {
-	case SENSOR0_CORE0:
-		cfg &= ~(AMDTEMP_REG_SELSENSOR | AMDTEMP_REG_SELCORE);
-		break;
-	case SENSOR0_CORE1:
-		cfg &= ~AMDTEMP_REG_SELSENSOR;
-		cfg |= AMDTEMP_REG_SELCORE;
-		break;
 	case SENSOR1_CORE0:
-		cfg &= ~AMDTEMP_REG_SELCORE;
-		cfg |= AMDTEMP_REG_SELSENSOR;
+		sel |= AMDTEMP_TTSR_SELSENSOR;
+		/* FALLTROUGH */
+	case SENSOR0_CORE0:
+	case CORE0:
+		if (sc->sc_swap)
+			sel |= AMDTEMP_TTSR_SELCORE;
 		break;
 	case SENSOR1_CORE1:
-		cfg |= (AMDTEMP_REG_SELSENSOR | AMDTEMP_REG_SELCORE);
-		break;
-	default:
-		cfg = 0;
+		sel |= AMDTEMP_TTSR_SELSENSOR;
+		/* FALLTROUGH */
+	case SENSOR0_CORE1:
+	case CORE1:
+		if (!sc->sc_swap)
+			sel |= AMDTEMP_TTSR_SELCORE;
 		break;
 	}
-	pci_write_config(dev, AMDTEMP_REG0F, cfg, 1);
-	temp = pci_read_config(dev, AMDTEMP_REG0F, 4);
-	temp = ((temp >> 16) & 0xff) * 10 + AMDTEMP_OFFSET0F;
-	
+	cfg = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 1);
+	cfg &= ~(AMDTEMP_TTSR_SELSENSOR | AMDTEMP_TTSR_SELCORE);
+	pci_write_config(dev, AMDTEMP_THERMTP_STAT, cfg | sel, 1);
+
+	/* CurTmp starts from -49C. */
+	offset = AMDTEMP_ZERO_C_TO_K - 490;
+
+	/* Adjust offset if DiodeOffset is set and valid. */
+	temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
+	diode_offset = (temp >> 8) & 0x3f;
+	if (diode_offset != 0)
+		offset += (diode_offset - 11) * 10;
+
+	temp = ((temp & sc->sc_mask) >> 14) * 5 / 2 + offset;
+
 	return (temp);
 }
 
 static int32_t
 amdtemp_gettemp(device_t dev, amdsensor_t sensor)
 {
+	struct amdtemp_softc *sc = device_get_softc(dev);
 	uint32_t temp;
+	int32_t diode_offset, offset;
+
+	/* CurTmp starts from 0C. */
+	offset = AMDTEMP_ZERO_C_TO_K;
+
+	/* Adjust offset if DiodeOffset is set and valid. */
+	temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
+	diode_offset = (temp >> 8) & 0x7f;
+	if (diode_offset > 0 && diode_offset < 0x40)
+		offset += (diode_offset - 11) * 10;
 
-	temp = pci_read_config(dev, AMDTEMP_REG, 4);
-	temp = ((temp >> 21) & 0x3ff) * 10 / 8 + AMDTEMP_OFFSET;
+	temp = pci_read_config(dev, AMDTEMP_REPTMP_CTRL, 4);
+	temp = ((temp & sc->sc_mask) >> 21) * 5 / 4 + offset;
 
 	return (temp);
 }
From jkim at FreeBSD.org  Fri Sep 11 22:06:01 2009
From: jkim at FreeBSD.org (Jung-uk Kim)
Date: Fri Sep 11 22:06:07 2009
Subject: svn commit: r197103 - head/sys/dev/amdtemp
Message-ID: <200909112205.n8BM5xD1064820@svn.freebsd.org>

Author: jkim
Date: Fri Sep 11 22:05:59 2009
New Revision: 197103
URL: http://svn.freebsd.org/changeset/base/197103

Log:
  Fix typos in comments from the previous commit.

Modified:
  head/sys/dev/amdtemp/amdtemp.c

Modified: head/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- head/sys/dev/amdtemp/amdtemp.c	Fri Sep 11 21:47:44 2009	(r197102)
+++ head/sys/dev/amdtemp/amdtemp.c	Fri Sep 11 22:05:59 2009	(r197103)
@@ -422,7 +422,7 @@ amdtemp_gettemp0f(device_t dev, amdsenso
 	switch (sensor) {
 	case SENSOR1_CORE0:
 		sel |= AMDTEMP_TTSR_SELSENSOR;
-		/* FALLTROUGH */
+		/* FALLTHROUGH */
 	case SENSOR0_CORE0:
 	case CORE0:
 		if (sc->sc_swap)
@@ -430,7 +430,7 @@ amdtemp_gettemp0f(device_t dev, amdsenso
 		break;
 	case SENSOR1_CORE1:
 		sel |= AMDTEMP_TTSR_SELSENSOR;
-		/* FALLTROUGH */
+		/* FALLTHROUGH */
 	case SENSOR0_CORE1:
 	case CORE1:
 		if (!sc->sc_swap)
From jkim at FreeBSD.org  Fri Sep 11 22:48:54 2009
From: jkim at FreeBSD.org (Jung-uk Kim)
Date: Fri Sep 11 22:49:06 2009
Subject: svn commit: r197104 - in head/sys/contrib/dev/acpica: . common
	compiler debugger dispatcher events executer hardware include
	namespace parser tables tools/acpiexec utilities
Message-ID: <200909112248.n8BMmsXX065768@svn.freebsd.org>

Author: jkim
Date: Fri Sep 11 22:48:53 2009
New Revision: 197104
URL: http://svn.freebsd.org/changeset/base/197104

Log:
  MFV:	r196804
  
  Import ACPICA 20090903

Added:
  head/sys/contrib/dev/acpica/include/actbl2.h   (contents, props changed)
  head/sys/contrib/dev/acpica/namespace/nsrepair.c
     - copied unchanged from r197103, vendor-sys/acpica/dist/namespace/nsrepair.c
  head/sys/contrib/dev/acpica/utilities/utids.c
     - copied unchanged from r197103, vendor-sys/acpica/dist/utilities/utids.c
Modified:
  head/sys/contrib/dev/acpica/   (props changed)
  head/sys/contrib/dev/acpica/acpica_prep.sh
  head/sys/contrib/dev/acpica/changes.txt
  head/sys/contrib/dev/acpica/common/dmrestag.c
  head/sys/contrib/dev/acpica/common/dmtable.c
  head/sys/contrib/dev/acpica/common/dmtbdump.c
  head/sys/contrib/dev/acpica/common/dmtbinfo.c
  head/sys/contrib/dev/acpica/compiler/aslcompiler.h
  head/sys/contrib/dev/acpica/compiler/aslcompiler.l
  head/sys/contrib/dev/acpica/compiler/aslcompiler.y
  head/sys/contrib/dev/acpica/compiler/asldefine.h
  head/sys/contrib/dev/acpica/compiler/aslfiles.c
  head/sys/contrib/dev/acpica/compiler/aslglobal.h
  head/sys/contrib/dev/acpica/compiler/aslload.c
  head/sys/contrib/dev/acpica/compiler/asllookup.c
  head/sys/contrib/dev/acpica/compiler/aslmain.c
  head/sys/contrib/dev/acpica/compiler/aslmap.c
  head/sys/contrib/dev/acpica/compiler/aslstubs.c
  head/sys/contrib/dev/acpica/compiler/asltypes.h
  head/sys/contrib/dev/acpica/debugger/dbcmds.c
  head/sys/contrib/dev/acpica/debugger/dbdisply.c
  head/sys/contrib/dev/acpica/debugger/dbexec.c
  head/sys/contrib/dev/acpica/dispatcher/dsfield.c
  head/sys/contrib/dev/acpica/dispatcher/dsmethod.c
  head/sys/contrib/dev/acpica/dispatcher/dsmthdat.c
  head/sys/contrib/dev/acpica/dispatcher/dsobject.c
  head/sys/contrib/dev/acpica/dispatcher/dswload.c
  head/sys/contrib/dev/acpica/events/evgpe.c
  head/sys/contrib/dev/acpica/events/evgpeblk.c
  head/sys/contrib/dev/acpica/events/evrgnini.c
  head/sys/contrib/dev/acpica/executer/exconfig.c
  head/sys/contrib/dev/acpica/executer/exfield.c
  head/sys/contrib/dev/acpica/executer/exfldio.c
  head/sys/contrib/dev/acpica/executer/exstorob.c
  head/sys/contrib/dev/acpica/executer/exutils.c
  head/sys/contrib/dev/acpica/hardware/hwgpe.c
  head/sys/contrib/dev/acpica/hardware/hwregs.c
  head/sys/contrib/dev/acpica/hardware/hwsleep.c
  head/sys/contrib/dev/acpica/hardware/hwtimer.c
  head/sys/contrib/dev/acpica/hardware/hwxface.c
  head/sys/contrib/dev/acpica/include/acconfig.h
  head/sys/contrib/dev/acpica/include/acdebug.h
  head/sys/contrib/dev/acpica/include/acdisasm.h
  head/sys/contrib/dev/acpica/include/acglobal.h
  head/sys/contrib/dev/acpica/include/achware.h
  head/sys/contrib/dev/acpica/include/acinterp.h
  head/sys/contrib/dev/acpica/include/aclocal.h
  head/sys/contrib/dev/acpica/include/acmacros.h
  head/sys/contrib/dev/acpica/include/acnamesp.h
  head/sys/contrib/dev/acpica/include/acobject.h
  head/sys/contrib/dev/acpica/include/acparser.h
  head/sys/contrib/dev/acpica/include/acpixf.h
  head/sys/contrib/dev/acpica/include/acpredef.h
  head/sys/contrib/dev/acpica/include/actbl.h
  head/sys/contrib/dev/acpica/include/actbl1.h
  head/sys/contrib/dev/acpica/include/actypes.h
  head/sys/contrib/dev/acpica/include/acutils.h
  head/sys/contrib/dev/acpica/include/amlcode.h
  head/sys/contrib/dev/acpica/namespace/nsalloc.c
  head/sys/contrib/dev/acpica/namespace/nseval.c
  head/sys/contrib/dev/acpica/namespace/nsinit.c
  head/sys/contrib/dev/acpica/namespace/nsload.c
  head/sys/contrib/dev/acpica/namespace/nspredef.c
  head/sys/contrib/dev/acpica/namespace/nsxfeval.c
  head/sys/contrib/dev/acpica/namespace/nsxfname.c
  head/sys/contrib/dev/acpica/parser/psloop.c
  head/sys/contrib/dev/acpica/parser/psxface.c
  head/sys/contrib/dev/acpica/tables/tbutils.c
  head/sys/contrib/dev/acpica/tools/acpiexec/aecommon.h
  head/sys/contrib/dev/acpica/utilities/uteval.c
  head/sys/contrib/dev/acpica/utilities/utglobal.c
  head/sys/contrib/dev/acpica/utilities/utinit.c
  head/sys/contrib/dev/acpica/utilities/utmisc.c
  head/sys/contrib/dev/acpica/utilities/utxface.c

Modified: head/sys/contrib/dev/acpica/acpica_prep.sh
==============================================================================
--- head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Sep 11 22:05:59 2009	(r197103)
+++ head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Sep 11 22:48:53 2009	(r197104)
@@ -21,7 +21,7 @@ fulldirs="common compiler debugger disas
 # files to remove
 stripdirs="acpisrc acpixtract examples generate os_specific"
 stripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h	\
-	acos2.h accygwin.h acefi.h actbl2.h acwin.h acwin64.h aeexec.c	\
+	acos2.h accygwin.h acefi.h acwin.h acwin64.h aeexec.c		\
 	aehandlers.c aemain.c aetables.c osunixdir.c readme.txt		\
 	utclib.c"
 
@@ -31,8 +31,8 @@ src_headers="acapps.h accommon.h acconfi
 	aclocal.h acmacros.h acnames.h acnamesp.h acobject.h acopcode.h	\
 	acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h	\
 	acresrc.h acrestyp.h acstruct.h actables.h actbl.h actbl1.h	\
-	actypes.h acutils.h amlcode.h amlresrc.h platform/acenv.h	\
-	platform/acfreebsd.h platform/acgcc.h"
+	actbl2.h actypes.h acutils.h amlcode.h amlresrc.h		\
+	platform/acenv.h platform/acfreebsd.h platform/acgcc.h"
 comp_headers="aslcompiler.h asldefine.h aslglobal.h asltypes.h"
 platform_headers="acfreebsd.h acgcc.h"
 

Modified: head/sys/contrib/dev/acpica/changes.txt
==============================================================================
--- head/sys/contrib/dev/acpica/changes.txt	Fri Sep 11 22:05:59 2009	(r197103)
+++ head/sys/contrib/dev/acpica/changes.txt	Fri Sep 11 22:48:53 2009	(r197104)
@@ -1,4 +1,227 @@
 ----------------------------------------
+03 September 2009. Summary of changes for version 20090903:
+
+This release is available at www.acpica.org/downloads
+
+1) ACPI CA Core Subsystem:
+
+For Windows Vista compatibility, added the automatic execution of an _INI 
+method located at the namespace root (\_INI). This method is executed at 
+table load time. This support is in addition to the automatic execution of 
+\_SB._INI. Lin Ming.
+
+Fixed a possible memory leak in the interpreter for AML package objects if 
+the package initializer list is longer than the defined size of the package. 
+This apparently can only happen if the BIOS changes the package size on the 
+fly (seen in a _PSS object), as ASL compilers do not allow this. The 
+interpreter will truncate the package to the defined size (and issue an error 
+message), but previously could leave the extra objects undeleted if they were 
+pre-created during the argument processing (such is the case if the package 
+consists of a number of sub-packages as in the _PSS.) ACPICA BZ 805.
+
+Fixed a problem seen when a Buffer or String is stored to itself via ASL. 
+This has been reported in the field. Previously, ACPICA would zero out the 
+buffer/string. Now, the operation is treated as a noop. Provides Windows 
+compatibility. ACPICA BZ 803. Lin Ming.
+
+Removed an extraneous error message for ASL constructs of the form 
+Store(LocalX,LocalX) when LocalX is uninitialized. These curious statements 
+are seen in many BIOSs and are once again treated as NOOPs and no error is 
+emitted when they are encountered. ACPICA BZ 785.
+
+Fixed an extraneous warning message if a _DSM reserved method returns a 
+Package object. _DSM can return any type of object, so validation on the 
+return type cannot be performed. ACPICA BZ 802.
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
+debug version of the code includes the debug output trace mechanism and has a 
+much larger code and data size.
+
+  Previous Release:
+    Non-Debug Version:  85.5K Code, 18.0K Data, 103.5K Total
+    Debug Version:     161.6K Code, 50.9K Data, 212.5K Total
+  Current Release:
+    Non-Debug Version:  85.6K Code, 18.0K Data, 103.6K Total
+    Debug Version:     161.7K Code, 50.9K Data, 212.6K Total
+
+2) iASL Compiler/Disassembler and Tools:
+
+iASL: Fixed a problem with the use of the Alias operator and Resource 
+Templates. The correct alias is now constructed and no error is emitted. 
+ACPICA BZ 738.
+
+iASL: Implemented the -I option to specify additional search directories for 
+include files. Allows multiple additional search paths for include files. 
+Directories are searched in the order specified on the command line (after 
+the local directory is searched.) ACPICA BZ 800.
+
+iASL: Fixed a problem where the full pathname for include files was not 
+emitted for warnings/errors. This caused the IDE support to not work 
+properly. ACPICA BZ 765.
+
+iASL: Implemented the -@ option to specify a Windows-style response file 
+containing additional command line options. ACPICA BZ 801.
+
+AcpiExec: Added support to load multiple AML files simultaneously (such as a 
+DSDT and multiple SSDTs). Also added support for wildcards within the AML 
+pathname. These features allow all machine tables to be easily loaded and 
+debugged together. ACPICA BZ 804.
+
+Disassembler: Added missing support for disassembly of HEST table Error Bank 
+subtables. 
+
+----------------------------------------
+30 July 2009. Summary of changes for version 20090730:
+
+This release is available at www.acpica.org/downloads
+
+The ACPI 4.0 implementation for ACPICA is complete with this release.
+
+1) ACPI CA Core Subsystem:
+
+ACPI 4.0: Added header file support for all new and changed ACPI tables. 
+Completely new tables are: IBFT, IVRS, MSCT, and WAET. Tables that are new 
+for ACPI 4.0, but have previously been supported in ACPICA are: CPEP, BERT, 
+EINJ, ERST, and HEST. Other newly supported tables are: UEFI and WDAT. There 
+have been some ACPI 4.0 changes to other existing tables. Split the large 
+actbl1.h header into the existing actbl2.h header. ACPICA BZ 774.
+
+ACPI 4.0: Implemented predefined name validation for all new names. There are 
+31 new names in ACPI 4.0. The predefined validation module was split into two 
+files. The new file is namespace/nsrepair.c. ACPICA BZ 770.
+
+Implemented support for so-called "module-level executable code". This is 
+executable AML code that exists outside of any control method and is intended 
+to be executed at table load time. Although illegal since ACPI 2.0, this type 
+of code still exists and is apparently still being created. Blocks of this 
+code are now detected and executed as intended. Currently, the code blocks 
+must exist under either an If, Else, or While construct; these are the 
+typical cases seen in the field. ACPICA BZ 762. Lin Ming.
+
+Implemented an automatic dynamic repair for predefined names that return 
+nested Package objects. This applies to predefined names that are defined to 
+return a variable-length Package of sub-packages. If the number of sub-
+packages is one, BIOS code is occasionally seen that creates a simple single 
+package with no sub-packages. This code attempts to fix the problem by 
+wrapping a new package object around the existing package. These methods can 
+be repaired: _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, and _TSS. ACPICA BZ 
+790.
+
+Fixed a regression introduced in 20090625 for the AcpiGetDevices interface. 
+The _HID/_CID matching was broken and no longer matched IDs correctly. ACPICA 
+BZ 793.
+
+Fixed a problem with AcpiReset where the reset would silently fail if the 
+register was one of the protected I/O ports. AcpiReset now bypasses the port 
+validation mechanism. This may eventually be driven into the AcpiRead/Write 
+interfaces.
+
+Fixed a regression related to the recent update of the AcpiRead/Write 
+interfaces. A sleep/suspend could fail if the optional PM2 Control register 
+does not exist during an attempt to write the Bus Master Arbitration bit. 
+(However, some hosts already delete the code that writes this bit, and the 
+code may in fact be obsolete at this date.) ACPICA BZ 799.
+
+Fixed a problem where AcpiTerminate could fault if inadvertently called twice 
+in succession. ACPICA BZ 795.
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
+debug version of the code includes the debug output trace mechanism and has a 
+much larger code and data size.
+
+  Previous Release:
+    Non-Debug Version:  84.7K Code, 17.8K Data, 102.5K Total
+    Debug Version:     160.5K Code, 50.6K Data, 211.1K Total
+  Current Release:
+    Non-Debug Version:  85.5K Code, 18.0K Data, 103.5K Total
+    Debug Version:     161.6K Code, 50.9K Data, 212.5K Total
+
+2) iASL Compiler/Disassembler and Tools:
+
+ACPI 4.0: Implemented disassembler support for all new ACPI tables and 
+changes to existing tables. ACPICA BZ 775.
+
+----------------------------------------
+25 June 2009. Summary of changes for version 20090625:
+
+This release is available at www.acpica.org/downloads
+
+The ACPI 4.0 Specification was released on June 16 and is available at 
+www.acpi.info. ACPICA implementation of ACPI 4.0 is underway and will 
+continue for the next few releases.
+
+1) ACPI CA Core Subsystem:
+
+ACPI 4.0: Implemented interpreter support for the IPMI operation region 
+address space. Includes support for bi-directional data buffers and an IPMI 
+address space handler (to be installed by an IPMI device driver.) ACPICA BZ 
+773. Lin Ming.
+
+ACPI 4.0: Added changes for existing ACPI tables - FACS and SRAT. Includes 
+support in both the header files and the disassembler.
+
+Completed a major update for the AcpiGetObjectInfo external interface. 
+Changes include:
+ - Support for variable, unlimited length HID, UID, and CID strings.
+ - Support Processor objects the same as Devices (HID,UID,CID,ADR,STA, etc.)
+ - Call the _SxW power methods on behalf of a device object.
+ - Determine if a device is a PCI root bridge.
+ - Change the ACPI_BUFFER parameter to ACPI_DEVICE_INFO.
+These changes will require an update to all callers of this interface. See 
+the updated ACPICA Programmer Reference for details. One new source file has 
+been added - utilities/utids.c. ACPICA BZ 368, 780.
+
+Updated the AcpiRead and AcpiWrite external interfaces to support 64-bit 
+transfers. The Value parameter has been extended from 32 bits to 64 bits in 
+order to support new ACPI 4.0 tables. These changes will require an update to 
+all callers of these interfaces. See the ACPICA Programmer Reference for 
+details. ACPICA BZ 768.
+
+Fixed several problems with AcpiAttachData. The handler was not invoked when 
+the host node was deleted. The data sub-object was not automatically deleted 
+when the host node was deleted. The interface to the handler had an unused 
+parameter, this was removed. ACPICA BZ 778.
+
+Enhanced the function that dumps ACPI table headers. All non-printable 
+characters in the string fields are now replaced with '?' (Signature, OemId, 
+OemTableId, and CompilerId.) ACPI tables with non-printable characters in 
+these fields are occasionally seen in the field. ACPICA BZ 788.
+
+Fixed a problem with predefined method repair code where the code that 
+attempts to repair/convert an object of incorrect type is only executed on 
+the first time the predefined method is called. The mechanism that disables 
+warnings on subsequent calls was interfering with the repair mechanism. 
+ACPICA BZ 781.
+
+Fixed a possible memory leak in the predefined validation/repair code when a 
+buffer is automatically converted to an expected string object.
+
+Removed obsolete 16-bit files from the distribution and from the current git 
+tree head. ACPICA BZ 776.
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
+debug version of the code includes the debug output trace mechanism and has a 
+much larger code and data size.
+
+  Previous Release:
+    Non-Debug Version:  83.4K Code, 17.5K Data, 100.9K Total
+    Debug Version:     158.9K Code, 50.0K Data, 208.9K Total
+  Current Release:
+    Non-Debug Version:  84.7K Code, 17.8K Data, 102.5K Total
+    Debug Version:     160.5K Code, 50.6K Data, 211.1K Total
+
+2) iASL Compiler/Disassembler and Tools:
+
+ACPI 4.0: iASL and Disassembler - implemented support for the new IPMI 
+operation region keyword. ACPICA BZ 771, 772. Lin Ming.
+
+ACPI 4.0: iASL - implemented compile-time validation support for all new 
+predefined names and control methods (31 total). ACPICA BZ 769.
+
+----------------------------------------
 21 May 2009. Summary of changes for version 20090521:
 
 This release is available at www.acpica.org/downloads

Modified: head/sys/contrib/dev/acpica/common/dmrestag.c
==============================================================================
--- head/sys/contrib/dev/acpica/common/dmrestag.c	Fri Sep 11 22:05:59 2009	(r197103)
+++ head/sys/contrib/dev/acpica/common/dmrestag.c	Fri Sep 11 22:48:53 2009	(r197104)
@@ -387,7 +387,7 @@ static ACPI_RESOURCE_TAG        *AcpiGbl
 
 static UINT32                   AcpiGbl_NextResourceId = 0;
 static UINT8                    AcpiGbl_NextPrefix = 0;
-static UINT8                    AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] =
+static char                     AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] =
                                     {'Y','Z','J','K','X'};
 
 

Modified: head/sys/contrib/dev/acpica/common/dmtable.c
==============================================================================
--- head/sys/contrib/dev/acpica/common/dmtable.c	Fri Sep 11 22:05:59 2009	(r197103)
+++ head/sys/contrib/dev/acpica/common/dmtable.c	Fri Sep 11 22:48:53 2009	(r197104)
@@ -132,6 +132,7 @@ AcpiDmGetTableData (
 static void
 AcpiDmCheckAscii (
     UINT8                   *Target,
+    char                    *RepairedName,
     UINT32                  Count);
 
 UINT8
@@ -156,17 +157,18 @@ static const char           *AcpiDmDmarS
     "Hardware Unit Definition",
     "Reserved Memory Region",
     "Root Port ATS Capability",
+    "Remapping Hardware Static Affinity",
     "Unknown SubTable Type"         /* Reserved */
 };
 
 static const char           *AcpiDmHestSubnames[] =
 {
-    "XPF Machine Check Exception",
-    "XPF Corrected Machine Check",
-    "NOT USED???",
-    "XPF Non-Maskable Interrupt",
-    "IPF Corrected Machine Check",
-    "IPF Corrected Platform Error",
+    "IA-32 Machine Check Exception",
+    "IA-32 Corrected Machine Check",
+    "IA-32 Non-Maskable Interrupt",
+    "Unknown SubTable Type",        /* 3 - Reserved */
+    "Unknown SubTable Type",        /* 4 - Reserved */
+    "Unknown SubTable Type",        /* 5 - Reserved */
     "PCI Express Root Port AER",
     "PCI Express AER (AER Endpoint)",
     "PCI Express/PCI-X Bridge AER",
@@ -208,6 +210,14 @@ static const char           *AcpiDmSratS
     "Unknown SubTable Type"         /* Reserved */
 };
 
+static const char           *AcpiDmIvrsSubnames[] =
+{
+    "Hardware Definition Block",
+    "Memory Definition Block",
+    "Unknown SubTable Type"         /* Reserved */
+};
+
+
 
 #define ACPI_FADT_PM_RESERVED       8
 
@@ -224,11 +234,12 @@ static const char           *AcpiDmFadtP
     "Unknown Profile Type"
 };
 
-
 /*******************************************************************************
  *
  * ACPI Table Data, indexed by signature.
  *
+ * Each entry contains: Signature, Table Info, Handler, Description
+ *
  * Simple tables have only a TableInfo structure, complex tables have a handler.
  * This table must be NULL terminated. RSDP and FACS are special-cased
  * elsewhere.
@@ -249,8 +260,10 @@ static ACPI_DMTABLE_DATA    AcpiDmTableD
     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, "Fixed ACPI Description Table"},
     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, "Hardware Error Source Table"},
     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           "High Precision Event Timer table"},
+    {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, "I/O Virtualization Reporting Structure"},
     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, "Multiple APIC Description Table"},
     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, "Memory Mapped Configuration table"},
+    {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, "Maximum System Characteristics Table"},
     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, "Root System Description Table"},
     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           "Smart Battery Specification Table"},
     {ACPI_SIG_SLIC, AcpiDmTableInfoSlic,    NULL,           "Software Licensing Description Table"},
@@ -259,6 +272,9 @@ static ACPI_DMTABLE_DATA    AcpiDmTableD
     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           "Server Platform Management Interface table"},
     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, "System Resource Affinity Table"},
     {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa,    NULL,           "Trusted Computing Platform Alliance table"},
+    {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           "UEFI Boot Optimization Table"},
+    {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           "Windows ACPI Emulated Devices Table"},
+    {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, "Watchdog Action Table"},
     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           "Watchdog Resource Table"},
     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, "Extended System Description Table"},
     {NULL,          NULL,                   NULL,           NULL}
@@ -511,7 +527,9 @@ AcpiDmDumpTable (
     UINT8                   Temp8;
     UINT16                  Temp16;
     ACPI_DMTABLE_DATA       *TableData;
+    const char              *Name;
     BOOLEAN                 LastOutputBlankLine = FALSE;
+    char                    RepairedName[8];
 
 
     if (!Info)
@@ -547,6 +565,7 @@ AcpiDmDumpTable (
         case ACPI_DMT_UINT8:
         case ACPI_DMT_CHKSUM:
         case ACPI_DMT_SPACEID:
+        case ACPI_DMT_IVRS:
         case ACPI_DMT_MADT:
         case ACPI_DMT_SRAT:
         case ACPI_DMT_ASF:
@@ -577,6 +596,9 @@ AcpiDmDumpTable (
         case ACPI_DMT_NAME8:
             ByteLength = 8;
             break;
+        case ACPI_DMT_BUF16:
+            ByteLength = 16;
+            break;
         case ACPI_DMT_STRING:
             ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
             break;
@@ -677,17 +699,28 @@ AcpiDmDumpTable (
                 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
             break;
 
+        case ACPI_DMT_BUF16:
+
+            /* Buffer of length 16 */
+
+            for (Temp8 = 0; Temp8 < 16; Temp8++)
+            {
+                AcpiOsPrintf ("%2.2X,", Target[Temp8]);
+            }
+            AcpiOsPrintf ("\n");
+            break;
+
         case ACPI_DMT_STRING:
 
-            AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target));
+            AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
             break;
 
         /* Fixed length ASCII name fields */
 
         case ACPI_DMT_SIG:
 
-            AcpiDmCheckAscii (Target, 4);
-            AcpiOsPrintf ("\"%4.4s\"    ", Target);
+            AcpiDmCheckAscii (Target, RepairedName, 4);
+            AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
             TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target));
             if (TableData)
             {
@@ -698,20 +731,20 @@ AcpiDmDumpTable (
 
         case ACPI_DMT_NAME4:
 
-            AcpiDmCheckAscii (Target, 4);
-            AcpiOsPrintf ("\"%4.4s\"\n", Target);
+            AcpiDmCheckAscii (Target, RepairedName, 4);
+            AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
             break;
 
         case ACPI_DMT_NAME6:
 
-            AcpiDmCheckAscii (Target, 6);
-            AcpiOsPrintf ("\"%6.6s\"\n", Target);
+            AcpiDmCheckAscii (Target, RepairedName, 6);
+            AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
             break;
 
         case ACPI_DMT_NAME8:
 
-            AcpiDmCheckAscii (Target, 8);
-            AcpiOsPrintf ("\"%8.8s\"\n", Target);
+            AcpiDmCheckAscii (Target, RepairedName, 8);
+            AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
             break;
 
         /* Special Data Types */
@@ -742,8 +775,8 @@ AcpiDmDumpTable (
             /* Generic Address Structure */
 
             AcpiOsPrintf ("\n");
-            AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
-                CurrentOffset, Target, sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
+            AcpiDmDumpTable (TableLength, CurrentOffset, Target,
+                sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
             AcpiOsPrintf ("\n");
             LastOutputBlankLine = TRUE;
             break;
@@ -790,8 +823,8 @@ AcpiDmDumpTable (
         case ACPI_DMT_HESTNTFY:
 
             AcpiOsPrintf ("\n");
-            AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
-                CurrentOffset, Target, sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
+            AcpiDmDumpTable (TableLength, CurrentOffset, Target,
+                sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
             AcpiOsPrintf ("\n");
             LastOutputBlankLine = TRUE;
             break;
@@ -849,6 +882,31 @@ AcpiDmDumpTable (
             AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]);
             break;
 
+        case ACPI_DMT_IVRS:
+
+            /* IVRS subtable types */
+
+            Temp8 = *Target;
+            switch (Temp8)
+            {
+            case ACPI_IVRS_TYPE_HARDWARE:
+                Name = AcpiDmIvrsSubnames[0];
+                break;
+
+            case ACPI_IVRS_TYPE_MEMORY1:
+            case ACPI_IVRS_TYPE_MEMORY2:
+            case ACPI_IVRS_TYPE_MEMORY3:
+                Name = AcpiDmIvrsSubnames[1];
+                break;
+
+            default:
+                Name = AcpiDmIvrsSubnames[2];
+                break;
+            }
+
+            AcpiOsPrintf ("%2.2X <%s>\n", *Target, Name);
+            break;
+
         case ACPI_DMT_EXIT:
             return (AE_OK);
 
@@ -888,6 +946,7 @@ AcpiDmDumpTable (
 static void
 AcpiDmCheckAscii (
     UINT8                   *Name,
+    char                    *RepairedName,
     UINT32                  Count)
 {
     UINT32                  i;
@@ -895,9 +954,15 @@ AcpiDmCheckAscii (
 
     for (i = 0; i < Count; i++)
     {
-        if (!Name[i] || !isprint (Name[i]))
+        RepairedName[i] = Name[i];
+
+        if (!Name[i])
+        {
+            return;
+        }
+        if (!isprint (Name[i]))
         {
-            Name[i] = ' ';
+            RepairedName[i] = ' ';
         }
     }
 }

Modified: head/sys/contrib/dev/acpica/common/dmtbdump.c
==============================================================================
--- head/sys/contrib/dev/acpica/common/dmtbdump.c	Fri Sep 11 22:05:59 2009	(r197103)
+++ head/sys/contrib/dev/acpica/common/dmtbdump.c	Fri Sep 11 22:48:53 2009	(r197104)
@@ -306,6 +306,7 @@ AcpiDmDumpAsf (
     UINT32                  DataLength = 0;
     UINT32                  DataOffset = 0;
     UINT32                  i;
+    UINT8                   Type;
 
 
     /* No main table, only sub-tables */
@@ -322,7 +323,11 @@ AcpiDmDumpAsf (
             return;
         }
 
-        switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */
+        /* The actual type is the lower 7 bits of Type */
+
+        Type = (UINT8) (SubTable->Header.Type & 0x7F);
+
+        switch (Type)
         {
         case ACPI_ASF_TYPE_INFO:
             InfoTable = AcpiDmTableInfoAsf0;
@@ -332,8 +337,8 @@ AcpiDmDumpAsf (
             InfoTable = AcpiDmTableInfoAsf1;
             DataInfoTable = AcpiDmTableInfoAsf1a;
             DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ALERT));
-            DataCount = ((ACPI_ASF_ALERT *) SubTable)->Alerts;
-            DataLength = ((ACPI_ASF_ALERT *) SubTable)->DataLength;
+            DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->Alerts;
+            DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->DataLength;
             DataOffset = Offset + sizeof (ACPI_ASF_ALERT);
             break;
 
@@ -341,8 +346,8 @@ AcpiDmDumpAsf (
             InfoTable = AcpiDmTableInfoAsf2;
             DataInfoTable = AcpiDmTableInfoAsf2a;
             DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_REMOTE));
-            DataCount = ((ACPI_ASF_REMOTE *) SubTable)->Controls;
-            DataLength = ((ACPI_ASF_REMOTE *) SubTable)->DataLength;
+            DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->Controls;
+            DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->DataLength;
             DataOffset = Offset + sizeof (ACPI_ASF_REMOTE);
             break;
 
@@ -353,7 +358,7 @@ AcpiDmDumpAsf (
         case ACPI_ASF_TYPE_ADDRESS:
             InfoTable = AcpiDmTableInfoAsf4;
             DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ADDRESS));
-            DataLength = ((ACPI_ASF_ADDRESS *) SubTable)->Devices;
+            DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, SubTable)->Devices;
             DataOffset = Offset + sizeof (ACPI_ASF_ADDRESS);
             break;
 
@@ -371,7 +376,7 @@ AcpiDmDumpAsf (
 
         /* Dump variable-length extra data */
 
-        switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */
+        switch (Type)
         {
         case ACPI_ASF_TYPE_ALERT:
         case ACPI_ASF_TYPE_CONTROL:
@@ -471,7 +476,7 @@ AcpiDmDumpCpep (
     {
         AcpiOsPrintf ("\n");
         Status = AcpiDmDumpTable (Length, Offset, SubTable,
-                    SubTable->Length, AcpiDmTableInfoCpep0);
+                    SubTable->Header.Length, AcpiDmTableInfoCpep0);
         if (ACPI_FAILURE (Status))
         {
             return;
@@ -479,8 +484,9 @@ AcpiDmDumpCpep (
 
         /* Point to next sub-table */
 
-        Offset += SubTable->Length;
-        SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, SubTable->Length);
+        Offset += SubTable->Header.Length;
+        SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable,
+                    SubTable->Header.Length);
     }
 }
 
@@ -550,6 +556,10 @@ AcpiDmDumpDmar (
             InfoTable = AcpiDmTableInfoDmar2;
             ScopeOffset = sizeof (ACPI_DMAR_ATSR);
             break;
+        case ACPI_DMAR_HARDWARE_AFFINITY:
+            InfoTable = AcpiDmTableInfoDmar3;
+            ScopeOffset = sizeof (ACPI_DMAR_RHSA);
+            break;
         default:
             AcpiOsPrintf ("\n**** Unknown DMAR sub-table type %X\n\n", SubTable->Type);
             return;
@@ -737,6 +747,8 @@ AcpiDmDumpHest (
     UINT32                  Offset = sizeof (ACPI_TABLE_HEST);
     ACPI_DMTABLE_INFO       *InfoTable;
     UINT32                  SubTableLength;
+    UINT32                  BankCount;
+    ACPI_HEST_IA_ERROR_BANK *BankTable;
 
 
     /* Main table */
@@ -752,31 +764,26 @@ AcpiDmDumpHest (
     SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset);
     while (Offset < Table->Length)
     {
+        BankCount = 0;
         switch (SubTable->Type)
         {
-        case ACPI_HEST_TYPE_XPF_MACHINE_CHECK:
+        case ACPI_HEST_TYPE_IA32_CHECK:
             InfoTable = AcpiDmTableInfoHest0;
-            SubTableLength = sizeof (ACPI_HEST_XPF_MACHINE_CHECK);
+            SubTableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK);
+            BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK,
+                            SubTable))->NumHardwareBanks;
             break;
 
-        case ACPI_HEST_TYPE_XPF_CORRECTED_MACHINE_CHECK:
+        case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
             InfoTable = AcpiDmTableInfoHest1;
-            SubTableLength = sizeof (ACPI_HEST_XPF_CORRECTED);
-            break;
-
-        case ACPI_HEST_TYPE_XPF_NON_MASKABLE_INTERRUPT:
-            InfoTable = AcpiDmTableInfoHest3;
-            SubTableLength = sizeof (ACPI_HEST_XPF_NMI);
+            SubTableLength = sizeof (ACPI_HEST_IA_CORRECTED);
+            BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED,
+                            SubTable))->NumHardwareBanks;
             break;
 
-        case ACPI_HEST_TYPE_IPF_CORRECTED_MACHINE_CHECK:
-            InfoTable = AcpiDmTableInfoHest4;
-            SubTableLength = sizeof (ACPI_HEST_IPF_CORRECTED);
-            break;
-
-        case ACPI_HEST_TYPE_IPF_CORRECTED_PLATFORM_ERROR:
-            InfoTable = AcpiDmTableInfoHest5;
-            SubTableLength = sizeof (ACPI_HEST_IPF_CORRECTED_PLATFORM);
+        case ACPI_HEST_TYPE_IA32_NMI:
+            InfoTable = AcpiDmTableInfoHest2;
+            SubTableLength = sizeof (ACPI_HEST_IA_NMI);
             break;
 
         case ACPI_HEST_TYPE_AER_ROOT_PORT:
@@ -794,7 +801,7 @@ AcpiDmDumpHest (
             SubTableLength = sizeof (ACPI_HEST_AER_BRIDGE);
             break;
 
-        case ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE:
+        case ACPI_HEST_TYPE_GENERIC_ERROR:
             InfoTable = AcpiDmTableInfoHest9;
             SubTableLength = sizeof (ACPI_HEST_GENERIC);
             break;
@@ -814,9 +821,34 @@ AcpiDmDumpHest (
             return;
         }
 
-        /* Point to next sub-table (each subtable is of fixed length) */
+        /* Point to end of current subtable (each subtable above is of fixed length) */
 
         Offset += SubTableLength;
+
+        /* If there are any (fixed-length) Error Banks from above, dump them now */
+
+        if (BankCount)
+        {
+            BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, SubTable, SubTableLength);
+            SubTableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK);
+
+            while (BankCount)
+            {
+                AcpiOsPrintf ("\n");
+                Status = AcpiDmDumpTable (Length, Offset, BankTable,
+                            sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank);
+                if (ACPI_FAILURE (Status))
+                {
+                    return;
+                }
+                Offset += sizeof (ACPI_HEST_IA_ERROR_BANK);
+                BankTable++;
+                BankCount--;
+            }
+        }
+
+        /* Point to next sub-table */
+
         SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, SubTable, SubTableLength);
     }
 }
@@ -824,6 +856,179 @@ AcpiDmDumpHest (
 
 /*******************************************************************************
  *
+ * FUNCTION:    AcpiDmDumpIvrs
+ *
+ * PARAMETERS:  Table               - A IVRS table
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Format the contents of a IVRS
+ *
+ ******************************************************************************/
+
+static UINT8 EntrySizes[] = {4,8,16,32};
+
+void
+AcpiDmDumpIvrs (
+    ACPI_TABLE_HEADER       *Table)
+{
+    ACPI_STATUS             Status;
+    UINT32                  Offset = sizeof (ACPI_TABLE_IVRS);
+    UINT32                  EntryOffset;
+    UINT32                  EntryLength;
+    UINT32                  EntryType;
+    ACPI_IVRS_DE_HEADER     *DeviceEntry;
+    ACPI_IVRS_HEADER        *SubTable;
+    ACPI_DMTABLE_INFO       *InfoTable;
+
+
+    /* Main table */
+
+    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIvrs);
+    if (ACPI_FAILURE (Status))
+    {
+        return;
+    }
+
+    /* Sub-tables */
+
+    SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset);
+    while (Offset < Table->Length)
+    {
+        /* Common sub-table header */
+
+        AcpiOsPrintf ("\n");
+        Status = AcpiDmDumpTable (Table->Length, Offset, SubTable,
+                    SubTable->Length, AcpiDmTableInfoIvrsHdr);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+
+        switch (SubTable->Type)
+        {
+        case ACPI_IVRS_TYPE_HARDWARE:
+            InfoTable = AcpiDmTableInfoIvrs0;
+            break;
+        case ACPI_IVRS_TYPE_MEMORY1:
+        case ACPI_IVRS_TYPE_MEMORY2:
+        case ACPI_IVRS_TYPE_MEMORY3:
+            InfoTable = AcpiDmTableInfoIvrs1;
+            break;
+        default:
+            AcpiOsPrintf ("\n**** Unknown IVRS sub-table type %X\n",
+                SubTable->Type);
+
+            /* Attempt to continue */
+
+            if (!SubTable->Length)
+            {
+                AcpiOsPrintf ("Invalid zero length subtable\n");
+                return;
+            }
+            goto NextSubTable;
+        }
+
+        /* Dump the subtable */
+
+        AcpiOsPrintf ("\n");
+        Status = AcpiDmDumpTable (Table->Length, Offset, SubTable,
+                    SubTable->Length, InfoTable);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+
+        /* The hardware subtable can contain multiple device entries */
+
+        if (SubTable->Type == ACPI_IVRS_TYPE_HARDWARE)
+        {
+            EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE);
+            DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, SubTable,
+                            sizeof (ACPI_IVRS_HARDWARE));
+
+            while (EntryOffset < (Offset + SubTable->Length))
+            {
+                AcpiOsPrintf ("\n");
+                /*
+                 * Upper 2 bits of Type encode the length of the device entry
+                 *
+                 * 00 = 4 byte
+                 * 01 = 8 byte
+                 * 10 = 16 byte - currently no entries defined
+                 * 11 = 32 byte - currently no entries defined
+                 */
+                EntryType = DeviceEntry->Type;
+                EntryLength = EntrySizes [EntryType >> 6];
+
+                switch (EntryType)
+                {
+                /* 4-byte device entries */
+
+                case ACPI_IVRS_TYPE_PAD4:
+                case ACPI_IVRS_TYPE_ALL:
+                case ACPI_IVRS_TYPE_SELECT:
+                case ACPI_IVRS_TYPE_START:
+                case ACPI_IVRS_TYPE_END:
+
+                    InfoTable = AcpiDmTableInfoIvrs4;
+                    break;
+
+                /* 8-byte entries, type A */
+
+                case ACPI_IVRS_TYPE_ALIAS_SELECT:
+                case ACPI_IVRS_TYPE_ALIAS_START:
+
+                    InfoTable = AcpiDmTableInfoIvrs8a;
+                    break;
+
+                /* 8-byte entries, type B */
+
+                case ACPI_IVRS_TYPE_PAD8:
+                case ACPI_IVRS_TYPE_EXT_SELECT:
+                case ACPI_IVRS_TYPE_EXT_START:
+
+                    InfoTable = AcpiDmTableInfoIvrs8b;
+                    break;
+
+                /* 8-byte entries, type C */
+
+                case ACPI_IVRS_TYPE_SPECIAL:
+
+                    InfoTable = AcpiDmTableInfoIvrs8c;
+                    break;
+
+                default:
+                    InfoTable = AcpiDmTableInfoIvrs4;
+                    AcpiOsPrintf (
+                        "\n**** Unknown IVRS device entry type/length: "
+                        "%.2X/%X at offset %.4X: (header below)\n",
+