From owner-svn-soc-all@FreeBSD.ORG Sun Aug 5 15:29:50 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 2C08C106566C for ; Sun, 5 Aug 2012 15:29:48 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 05 Aug 2012 15:29:48 +0000 Date: Sun, 05 Aug 2012 15:29:48 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120805152948.2C08C106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240105 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf arm/ti arm/ti/twl boot/fdt/dts X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2012 15:29:50 -0000 Author: aleek Date: Sun Aug 5 15:29:47 2012 New Revision: 240105 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240105 Log: added registers map for i2c OMAP3 Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_clks.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sun Aug 5 14:48:55 2012 (r240104) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sun Aug 5 15:29:47 2012 (r240105) @@ -82,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"msdosfs:mmcsd0s3\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" # Console and misc Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h Sun Aug 5 14:48:55 2012 (r240104) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h Sun Aug 5 15:29:47 2012 (r240105) @@ -34,6 +34,8 @@ * Simply contains register bit flags. */ +#if defined(SOC_TI_AM37X) || defined(SOC_OMAP4) + /* * OMAP4 I2C Registers, Summary 1 */ @@ -109,5 +111,78 @@ #define I2C_REG_IRQENABLE_CLR 0x30 +#elif defined( SOC_TI_AM37X ) || defined( SOC_OMAP3 ) + + +#define I2C_REV 0x00 +#define I2C_IE 0x04 +#define I2C_IE_XDR (1UL << 14) /* Transmit draining interrupt */ +#define I2C_IE_RDR (1UL << 13) /* Receive draining interrupt */ +#define I2C_IE_AAS (1UL << 9) /* Addressed as Slave interrupt */ +#define I2C_IE_BF (1UL << 8) /* Bus Free interrupt */ +#define I2C_IE_AERR (1UL << 7) /* Access Error interrupt */ +#define I2C_IE_STC (1UL << 6) /* Start Condition interrupt */ +#define I2C_IE_GC (1UL << 5) /* General Call interrupt */ +#define I2C_IE_XRDY (1UL << 4) /* Transmit Data Ready interrupt */ +#define I2C_IE_RRDY (1UL << 3) /* Receive Data Ready interrupt */ +#define I2C_IE_ARDY (1UL << 2) /* Register Access Ready interrupt */ +#define I2C_IE_NACK (1UL << 1) /* No Acknowledgment interrupt */ +#define I2C_IE_AL (1UL << 0) /* Arbitration Lost interrupt */ +#define I2C_STAT 0x08 +#define I2C_STAT_XDR (1UL << 14) +#define I2C_STAT_RDR (1UL << 13) +#define I2C_STAT_BB (1UL << 12) +#define I2C_STAT_ROVR (1UL << 11) +#define I2C_STAT_XUDF (1UL << 10) +#define I2C_STAT_AAS (1UL << 9) +#define I2C_STAT_BF (1UL << 8) +#define I2C_STAT_AERR (1UL << 7) +#define I2C_STAT_STC (1UL << 6) +#define I2C_STAT_GC (1UL << 5) +#define I2C_STAT_XRDY (1UL << 4) +#define I2C_STAT_RRDY (1UL << 3) +#define I2C_STAT_ARDY (1UL << 2) +#define I2C_STAT_NACK (1UL << 1) +#define I2C_STAT_AL (1UL << 0) +#define I2C_SYSS 0x10 +#define I2C_BUF 0x14 +#define I2C_CNT 0x18 +#define I2C_DATA 0x1C +#define I2C_CON 0x24 +#define I2C_CON_I2C_EN (1UL << 15) +#define I2C_CON_OPMODE_STD (0UL << 12) +#define I2C_CON_OPMODE_HS (1UL << 12) +#define I2C_CON_OPMODE_SCCB (2UL << 12) +#define I2C_CON_OPMODE_MASK (3UL << 13) +#define I2C_CON_I2C_STB (1UL << 11) +#define I2C_CON_MST (1UL << 10) +#define I2C_CON_TRX (1UL << 9) +#define I2C_CON_XSA (1UL << 8) +#define I2C_CON_XOA0 (1UL << 7) +#define I2C_CON_XOA1 (1UL << 6) +#define I2C_CON_XOA2 (1UL << 5) +#define I2C_CON_XOA3 (1UL << 4) +#define I2C_CON_STP (1UL << 1) +#define I2C_CON_STT (1UL << 0) + +#define I2C_OA0 0x28 +#define I2C_SA 0x2C +#define I2C_PSC 0x30 +#define I2C_SCLL 0x34 +#define I2C_SCLH 0x38 +#define I2C_SYSTEST 0x3C +#define I2C_BUFSTAT 0x40 +#define I2C_OA1 0x44 +#define I2C_OA2 0x48 +#define I2C_OA3 0x4C +#define I2C_ACTOA 0x50 +#define I2C_SBLOCK 0x54 + +#define I2C_OMAP3_SYSC 0x20 +#define I2C_OMAP4_SYSC 0x10 + + +#endif + #endif /* _TI_I2C_H_ */ Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_clks.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_clks.c Sun Aug 5 14:48:55 2012 (r240104) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_clks.c Sun Aug 5 15:29:47 2012 (r240105) @@ -75,7 +75,7 @@ #include "twl_clks.h" -static int twl_clks_debug = 1; //@todo XXX make it #if DEBUG +//static int twl_clks_debug = 1; //@todo XXX make it #if DEBUG /* @@ -336,7 +336,8 @@ if (!xlocked) TWL_CLKS_LOCK_DOWNGRADE(sc); - if ((twl_clks_debug > 1) && !err) + //if ((twl_clks_debug > 1) && !err) //@todo XXX + if (!err) device_printf(sc->sc_dev, "%s : %sabled\n", clk->name, enable ? "en" : "dis"); @@ -556,14 +557,14 @@ TWL_CLKS_XUNLOCK(sc); - if (twl_clks_debug) { + //if (twl_clks_debug) {//@todo XXX LIST_FOREACH(entry, &sc->sc_clks_list, link) { err = twl_clks_is_enabled(sc->sc_dev, entry->name, &enable); if (!err) device_printf(sc->sc_dev, "%s : %s\n", entry->name, enable ? "on" : "off"); } - } + //} return (0); } Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Sun Aug 5 14:48:55 2012 (r240104) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Sun Aug 5 15:29:47 2012 (r240105) @@ -75,7 +75,7 @@ #include "twl.h" #include "twl_vreg.h" -static int twl_vreg_debug = 10; +//static int twl_vreg_debug = 10; /* @@ -596,7 +596,8 @@ if (!xlocked) TWL_VREG_LOCK_DOWNGRADE(sc); - if ((twl_vreg_debug > 1) && !err) + //if ((twl_vreg_debug > 1) && !err) todo XXX + if (!err) device_printf(sc->sc_dev, "%s : setting voltage to %dmV (vsel: 0x%x)\n", regulator->name, millivolts, vsel); @@ -669,7 +670,8 @@ if (!xlocked) TWL_VREG_LOCK_DOWNGRADE(sc); - if ((twl_vreg_debug > 1) && !err) + //if ((twl_vreg_debug > 1) && !err) @todo XXX + if (!err) device_printf(sc->sc_dev, "%s : reading voltage is %dmV (vsel: 0x%x)\n", regulator->name, *millivolts, vsel); @@ -931,13 +933,13 @@ } - if (twl_vreg_debug) { +// if (twl_vreg_debug) { @todo XXX LIST_FOREACH(entry, &sc->sc_vreg_list, entries) { err = twl_vreg_read_regulator_voltage(sc, entry, &millivolts); if (!err) device_printf(sc->sc_dev, "%s : %d mV\n", entry->name, millivolts); } - } +// } return (0); } Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Aug 5 14:48:55 2012 (r240104) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Aug 5 15:29:47 2012 (r240105) @@ -195,9 +195,9 @@ interrupts = <56>; interrupt-parent = <&AINTC>; i2c-device-id = <1>; - pmic@48 { + pmic@24 { compatible = "ti,twl4030"; - reg = <0x48>; + reg = <0x24>; }; }; From owner-svn-soc-all@FreeBSD.ORG Sun Aug 5 16:28:37 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 301891065670 for ; Sun, 5 Aug 2012 16:28:35 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 05 Aug 2012 16:28:35 +0000 Date: Sun, 05 Aug 2012 16:28:35 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120805162835.301891065670@hub.freebsd.org> Cc: Subject: socsvn commit: r240108 - soc2012/gpf/pefs_kmod/sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2012 16:28:37 -0000 Author: gpf Date: Sun Aug 5 16:28:34 2012 New Revision: 240108 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240108 Log: -declare sysctl var vfs.pefs.exec.enable that will be used for dbg purposes while coding immutable file execution control in sys/kern/kern_exec.c Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Sun Aug 5 15:55:36 2012 (r240107) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Sun Aug 5 16:28:34 2012 (r240108) @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -618,6 +619,14 @@ .vfs_vget = pefs_vget, }; +/* XXXgpf: declare our debugging sysctl for kern_exec.c */ +SYSCTL_NODE(_vfs_pefs, OID_AUTO, exec, CTLFLAG_RW, 0, + "PEFS kern_exec.c stuff"); + +int pefs_exec_enable = 0; +SYSCTL_INT(_vfs_pefs_exec, OID_AUTO, enable, CTLFLAG_RW, + &pefs_exec_enable, 0, "Enable exec protection"); + VFS_SET(pefs_vfsops, pefs, VFCF_LOOPBACK); MODULE_DEPEND(pefs, crypto, 1, 1, 1); #ifdef PEFS_AESNI From owner-svn-soc-all@FreeBSD.ORG Sun Aug 5 19:00:56 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0923E106564A for ; Sun, 5 Aug 2012 19:00:54 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 05 Aug 2012 19:00:54 +0000 Date: Sun, 05 Aug 2012 19:00:54 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120805190054.0923E106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240113 - soc2012/gpf/pefs_head/head/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2012 19:00:56 -0000 Author: gpf Date: Sun Aug 5 19:00:53 2012 New Revision: 240113 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240113 Log: kern_exec.c hack: During an exec(), kernel checks if sysctl var "vfs.pefs.exec.enable" exists and is turned on. If it is active, we check the schg flag of the executable. For the moment, we simply print a "denied" message. Next patch will return proper error code and fail in a graceful manner. The pefs specific sysctl var is used to ease development so it's just temporary. If the file being executed is a shell script, only the respective interpreter is checked for the schg flag, not the script itself. work in progress Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Sun Aug 5 17:30:17 2012 (r240112) +++ soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Sun Aug 5 19:00:53 2012 (r240113) @@ -122,7 +122,7 @@ NULL, 0, sysctl_kern_stackprot, "I", ""); u_long ps_arg_cache_limit = PAGE_SIZE / 16; -SYSCTL_ULONG(_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW, +SYSCTL_ULONG(_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW, &ps_arg_cache_limit, 0, ""); static int map_at_zero = 0; @@ -186,9 +186,9 @@ #ifndef _SYS_SYSPROTO_H_ struct execve_args { - char *fname; + char *fname; char **argv; - char **envv; + char **envv; }; #endif @@ -548,6 +548,24 @@ goto interpret; } + { + int enabled, rval; + size_t enabled_len; + + rval = kernel_sysctlbyname(td, "vfs.pefs.exec.enable", + &enabled, &enabled_len, NULL, 0, NULL, 0); + //printf("sysctl vfs.pefs.exec.enable=%d returns %d\n", enabled, + //rval); + if (rval == 0 && enabled != 0) { + printf("checking flag for %s\n", args->fname); + if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { + printf("denied!\n"); + //error = ... + //goto exec_fail_dealloc; + } + } + } + /* * NB: We unlock the vnode here because it is believed that none * of the sv_copyout_strings/sv_fixup operations require the vnode. @@ -821,7 +839,7 @@ /* Set values passed into the program in registers. */ if (p->p_sysent->sv_setregs) - (*p->p_sysent->sv_setregs)(td, imgp, + (*p->p_sysent->sv_setregs)(td, imgp, (u_long)(uintptr_t)stack_base); else exec_setregs(td, imgp, (u_long)(uintptr_t)stack_base); @@ -1160,7 +1178,7 @@ } if ((error = copyinstr(argp, args->endp, args->stringspace, &length))) { - if (error == ENAMETOOLONG) + if (error == ENAMETOOLONG) error = E2BIG; goto err_exit; } From owner-svn-soc-all@FreeBSD.ORG Sun Aug 5 21:32:54 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 55BE5106564A for ; Sun, 5 Aug 2012 21:32:52 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 05 Aug 2012 21:32:52 +0000 Date: Sun, 05 Aug 2012 21:32:52 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120805213252.55BE5106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240116 - in soc2012/rudot/sys: kern sys X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2012 21:32:54 -0000 Author: rudot Date: Sun Aug 5 21:32:51 2012 New Revision: 240116 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240116 Log: when limiting %cpu, we act sooner than the limits are exceeded already. This makes exceeding %cpu limits less likely Modified: soc2012/rudot/sys/kern/kern_racct.c soc2012/rudot/sys/kern/kern_rctl.c soc2012/rudot/sys/sys/rctl.h Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Sun Aug 5 20:19:27 2012 (r240115) +++ soc2012/rudot/sys/kern/kern_racct.c Sun Aug 5 21:32:51 2012 (r240116) @@ -66,8 +66,19 @@ FEATURE(racct, "Resource Accounting"); +/* + * Do not block processes that have their %cpu usage <= RACCT_PCTCPU_IGNORE + */ #define RACCT_PCTCPU_IGNORE 1 +/* + * How many seconds it takes to use the scheduler %cpu calculations. When a + * process starts, we compute its %cpu usage by dividing its runtime by the + * process wall clock time. After RACCT_PCPU_SECS pass, we use the value + * provided by the scheduler. + */ +#define RACCT_PCPU_SECS 3 + struct mtx racct_lock; MTX_SYSINIT(racct_lock, &racct_lock, "racct lock", MTX_DEF); @@ -298,7 +309,7 @@ swtime = (ticks - p->p_swtick) / hz; if ((swtime == 0) || ((p->p_flag & P_INMEM) == 0)) return (0); - if (swtime < 20) { + if (swtime < RACCT_PCPU_SECS) { /* * For short-lived processes, the sched_pctcpu() returns small * values even for cpu intensive processes. Therefore we use @@ -568,8 +579,7 @@ static int racct_set_check_locked(struct proc *p, int resource, uint64_t amount) { - int64_t diff; - int over_limit; + int64_t diff, available; SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); @@ -587,9 +597,9 @@ ("racct_set: usage of non-reclaimable resource %d dropping", resource)); #endif - over_limit = 0; + available = INT64_MAX; #ifdef RCTL - over_limit = rctl_over_limit(p, resource, diff); + available = rctl_pcpu_available(p); #endif racct_alloc_resource(p->p_racct, resource, diff); if (diff > 0) @@ -597,7 +607,7 @@ else if (diff < 0) racct_sub_cred_locked(p->p_ucred, resource, -diff); - return (over_limit); + return (available <= diff); } static int @@ -1052,7 +1062,8 @@ wallclock.tv_usec); pct = racct_getpcpu(p, pct_estimate); mtx_lock(&racct_lock); - over_limits = racct_set_check_locked(p, RACCT_PCTCPU, pct); + over_limits = racct_set_check_locked(p, RACCT_PCTCPU, + pct); if (over_limits) { racct_proc_disable(p); } else if (racct_proc_disabled(p)) { Modified: soc2012/rudot/sys/kern/kern_rctl.c ============================================================================== --- soc2012/rudot/sys/kern/kern_rctl.c Sun Aug 5 20:19:27 2012 (r240115) +++ soc2012/rudot/sys/kern/kern_rctl.c Sun Aug 5 21:32:51 2012 (r240116) @@ -76,6 +76,8 @@ #define RCTL_MAX_INBUFLEN 4096 #define RCTL_LOG_BUFSIZE 128 +#define RCTL_PCPU_SHIFT 10 + /* * 'rctl_rule_link' connects a rule with every racct it's related to. * For example, rule 'user:X:openfiles:deny=N/process' is linked @@ -272,31 +274,48 @@ } /* - * Return non-zero if allocating 'amount' by proc 'p' would exceed - * 'resource' limit specified by any rule applicable to the process 'p'. - * The 'amount' can be negative. + * Special version of rctl_available() function for the %cpu resource. + * We slightly cheat here and return less than we normally would. */ -int -rctl_over_limit(const struct proc *p, int resource, int64_t amount) { +int64_t +rctl_pcpu_available(const struct proc *p) { struct rctl_rule *rule; struct rctl_rule_link *link; - int over_limit; + int64_t available, minavailable, limit; + + minavailable = INT64_MAX; + limit = 0; - over_limit = 0; rw_rlock(&rctl_lock); LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { rule = link->rrl_rule; - if (rule->rr_resource != resource) + if (rule->rr_resource != RACCT_PCTCPU) continue; - if (rctl_would_exceed(p, rule, amount)) { - over_limit = 1; - break; + if (rule->rr_action != RCTL_ACTION_DENY) + continue; + available = rctl_available_resource(p, rule); + if (available < minavailable) { + minavailable = available; + limit = rule->rr_amount; } } rw_runlock(&rctl_lock); - return (over_limit); + + /* + * Return slightly less than actual value of the available + * %cpu resource. This makes %cpu throttling more agressive + * and lets us act sooner than the limits are already exceeded. + */ + if (limit != 0) { + if (limit > 2 * RCTL_PCPU_SHIFT) + minavailable -= RCTL_PCPU_SHIFT; + else + minavailable -= (limit / 2); + } + + return (minavailable); } /* Modified: soc2012/rudot/sys/sys/rctl.h ============================================================================== --- soc2012/rudot/sys/sys/rctl.h Sun Aug 5 20:19:27 2012 (r240115) +++ soc2012/rudot/sys/sys/rctl.h Sun Aug 5 21:32:51 2012 (r240116) @@ -140,7 +140,7 @@ int rctl_rule_add(struct rctl_rule *rule); int rctl_rule_remove(struct rctl_rule *filter); int rctl_enforce(struct proc *p, int resource, uint64_t amount); -int rctl_over_limit(const struct proc *p, int resource, int64_t amount); +int64_t rctl_pcpu_available(const struct proc *p); uint64_t rctl_get_limit(struct proc *p, int resource); uint64_t rctl_get_available(struct proc *p, int resource); const char *rctl_resource_name(int resource); From owner-svn-soc-all@FreeBSD.ORG Mon Aug 6 13:02:57 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C776F106564A for ; Mon, 6 Aug 2012 13:02:55 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 06 Aug 2012 13:02:55 +0000 Date: Mon, 06 Aug 2012 13:02:55 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120806130255.C776F106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240133 - soc2012/rudot/aux X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 13:02:57 -0000 Author: rudot Date: Mon Aug 6 13:02:55 2012 New Revision: 240133 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240133 Log: delivery of signals wakes racct-sleeping thread Modified: soc2012/rudot/aux/build_kernel.sh Modified: soc2012/rudot/aux/build_kernel.sh ============================================================================== --- soc2012/rudot/aux/build_kernel.sh Mon Aug 6 11:02:23 2012 (r240132) +++ soc2012/rudot/aux/build_kernel.sh Mon Aug 6 13:02:55 2012 (r240133) @@ -1,9 +1,2 @@ -# check http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg23424.html - -if [ `hostname` != "target" ]; then - echo "You can run it only on the target machine." - exit -fi - cd /usr/src make buildkernel -DNO_MODULES -DNO_CLEAN -DNO_KERNELDEPEND KERNCONF=RCTL && make installkernel -DNO_MODULES KERNCONF=RCTL From owner-svn-soc-all@FreeBSD.ORG Mon Aug 6 13:08:22 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 430A5106566B for ; Mon, 6 Aug 2012 13:08:20 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 06 Aug 2012 13:08:20 +0000 Date: Mon, 06 Aug 2012 13:08:20 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120806130820.430A5106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240134 - soc2012/rudot/aux X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 13:08:22 -0000 Author: rudot Date: Mon Aug 6 13:08:19 2012 New Revision: 240134 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240134 Log: fixing last commit Modified: soc2012/rudot/aux/build_kernel.sh Modified: soc2012/rudot/aux/build_kernel.sh ============================================================================== --- soc2012/rudot/aux/build_kernel.sh Mon Aug 6 13:02:55 2012 (r240133) +++ soc2012/rudot/aux/build_kernel.sh Mon Aug 6 13:08:19 2012 (r240134) @@ -1,2 +1,9 @@ +# check http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg23424.html + +if [ `hostname` != "target" ]; then + echo "You can run it only on the target machine." + exit +fi + cd /usr/src make buildkernel -DNO_MODULES -DNO_CLEAN -DNO_KERNELDEPEND KERNCONF=RCTL && make installkernel -DNO_MODULES KERNCONF=RCTL From owner-svn-soc-all@FreeBSD.ORG Mon Aug 6 13:10:27 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B94EF106564A for ; Mon, 6 Aug 2012 13:10:25 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 06 Aug 2012 13:10:25 +0000 Date: Mon, 06 Aug 2012 13:10:25 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120806131025.B94EF106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240135 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 13:10:28 -0000 Author: rudot Date: Mon Aug 6 13:10:25 2012 New Revision: 240135 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240135 Log: delivery of signals wakes racct-sleeping thread Modified: soc2012/rudot/sys/kern/subr_trap.c Modified: soc2012/rudot/sys/kern/subr_trap.c ============================================================================== --- soc2012/rudot/sys/kern/subr_trap.c Mon Aug 6 13:08:19 2012 (r240134) +++ soc2012/rudot/sys/kern/subr_trap.c Mon Aug 6 13:10:25 2012 (r240135) @@ -103,6 +103,9 @@ userret(struct thread *td, struct trapframe *frame) { struct proc *p = td->td_proc; +#ifdef RACCT + int sig; +#endif CTR3(KTR_SYSC, "userret: thread %p (pid %d, %s)", td, p->p_pid, td->td_name); @@ -154,7 +157,10 @@ #ifdef RACCT mtx_lock(&racct_lock); while (racct_proc_disabled(p)) { - msleep(p->p_racct, &racct_lock, 0, "racct", 0); + sig = msleep(p->p_racct, &racct_lock, PCATCH | PBDRY, "racct", + hz); + if ((sig == EINTR) || (sig == ERESTART)) + break; } mtx_unlock(&racct_lock); #endif From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 07:28:17 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9DFAA106566B for ; Tue, 7 Aug 2012 07:28:15 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 07:28:15 +0000 Date: Tue, 07 Aug 2012 07:28:15 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807072815.9DFAA106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240166 - soc2012/gpf/pefs_head/head/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 07:28:17 -0000 Author: gpf Date: Tue Aug 7 07:28:14 2012 New Revision: 240166 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240166 Log: - abort exec if our check fails. future commit will probably turn this code snippet into a MAC hook function. Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Tue Aug 7 05:46:36 2012 (r240165) +++ soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Tue Aug 7 07:28:14 2012 (r240166) @@ -549,19 +549,17 @@ } { + /* XXXgpf: [TODO] place this in a MAC hook */ int enabled, rval; size_t enabled_len; rval = kernel_sysctlbyname(td, "vfs.pefs.exec.enable", &enabled, &enabled_len, NULL, 0, NULL, 0); - //printf("sysctl vfs.pefs.exec.enable=%d returns %d\n", enabled, - //rval); + if (rval == 0 && enabled != 0) { - printf("checking flag for %s\n", args->fname); if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { - printf("denied!\n"); - //error = ... - //goto exec_fail_dealloc; + error = EPERM; + goto exec_fail_dealloc; } } } From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 10:39:42 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id DFED3106566B for ; Tue, 7 Aug 2012 10:39:40 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 10:39:40 +0000 Date: Tue, 07 Aug 2012 10:39:40 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807103940.DFED3106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240171 - soc2012/gpf/pefs_head/head/libexec/rtld-elf X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 10:39:42 -0000 Author: gpf Date: Tue Aug 7 10:39:40 2012 New Revision: 240171 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240171 Log: - for every object that's being executed by rtld, check the schg flag, if vfs.pefs.exec.enable is turned on. Modified: soc2012/gpf/pefs_head/head/libexec/rtld-elf/rtld.c Modified: soc2012/gpf/pefs_head/head/libexec/rtld-elf/rtld.c ============================================================================== --- soc2012/gpf/pefs_head/head/libexec/rtld-elf/rtld.c Tue Aug 7 09:22:46 2012 (r240170) +++ soc2012/gpf/pefs_head/head/libexec/rtld-elf/rtld.c Tue Aug 7 10:39:40 2012 (r240171) @@ -1937,6 +1937,23 @@ return NULL; } } + /* XXXgpf: check schg flag for every object */ + { + int enabled, rval; + size_t enabled_len; + + enabled_len = sizeof(enabled); + rval = sysctlbyname("vfs.pefs.exec.enable", &enabled, + &enabled_len, 0, 0); + + if (rval == 0 && enabled != 0) { + if ((sbp->st_flags & SF_IMMUTABLE) == 0) { + _rtld_error("Cannot execute object: %s without schg\n", path); + return NULL; + } + } + } + dbg("loading \"%s\"", printable_path(path)); obj = map_object(fd, printable_path(path), sbp); if (obj == NULL) From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 15:35:19 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 98F8C106566B for ; Tue, 7 Aug 2012 15:35:18 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 15:35:18 +0000 Date: Tue, 07 Aug 2012 15:35:18 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807153518.98F8C106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240175 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 15:35:19 -0000 Author: rudot Date: Tue Aug 7 15:35:17 2012 New Revision: 240175 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240175 Log: decay %cpu in racct containers (per-user, per-loginclass and per-jail) - work inb progress Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Tue Aug 7 13:11:47 2012 (r240174) +++ soc2012/rudot/sys/kern/kern_racct.c Tue Aug 7 15:35:17 2012 (r240175) @@ -157,7 +157,9 @@ RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, [RACCT_WALLCLOCK] = RACCT_IN_MILLIONS, - [RACCT_PCTCPU] = RACCT_RECLAIMABLE | RACCT_DENIABLE }; + [RACCT_PCTCPU] = RACCT_DENIABLE }; + +static const fixpt_t RACCT_DECAY_FACTOR = 0.9 * FSCALE; #ifdef SCHED_4BSD /* @@ -579,7 +581,9 @@ static int racct_set_check_locked(struct proc *p, int resource, uint64_t amount) { - int64_t diff, available; + int64_t available; + int64_t old_amount, decayed_amount; + int64_t diff, decayed_diff; SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); @@ -591,21 +595,19 @@ /* * may be negative */ - diff = amount - p->p_racct->r_resources[resource]; -#ifdef notyet - KASSERT(diff >= 0 || RACCT_IS_RECLAIMABLE(resource), - ("racct_set: usage of non-reclaimable resource %d dropping", - resource)); -#endif + old_amount = p->p_racct->r_resources[resource]; + diff = amount - old_amount; + decayed_amount = old_amount * RACCT_DECAY_FACTOR / FSCALE; + decayed_diff = amount - decayed_amount; available = INT64_MAX; #ifdef RCTL available = rctl_pcpu_available(p); #endif racct_alloc_resource(p->p_racct, resource, diff); - if (diff > 0) - racct_add_cred_locked(p->p_ucred, resource, diff); - else if (diff < 0) - racct_sub_cred_locked(p->p_ucred, resource, -diff); + if (decayed_diff > 0) + racct_add_cred_locked(p->p_ucred, resource, decayed_diff); + else if (decayed_diff < 0) + racct_sub_cred_locked(p->p_ucred, resource, -decayed_diff); return (available <= diff); } @@ -1017,6 +1019,38 @@ } static void +racct_decay_resource(struct racct *racct, void * res, void* dummy) +{ + int resource; + int64_t r_old, r_new; + + mtx_assert(&racct_lock, MA_OWNED); + + resource = *(int *) res; + r_old = racct->r_resources[resource]; + + /* If there is nothing to decay, just exit. */ + if (r_old <= 0) + return; + + r_new = r_old * RACCT_DECAY_FACTOR / FSCALE; + racct->r_resources[resource] = r_new; +} + +static void +racct_decay_pcpu(void) +{ + int resource; + + mtx_assert(&racct_lock, MA_OWNED); + + resource = RACCT_PCTCPU; + ui_racct_foreach(racct_decay_resource, &resource, NULL); + loginclass_racct_foreach(racct_decay_resource, &resource, NULL); + prison_racct_foreach(racct_decay_resource, &resource, NULL); +} + +static void racctd(void) { struct thread *td; @@ -1027,6 +1061,10 @@ int over_limits; for (;;) { + mtx_lock(&racct_lock); + racct_decay_pcpu(); + mtx_unlock(&racct_lock); + sx_slock(&allproc_lock); LIST_FOREACH(p, &zombproc, p_list) { From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 19:26:05 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9BBBA106564A for ; Tue, 7 Aug 2012 19:26:03 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 19:26:03 +0000 Date: Tue, 07 Aug 2012 19:26:03 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807192603.9BBBA106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240177 - in soc2012/gmiller/locking-head: . lib/libthr/thread X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 19:26:05 -0000 Author: gmiller Date: Tue Aug 7 19:26:02 2012 New Revision: 240177 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240177 Log: r240208@FreeBSD-dev: root | 2012-07-25 03:47:07 -0500 Add XML output for lock profiling data. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Tue Aug 7 18:50:33 2012 (r240176) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Tue Aug 7 19:26:02 2012 (r240177) @@ -73,9 +73,90 @@ }; static int lockprof_enabled; +static int xml_indent = 0; +static FILE *xml_file; + +static void +indent(void) +{ + int i; + + for (i = 0; i < xml_indent; i++) { + fputc(' ', xml_file); + } +} + +static void +open_element(const char *tag) +{ + indent(); + fprintf(xml_file, "<%s>\n", tag); + + xml_indent += 2; +} + +static void +close_element(const char *tag) +{ + xml_indent -= 2; + + indent(); + fprintf(xml_file, "\n", tag); +} + +static void +write_element_string(const char *tag, const char *str) +{ + indent(); + fprintf(xml_file, "<%s>%s\n", tag, str, tag); +} + +static void +write_element_numeric(const char *tag, long value) +{ + indent(); + fprintf(xml_file, "<%s>%ld\n", tag, value, tag); +} + +static void +write_element_timespec(const char *tag, struct timespec *ts) +{ + long tm; + + tm = ts->tv_sec * 1000000L + ts->tv_nsec / 1000; + write_element_numeric(tag, tm); + +} + +static void +write_xml(void) +{ + struct pthread_statistics_np stats; + + xml_file = fopen("lockprof.xml", "wt"); + + open_element("lockprof"); + + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { + write_element_string("file", stats.file); + write_element_numeric("line", stats.line); + write_element_timespec("wait_max", &stats.wait_max); + write_element_timespec("hold_max", &stats.hold_max); + write_element_numeric("contest_count", stats.contest_count); + write_element_timespec("wait_time", &stats.wait_time); + write_element_timespec("hold_time", &stats.hold_time); + write_element_numeric("acq_count", stats.acq_count); + } + pthread_statistics_end_np(&stats); + + close_element("lockprof"); + + fclose(xml_file); +} void -_lock_profile_init() +_lock_profile_init(void) { int i; @@ -84,6 +165,8 @@ } lockprof_enabled = 1; + + atexit(write_xml); } static struct acquisition * From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 19:26:25 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id AC1DC106567C for ; Tue, 7 Aug 2012 19:26:23 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 19:26:23 +0000 Date: Tue, 07 Aug 2012 19:26:23 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807192623.AC1DC106567C@hub.freebsd.org> Cc: Subject: socsvn commit: r240178 - in soc2012/gmiller/locking-head: . include lib/libwitness tools/regression/lib/libthr/lockprof tools/regression/lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 19:26:25 -0000 Author: gmiller Date: Tue Aug 7 19:26:23 2012 New Revision: 240178 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240178 Log: r240239@FreeBSD-dev: root | 2012-07-25 09:06:18 -0500 Add XML output file to libwitness. Added: soc2012/gmiller/locking-head/lib/libwitness/xml.c Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/Makefile soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/include/pthread_np.h Tue Aug 7 19:26:23 2012 (r240178) @@ -73,6 +73,7 @@ struct pthread_lockorder_np { struct _pthread_lockorder_private *_pvt; void *lock; + char *name; void *child; void *sibling; }; Modified: soc2012/gmiller/locking-head/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/Makefile Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/lib/libwitness/Makefile Tue Aug 7 19:26:23 2012 (r240178) @@ -4,7 +4,7 @@ LIB= witness SHLIB_MAJOR= 1 -SRCS= wrappers.c graph.c lists.c logs.c lockinfo.c +SRCS= wrappers.c graph.c lists.c logs.c lockinfo.c xml.c DPADD= ${LIBTHR} LDADD= -lthr Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Tue Aug 7 19:26:23 2012 (r240178) @@ -35,8 +35,9 @@ static _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head = SLIST_HEAD_INITIALIZER(lock_head); -static int reset_count = 0; +static int reset_count = 0; static _Thread_local int thread_reset_count = 0; +static int exit_set = 0; void add_lock(struct lock_info *lock) @@ -44,6 +45,11 @@ struct lock_entry *entry; struct lock_entry *next; + if (exit_set == 0) { + atexit(write_xml); + exit_set = 1; + } + if (lock == NULL) { return; } Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Aug 7 19:26:23 2012 (r240178) @@ -162,6 +162,7 @@ ret = ENOMEM; } else { node->_pvt->last_record = NULL; + node->name = NULL; } pthread_mutex_unlock(&witness_mtx); @@ -172,35 +173,50 @@ int pthread_lockorder_next_np(struct pthread_lockorder_np *node) { - if (node->_pvt != NULL) { - if (node->_pvt->last_record == NULL) { - node->_pvt->last_record = SLIST_FIRST(&lock_info_head); - } else { - node->_pvt->last_record = - SLIST_NEXT(node->_pvt->last_record, - lock_info_next); - } - - if (node->_pvt->last_record != NULL) { - node->lock = node->_pvt->last_record->lock; - if (node->_pvt->last_record->child != NULL) { - node->child = - node->_pvt->last_record->child->lock; - } else { - node->child = NULL; - } - if (node->_pvt->last_record->sibling != NULL) { - node->sibling = - node->_pvt->last_record->sibling->lock; - } else { - node->sibling = NULL; - } + if (node->_pvt == NULL) { + return (0); + } + + if (node->_pvt->last_record == NULL) { + node->_pvt->last_record = SLIST_FIRST(&lock_info_head); + } else { + node->_pvt->last_record = + SLIST_NEXT(node->_pvt->last_record, lock_info_next); + } + + if (node->_pvt->last_record == NULL) { + return (0); + } + + /* + The lock isn't needed to prevent races, but it is needed to ensure + that any locks grabbed for memory allocation don't get logged. + */ + pthread_mutex_lock(&witness_mtx); + + if (node->name != NULL) { + free(node->name); + node->name = NULL; + } - return (1); - } + node->lock = node->_pvt->last_record->lock; + if (node->_pvt->last_record->name != NULL) { + node->name = strdup(node->_pvt->last_record->name); + } + if (node->_pvt->last_record->child != NULL) { + node->child = node->_pvt->last_record->child->lock; + } else { + node->child = NULL; + } + if (node->_pvt->last_record->sibling != NULL) { + node->sibling = node->_pvt->last_record->sibling->lock; + } else { + node->sibling = NULL; } - return (0); + pthread_mutex_unlock(&witness_mtx); + + return (1); } void @@ -208,4 +224,9 @@ { free(node->_pvt); node->_pvt = NULL; + + if (node->name != NULL) { + free((char *)node->name); + node->name = NULL; + } } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Aug 7 19:26:23 2012 (r240178) @@ -67,3 +67,5 @@ int blessed(struct lock_info *first, struct lock_info *second); void reset_lock_info(void); void check_default_name(struct lock_info *lock, const char *prefix); + +void write_xml(void); Added: soc2012/gmiller/locking-head/lib/libwitness/xml.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/lib/libwitness/xml.c Tue Aug 7 19:26:23 2012 (r240178) @@ -0,0 +1,134 @@ +/*- + * Copyright (c) 2012 Greg Miller .. + * 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. + * + */ + +#include +#include + +#include "witness.h" + +static int xml_indent = 0; +static FILE *xml_file; + +static void +indent(void) +{ + int i; + + for (i = 0; i < xml_indent; i++) { + fputc(' ', xml_file); + } +} + +static void +open_element(const char *tag) +{ + indent(); + fprintf(xml_file, "<%s>\n", tag); + + xml_indent += 2; +} + +static void +close_element(const char *tag) +{ + xml_indent -= 2; + + indent(); + fprintf(xml_file, "\n", tag); +} + +static void +write_element_string(const char *tag, const char *str) +{ + indent(); + fprintf(xml_file, "<%s>%s\n", tag, str, tag); +} + +static void +write_element_pointer(const char *tag, void *ptr) +{ + indent(); + fprintf(xml_file, "<%s>%p\n", tag, ptr, tag); +} + +void +write_xml(void) +{ + struct pthread_lor_np lor; + struct pthread_lockorder_np node; + + xml_file = fopen("witness.xml", "wt"); + + open_element("witness"); + + open_element("log"); + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + open_element("lor"); + + open_element("first"); + write_element_pointer("address", lor.lock_first); + write_element_string("name", lor.name_first); + close_element("first"); + + open_element("second"); + write_element_pointer("address", lor.lock_second); + write_element_string("name", lor.name_second); + close_element("second"); + + close_element("lor"); + } + pthread_lor_end_np(&lor); + + close_element("log"); + + open_element("graph"); + + pthread_lockorder_begin_np(&node); + while (pthread_lockorder_next_np(&node)) { + open_element("node"); + + write_element_pointer("address", node.lock); + write_element_string("name", node.name); + if (node.child != NULL) { + write_element_pointer("child", node.child); + } + if (node.sibling != NULL) { + write_element_pointer("sibling", node.sibling); + } + + close_element("node"); + } + pthread_lockorder_end_np(&node); + + close_element("graph"); + + close_element("witness"); + + fclose(xml_file); +} Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Tue Aug 7 19:26:23 2012 (r240178) @@ -9,7 +9,7 @@ .PHONY: clean clean: - -rm -f ${TESTS} + -rm -f ${TESTS} lockprof.xml lock-cycle: lock-cycle.c check.c ${CC} -o lock-cycle lock-cycle.c check.c ${CFLAGS} Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Tue Aug 7 19:26:02 2012 (r240177) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Tue Aug 7 19:26:23 2012 (r240178) @@ -9,7 +9,7 @@ .PHONY: clean clean: - -rm -f ${TESTS} + -rm -f ${TESTS} witness.xml lor-basic: lor-basic.c check.c ${CC} -o lor-basic lor-basic.c check.c ${CFLAGS} From owner-svn-soc-all@FreeBSD.ORG Tue Aug 7 20:16:57 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8DBDD1065672 for ; Tue, 7 Aug 2012 20:16:55 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 07 Aug 2012 20:16:55 +0000 Date: Tue, 07 Aug 2012 20:16:55 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120807201655.8DBDD1065672@hub.freebsd.org> Cc: Subject: socsvn commit: r240179 - in soc2012/aleek/beaglexm-armv6/sys: arm/ti arm/ti/twl boot/fdt/dts X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Aug 2012 20:16:57 -0000 Author: aleek Date: Tue Aug 7 20:16:54 2012 New Revision: 240179 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240179 Log: fixed twl driver issues. Now, TWL seems to work fine Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Tue Aug 7 19:26:23 2012 (r240178) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Tue Aug 7 20:16:54 2012 (r240179) @@ -180,6 +180,7 @@ static inline uint16_t ti_i2c_read_2(struct ti_i2c_softc *sc, bus_size_t off) { + //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); return bus_read_2(sc->sc_mem_res, off); } @@ -198,6 +199,7 @@ static inline void ti_i2c_write_2(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val) { + //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); bus_write_2(sc->sc_mem_res, off, val); } @@ -218,6 +220,7 @@ ti_i2c_read_reg(struct ti_i2c_softc *sc, bus_size_t off) { /* XXXOMAP3: FIXME add registers mapping here */ + //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); return bus_read_2(sc->sc_mem_res, off); } @@ -237,6 +240,7 @@ static inline void ti_i2c_write_reg(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val) { + //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); /* XXXOMAP3: FIXME add registers mapping here */ bus_write_2(sc->sc_mem_res, off, val); } @@ -260,9 +264,12 @@ ti_i2c_set_intr_enable(struct ti_i2c_softc *sc, uint16_t ie) { /* XXXOMAP3: FIXME */ + ti_i2c_write_2(sc, I2C_REG_IE, ie); + /* ti_i2c_write_2(sc, I2C_REG_IRQENABLE_CLR, 0xffff); if (ie) ti_i2c_write_2(sc, I2C_REG_IRQENABLE_SET, ie); + */ } /** @@ -1082,7 +1089,8 @@ /* XXXOMAP3: FIXME get proper revision here */ /* First read the version number of the I2C module */ - sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff; + //@todo aleek fix this change cause dmarion will be pissed ;) + sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_LO) & 0xff; device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4, sc->sc_rev & 0xf); Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h Tue Aug 7 19:26:23 2012 (r240178) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.h Tue Aug 7 20:16:54 2012 (r240179) @@ -34,7 +34,7 @@ * Simply contains register bit flags. */ -#if defined(SOC_TI_AM37X) || defined(SOC_OMAP4) +#if defined(SOC_TI_AM335X) || defined(SOC_OMAP4) /* * OMAP4 I2C Registers, Summary 1 @@ -114,8 +114,8 @@ #elif defined( SOC_TI_AM37X ) || defined( SOC_OMAP3 ) -#define I2C_REV 0x00 -#define I2C_IE 0x04 +#define I2C_REG_REV 0x00 +#define I2C_REG_IE 0x04 #define I2C_IE_XDR (1UL << 14) /* Transmit draining interrupt */ #define I2C_IE_RDR (1UL << 13) /* Receive draining interrupt */ #define I2C_IE_AAS (1UL << 9) /* Addressed as Slave interrupt */ @@ -128,7 +128,7 @@ #define I2C_IE_ARDY (1UL << 2) /* Register Access Ready interrupt */ #define I2C_IE_NACK (1UL << 1) /* No Acknowledgment interrupt */ #define I2C_IE_AL (1UL << 0) /* Arbitration Lost interrupt */ -#define I2C_STAT 0x08 +#define I2C_REG_STAT 0x08 #define I2C_STAT_XDR (1UL << 14) #define I2C_STAT_RDR (1UL << 13) #define I2C_STAT_BB (1UL << 12) @@ -144,11 +144,11 @@ #define I2C_STAT_ARDY (1UL << 2) #define I2C_STAT_NACK (1UL << 1) #define I2C_STAT_AL (1UL << 0) -#define I2C_SYSS 0x10 -#define I2C_BUF 0x14 -#define I2C_CNT 0x18 -#define I2C_DATA 0x1C -#define I2C_CON 0x24 +#define I2C_REG_SYSS 0x10 +#define I2C_REG_BUF 0x14 +#define I2C_REG_CNT 0x18 +#define I2C_REG_DATA 0x1C +#define I2C_REG_CON 0x24 #define I2C_CON_I2C_EN (1UL << 15) #define I2C_CON_OPMODE_STD (0UL << 12) #define I2C_CON_OPMODE_HS (1UL << 12) @@ -165,21 +165,22 @@ #define I2C_CON_STP (1UL << 1) #define I2C_CON_STT (1UL << 0) -#define I2C_OA0 0x28 -#define I2C_SA 0x2C -#define I2C_PSC 0x30 -#define I2C_SCLL 0x34 -#define I2C_SCLH 0x38 -#define I2C_SYSTEST 0x3C -#define I2C_BUFSTAT 0x40 -#define I2C_OA1 0x44 -#define I2C_OA2 0x48 -#define I2C_OA3 0x4C -#define I2C_ACTOA 0x50 -#define I2C_SBLOCK 0x54 +#define I2C_REG_OA0 0x28 +#define I2C_REG_SA 0x2C +#define I2C_REG_PSC 0x30 +#define I2C_REG_SCLL 0x34 +#define I2C_REG_SCLH 0x38 +#define I2C_REG_SYSTEST 0x3C +#define I2C_REG_BUFSTAT 0x40 +#define I2C_REG_OA1 0x44 +#define I2C_REG_OA2 0x48 +#define I2C_REG_OA3 0x4C +#define I2C_REG_ACTOA 0x50 +#define I2C_REG_SBLOCK 0x54 -#define I2C_OMAP3_SYSC 0x20 -#define I2C_OMAP4_SYSC 0x10 +#define I2C_REG_SYSC 0x20 +#define I2C_REG_REVNB_LO 0x00 +#define I2C_REG_REVNB_HI 0x04 #endif Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Tue Aug 7 19:26:23 2012 (r240178) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Tue Aug 7 20:16:54 2012 (r240179) @@ -558,6 +558,7 @@ int err; uint8_t vsel; int xlocked; + device_printf( sc->sc_dev, "%s\n", __FUNCTION__ ); TWL_VREG_ASSERT_LOCKED(sc); @@ -626,6 +627,7 @@ int en = 0; int xlocked; uint8_t vsel; + device_printf( sc->sc_dev, "%s\n", __FUNCTION__ ); TWL_VREG_ASSERT_LOCKED(sc); @@ -829,12 +831,14 @@ struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); struct twl_regulator_entry *new; + device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); new = malloc(sizeof(struct twl_regulator_entry), M_DEVBUF, M_NOWAIT | M_ZERO); if (new == NULL) return (NULL); + device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); strncpy(new->name, name, TWL_VREG_MAX_NAMELEN); new->name[TWL_VREG_MAX_NAMELEN - 1] = '\0'; @@ -847,6 +851,7 @@ new->num_supp_voltages = num_voltages; + device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Add a sysctl entry for the voltage */ new->oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, name, CTLTYPE_INT | CTLFLAG_RD, sc, 0, Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Tue Aug 7 19:26:23 2012 (r240178) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Tue Aug 7 20:16:54 2012 (r240179) @@ -186,7 +186,6 @@ mmchs-device-id = <1>; }; - i2c1: i2c@48070000 { #address-cells = <1>; #size-cells = <0>; @@ -195,9 +194,9 @@ interrupts = <56>; interrupt-parent = <&AINTC>; i2c-device-id = <1>; - pmic@24 { + pmic@48 { compatible = "ti,twl4030"; - reg = <0x24>; + reg = <0x48>; }; }; From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 04:42:27 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0F2F0106564A for ; Wed, 8 Aug 2012 04:42:25 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 04:42:25 +0000 Date: Wed, 08 Aug 2012 04:42:25 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808044225.0F2F0106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240184 - soc2012/tzabal/server-side/akcrs-setup X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 04:42:27 -0000 Author: tzabal Date: Wed Aug 8 04:42:24 2012 New Revision: 240184 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240184 Log: Modification on the database schema and on the installation guide. Modified: soc2012/tzabal/server-side/akcrs-setup/database.sql soc2012/tzabal/server-side/akcrs-setup/setup Modified: soc2012/tzabal/server-side/akcrs-setup/database.sql ============================================================================== --- soc2012/tzabal/server-side/akcrs-setup/database.sql Wed Aug 8 00:20:30 2012 (r240183) +++ soc2012/tzabal/server-side/akcrs-setup/database.sql Wed Aug 8 04:42:24 2012 (r240184) @@ -3,22 +3,22 @@ * for the PostgreSQL DBMS */ -DROP TABLE Reports; -DROP TABLE Bugs; -DROP TABLE Submitters; +DROP TABLE reports; +DROP TABLE bugs; +DROP TABLE submitters; -CREATE TABLE Submitters +CREATE TABLE submitters ( id serial NOT NULL, email varchar(254) NOT NULL, - password varchar(64) NOT NULL, + password char(64) NOT NULL, CONSTRAINT submitters_pkey PRIMARY KEY (id) ); -CREATE TABLE Bugs +CREATE TABLE bugs ( id serial NOT NULL, state varchar(10) NOT NULL, @@ -28,12 +28,13 @@ ); -CREATE TABLE Reports +CREATE TABLE reports ( id serial NOT NULL, bug_id integer NOT NULL, submitter_id integer NOT NULL, received_date date DEFAULT CURRENT_DATE, + confirmation_code char(16) NOT NULL, confirmed boolean DEFAULT false, crashtype text, crashdate text, @@ -44,6 +45,8 @@ machine text, panic text, backtrace text, + top_significant_func text, + rem_significant_funcs text[], ps_axl text, vmstat_s text, vmstat_m text, @@ -71,4 +74,4 @@ CONSTRAINT reports_submitter_id_fkey FOREIGN KEY (submitter_id) REFERENCES Submitters (id) ); -INSERT INTO Bugs (id, state, reported) VALUES (-1, 'Unknown', 0); +INSERT INTO bugs (id, state, reported) VALUES (-1, 'Unknown', -1); \ No newline at end of file Modified: soc2012/tzabal/server-side/akcrs-setup/setup ============================================================================== --- soc2012/tzabal/server-side/akcrs-setup/setup Wed Aug 8 00:20:30 2012 (r240183) +++ soc2012/tzabal/server-side/akcrs-setup/setup Wed Aug 8 04:42:24 2012 (r240184) @@ -29,6 +29,9 @@ # Create an auxiliary directory used for various actions mkdir /tmp/crashreports +# Create a directory where the invalid crash reports will be keeped for debugging purposes +mkdir /tmp/crashreports/invalidreports + # Make sure that the OpenSSH daemon is enabled cat /etc/rc.conf | grep 'sshd_enable="YES"' @@ -66,7 +69,43 @@ ########################################################### # Part 2. Apache ########################################################### +# Install the default and the most widely used version of the Apache HTTP Server in FreeBSD (Apache HTTP Server 2.2.22) +cd /usr/ports/www/apache22 + +# Make any necessary configuration (THREADS selected) +make config + +# Build, install and clean +make install clean + +# Launch Apache at system startup +echo 'apache22_enable="YES"' >> /etc/rc.conf + +# Create a copy of the original configuration file +cp -v /usr/local/etc/apache22/httpd.conf /usr/local/etc/apache22/httpd.conf.original + +# Check the Apache configuration for errors. Do this the first time or after every change of the configuration file. +/usr/local/etc/rc.d/apache22 configtest + +# Install the Apache module for WSGI +cd /usr/ports/www/mod_wsgi3 +make install clean + +# Create a directory for the WSGI scripts +mkdir /usr/local/www/apache22/wsgi-scripts + +# Place the WSGI script inside the WSGI directory +cp -v /home/tzabal/confirm_report.wsgi /usr/local/www/apache22/wsgi-scripts + +# Set proper permissions (others need to have execute permissions) +chmod 755 /usr/local/www/apache22/wsgi-scripts/confirm_report.wsgi +# Make the WSGI script accessible +echo "WSGIScriptAlias /confirm_report /usr/local/www/apache22/wsgi-scripts/confirm_report.wsgi" >> /usr/local/etc/apache22/httpd.conf +echo "" >> /usr/local/etc/apache22/httpd.conf +echo " Order allow,deny" >> /usr/local/etc/apache22/httpd.conf +echo " Allow from all" >> /usr/local/etc/apache22/httpd.conf +echo "" >> /usr/local/etc/apache22/httpd.conf ########################################################### From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 04:52:06 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 60279106564A for ; Wed, 8 Aug 2012 04:52:05 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 04:52:05 +0000 Date: Wed, 08 Aug 2012 04:52:05 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808045205.60279106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240185 - in soc2012/tzabal/server-side: akcrs-handler akcrs-release/9.0.0/usr.sbin/crashreportd X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 04:52:06 -0000 Author: tzabal Date: Wed Aug 8 04:52:04 2012 New Revision: 240185 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240185 Log: Implementation of the Recognize phase and complete reorganization of the crashreportd program. The single /usr/sbin/crashreportd module has been divided in several modules that lie under the server-side/akcrs-handler directory. Added: soc2012/tzabal/server-side/akcrs-handler/ soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi (contents, props changed) soc2012/tzabal/server-side/akcrs-handler/crashreport.py soc2012/tzabal/server-side/akcrs-handler/database.py soc2012/tzabal/server-side/akcrs-handler/main.py soc2012/tzabal/server-side/akcrs-handler/settings.py Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Added: soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi Wed Aug 8 04:52:04 2012 (r240185) @@ -0,0 +1,49 @@ +import urlparse +# Importing the cgi module leads to an error when accessing the web page +#from cgi import escape + +import database + +def application(environ, start_response): + response_body = 'Invalid confirmation code.' + + db = database.Database() + if not db.connection: + response_body = 'Could not connect to database.' + + if environ['REQUEST_METHOD'] == 'GET': + + parameters = urlparse.parse_qs(environ['QUERY_STRING']) + + if 'id' in parameters and 'code' in parameters: + report_id = parameters['id'][0] + code = parameters['code'][0] + + db.query = ('SELECT 1' + 'FROM reports ' + 'WHERE id = %s AND confirmation_code = %s AND ' + 'confirmed = %s') + db.values = (report_id, code, False) + + if not db.execute_query(): + response_body = 'Could not execute the query.' + + if db.cursor.rowcount == 1: + db.query = 'UPDATE Reports SET confirmed = %s WHERE id = %s' + db.values = (True, id) + + if not db.execute_query(): + response_body = 'Could not execute the query.' + + db.save() + db.cursor.close() + db.connection.close() + + response_body = 'Your report has been confirmed succesfully.' + + status = '200 OK' + response_headers = [('Content-type', 'text/html')] + + start_response(status, response_headers) + + return [response_body] Added: soc2012/tzabal/server-side/akcrs-handler/crashreport.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-handler/crashreport.py Wed Aug 8 04:52:04 2012 (r240185) @@ -0,0 +1,130 @@ +import logging +import os +import re +import tarfile +from StringIO import StringIO + +from lxml import etree + +class CrashReport(object): + """This class represents a crash report.""" + + valid_name = re.compile('^crashreport\.[A-Za-z0-9]{6}\.tar\.gz$') + + def __init__(self, path): + name = os.path.basename(path) + + self.name = name + self.path = path + self.confirmation_code = None + self.data = CrashData() + + + def has_valid_name(self): + """Returns True is the report's name matches the name of a valid crash + report. Otherwise it returns implicit False.""" + match = re.match(self.__class__.valid_name, self.name) + + if not match: + logging.info('Invalid crash report name: %s' % self.name) + return + + return True + + + def has_valid_type(self): + """Returns True if the report's file type matches the file type of a + valid crash report. Otherwise it returns implicit False.""" + if not tarfile.is_tarfile(self.path): + logging.info('The report %s cannot be read from the tarfile module' + % self.path) + return + + try: + tarfileobj = tarfile.open(self.path, 'r:gz') + except tarfile.ReadError: + logging.info('The provided mode is not suitable to open for reading' + ' the report %s' % self.path) + return + except tarfile.CompressionError: + logging.info('The compression method for the report %s is not ' + 'supported' % self.path) + return + finally: + tarfileobj.close() + + return True + + + def has_valid_contents_number(self): + """Returns True is the report contains the same number of files that a + valid crash report has. Othewise it returns implicit False.""" + try: + tarfileobj = tarfile.open(self.path, 'r:gz') + except tarfile.ReadError: + return + except tarfile.CompressionError: + return + else: + contents_list = tarfileobj.getnames() + if not len(contents_list) == 1: + logging.info('The report %s has invalid number of contents' + % self.path) + return + self.data.name = contents_list[0] + finally: + tarfileobj.close() + + return True + + + +class CrashData(object): + """This class represents the crash data that a crash report contains.""" + + valid_name = re.compile('^crashreport\.[A-Za-z0-9]{6}\.xml$') + + def __init__(self): + self.name = None + self.path = None + self.info = {} + self.commands = {} + + + def has_valid_name(self): + """Returns True if the report's crash data name matches the name of a + valid crash data. Otherwise it returns implicit False.""" + match = re.match(self.__class__.valid_name, self.name) + + if not match: + logging.info('Invalid crash data name: %s' % self.name) + return + + return True + + + def has_valid_crashdata(self): + """Returns True if the crash data is a well formed and valid XML file. + Otherwise implicit False.""" + dtdfile = StringIO(""" + + + + + + """) + + try: + elemtree = etree.parse(self.path) + except: + logging.info('%s is not a well formed crash report data.' % + (self.path)) + return + else: + dtd = etree.DTD(dtdfile) + if not dtd.validate(elemtree): + logging.info('%s is not a valid crash report data.' % + (self.path)) + return + + return True \ No newline at end of file Added: soc2012/tzabal/server-side/akcrs-handler/database.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-handler/database.py Wed Aug 8 04:52:04 2012 (r240185) @@ -0,0 +1,40 @@ +import logging +import psycopg2 + +import settings + +class Database: + + def __init__(self): + try: + self.connection = psycopg2.connect(database=settings.DBNAME, + host=settings.DBHOST, + user=settings.DBUSER, + password=settings.DBPASS) + except: + self.connection = None + logging.error('Could not connect to the database') + else: + self.cursor = self.connection.cursor() + + self.query = None + self.values = None + + def execute_query(self): + try: + if self.values: + self.cursor.execute(self.query, self.values) + else: + self.cursor.execute(self.query) + except Exception, err: + logging.info('Could not execute the query: %s' % self.query) + logging.info(err.pgerror) + return + + self.query = None + self.values = None + + return True + + def save(self): + self.connection.commit() \ No newline at end of file Added: soc2012/tzabal/server-side/akcrs-handler/main.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-handler/main.py Wed Aug 8 04:52:04 2012 (r240185) @@ -0,0 +1,497 @@ +import difflib +import hashlib +import logging +import os +import random +import shutil +import smtplib +import string +import tarfile +import time +from email.mime.text import MIMEText + +from lxml import etree + +import crashreport +import database +import settings + + +db = database.Database() + + +def move_invalid_report(path): + if not os.path.isfile(path): + return + + if not os.path.isdir(settings.INVALID_REPORTS_DIR): + logging.error('Invalid reports directory does not exist') + return + + shutil.move(path, settings.INVALID_REPORTS_DIR) + + +def send_confirmation_email(report): + smtpserver = settings.SMTPSERVER + sender = settings.SENDER + receiver = report.data.info['email'] + subject = settings.SUBJECT + text = settings.TEXT % (report.id, report.confirmation_code) + + message = MIMEText(text) + message['From'] = sender + message['To'] = receiver + message['Subject'] = subject + + try: + smtpconn = smtplib.SMTP(smtpserver) + smtpconn.sendmail(sender, receiver, message.as_string()) + except smtplib.SMTPException, err: + logging.info(err) + return + finally: + smtpconn.quit() + + return True + + +def generate_random_string(size): + """Generates and returns a random string of the specified size. + + The string is a sequence of characters that are chosen randomly from a set + that contains digits, lowercase and uppercase letters. + """ + chars = string.letters + string.digits + return ''.join(random.choice(chars) for ch in range(size)) + + +def store_report(report): + # Bugs + if report.bug_id == -1: + db.query = ('INSERT INTO bugs (state, reported) ' + 'VALUES (%s, %s) ' + 'RETURNING id') + db.values = ('Open', 0) + + if not db.execute_query(): + return + + report.bug_id = db.cursor.fetchone() + db.save() + elif type(report.bug_id) == type([]): + report.bug_id = -1 + + # Submitters + db.query = 'SELECT id FROM submitters WHERE email = %s' + db.values = (report.data.info['email'], ) + + if not db.execute_query(): + return + + if db.cursor.rowcount: + report.submitter_id = db.cursor.fetchone() + else: + password = generate_random_string(8) + hashobj = hashlib.sha256() + hashobj.update(password) + hashpass = hashobj.hexdigest() + + db.query = ('INSERT INTO submitters (email, password) ' + 'VALUES (%s, %s)' + 'RETURNING id') + db.values = (report.data.info['email'], hashpass) + + if not db.execute_query(): + return + + report.submitter_id = db.cursor.fetchone() + db.save() + + # Reports + report.confirmation_code = generate_random_string(16) + + db.query = """INSERT INTO reports (bug_id, submitter_id, confirmation_code, + crashtype, crashdate, hostname, ostype, osrelease, version, machine, panic, + backtrace, top_significant_func, rem_significant_funcs, ps_axl, vmstat_s, + vmstat_m, vmstat_z, vmstat_i, pstat_T, pstat_s, iostat, ipcs_a, ipcs_T, + nfsstat, netstat_s, netstat_m, netstat_id, netstat_anr, netstat_anA, + netstat_aL, fstat, dmesg, kernelconfig, ddbcapturebuffer) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) + RETURNING id""" + + db.values = (report.bug_id, + report.submitter_id, + report.confirmation_code, + report.data.commands['crashtype'], + report.data.commands['crashdate'], + report.data.commands['hostname'], + report.data.commands['ostype'], + report.data.commands['osrelease'], + report.data.commands['version'], + report.data.commands['machine'], + report.data.commands['panic'], + report.data.commands['backtrace'], + report.top_significant_func, + report.rem_significant_funcs, + report.data.commands['ps_axl'], + report.data.commands['vmstat_s'], + report.data.commands['vmstat_m'], + report.data.commands['vmstat_z'], + report.data.commands['vmstat_i'], + report.data.commands['pstat_T'], + report.data.commands['pstat_s'], + report.data.commands['iostat'], + report.data.commands['ipcs_a'], + report.data.commands['ipcs_T'], + report.data.commands['nfsstat'], + report.data.commands['netstat_s'], + report.data.commands['netstat_m'], + report.data.commands['netstat_id'], + report.data.commands['netstat_anr'], + report.data.commands['netstat_anA'], + report.data.commands['netstat_aL'], + report.data.commands['fstat'], + report.data.commands['dmesg'], + report.data.commands['kernelconfig'], + report.data.commands['ddbcapturebuffer']) + + if not db.execute_query(): + return + + report.id = db.cursor.fetchone() + db.save() + + return True + + +def uniqify_sequence(seq): + """Takes a sequence of elements and returns a sequence with only unique + elements. (Taken from http://www.peterbe.com/plog/uniqifiers-benchmark)""" + keys = {} + for e in seq: + keys[e] = 1 + return keys.keys() + + +def allocate_values(length): + """Takes an integer as input and returns a list with length equals to that + integer plus one. The list contains values that are allocated in an + increment and symmetric way, and the first index of the list (i.e zero) is + not used (is None). The values are calculated using the length of the list + and the constant REMAINING_FRAMES_MAX_PERC.""" + # Average value + avg = settings.REMAINING_FRAMES_MAX_PERC / length + + # Divide the list in 2 sets + elems_per_set = length // 2 + + # Initialize the list (need to access the middle element afterwards) + values = [None] * (length + 1) + + # Handle even and odd lengths + if length % 2 == 0: + # Auxiliary variable for swapping between the two sets + aux = 1 + else: + aux = 2 + # If odd, then the average value to the middle element + values[elems_per_set + 1] = avg + + # How the values will be allocated + diff = 1 + # Increment and symmetric allocation of values + for i in range(elems_per_set, 0, -1): + values[i] = avg + diff + values[i+aux] = avg - diff + aux += 2 + diff += 1 + + return values + + +def contains_any(str, set): + """Returns True if the string str contains any of the elements found + in the iterable set.""" + for elem in set: + if elem in str: + return True + + return + + +def get_significant_funcs(backtrace): + """Takes a backtrace as a string and returns a list that + contains only the function names of the most significant stack frames.""" + + # Store every stack frame of the backtrace in a separate line + backtrace = backtrace.splitlines() + + # For every stack frame store only the function name + backtrace[0] = backtrace[0].split()[1] + for index, stackframe in enumerate(backtrace[1:], 1): + backtrace[index] = stackframe.split()[3] + + # Find the most significant stack frames and store only the function names + hit_significant = False + significant_funcs = [] + insignificant_funcs = ('syscall', 'panic', 'trap', 'lock', 'sleep', '??') + for func in reversed(backtrace): + if not contains_any(func, insignificant_funcs): + hit_significant = True + significant_funcs.append(func) + else: + if hit_significant: + break + significant_funcs.reverse() + + return significant_funcs + + +def recognize_report(report): + # Calculate the significant functions of the report + significant_funcs = get_significant_funcs(report.data.commands['backtrace']) + report.top_significant_func = significant_funcs[0] + report.rem_significant_funcs = significant_funcs[1:] + + # Retrieve from the database the confirmed reports + db.query = ('SELECT bug_id, panic, top_significant_func, rem_significant_funcs ' + 'FROM Reports ' + 'WHERE confirmed = true') + if not db.execute_query(): + return + loggedreports = db.cursor.fetchall() + + # A list that contains the percentages of similarity of the examined report + # with all the others retrieved from the database + sims = [[None for i in range(2)] for j in range(db.cursor.rowcount)] + + # Check the examined report against all the retrieved reports + for index, loggedreport in enumerate(loggedreports): + # Store the bug_id of the report + sims[index][0] = loggedreport[0] + + # Calculate the percentage of similarity between the panic messages + ratio = difflib.SequenceMatcher(None, + report.data.commands['panic'], + loggedreport[1] + ).ratio() + sims[index][1] = settings.PANIC_MESSAGE_MAX_PERC * ratio + + # Calculate the percentage of similarity between the top significant + # function names + ratio = difflib.SequenceMatcher(None, + report.top_significant_func, + loggedreport[2] + ).ratio() + sims[index][1] += settings.TOP_FRAME_MAX_PERC * ratio + + # Calculate the percentage of similarity between the remaining + # significant function names + + # Firstly, create an increment and symmetric allocation of maximum + # percentages for the remaining significant function names. + # Compare X function names, where X is the length of the report with + # the fewest remaining significant function names + length = min(len(significant_funcs), len(loggedreport[3])) + rem_sig_max_percs = allocate_values(length - 1) + + # Then, calculate the percentage of similarity between every remaining + # significant function name based on the previous calculated percentages + for i in range(1, length, 1): + ratio = difflib.SequenceMatcher(None, + report.rem_significant_funcs[i], + loggedreport[3][i] + ).ratio() + sims[index][1] += rem_sig_max_percs[i] * ratio + + # Find with which reports the examined report is similar based on the value + # of the limit percentage + passlimit = [] + for sim in sims: + if sim[1] >= settings.LIMIT_PERC: + passlimit.append(sim[0]) + + # Finally, check if the examined report concluded to refer to none or only + # one logged bug. If it refers to more than one bugs, then this is an + # indication that our algorithm is not accurate. + report.bug_id = -1 + if len(passlimit): + if passlimit.count(passlimit[0]) == len(passlimit): + # Refers to a known bug + report.bug_id = passlimit[0] + else: + # Refers to more than one known bugs + report.bug_id = uniqify_sequence(passlimit) + + return True + + +def parse_crashdata(report): + """Parses the crash data XML file of the given report and store the data in + instance variables of the report.""" + validnames = ['crashtype', 'crashdate', 'hostname', 'ostype', 'osrelease', + 'version', 'machine', 'panic', 'backtrace', 'ps_axl', + 'vmstat_s', 'vmstat_m', 'vmstat_z', 'vmstat_i', 'pstat_T', + 'pstat_s', 'iostat', 'ipcs_a', 'ipcs_T', 'nfsstat', + 'netstat_s', 'netstat_m', 'netstat_id', 'netstat_anr', + 'netstat_anA', 'netstat_aL', 'fstat', 'dmesg', 'kernelconfig', + 'ddbcapturebuffer'] + + if not os.path.isfile(report.data.path): + logging.info('Crash report data %s is not an existing regular file' + % report.data.path) + return + + elemtree = etree.parse(report.data.path) + root = elemtree.getroot() + + report.data.info['email'] = root[0][0].text.strip() + + for elem in elemtree.iter(): + if elem.tag == 'command': + children = list(elem) + name = children[0].text.strip() + result = children[1].text.strip() + if name in validnames: + report.data.commands[name] = result + + return True + + +def discard_report(path): + """Discards a crash report from the system.""" + os.remove(path) + + +def clear_directory(directory): + """Takes the absolute path of a directory, and removes all the files (not + directories) that it contains.""" + for filename in os.listdir(directory): + filepath = directory + '/' + filename + if os.path.isfile(filepath): + os.remove(filepath) + + +def extract_report(report): + """Extracts the given report to the auxiliary directory.""" + if not os.path.isdir(settings.AUXILIARY_DIR): + logging.error('Auxiliary directory does not exist') + return + + clear_directory(settings.AUXILIARY_DIR) + + try: + tarfileobj = tarfile.open(report.path, 'r:gz') + tarfileobj.extractall(settings.AUXILIARY_DIR) + except tarfile.ReadError: + return + except tarfile.CompressionError: + return + else: + report.data.path = settings.AUXILIARY_DIR + '/' + report.data.name + finally: + tarfileobj.close() + + return True + + +def check_report(report): + """Checks a crash report for validity and security. + + It is a function that calls all the methods provided by the CrashReport and + the CrashData objects that are related with the validity of a report. The + methods are called in a stict order because some methods assign values + to the instance variables of the given object and some other methods depend + on them. This is done in order to avoid execution of the same code multiple + times, distinguish the checks easily, and organize the code better. + """ + if not report.has_valid_name(): + return + + if not report.has_valid_type(): + return + + if not report.has_valid_contents_number(): + return + + if not report.data.has_valid_name(): + return + + if not extract_report(report): + return + + if not report.data.has_valid_crashdata(): + return + + return True + + +def create_pid_file(): + """Creates the Process ID file that contains the PID of crashreportd. + + It is used from the rc.d script to stop the program normally. + """ + pid = os.getpid() + try: + pidfile = open(settings.PID_FILE, 'w') + pidfile.write(str(pid)) + except IOError: + logging.error('Could not create the Process ID file') + return + finally: + pidfile.close() + + return True + + +def start_logging(): + """Turns on or off the logging facility.""" + if settings.LOGGING_FILE: + logging.basicConfig(level=logging.DEBUG, filename=settings.LOGGING_FILE, + format='%(asctime)s in %(funcName)s() at ' + '%(lineno)s %(levelname)s: %(message)s', + datefmt='%Y-%m-%d %H:%M:%S') + + +def main(): + start_logging() + + if not create_pid_file(): + return + + if not db.connection: + return + + while True: + dirlist = os.listdir(settings.CRASHREPORTS_DIR) + for filename in dirlist: + path = settings.CRASHREPORTS_DIR + '/' + filename + report = crashreport.CrashReport(path) + + if not check_report(report): + move_invalid_report(report.path) + continue + + if not parse_crashdata(report): + move_invalid_report(report.path) + continue + + if not recognize_report(report): + move_invalid_report(report.path) + continue + + if not store_report(report): + move_invalid_report(report.path) + continue + + if not send_confirmation_email(report): + move_invalid_report(report.path) + continue + + discard_report(report.path) + time.sleep(settings.INTERVAL_TIME) + + +if __name__ == '__main__': + main() \ No newline at end of file Added: soc2012/tzabal/server-side/akcrs-handler/settings.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-handler/settings.py Wed Aug 8 04:52:04 2012 (r240185) @@ -0,0 +1,63 @@ +# Interval time +INTERVAL_TIME = 10 + +# Process ID file +PID_FILE = '/var/run/crashreportd.pid' + +# Crashreports directory +CRASHREPORTS_DIR = '/var/spool/crashreports' + +# Auxiliary directory +AUXILIARY_DIR = '/tmp/crashreports' + +# Invalid crash reports +INVALID_REPORTS_DIR = AUXILIARY_DIR + '/invalidreports' + +# Logging file +LOGGING_FILE = '/home/tzabal/crashreportd.log' + +# Database name +DBNAME = 'akcrsdb' + +# Database host +DBHOST = '127.0.0.1' + +# Database user +DBUSER = 'akcrs' + +# Database user password +DBPASS = 'freebsd' + +# SMTP Server +SMTPSERVER = 'smtp.hol.gr' + +# Email address and name of the sender +SENDER = 'Automated Kernel Crash Reporting System ' + +# Confirmation email subject +SUBJECT = 'Confirm your kernel crash report' + +# Confirmation email text +TEXT = """\ +Hello, + +Please confirm your kernel crash report by clicking the following link: +http://akcrs.dyndns.org/confirm_report?id=%s&code=%s + +Once you confirm, your kernel crash report will be stored in our database as +valid. + +Thank your for your time. +""" + +# Panic message maximum percentage +PANIC_MESSAGE_MAX_PERC = 25 + +# Top significant frame maximum percentage +TOP_FRAME_MAX_PERC = 25 + +# Remaining significant frames maximum percentage +REMAINING_FRAMES_MAX_PERC = 50.0 + +# Limit percentage for similar reports +LIMIT_PERC = 60 \ No newline at end of file Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py ============================================================================== --- soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Wed Aug 8 04:42:24 2012 (r240184) +++ soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Wed Aug 8 04:52:04 2012 (r240185) @@ -151,20 +151,27 @@ def send_confirmation_email(report): - sender = 'Automated Kernel Crash Reporting System ' - #receiver = report.data.info['email'] - receiver = 'invalid@it.teithe.gr' - subject = 'Kernel Crash Report Confirmation' - text = 'Confirm your kernel crash report by clicking here.' smtpserver = 'smtp.hol.gr' + sender = 'Automated Kernel Crash Reporting System ' + receiver = report.data.info['email'] + subject = 'Confirm your kernel crash report' + text = """\ + Hello, + + Please confirm your kernel crash report by clicking the following link: + http://akcrs.dyndns.org/confirm_report?code=%s + + Once you confirm, your kernel crash report will be stored in our database + as valid. + + Thank you for your time. + """ % (report.confirmation_code) message = MIMEText(text) message['From'] = sender message['To'] = receiver message['Subject'] = subject - #print message - try: smtpconn = smtplib.SMTP(smtpserver) smtpconn.sendmail(sender, receiver, message.as_string()) @@ -191,28 +198,25 @@ elemtree = etree.parse(report.data.path) root = elemtree.getroot() - report.data.info['email'] = re.sub(r'\s', '', root[0][0].text) + report.data.info['email'] = root[0][0].text.strip() for elem in elemtree.iter(): if elem.tag == 'command': children = list(elem) - #print 'children[0].text: %s' % (children[0].text) - name = re.sub(r'\s', '', children[0].text) - result = children[1].text + name = children[0].text.strip() + result = children[1].text.strip() if name in validnames: - #print 'name: %s' % (name) report.data.commands[name] = result return True -def generate_password(): - """Generates and returns a random password. +def generate_random_string(size): + """Generates and returns a random string of the specified size. - Password is 8 characters in length and it may contain digits, lowercase and - uppercase letters. + The string is a sequence of characters that are chosen randomly from a set + that contains digits, lowercase and uppercase letters. """ - size = 8 chars = string.letters + string.digits return ''.join(random.choice(chars) for ch in range(size)) @@ -228,10 +232,10 @@ if _curs.rowcount: submitter_id = _curs.fetchone() - print 'Submitter_id: %s' % (submitter_id) + #print 'Submitter_id: %s' % (submitter_id) else: - password = generate_password() - print 'password: %s' % (password) + password = generate_random_string(8) + #print 'password: %s' % (password) hashobj = hashlib.sha256() hashobj.update(password) hashpass = hashobj.hexdigest() @@ -252,16 +256,21 @@ # with previously logged reports bug_id = -1 - query = """INSERT INTO Reports (bug_id, submitter_id, crashtype, crashdate, - hostname, ostype, osrelease, version, machine, panic, backtrace, ps_axl, - vmstat_s, vmstat_m, vmstat_z, vmstat_i, pstat_T, pstat_s, iostat, ipcs_a, - ipcs_T, nfsstat, netstat_s, netstat_m, netstat_id, netstat_anr, - netstat_anA, netstat_aL, fstat, dmesg, kernelconfig, ddbcapturebuffer) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, - %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""" + confirmation_code = generate_random_string(12) + report.confirmation_code = confirmation_code + + query = """INSERT INTO Reports (bug_id, submitter_id, confirmation_code, + crashtype, crashdate, hostname, ostype, osrelease, version, machine, panic, + backtrace, ps_axl, vmstat_s, vmstat_m, vmstat_z, vmstat_i, pstat_T, + pstat_s, iostat, ipcs_a, ipcs_T, nfsstat, netstat_s, netstat_m, netstat_id, + netstat_anr, netstat_anA, netstat_aL, fstat, dmesg, kernelconfig, + ddbcapturebuffer) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s)""" values = (bug_id, submitter_id, + confirmation_code, report.data.commands['crashtype'], report.data.commands['crashdate'], report.data.commands['hostname'], @@ -389,7 +398,6 @@ try: pidfile = open(_pid_file, 'w') pidfile.write(str(pid)) - pidfile.close() except IOError: return finally: From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 11:45:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C5326106566B for ; Wed, 8 Aug 2012 11:45:44 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 11:45:44 +0000 Date: Wed, 08 Aug 2012 11:45:44 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808114544.C5326106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240189 - in soc2012/gpf: pefs_head/head/sys/kern pefs_kmod/sys/fs/pefs pefs_kmod/sys/modules/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 11:45:47 -0000 Author: gpf Date: Wed Aug 8 11:45:43 2012 New Revision: 240189 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240189 Log: Move kern_exec.c hack to a proper pefs MAC policy. The problem is that now, the script file is itself checked for the schg flag. More on that can be found on the gigantic comment header in pefs_mac.c Added: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c soc2012/gpf/pefs_kmod/sys/modules/pefs/Makefile Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Wed Aug 8 09:42:44 2012 (r240188) +++ soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Wed Aug 8 11:45:43 2012 (r240189) @@ -548,21 +548,21 @@ goto interpret; } - { - /* XXXgpf: [TODO] place this in a MAC hook */ - int enabled, rval; - size_t enabled_len; - - rval = kernel_sysctlbyname(td, "vfs.pefs.exec.enable", - &enabled, &enabled_len, NULL, 0, NULL, 0); - - if (rval == 0 && enabled != 0) { - if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { - error = EPERM; - goto exec_fail_dealloc; - } - } - } + //{ + ///* XXXgpf: [TODO] place this in a MAC hook */ + //int enabled, rval; + //size_t enabled_len; + + //rval = kernel_sysctlbyname(td, "vfs.pefs.exec.enable", + //&enabled, &enabled_len, NULL, 0, NULL, 0); + + //if (rval == 0 && enabled != 0) { + //if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { + //error = EPERM; + //goto exec_fail_dealloc; + //} + //} + //} /* * NB: We unlock the vnode here because it is believed that none Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Wed Aug 8 09:42:44 2012 (r240188) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Wed Aug 8 11:45:43 2012 (r240189) @@ -319,7 +319,7 @@ dig = malloc(*digest_len, M_TEMP, M_WAITOK); /* * XXXgpf: Does this interface work for any length input? - * Also, I should either use a different interface or store the + * [TODO] Also, I should either use a different interface or store the * checksums in hex during .pefs.checksum creation because turning * them to hex at this point every single time we have a read is * just silly. Added: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Wed Aug 8 11:45:43 2012 (r240189) @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2012 Efstratios Karatzas + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +/* + * XXXgpf: + * The problem with this MAC hook is that the hook is called before + * do_execve() checks if our executable requires an interpreter. + * Therefore, the script file will itself be checked for the schg flag. + * + * We could: + * + * a) allow this because it's a feature! During development of a script, + * user will have to pass it as an argument to the interpreter and when it's + * complete, continue calling it like that or add the schg flag. + * + * b) add a brand new MAC hook that will be called at the precise point + * in do_execve() where only the interpreter or the regular executable + * will be checked for the schg flag. [don't seem the other devs will go + * for us modying MAC framework though] + * + * c) duplicate code from do_execve() and perform the check ourselves. It + * could be done I guess but I'm not sure since image activators seem to have + * their own custom functions that are called in order to figure out whether + * the interpreted flag should be turned on. Don't know how much they are + * allowed to tamper with imgp, besides that flag. + * + */ +static int +pefs_vnode_check_exec(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct image_params *imgp, + struct label *execlabel) +{ + int enabled, rval; + size_t enabled_len; + + rval = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable", + &enabled, &enabled_len, NULL, 0, NULL, 0); + + if (rval == 0 && enabled != 0) { + if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { + return (EPERM); + } + } + + return (0); +} + +static struct mac_policy_ops pefs_ops = +{ + .mpo_vnode_check_exec = pefs_vnode_check_exec, +}; + +MAC_POLICY_SET(&pefs_ops, mac_pefs, "pefs exec protection", + MPC_LOADTIME_FLAG_UNLOADOK, NULL); + +/* XXXgpf: declare our debugging sysctl for kern_exec.c */ +SYSCTL_NODE(_vfs_pefs, OID_AUTO, exec, CTLFLAG_RW, 0, + "PEFS kern_exec.c stuff"); + +int pefs_exec_enable = 0; +SYSCTL_INT(_vfs_pefs_exec, OID_AUTO, enable, CTLFLAG_RW, + &pefs_exec_enable, 0, "Enable exec protection"); Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Wed Aug 8 09:42:44 2012 (r240188) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Wed Aug 8 11:45:43 2012 (r240189) @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -619,14 +618,6 @@ .vfs_vget = pefs_vget, }; -/* XXXgpf: declare our debugging sysctl for kern_exec.c */ -SYSCTL_NODE(_vfs_pefs, OID_AUTO, exec, CTLFLAG_RW, 0, - "PEFS kern_exec.c stuff"); - -int pefs_exec_enable = 0; -SYSCTL_INT(_vfs_pefs_exec, OID_AUTO, enable, CTLFLAG_RW, - &pefs_exec_enable, 0, "Enable exec protection"); - VFS_SET(pefs_vfsops, pefs, VFCF_LOOPBACK); MODULE_DEPEND(pefs, crypto, 1, 1, 1); #ifdef PEFS_AESNI Modified: soc2012/gpf/pefs_kmod/sys/modules/pefs/Makefile ============================================================================== --- soc2012/gpf/pefs_kmod/sys/modules/pefs/Makefile Wed Aug 8 09:42:44 2012 (r240188) +++ soc2012/gpf/pefs_kmod/sys/modules/pefs/Makefile Wed Aug 8 11:45:43 2012 (r240189) @@ -7,7 +7,8 @@ pefs_subr.c pefs_vfsops.c pefs_vnops.c pefs_xbase64.c pefs_crypto.c \ pefs_dircache.c \ pefs_xts.c vmac.c \ - pefs_checksum.c + pefs_checksum.c \ + pefs_mac.c .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" SRCS+= pefs_aesni.c From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 15:32:30 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id BAAB71065672 for ; Wed, 8 Aug 2012 15:32:28 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 15:32:28 +0000 Date: Wed, 08 Aug 2012 15:32:28 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808153228.BAAB71065672@hub.freebsd.org> Cc: Subject: socsvn commit: r240191 - in soc2012/exxo/freebsd-head: include/rpcsvc lib/libc lib/libc/yp usr.bin/ypwhich usr.sbin/ypbind X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 15:32:30 -0000 Author: exxo Date: Wed Aug 8 15:32:28 2012 New Revision: 240191 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240191 Log: Fix alignment issue and apply proper options for buildworld Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h soc2012/exxo/freebsd-head/lib/libc/Makefile soc2012/exxo/freebsd-head/lib/libc/yp/Makefile.inc soc2012/exxo/freebsd-head/lib/libc/yp/Symbol.map soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Wed Aug 8 15:32:28 2012 (r240191) @@ -247,7 +247,7 @@ #endif } ypbind_binding_addr; u_short ypbind_binding_port; -}; +} __attribute__ ((__packed__)); struct ypbind_resp { enum ypbind_resptype ypbind_status; @@ -349,7 +349,9 @@ bool_t xdr_ypresp_val(XDR *, struct ypresp_val *); bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *); +#ifdef YPBIND_COMPAT_V2 bool_t xdr_ypbind_resp_v2(XDR *, struct ypbind_resp_v2 *); +#endif bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *); bool_t xdr_yp_inaddr(XDR *, struct inaddr *); bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *); Modified: soc2012/exxo/freebsd-head/lib/libc/Makefile ============================================================================== --- soc2012/exxo/freebsd-head/lib/libc/Makefile Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/lib/libc/Makefile Wed Aug 8 15:32:28 2012 (r240191) @@ -24,7 +24,7 @@ LIB=c SHLIB_MAJOR= 7 WARNS?= 2 -CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include +CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include -I${.CURDIR}/../../sys/ CFLAGS+=-I${.CURDIR}/${LIBC_ARCH} .if ${MK_NLS} != "no" CFLAGS+=-DNLS @@ -96,7 +96,7 @@ .include "${.CURDIR}/softfloat/Makefile.inc" .endif .if ${MK_NIS} != "no" -CFLAGS+= -DYP +CFLAGS+= -DYP -DYPBIND_COMPAT_V2 .include "${.CURDIR}/yp/Makefile.inc" .endif .if ${MK_HESIOD} != "no" Modified: soc2012/exxo/freebsd-head/lib/libc/yp/Makefile.inc ============================================================================== --- soc2012/exxo/freebsd-head/lib/libc/yp/Makefile.inc Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/lib/libc/yp/Makefile.inc Wed Aug 8 15:32:28 2012 (r240191) @@ -10,7 +10,7 @@ SYM_MAPS+= ${.CURDIR}/yp/Symbol.map RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x -RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C +RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C -DYPBIND_COMPAT_V2 yp_xdr.c: ${RPCSRC} ${RPCGEN} -c -o ${.TARGET} ${RPCSRC} Modified: soc2012/exxo/freebsd-head/lib/libc/yp/Symbol.map ============================================================================== --- soc2012/exxo/freebsd-head/lib/libc/yp/Symbol.map Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/lib/libc/yp/Symbol.map Wed Aug 8 15:32:28 2012 (r240191) @@ -23,3 +23,9 @@ ypprot_err; _yp_check; }; + +FBSD_1.3 { + xdr_ypbind_resp_v2; + xdr_ypbind_binding_v2; + xdr_ypbind_setdom_v2; +}; Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Wed Aug 8 15:32:28 2012 (r240191) @@ -161,7 +161,7 @@ if (clnt_control(client, CLSET_VERS, &version) == TRUE) r = clnt_call(client, YPBINDPROC_DOMAIN, (xdrproc_t)xdr_domainname, &dom, - (xdrproc_t)xdr_ypbind_resp_v2, &ypbr.resp2, tv); /* TODO libc must define YPBIND_COMPAT_V2 */ + (xdrproc_t)xdr_ypbind_resp_v2, &ypbr.resp2, tv); } #endif if (r != RPC_SUCCESS) { Modified: soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Wed Aug 8 13:54:26 2012 (r240190) +++ soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Wed Aug 8 15:32:28 2012 (r240191) @@ -384,10 +384,10 @@ *(u_short *)&res.ypbf_rport = *ss_getport(&ypdb->dom_server_addr); #ifdef INET6 if (family == AF_INET6) - bcopy(ss_to_sin6addr(&ypdb->dom_server_addr), (char *) res.ypbf_raddr, sizeof(struct in6_addr)); + bcopy(ss_to_sin6addr(&ypdb->dom_server_addr), (char *) &res.ypbf_raddr, sizeof(struct in6_addr)); else #endif - bcopy(ss_to_sinaddr(&ypdb->dom_server_addr), (char *) res.ypbf_raddr, sizeof(struct in_addr)); + bcopy(ss_to_sinaddr(&ypdb->dom_server_addr), (char *) &res.ypbf_raddr, sizeof(struct in_addr)); } return ((char *) &res); } @@ -514,9 +514,11 @@ case YPBINDPROC_DOMAIN: xdr_argument = xdr_domainname; +#ifdef YPBIND_COMPAT_V2 if (version == YPBINDVERS_2) xdr_result = xdr_ypbind_resp_v2; else +#endif xdr_result = xdr_ypbind_resp; local = (funcptr) ypbindproc_domain; break; @@ -534,9 +536,11 @@ svcerr_weakauth(transp); return; } +#ifdef YPBIND_COMPAT_V2 if (version == YPBINDVERS_2) xdr_argument = xdr_ypbind_setdom_v2; else +#endif xdr_argument = xdr_ypbind_setdom; xdr_result = xdr_void; local = (funcptr) ypbindproc_setdom; From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 16:06:21 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 52A6B106566B for ; Wed, 8 Aug 2012 16:06:20 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 16:06:20 +0000 Date: Wed, 08 Aug 2012 16:06:20 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808160620.52A6B106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240194 - soc2012/jhagewood X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 16:06:21 -0000 Author: jhagewood Date: Wed Aug 8 16:06:20 2012 New Revision: 240194 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240194 Log: Deleted: soc2012/jhagewood/ From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 16:06:33 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 380AF106566C for ; Wed, 8 Aug 2012 16:06:32 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 16:06:32 +0000 Date: Wed, 08 Aug 2012 16:06:32 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808160632.380AF106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240195 - soc2012/jhagewood X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 16:06:33 -0000 Author: jhagewood Date: Wed Aug 8 16:06:31 2012 New Revision: 240195 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240195 Log: Added: soc2012/jhagewood/ From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 16:07:28 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 99307106564A for ; Wed, 8 Aug 2012 16:07:26 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 16:07:26 +0000 Date: Wed, 08 Aug 2012 16:07:26 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808160726.99307106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240196 - in soc2012/jhagewood: . diff diff3 mdocml mdocml/ports-textproc-patches mdocml/tests sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 16:07:28 -0000 Author: jhagewood Date: Wed Aug 8 16:07:26 2012 New Revision: 240196 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240196 Log: Reorganized subtree Added: soc2012/jhagewood/Milestones soc2012/jhagewood/diff/ soc2012/jhagewood/diff/Makefile soc2012/jhagewood/diff/TODO soc2012/jhagewood/diff/decompress.c soc2012/jhagewood/diff/diff (contents, props changed) soc2012/jhagewood/diff/diff-test.sh soc2012/jhagewood/diff/diff.1 soc2012/jhagewood/diff/diff.1.gz (contents, props changed) soc2012/jhagewood/diff/diff.c soc2012/jhagewood/diff/diff.h soc2012/jhagewood/diff/diffdir.c soc2012/jhagewood/diff/diffreg.c soc2012/jhagewood/diff/pathnames.h soc2012/jhagewood/diff3/ soc2012/jhagewood/diff3/Makefile soc2012/jhagewood/diff3/TODO soc2012/jhagewood/diff3/diff3-test.sh soc2012/jhagewood/diff3/diff3.1 soc2012/jhagewood/diff3/diff3.ksh soc2012/jhagewood/diff3/diff3.sh soc2012/jhagewood/diff3/diff3prog.c soc2012/jhagewood/mdocml/ soc2012/jhagewood/mdocml/Makefile soc2012/jhagewood/mdocml/TODO soc2012/jhagewood/mdocml/apropos.1 soc2012/jhagewood/mdocml/apropos.c soc2012/jhagewood/mdocml/apropos_db.c soc2012/jhagewood/mdocml/apropos_db.h soc2012/jhagewood/mdocml/arch.c soc2012/jhagewood/mdocml/arch.in soc2012/jhagewood/mdocml/att.c soc2012/jhagewood/mdocml/att.in soc2012/jhagewood/mdocml/catman.8 soc2012/jhagewood/mdocml/catman.c soc2012/jhagewood/mdocml/cgi.c soc2012/jhagewood/mdocml/chars.c soc2012/jhagewood/mdocml/chars.in soc2012/jhagewood/mdocml/compat_fgetln.c soc2012/jhagewood/mdocml/compat_getsubopt.c soc2012/jhagewood/mdocml/compat_strlcat.c soc2012/jhagewood/mdocml/compat_strlcpy.c soc2012/jhagewood/mdocml/config.h.post soc2012/jhagewood/mdocml/config.h.pre soc2012/jhagewood/mdocml/demandoc.1 soc2012/jhagewood/mdocml/demandoc.c soc2012/jhagewood/mdocml/eqn.7 soc2012/jhagewood/mdocml/eqn.c soc2012/jhagewood/mdocml/eqn_html.c soc2012/jhagewood/mdocml/eqn_term.c soc2012/jhagewood/mdocml/example.style.css soc2012/jhagewood/mdocml/external.png (contents, props changed) soc2012/jhagewood/mdocml/html.c soc2012/jhagewood/mdocml/html.h soc2012/jhagewood/mdocml/index.css soc2012/jhagewood/mdocml/index.sgml soc2012/jhagewood/mdocml/lib.c soc2012/jhagewood/mdocml/lib.in soc2012/jhagewood/mdocml/libman.h soc2012/jhagewood/mdocml/libmandoc.h soc2012/jhagewood/mdocml/libmdoc.h soc2012/jhagewood/mdocml/libroff.h soc2012/jhagewood/mdocml/main.c soc2012/jhagewood/mdocml/main.h soc2012/jhagewood/mdocml/man-cgi.css soc2012/jhagewood/mdocml/man.7 soc2012/jhagewood/mdocml/man.c soc2012/jhagewood/mdocml/man.cgi.7 soc2012/jhagewood/mdocml/man.h soc2012/jhagewood/mdocml/man.h.orig soc2012/jhagewood/mdocml/man_hash.c soc2012/jhagewood/mdocml/man_html.c soc2012/jhagewood/mdocml/man_macro.c soc2012/jhagewood/mdocml/man_term.c soc2012/jhagewood/mdocml/man_term.c.orig soc2012/jhagewood/mdocml/man_validate.c soc2012/jhagewood/mdocml/mandoc.1 soc2012/jhagewood/mdocml/mandoc.3 soc2012/jhagewood/mdocml/mandoc.c soc2012/jhagewood/mdocml/mandoc.h soc2012/jhagewood/mdocml/mandoc_char.7 soc2012/jhagewood/mdocml/mandocdb.8 soc2012/jhagewood/mdocml/mandocdb.c soc2012/jhagewood/mdocml/mandocdb.h soc2012/jhagewood/mdocml/manpath.c soc2012/jhagewood/mdocml/manpath.h soc2012/jhagewood/mdocml/manpaths.txt soc2012/jhagewood/mdocml/mdoc.7 soc2012/jhagewood/mdocml/mdoc.c soc2012/jhagewood/mdocml/mdoc.h soc2012/jhagewood/mdocml/mdoc_argv.c soc2012/jhagewood/mdocml/mdoc_hash.c soc2012/jhagewood/mdocml/mdoc_html.c soc2012/jhagewood/mdocml/mdoc_macro.c soc2012/jhagewood/mdocml/mdoc_man.c soc2012/jhagewood/mdocml/mdoc_term.c soc2012/jhagewood/mdocml/mdoc_validate.c soc2012/jhagewood/mdocml/mdocml-manpage-errors.txt soc2012/jhagewood/mdocml/msec.c soc2012/jhagewood/mdocml/msec.in soc2012/jhagewood/mdocml/out.c soc2012/jhagewood/mdocml/out.h soc2012/jhagewood/mdocml/ports-textproc-patches/ soc2012/jhagewood/mdocml/ports-textproc-patches/patch-config.txt soc2012/jhagewood/mdocml/ports-textproc-patches/patch-lib.in.txt soc2012/jhagewood/mdocml/ports-textproc-patches/patch-mdoc_validate.c soc2012/jhagewood/mdocml/ports-textproc-patches/patch-msec.in.txt soc2012/jhagewood/mdocml/preconv.1 soc2012/jhagewood/mdocml/preconv.c soc2012/jhagewood/mdocml/predefs.in soc2012/jhagewood/mdocml/read.c soc2012/jhagewood/mdocml/roff.7 soc2012/jhagewood/mdocml/roff.c soc2012/jhagewood/mdocml/st.c soc2012/jhagewood/mdocml/st.in soc2012/jhagewood/mdocml/style.css soc2012/jhagewood/mdocml/tbl.7 soc2012/jhagewood/mdocml/tbl.c soc2012/jhagewood/mdocml/tbl_data.c soc2012/jhagewood/mdocml/tbl_html.c soc2012/jhagewood/mdocml/tbl_layout.c soc2012/jhagewood/mdocml/tbl_opts.c soc2012/jhagewood/mdocml/tbl_term.c soc2012/jhagewood/mdocml/term.c soc2012/jhagewood/mdocml/term.h soc2012/jhagewood/mdocml/term_ascii.c soc2012/jhagewood/mdocml/term_ps.c soc2012/jhagewood/mdocml/test-fgetln.c soc2012/jhagewood/mdocml/test-getsubopt.c soc2012/jhagewood/mdocml/test-mmap.c soc2012/jhagewood/mdocml/test-strlcat.c soc2012/jhagewood/mdocml/test-strlcpy.c soc2012/jhagewood/mdocml/test-strptime.c soc2012/jhagewood/mdocml/tests/ soc2012/jhagewood/mdocml/tests/compile-man-pages.sh (contents, props changed) soc2012/jhagewood/mdocml/tests/mdocml-test.sh (contents, props changed) soc2012/jhagewood/mdocml/tree.c soc2012/jhagewood/mdocml/vol.c soc2012/jhagewood/mdocml/vol.in soc2012/jhagewood/mdocml/whatis.1 soc2012/jhagewood/sdiff/ soc2012/jhagewood/sdiff/Makefile soc2012/jhagewood/sdiff/TODO soc2012/jhagewood/sdiff/benchmarks soc2012/jhagewood/sdiff/common.c soc2012/jhagewood/sdiff/common.h soc2012/jhagewood/sdiff/edit.c soc2012/jhagewood/sdiff/extern.h soc2012/jhagewood/sdiff/sdiff-test.sh soc2012/jhagewood/sdiff/sdiff.1 soc2012/jhagewood/sdiff/sdiff.c Added: soc2012/jhagewood/Milestones ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/Milestones Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,30 @@ +May 21 - June 17 + + Implement missing features of mdocml, including legacy features. + Testing of mdocml. + +June 18 - July 1 + + Complete diff + Debugging and testing of diff + +July 2 - July 18 + + Mid-term evaluations. + Complete sdiff + Debugging and testing of sdiff + +July 19 - August 5 + + Complete diff3 + Debugging and testing of diff3 + +August 6 – August 12 + + Thouroughly test and benchmark all utilities. + +August 13 - August 20 + + "Pencils down" period. + Finish cleaning up code and do any testing that might be left. + Write documentation. Added: soc2012/jhagewood/diff/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/Makefile Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,10 @@ +# $FreeBSD$ +# $OpenBSD: Makefile,v 1.2 2003/06/25 02:42:50 deraadt Exp $ + +DEBUG_FLAGS+= -g + +PROG= diff zdiff +SRCS= diff.c diffdir.c diffreg.c +CFLAGS+= -std=c99 -Wall -pedantic -lz + +.include Added: soc2012/jhagewood/diff/TODO ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/TODO Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,77 @@ +TASK STATUS NOTE + +--unified GNU compatibility COMPLETE Fixed timestamp. +--context GNU compatibility COMPLETE Fixed timestamp, will test more. +--ignore-blank-lines IN PROGRESS Was already implemented in check(), but has weird outputs. +--left-column COMPLETE Because side-by-side mode is executed by sdiff, option is simply passed to sdiff. +--show-function-line INCOMPLETE +--unidirectional-new-file INCOMPLETE +--normal COMPLETE Sets format to D_NORMAL in getopt_long(). +--suppress-common-lines COMPLETE Because side-by-side mode is executed by sdiff, option is simply passed to sdiff. +--GTYPE-group-format IN PROGRESS Added options for various GTYPEs. +--line-format IN PROGRESS Added new-line-format, old-line-format, and unchanged-line-format for compatibility +--LTYPE-line-format INCOMPLETE +--from-file COMPLETE Checks for flag then calls diffreg() with input files diff'd against optarg. +--to-file COMPLETE Checks for flag then calls diffreg() with optarg diff'd against input files. +--horizon-lines INCOMPLETE +--speed-large-file INCOMPLETE +--ignore-tab-expansion IN PROGRESS Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?) +--width INCOMPLETE +--help COMPLETE +Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and detects if file is binary. +Test script COMPLETE +Support for zdiff IN PROGRESS Needs testing. + + +Notes: + +- When using text files with non-ascii characters, diff will interpret them as binary files and output "Files [file1] and [file2] differ." + Very important compatibility problem with GNU diff, which will diff files that aren't strictly ascii. + - Error is associated with asciifile() in diffreg.c + - FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character is ASCII, it checks the first 32kb of data in the file for a null character. If a null character is found, diff assumes that the file is a text file. +- With some files, modification times displayed in the timestamp for file1 are different than the time outputted by GNU diff. +- The -ignore-*-* options need some work. +- BUG: BSD diff seg faults when another longopt is used with '--side-by-side'. FIX: When passing args to sdiff for side-by-side mode, only the + short option '-y' was excluded. Added '--side-by-side' as an exception also. +- --ignore-*-* options + -WORKING + --ignore-all-space + --ignore-case + --ignore-file-name-case + --ignore-matching-lines + --ignore-space-change + -NOT WORKING + --ignore-blank-lines + --ignore-tab-expansion + +- line formats: + + %l Only includes contents of a line, excluding trailing new line. + %L Only includes contents of a line, including trailing new line. + %% Stand for '%' + %c'C' Where C is a character. + %c'\O' where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O. + Fn Where n is: + -'e' + -'f' + -'l' + -'m' + -'n' + -'E, F, L, M, N' + +- group formats: + + %< Stands for the lines from the first file, including trailing new lines. + %> Stands for the lines from the second file, including trailing new lines. + %= Stands for lines common to both files, including trailing new lines. + %% Stands for '%' + %c'C' Where C is a character. + %c'\O' where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O. + Fn Where n is: + -'e' + -'f' + -'l' + -'m' + -'n' + -'E, F, L, M, N' + Added: soc2012/jhagewood/diff/decompress.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/decompress.c Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2012 Jesse Hagewood + * 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. + */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)decompress.c 6/6/93"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef WITHOUT_BZIP2 +#include +#endif + +#include "diff.h" +#include "pathnames.h" + +#define MAXBUFSIZE (32 * 1024) + +/* Decompresses a gzip file and returns a regular FILE. */ +FILE * +decompressfile(char *filename, char *mode) { + + FILE *file; + char *buf; + gzFile comprfile; + + if (comprfile = gzopen(filename, mode) == Z_NULL) + err(1, "Could not open compressed file %s.", filename); + gzread(comprfile, buf, MAXBUFSIZE); + file = fdopen(buf, mode); + + return file; +} Added: soc2012/jhagewood/diff/diff ============================================================================== Binary file. No diff available. Added: soc2012/jhagewood/diff/diff-test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff-test.sh Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,101 @@ +# Script for testing BSD diff outputs against GNU diff outputs. +# Jesse Hagewood +# jhagewood@freebsd.org + +#!/bin/sh + +rm -rf ./test_outputs +mkdir ./test_outputs +mkdir ./test_outputs/gnu +mkdir ./test_outputs/bsd + +run () { + + # Default diff + $1 1.txt 2.txt >> $2/diff.txt + + # --unified output + $1 -u 1.txt 2.txt >> $2/unified.txt + $1 --unified 1.txt 2.txt >> $2/unified.txt + $1 --unified="3" 1.txt 2.txt >> $2/unified.txt + + # --context output + $1 -c 1.txt 2.txt >> $2/context.txt + $1 --context 1.txt 2.txt >> $2/context.txt + $1 --context="3" 1.txt 2.txt >> $2/context.txt + + # --normal format output + $1 --normal 1.txt 2.txt >> $2/normal.txt + $1 -c --normal 1.txt 2.txt >> $2/normal.txt + $1 -u --normal 1.txt 2.txt >> $2/normal.txt + + # --brief + $1 -b 1.txt 2.txt >> $2/brief.txt + $1 --brief 1.txt 2.txt >> $2/brief.txt + + # --ed + $1 -ed 1.txt 2.txt >> $2/ed.txt + $1 -e 1.txt 2.txt >> $2/ed.txt + + # --expand-tabs + $1 --expand-tabs 1.txt 2.txt >> $2/expand-tabs.txt + $1 -t 1.txt 2.txt >> $2/expand-tabs.txt + + # --forward-ed + $1 --forward-ed 1.txt 2.txt >> $2/forward-ed.txt + $1 -f 1.txt 2.txt >> $2/forward-ed.txt + + # --to-file + # XXX Currently hangs on BSD diff. + #$1 --to-file="3.txt" 1.txt 2.txt >> $2/tofile.txt + + # --from-file + # XXX Currently hangs on BSD diff. + #$1 --from-file="3.txt" 1.txt 2.txt >> $2/fromfile.txt + + # --text + $1 --text 1.txt 2.txt >> $2/text.txt + $1 -a 1.txt 2.txt >> $2/text.txt + + # --strip-trailing-cr + $1 --strip-trailing-cr 1.txt 2.txt >> $2 stripcr.txt + + # --rcs + $1 --rcs 1.txt 2.txt >> $2/rcs.txt + $1 -n 1.txt 2.txt >> $2/rcs.txt + + # --width + $1 --width="10" 1.txt 2.txt >> $2/width.txt + $1 -W "10" 1.txt 2.txt >> $2/width.txt + + # --side-by-side + $1 --side-by-side 1.txt 2.txt >> $2/sbs.txt + $1 -y 1.txt 2.txt >> $2/sbs.txt + + # --left-column + $1 -y --left-column 1.txt 2.txt >> $2/lc.txt + $1 --side-by-side --left-column 1.txt 2.txt >> $2/lc.txt + + # --suppress-common-lines + $1 -y --suppress-common-lines 1.txt 2.txt >> $2/scl.txt + $1 --side-by-side --suppress-common-lines 1.txt 2.txt >> $2/scl.txt + + # --line-format + $1 --line-format="%l %% %c'T'" 1.txt 2.txt >> $2/lf.txt + + # --help + $1 --help 1.txt 2.txt >> $2/help.txt +} + +DIR_PATH="./test_outputs/gnu" +DIFF_PATH="/usr/bin/diff" +run "$DIFF_PATH" "$DIR_PATH" +DIR_PATH="./test_outputs/bsd" +DIFF_PATH="./diff" +run "$DIFF_PATH" "$DIR_PATH" + +# +# Get the diff between the GNU and BSD outputs. +# + +diff -rupN ./test_outputs/gnu/ ./test_outputs/bsd/ >> ./test_outputs/gnu-bsd-diff.txt Added: soc2012/jhagewood/diff/diff.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff.1 Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,511 @@ +.\" $FreeBSD$ +.\" $OpenBSD: diff.1,v 1.33 2007/05/31 19:20:09 jmc Exp $ +.\" +.\" Copyright (c) 1980, 1990, 1993 +.\" 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. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" 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. +.\" +.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 +.\" +.Dd Apr 7, 2008 +.Dt DIFF 1 +.Os +.Sh NAME +.Nm diff +.Nd differential file and directory comparator +.Sh SYNOPSIS +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Oo +.Fl c | e | f | +.Fl n | u +.Oc +.Op Fl L Ar label +.Ar file1 file2 +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl C Op Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdilqtw +.Op Fl I Ar pattern +.Fl D Ar string +.Ar file1 file2 +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl U Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdilNPpqrsTtw +.Op Fl I Ar pattern +.Oo +.Fl c | e | f | +.Fl n | u +.Oc +.Bk -words +.Op Fl L Ar label +.Op Fl S Ar name +.Op Fl X Ar file +.Op Fl x Ar pattern +.Ek +.Ar dir1 dir2 +.Nm diff +.Op Fl v +.Sh DESCRIPTION +The +.Nm +utility compares the contents of +.Ar file1 +and +.Ar file2 +and writes to the standard output the list of changes necessary to +convert one file into the other. +No output is produced if the files are identical. +.Pp +Output options (mutually exclusive): +.Bl -tag -width Ds +.It Fl C Op Ar number , Fl Fl context Ns = Ns Op Ar number +Like +.Fl c +but produces a diff with +.Ar number +lines of context. +.It Fl c +Produces a diff with 3 lines of context. +With +.Fl c +the output format is modified slightly: +the output begins with identification of the files involved and +their creation dates and then each change is separated +by a line with fifteen +.Li * Ns 's . +The lines removed from +.Ar file1 +are marked with +.Sq \&-\ \& ; +those added to +.Ar file2 +are marked +.Sq \+\ \& . +Lines which are changed from one file to the other are marked in +both files with +.Sq !\ \& . +Changes which lie within 3 lines of each other are grouped together on +output. +.It Fl D Ar string , Fl Fl ifdef Ns = Ns Ar string +Creates a merged version of +.Ar file1 +and +.Ar file2 +on the standard output, with C preprocessor controls included so that +a compilation of the result without defining +.Ar string +is equivalent to compiling +.Ar file1 , +while defining +.Ar string +will yield +.Ar file2 . +.It Fl e , Fl Fl ed +Produces output in a form suitable as input for the editor utility, +.Xr ed 1 , +which can then be used to convert file1 into file2. +.Pp +Extra commands are added to the output when comparing directories with +.Fl e , +so that the result is a +.Xr sh 1 +script for converting text files which are common to the two directories +from their state in +.Ar dir1 +to their state in +.Ar dir2 . +.It Fl f +Identical output to that of the +.Fl e +flag, but in reverse order. +It cannot be digested by +.Xr ed 1 . +.It Fl n , Fl Fl rcs +Produces a script similar to that of +.Fl e , +but in the opposite order and with a count of changed lines on each +insert or delete command. +This is the form used by +.Xr rcsdiff 1 . +.It Fl q , Fl Fl brief +Just print a line when the files differ. +Does not output a list of changes. +.It Fl U Op Ar number , Fl Fl unified Ns = Ns Op Ar number +Like +.Fl u +but produces a diff with +.Ar number +lines of context. +.It Fl u +Produces a +.Em unified +diff with 3 lines of context. +A unified diff is similar to the context diff produced by the +.Fl c +option. +However, unlike with +.Fl c , +all lines to be changed (added and/or removed) are present in +a single section. +.El +.Pp +Comparison options: +.Bl -tag -width Ds +.It Fl a , Fl Fl text +Treat all files as +.Tn ASCII +text. +Normally +.Nm +will simply print +.Dq Binary files ... differ +if files contain binary characters. +Use of this option forces +.Nm +to produce a diff. +.It Fl b , Fl Fl ignore-space-change +Causes trailing blanks (spaces and tabs) to be ignored, and other +strings of blanks to compare equal. +.It Fl d , Fl Fl minimal +Try very hard to produce a diff as small as possible. +This may consume a lot of processing power and memory when processing +large files with many changes. +.It Fl I Ar pattern , Fl Fl ignore-matching-lines Ns = Ns Ar pattern +Ignores changes, insertions, and deletions whose lines match the +extended regular expression +.Ar pattern . +Multiple +.Fl I +patterns may be specified. +All lines in the change must match some pattern for the change to be +ignored. +See +.Xr re_format 7 +for more information on regular expression patterns. +.It Fl i , Fl Fl ignore-case +Ignores the case of letters. +E.g., +.Dq A +will compare equal to +.Dq a . +.It Fl L Ar label +Print +.Ar label +instead of the first (and second, if this option is specified twice) +file name and time in the context or unified diff header. +.It Fl l , Fl Fl paginate +Long output format; each text file +.Nm diff Ns \'d +is piped through +.Xr pr 1 +to paginate it; +other differences are remembered and summarized +after all text file differences are reported. +.It Fl p , Fl Fl show-c-function +With unified and context diffs, show with each change +the first 40 characters of the last line before the context beginning +with a letter, an underscore or a dollar sign. +For C source code following standard layout conventions, this will +show the prototype of the function the change applies to. +.It Fl T , Fl Fl initial-tab +Print a tab rather than a space before the rest of the line for the +normal, context or unified output formats. +This makes the alignment of tabs in the line consistent. +.It Fl t , Fl Fl expand-tabs +Will expand tabs in output lines. +Normal or +.Fl c +output adds character(s) to the front of each line which may screw up +the indentation of the original source lines and make the output listing +difficult to interpret. +This option will preserve the original source's indentation. +.It Fl w , Fl Fl ignore-all-space +Is similar to +.Fl b +but causes whitespace (blanks and tabs) to be totally ignored. +E.g., +.Dq if (\ \&a == b \&) +will compare equal to +.Dq if(a==b) . +.El +.Pp +Directory comparison options: +.Bl -tag -width Ds +.It Fl N , Fl Fl new-file +If a file is found in only one directory, act as if it was found in the +other directory too but was of zero size. +.It Fl P +If a file is found only in +.Ar dir2 , +act as if it was found in +.Ar dir1 +too but was of zero size. +.It Fl r , Fl Fl recursive +Causes application of +.Nm +recursively to common sub7 directories encountered. +.It Fl S Ar name , Fl starting-file Ns = Ns Ar name +Re-starts a directory +.Nm +in the middle, beginning with file +.Ar name . +.It Fl s , Fl Fl report-identical-files +Causes +.Nm +to report files which are the same, which are otherwise not mentioned. +.It Fl X Ar file , Fl Fl exclude-from Ns = Ns Ar file +Exclude files and subdirectories from comparison whose basenames match +lines in +.Ar file . +Multiple +.Fl X +options may be specified. +.It Fl x Ar pattern , Fl Fl exclude Ns = Ns Ar pattern +Exclude files and subdirectories from comparison whose basenames match +.Ar pattern . +Patterns are matched using shell-style globbing via +.Xr fnmatch 3 . +Multiple +.Fl x +options may be specified. +.It Fl v , Fl Fl version +Print version ino. +.El +.Pp +If both arguments are directories, +.Nm +sorts the contents of the directories by name, and then runs the +regular file +.Nm +algorithm, producing a change list, +on text files which are different. +Binary files which differ, +common subdirectories, and files which appear in only one directory +are described as such. +In directory mode only regular files and directories are compared. +If a non-regular file such as a device special file or +.Tn FIFO +is encountered, a diagnostic message is printed. +.Pp +If only one of +.Ar file1 +and +.Ar file2 +is a directory, +.Nm +is applied to the non-directory file and the file contained in +the directory file with a filename that is the same as the +last component of the non-directory file. +.Pp +If either +.Ar file1 +or +.Ar file2 +is +.Sq Fl , +the standard input is +used in its place. +.Ss Output Style +The default (without +.Fl e , +.Fl c , +or +.Fl n +.\" -C +options) +output contains lines of these forms, where +.Va XX , YY , ZZ , QQ +are line numbers respective of file order. +.Pp +.Bl -tag -width "XX,YYcZZ,QQ" -compact +.It Li XX Ns Ic a Ns Li YY +At (the end of) line +.Va XX +of +.Ar file1 , +append the contents +of line +.Va YY +of +.Ar file2 +to make them equal. +.It Li XX Ns Ic a Ns Li YY,ZZ +Same as above, but append the range of lines, +.Va YY +through +.Va ZZ +of +.Ar file2 +to line +.Va XX +of file1. +.It Li XX Ns Ic d Ns Li YY +At line +.Va XX +delete +the line. +The value +.Va YY +tells to which line the change would bring +.Ar file1 +in line with +.Ar file1 . +.It Li XX,YY Ns Ic d Ns Li ZZ +Delete the range of lines +.Va XX +through +.Va YY +in +.Ar file1 . +.It Li XX Ns Ic c Ns Li YY +Change the line +.Va XX +in +.Ar file1 +to the line +.Va YY +in +.Ar file2 . +.It Li XX,YY Ns Ic c Ns Li ZZ +Replace the range of specified lines with the line +.Va ZZ . +.It Li XX,YY Ns Ic c Ns Li ZZ,QQ +Replace the range +.Va XX , Ns Va YY +from +.Ar file1 +with the range +.Va ZZ , Ns Va QQ +from +.Ar file2 . +.El +.Pp +These lines resemble +.Xr ed 1 +subcommands to convert +.Ar file1 +into +.Ar file2 . +The line numbers before the action letters pertain to +.Ar file1 ; +those after pertain to +.Ar file2 . +Thus, by exchanging +.Ic a +for +.Ic d +and reading the line in reverse order, one can also +determine how to convert +.Ar file2 +into +.Ar file1 . +As in +.Xr ed 1 , +identical +pairs (where num1 = num2) are abbreviated as a single +number. +.Sh ENVIRONMENT +.Bl -tag -width TMPDIR +.It Ev TMPDIR +If the environment variable +.Ev TMPDIR +exists, +.Nm +will use the directory specified by +.Ev TMPDIR +as the temporary directory. +.El +.Sh FILES +.Bl -tag -width /tmp/diff.XXXXXXXX -compact +.It Pa /tmp/diff. Ns Ar XXXXXXXX +Temporary file used when comparing a device or the standard input. +Note that the temporary file is unlinked as soon as it is created +so it will not show up in a directory listing. +.El +.Sh DIAGNOSTICS +The +.Nm +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It 0 +No differences were found. +.It 1 +Differences were found. +.It \*(Gt1 +An error occurred. +.El +.Sh SEE ALSO +.Xr cmp 1 , +.Xr comm 1 , +.Xr diff3 1 , +.Xr ed 1 , +.Xr pr 1 , +.Xr sdiff 1 , +.Xr fnmatch 3 , +.Xr re_format 7 +.Sh STANDARDS +The +.Nm +utility is compliant with the +St -p1003.1-2004 +specification. +.Pp +The flags +.Op Fl aDdIiLlNnPpqSsTtUuwXx +are extensions to that specification. +.Sh HISTORY +A +.Nm +command appeared in +.At v6 . +.Sh BUGS +When comparing directories with the +.Fl b , +.Fl w +or +.Fl i +options specified, +.Nm +first compares the files ala +.Xr cmp 1 , +and then decides to run the +.Nm +algorithm if they are not equal. +This may cause a small amount of spurious output if the files +then turn out to be identical because the only differences are +insignificant whitespace or case differences. Added: soc2012/jhagewood/diff/diff.1.gz ============================================================================== Binary file. No diff available. Added: soc2012/jhagewood/diff/diff.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff.c Wed Aug 8 16:07:26 2012 (r240196) @@ -0,0 +1,711 @@ +/* + * Copyright (c) 2003 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)diff.c 8.1 (Berkeley) 6/6/93"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "diff.h" +#include "pathnames.h" + +int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag; +int sflag, tflag, Tflag, wflag, Toflag, Fromflag; +int Bflag, yflag; +int filebehave; +int strip_cr, suppress_cl, tabsize = 8; +char ignore_file_case = 0; +int format, context, status; +char *start, *ifdefname, *diffargs, *label[2], *ignore_pats, *line_format, *group_format; +struct stat stb1, stb2; +struct excludes *excludes_list; +regex_t ignore_re; + +int flag_opts = 0; + +#define OPTIONS "0123456789aBbC:cdD:EefhI:iL:lnNPpqrS:sTtU:uvwXy:x" + + +/* Options which exceed manageable alphanumeric assignments */ +enum +{ + OPT_IGN_FN_CASE = CHAR_MAX + 1, + OPT_NIGN_FN_CASE, + OPT_STRIPCR, + OPT_NORMAL, + OPT_LEFTC, + OPT_SUPCL, + OPT_CHGD_GF, + OPT_NEW_GF, + OPT_OLD_GF, + OPT_UNCHGD_GF, + OPT_LF, + OPT_LLF, + OPT_TSIZE, + OPT_FFILE, + OPT_TOFILE, + OPT_HLINES, + OPT_LFILES, + OPT_HELP, + OPT_NEW_LF, + OPT_OLD_LF, + OPT_UNCHGD_LF, +}; + + +static struct option longopts[] = { + + /* + * Commented-out options are unimplemented. + */ + + { "brief", no_argument, NULL, 'q' }, + { "changed-group-format", required_argument, NULL, OPT_CHGD_GF}, + { "context", optional_argument, NULL, 'C' }, + { "ed", no_argument, NULL, 'e' }, + { "exclude", required_argument, NULL, 'x' }, + { "exclude-from", required_argument, NULL, 'X' }, + { "expand-tabs", no_argument, NULL, 't' }, + { "from-file", required_argument, NULL, OPT_FFILE }, + { "forward-ed", no_argument, NULL, 'f' }, + { "help", no_argument, NULL, OPT_HELP }, + /*{ "horizon-lines", required_argument, NULL, OPT_HLINES },*/ + { "ifdef", required_argument, NULL, 'D' }, + { "ignore-all-space", no_argument, NULL, 'W' }, + { "ignore-blank-lines", no_argument, NULL, 'B' }, + { "ignore-case", no_argument, NULL, 'i' }, + { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, + { "ignore-matching-lines", required_argument, NULL, 'I' }, + { "ignore-space-change", no_argument, NULL, 'b' }, + { "ignore-tab-expansion", no_argument, NULL, 'E' }, + { "initial-tab", no_argument, NULL, 'T' }, + { "label", required_argument, NULL, 'L' }, + { "left-column", no_argument, NULL, OPT_LEFTC }, + { "line-format", required_argument, NULL, OPT_LF }, + { "minimal", no_argument, NULL, 'd' }, + { "new-file", no_argument, NULL, 'N' }, + { "new-line-format", required_argument, NULL, OPT_NEW_LF}, + { "new-group-format", required_argument, NULL, OPT_NEW_GF}, + { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE }, + { "normal", no_argument, NULL, OPT_NORMAL }, + { "old-line-format", required_argument, NULL, OPT_OLD_LF}, + { "old-group-format", required_argument, NULL, OPT_OLD_GF}, + { "paginate", no_argument, NULL, 'l' }, + { "recursive", no_argument, NULL, 'r' }, + { "report-identical-files", no_argument, NULL, 's' }, + { "rcs", no_argument, NULL, 'n' }, + { "show-c-function", no_argument, NULL, 'p' }, + { "show-function-line", required_argument, NULL, 'F' }, + { "side-by-side", no_argument, NULL, 'y' }, + /*{ "speed-large-files", no_argument, NULL, OPT_LFILES }, */ + { "starting-file", required_argument, NULL, 'S' }, + { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, + { "suppress-common-lines", no_argument, NULL, OPT_SUPCL }, + { "tabsize", optional_argument, NULL, OPT_TSIZE }, + { "text", no_argument, NULL, 'a' }, + { "to-file", required_argument, NULL, OPT_TOFILE }, + { "unchanged-group-format", required_argument, NULL, OPT_UNCHGD_GF}, + { "unchanged-line-format", required_argument, NULL, OPT_UNCHGD_LF}, + { "unidirectional-new-file", no_argument, NULL, 'P' }, + { "unified", optional_argument, NULL, 'U' }, + { "version", no_argument, NULL, 'v' }, + /*{ "width", optional_argument, NULL, 'w' }, */ + { NULL, 0, NULL, '\0'} +}; + +static const char *help_msg[] = { +"\t-a --text treat files as ASCII text", +"\t-B --ignore-blank-lines Ignore blank newlines in the comparison", +"\t-b --ignore-space-change Ignore all changes due to whitespace", +"\t-C -c NUM --context=NUM Show NUM lines before and after change (default 3)", +"\t-D --ifdef=NAME Output merged file with `#ifdef NAME' diffs", +"\t-E --ignore-tab-expansion Ignore tab expansion in the comparison", +"\t-e --ed Output an ed script", +"\t-F --show-function-line=RE Show the most recent line matching RE", +"\t-f --forward-ed Output a forward ed script", +"\t-I --ignore-matching-lines=RE Ignore changes whose lines all match RE", +"\t-i --ignore-case Ignore case differences in file contents", +"\t-L --label=NAME Label file header", +"\t-l --paginate Paginates output through pr", +"\t-N --new-file Treat new files as empty", +"\t-n --rcs Output an RCS format diff", +"\t-P --unidirectional-new-file Treat absent-first files as empty", +"\t-p --show-c-function Show which C function each change is in", +"\t-q --brief report only when files differ", +"\t-r --recursive Recursively compare any sub-directories found", +"\t-S --starting-file=FILE Start with FILE when comparing directories", +"\t-s --report-identical-files Report when two files are the same", +"\t-T --initial-tab Make tabs line up by prepending a tab", +"\t-t --expand-tabs Expand tabs to spaces in output", +"\t-U -u NUM --unified=NUM Show NUM lines of unified context", +"\t-v --version Show diff version", +"\t-W --ignore-all-space Ignore all space", *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 16:45:16 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 53322106566C for ; Wed, 8 Aug 2012 16:45:14 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 16:45:14 +0000 Date: Wed, 08 Aug 2012 16:45:14 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808164514.53322106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240197 - soc2012/jhagewood/diff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 16:45:16 -0000 Author: jhagewood Date: Wed Aug 8 16:45:13 2012 New Revision: 240197 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240197 Log: zdiff integration Modified: soc2012/jhagewood/diff/Makefile soc2012/jhagewood/diff/decompress.c soc2012/jhagewood/diff/diffreg.c Modified: soc2012/jhagewood/diff/Makefile ============================================================================== --- soc2012/jhagewood/diff/Makefile Wed Aug 8 16:07:26 2012 (r240196) +++ soc2012/jhagewood/diff/Makefile Wed Aug 8 16:45:13 2012 (r240197) @@ -4,7 +4,7 @@ DEBUG_FLAGS+= -g PROG= diff zdiff -SRCS= diff.c diffdir.c diffreg.c +SRCS= diff.c diffdir.c diffreg.c decompress.c CFLAGS+= -std=c99 -Wall -pedantic -lz .include Modified: soc2012/jhagewood/diff/decompress.c ============================================================================== --- soc2012/jhagewood/diff/decompress.c Wed Aug 8 16:07:26 2012 (r240196) +++ soc2012/jhagewood/diff/decompress.c Wed Aug 8 16:45:13 2012 (r240197) @@ -62,13 +62,13 @@ decompressfile(char *filename, char *mode) { FILE *file; - char *buf; + char *buf = ""; gzFile comprfile; if (comprfile = gzopen(filename, mode) == Z_NULL) err(1, "Could not open compressed file %s.", filename); gzread(comprfile, buf, MAXBUFSIZE); - file = fdopen(buf, mode); + fputs(buf, file); return file; } Modified: soc2012/jhagewood/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diffreg.c Wed Aug 8 16:07:26 2012 (r240196) +++ soc2012/jhagewood/diff/diffreg.c Wed Aug 8 16:45:13 2012 (r240197) @@ -191,6 +191,8 @@ int d; /* end line in new file */ }; +extern FILE *decompressfile(char *, char *); + static FILE *opentemp(const char *); static void output(char *, FILE *, char *, FILE *, int); static void check(char *, FILE *, char *, FILE *); From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 16:48:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id DF16E106564A for ; Wed, 8 Aug 2012 16:48:49 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 16:48:49 +0000 Date: Wed, 08 Aug 2012 16:48:49 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808164849.DF16E106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240198 - soc2012/jhagewood/diff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 16:48:52 -0000 Author: jhagewood Date: Wed Aug 8 16:48:49 2012 New Revision: 240198 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240198 Log: gdb output for error in zdiff Modified: soc2012/jhagewood/diff/TODO Modified: soc2012/jhagewood/diff/TODO ============================================================================== --- soc2012/jhagewood/diff/TODO Wed Aug 8 16:45:13 2012 (r240197) +++ soc2012/jhagewood/diff/TODO Wed Aug 8 16:48:49 2012 (r240198) @@ -74,4 +74,40 @@ -'m' -'n' -'E, F, L, M, N' - + +- gdb output for error in zdiff integration: + +GNU gdb 6.1.1 [FreeBSD] +Copyright 2004 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "amd64-marcel-freebsd"... +(gdb) run 1.txt 2.txt +Starting program: /usr/home/jesse/Documents/diff/zdiff 1.txt 2.txt + +Program received signal SIGBUS, Bus error. +0x0000000800b5ead8 in getdtablesize () from /lib/libc.so.7 +(gdb) list +197 +198 static void set_argstr(char **, char **); +199 static void usage(void); +200 static void push_excludes(char *); +201 static void push_ignore_pats(char *); +202 static void read_excludes_file(char *); +203 +204 int +205 main(int argc, char **argv) +206 { +(gdb) where +#0 0x0000000800b5ead8 in getdtablesize () from /lib/libc.so.7 +#1 0x0000000800b5ebfd in getdtablesize () from /lib/libc.so.7 +#2 0x0000000800b5e6dd in f_prealloc () from /lib/libc.so.7 +#3 0x0000000800b4282c in funopen () from /lib/libc.so.7 +#4 0x0000000800b425ca in rewind () from /lib/libc.so.7 +#5 0x0000000000403bef in istextfile (f=0x7fffffffdb85) at diffreg.c:1375 +#6 0x000000000040615c in diffreg (ofile1=0x7fffffffdb85 "ocal/bintxt", + ofile2=0x7fffffffdb8b "intxt", flags=Variable "flags" is not available. +) at diffreg.c:389 +#7 0x0000000000402c7f in main (argc=2, argv=0x7fffffffd8b0) at diff.c:506 From owner-svn-soc-all@FreeBSD.ORG Wed Aug 8 21:05:10 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id EAA18106566C for ; Wed, 8 Aug 2012 21:05:07 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 08 Aug 2012 21:05:07 +0000 Date: Wed, 08 Aug 2012 21:05:07 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120808210507.EAA18106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240206 - soc2012/oleksandr/udf-head/sys/fs/udf2 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 21:05:10 -0000 Author: oleksandr Date: Wed Aug 8 21:05:07 2012 New Revision: 240206 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240206 Log: Correct udf_readdir and add some KASSERTs Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Aug 8 20:21:33 2012 (r240205) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Aug 8 21:05:07 2012 (r240206) @@ -964,7 +964,7 @@ ump->packet_size = MAXPHYS / ump->discinfo.sector_size; ump->packet_size = MIN(ump->packet_size, 64); } - /*KASSERT(ump->packet_size >= 1); */ + KASSERT(ump->packet_size >= 1, ("udf_read_anchors: packet size is less than one")); /* read anchors start+256, start+512, end-256, end */ positions[0] = track_start+256; @@ -2133,7 +2133,7 @@ #if 0 /* - * Select our sheduler + * Select our scheduler */ ump->strategy = &udf_strat_rmw; if (n_virt || (ump->discinfo.mmc_cur & MMC_CAP_PSEUDOOVERWRITE)) @@ -3180,7 +3180,8 @@ */ ump->sparable_packet_size = le16toh(pms->packet_len); - /*KASSERT(ump->sparable_packet_size >= ump->packet_size); */ /* XXX */ + KASSERT(ump->sparable_packet_size >= ump->packet_size, + ("udf_read_sparables: sparable packet size is less than packet size")); for (spar = 0; spar < pms->n_st; spar++) { lb_num = pms->st_loc[spar]; Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Aug 8 20:21:33 2012 (r240205) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Aug 8 21:05:07 2012 (r240206) @@ -231,7 +231,7 @@ #endif KASSERT(udf_node, ("udf_read: udf_node is null")); - KASSERT(udf_noed->fe || udf_node->efe, ("udf_read: Extended File Entry or File Entry is null")); + KASSERT(udf_node->fe || udf_node->efe, ("udf_read: Extended File Entry or File Entry is null")); /* get file/directory filesize */ if (udf_node->fe) @@ -275,14 +275,8 @@ /* --------------------------------------------------------------------- */ #if 0 int -udf_write(void *v) +udf_write(struct vop_write_args *ap) { - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - kauth_cred_t a_cred; - } */ *ap = v; struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; int ioflag = ap->a_ioflag; @@ -598,7 +592,7 @@ udf_node = VTOI(vp); ump = udf_node->ump; - DPRINTF(READDIR, ("udf_readdir_called\n")); + DPRINTF(READDIR, ("udf_readdir called\n")); /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) @@ -622,7 +616,7 @@ * were it left off. */ ncookies = uio->uio_resid / 8; - cookies = malloc(sizeof(u_long) * ncookies, M_UDFTEMP, + cookies = malloc(sizeof(u_long) * ncookies, M_TEMP, M_WAITOK | M_ZERO); if (cookies == NULL) return (ENOMEM); @@ -733,10 +727,8 @@ DPRINTF(READDIR, ("\tread dirent `%s', type %d\n", dirent->d_name, dirent->d_type)); if (cookiesp) { - /* - if (++acookies >= ncookies) + if (acookies + 1 > ncookies) break; - */ acookies++; *cookiesp++ = cookie; } @@ -753,7 +745,8 @@ bail: /* tell the calling layer whether we need to be called again */ - *ap->a_eofflag = (uio->uio_offset >= file_size); + if (ap->a_eofflag) + *ap->a_eofflag = (uio->uio_offset >= file_size); if (error < 0) error = 0; @@ -763,7 +756,7 @@ free(cookies, M_UDFTEMP); } else { *ap->a_ncookies = acookies; - //*ap->a_cookies = cookies; + *ap->a_cookies = cookies; } } From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 09:51:04 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D5FC6106564A for ; Thu, 9 Aug 2012 09:51:01 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 09:51:01 +0000 Date: Thu, 09 Aug 2012 09:51:01 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809095101.D5FC6106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240207 - in soc2012/rudot/sys: kern sys X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 09:51:04 -0000 Author: rudot Date: Thu Aug 9 09:51:00 2012 New Revision: 240207 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240207 Log: decay %cpu in racct containers - work in progress Modified: soc2012/rudot/sys/kern/kern_racct.c soc2012/rudot/sys/sys/racct.h Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Wed Aug 8 21:05:07 2012 (r240206) +++ soc2012/rudot/sys/kern/kern_racct.c Thu Aug 9 09:51:00 2012 (r240207) @@ -157,7 +157,7 @@ RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, [RACCT_WALLCLOCK] = RACCT_IN_MILLIONS, - [RACCT_PCTCPU] = RACCT_DENIABLE }; + [RACCT_PCTCPU] = RACCT_DECAYING | RACCT_DENIABLE }; static const fixpt_t RACCT_DECAY_FACTOR = 0.9 * FSCALE; @@ -303,7 +303,7 @@ #endif #ifdef SMP struct pcpu *pc; - u_int cpuid; + int found; #endif fixpt_t p_pctcpu; struct thread *td; @@ -325,12 +325,15 @@ if (td == PCPU_GET(idlethread)) continue; #ifdef SMP - cpuid = td->td_oncpu; - if (cpuid != NOCPU) { - pc = pcpu_find(cpuid); - if (td == pc->pc_idlethread) - continue; + found = 0; + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { + if (td == pc->pc_idlethread) { + found = 1; + break; + } } + if (found) + continue; #endif thread_lock(td); #ifdef SCHED_4BSD @@ -398,7 +401,7 @@ KASSERT(src->r_resources[i] <= dest->r_resources[i], ("racct propagation meltdown: src > dest")); } - if (RACCT_IS_RECLAIMABLE(i)) { + if (RACCT_CAN_DROP(i)) { dest->r_resources[i] -= src->r_resources[i]; if (dest->r_resources[i] < 0) { KASSERT(RACCT_IS_SLOPPY(i), @@ -583,7 +586,7 @@ { int64_t available; int64_t old_amount, decayed_amount; - int64_t diff, decayed_diff; + int64_t diff_proc, diff_cred; SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); @@ -592,30 +595,36 @@ */ PROC_LOCK_ASSERT(p, MA_OWNED); + old_amount = p->p_racct->r_resources[resource]; /* - * may be negative + * the diffs may be negative */ - old_amount = p->p_racct->r_resources[resource]; - diff = amount - old_amount; - decayed_amount = old_amount * RACCT_DECAY_FACTOR / FSCALE; - decayed_diff = amount - decayed_amount; + diff_proc = amount - old_amount; + if (RACCT_IS_DECAYING(resource)) { + decayed_amount = old_amount * RACCT_DECAY_FACTOR / FSCALE; + diff_cred = amount - decayed_amount; + } else { + diff_cred = diff_proc; + } available = INT64_MAX; + #ifdef RCTL available = rctl_pcpu_available(p); #endif - racct_alloc_resource(p->p_racct, resource, diff); - if (decayed_diff > 0) - racct_add_cred_locked(p->p_ucred, resource, decayed_diff); - else if (decayed_diff < 0) - racct_sub_cred_locked(p->p_ucred, resource, -decayed_diff); + racct_alloc_resource(p->p_racct, resource, diff_proc); + if (diff_cred > 0) + racct_add_cred_locked(p->p_ucred, resource, diff_cred); + else if (diff_cred < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff_cred); - return (available <= diff); + return (available <= diff_proc); } static int racct_set_locked(struct proc *p, int resource, uint64_t amount) { - int64_t diff; + int64_t old_amount, decayed_amount; + int64_t diff_proc, diff_cred; #ifdef RCTL int error; #endif @@ -627,15 +636,25 @@ */ PROC_LOCK_ASSERT(p, MA_OWNED); - diff = amount - p->p_racct->r_resources[resource]; + old_amount = p->p_racct->r_resources[resource]; + /* + * the diffs may be negative + */ + diff_proc = amount - old_amount; + if (RACCT_IS_DECAYING(resource)) { + decayed_amount = old_amount * RACCT_DECAY_FACTOR / FSCALE; + diff_cred = amount - decayed_amount; + } else { + diff_cred = diff_proc; + } #ifdef notyet - KASSERT(diff >= 0 || RACCT_IS_RECLAIMABLE(resource), - ("racct_set: usage of non-reclaimable resource %d dropping", + KASSERT(diff_proc >= 0 || RACCT_CAN_DROP(resource), + ("racct_set: usage of non-droppable resource %d dropping", resource)); #endif #ifdef RCTL - if (diff > 0) { - error = rctl_enforce(p, resource, diff); + if (diff_proc > 0) { + error = rctl_enforce(p, resource, diff_proc); if (error && RACCT_IS_DENIABLE(resource)) { SDT_PROBE(racct, kernel, rusage, set_failure, p, resource, amount, 0, 0); @@ -643,11 +662,11 @@ } } #endif - racct_alloc_resource(p->p_racct, resource, diff); - if (diff > 0) - racct_add_cred_locked(p->p_ucred, resource, diff); - else if (diff < 0) - racct_sub_cred_locked(p->p_ucred, resource, -diff); + racct_alloc_resource(p->p_racct, resource, diff_proc); + if (diff_cred > 0) + racct_add_cred_locked(p->p_ucred, resource, diff_cred); + else if (diff_cred < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff_cred); return (0); } @@ -745,8 +764,8 @@ * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(RACCT_IS_RECLAIMABLE(resource), - ("racct_sub: called for non-reclaimable resource %d", resource)); + KASSERT(RACCT_CAN_DROP(resource), + ("racct_sub: called for non-droppable resource %d", resource)); mtx_lock(&racct_lock); KASSERT(amount <= p->p_racct->r_resources[resource], @@ -768,8 +787,8 @@ 0, 0); #ifdef notyet - KASSERT(RACCT_IS_RECLAIMABLE(resource), - ("racct_sub_cred: called for non-reclaimable resource %d", + KASSERT(RACCT_CAN_DROP(resource), + ("racct_sub_cred: called for resource %d which can not drop", resource)); #endif @@ -1024,8 +1043,6 @@ int resource; int64_t r_old, r_new; - mtx_assert(&racct_lock, MA_OWNED); - resource = *(int *) res; r_old = racct->r_resources[resource]; @@ -1033,18 +1050,15 @@ if (r_old <= 0) return; + mtx_lock(&racct_lock); r_new = r_old * RACCT_DECAY_FACTOR / FSCALE; racct->r_resources[resource] = r_new; + mtx_unlock(&racct_lock); } static void -racct_decay_pcpu(void) +racct_decay(int resource) { - int resource; - - mtx_assert(&racct_lock, MA_OWNED); - - resource = RACCT_PCTCPU; ui_racct_foreach(racct_decay_resource, &resource, NULL); loginclass_racct_foreach(racct_decay_resource, &resource, NULL); prison_racct_foreach(racct_decay_resource, &resource, NULL); @@ -1061,9 +1075,7 @@ int over_limits; for (;;) { - mtx_lock(&racct_lock); - racct_decay_pcpu(); - mtx_unlock(&racct_lock); + racct_decay(RACCT_PCTCPU); sx_slock(&allproc_lock); Modified: soc2012/rudot/sys/sys/racct.h ============================================================================== --- soc2012/rudot/sys/sys/racct.h Wed Aug 8 21:05:07 2012 (r240206) +++ soc2012/rudot/sys/sys/racct.h Thu Aug 9 09:51:00 2012 (r240207) @@ -79,6 +79,7 @@ #define RACCT_INHERITABLE 0x04 #define RACCT_DENIABLE 0x08 #define RACCT_SLOPPY 0x10 +#define RACCT_DECAYING 0x20 extern int racct_types[]; @@ -90,7 +91,9 @@ #define RACCT_IS_IN_MILLIONS(X) (racct_types[X] & RACCT_IN_MILLIONS) /* - * Resource usage can drop, as opposed to only grow. + * Resource usage can drop, as opposed to only grow. When the process + * terminates, its resource usage is freed from the respective + * per-credential racct containers. */ #define RACCT_IS_RECLAIMABLE(X) (racct_types[X] & RACCT_RECLAIMABLE) @@ -114,6 +117,20 @@ #define RACCT_IS_SLOPPY(X) (racct_types[X] & RACCT_SLOPPY) /* + * When a process terminates, its resource usage is not automatically + * subtracted from per-credential racct containers. Instead, the resource + * usage of per-credential racct containers decays in time. + * Resource usage can olso drop for such resource. + * So far, the only such resource is RACCT_PCTCPU. + */ +#define RACCT_IS_DECAYING(X) (racct_types[X] & RACCT_DECAYING) + +/* + * Resource usage can drop, as opposed to only grow. + */ +#define RACCT_CAN_DROP(X) (RACCT_IS_RECLAIMABLE(X) | RACCT_IS_DECAYING(X)) + +/* * The 'racct' structure defines resource consumption for a particular * subject, such as process or jail. * From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 11:25:21 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 6DA77106564A for ; Thu, 9 Aug 2012 11:25:19 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 11:25:19 +0000 Date: Thu, 09 Aug 2012 11:25:19 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809112519.6DA77106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240208 - in soc2012/aleek/beaglexm-armv6/sys: arm/ti arm/ti/twl arm/ti/usb boot/fdt/dts X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 11:25:21 -0000 Author: aleek Date: Thu Aug 9 11:25:18 2012 New Revision: 240208 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240208 Log: ti_i2c and ti_twl refactoring Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Thu Aug 9 09:51:00 2012 (r240207) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Thu Aug 9 11:25:18 2012 (r240208) @@ -180,7 +180,6 @@ static inline uint16_t ti_i2c_read_2(struct ti_i2c_softc *sc, bus_size_t off) { - //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); return bus_read_2(sc->sc_mem_res, off); } @@ -199,7 +198,6 @@ static inline void ti_i2c_write_2(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val) { - //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); bus_write_2(sc->sc_mem_res, off, val); } @@ -219,8 +217,6 @@ static inline uint16_t ti_i2c_read_reg(struct ti_i2c_softc *sc, bus_size_t off) { - /* XXXOMAP3: FIXME add registers mapping here */ - //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); return bus_read_2(sc->sc_mem_res, off); } @@ -240,8 +236,6 @@ static inline void ti_i2c_write_reg(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val) { - //device_printf( sc->sc_dev, "%s offset 0x%02lx\n", __FUNCTION__, off ); - /* XXXOMAP3: FIXME add registers mapping here */ bus_write_2(sc->sc_mem_res, off, val); } @@ -263,13 +257,13 @@ static inline void ti_i2c_set_intr_enable(struct ti_i2c_softc *sc, uint16_t ie) { - /* XXXOMAP3: FIXME */ +#if defined( SOC_TI_AM37X ) || defined( SOC_OMAP3 ) ti_i2c_write_2(sc, I2C_REG_IE, ie); - /* +#elif defined(SOC_TI_AM335X) || defined(SOC_OMAP4) ti_i2c_write_2(sc, I2C_REG_IRQENABLE_CLR, 0xffff); if (ie) ti_i2c_write_2(sc, I2C_REG_IRQENABLE_SET, ie); - */ +#endif } /** @@ -1090,7 +1084,11 @@ /* XXXOMAP3: FIXME get proper revision here */ /* First read the version number of the I2C module */ //@todo aleek fix this change cause dmarion will be pissed ;) - sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_LO) & 0xff; +#if defined(SOC_TI_AM335X) || defined(SOC_OMAP4) + sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff; +#elif defined( SOC_TI_AM37X ) || defined( SOC_OMAP3 ) + sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REV) & 0xff; +#endif device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4, sc->sc_rev & 0xf); Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Thu Aug 9 09:51:00 2012 (r240207) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Thu Aug 9 11:25:18 2012 (r240208) @@ -558,7 +558,6 @@ int err; uint8_t vsel; int xlocked; - device_printf( sc->sc_dev, "%s\n", __FUNCTION__ ); TWL_VREG_ASSERT_LOCKED(sc); @@ -627,7 +626,6 @@ int en = 0; int xlocked; uint8_t vsel; - device_printf( sc->sc_dev, "%s\n", __FUNCTION__ ); TWL_VREG_ASSERT_LOCKED(sc); @@ -831,14 +829,12 @@ struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); struct twl_regulator_entry *new; - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); new = malloc(sizeof(struct twl_regulator_entry), M_DEVBUF, M_NOWAIT | M_ZERO); if (new == NULL) return (NULL); - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); strncpy(new->name, name, TWL_VREG_MAX_NAMELEN); new->name[TWL_VREG_MAX_NAMELEN - 1] = '\0'; @@ -851,7 +847,6 @@ new->num_supp_voltages = num_voltages; - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Add a sysctl entry for the voltage */ new->oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, name, CTLTYPE_INT | CTLFLAG_RD, sc, 0, @@ -892,7 +887,6 @@ int len = 0, prop_len; - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Add the regulators from the list */ walker = ®ulators[0]; while (walker->name != NULL) { @@ -907,14 +901,12 @@ walker++; } - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Check if the FDT is telling us to set any voltages */ child = ofw_bus_get_node(sc->sc_pdev); if (child) { prop_len = OF_getprop(child, "voltage-regulators", rnames, sizeof(rnames)); - device_printf( sc->sc_dev, "prop_len: %d\n", prop_len ); while (len < prop_len) { name = rnames + len; len += strlen(name) + 1; @@ -966,7 +958,6 @@ struct twl_vreg_softc *sc; sc = device_get_softc((device_t)dev); - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); TWL_VREG_XLOCK(sc); @@ -1010,7 +1001,6 @@ /* We have to wait until interrupts are enabled. I2C read and write * only works if the interrupts are available. */ - device_printf( sc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); sc->sc_init_hook.ich_func = twl_vreg_init; sc->sc_init_hook.ich_arg = dev; Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 09:51:00 2012 (r240207) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 11:25:18 2012 (r240208) @@ -294,7 +294,6 @@ omap_ehci_soft_phy_reset(struct omap_ehci_softc *isc, unsigned int port) { unsigned long timeout = (hz < 10) ? 1 : ((100 * hz) / 1000); - timeout = timeout<<2; uint32_t reg; reg = ULPI_FUNC_CTRL_RESET Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Thu Aug 9 09:51:00 2012 (r240207) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Thu Aug 9 11:25:18 2012 (r240208) @@ -65,7 +65,7 @@ /* Set of triplets < padname, muxname, padstate> */ scm-pad-config = /* USB */ - /* + "af10", "hsusb1_stp", "output", "ae10", "hsusb1_clk", "output", "af9", "hsusb1_dir", "input_pulldown", @@ -77,7 +77,7 @@ "ae11", "hsusb1_data4", "input_pulldown", "ah9", "hsusb1_data5", "input_pulldown", "af13", "hsusb1_data6", "input_pulldown", - "ae13", "hsusb1_data7", "input_pulldown",*/ + "ae13", "hsusb1_data7", "input_pulldown", "af7", "hsusb2_stp", "output", "ag7", "hsusb2_dir", "input_pulldown", From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 12:35:18 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9A38C1065672 for ; Thu, 9 Aug 2012 12:35:16 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 12:35:16 +0000 Date: Thu, 09 Aug 2012 12:35:16 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809123516.9A38C1065672@hub.freebsd.org> Cc: Subject: socsvn commit: r240209 - in soc2012/aleek/beaglexm-armv6/sys/arm/ti: am37x usb X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 12:35:18 -0000 Author: aleek Date: Thu Aug 9 12:35:15 2012 New Revision: 240209 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240209 Log: fix bug in gptimer Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c Thu Aug 9 11:25:18 2012 (r240208) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_gptimer_tc.c Thu Aug 9 12:35:15 2012 (r240209) @@ -177,7 +177,7 @@ /* Get a pointer to the individual sc struct */ - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) { ret = EINVAL; @@ -186,7 +186,7 @@ ret = 0; } - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return (ret); } @@ -212,11 +212,11 @@ if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) return (EINVAL); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); gptimer_write_4(OMAP3_GPT_TCRR, cnt); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return (0); } @@ -257,7 +257,7 @@ return (rc); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); /* Determine if the pre-scalar is enabled and if so the prescaler value */ tclr = gptimer_read_4(OMAP3_GPT_TCLR); @@ -269,7 +269,7 @@ /* Get the reload count */ tldr = gptimer_read_4(OMAP3_GPT_TLDR); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); /* Calculate the tick freq */ @@ -335,7 +335,7 @@ return (EINVAL); } - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); /* Enable the functional and interface clock */ if (flags & OMAP3_GPTIMER_32KCLK_FLAG) @@ -451,7 +451,7 @@ /* Finally set the activated flag */ sc->flags |= OMAP3_GPTIMER_ACTIVATED_FLAG; - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return (0); } @@ -475,13 +475,13 @@ if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) return (EINVAL); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); val = gptimer_read_4(OMAP3_GPT_TCLR); val |= TCLR_ST; gptimer_write_4(OMAP3_GPT_TCLR, val); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return 0; } @@ -497,13 +497,13 @@ if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) return (EINVAL); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); val = gptimer_read_4(OMAP3_GPT_TCLR); val |= TCLR_ST; gptimer_write_4(OMAP3_GPT_TCLR, val); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return 0; } @@ -527,13 +527,13 @@ if (!(sc->flags & OMAP3_GPTIMER_ACTIVATED_FLAG)) return (EINVAL); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); val = gptimer_read_4(OMAP3_GPT_TCLR); val &= ~TCLR_ST; gptimer_write_4(OMAP3_GPT_TCLR, val); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return 0; } @@ -555,18 +555,18 @@ if (sc == NULL) return (ENOMEM); - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); /* If a callback is already installed this won't work */ if (sc->callback != NULL) { - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return(EINVAL); } /* Sanity check the timer is already activated and periodic type */ if ((sc->flags & (OMAP3_GPTIMER_ACTIVATED_FLAG | OMAP3_GPTIMER_PERIODIC_FLAG)) != (OMAP3_GPTIMER_ACTIVATED_FLAG | OMAP3_GPTIMER_PERIODIC_FLAG)) { - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return(EINVAL); } @@ -575,7 +575,7 @@ if (bus_setup_intr(sc->sc_dev, sc->irq_res, INTR_TYPE_CLK, filter, NULL, NULL, &sc->irq_h)) { device_printf(sc->sc_dev, "Error: failed to activate interrupt\n"); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return(EINVAL); } @@ -587,7 +587,7 @@ gptimer_write_4(OMAP3_GPT_TIER, val); } - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); return(0); } @@ -607,8 +607,8 @@ { uint32_t stat; - //OMAP3_GPTIMER_LOCK(sc); - + OMAP3_GPTIMER_LOCK(sc); + /* Read the interrupt status flag and clear it */ /* Read the status and it with the enable flag */ stat = gptimer_read_4(OMAP3_GPT_TISR); @@ -616,7 +616,7 @@ /* Clear the status flag */ gptimer_write_4(OMAP3_GPT_TISR, stat); - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); } @@ -668,7 +668,7 @@ void* callback_data; uint32_t stat = 0x0000; - //OMAP3_GPTIMER_LOCK(sc); + OMAP3_GPTIMER_LOCK(sc); /* Read the interrupt status flag and clear it */ if (sc->profile == OMAP_GPTIMER_PROFILE_OMAP3) { @@ -685,7 +685,7 @@ callback = sc->callback; callback_data = sc->callback_data; - //OMAP3_GPTIMER_UNLOCK(sc); + OMAP3_GPTIMER_UNLOCK(sc); /* Check if an actual overflow interrupt */ if ((stat & OVF) && (callback != NULL)) @@ -782,6 +782,7 @@ struct omap3_gptimer_softc *sc = device_get_softc(dev); omap3_gptimer_attach_common(dev); + mtx_init(&sc->mtx, device_get_nameunit(dev), "omap3_gptimer_tc", MTX_SPIN ); /* Set the clock source for the timer, this is just a one to one * mapping of the clock id to timer, i.e. n=0 => GPTIMER1_CLK. */ @@ -858,6 +859,7 @@ struct omap3_gptimer_softc *sc = device_get_softc(dev); omap3_gptimer_attach_common(dev); + mtx_init(&sc->mtx, device_get_nameunit(dev), "omap3_gptimer_et", MTX_SPIN ); /* Set the clock source for the timer, this is just a one to one * mapping of the clock id to timer, i.e. n=0 => GPTIMER1_CLK. */ Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 11:25:18 2012 (r240208) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 12:35:15 2012 (r240209) @@ -895,6 +895,7 @@ /* Setup the interrupt */ + device_printf( dev, "%s:%d\n", __func__, __LINE__ ); err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); if (err) { @@ -904,8 +905,10 @@ } + device_printf( dev, "%s:%d\n", __func__, __LINE__ ); /* Finally we are ready to kick off the ECHI host controller */ - err = ehci_init(sc); + err = 0; //ehci_init(sc); + device_printf( dev, "%s:%d\n", __func__, __LINE__ ); if (err == 0) { err = device_probe_and_attach(sc->sc_bus.bdev); } From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 14:10:42 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4D03C106566C for ; Thu, 9 Aug 2012 14:10:41 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 14:10:41 +0000 Date: Thu, 09 Aug 2012 14:10:41 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809141041.4D03C106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240210 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 14:10:42 -0000 Author: gpf Date: Thu Aug 9 14:10:40 2012 New Revision: 240210 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240210 Log: minor changes, comment updates and code refactoring Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Thu Aug 9 12:35:15 2012 (r240209) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Thu Aug 9 14:10:40 2012 (r240210) @@ -812,7 +812,7 @@ /* XXXgpf: for debugging purposes */ static void -pefs_rb_print(struct hardlink_head *hlc_headp) +pefs_hardlink_print(struct hardlink_head *hlc_headp) { struct hardlink_counter *hlcp; struct file_header *fhp; @@ -828,7 +828,7 @@ } static void -pefs_rb_warn(struct hardlink_head *hlc_headp) +pefs_hardlink_warn(struct hardlink_head *hlc_headp) { struct hardlink_counter *hlcp; struct file_header *fhp; @@ -848,7 +848,7 @@ } static int -pefs_rb_insert(struct hardlink_head *hlc_headp, struct file_header *fhp, +pefs_hardlink_insert(struct hardlink_head *hlc_headp, struct file_header *fhp, struct stat *sbp) { struct hardlink_counter find, *res, *new_hlcp; @@ -880,7 +880,7 @@ } static int -pefs_rb_cmp(struct hardlink_counter *hlcp1, struct hardlink_counter *hlcp2) +pefs_hardlink_cmp(struct hardlink_counter *hlcp1, struct hardlink_counter *hlcp2) { if (hlcp1->inode < hlcp2->inode) return -1; @@ -891,7 +891,7 @@ } static void -pefs_rb_free(struct hardlink_head *hlc_headp) +pefs_hardlink_free(struct hardlink_head *hlc_headp) { struct hardlink_counter *cur, *next; @@ -1067,7 +1067,7 @@ /* Keep all hardlink file headers in a rb tree */ if (sb.st_nlink > 1 && hlc_headp != NULL) - return (pefs_rb_insert(hlc_headp, fhp, &sb)); + return (pefs_hardlink_insert(hlc_headp, fhp, &sb)); return (0); } @@ -1177,9 +1177,9 @@ if (error != 0) return (error); - pefs_rb_print(&hlc_head); - pefs_rb_warn(&hlc_head); - pefs_rb_free(&hlc_head); + pefs_hardlink_print(&hlc_head); + pefs_hardlink_warn(&hlc_head); + pefs_hardlink_free(&hlc_head); error = pefs_allocate_hash_table(chtp, nfiles, PEFS_EXTEND); if (error != 0) @@ -1306,12 +1306,8 @@ struct file_header *fhp; fhp = bp->fhp; + /* Empty files aren't allowed so nhashes == 0 symbolizes an empty bucket */ if (fhp == NULL) { - /* - * XXXgpf: empty files are not allowed so nhashes == 0 symbolizes - * an empty bucket. perhaps a bitmap would be better? or we could - * steal a bit from some data member? - */ emptyfh.nhashes = 0; emptyfh.file_id = 0; emptyfh.offset_to_checksums = 0; @@ -1341,8 +1337,12 @@ * All data member writes are done separately so as to avoid alignment problems. * Writes are always in little endian byte order. * - * First 16 bytes of .pefs.checksum are filled with .pefs.checksum's file - * header. Right after this header lies the 'index' part of our database. + * First 512 bytes of .pefs.checksum are reserved for the file's digital + * signature. + * + * After that, the next 16 bytes of .pefs.checksum are filled with + * .pefs.checksum's global file header. Right after this header lies the + * 'index' part of our database. * This index is later kept in kernel memory. * * Index: @@ -1437,7 +1437,7 @@ cfhp->offset_to_hash_table = PEFS_CFH_SIZE; } -/* read dsa pubkey from file */ +/* read dsa privkey from file */ static EVP_PKEY * pefs_read_dsa_privkey(FILE *pk_fp) { @@ -1469,7 +1469,7 @@ return (pkey); } -/* Sign .pefs.checksum. Signature is placed in a different file. */ +/* Sign .pefs.checksum. Signature is placed at the beginning of the file. */ static int pefs_sign_file(int fd, FILE *pkfp) { @@ -1481,8 +1481,6 @@ unsigned int sign_len; int bytes, error, rval; - /* XXXgpf: [TODO] offer option of DSA/RSA & appropriate digests */ - /* generate keys */ pkey = pefs_read_dsa_privkey(pkfp); if (pkey == NULL) return (PEFS_ERR_SYS); @@ -1715,8 +1713,7 @@ * later written to file ".pefs.checksum" which is created under csm_path. * algo is used as a cryptographic hash function that produces checksums * for 4k blocks of each file. When we are done with .pefs.checksum, we - * sign it and place the signature in .pefs.signature. The public key is placed - * in .pefs.pkey. + * sign it and place the signature at the beginning of .pefs.checksum. */ int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, @@ -2138,19 +2135,12 @@ return (PEFS_ERR_SYS); } - /* - * XXXgpf: probably print warning and move on to the next file - * instead of returning so as to print as many warnings - * as possible. - */ if ((sb.st_flags & SF_IMMUTABLE) == 0) { pefs_warn("file %s does not have schg flag", fhp->path); - closedir(dirp); - pefs_free_file_header(fhp); - return (PEFS_ERR_SYS); + *checksum_error = PEFS_ERR_CHECKSUM; } - error = pefs_rb_insert(hlc_headp, fhp, &sb); + error = pefs_hardlink_insert(hlc_headp, fhp, &sb); if (error != 0) { closedir(dirp); pefs_free_file_header(fhp); @@ -2222,7 +2212,7 @@ * B) The entire filesystem is traversed in order to check each and every file. * C) warning messages are produced for hardlinks and symbolic links. * D) check that every file in .pefs.checksum was actually found in filesystem. - * E) verify .pefs.signature from public key found in .pefs.pkey + * E) verify the file's signature with the user supplied public key */ int pefs_verify_checksum(int fdin, FILE *pk_fp, char *fsroot, int flags) @@ -2280,8 +2270,8 @@ if (error != 0) goto out; - /* pefs_rb_print(&hlc_head); */ - pefs_rb_warn(&hlc_head); + /* pefs_hardlink_print(&hlc_head); */ + pefs_hardlink_warn(&hlc_head); if ((flags & PEFS_UNMOUNTED) == 0 && (flags & PEFS_NOKEY) == 0) pefs_symlink_warn(&cht, &fh_head); @@ -2294,7 +2284,7 @@ out: pefs_free_hash_table(&cht); - pefs_rb_free(&hlc_head); + pefs_hardlink_free(&hlc_head); pefs_free_file_header_tail(&fh_head); return (error); @@ -2330,4 +2320,4 @@ return (error); } -RB_GENERATE(hardlink_head, hardlink_counter, hardlink_entries, pefs_rb_cmp); +RB_GENERATE(hardlink_head, hardlink_counter, hardlink_entries, pefs_hardlink_cmp); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Thu Aug 9 12:35:15 2012 (r240209) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Thu Aug 9 14:10:40 2012 (r240210) @@ -1006,7 +1006,8 @@ /* * XXXgpf: Instead of a man page entry: * - * pefs addchecksum [-f] [-a algo] [-i inputfile] [-p path] filesystem + * pefs addchecksum [-f] [-a algo] [-i inputfile] [-k pkey_file] [-p path] \ + * filesystem * * $command creates .pefs.checksum db file for filesystem. * This file will contain all checksums necessary to check integrity @@ -1022,17 +1023,15 @@ * path defines where .pefs.checksum should be created. By default, * .pefs.checksum is created under $PWD. path should be a directory, * outside of target pefs filesystem. - * - * Alongside .pefs.checksum, two other files are created: .pefs.signature & - * .pefs.pkey. The first one contains the digital signature of .pefs.checksum - * and the other one the public key that is used for signature verification. - * They are created under the same parent directory as .pefs.checksum. + * + * pkey_file is the file that contains the private key that will be used + * by the DSA signing algorithm. Key should be in PEM format. * * -f symbolizes that $command should set immutable flag schg for every file * in inputlist if the flag is not already set. * * When $command is run, filesystem must be mounted with pefs, and - * user must have supplied the necessary key(s). + * user must have supplied the necessary pefs key(s). * */ static int @@ -1115,7 +1114,7 @@ argv += optind; if (pk_fp == NULL) { - pefs_warn("user must provide a file containing the public key"); + pefs_warn("user must provide a file containing the private key"); return (PEFS_ERR_INVALID); } @@ -1136,7 +1135,7 @@ /* * XXXgpf: Instead of a man page entry: * - * pefs verify [-u/-n] [-k pkey_file] [-s sign_file] checksumpath filesystem + * pefs verify [-u/-n] [-k pkey_file] checksumpath filesystem * * $command verifies the contents of a .pefs.checksum file. It scans the * entire filesystem and checks that every entry in .pefs.checksum is @@ -1153,13 +1152,7 @@ * flags -u and -n are mutually exclusive. * * pkey_file is the file containing the public key that is used to verify - * .pefs.checksum's signature. - * - * sign_file contains the public signature that is used to verify - * .pefs.checksum's digital signature. - * - * If pkey_file or sign_file are not supplied, $command expects to find the - * respective files under the same parent directory as .pefs.checksum. + * .pefs.checksum's signature by the DSA algorithm. * * By default, pefs will assume that filesystem is mounted and user * has provided key. @@ -1362,8 +1355,8 @@ " pefs randomchain [-fv] [-n min] [-N max] filesystem\n" " pefs showchains [-fp] [-i iterations] [-k keyfile] filesystem\n" " pefs showalgs\n" -" pefs addchecksum [-f] [-a algo] [-i inputfile] [-p checksumpath] filesystem\n" -" pefs verify [-n/u] [-k pkey_file] [-s sign_file] [checksumpath filesystem]\n" +" pefs addchecksum [-f] [-a algo] [-i inputfile] [-k pkey_file] [-p checksumpath] filesystem\n" +" pefs verify [-n/u] [-k pkey_file] [checksumpath filesystem]\n" " pefs nameid [-u/-n] [filepath]" ); exit(PEFS_ERR_USAGE); Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Thu Aug 9 12:35:15 2012 (r240209) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Thu Aug 9 14:10:40 2012 (r240210) @@ -59,7 +59,7 @@ * b) add a brand new MAC hook that will be called at the precise point * in do_execve() where only the interpreter or the regular executable * will be checked for the schg flag. [don't seem the other devs will go - * for us modying MAC framework though] + * for us modifying MAC framework though] * * c) duplicate code from do_execve() and perform the check ourselves. It * could be done I guess but I'm not sure since image activators seem to have From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 16:14:08 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D6746106564A for ; Thu, 9 Aug 2012 16:14:05 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 16:14:05 +0000 Date: Thu, 09 Aug 2012 16:14:05 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809161405.D6746106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240214 - in soc2012/aleek/beaglexm-armv6/sys/arm: conf ti/usb X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 16:14:08 -0000 Author: aleek Date: Thu Aug 9 16:14:05 2012 New Revision: 240214 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240214 Log: working od omap ehci driver. Its still not working Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Thu Aug 9 15:11:38 2012 (r240213) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Thu Aug 9 16:14:05 2012 (r240214) @@ -107,8 +107,8 @@ # USB support device usb options USB_DEBUG -options USB_REQ_DEBUG -options USB_VERBOSE +options USB_REQ_DEBUG +options USB_VERBOSE device musb device ehci device umass Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 15:11:38 2012 (r240213) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Thu Aug 9 16:14:05 2012 (r240214) @@ -102,6 +102,9 @@ #include #include +#include +#include + #include #include "gpio_if.h" @@ -111,6 +114,7 @@ device_t sc_dev; device_t sc_gpio_dev; + device_t sc_vreg_dev; /* TLL register set */ struct resource* tll_mem_res; @@ -352,6 +356,11 @@ /* Enable Clocks for high speed USBHOST */ ti_prcm_clk_enable(USBHSHOST_CLK); + + /* enabling TWL4030/TPS95950 voltage regulator */ + twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v5", 1800); + twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v8", 1800); + twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb3v1", 1800); /* Hold the PHY in reset while configuring */ for (int i = 0; i < 3; i++) { @@ -381,6 +390,8 @@ /* Enable the USB TLL */ ti_prcm_clk_enable(USBTLL_CLK); + //omap_ehci_write_4(isc, OMAP_USBHOST_INSNREG04, OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND); + /* Perform TLL soft reset, and wait until reset is complete */ omap_tll_write_4(isc, OMAP_USBTLL_SYSCONFIG, TLL_SYSCONFIG_SOFTRESET); @@ -414,7 +425,7 @@ TLL_SYSCONFIG_CACTIVITY); } else if (isc->ehci_rev == OMAP_EHCI_REV2) { - +#if 0 /* For OMAP44xx devices you have to enable the per-port clocks: * PHY_MODE - External ULPI clock * TTL_MODE - Internal UTMI clock @@ -437,6 +448,7 @@ else if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_HSIC) ti_prcm_clk_enable(USBP2_HSIC_CLK); } +#endif } /* Put UHH in SmartIdle/SmartStandby mode */ @@ -533,6 +545,13 @@ omap_ehci_utmi_init(isc, tll_ch_mask); } + /* Soft reset the PHY using PHY reset command over ULPI */ + if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(isc, 0); + if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(isc, 1); + + //ehci_reset( isc->base ); /* Release the PHY reset signal now we have configured everything */ if (reset_performed) { @@ -560,11 +579,6 @@ reg |= (1 << 16); omap_ehci_write_4(isc, OMAP_USBHOST_USBCMD, reg); - /* Soft reset the PHY using PHY reset command over ULPI */ - if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) - omap_ehci_soft_phy_reset(isc, 0); - if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) - omap_ehci_soft_phy_reset(isc, 1); return(0); @@ -785,6 +799,7 @@ /* save the device */ isc->sc_dev = dev; + isc->sc_vreg_dev = devclass_get_device(devclass_find("twl_vreg"), 0); /* get all DMA memory */ if (usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(dev), @@ -895,7 +910,6 @@ /* Setup the interrupt */ - device_printf( dev, "%s:%d\n", __func__, __LINE__ ); err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); if (err) { @@ -905,10 +919,8 @@ } - device_printf( dev, "%s:%d\n", __func__, __LINE__ ); /* Finally we are ready to kick off the ECHI host controller */ err = 0; //ehci_init(sc); - device_printf( dev, "%s:%d\n", __func__, __LINE__ ); if (err == 0) { err = device_probe_and_attach(sc->sc_bus.bdev); } From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 17:32:28 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9B39F106564A for ; Thu, 9 Aug 2012 17:32:27 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 17:32:27 +0000 Date: Thu, 09 Aug 2012 17:32:27 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809173227.9B39F106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240216 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 17:32:28 -0000 Author: jhagewood Date: Thu Aug 9 17:32:26 2012 New Revision: 240216 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240216 Log: Modified: soc2012/jhagewood/diff3/diff3prog.c Modified: soc2012/jhagewood/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3prog.c Thu Aug 9 16:38:17 2012 (r240215) +++ soc2012/jhagewood/diff3/diff3prog.c Thu Aug 9 17:32:26 2012 (r240216) @@ -125,7 +125,7 @@ int overlapcnt; FILE *fp[3]; int cline[3]; /* # of the last-read line in each file (0-2) */ -char *diff_prog = NULL; +char *diff_prog = "/usr/bin/diff"; char *labels[3] = {NULL}; /* * The latest known correspondence between line numbers of the 3 files From owner-svn-soc-all@FreeBSD.ORG Thu Aug 9 17:33:05 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 759A0106564A for ; Thu, 9 Aug 2012 17:33:03 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 09 Aug 2012 17:33:03 +0000 Date: Thu, 09 Aug 2012 17:33:03 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120809173303.759A0106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240217 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 17:33:05 -0000 Author: jhagewood Date: Thu Aug 9 17:33:03 2012 New Revision: 240217 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240217 Log: diff3prog.c to diff3.c Added: soc2012/jhagewood/diff3/diff3.c - copied unchanged from r240216, soc2012/jhagewood/diff3/diff3prog.c Deleted: soc2012/jhagewood/diff3/diff3prog.c Copied: soc2012/jhagewood/diff3/diff3.c (from r240216, soc2012/jhagewood/diff3/diff3prog.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff3/diff3.c Thu Aug 9 17:33:03 2012 (r240217, copy of r240216, soc2012/jhagewood/diff3/diff3prog.c) @@ -0,0 +1,771 @@ +/* $OpenBSD: diff3prog.c,v 1.11 2009/10/27 23:59:37 deraadt Exp $ */ + +/* + * Copyright (C) Caldera International Inc. 2001-2002. + * 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 and documentation 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 or owned by Caldera + * International, Inc. + * 4. Neither the name of Caldera International, Inc. nor the names of other + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA + * INTERNATIONAL, INC. 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 CALDERA INTERNATIONAL, INC. 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) 1991, 1993 + * 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + * + * @(#)diff3.c 8.1 (Berkeley) 6/6/93 + */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)diff3.c 8.1 (Berkeley) 6/6/93"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD: soc2012/jhagewood/diff3/diff3/diff3prog.c 237773 2012-06-15 18:23:01Z jhagewood $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* diff3 - 3-way differential file comparison */ + +/* diff3 [-ex3EX] d13 d23 f1 f2 f3 [m1 m3] + * + * d13 = diff report on f1 vs f3 + * d23 = diff report on f2 vs f3 + * f1, f2, f3 the 3 files + * if changes in f1 overlap with changes in f3, m1 and m3 are used + * to mark the overlaps; otherwise, the file names f1 and f3 are used + * (only for options E and X). + */ + +/* + * "from" is first in range of changed lines; "to" is last+1 + * from=to=line after point of insertion for added lines. + */ +struct range { + int from; + int to; +}; +struct diff { + struct range old; + struct range new; +}; + +size_t szchanges; + +struct diff *d13; +struct diff *d23; +/* + * "de" is used to gather editing scripts. These are later spewed out in + * reverse order. Its first element must be all zero, the "new" component + * of "de" contains line positions or byte positions depending on when you + * look (!?). Array overlap indicates which sections in "de" correspond to + * lines that are different in all three files. + */ +struct diff *de; +char *overlap; +int overlapcnt; +FILE *fp[3]; +int cline[3]; /* # of the last-read line in each file (0-2) */ +char *diff_prog = "/usr/bin/diff"; +char *labels[3] = {NULL}; +/* + * The latest known correspondence between line numbers of the 3 files + * is stored in last[1-3]; + */ +int last[4]; +int aflag, Aflag, eflag, iflag, mflag, Tflag; +int oflag; /* indicates whether to mark overlaps (-E or -X)*/ +int strip_cr; +int debug = 0; +char f1mark[40], f2mark[40], f3mark[40]; /* markers for -E and -X */ + +static int duplicate(struct range *, struct range *); +static int edit(struct diff *, int, int); +static char *getchange(FILE *); +static char *getline(FILE *, size_t *); +static int number(char **); +static int readin(char *, struct diff **); +static int skip(int, int, char *); +static void change(int, struct range *, int); +static void keep(int, struct range *); +static void merge(int, int); +static int istextfile(FILE *); +static void prange(struct range *); +static void repos(int); +static void separate(const char *); +static void edscript(int) __dead2; +static void remove_cr(FILE *); +static void trouble(void) __dead2; +static void increase(void); +static void help(void); +static void usage(void) __dead2; + +enum { + HELP_OPT = CHAR_MAX + 1, + STRIPCR_OPT, + DIFFPROG_OPT, +}; + +#define MAX_CHECK 768 /* 3 kilobytes of chars. */ + +#define OPTIONS "3aAeEiL:mTvxX" +static struct option longopts[] = { + { "ed", no_argument, NULL, 'e' }, + { "show-overlap", no_argument, NULL, 'E' }, + { "overlap-only", no_argument, NULL, 'x' }, + { "initial-tab", no_argument, NULL, 'T' }, + { "text", no_argument, NULL, 'a' }, + { "version", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, HELP_OPT }, + { "strip-trailing-cr", no_argument, NULL, STRIPCR_OPT }, + + /* features to implement */ + { "show-all", no_argument, NULL, 'A' }, + { "easy-only", no_argument, NULL, '3' }, + { "merge", no_argument, NULL, 'm' }, + { "label", required_argument, NULL, 'L' }, + { "diff-program", required_argument, NULL, DIFFPROG_OPT }, + + +}; + +int +main(int argc, char **argv) +{ + int ch, i, j, m, n; + + eflag = 0; + oflag = 0; + while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { + switch (ch) { + case 'A': + Aflag = 1; + break; + case 'a': + aflag = 1; + break; + case 'E': + eflag = 3; + oflag = 1; + break; + case 'e': + eflag = 3; + break; + case 'i': + iflag = 1; + break; + case 'L': + oflag = 1; + for(i=0; i<3 && labels[i] != NULL; i++); + i = i <= 2 ? i : 2 ; + labels[i] = optarg; + break; + case 'm': + Aflag = 1; + eflag = 0; + mflag = 1; + break; + case 'T': + Tflag = 1; + break; + case 'X': + oflag = eflag = 1; + break; + case 'v': + /* To do. */ + exit(0); + case 'x': + eflag = 1; + break; + case '3': + eflag = 2; + break; + case HELP_OPT: + help(); + exit(0); + case STRIPCR_OPT: + strip_cr = 1; + break; + case DIFFPROG_OPT: + diff_prog = optarg; + break; + } + } + argc -= optind; + argv += optind; + if (argc < 3) + usage(); + if (oflag) { + (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", + labels[0] != NULL ? labels[0] : + argc >= 6 ? argv[5] : argv[2]); + (void)snprintf(f2mark, sizeof(f2mark), "||||||| %s", + labels[1] != NULL ? labels[1] : + argc >= 6 ? argv[4] : argv[3]); + (void)snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", + labels[2] != NULL ? labels[2] : + argc >= 7 ? argv[6] : argv[4]); + } + increase(); + m = readin(argv[0], &d13); + n = readin(argv[1], &d23); + j = 0; + for (i = 2; i >= 0; i--) { + if ((fp[j] = fopen(argv[(argc-1)-i], "r")) == NULL) + err(EXIT_FAILURE, "Can't open %s", argv[(argc-1)-i]); + if (strip_cr) + remove_cr(fp[j]); + j++; + } + merge(m, n); + exit(EXIT_SUCCESS); +} + +/* + * Pick up the line numbers of all changes from one change file. + * (This puts the numbers in a vector, which is not strictly necessary, + * since the vector is processed in one sequential pass. + * The vector could be optimized out of existence) + */ +static int +readin(char *name, struct diff **dd) +{ + int a, b, c, d, i; + char kind, *p; + + fp[0] = fopen(name, "r"); + if (fp[0] == NULL) + err(EXIT_FAILURE, "Can't open %s", name); + for (i=0; (p = getchange(fp[0])); i++) { + if (i >= szchanges - 1) + increase(); + a = b = number(&p); + if (*p == ',') { + p++; + b = number(&p); + } + kind = *p++; + c = d = number(&p); + if (*p==',') { + p++; + d = number(&p); + } + if (kind == 'a') + a++; + if (kind == 'd') + c++; + b++; + d++; + (*dd)[i].old.from = a; + (*dd)[i].old.to = b; + (*dd)[i].new.from = c; + (*dd)[i].new.to = d; + } + if (i) { + (*dd)[i].old.from = (*dd)[i-1].old.to; + (*dd)[i].new.from = (*dd)[i-1].new.to; + } + (void)fclose(fp[0]); + return (i); +} + +static int +number(char **lc) +{ + int nn; + + nn = 0; + while (isdigit((unsigned char)(**lc))) + nn = nn*10 + *(*lc)++ - '0'; + return (nn); +} + +static char * +getchange(FILE *b) +{ + char *line; + + while ((line = getline(b, NULL))) { + if (isdigit((unsigned char)line[0])) + return (line); + } + return (NULL); +} + +static char * +getline(FILE *b, size_t *n) +{ + char *cp; + size_t len; + static char *buf; + static size_t bufsize; + + if ((cp = fgetln(b, &len)) == NULL) + return (NULL); + + if (cp[len - 1] != '\n') + len++; + if (len + 1 > bufsize) { + do { + bufsize += 1024; + } while (len + 1 > bufsize); + if ((buf = realloc(buf, bufsize)) == NULL) + err(EXIT_FAILURE, NULL); + } + memcpy(buf, cp, len - 1); + buf[len - 1] = '\n'; + buf[len] = '\0'; + if (n != NULL) + *n = len; + return (buf); +} + +static void +merge(int m1, int m2) +{ + struct diff *d1, *d2, *d3; + int dup, j, t1, t2; + + d1 = d13; + d2 = d23; + j = 0; + + if ((istextfile(fp[0]) && istextfile(fp[1]) && istextfile(fp[2])) == 0) { + printf("Binary file detected; comparison failed\n"); + exit(EXIT_FAILURE); + } + while ((t1 = d1 < d13 + m1) | (t2 = d2 < d23 + m2)) { + if (debug) { + printf("%d,%d=%d,%d %d,%d=%d,%d\n", + d1->old.from,d1->old.to, + d1->new.from,d1->new.to, + d2->old.from,d2->old.to, + d2->new.from,d2->new.to); + } + /* first file is different from others */ + if (!t2 || (t1 && d1->new.to < d2->new.from)) { + /* stuff peculiar to 1st file */ + if (eflag == 0) { + separate("1"); + change(1, &d1->old, 0); + keep(2, &d1->new); + change(3, &d1->new, 0); + } + d1++; + continue; + } + /* second file is different from others */ + if (!t1 || (t2 && d2->new.to < d1->new.from)) { + if (eflag == 0) { + separate("2"); + keep(1, &d2->new); + change(2, &d2->old, 0); + change(3, &d2->new, 0); + } + d2++; + continue; + } + /* + * Merge overlapping changes in first file + * this happens after extension (see below). + */ + if (d1 + 1 < d13 + m1 && d1->new.to >= d1[1].new.from) { + d1[1].old.from = d1->old.from; + d1[1].new.from = d1->new.from; + d1++; + continue; + } + + /* merge overlapping changes in second */ + if (d2 + 1 < d23 + m2 && d2->new.to >= d2[1].new.from) { + d2[1].old.from = d2->old.from; + d2[1].new.from = d2->new.from; + d2++; + continue; + } + /* stuff peculiar to third file or different in all */ + if (d1->new.from == d2->new.from && d1->new.to == d2->new.to) { + dup = duplicate(&d1->old,&d2->old); + /* + * dup = 0 means all files differ + * dup = 1 means files 1 and 2 identical + */ + if (eflag == 0) { + separate(dup ? "3" : ""); + change(1, &d1->old, dup); + change(2, &d2->old, 0); + d3 = d1->old.to > d1->old.from ? d1 : d2; + change(3, &d3->new, 0); + } else + j = edit(d1, dup, j); + d1++; + d2++; + continue; + } + /* + * Overlapping changes from file 1 and 2; extend changes + * appropriately to make them coincide. + */ + if (d1->new.from < d2->new.from) { + d2->old.from -= d2->new.from-d1->new.from; + d2->new.from = d1->new.from; + } else if (d2->new.from < d1->new.from) { + d1->old.from -= d1->new.from-d2->new.from; + d1->new.from = d2->new.from; + } + if (d1->new.to > d2->new.to) { + d2->old.to += d1->new.to - d2->new.to; + d2->new.to = d1->new.to; + } else if (d2->new.to > d1->new.to) { + d1->old.to += d2->new.to - d1->new.to; + d1->new.to = d2->new.to; + } + } + if (eflag) + edscript(j); +} + +static int +istextfile(FILE *f) +{ + int i, check_size; + char ch; + + if (aflag || f == NULL) + return (1); + rewind(f); + for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { + ch = fgetc(f); + if (ch == '\0') { + rewind(f); + return (0); + } + } + rewind(f); + return (1); +} + +static void +separate(const char *s) +{ + + printf("====%s\n", s); +} + +/* + * The range of lines rold.from thru rold.to in file i is to be changed. + * It is to be printed only if it does not duplicate something to be + * printed later. + */ +static void +change(int i, struct range *rold, int dup) +{ + + printf("%d:", i); + last[i] = rold->to; + prange(rold); + if (dup || debug) + return; + i--; + (void)skip(i, rold->from, NULL); + (void)skip(i, rold->to, " "); +} + +/* + * Print the range of line numbers, rold.from thru rold.to, as n1,n2 or + * n1. + */ +static void +prange(struct range *rold) +{ + + if (rold->to <= rold->from) + printf("%da\n", rold->from - 1); + else { + printf("%d", rold->from); + if (rold->to > rold->from+1) + printf(",%d", rold->to - 1); + printf("c\n"); + } +} + +/* + * No difference was reported by diff between file 1 (or 2) and file 3, + * and an artificial dummy difference (trange) must be ginned up to + * correspond to the change reported in the other file. + */ +static void +keep(int i, struct range *rnew) +{ + int delta; + struct range trange; + + delta = last[3] - last[i]; + trange.from = rnew->from - delta; + trange.to = rnew->to - delta; + change(i, &trange, 1); +} + +/* + * skip to just before line number from in file "i". If "pr" is non-NULL, + * print all skipped stuff with string pr as a prefix. + */ +static int +skip(int i, int from, char *pr) +{ + size_t j, n; + char *line; + + for (n = 0; cline[i] < from - 1; n += j) { + if ((line = getline(fp[i], &j)) == NULL) + trouble(); + if (pr != NULL) + printf("%s%s", Tflag == 1? "\t" : pr, line); + cline[i]++; + } + return ((int) n); +} + +/* + * Return 1 or 0 according as the old range (in file 1) contains exactly + * the same data as the new range (in file 2). + */ +static int +duplicate(struct range *r1, struct range *r2) +{ + int c, d; + int nchar; + int nline; + + if (r1->to-r1->from != r2->to-r2->from) + return (0); + (void)skip(0, r1->from, NULL); + (void)skip(1, r2->from, NULL); + nchar = 0; + for (nline=0; nline < r1->to - r1->from; nline++) { + do { + c = getc(fp[0]); + d = getc(fp[1]); + if (c == -1 || d== -1) + trouble(); + nchar++; + if (c != d) { + repos(nchar); + return (0); + } + } while (c != '\n'); + } + repos(nchar); + return (1); +} + +static void +repos(int nchar) +{ + int i; + + for (i = 0; i < 2; i++) + (void)fseek(fp[i], (long)-nchar, SEEK_CUR); +} + +/* If file has trailing carriage return, remove it. */ +static void +remove_cr(FILE *f) +{ + char ch; + fpos_t position; + fpos_t tcr_pos; + + while (ch != EOF) { + fgetpos(f, &position); + ch = fgetc(f); + if ((ch == '\r' || ch == '\n') && fgetc(f) == EOF) { + tcr_pos = position; + break; + } + } + if (&tcr_pos != NULL) { + fsetpos(f, &tcr_pos); + fputc((int)'\0', f); + } + rewind(f); +} + +static void +trouble(void) +{ + + errx(EXIT_FAILURE, "logic error"); +} + +/* + * collect an editing script for later regurgitation + */ +static int +edit(struct diff *diff, int dup, int j) +{ + + if (((dup + 1) & eflag) == 0) + return (j); + j++; + overlap[j] = !dup; + if (!dup) + overlapcnt++; + de[j].old.from = diff->old.from; + de[j].old.to = diff->old.to; + de[j].new.from = de[j-1].new.to + skip(2, diff->new.from, NULL); + de[j].new.to = de[j].new.from + skip(2, diff->new.to, NULL); + return (j); +} + +/* regurgitate */ +static void +edscript(int n) +{ + int j, k; + char block[BUFSIZ]; + + for (n = n; n > 0; n--) { + if (!oflag || !overlap[n]) + prange(&de[n].old); + else + printf("%da\n=======\n", de[n].old.to -1); + (void)fseek(fp[2], (long)de[n].new.from, SEEK_SET); + for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) { + j = k > BUFSIZ ? BUFSIZ : k; + if (fread(block, 1, j, fp[2]) != j) + trouble(); + (void)fwrite(block, 1, j, stdout); + } + if (!oflag || !overlap[n]) + printf(".\n"); + else { + printf("%s\n.\n", f3mark); + printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); + } + } + if (iflag) + printf("w\nq\n"); + + exit(overlapcnt); +} + +static void +increase(void) +{ + struct diff *p; + char *q; + size_t newsz, incr; + + /* are the memset(3) calls needed? */ + newsz = szchanges == 0 ? 64 : 2 * szchanges; + incr = newsz - szchanges; + + p = realloc(d13, newsz * sizeof(struct diff)); + if (p == NULL) + err(1, NULL); + memset(p + szchanges, 0, incr * sizeof(struct diff)); + d13 = p; + p = realloc(d23, newsz * sizeof(struct diff)); + if (p == NULL) + err(1, NULL); + memset(p + szchanges, 0, incr * sizeof(struct diff)); + d23 = p; + p = realloc(de, newsz * sizeof(struct diff)); + if (p == NULL) + err(1, NULL); + memset(p + szchanges, 0, incr * sizeof(struct diff)); + de = p; + q = realloc(overlap, newsz * sizeof(char)); + if (q == NULL) + err(1, NULL); + memset(q + szchanges, 0, incr * sizeof(char)); + overlap = q; + szchanges = newsz; +} + +static void +help(void) +{ + + printf("%s", + "\t-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE.\n" + "\t-A --show-all Output all changes, bracketing conflicts.\n" + "\t-x --overlap-only Output overlapping changes.\n" + "\t-3 --easy-only Output unmerged nonoverlapping changes.\n\n"); + printf("%s", + "\t-m --merge Output merged file instead of ed script (default -A).\n" + "\t-L LABEL --label=LABEL Use LABEL instead of file name.\n" + "\t-a --text Treat all files as text.\n" + "\t-T --initial-tab Make tabs line up by prepending a tab.\n\n"); + printf("%s", + "\t-v --version Output version info.\n" + "\t--help Output this help.\n\n"); +} + +static void +usage(void) +{ + + fprintf(stderr, "usage: diff3 %s file1 file2 file3\n", OPTIONS); + exit(EXIT_FAILURE); +} From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 12:41:53 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id AB7B6106564A for ; Fri, 10 Aug 2012 12:41:51 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 12:41:51 +0000 Date: Fri, 10 Aug 2012 12:41:51 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810124151.AB7B6106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240240 - in soc2012/gpf: pefs_head/head/sys/kern pefs_head/head/sys/security/mac pefs_head/head/sys/vm pefs_kmod/sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 12:41:53 -0000 Author: gpf Date: Fri Aug 10 12:41:51 2012 New Revision: 240240 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240240 Log: -introduce new MAC hook mac_vnode_check_exec_noscript() that will not be called for scripts; only for regular executables and interpreters. -use mac_vnode_check_mmap() to see if there's an attempt to mmap a vnode with the PROT_EXEC flag turned on. -introduce new MAC hook mac_vnode_set_mmap_maxprot() in an attempt to control mprotect(2) attempts with the PROT_EXEC flag. Please refer to the large comment headers that can be found in pefs_kmod/sys/fs/pefs/pefs_mac.c for a more thorough and up to date explanation of this svn commit. Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c soc2012/gpf/pefs_head/head/sys/security/mac/mac_framework.h soc2012/gpf/pefs_head/head/sys/security/mac/mac_policy.h soc2012/gpf/pefs_head/head/sys/security/mac/mac_vfs.c soc2012/gpf/pefs_head/head/sys/vm/vm_mmap.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Modified: soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_head/head/sys/kern/kern_exec.c Fri Aug 10 12:41:51 2012 (r240240) @@ -548,21 +548,11 @@ goto interpret; } - //{ - ///* XXXgpf: [TODO] place this in a MAC hook */ - //int enabled, rval; - //size_t enabled_len; - - //rval = kernel_sysctlbyname(td, "vfs.pefs.exec.enable", - //&enabled, &enabled_len, NULL, 0, NULL, 0); - - //if (rval == 0 && enabled != 0) { - //if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) { - //error = EPERM; - //goto exec_fail_dealloc; - //} - //} - //} +#ifdef MAC + error = mac_vnode_check_exec_noscript(td->td_ucred, imgp->vp, imgp); + if (error) + goto exec_fail_dealloc; +#endif /* * NB: We unlock the vnode here because it is believed that none Modified: soc2012/gpf/pefs_head/head/sys/security/mac/mac_framework.h ============================================================================== --- soc2012/gpf/pefs_head/head/sys/security/mac/mac_framework.h Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_head/head/sys/security/mac/mac_framework.h Fri Aug 10 12:41:51 2012 (r240240) @@ -91,6 +91,7 @@ #include /* XXX acl_type_t */ #include /* accmode_t */ +#include /* XXX vm_prot_t */ /* * Entry points to the TrustedBSD MAC Framework from the remainder of the @@ -383,6 +384,8 @@ int attrnamespace, const char *name); int mac_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct image_params *imgp); +int mac_vnode_check_exec_noscript(struct ucred *cred, struct vnode *vp, + struct image_params *imgp); int mac_vnode_check_getacl(struct ucred *cred, struct vnode *vp, acl_type_t type); int mac_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, @@ -395,6 +398,8 @@ struct componentname *cnp); int mac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, int prot, int flags); +void mac_vnode_set_mmap_maxprot(struct ucred *cred, struct vnode *vp, + vm_prot_t *maxprotp, int flags); int mac_vnode_check_mprotect(struct ucred *cred, struct vnode *vp, int prot); int mac_vnode_check_open(struct ucred *cred, struct vnode *vp, Modified: soc2012/gpf/pefs_head/head/sys/security/mac/mac_policy.h ============================================================================== --- soc2012/gpf/pefs_head/head/sys/security/mac/mac_policy.h Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_head/head/sys/security/mac/mac_policy.h Fri Aug 10 12:41:51 2012 (r240240) @@ -65,6 +65,7 @@ */ #include /* XXX acl_type_t */ #include /* XXX accmode_t */ +#include /* XXX vm_prot_t */ struct acl; struct auditinfo; @@ -566,6 +567,9 @@ typedef int (*mpo_vnode_check_exec_t)(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel); +typedef int (*mpo_vnode_check_exec_noscript_t)(struct ucred *cred, + struct vnode *vp, struct label *vplabel, + struct image_params *imgp, struct label *execlabel); typedef int (*mpo_vnode_check_getacl_t)(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type); @@ -585,6 +589,9 @@ typedef int (*mpo_vnode_check_mmap_t)(struct ucred *cred, struct vnode *vp, struct label *label, int prot, int flags); +typedef void (*mpo_vnode_set_mmap_maxprot_t)(struct ucred *cred, + struct vnode *vp, struct label *label, vm_prot_t *maxprotp, + int flags); typedef void (*mpo_vnode_check_mmap_downgrade_t)(struct ucred *cred, struct vnode *vp, struct label *vplabel, int *prot); typedef int (*mpo_vnode_check_mprotect_t)(struct ucred *cred, @@ -922,12 +929,14 @@ mpo_vnode_check_deleteacl_t mpo_vnode_check_deleteacl; mpo_vnode_check_deleteextattr_t mpo_vnode_check_deleteextattr; mpo_vnode_check_exec_t mpo_vnode_check_exec; + mpo_vnode_check_exec_noscript_t mpo_vnode_check_exec_noscript; mpo_vnode_check_getacl_t mpo_vnode_check_getacl; mpo_vnode_check_getextattr_t mpo_vnode_check_getextattr; mpo_vnode_check_link_t mpo_vnode_check_link; mpo_vnode_check_listextattr_t mpo_vnode_check_listextattr; mpo_vnode_check_lookup_t mpo_vnode_check_lookup; mpo_vnode_check_mmap_t mpo_vnode_check_mmap; + mpo_vnode_set_mmap_maxprot_t mpo_vnode_set_mmap_maxprot; mpo_vnode_check_mmap_downgrade_t mpo_vnode_check_mmap_downgrade; mpo_vnode_check_mprotect_t mpo_vnode_check_mprotect; mpo_vnode_check_open_t mpo_vnode_check_open; Modified: soc2012/gpf/pefs_head/head/sys/security/mac/mac_vfs.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/security/mac/mac_vfs.c Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_head/head/sys/security/mac/mac_vfs.c Fri Aug 10 12:41:51 2012 (r240240) @@ -489,6 +489,24 @@ return (error); } +MAC_CHECK_PROBE_DEFINE3(vnode_check_exec_noscript, "struct ucred *", + "struct vnode *", "struct image_params *"); + +int +mac_vnode_check_exec_noscript(struct ucred *cred, struct vnode *vp, + struct image_params *imgp) +{ + int error; + + ASSERT_VOP_LOCKED(vp, "mac_vnode_check_exec_noscript"); + + MAC_POLICY_CHECK(vnode_check_exec_noscript, cred, vp, vp->v_label, imgp, + imgp->execlabel); + MAC_CHECK_PROBE3(vnode_check_exec_noscript, error, cred, vp, imgp); + + return (error); +} + MAC_CHECK_PROBE_DEFINE3(vnode_check_getacl, "struct ucred *", "struct vnode *", "acl_type_t"); @@ -597,6 +615,17 @@ } void +mac_vnode_set_mmap_maxprot(struct ucred *cred, struct vnode *vp, + vm_prot_t *maxprotp, int flags) +{ + + ASSERT_VOP_LOCKED(vp, "mac_vnode_set_mmap_maxprot"); + + MAC_POLICY_PERFORM(vnode_set_mmap_maxprot, cred, vp, vp->v_label, + maxprotp, flags); +} + +void mac_vnode_check_mmap_downgrade(struct ucred *cred, struct vnode *vp, int *prot) { Modified: soc2012/gpf/pefs_head/head/sys/vm/vm_mmap.c ============================================================================== --- soc2012/gpf/pefs_head/head/sys/vm/vm_mmap.c Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_head/head/sys/vm/vm_mmap.c Fri Aug 10 12:41:51 2012 (r240240) @@ -1295,6 +1295,7 @@ error = mac_vnode_check_mmap(cred, vp, prot, flags); if (error != 0) goto done; + mac_vnode_set_mmap_maxprot(cred, vp, maxprotp, flags); #endif if ((flags & MAP_SHARED) != 0) { if ((va.va_flags & (SF_SNAPSHOT|IMMUTABLE|APPEND)) != 0) { Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Fri Aug 10 11:11:04 2012 (r240239) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Fri Aug 10 12:41:51 2012 (r240240) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,8 @@ #include #include +#include + #include #include @@ -49,24 +52,24 @@ * The problem with this MAC hook is that the hook is called before * do_execve() checks if our executable requires an interpreter. * Therefore, the script file will itself be checked for the schg flag. - * + * * We could: - * + * * a) allow this because it's a feature! During development of a script, - * user will have to pass it as an argument to the interpreter and when it's + * user will have to pass it as an argument to the interpreter and when it's * complete, continue calling it like that or add the schg flag. - * + * * b) add a brand new MAC hook that will be called at the precise point - * in do_execve() where only the interpreter or the regular executable + * in do_execve() where only the interpreter or the regular executable * will be checked for the schg flag. [don't seem the other devs will go * for us modifying MAC framework though] - * - * c) duplicate code from do_execve() and perform the check ourselves. It + * + * c) duplicate code from do_execve() and perform the check ourselves. It * could be done I guess but I'm not sure since image activators seem to have * their own custom functions that are called in order to figure out whether * the interpreted flag should be turned on. Don't know how much they are * allowed to tamper with imgp, besides that flag. - * + * */ static int pefs_vnode_check_exec(struct ucred *cred, struct vnode *vp, @@ -88,18 +91,128 @@ return (0); } +/* + * XXXgpf: + * + * This new hook is placed in do_execve(), found in sys/kern/kern_exec.c. + * Its purpose is to only check the interpreter for the schg flag in case + * there's an executable that requires an interpreter. + * + * It is placed after exec_check_permissions() and it will be called after + * we've looped back for the interpreter. Therefore, only either the interpeter + * or the regular executable itself will ever be checked by this hook; we'll + * never check the script file itself. + * + * It uses a different dbg sysctl var than the above hook for obvious reasons. + */ +static int +pefs_vnode_check_exec_noscript(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct image_params *imgp, + struct label *execlabel) +{ + int enabled, rval; + size_t enabled_len; + + rval = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable_noscript", + &enabled, &enabled_len, NULL, 0, NULL, 0); + + if (rval == 0 && enabled != 0) { + if ((imgp->attr->va_flags & SF_IMMUTABLE) == 0) + return (EPERM); + } + + return (0); +} + + +/* + * XXXgpf: Check if schg is turned on when we mmap() a vnode with + * the PROT_EXEC flag. + */ +static int +pefs_vnode_check_mmap(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int prot, int flags) +{ + struct vattr va; + int enabled1, enabled2, error, rval1, rval2; + size_t enabled_len; + + if ((prot & PROT_EXEC) == 0) + return (0); + + rval1 = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable", + &enabled1, &enabled_len, NULL, 0, NULL, 0); + + rval2 = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable_noscript", + &enabled2, &enabled_len, NULL, 0, NULL, 0); + + if ((rval1 == 0 && enabled1 != 0) || (rval2 == 0 && enabled2 != 0)) { + error = VOP_GETATTR(vp, &va, cred); + if (error != 0) + return (EACCES); + + if ((va.va_flags & SF_IMMUTABLE) == 0) + return (EACCES); + } + + return (0); +} + +/* + * XXXgpf: + * + * Checking mmap(2) with the above MAC hook is not enough if we wish to + * prevent user from mmaping a file and then executing those pages due to + * mprotect(2). + * + * I did notice the existance of mac_vnode_check_mprotect(), but unfortunately + * it's not used anywhere in the kernel for some reason(?)! If it ever comes + * back into action, I believe it would be preferable to the following solution. + * + * My alternative solution was to set the MAXPROT flag of the mapped area + * during mmap(). If we are mapping a file and we need schg protection, we + * remove VM_PROT_EXECUTE from MAXPROT which in turn causes following attempts + * to mprotect() with PROT_EXEC to fail. + */ +static void +pefs_vnode_set_mmap_maxprot(struct ucred *cred, struct vnode *vp, + struct label *vplabel, vm_prot_t *maxprotp, int flags) +{ + int enabled1, enabled2, rval1, rval2; + size_t enabled_len; + + if ((*maxprotp & VM_PROT_EXECUTE) == 0) + return; + + rval1 = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable", + &enabled1, &enabled_len, NULL, 0, NULL, 0); + + rval2 = kernel_sysctlbyname(curthread, "vfs.pefs.exec.enable_noscript", + &enabled2, &enabled_len, NULL, 0, NULL, 0); + + if ((rval1 == 0 && enabled1 != 0) || (rval2 == 0 && enabled2 != 0)) + *maxprotp &= ~VM_PROT_EXECUTE; +} + static struct mac_policy_ops pefs_ops = { .mpo_vnode_check_exec = pefs_vnode_check_exec, + .mpo_vnode_check_exec_noscript = pefs_vnode_check_exec_noscript, + .mpo_vnode_check_mmap = pefs_vnode_check_mmap, + .mpo_vnode_set_mmap_maxprot = pefs_vnode_set_mmap_maxprot, }; MAC_POLICY_SET(&pefs_ops, mac_pefs, "pefs exec protection", MPC_LOADTIME_FLAG_UNLOADOK, NULL); -/* XXXgpf: declare our debugging sysctl for kern_exec.c */ +/* XXXgpf: declare our debugging sysctls for schg execution control */ SYSCTL_NODE(_vfs_pefs, OID_AUTO, exec, CTLFLAG_RW, 0, "PEFS kern_exec.c stuff"); int pefs_exec_enable = 0; SYSCTL_INT(_vfs_pefs_exec, OID_AUTO, enable, CTLFLAG_RW, &pefs_exec_enable, 0, "Enable exec protection"); + +int pefs_exec_enable_noscript = 0; +SYSCTL_INT(_vfs_pefs_exec, OID_AUTO, enable_noscript, CTLFLAG_RW, + &pefs_exec_enable_noscript, 0, "Enable exec protection [no scripts]"); From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 14:53:36 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 654D2106566B for ; Fri, 10 Aug 2012 14:53:34 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 14:53:34 +0000 Date: Fri, 10 Aug 2012 14:53:34 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810145334.654D2106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240242 - in soc2012/aleek/beaglexm-armv6/sys/arm: conf ti/usb X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 14:53:36 -0000 Author: aleek Date: Fri Aug 10 14:53:33 2012 New Revision: 240242 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240242 Log: reverted ehci changes. It is still not working Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Fri Aug 10 13:36:33 2012 (r240241) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Fri Aug 10 14:53:33 2012 (r240242) @@ -82,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s3\" # Console and misc @@ -109,21 +109,21 @@ options USB_DEBUG options USB_REQ_DEBUG options USB_VERBOSE -device musb +#device musb device ehci device umass device scbus # SCSI bus (required for SCSI) -device da # Direct Access (disks) +#device da # Direct Access (disks) # Ethernet device loop -device ether -device mii -device smcphy +#device ether +#device mii +#device smcphy # USB ethernet support, requires miibus -device miibus -device smsc +#device miibus +#device smsc # Flattened Device Tree options FDT Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Fri Aug 10 13:36:33 2012 (r240241) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Fri Aug 10 14:53:33 2012 (r240242) @@ -920,7 +920,7 @@ /* Finally we are ready to kick off the ECHI host controller */ - err = 0; //ehci_init(sc); + err = ehci_init(sc); if (err == 0) { err = device_probe_and_attach(sc->sc_bus.bdev); } From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 15:51:37 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D6BDB1065674 for ; Fri, 10 Aug 2012 15:51:35 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 15:51:35 +0000 Date: Fri, 10 Aug 2012 15:51:35 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810155135.D6BDB1065674@hub.freebsd.org> Cc: Subject: socsvn commit: r240245 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 15:51:37 -0000 Author: gpf Date: Fri Aug 10 15:51:34 2012 New Revision: 240245 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240245 Log: rework how nameids are used by the codebase. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Aug 10 14:51:41 2012 (r240244) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Aug 10 15:51:34 2012 (r240245) @@ -127,12 +127,17 @@ TAILQ_ENTRY(checksum) checksum_entries; }; +union file_id { + uint64_t fid_num; + uint8_t fid_str[8]; +}; + /* XXXgpf: [TODO] turns offsets to uint64_t? */ struct file_header { /* on disk information */ uint32_t nhashes; /* the number of hashes for the file */ uint32_t offset_to_checksums; /* in file offset to start of checksums */ - uint64_t file_id; /* id is MAC tweak from filename (first 64 bits) */ + union file_id fid; /* id is MAC tweak from filename (first 64 bits) */ /* in memory information */ char path[MAXPATHLEN + 1]; /* fullpath for this file */ @@ -472,7 +477,7 @@ fhp->nhashes = 0; fhp->offset_to_checksums = 0; - fhp->file_id = 0; + fhp->fid.fid_num = 0; fhp->fd = -1; fhp->pfd = -1; fhp->found = 0; @@ -545,7 +550,7 @@ { uint32_t nbucket; - nbucket = fhp->file_id % chtp->size; + nbucket = fhp->fid.fid_num % chtp->size; dprintf(("hash1: goto bucket %d\n", nbucket)); return (nbucket); } @@ -555,8 +560,8 @@ { uint32_t nbucket; - nbucket = fnv_64_buf(&(fhp->file_id), sizeof(fhp->file_id), FNV1_64_INIT) % - chtp->size; + nbucket = fnv_64_buf(&(fhp->fid.fid_num), sizeof(fhp->fid.fid_num), + FNV1_64_INIT) % chtp->size; dprintf(("hash2: goto bucket %d\n", nbucket)); return (nbucket); @@ -572,7 +577,7 @@ pos1 = pefs_hash1(chtp, elem); elem1 = chtp->buckets1[pos1].fhp; if (elem1 != NULL) { - if (elem1->file_id == elem->file_id) { + if (elem1->fid.fid_num == elem->fid.fid_num) { return (elem1); } } @@ -580,7 +585,7 @@ pos2 = pefs_hash2(chtp, elem); elem2 = chtp->buckets2[pos2].fhp; if (elem2 != NULL) { - if (elem2->file_id == elem->file_id) { + if (elem2->fid.fid_num == elem->fid.fid_num) { return (elem2); } } @@ -648,7 +653,8 @@ fhp = chtp->buckets1[i].fhp; dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1)); if (fhp != NULL) { - dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes)); + dprintf(("\tid = %llu\tnhashes = %d\n", fhp->fid.fid_num, + fhp->nhashes)); if (fhp->path[0] == '/') dprintf(("\tpath = %s\n", fhp->path)); TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) { @@ -665,7 +671,8 @@ fhp = chtp->buckets2[i].fhp; dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1)); if (fhp != NULL) { - dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes)); + dprintf(("\tid = %llu\tnhashes = %d\n", fhp->fid.fid_num, + fhp->nhashes)); if (fhp->path[0] == '/') dprintf(("\tpath = %s\n", fhp->path)); TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) { @@ -715,8 +722,7 @@ error = PEFS_ERR_GENERIC; } else { - memcpy(&temp, buf, sizeof(temp)); - fhp->file_id = be64toh(temp); + memcpy(fhp->fid.fid_str, buf, sizeof(temp)); error = 0; } @@ -730,10 +736,8 @@ /* feed parent directory to ioctl() */ error = ioctl(fhp->pfd, PEFS_GETNAMECSUM, &xncs); - if (error == 0) { - memcpy(&temp, xncs.pxnc_csum, sizeof(xncs.pxnc_csum)); - fhp->file_id = be64toh(temp); - } + if (error == 0) + memcpy(fhp->fid.fid_str, xncs.pxnc_csum, sizeof(xncs.pxnc_csum)); else pefs_warn("failed to fetch file id from kernel for filename: %s", fhp->filename); @@ -1267,7 +1271,6 @@ pefs_write_file_header(int fdout, struct file_header *fhp, uint32_t *buckets_offset) { - uint64_t file_id; uint32_t nhashes, offset_to_checksums; int bytes; @@ -1288,13 +1291,13 @@ } (*buckets_offset)+= sizeof(offset_to_checksums); - file_id = htole64(fhp->file_id); - bytes = pwrite(fdout, &file_id, sizeof(file_id), *buckets_offset); - if (bytes != sizeof(file_id)) { + bytes = pwrite(fdout, fhp->fid.fid_str, sizeof(fhp->fid.fid_str), + *buckets_offset); + if (bytes != sizeof(fhp->fid.fid_str)) { warn("error writing to .pefs.checksum"); return (PEFS_ERR_IO); } - (*buckets_offset)+= sizeof(file_id); + (*buckets_offset)+= sizeof(fhp->fid.fid_str); return (0); } @@ -1309,7 +1312,7 @@ /* Empty files aren't allowed so nhashes == 0 symbolizes an empty bucket */ if (fhp == NULL) { emptyfh.nhashes = 0; - emptyfh.file_id = 0; + emptyfh.fid.fid_num = 0; emptyfh.offset_to_checksums = 0; fhp = &emptyfh; } @@ -1335,12 +1338,13 @@ /* * All data member writes are done separately so as to avoid alignment problems. - * Writes are always in little endian byte order. + * Writes are always in little endian byte order, except file_id which is + * always treated as big endian. * - * First 512 bytes of .pefs.checksum are reserved for the file's digital + * First 512 bytes of .pefs.checksum are reserved for the file's digital * signature. - * - * After that, the next 16 bytes of .pefs.checksum are filled with + * + * After that, the next 16 bytes of .pefs.checksum are filled with * .pefs.checksum's global file header. Right after this header lies the * 'index' part of our database. * This index is later kept in kernel memory. @@ -1827,7 +1831,6 @@ pefs_read_file_header(int fdin, struct file_header *fhp, uint32_t *buckets_offset) { - uint64_t file_id; uint32_t nhashes, offset_to_checksums; int bytes; @@ -1848,13 +1851,13 @@ fhp->offset_to_checksums = le32toh(offset_to_checksums); (*buckets_offset)+= sizeof(offset_to_checksums); - bytes = pread(fdin, &file_id, sizeof(file_id), *buckets_offset); - if (bytes != sizeof(file_id)) { + bytes = pread(fdin, fhp->fid.fid_str, sizeof(fhp->fid.fid_str), + *buckets_offset); + if (bytes != sizeof(fhp->fid.fid_str)) { warn("error reading from .pefs.checksum"); return (PEFS_ERR_IO); } - fhp->file_id = le64toh(file_id); - (*buckets_offset)+= sizeof(file_id); + (*buckets_offset)+= sizeof(fhp->fid.fid_str); //dprintf(("\nfile header offset = %d\n", *fh_offset)); //dprintf(("\n++priting file header info++\n")); @@ -2005,7 +2008,8 @@ uint32_t i; int error, cmp; - dprintf(("comparing hashes for file with fid: %llu\n", fhp->file_id)); + dprintf(("comparing hashes for file with fid: %llu\n", + fhp->fid.fid_num)); error = 0; if (fhp->nhashes != indexfhp->nhashes) { @@ -2187,7 +2191,7 @@ if (fhp->found != 1) { pefs_warn("file with file id %llu was not found in " "filesystem but exists in %s", - fhp->file_id, PEFS_FILE_CHECKSUM); + fhp->fid.fid_num, PEFS_FILE_CHECKSUM); error = PEFS_ERR_NOENT; } } @@ -2198,7 +2202,7 @@ if (fhp->found != 1) { pefs_warn("file with file id %llu was not found in " "filesystem but exists in %s", - fhp->file_id, PEFS_FILE_CHECKSUM); + fhp->fid.fid_num, PEFS_FILE_CHECKSUM); error = PEFS_ERR_NOENT; } } @@ -2313,7 +2317,7 @@ if (error != 0) goto out; - printf("id: %llu\n", fhp->file_id); + printf("id: %llu\n", fhp->fid.fid_num); out: pefs_free_file_header(fhp); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Aug 10 14:51:41 2012 (r240244) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Aug 10 15:51:34 2012 (r240245) @@ -1023,7 +1023,7 @@ * path defines where .pefs.checksum should be created. By default, * .pefs.checksum is created under $PWD. path should be a directory, * outside of target pefs filesystem. - * + * * pkey_file is the file that contains the private key that will be used * by the DSA signing algorithm. Key should be in PEM format. * Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Aug 10 14:51:41 2012 (r240244) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Aug 10 15:51:34 2012 (r240245) @@ -77,7 +77,6 @@ //offset = le32toh(offset); //p+=sizeof(offset); //memcpy(&file_id, p, sizeof(file_id)); - //file_id = le64toh(file_id); //printf("cell %d:\n", i); //printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", //nhashes, offset, file_id); @@ -99,7 +98,6 @@ //offset = le32toh(offset); //p+=sizeof(offset); //memcpy(&file_id, p, sizeof(file_id)); - //file_id = le64toh(file_id); //printf("cell %d:\n", i); //printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", //nhashes, offset, file_id); @@ -147,7 +145,7 @@ { uint32_t nbucket; - nbucket = pcie->pcie_file_id % pc->pcs_hash_table_size; + nbucket = pcie->pcie_fid.pcfi_num % pc->pcs_hash_table_size; dprintf(("hash1: goto bucket %d\n", nbucket)); return (nbucket); } @@ -158,8 +156,9 @@ { uint32_t nbucket; - nbucket = fnv_64_buf(&(pcie->pcie_file_id), sizeof(pcie->pcie_file_id), - FNV1_64_INIT) % pc->pcs_hash_table_size; + nbucket = fnv_64_buf(&(pcie->pcie_fid.pcfi_num), + sizeof(pcie->pcie_fid.pcfi_num), FNV1_64_INIT) % + pc->pcs_hash_table_size; dprintf(("hash2: goto bucket %d\n", nbucket)); return (nbucket); @@ -180,8 +179,7 @@ pcie->pcie_offset = le32toh(pcie->pcie_offset); p+=sizeof(pcie->pcie_offset); - memcpy(&(pcie->pcie_file_id), p, sizeof(pcie->pcie_file_id)); - pcie->pcie_file_id = le64toh(pcie->pcie_file_id); + memcpy(pcie->pcie_fid.pcfi_str, p, sizeof(pcie->pcie_fid.pcfi_str)); } } @@ -204,9 +202,9 @@ dprintf(("cell %d:\n", pos)); dprintf(("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", target_pcie.pcie_nhashes, target_pcie.pcie_offset, - target_pcie.pcie_file_id)); + target_pcie.pcie_fid.pcfi_num)); - if (target_pcie.pcie_file_id == pcie->pcie_file_id) { + if (target_pcie.pcie_fid.pcfi_num == pcie->pcie_fid.pcfi_num) { pn->pn_checksum_index_entry = start; dprintf(("checksum lookup: found1!\n")); return (0); @@ -221,9 +219,9 @@ dprintf(("cell %d:\n", pos)); dprintf(("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", target_pcie.pcie_nhashes, target_pcie.pcie_offset, - target_pcie.pcie_file_id)); + target_pcie.pcie_fid.pcfi_num)); - if (target_pcie.pcie_file_id == pcie->pcie_file_id) { + if (target_pcie.pcie_fid.pcfi_num == pcie->pcie_fid.pcfi_num) { pn->pn_checksum_index_entry = start; dprintf(("checksum lookup: found2!\n")); return (0); @@ -273,9 +271,8 @@ dprintf(("name_pton error: %d\n", error)); } else { - memcpy(&(pcie.pcie_file_id), buf, sizeof(pcie.pcie_file_id)); - pcie.pcie_file_id = be64toh(pcie.pcie_file_id); - dprintf(("id to lookup: %llu\n", pcie.pcie_file_id)); + memcpy(pcie.pcie_fid.pcfi_str, buf, sizeof(pcie.pcie_fid.pcfi_str)); + dprintf(("id to lookup: %llu\n", pcie.pcie_fid.pcfi_num)); error = pefs_checksum_index_lookup(&pcie, vp); if (error != 0) { free(buf, M_TEMP); @@ -288,12 +285,13 @@ */ error = VOP_GETATTR(vp, &va, cred); if (error != 0) { - dprintf(("unable to retrieve attributes of %llu\n", pcie.pcie_file_id)); + dprintf(("unable to retrieve attributes of %llu\n", + pcie.pcie_fid.pcfi_num)); pn->pn_flags|= PN_WRONG_CHECKSUM; } else { if ((va.va_flags & SF_IMMUTABLE) == 0) { - dprintf(("schg not set for %llu\n", pcie.pcie_file_id)); + dprintf(("schg not set for %llu\n", pcie.pcie_fid.pcfi_num)); pn->pn_flags|= PN_WRONG_CHECKSUM; } } @@ -417,7 +415,7 @@ pefs_get_index_entry(pn->pn_checksum_index_entry, &pcie); - dprintf(("id: %llu\n", pcie.pcie_file_id)); + dprintf(("id: %llu\n", pcie.pcie_fid.pcfi_num)); buf = (char *)pc->pc_base; end = buf + pc->pc_size; Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Aug 10 14:51:41 2012 (r240244) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Aug 10 15:51:34 2012 (r240245) @@ -49,10 +49,15 @@ #define dprintf(a) (void)0 #endif +union pefs_checksum_file_id { + uint64_t pcfi_num; + uint8_t pcfi_str[8]; +}; + struct pefs_checksum_index_entry { uint32_t pcie_nhashes; uint32_t pcie_offset; - uint64_t pcie_file_id; + union pefs_checksum_file_id pcie_fid; }; static __inline int Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Fri Aug 10 14:51:41 2012 (r240244) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_mac.c Fri Aug 10 15:51:34 2012 (r240245) @@ -166,10 +166,10 @@ * mprotect(2). * * I did notice the existance of mac_vnode_check_mprotect(), but unfortunately - * it's not used anywhere in the kernel for some reason(?)! If it ever comes + * it's not used anywhere in the kernel for some reason(?)! If it ever comes * back into action, I believe it would be preferable to the following solution. - * - * My alternative solution was to set the MAXPROT flag of the mapped area + * + * My alternative solution was to set the MAXPROT flag of the mapped area * during mmap(). If we are mapping a file and we need schg protection, we * remove VM_PROT_EXECUTE from MAXPROT which in turn causes following attempts * to mprotect() with PROT_EXEC to fail. From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 16:26:18 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8AFF2106566B for ; Fri, 10 Aug 2012 16:26:16 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 16:26:16 +0000 Date: Fri, 10 Aug 2012 16:26:16 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810162616.8AFF2106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240249 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 16:26:18 -0000 Author: gpf Date: Fri Aug 10 16:26:15 2012 New Revision: 240249 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240249 Log: -fix typo Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Aug 10 15:29:41 2012 (r240248) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Aug 10 16:26:15 2012 (r240249) @@ -1451,7 +1451,7 @@ dsa = PEM_read_DSAPrivateKey(pk_fp, NULL, NULL, NULL); if (dsa == NULL) { - pefs_warn("error reading dsa pubkey"); + pefs_warn("error reading dsa private key"); return (NULL); } From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 17:48:11 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 99EAB106566B for ; Fri, 10 Aug 2012 17:48:10 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 17:48:10 +0000 Date: Fri, 10 Aug 2012 17:48:10 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810174810.99EAB106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240250 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 17:48:11 -0000 Author: rudot Date: Fri Aug 10 17:48:09 2012 New Revision: 240250 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240250 Log: add %cpu resource to ucred containers on racct_proc_exit() Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 16:26:15 2012 (r240249) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:48:09 2012 (r240250) @@ -159,7 +159,7 @@ RACCT_IN_MILLIONS, [RACCT_PCTCPU] = RACCT_DECAYING | RACCT_DENIABLE }; -static const fixpt_t RACCT_DECAY_FACTOR = 0.9 * FSCALE; +static const fixpt_t RACCT_DECAY_FACTOR = 0.3 * FSCALE; #ifdef SCHED_4BSD /* @@ -475,7 +475,7 @@ racct->r_resources[resource] += amount; if (racct->r_resources[resource] < 0) { - KASSERT(RACCT_IS_SLOPPY(resource), + KASSERT(RACCT_IS_SLOPPY(resource) | RACCT_IS_DECAYING(resource), ("racct_alloc_resource: usage < 0")); racct->r_resources[resource] = 0; } @@ -888,6 +888,8 @@ { int i; uint64_t runtime; + struct timeval wallclock; + u_int pct_estimate, pct; PROC_LOCK(p); /* @@ -900,8 +902,16 @@ if (runtime < p->p_prev_runtime) runtime = p->p_prev_runtime; #endif + microuptime(&wallclock); + timevalsub(&wallclock, &p->p_stats->p_start); + pct_estimate = (runtime * 100) / + ((uint64_t)wallclock.tv_sec * 1000000 + + wallclock.tv_usec); + pct = racct_getpcpu(p, pct_estimate); + mtx_lock(&racct_lock); racct_set_locked(p, RACCT_CPU, runtime); + racct_add_cred_locked(p->p_ucred, RACCT_PCTCPU, pct_estimate); for (i = 0; i <= RACCT_MAX; i++) { if (p->p_racct->r_resources[i] == 0) From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 17:51:34 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 97F0E1065735 for ; Fri, 10 Aug 2012 17:51:31 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 17:51:31 +0000 Date: Fri, 10 Aug 2012 17:51:31 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810175131.97F0E1065735@hub.freebsd.org> Cc: Subject: socsvn commit: r240251 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 17:51:34 -0000 Author: rudot Date: Fri Aug 10 17:51:31 2012 New Revision: 240251 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240251 Log: quick fix Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:48:09 2012 (r240250) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:51:31 2012 (r240251) @@ -475,7 +475,7 @@ racct->r_resources[resource] += amount; if (racct->r_resources[resource] < 0) { - KASSERT(RACCT_IS_SLOPPY(resource) | RACCT_IS_DECAYING(resource), + KASSERT(RACCT_IS_SLOPPY(resource) || RACCT_IS_DECAYING(resource), ("racct_alloc_resource: usage < 0")); racct->r_resources[resource] = 0; } From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 17:53:54 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3AF81106564A for ; Fri, 10 Aug 2012 17:53:52 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 17:53:52 +0000 Date: Fri, 10 Aug 2012 17:53:52 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810175352.3AF81106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240252 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 17:53:54 -0000 Author: rudot Date: Fri Aug 10 17:53:51 2012 New Revision: 240252 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240252 Log: another fix Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:51:31 2012 (r240251) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:53:51 2012 (r240252) @@ -911,7 +911,7 @@ mtx_lock(&racct_lock); racct_set_locked(p, RACCT_CPU, runtime); - racct_add_cred_locked(p->p_ucred, RACCT_PCTCPU, pct_estimate); + racct_add_cred_locked(p->p_ucred, RACCT_PCTCPU, pct); for (i = 0; i <= RACCT_MAX; i++) { if (p->p_racct->r_resources[i] == 0) From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 21:38:30 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7440C106566C for ; Fri, 10 Aug 2012 21:38:28 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 21:38:28 +0000 Date: Fri, 10 Aug 2012 21:38:28 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810213828.7440C106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240258 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 21:38:30 -0000 Author: jhagewood Date: Fri Aug 10 21:38:27 2012 New Revision: 240258 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240258 Log: Modified: soc2012/jhagewood/sdiff/TODO soc2012/jhagewood/sdiff/common.h Modified: soc2012/jhagewood/sdiff/TODO ============================================================================== --- soc2012/jhagewood/sdiff/TODO Fri Aug 10 19:02:49 2012 (r240257) +++ soc2012/jhagewood/sdiff/TODO Fri Aug 10 21:38:27 2012 (r240258) @@ -6,7 +6,7 @@ Add more information to man file. COMPLETE Fix sdiff to work with binary data COMPLETE TODO: Add some error checking Replace goto statements COMPLETE - +zsdiff integration IN PROGRESS NOTES: - In diff, 'w' is used for --ignore-all-spaces instead of 'W'. When 'W' is passed to sdiff, it must be passed to diff as 'w'. Modified: soc2012/jhagewood/sdiff/common.h ============================================================================== --- soc2012/jhagewood/sdiff/common.h Fri Aug 10 19:02:49 2012 (r240257) +++ soc2012/jhagewood/sdiff/common.h Fri Aug 10 21:38:27 2012 (r240258) @@ -6,3 +6,4 @@ */ void cleanup(const char *) __dead2; +FILE *decompressfile(char *, char *); From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 21:40:05 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4D5AE106564A for ; Fri, 10 Aug 2012 21:40:04 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 21:40:04 +0000 Date: Fri, 10 Aug 2012 21:40:04 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810214004.4D5AE106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240259 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 21:40:05 -0000 Author: jhagewood Date: Fri Aug 10 21:40:03 2012 New Revision: 240259 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240259 Log: gzip decompression sdiff Added: soc2012/jhagewood/sdiff/decompress.c Added: soc2012/jhagewood/sdiff/decompress.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/sdiff/decompress.c Fri Aug 10 21:40:03 2012 (r240259) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012 Jesse Hagewood + * 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. + */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)decompress.c 6/6/93"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef WITHOUT_BZIP2 +#include +#endif + +#include "common.h" + +#define MAXBUFSIZE (32 * 1024) + +/* Decompresses a gzip file and returns a regular FILE. */ +FILE * +decompressfile(char *filename, char *mode) { + + FILE *file; + char *buf = ""; + gzFile comprfile; + + if (comprfile = gzopen(filename, mode) == Z_NULL) + err(1, "Could not open compressed file %s.", filename); + gzread(comprfile, buf, MAXBUFSIZE); + fputs(buf, file); + + return file; +} From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 22:24:47 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 55812106564A for ; Fri, 10 Aug 2012 22:24:46 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 22:24:46 +0000 Date: Fri, 10 Aug 2012 22:24:46 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810222446.55812106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240261 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 22:24:47 -0000 Author: jhagewood Date: Fri Aug 10 22:24:45 2012 New Revision: 240261 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240261 Log: dates in decompress.c Modified: soc2012/jhagewood/sdiff/decompress.c Modified: soc2012/jhagewood/sdiff/decompress.c ============================================================================== --- soc2012/jhagewood/sdiff/decompress.c Fri Aug 10 21:11:00 2012 (r240260) +++ soc2012/jhagewood/sdiff/decompress.c Fri Aug 10 22:24:45 2012 (r240261) @@ -26,7 +26,7 @@ #if 0 #ifndef lint -static char sccsid[] = "@(#)decompress.c 6/6/93"; +static char sccsid[] = "@(#)decompress.c 8/10/12"; #endif #endif /* not lint */ #include From owner-svn-soc-all@FreeBSD.ORG Fri Aug 10 22:25:00 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3AD93106564A for ; Fri, 10 Aug 2012 22:24:58 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 10 Aug 2012 22:24:58 +0000 Date: Fri, 10 Aug 2012 22:24:58 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120810222458.3AD93106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r240262 - soc2012/jhagewood/diff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 22:25:00 -0000 Author: jhagewood Date: Fri Aug 10 22:24:57 2012 New Revision: 240262 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240262 Log: dates in decompress.c Modified: soc2012/jhagewood/diff/decompress.c Modified: soc2012/jhagewood/diff/decompress.c ============================================================================== --- soc2012/jhagewood/diff/decompress.c Fri Aug 10 22:24:45 2012 (r240261) +++ soc2012/jhagewood/diff/decompress.c Fri Aug 10 22:24:57 2012 (r240262) @@ -26,7 +26,7 @@ #if 0 #ifndef lint -static char sccsid[] = "@(#)decompress.c 6/6/93"; +static char sccsid[] = "@(#)decompress.c 8/10/12"; #endif #endif /* not lint */ #include From owner-svn-soc-all@FreeBSD.ORG Sat Aug 11 05:18:35 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C5E54106566C for ; Sat, 11 Aug 2012 05:18:34 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 11 Aug 2012 05:18:34 +0000 Date: Sat, 11 Aug 2012 05:18:34 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120811051834.C5E54106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240264 - in soc2012/gmiller/locking-head: . tools/regression/lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2012 05:18:35 -0000 Author: gmiller Date: Sat Aug 11 05:18:33 2012 New Revision: 240264 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240264 Log: r240281@FreeBSD-dev: root | 2012-07-25 14:13:25 -0500 Add a test to verify that locks with the same name share data in libwitness. Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.t - copied unchanged from r239709, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Sat Aug 11 00:06:56 2012 (r240263) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Sat Aug 11 05:18:33 2012 (r240264) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lor-basic setorder bless setname graph +TESTS= lor-basic setorder bless setname graph shared CFLAGS+= -g -Wall -Wextra -Werror -lwitness -lpthread -static .PHONY: tests @@ -25,3 +25,6 @@ graph: graph.c check.c ${CC} -o graph graph.c check.c ${CFLAGS} + +shared: shared.c check.c + ${CC} -o shared shared.c check.c ${CFLAGS} Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c Sat Aug 11 05:18:33 2012 (r240264) @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2012 Greg Miller .. + * 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. + * + */ + +#include +#include + +#include "check.h" + +void +share_test(void) +{ + pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; + + pthread_setname_np(mutex1, "shared_mutex"); + pthread_setname_np(mutex2, "shared_mutex"); + + pthread_mutex_lock(&mutex1); + pthread_mutex_lock(&mutex2); + + pthread_mutex_unlock(&mutex2); + pthread_mutex_unlock(&mutex1); +} + +void +check_share(void) +{ + struct pthread_lockorder_np order; + int node_count = 0; + + pthread_lockorder_begin_np(&order); + while (pthread_lockorder_next_np(&order)) { + node_count++; + } + pthread_lockorder_end_np(&order); + + check(node_count == 0); +} + +int +main(void) +{ + share_test(); + check_share(); + + show_test_results(); + + return (0); +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.t (from r239709, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.t Sat Aug 11 05:18:33 2012 (r240264, copy of r239709, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t) @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +executable=`basename $0 .t` + +make $executable 2>&1 > /dev/null + +exec ./$executable From owner-svn-soc-all@FreeBSD.ORG Sat Aug 11 05:18:54 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id E5293106566B for ; Sat, 11 Aug 2012 05:18:51 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 11 Aug 2012 05:18:51 +0000 Date: Sat, 11 Aug 2012 05:18:51 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120811051851.E5293106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240265 - in soc2012/gmiller/locking-head: . include lib/libwitness tools/regression/lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2012 05:18:54 -0000 Author: gmiller Date: Sat Aug 11 05:18:51 2012 New Revision: 240265 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240265 Log: r240330@FreeBSD-dev: root | 2012-08-11 00:17:01 -0500 Treat locks that have the same name as the same lock. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/logs.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c soc2012/gmiller/locking-head/lib/libwitness/xml.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/graph.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/include/pthread_np.h Sat Aug 11 05:18:51 2012 (r240265) @@ -62,20 +62,17 @@ struct pthread_lor_np { struct _pthread_lor_private *_pvt; - void *lock_first; - void *lock_second; - const char *name_first; - const char *name_second; + char *name_first; + char *name_second; }; struct _pthread_lockorder_private; struct pthread_lockorder_np { struct _pthread_lockorder_private *_pvt; - void *lock; char *name; - void *child; - void *sibling; + char *child; + char *sibling; }; typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Sat Aug 11 05:18:51 2012 (r240265) @@ -40,10 +40,12 @@ static int exit_set = 0; void -add_lock(struct lock_info *lock) +add_lock(void *lock) { struct lock_entry *entry; struct lock_entry *next; + struct lock_instance *inst; + struct lock_info *info; if (exit_set == 0) { atexit(write_xml); @@ -54,6 +56,9 @@ return; } + inst = lookup_lock(lock); + info = get_lock_info(inst); + next = SLIST_FIRST(&lock_head); entry = malloc(sizeof(*entry)); @@ -61,7 +66,7 @@ return; } - entry->lock = lock; + entry->lock = info; if (reset_count > thread_reset_count) { thread_reset_count = reset_count; @@ -85,13 +90,18 @@ } void -remove_lock(struct lock_info *lock) +remove_lock(void *lock) { + struct lock_instance *inst; + struct lock_info *info; struct lock_entry *entry; struct lock_entry *temp; + inst = lookup_lock(lock); + info = get_lock_info(inst); + SLIST_FOREACH_SAFE(entry, &lock_head, lock_next, temp) { - if (entry->lock == lock) { + if (entry->lock == info) { SLIST_REMOVE(&lock_head, entry, lock_entry, lock_next); free(entry); Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Sat Aug 11 05:18:51 2012 (r240265) @@ -32,46 +32,50 @@ static SLIST_HEAD(lock_info_head, lock_info) lock_info_head = SLIST_HEAD_INITIALIZER(lock_info_head); +static SLIST_HEAD(lock_instance_head, lock_instance) lock_instance_head = + SLIST_HEAD_INITIALIZER(lock_instance_head); + struct _pthread_lockorder_private { struct lock_info *last_record; }; -struct lock_info * +struct lock_instance * lookup_lock(void *lock) { - struct lock_info *info = NULL; + struct lock_instance *inst = NULL; + struct lock_instance *iter; - SLIST_FOREACH(info, &lock_info_head, lock_info_next) { - if (info->lock == lock && info->active) { + SLIST_FOREACH(iter, &lock_instance_head, lock_instance_next) { + if (iter->lock == lock) { + inst = iter; break; } } - if (info == NULL) { - info = malloc(sizeof(struct lock_info)); - if (info != NULL) { - info->active = 1; - info->lock = lock; - info->child = NULL; - info->sibling = NULL; - info->name = NULL; - SLIST_INIT(&info->bless_head); - SLIST_INSERT_HEAD(&lock_info_head, info, - lock_info_next); + if (inst == NULL) { + inst = malloc(sizeof(struct lock_instance)); + if (inst != NULL) { + inst->lock = lock; + inst->info = NULL; + + SLIST_INSERT_HEAD(&lock_instance_head, inst, + lock_instance_next); } } - return (info); + return (inst); } void destroy_lock(void *lock) { - struct lock_info *info; + struct lock_instance *inst; - info = lookup_lock(lock); - if (info != NULL) { - info->active = 0; + inst = lookup_lock(lock); + if (inst != NULL) { + SLIST_REMOVE(&lock_instance_head, inst, lock_instance, + lock_instance_next); + free(inst); } } @@ -114,36 +118,122 @@ } } -int -pthread_setname_np(void *lock, const char *name) +void +reset_lock_instance(void) +{ + struct lock_instance *inst; + + while (!SLIST_EMPTY(&lock_instance_head)) { + inst = SLIST_FIRST(&lock_instance_head); + + SLIST_REMOVE_HEAD(&lock_instance_head, lock_instance_next); + + free(inst); + } +} + +struct lock_info * +get_lock_info(struct lock_instance *inst) { struct lock_info *info; - info = lookup_lock(lock); + if (inst == NULL) { + return (NULL); + } + + if (inst->info != NULL) { + return (inst->info); + } + + info = malloc(sizeof(struct lock_info)); + if (info != NULL) { + info->name = NULL; + info->child = NULL; + info->sibling = NULL; + SLIST_INIT(&info->bless_head); + SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); + + inst->info = info; + } + + return (info); +} + +static struct lock_info * +lookup_info(const char *name) +{ + struct lock_info *info = NULL; + struct lock_info *iter; + + SLIST_FOREACH(iter, &lock_info_head, lock_info_next) { + if (strcmp(name, get_lock_name(iter)) == 0) { + info = iter; + break; + } + } + if (info == NULL) { - return (ENOMEM); + info = malloc(sizeof(struct lock_info)); + if (info != NULL) { + info->name = strdup(name); + info->child = NULL; + info->sibling = NULL; + SLIST_INIT(&info->bless_head); + SLIST_INSERT_HEAD(&lock_info_head, info, + lock_info_next); + } } - info->name = reallocf(info->name, strlen(name) + 1); - if (info->name == NULL) { - return (errno); + return (info); +} + +int +pthread_setname_np(void *lock, const char *name) +{ + struct lock_instance *inst; + + inst = lookup_lock(lock); + if (inst == NULL) { + return (ENOMEM); } - strcpy(info->name, name); + inst->info = lookup_info(name); + if (inst->info == NULL) { + return (ENOMEM); + } return (0); } +const char * +get_lock_name(struct lock_info *info) +{ + if (info->name != NULL) { + return (info->name); + } + + return ""; +} + void -check_default_name(struct lock_info *lock, const char *prefix) +check_default_name(void *lock, const char *prefix) { - if (lock != NULL && lock->name == NULL) { - lock->name = malloc(MAX_DEFAULT_NAME_LENGTH + 1); - if (lock->name != NULL) { - snprintf(lock->name, MAX_DEFAULT_NAME_LENGTH, "%s%p", - prefix, lock->lock); - } + struct lock_instance *inst; + struct lock_info *info; + + inst = lookup_lock(lock); + info = get_lock_info(inst); + + if (info == NULL || info->name != NULL) { + return; + } + + info->name = malloc(MAX_DEFAULT_NAME_LENGTH + 1); + if (info->name == NULL) { + return; } + + snprintf(info->name, MAX_DEFAULT_NAME_LENGTH, "%s_%p", prefix, lock); } int @@ -196,20 +286,18 @@ if (node->name != NULL) { free(node->name); - node->name = NULL; } - node->lock = node->_pvt->last_record->lock; - if (node->_pvt->last_record->name != NULL) { - node->name = strdup(node->_pvt->last_record->name); - } + node->name = strdup(get_lock_name(node->_pvt->last_record)); if (node->_pvt->last_record->child != NULL) { - node->child = node->_pvt->last_record->child->lock; + node->child = + strdup(get_lock_name(node->_pvt->last_record->child)); } else { node->child = NULL; } if (node->_pvt->last_record->sibling != NULL) { - node->sibling = node->_pvt->last_record->sibling->lock; + node->sibling = + strdup(get_lock_name(node->_pvt->last_record->sibling)); } else { node->sibling = NULL; } @@ -222,11 +310,13 @@ void pthread_lockorder_end_np(struct pthread_lockorder_np *node) { - free(node->_pvt); - node->_pvt = NULL; + if (node->_pvt != NULL) { + free(node->_pvt); + node->_pvt = NULL; + } if (node->name != NULL) { - free((char *)node->name); + free(node->name); node->name = NULL; } } Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Sat Aug 11 05:18:51 2012 (r240265) @@ -57,6 +57,7 @@ pthread_lor_begin_np(struct pthread_lor_np *lor) { int ret = 0; + /* The lock isn't needed to prevent races, but it is needed to ensure that any locks grabbed by malloc() don't get logged. @@ -70,6 +71,9 @@ lor->_pvt->last_record = NULL; } + lor->name_first = NULL; + lor->name_second = NULL; + pthread_mutex_unlock(&witness_mtx); return (ret); @@ -90,10 +94,10 @@ } if (lor->_pvt->last_record != NULL) { - lor->lock_first = lor->_pvt->last_record->lock_first->lock; - lor->lock_second = lor->_pvt->last_record->lock_second->lock; - lor->name_first = lor->_pvt->last_record->lock_first->name; - lor->name_second = lor->_pvt->last_record->lock_second->name; + lor->name_first = + strdup(get_lock_name(lor->_pvt->last_record->lock_first)); + lor->name_second = + strdup(get_lock_name(lor->_pvt->last_record->lock_second)); res = 1; } @@ -110,6 +114,14 @@ free(lor->_pvt); lor->_pvt = NULL; } + + if (lor->name_first != NULL) { + free(lor->name_first); + } + + if (lor->name_second != NULL) { + free(lor->name_second); + } } void Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Sat Aug 11 05:18:51 2012 (r240265) @@ -41,31 +41,38 @@ struct lock_info { SLIST_ENTRY(lock_info) lock_info_next; - SLIST_ENTRY(lock_info) root_next; - void *lock; - int active; struct lock_info *child; struct lock_info *sibling; SLIST_HEAD(bless_head, blessing) bless_head; char *name; }; +struct lock_instance { + SLIST_ENTRY(lock_instance) lock_instance_next; + struct lock_info *info; + void *lock; +}; + extern pthread_mutex_t witness_mtx; -void add_lock(struct lock_info *lock); -void remove_lock(struct lock_info *lock); -int insert_lock(struct lock_info *new_lock, - struct lock_info *previous); +void add_lock(void *lock); +void remove_lock(void *lock); + +int insert_lock(struct lock_info *from, + struct lock_info *to); void reset_lists(void); void log_reversal(struct lock_info *lock, struct lock_info *previous); -struct lock_info *lookup_lock(void *lock); -void destroy_lock(void *lock); int blessed(struct lock_info *first, struct lock_info *second); void reset_lock_info(void); -void check_default_name(struct lock_info *lock, const char *prefix); +void check_default_name(void *lock, const char *prefix); +const char *get_lock_name(struct lock_info *info); +struct lock_info *get_lock_info(struct lock_instance *lock); +void destroy_lock(void *lock); +struct lock_instance *lookup_lock(void *lock); +void reset_lock_instance(void); void write_xml(void); Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Sat Aug 11 05:18:51 2012 (r240265) @@ -54,16 +54,14 @@ pthread_mutex_lock(pthread_mutex_t *mutex) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(mutex); - check_default_name(lock, "mutex_"); + check_default_name(mutex, "mutex"); ret = _pthread_mutex_lock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(lock); + add_lock(mutex); } _pthread_mutex_unlock(&witness_mtx); @@ -75,16 +73,14 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(mutex); - check_default_name(lock, "mutex_"); + check_default_name(mutex, "mutex"); ret = _pthread_mutex_trylock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(lock); + add_lock(mutex); } _pthread_mutex_unlock(&witness_mtx); @@ -96,16 +92,14 @@ pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(mutex); - check_default_name(lock, "mutex_"); + check_default_name(mutex, "mutex"); ret = _pthread_mutex_timedlock(mutex, ts); if (mutex != &witness_mtx && ret == 0) { - add_lock(lock); + add_lock(mutex); } _pthread_mutex_unlock(&witness_mtx); @@ -122,7 +116,7 @@ ret = _pthread_mutex_unlock(mutex); if (mutex != &witness_mtx && ret == 0) { - remove_lock(lookup_lock(mutex)); + remove_lock(mutex); } _pthread_mutex_unlock(&witness_mtx); @@ -149,16 +143,14 @@ pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_rdlock(rwlock); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -170,16 +162,14 @@ pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_tryrdlock(rwlock); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -191,16 +181,14 @@ pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_timedrdlock(rwlock, ts); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -212,16 +200,14 @@ pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_wrlock(rwlock); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -233,16 +219,14 @@ pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_trywrlock(rwlock); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -254,16 +238,14 @@ pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(rwlock); - check_default_name(lock, "rwlock_"); + check_default_name(rwlock, "rwlock"); ret = _pthread_rwlock_timedwrlock(rwlock, ts); if (ret == 0) { - add_lock(lock); + add_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -280,7 +262,7 @@ ret = _pthread_rwlock_unlock(rwlock); if (ret == 0) { - remove_lock(lookup_lock(rwlock)); + remove_lock(rwlock); } _pthread_mutex_unlock(&witness_mtx); @@ -307,16 +289,14 @@ pthread_spin_lock(pthread_spinlock_t *spin) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(spin); - check_default_name(lock, "spinlock_"); + check_default_name(spin, "spinlock"); ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(lock); + add_lock(spin); } _pthread_mutex_unlock(&witness_mtx); @@ -328,16 +308,14 @@ pthread_spin_trylock(pthread_spinlock_t *spin) { int ret; - struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); - lock = lookup_lock(spin); - check_default_name(lock, "spinlock_"); + check_default_name(spin, "spinlock"); ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(lock); + add_lock(spin); } _pthread_mutex_unlock(&witness_mtx); @@ -354,7 +332,7 @@ ret = _pthread_spin_unlock(spin); if (ret == 0) { - remove_lock(lookup_lock(spin)); + remove_lock(spin); } _pthread_mutex_unlock(&witness_mtx); @@ -384,7 +362,8 @@ _pthread_mutex_lock(&witness_mtx); - if (insert_lock(lookup_lock(first), lookup_lock(second)) < 0) { + if (insert_lock(get_lock_info(lookup_lock(first)), + get_lock_info(lookup_lock(second))) < 0) { ret = EINVAL; } @@ -398,14 +377,19 @@ { struct lock_info *first; struct lock_info *second; + struct lock_instance *first_inst; + struct lock_instance *second_inst; struct blessing *first_bless = NULL; struct blessing *second_bless = NULL; int ret = 0; _pthread_mutex_lock(&witness_mtx); - first = lookup_lock(first_addr); - second = lookup_lock(second_addr); + first_inst = lookup_lock(first_addr); + second_inst = lookup_lock(second_addr); + + first = get_lock_info(first_inst); + second = get_lock_info(second_inst); first_bless = malloc(sizeof(struct blessing)); second_bless = malloc(sizeof(struct blessing)); @@ -414,14 +398,6 @@ second_bless == NULL) { ret = ENOMEM; - if (first != NULL) { - free(first); - } - - if (second != NULL) { - free(second); - } - if (first_bless != NULL) { free(first_bless); } @@ -445,6 +421,7 @@ _pthread_mutex_lock(&witness_mtx); reset_lists(); + reset_lock_instance(); reset_lock_info(); _pthread_mutex_unlock(&witness_mtx); Modified: soc2012/gmiller/locking-head/lib/libwitness/xml.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/xml.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/lib/libwitness/xml.c Sat Aug 11 05:18:51 2012 (r240265) @@ -68,13 +68,6 @@ fprintf(xml_file, "<%s>%s\n", tag, str, tag); } -static void -write_element_pointer(const char *tag, void *ptr) -{ - indent(); - fprintf(xml_file, "<%s>%p\n", tag, ptr, tag); -} - void write_xml(void) { @@ -91,15 +84,8 @@ while (pthread_lor_next_np(&lor)) { open_element("lor"); - open_element("first"); - write_element_pointer("address", lor.lock_first); - write_element_string("name", lor.name_first); - close_element("first"); - - open_element("second"); - write_element_pointer("address", lor.lock_second); - write_element_string("name", lor.name_second); - close_element("second"); + write_element_string("first", lor.name_first); + write_element_string("second", lor.name_second); close_element("lor"); } @@ -113,13 +99,12 @@ while (pthread_lockorder_next_np(&node)) { open_element("node"); - write_element_pointer("address", node.lock); write_element_string("name", node.name); if (node.child != NULL) { - write_element_pointer("child", node.child); + write_element_string("child", node.child); } if (node.sibling != NULL) { - write_element_pointer("sibling", node.sibling); + write_element_string("sibling", node.sibling); } close_element("node"); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/graph.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/graph.c Sat Aug 11 05:18:51 2012 (r240265) @@ -27,23 +27,25 @@ #include #include +#include #include #include "check.h" void -check_graph(pthread_mutex_t *lock_buffer, int lock_count) +check_graph(int lock_count) { struct pthread_lockorder_np order; int i; pthread_lockorder_begin_np(&order); while (pthread_lockorder_next_np(&order)) { - i = (pthread_mutex_t *)order.lock - lock_buffer; - if (i >= 0 && i < lock_count) { - check((i < (lock_count - 1) && - (lock_buffer + i + 1) == order.child) || - (i == (lock_count - 1) && order.child == NULL)); + i = atol(order.name); + if (i >= 1 && i <= lock_count) { + check((i < lock_count && + order.child != NULL && + atol(order.child) == i + 1) || + (i == lock_count && order.child == NULL)); check(order.sibling == NULL); } } @@ -87,6 +89,7 @@ int i; pthread_mutex_t *lock_buffer; int *lock_set; + char name[11]; pthread_lockorder_reset_np(); @@ -95,10 +98,13 @@ for (i = 0; i < lock_count; i++) { pthread_mutex_init(&lock_buffer[i], NULL); + + sprintf(name, "%d", i + 1); + pthread_setname_np(&lock_buffer[i], name); } graph_test(lock_buffer, lock_count, lock_set, 0, 0); - check_graph(lock_buffer, lock_count); + check_graph(lock_count); for (i = 0; i < lock_count; i++) { pthread_mutex_destroy(&lock_buffer[i]); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c Sat Aug 11 05:18:51 2012 (r240265) @@ -61,16 +61,16 @@ pthread_lor_begin_np(&lor); while (pthread_lor_next_np(&lor)) { + check((strcmp(lor.name_first, "mutex 1") == 0 && + strcmp(lor.name_second, "mutex 2") == 0) || + (strcmp(lor.name_first, "mutex 2") == 0 && + strcmp(lor.name_second, "mutex 1") == 0)); + record_count++; } pthread_lor_end_np(&lor); check(record_count == 1); - - check((strcmp(lor.name_first, "mutex 1") == 0 && - strcmp(lor.name_second, "mutex 2") == 0) || - (strcmp(lor.name_first, "mutex 2") == 0 && - strcmp(lor.name_second, "mutex 1") == 0)); } int Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c Sat Aug 11 05:18:33 2012 (r240264) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/shared.c Sat Aug 11 05:18:51 2012 (r240265) @@ -31,41 +31,89 @@ #include "check.h" void -share_test(void) +unshared_test(void) { pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; - pthread_setname_np(mutex1, "shared_mutex"); - pthread_setname_np(mutex2, "shared_mutex"); + pthread_mutex_lock(&mutex1); + pthread_mutex_lock(&mutex2); + + pthread_mutex_unlock(&mutex2); + pthread_mutex_unlock(&mutex1); + + pthread_mutex_lock(&mutex2); + pthread_mutex_lock(&mutex1); + + pthread_mutex_unlock(&mutex1); + pthread_mutex_unlock(&mutex2); + + pthread_mutex_destroy(&mutex1); + pthread_mutex_destroy(&mutex2); +} + +void +check_unshared(void) +{ + struct pthread_lor_np lor; + int lor_count = 0; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + lor_count++; + } + pthread_lor_end_np(&lor); + + check(lor_count == 1); +} + +void +shared_test(void) +{ + pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; + + pthread_lor_clear_np(); + + pthread_setname_np(&mutex1, "shared_mutex"); + pthread_setname_np(&mutex2, "shared_mutex"); pthread_mutex_lock(&mutex1); pthread_mutex_lock(&mutex2); pthread_mutex_unlock(&mutex2); pthread_mutex_unlock(&mutex1); + + pthread_mutex_lock(&mutex2); + pthread_mutex_lock(&mutex1); + + pthread_mutex_unlock(&mutex1); + pthread_mutex_unlock(&mutex2); } void -check_share(void) +check_shared(void) { - struct pthread_lockorder_np order; - int node_count = 0; + struct pthread_lor_np lor; + int lor_count = 0; - pthread_lockorder_begin_np(&order); - while (pthread_lockorder_next_np(&order)) { - node_count++; + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + lor_count++; } - pthread_lockorder_end_np(&order); + pthread_lor_end_np(&lor); - check(node_count == 0); + check(lor_count == 0); } int main(void) { - share_test(); - check_share(); + unshared_test(); + check_unshared(); + + shared_test(); + check_shared(); show_test_results(); From owner-svn-soc-all@FreeBSD.ORG Sat Aug 11 16:18:15 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7DA471065672 for ; Sat, 11 Aug 2012 16:18:13 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 11 Aug 2012 16:18:13 +0000 Date: Sat, 11 Aug 2012 16:18:13 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120811161813.7DA471065672@hub.freebsd.org> Cc: Subject: socsvn commit: r240274 - in soc2012/aleek/beaglexm-armv6/sys/arm: conf ti/twl ti/usb X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2012 16:18:15 -0000 Author: aleek Date: Sat Aug 11 16:18:11 2012 New Revision: 240274 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240274 Log: USB EHCI OMAP testing. Ive found some issues about phy resetting, but the patches dont work Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Aug 11 15:47:22 2012 (r240273) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Aug 11 16:18:11 2012 (r240274) @@ -82,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"msdosfs:mmcsd0s3\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" # Console and misc Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c Sat Aug 11 15:47:22 2012 (r240273) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c Sat Aug 11 16:18:11 2012 (r240274) @@ -419,7 +419,6 @@ return (ENOMEM); /* FIXME: should be in DTS file */ - device_printf( dev, "habababa\n" ); if ((sc->sc_vreg = device_add_child(dev, "twl_vreg", -1)) == NULL) device_printf(dev, "could not allocate twl_vreg instance\n"); if ((sc->sc_clks = device_add_child(dev, "twl_clks", -1)) == NULL) Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sat Aug 11 15:47:22 2012 (r240273) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sat Aug 11 16:18:11 2012 (r240274) @@ -350,35 +350,53 @@ uint32_t reg = 0; int reset_performed = 0; int i; +// int gpio_val; device_printf(isc->sc_dev, "Starting TI EHCI USB Controller\n"); /* Enable Clocks for high speed USBHOST */ - ti_prcm_clk_enable(USBHSHOST_CLK); + if( ti_prcm_clk_enable(USBHSHOST_CLK) != 0 ) + { + device_printf( isc->sc_dev, "KURWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ); + } /* enabling TWL4030/TPS95950 voltage regulator */ - twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v5", 1800); - twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v8", 1800); - twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb3v1", 1800); + //twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v5", 1500); + //twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v8", 1800); + //twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb3v1", 3100); /* Hold the PHY in reset while configuring */ + /* for (int i = 0; i < 3; i++) { if (isc->phy_reset[i]) { - /* Configure the GPIO to drive low (hold in reset) */ + // Configure the GPIO to drive low (hold in reset) if ((isc->reset_gpio_pin[i] != -1) && (isc->sc_gpio_dev != NULL)) { GPIO_PIN_SETFLAGS(isc->sc_gpio_dev, isc->reset_gpio_pin[i], GPIO_PIN_OUTPUT); - GPIO_PIN_SET(isc->sc_gpio_dev, isc->reset_gpio_pin[i], - GPIO_PIN_LOW); + if( GPIO_PIN_SET(isc->sc_gpio_dev, isc->reset_gpio_pin[i], + GPIO_PIN_LOW) != 0 ) + { + return ENXIO; + } + if( GPIO_PIN_SET(isc->sc_gpio_dev, 56, + GPIO_PIN_LOW) != 0 ) + { + return ENXIO; + } + GPIO_PIN_GET( isc->sc_gpio_dev, isc->reset_gpio_pin[i], &gpio_val ); + if( gpio_val != GPIO_PIN_LOW ) + { + return ENXIO; + } reset_performed = 1; } } } - +*/ /* Hold the PHY in RESET for enough time till DIR is high */ - if (reset_performed) - DELAY(10); + //if (reset_performed) + DELAY(100); /* Read the UHH revision */ isc->ehci_rev = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_REVISION); @@ -388,7 +406,10 @@ if (isc->ehci_rev == OMAP_EHCI_REV1) { /* Enable the USB TLL */ - ti_prcm_clk_enable(USBTLL_CLK); + if( ti_prcm_clk_enable(USBTLL_CLK) != 0 ) + { + device_printf( isc->sc_dev, "AKURWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ); + } //omap_ehci_write_4(isc, OMAP_USBHOST_INSNREG04, OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND); @@ -524,10 +545,8 @@ * the root-hub is allowed to suspend. Writing 1 to this undocumented * register bit disables this feature and restores normal behavior." */ -#if 0 omap_ehci_write_4(isc, OMAP_USBHOST_INSNREG04, OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND); -#endif /* If any of the ports are configured in TLL mode, enable them */ if ((isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL) || @@ -545,14 +564,6 @@ omap_ehci_utmi_init(isc, tll_ch_mask); } - /* Soft reset the PHY using PHY reset command over ULPI */ - if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) - omap_ehci_soft_phy_reset(isc, 0); - if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) - omap_ehci_soft_phy_reset(isc, 1); - - //ehci_reset( isc->base ); - /* Release the PHY reset signal now we have configured everything */ if (reset_performed) { @@ -566,10 +577,17 @@ && (isc->sc_gpio_dev != NULL)) { GPIO_PIN_SET(isc->sc_gpio_dev, isc->reset_gpio_pin[i], GPIO_PIN_HIGH); + GPIO_PIN_SET(isc->sc_gpio_dev, + 56, GPIO_PIN_HIGH); } } } + /* Soft reset the PHY using PHY reset command over ULPI */ + if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(isc, 0); + if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(isc, 1); /* Set the interrupt threshold control, it controls the maximum rate at * which the host controller issues interrupts. We set it to 1 microframe * at startup - the default is 8 mircoframes (equates to 1ms).