From owner-p4-projects@FreeBSD.ORG Sun May 2 10:22:41 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 307B4106566C; Sun, 2 May 2010 10:22:41 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E8E44106566B for ; Sun, 2 May 2010 10:22:40 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D5CF28FC18 for ; Sun, 2 May 2010 10:22:40 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o42AMep9088408 for ; Sun, 2 May 2010 10:22:40 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o42AMerf088406 for perforce@freebsd.org; Sun, 2 May 2010 10:22:40 GMT (envelope-from mav@freebsd.org) Date: Sun, 2 May 2010 10:22:40 GMT Message-Id: <201005021022.o42AMerf088406@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 177589 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 10:22:41 -0000 http://p4web.freebsd.org/@@177589?ac=10 Change 177589 by mav@mav_mavtest on 2010/05/02 10:22:03 IFC Affected files ... .. //depot/projects/scottl-camlock/src/lib/libpmc/libpmc.c#10 integrate .. //depot/projects/scottl-camlock/src/lib/libufs/cgroup.c#4 integrate .. //depot/projects/scottl-camlock/src/sys/amd64/amd64/trap.c#27 integrate .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#156 integrate .. //depot/projects/scottl-camlock/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c#3 integrate .. //depot/projects/scottl-camlock/src/sys/conf/NOTES#57 integrate .. //depot/projects/scottl-camlock/src/sys/conf/options#42 integrate .. //depot/projects/scottl-camlock/src/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c#2 integrate .. //depot/projects/scottl-camlock/src/sys/dev/hwpmc/hwpmc_mod.c#16 integrate .. //depot/projects/scottl-camlock/src/sys/kern/kern_resource.c#18 integrate .. //depot/projects/scottl-camlock/src/sys/kern/uipc_mbuf.c#18 integrate .. //depot/projects/scottl-camlock/src/sys/mips/conf/AR71XX#6 integrate .. //depot/projects/scottl-camlock/src/sys/vm/vm_map.c#31 integrate .. //depot/projects/scottl-camlock/src/usr.bin/pathchk/pathchk.1#2 integrate .. //depot/projects/scottl-camlock/src/usr.bin/pathchk/pathchk.c#2 integrate Differences ... ==== //depot/projects/scottl-camlock/src/lib/libpmc/libpmc.c#10 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.26 2010/04/02 13:23:49 fabient Exp $"); +__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.27 2010/05/01 21:59:06 rstone Exp $"); #include #include @@ -737,9 +737,16 @@ case PMC_EV_IAP_EVENT_40H: /* Core */ case PMC_EV_IAP_EVENT_41H: /* Core */ case PMC_EV_IAP_EVENT_42H: /* Core, Core2, Atom */ - case PMC_EV_IAP_EVENT_77H: /* Core */ if (cachestate == 0) cachestate = (0xF << 8); + break; + case PMC_EV_IAP_EVENT_77H: /* Atom */ + /* IAP_EVENT_77H only accepts a cachestate qualifier on the + * Atom processor + */ + if(cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM && cachestate == 0) + cachestate = (0xF << 8); + break; default: break; } ==== //depot/projects/scottl-camlock/src/lib/libufs/cgroup.c#4 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include -__FBSDID("$FreeBSD: src/lib/libufs/cgroup.c,v 1.6 2010/04/24 07:05:35 jeff Exp $"); +__FBSDID("$FreeBSD: src/lib/libufs/cgroup.c,v 1.7 2010/05/01 18:56:45 emaste Exp $"); #include #include @@ -145,7 +145,7 @@ fs = &disk->d_fs; cgp = &disk->d_cg; inosused = cg_inosused(cgp); - for (ino = 0; ino < fs->fs_ipg / NBBY; ino++) + for (ino = 0; ino < fs->fs_ipg; ino++) if (isclr(inosused, ino)) goto gotit; return (0); ==== //depot/projects/scottl-camlock/src/sys/amd64/amd64/trap.c#27 (text+ko) ==== @@ -38,7 +38,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.341 2010/04/13 10:12:58 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.342 2010/05/01 13:15:35 kib Exp $"); /* * AMD64 Trap and System call handling @@ -172,52 +172,6 @@ extern char *syscallnames[]; -/* #define DEBUG 1 */ -#ifdef DEBUG -static void -report_seg_fault(const char *segn, struct trapframe *frame) -{ - struct proc_ldt *pldt; - struct trapframe *pf; - - pldt = curproc->p_md.md_ldt; - printf("%d: %s load fault %lx %p %d\n", - curproc->p_pid, segn, frame->tf_err, - pldt != NULL ? pldt->ldt_base : NULL, - pldt != NULL ? pldt->ldt_refcnt : 0); - kdb_backtrace(); - pf = (struct trapframe *)frame->tf_rsp; - printf("rdi %lx\n", pf->tf_rdi); - printf("rsi %lx\n", pf->tf_rsi); - printf("rdx %lx\n", pf->tf_rdx); - printf("rcx %lx\n", pf->tf_rcx); - printf("r8 %lx\n", pf->tf_r8); - printf("r9 %lx\n", pf->tf_r9); - printf("rax %lx\n", pf->tf_rax); - printf("rbx %lx\n", pf->tf_rbx); - printf("rbp %lx\n", pf->tf_rbp); - printf("r10 %lx\n", pf->tf_r10); - printf("r11 %lx\n", pf->tf_r11); - printf("r12 %lx\n", pf->tf_r12); - printf("r13 %lx\n", pf->tf_r13); - printf("r14 %lx\n", pf->tf_r14); - printf("r15 %lx\n", pf->tf_r15); - printf("fs %x\n", pf->tf_fs); - printf("gs %x\n", pf->tf_gs); - printf("es %x\n", pf->tf_es); - printf("ds %x\n", pf->tf_ds); - printf("tno %x\n", pf->tf_trapno); - printf("adr %lx\n", pf->tf_addr); - printf("flg %x\n", pf->tf_flags); - printf("err %lx\n", pf->tf_err); - printf("rip %lx\n", pf->tf_rip); - printf("cs %lx\n", pf->tf_cs); - printf("rfl %lx\n", pf->tf_rflags); - printf("rsp %lx\n", pf->tf_rsp); - printf("ss %lx\n", pf->tf_ss); -} -#endif - /* * Exception, fault, and trap interface to the FreeBSD kernel. * This common code is called from assembly language IDT gate entry @@ -314,9 +268,7 @@ */ printf("kernel trap %d with interrupts disabled\n", type); -#ifdef DEBUG - report_seg_fault("hlt", frame); -#endif + /* * We shouldn't enable interrupts while holding a * spin lock or servicing an NMI. @@ -535,33 +487,21 @@ goto out; } if (frame->tf_rip == (long)ld_ds) { -#ifdef DEBUG - report_seg_fault("ds", frame); -#endif frame->tf_rip = (long)ds_load_fault; frame->tf_ds = _udatasel; goto out; } if (frame->tf_rip == (long)ld_es) { -#ifdef DEBUG - report_seg_fault("es", frame); -#endif frame->tf_rip = (long)es_load_fault; frame->tf_es = _udatasel; goto out; } if (frame->tf_rip == (long)ld_fs) { -#ifdef DEBUG - report_seg_fault("fs", frame); -#endif frame->tf_rip = (long)fs_load_fault; frame->tf_fs = _ufssel; goto out; } if (frame->tf_rip == (long)ld_gs) { -#ifdef DEBUG - report_seg_fault("gs", frame); -#endif frame->tf_rip = (long)gs_load_fault; frame->tf_gs = _ugssel; goto out; @@ -667,30 +607,6 @@ ksi.ksi_addr = (void *)addr; trapsignal(td, &ksi); -#ifdef DEBUG -{ - register_t rg,rgk, rf; - - if (type <= MAX_TRAP_MSG) { - uprintf("fatal process exception: %s", - trap_msg[type]); - if ((type == T_PAGEFLT) || (type == T_PROTFLT)) - uprintf(", fault VA = 0x%lx", frame->tf_addr); - uprintf("\n"); - } - rf = rdmsr(0xc0000100); - rg = rdmsr(0xc0000101); - rgk = rdmsr(0xc0000102); - uprintf("pid %d TRAP %d rip %lx err %lx addr %lx cs %lx ss %lx ds %x " - "es %x fs %x fsbase %lx %lx gs %x gsbase %lx %lx %lx\n", - curproc->p_pid, type, frame->tf_rip, frame->tf_err, - frame->tf_addr, - frame->tf_cs, frame->tf_ss, frame->tf_ds, frame->tf_es, - frame->tf_fs, td->td_pcb->pcb_fsbase, rf, - frame->tf_gs, td->td_pcb->pcb_gsbase, rg, rgk); -} -#endif - user: userret(td, frame); mtx_assert(&Giant, MA_NOTOWNED); ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#156 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.247 2010/04/30 08:57:03 mav Exp $"); +__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.248 2010/05/02 04:16:39 mav Exp $"); #include #include @@ -4874,6 +4874,8 @@ if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0 && (--dev->tag_delay_count == 0)) xpt_start_tags(ccb_h->path); + if (!device_is_send_queued(dev)) + xpt_schedule_dev_sendq(ccb_h->path->bus, dev); } if (ccb_h->status & CAM_RELEASE_SIMQ) { ==== //depot/projects/scottl-camlock/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c#3 (text+ko) ==== @@ -38,15 +38,22 @@ int zfs_txg_timeout = 30; /* max seconds worth of delta per txg */ extern int zfs_txg_synctime; +extern uint64_t zfs_write_limit_override; SYSCTL_DECL(_vfs_zfs); -SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS TXG"); +SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, + "ZFS transaction groups (TXG)"); TUNABLE_INT("vfs.zfs.txg.timeout", &zfs_txg_timeout); SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RDTUN, &zfs_txg_timeout, 0, "Maximum seconds worth of delta per txg"); TUNABLE_INT("vfs.zfs.txg.synctime", &zfs_txg_synctime); SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, synctime, CTLFLAG_RDTUN, &zfs_txg_synctime, 0, "Target seconds to sync a txg"); +TUNABLE_QUAD("vfs.zfs.txg.write_limit_override", &zfs_write_limit_override); +SYSCTL_QUAD(_vfs_zfs_txg, OID_AUTO, write_limit_override, CTLFLAG_RW, + &zfs_write_limit_override, 0, + "Override maximum size of a txg to this size in bytes, " + "value of 0 means don't override"); /* * Prepare the txg subsystem. ==== //depot/projects/scottl-camlock/src/sys/conf/NOTES#57 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1581 2010/04/14 20:45:33 yongari Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1582 2010/05/01 16:36:14 imp Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -2093,6 +2093,15 @@ #device ath_rf5413 #device ath_ar5416 # AR5416 chips options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors +# All of the AR5212 parts have a problem when paired with the AR71xx +# CPUS. These parts have a bug that triggers a fatal bus error on the AR71xx +# only. Details of the exact nature of the bug are sketchy, but some can be +# found at https://forum.openwrt.org/viewtopic.php?pid=70060 on pages 4, 5 and +# 6. This option enables this workaround. There is a performance penalty +# for this work around, but without it things don't work at all. The DMA +# from the card usually bursts 128 bytes, but on the affected CPUs, only +# 4 are safe. +options AH_RXCFG_SDMAMW_4BYTES #device ath_ar9160 # AR9160 chips #device ath_ar9280 # AR9280 chips #device ath_ar9285 # AR9285 chips ==== //depot/projects/scottl-camlock/src/sys/conf/options#42 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options,v 1.701 2010/03/24 20:02:40 rrs Exp $ +# $FreeBSD: src/sys/conf/options,v 1.702 2010/05/01 16:36:14 imp Exp $ # # On the handling of kernel options # @@ -771,6 +771,7 @@ AH_NEED_DESC_SWAP opt_ah.h AH_USE_INIPDGAIN opt_ah.h AH_MAXCHAN opt_ah.h +AH_RXCFG_SDMAMW_4BYTES opt_ah.h # options for the Broadcom BCM43xx driver (bwi) BWI_DEBUG opt_bwi.h ==== //depot/projects/scottl-camlock/src/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c#2 (text+ko) ==== @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $FreeBSD: src/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c,v 1.9 2009/02/24 01:07:06 sam Exp $ + * $FreeBSD: src/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c,v 1.10 2010/05/01 16:36:14 imp Exp $ */ #include "opt_ah.h" @@ -283,6 +283,14 @@ regWrites = ath_hal_ini_write(ah, &ahp->ah_ini_modes, modesIndex, 0); regWrites = write_common(ah, &ahp->ah_ini_common, bChannelChange, regWrites); +#ifdef AH_RXCFG_SDMAMW_4BYTES + /* + * Nala doesn't work with 128 byte bursts on pb42(hydra) (ar71xx), + * use 4 instead. Enabling it on all platforms would hurt performance, + * so we only enable it on the ones that are affected by it. + */ + OS_REG_WRITE(ah, AR_RXCFG, 0); +#endif ahp->ah_rfHal->writeRegs(ah, modesIndex, freqIndex, regWrites); OS_MARK(ah, AH_MARK_RESET_LINE, __LINE__); ==== //depot/projects/scottl-camlock/src/sys/dev/hwpmc/hwpmc_mod.c#16 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/hwpmc/hwpmc_mod.c,v 1.49 2010/03/31 20:00:44 fabient Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/hwpmc/hwpmc_mod.c,v 1.50 2010/05/01 22:04:58 rstone Exp $"); #include #include @@ -2675,16 +2675,16 @@ PMCDBG(PMC,OPS,1, "po=%p in global list", po); } po->po_sscount++; - } - /* - * Log mapping information for all existing processes in the - * system. Subsequent mappings are logged as they happen; - * see pmc_process_mmap(). - */ - if (po->po_logprocmaps == 0) { - pmc_log_all_process_mappings(po); - po->po_logprocmaps = 1; + /* + * Log mapping information for all existing processes in the + * system. Subsequent mappings are logged as they happen; + * see pmc_process_mmap(). + */ + if (po->po_logprocmaps == 0) { + pmc_log_all_process_mappings(po); + po->po_logprocmaps = 1; + } } /* ==== //depot/projects/scottl-camlock/src/sys/kern/kern_resource.c#18 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.195 2010/03/03 21:46:51 rrs Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.196 2010/05/01 14:46:17 kib Exp $"); #include "opt_compat.h" @@ -76,6 +76,7 @@ struct timeval *up, struct timeval *sp); static int donice(struct thread *td, struct proc *chgp, int n); static struct uidinfo *uilookup(uid_t uid); +static void ruxagg_tlock(struct proc *p, struct thread *td); /* * Resource controls and accounting. @@ -629,9 +630,7 @@ return; PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td) { - thread_lock(td); - ruxagg(&p->p_rux, td); - thread_unlock(td); + ruxagg_tlock(p, td); } PROC_SUNLOCK(p); if (p->p_rux.rux_runtime > p->p_cpulimit * cpu_tickrate()) { @@ -842,9 +841,7 @@ FOREACH_THREAD_IN_PROC(p, td) { if (td->td_incruntime == 0) continue; - thread_lock(td); - ruxagg(&p->p_rux, td); - thread_unlock(td); + ruxagg_tlock(p, td); } calcru1(p, &p->p_rux, up, sp); } @@ -945,10 +942,7 @@ } int -kern_getrusage(td, who, rup) - struct thread *td; - int who; - struct rusage *rup; +kern_getrusage(struct thread *td, int who, struct rusage *rup) { struct proc *p; int error; @@ -1022,6 +1016,15 @@ td->td_sticks = 0; } +static void +ruxagg_tlock(struct proc *p, struct thread *td) +{ + + thread_lock(td); + ruxagg(&p->p_rux, td); + thread_unlock(td); +} + /* * Update the rusage_ext structure and fetch a valid aggregate rusage * for proc p if storage for one is supplied. @@ -1036,9 +1039,7 @@ *ru = p->p_ru; if (p->p_numthreads > 0) { FOREACH_THREAD_IN_PROC(p, td) { - thread_lock(td); - ruxagg(&p->p_rux, td); - thread_unlock(td); + ruxagg_tlock(p, td); rucollect(ru, &td->td_ru); } } ==== //depot/projects/scottl-camlock/src/sys/kern/uipc_mbuf.c#18 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_mbuf.c,v 1.185 2009/06/22 22:20:38 andre Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_mbuf.c,v 1.186 2010/05/01 18:34:50 zec Exp $"); #include "opt_param.h" #include "opt_mbuf_stress_test.h" @@ -948,9 +948,8 @@ len = 0; } } - m = mp; if (mp->m_flags & M_PKTHDR) - m->m_pkthdr.len -= (req_len - len); + mp->m_pkthdr.len -= (req_len - len); } else { /* * Trim from tail. Scan the mbuf chain, ==== //depot/projects/scottl-camlock/src/sys/mips/conf/AR71XX#6 (text+ko) ==== @@ -1,7 +1,7 @@ # # AR71XX -- Kernel configuration file for FreeBSD/mips for Atheros 71xx systems # -# $FreeBSD: src/sys/mips/conf/AR71XX,v 1.5 2010/03/29 22:03:55 imp Exp $ +# $FreeBSD: src/sys/mips/conf/AR71XX,v 1.7 2010/05/01 16:39:46 imp Exp $ # ident AR71XX @@ -29,11 +29,11 @@ # options NFS_LEGACYRPC # Debugging for use in -current -# options DEADLKRES -# options INVARIANTS -# options INVARIANT_SUPPORT -# options WITNESS -# options WITNESS_SKIPSPIN +options DEADLKRES +options INVARIANTS +options INVARIANT_SUPPORT +options WITNESS +options WITNESS_SKIPSPIN options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support options UFS_ACL #Support for access control lists @@ -62,6 +62,7 @@ options ATH_DEBUG device ath_hal option AH_SUPPORT_AR5416 +option AH_RXCFG_SDMAMW_4BYTES # See NOTES for details of this WAR device ath_rate_sample device mii ==== //depot/projects/scottl-camlock/src/sys/vm/vm_map.c#31 (text+ko) ==== @@ -63,7 +63,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.428 2010/04/18 22:32:07 jmallett Exp $"); +__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.429 2010/05/02 01:25:03 alc Exp $"); #include #include @@ -1412,7 +1412,11 @@ } result = vm_map_insert(map, object, offset, start, start + length, prot, max, cow); - } while (result == KERN_NO_SPACE && find_space == VMFS_ALIGNED_SPACE); + } while (result == KERN_NO_SPACE && (find_space == VMFS_ALIGNED_SPACE +#ifdef VMFS_TLB_ALIGNED_SPACE + || find_space == VMFS_TLB_ALIGNED_SPACE +#endif + )); vm_map_unlock(map); return (result); } ==== //depot/projects/scottl-camlock/src/usr.bin/pathchk/pathchk.1#2 (text+ko) ==== @@ -25,9 +25,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/usr.bin/pathchk/pathchk.1,v 1.5 2005/01/18 13:43:52 ru Exp $ +.\" $FreeBSD: src/usr.bin/pathchk/pathchk.1,v 1.7 2010/05/01 22:10:45 jilles Exp $ .\" -.Dd May 21, 2002 +.Dd May 1, 2010 .Dt PATHCHK 1 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd check pathnames .Sh SYNOPSIS .Nm -.Op Fl p +.Op Fl pP .Ar pathname ... .Sh DESCRIPTION The @@ -95,6 +95,16 @@ .Pq Ql \&- character. .El +.It Fl P +In addition to the default or +.Fl p +checks, write a diagnostic for each argument that: +.Bl -bullet +.It +Is empty. +.It +Contains a component that starts with a hyphen. +.El .El .Sh EXIT STATUS .Ex -std @@ -104,7 +114,7 @@ .Tn POSIX systems: .Pp -.Dl "find . -print | xargs pathchk -p" +.Dl "find . -exec pathchk -p -- {} +" .Sh SEE ALSO .Xr getconf 1 , .Xr pathconf 2 , ==== //depot/projects/scottl-camlock/src/usr.bin/pathchk/pathchk.c#2 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/usr.bin/pathchk/pathchk.c,v 1.5 2005/05/21 09:55:07 ru Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/pathchk/pathchk.c,v 1.6 2010/05/01 22:00:28 jilles Exp $"); #include #include @@ -51,6 +51,7 @@ static void usage(void); static int pflag; /* Perform portability checks */ +static int Pflag; /* Check for empty paths, leading '-' */ int main(int argc, char *argv[]) @@ -58,11 +59,14 @@ int ch, rval; const char *arg; - while ((ch = getopt(argc, argv, "p")) > 0) { + while ((ch = getopt(argc, argv, "pP")) > 0) { switch (ch) { case 'p': pflag = 1; break; + case 'P': + Pflag = 1; + break; default: usage(); /*NOTREACHED*/ @@ -102,6 +106,15 @@ p = pathd; + if (Pflag && *p == '\0') { + warnx("%s: empty pathname", path); + goto bad; + } + if ((Pflag || pflag) && (*p == '-' || strstr(p, "/-") != NULL)) { + warnx("%s: contains a component starting with '-'", path); + goto bad; + } + if (!pflag) { errno = 0; namemax = pathconf(*p == '/' ? "/" : ".", _PC_NAME_MAX); @@ -182,9 +195,6 @@ "0123456789._-"; long s; - if (*path == '-') - return (*path); - s = strspn(path, charset); if (path[s] != '\0') return (path[s]);