From owner-svn-soc-all@FreeBSD.ORG Sun Jul 22 12:31:07 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 5589B106564A for ; Sun, 22 Jul 2012 12:31:05 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 22 Jul 2012 12:31:05 +0000 Date: Sun, 22 Jul 2012 12:31: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: <20120722123105.5589B106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239660 - in soc2012/aleek/beaglexm-armv6/sys: arm/ti/am37x 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: Sun, 22 Jul 2012 12:31:07 -0000 Author: aleek Date: Sun Jul 22 12:31:03 2012 New Revision: 239660 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239660 Log: uncommented PRCM clocks for USB Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_prcm.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/am37x/am37x_prcm.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_prcm.c Sun Jul 22 11:22:04 2012 (r239659) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/am37x_prcm.c Sun Jul 22 12:31:03 2012 (r239660) @@ -184,8 +184,17 @@ omap3_clk_generic_get_source_freq(struct ti_clock_dev *clkdev, unsigned int *freq); static int +omap3_clk_hsusbhost_activate(struct ti_clock_dev *clkdev); + +static int +omap3_clk_hsusbhost_deactivate(struct ti_clock_dev *clkdev ); + +static int omap3_clk_alwayson_null_func(struct ti_clock_dev *clkdev); +static int +omap3_clk_setup_dpll5(uint32_t mul, uint32_t div); + static const struct ti_clk_details* omap3_clk_details(clk_ident_t id); @@ -291,11 +300,11 @@ #if 0 OMAP3_GENERIC_CLOCK_DEV(MMC2_CLK), OMAP3_GENERIC_CLOCK_DEV(MMC3_CLK), +#endif /* USB HS (high speed TLL, EHCI and OHCI) */ OMAP3_GENERIC_CLOCK_DEV(USBTLL_CLK), OMAP3_HSUSBHOST_CLOCK_DEV(USBHSHOST_CLK), -#endif /* GPIO */ OMAP3_GENERIC_CLOCK_DEV(GPIO1_CLK), OMAP3_GENERIC_CLOCK_DEV(GPIO2_CLK), @@ -392,6 +401,7 @@ 0x00, 0x10, 0x20, 25), OMAP3_GENERIC_CLOCK_DETAILS(MMC3_CLK, FREQ_96MHZ, CORE_CM_OFFSET, 0x00, 0x10, 0x20, 30), +#endif /* USB HS (high speed TLL, EHCI and OHCI) */ OMAP3_GENERIC_CLOCK_DETAILS(USBTLL_CLK, -1, CORE_CM_OFFSET, @@ -399,6 +409,7 @@ OMAP3_GENERIC_CLOCK_DETAILS(USBHSHOST_CLK, -1, USBHOST_CM_OFFSET, 0x00, 0x10, 0x20, 1), +#if 0 /* GPIO modules */ OMAP3_GENERIC_CLOCK_DETAILS(GPIO1_CLK, -1, WKUP_CM_OFFSET, 0x00, 0x10, 0x20, 3), @@ -595,6 +606,7 @@ return (0); } } + printf("Error: failed to enable module with USB clock %d\n", clkdev->id); return (ETIMEDOUT); } @@ -755,6 +767,188 @@ } /** + * omap3_clk_usbhost_activate - activates a modules iinterface and func clock + * @clkdev: pointer to the clock device structure. + * @mem_res: array of memory resources mapped when PRCM driver attached + * + * + * + * LOCKING: + * Inherits the locks from the omap_prcm driver, no internal locking. + * + * RETURNS: + * Returns 0 on success or a positive error code on failure. + */ +static int +omap3_clk_hsusbhost_activate(struct ti_clock_dev *clkdev) +{ + const struct ti_clk_details* clk_details = omap3_clk_details(clkdev->id); + //struct resource* clk_mem_res = mem_res[CM_INSTANCE_MEM_REGION]; + uint32_t fclken, iclken; + unsigned int sysclk; + + if (clk_details == NULL) + return (ENXIO); + if (clkdev->id != USBHSHOST_CLK) + return (EINVAL); + + /* First ensure DPLL5 is setup and running, this provides the 120M clock */ + + /* SYS_CLK feeds the DPLL so need that to calculate the mul & div */ + omap3_clk_get_sysclk_freq(NULL, &sysclk); + + /* Activate DPLL5 and therefore the 120M clock */ + if (omap3_clk_setup_dpll5(120, 13) != 0) + return (ETIMEDOUT); + + + /* All the 'generic' clocks have a FCLKEN, ICLKEN and IDLEST register which + * is for the functional, interface and clock status regsters respectively. + */ + + /* Enable the interface clock */ + iclken = cm_read_4( clk_details->iclken_offset); + iclken |= 0x1; + cm_write_4(clk_details->iclken_offset, iclken); + + /* Read back the value to ensure the write has taken place ... needed ? */ + iclken = cm_read_4(clk_details->iclken_offset); + + + /* Enable the functional clock */ + fclken = cm_read_4(clk_details->fclken_offset); + fclken |= 0x03; + cm_write_4(clk_details->fclken_offset, fclken); + + /* Read back the value to ensure the write has taken place ... needed ? */ + fclken = cm_read_4(clk_details->fclken_offset); + + + /* Now poll on the IDLEST register to tell us if the module has come up. + * TODO: We need to take into account the parent clocks. + */ +#if 0 + if (omap3_clk_wait_on_reg(clk_mem_res, clk_details->idlest_offset, 0x02, + 0x00) != 0) { + printf("Error: failed to enable module with USB clock %d\n", clkdev->id); + return (ETIMEDOUT); + } +#endif + for( int i=0; i< MAX_MODULE_ENABLE_WAIT; ++i ) + { + if( ( cm_read_4( clk_details->idlest_offset ) & 0x02 ) == 0x00 ) + { + return (0); + } + } + printf("Error: failed to enable module with USB clock %d\n", clkdev->id); + return (ETIMEDOUT); +} + +/** + * omap3_clk_hsusbhost_deactivate - deactivates a modules clock + * @clkdev: pointer to the clock device structure. + * @mem_res: array of memory resources mapped when PRCM driver attached + * + * + * + * LOCKING: + * Inherits the locks from the omap_prcm driver, no internal locking. + * + * RETURNS: + * Returns 0 on success or a positive error code on failure. + */ +static int +omap3_clk_hsusbhost_deactivate(struct ti_clock_dev *clkdev ) +{ + const struct ti_clk_details* clk_details = omap3_clk_details(clkdev->id); + //struct resource* clk_mem_res = mem_res[CM_INSTANCE_MEM_REGION]; //@todo remove + uint32_t fclken, iclken; + + if (clk_details == NULL) + return (ENXIO); + + + /* All the 'generic' clocks have a FCLKEN, ICLKEN and IDLEST register which + * is for the functional, interface and clock status regsters respectively. + */ + + /* Disable the interface clock */ + iclken = cm_read_4(clk_details->iclken_offset); + iclken &= ~(1UL << clk_details->bit_offset); + cm_write_4(clk_details->iclken_offset, iclken); + + /* Disable the functional clock */ + fclken = cm_read_4(clk_details->fclken_offset); + fclken &= ~(1UL << clk_details->bit_offset); + cm_write_4(clk_details->fclken_offset, fclken); + + + return (0); +} + +/** + * omap3_clk_setup_dpll5 - setup DPLL5 which is needed for the 120M_FCLK + * @dev: prcm device handle + * + * Sets up the DPLL5 at the frequency specified by the mul and div arguments + * (the source clock is SYS_CLK). + * + * LOCKING: + * None + * + * RETURNS: + * Returns 0 on success otherwise ETIMEDOUT if DPLL failed to lock. + */ +static int +omap3_clk_setup_dpll5(uint32_t mul, uint32_t div) +{ + uint32_t val; + + /* DPPL5 uses DPLL5_ALWON_FCLK as it's reference clock, this is just SYS_CLK + * which on the beagleboard is 13MHz. + */ + + /* Set the multipler and divider values for the PLL. We want 120Mhz so take + * the system clock (13Mhz) divide by that then multiple by 120. + */ + val = ((mul & 0x7ff) << 8) | ((div - 1) & 0x7f); + cm_write_4(CLOCK_CTRL_CM_OFFSET + 0x4C, val); + + /* This is the clock divider from the PLL into the 120Mhz clock supplied to + * the USB module. */ + val = 0x01; + cm_write_4(CLOCK_CTRL_CM_OFFSET + 0x50, val); + + /* PERIPH2_DPLL_FREQSEL = 0x7 (1.75 MHz—2.1 MHz) + * EN_PERIPH2_DPLL = 0x7 (Enables the DPLL5 in lock mode) + */ + val = (7 << 4) | (7 << 0); + cm_write_4(CLOCK_CTRL_CM_OFFSET + 0x04, val); + + + /* Disable auto-idle */ + cm_write_4(CLOCK_CTRL_CM_OFFSET + 0x34, 0x00); + + + /* Wait until the DPLL5 is locked and there is clock activity */ +#if 0 + return (omap3_clk_wait_on_reg(cm_mem_res, (CLOCK_CTRL_CM_OFFSET + 0x24), + 0x01, 0x01)); +#endif + for( int i=0; i< MAX_MODULE_ENABLE_WAIT; ++i ) + { + if( (cm_read_4( (CLOCK_CTRL_CM_OFFSET + 0x24) ) & 0x01 ) == 0x01 ) + { + return (0); + } + } + return (ETIMEDOUT); +} + + + +/** * omap3_clk_details - returns a pointer to the generic clock details * @id: The ID of the clock to get the details for * Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sun Jul 22 11:22:04 2012 (r239659) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sun Jul 22 12:31:03 2012 (r239660) @@ -742,11 +742,9 @@ static int omap_ehci_probe(device_t dev) { - device_printf( dev, "probing!\n\n" ); if (!ofw_bus_is_compatible(dev, "ti,ehci")) return (ENXIO); - device_printf( dev, "probed!!!\n\n" ); device_set_desc(dev, OMAP_EHCI_HC_DEVSTR); return (BUS_PROBE_DEFAULT); Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Jul 22 11:22:04 2012 (r239659) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Jul 22 12:31:03 2012 (r239660) @@ -168,7 +168,7 @@ }; ehci@48064800 { - compatible = "ti, ehci"; + compatible = "ti,ehci"; reg = < 0x48064800 0x400 /* EHCI */ 0x48064000 0x400 /* UHH */ 0x48062000 0x1000 /* TLL */ >; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 22 16:06:40 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 76CBF106566C for ; Sun, 22 Jul 2012 16:06:38 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 22 Jul 2012 16:06:38 +0000 Date: Sun, 22 Jul 2012 16:06:38 +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: <20120722160638.76CBF106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239673 - in soc2012/aleek/beaglexm-armv6/sys: arm/ti 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: Sun, 22 Jul 2012 16:06:40 -0000 Author: aleek Date: Sun Jul 22 16:06:38 2012 New Revision: 239673 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239673 Log: configured GPIO pins for USB EHCI Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_sdma.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_gpio.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c Sun Jul 22 15:40:31 2012 (r239672) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c Sun Jul 22 16:06:38 2012 (r239673) @@ -69,7 +69,9 @@ /* Register definitions */ #define TI_GPIO_REVISION 0x0000 #define TI_GPIO_SYSCONFIG 0x0010 + #if defined(SOC_OMAP3) || defined(SOC_TI_AM37X) + #define TI_GPIO_REVISION 0x0000 #define TI_GPIO_SYSCONFIG 0x0010 #define TI_GPIO_SYSSTATUS 0x0014 @@ -96,7 +98,9 @@ #define TI_GPIO_SETWKUENA 0x0084 #define TI_GPIO_CLEARDATAOUT 0x0090 #define TI_GPIO_SETDATAOUT 0x0094 + #elif defined(SOC_OMAP4) || defined(SOC_TI_AM335X) + #define TI_GPIO_IRQSTATUS_RAW_0 0x0024 #define TI_GPIO_IRQSTATUS_RAW_1 0x0028 #define TI_GPIO_IRQSTATUS_0 0x002C Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_sdma.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_sdma.c Sun Jul 22 15:40:31 2012 (r239672) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_sdma.c Sun Jul 22 16:06:38 2012 (r239673) @@ -341,6 +341,8 @@ if (ch == NULL) return (EINVAL); + device_printf( sc->sc_dev, "Activating channel %d\n", *ch ); + TI_SDMA_LOCK(sc); /* Check to see if all channels are in use */ Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sun Jul 22 15:40:31 2012 (r239672) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sun Jul 22 16:06:38 2012 (r239673) @@ -294,6 +294,7 @@ 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 @@ -348,28 +349,36 @@ int i; device_printf(isc->sc_dev, "Starting TI EHCI USB Controller\n"); + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Enable Clocks for high speed USBHOST */ ti_prcm_clk_enable(USBHSHOST_CLK); + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Hold the PHY in reset while configuring */ for (int i = 0; i < 3; i++) { if (isc->phy_reset[i]) { + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Configure the GPIO to drive low (hold in reset) */ if ((isc->reset_gpio_pin[i] != -1) && (isc->sc_gpio_dev != NULL)) { + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); GPIO_PIN_SETFLAGS(isc->sc_gpio_dev, isc->reset_gpio_pin[i], GPIO_PIN_OUTPUT); + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); GPIO_PIN_SET(isc->sc_gpio_dev, isc->reset_gpio_pin[i], GPIO_PIN_LOW); + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); reset_performed = 1; } } } + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Hold the PHY in RESET for enough time till DIR is high */ if (reset_performed) DELAY(10); + device_printf( isc->sc_dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Read the UHH revision */ isc->ehci_rev = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_REVISION); @@ -804,6 +813,7 @@ * The interrupt resource is just the single interupt for the controller. */ + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Allocate resource for the EHCI register set */ rid = 0; sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); @@ -811,6 +821,7 @@ device_printf(dev, "Error: Could not map EHCI memory\n"); goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Request an interrupt resource */ rid = 0; sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); @@ -818,6 +829,7 @@ device_printf(dev, "Error: could not allocate irq\n"); goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Allocate resource for the UHH register set */ rid = 1; @@ -826,6 +838,7 @@ device_printf(dev, "Error: Could not map UHH memory\n"); goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Allocate resource for the TLL register set */ rid = 2; isc->tll_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); @@ -833,6 +846,7 @@ device_printf(dev, "Error: Could not map TLL memory\n"); goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Add this device as a child of the USBus device */ sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); @@ -840,6 +854,7 @@ device_printf(dev, "Error: could not add USB device\n"); goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); device_set_desc(sc->sc_bus.bdev, OMAP_EHCI_HC_DEVSTR); @@ -863,6 +878,7 @@ isc->reset_gpio_pin[i] = -1; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); tuple_size = sizeof(pcell_t) * 3; node = ofw_bus_get_node(dev); len = OF_getprop(node, "phy-config", phyconf, sizeof(phyconf)); @@ -882,6 +898,7 @@ } } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Initialise the ECHI registers */ err = omap_ehci_init(isc); if (err) { @@ -890,12 +907,14 @@ } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Set the tag and size of the register set in the EHCI context */ sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); sc->sc_io_size = rman_get_size(sc->sc_io_res); + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Setup the interrupt */ 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); @@ -905,9 +924,11 @@ goto error; } + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Finally we are ready to kick off the ECHI host controller */ err = ehci_init(sc); + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); if (err == 0) { err = device_probe_and_attach(sc->sc_bus.bdev); } Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Jul 22 15:40:31 2012 (r239672) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sun Jul 22 16:06:38 2012 (r239673) @@ -64,9 +64,39 @@ reg = < 0x48002000 0x2000 >; /* Set of triplets < padname, muxname, padstate> */ scm-pad-config = - /* I2C0 */ - "I2C0_SDA", "I2C0_SDA","input_pullup_inact_slow", - "I2C0_SCL", "I2C0_SCL","input_pullup_inact_slow"; + /* USB */ + /* + "af10", "hsusb1_stp", "output", + "ae10", "hsusb1_clk", "output", + "af9", "hsusb1_dir", "input_pulldown", + "ag9", "hsusb1_nxt", "input_pulldown", + "af11", "hsusb1_data0", "input_pulldown", + "ag12", "hsusb1_data1", "input_pulldown", + "ah12", "hsusb1_data2", "input_pulldown", + "ah14", "hsusb1_data3", "input_pulldown", + "ae11", "hsusb1_data4", "input_pulldown", + "ah9", "hsusb1_data5", "input_pulldown", + "af13", "hsusb1_data6", "input_pulldown", + "ae13", "hsusb1_data7", "input_pulldown",*/ + + "af7", "hsusb2_stp", "output", + "ag7", "hsusb2_dir", "input_pulldown", + "ah7", "hsusb2_nxt", "input_pulldown", + + "ag8", "hsusb2_data0", "input_pulldown", + "ah8", "hsusb2_data1", "input_pulldown", + "ab2", "hsusb2_data2", "input_pulldown", + "v3", "hsusb2_data3", "input_pulldown", + "y2", "hsusb2_data4", "input_pulldown", + "y3", "hsusb2_data5", "input_pulldown", + "y4", "hsusb2_data6", "input_pulldown", + "aa3", "hsusb2_data7", "input_pulldown", + + "ad25", "gpio_147", "output", + "ae7", "hsusb2_clk", "output", + "r8", "gpio_56", "output"; + + }; prcm@48004000 { @@ -169,6 +199,20 @@ ehci@48064800 { compatible = "ti,ehci"; + /* + * USB port PHY configuration is a tuple: + * mode is one of the following values: + * 0 - unknown + * 1 - PHY + * 2 - TLL + * 3 - HSIC + * + * reset indicates (if non-zero) if port reset is required + * gpio_pin - GPIO pin that is used to perform reset + */ + phy-config = < 1 0 0 + 1 1 56 + 0 0 0>; reg = < 0x48064800 0x400 /* EHCI */ 0x48064000 0x400 /* UHH */ 0x48062000 0x1000 /* TLL */ >; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 00:21: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 42A31106566C for ; Mon, 23 Jul 2012 00:21:32 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 00:21:32 +0000 Date: Mon, 23 Jul 2012 00:21:32 +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: <20120723002132.42A31106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239684 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport 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, 23 Jul 2012 00:21:34 -0000 Author: tzabal Date: Mon Jul 23 00:21:31 2012 New Revision: 239684 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239684 Log: Change the encoding of the XML crash report from UTF-8 to ISO-8859-1 in order to fix a bug with unrecognized characters that resulted in a 'not well-formed' error when parsing the report. Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Sun Jul 22 23:21:21 2012 (r239683) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Mon Jul 23 00:21:31 2012 (r239684) @@ -171,7 +171,7 @@ orig_IFS="${IFS}" IFS=";" -echo "" > ${data} +echo "" > ${data} echo "" >> ${data} echo "
" >> ${data} From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 06:13:09 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 53537106564A for ; Mon, 23 Jul 2012 06:13:07 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 06:13:07 +0000 Date: Mon, 23 Jul 2012 06:13:07 +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: <20120723061307.53537106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239690 - in soc2012/jhagewood/diff3: . 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: Mon, 23 Jul 2012 06:13:09 -0000 Author: jhagewood Date: Mon Jul 23 06:13:06 2012 New Revision: 239690 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239690 Log: Changed diff3 back to diff3prog temporarily, doesn't build otherwise. Modified: soc2012/jhagewood/diff3/diff3/Makefile soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/diff3/Makefile ============================================================================== --- soc2012/jhagewood/diff3/diff3/Makefile Mon Jul 23 04:48:58 2012 (r239689) +++ soc2012/jhagewood/diff3/diff3/Makefile Mon Jul 23 06:13:06 2012 (r239690) @@ -1,6 +1,6 @@ # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ -PROG= diff3 +PROG= diff3prog MAN= diff3.1 BINDIR= /usr/libexec Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Mon Jul 23 04:48:58 2012 (r239689) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Mon Jul 23 06:13:06 2012 (r239690) @@ -1,13 +1,7 @@ -diff -rupN jhagewood/diff3/diff3-orig/Makefile jhagewood/diff3/diff3/Makefile ---- jhagewood/diff3/diff3-orig/Makefile 2012-07-19 17:32:16.000000000 -0400 -+++ jhagewood/diff3/diff3/Makefile 2012-07-20 03:09:41.000000000 -0400 -@@ -1,11 +1,11 @@ - # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ - --PROG= diff3prog -+PROG= diff3 - MAN= diff3.1 - BINDIR= /usr/libexec +diff -rupN diff3-orig/Makefile diff3/Makefile +--- diff3-orig/Makefile 2012-07-23 02:07:00.000000000 -0400 ++++ diff3/Makefile 2012-07-23 02:09:25.000000000 -0400 +@@ -6,6 +6,6 @@ BINDIR= /usr/libexec beforeinstall: install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ @@ -15,9 +9,9 @@ + ${.CURDIR}/diff3.sh ${DESTDIR}/usr/bin/diff3 .include -diff -rupN jhagewood/diff3/diff3-orig/diff3.1 jhagewood/diff3/diff3/diff3.1 ---- jhagewood/diff3/diff3-orig/diff3.1 2012-07-19 17:32:16.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3.1 2012-07-21 20:49:56.000000000 -0400 +diff -rupN diff3-orig/diff3.1 diff3/diff3.1 +--- diff3-orig/diff3.1 2012-07-23 02:07:00.000000000 -0400 ++++ diff3/diff3.1 2012-07-23 02:07:00.000000000 -0400 @@ -173,7 +173,7 @@ as the temporary directory. temporary file .It Pa /tmp/d3b.XXXXXXXXXX @@ -27,9 +21,9 @@ the actual executable .El .Sh SEE ALSO -diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c ---- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-19 17:32:16.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-07-21 20:48:17.000000000 -0400 +diff -rupN diff3-orig/diff3prog.c diff3/diff3prog.c +--- diff3-orig/diff3prog.c 2012-07-23 02:07:00.000000000 -0400 ++++ diff3/diff3prog.c 2012-07-23 02:07:00.000000000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 16:05:40 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 CB337106564A for ; Mon, 23 Jul 2012 16:05:38 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 16:05:38 +0000 Date: Mon, 23 Jul 2012 16:05:38 +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: <20120723160538.CB337106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239699 - 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: Mon, 23 Jul 2012 16:05:40 -0000 Author: gpf Date: Mon Jul 23 16:05:38 2012 New Revision: 239699 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239699 Log: minor changes to supplement the last svn commit 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 Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Mon Jul 23 15:20:52 2012 (r239698) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Mon Jul 23 16:05:38 2012 (r239699) @@ -97,7 +97,10 @@ /* on disk size of a single file header (also a bucket in cuckoo hashing) */ #define PEFS_FH_SIZE 16 -/* this struct is used to check if all hardlinks for a given inode are supplied by the user */ +/* + * This struct is used to check if all hardlinks for a given inode are supplied + * by the user + */ struct hardlink_counter { ino_t inode; /* inode number for the file in question */ uint32_t total_links; /* total hardlinks of the file */ @@ -1428,6 +1431,7 @@ strlcpy(cfhp->hash_algo, algo, sizeof(cfhp->hash_algo)); } +/* generate dsa keys & write public key to a file */ static EVP_PKEY * pefs_generate_dsa(FILE *pkfp) { @@ -1476,6 +1480,7 @@ return (pkey); } +/* Sign .pefs.checksum. Signature is placed in a different file. */ static int pefs_sign_file(int fd, FILE *pkfp, FILE *signfp) { @@ -1487,6 +1492,8 @@ unsigned int sign_len; int bytes, error, rval; + /* XXXgpf: [TODO] offer option of DSA/RSA & appropriate digests */ + /* generate keys */ pkey = pefs_generate_dsa(pkfp); if (pkey == NULL) return (PEFS_ERR_SYS); @@ -1498,6 +1505,7 @@ return (PEFS_ERR_GENERIC); } + /* generate digital signature */ EVP_SignInit(&ctx, md); error = lseek(fd, 0, SEEK_SET); @@ -1537,6 +1545,7 @@ return (PEFS_ERR_SYS); } + /* write digital signature to .pefs.signature */ if (fwrite(sign, sizeof(char), sign_len, signfp) < sign_len) { pefs_warn("error writing signature"); free(sign); @@ -1550,6 +1559,7 @@ return (0); } +/* read dsa pubkey from file */ static EVP_PKEY * pefs_read_dsa(FILE *pk_fp) { @@ -1581,6 +1591,7 @@ return (pkey); } +/* verify digital signature of .pefs.checksum */ static int pefs_verify_signature(int fd, FILE *pk_fp, FILE *sign_fp) { @@ -1592,6 +1603,7 @@ unsigned int sign_len; int bytes, error, rval; + /* read public key from .pefs.pkey */ pkey = pefs_read_dsa(pk_fp); if (pkey == NULL) return (PEFS_ERR_SYS); @@ -1603,6 +1615,7 @@ return (PEFS_ERR_SYS); } + /* read signature from .pefs.signature */ sign_len = fread(sign, sizeof(char), EVP_PKEY_size(pkey), sign_fp); if (ferror(sign_fp)) { pefs_warn("error reading from signature file"); @@ -1617,6 +1630,8 @@ EVP_PKEY_free(pkey); return (PEFS_ERR_GENERIC); } + + /* process .pefs.checksum & verify the signature */ EVP_VerifyInit(&ctx, md); error = lseek(fd, 0, SEEK_SET); @@ -1658,6 +1673,9 @@ return (PEFS_ERR_GENERIC); } + free(sign); + EVP_PKEY_free(pkey); + return (0); } @@ -1730,7 +1748,9 @@ * An in memory database is created from entries in fpin. This database is * 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. + * 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. */ int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, @@ -2081,7 +2101,9 @@ strcmp(sdp->d_name, ".") == 0 || strcmp(sdp->d_name, ".pefs.db") == 0 || strcmp(sdp->d_name, ".pefs.conf") == 0 || - strcmp(sdp->d_name, ".pefs.checksum") == 0) + strcmp(sdp->d_name, ".pefs.checksum") == 0 || + strcmp(sdp->d_name, ".pefs.signature") == 0 || + strcmp(sdp->d_name, ".pefs.pkey") == 0) continue; dprintf(("dirent: %s\n", sdp->d_name)); @@ -2232,8 +2254,9 @@ * Verify the contents of a .pefs.checksum file. * A) .pefs.checksum is read into memory. * B) The entire filesystem is traversed in order to check each and every file. - * C) warning messages are produces for hardlinks and symbolic links. + * 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 */ int pefs_verify_checksum(int fdin, FILE *pk_fp, FILE *sign_fp, Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Mon Jul 23 15:20:52 2012 (r239698) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Mon Jul 23 16:05:38 2012 (r239699) @@ -1021,14 +1021,17 @@ * .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. + * * -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). * - * [TODO] a flag that allows $command to turn on immutable flags for - * every file that requires integrity checking. */ static int pefs_addchecksum(int argc, char *argv[]) @@ -1045,7 +1048,7 @@ fpin = stdin; /* by default use sha256 */ algo = supported_digests[0]; - /* by default create checksum file under $PWD */ + /* by default create checksum files under $PWD */ snprintf(csm_path, sizeof(csm_path), "./%s", PEFS_FILE_CHECKSUM); snprintf(pk_path, sizeof(pk_path), "./%s", PEFS_FILE_PKEY); snprintf(sign_path, sizeof(sign_path), "./%s", PEFS_FILE_SIGNATURE); @@ -1135,10 +1138,17 @@ * * 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. + * * By default, pefs will assume that filesystem is mounted and user * has provided key. - * - * [TODO] Verify the integrity of the checksum file itself via a signature. */ static int pefs_verify(int argc, char *argv[]) @@ -1150,6 +1160,7 @@ FILE *pk_fp, *sign_fp; int error, fdin, flags, i; + fdin = -1; flags = PEFS_VERIFY; pk_fp = NULL; sign_fp = NULL; @@ -1159,7 +1170,8 @@ pk_fp = fopen(optarg, "r"); if (pk_fp == NULL) { warn("error opening pkey file %s", optarg); - return (PEFS_ERR_SYS); + error = PEFS_ERR_SYS; + goto out; } break; case 'n': @@ -1173,7 +1185,8 @@ sign_fp = fopen(optarg, "r"); if (sign_fp == NULL) { warn("error opening signature file %s", optarg); - return (PEFS_ERR_SYS); + error = PEFS_ERR_SYS; + goto out; } break; case 'u': @@ -1197,11 +1210,11 @@ pefs_usage(); } - /* XXXgpf: [TODO] close files if error */ fdin = open(argv[0], O_RDONLY); if (fdin == -1) { warn("cannot open %s file: %s", PEFS_FILE_CHECKSUM, argv[0]); - return (PEFS_ERR_INVALID); + error = PEFS_ERR_INVALID; + goto out; } dirnamep = dirname(argv[0]); if (pk_fp == NULL) { @@ -1209,7 +1222,8 @@ pk_fp = fopen(pk_path, "r"); if (pk_fp == NULL) { warn("error opening pkey file %s", pk_path); - return (PEFS_ERR_SYS); + error = PEFS_ERR_SYS; + goto out; } } if (sign_fp == NULL) { @@ -1218,7 +1232,8 @@ sign_fp = fopen(sign_path, "r"); if (sign_fp == NULL) { warn("error opening signature file %s", sign_path); - return (PEFS_ERR_SYS); + error = PEFS_ERR_SYS; + goto out; } } @@ -1235,14 +1250,14 @@ strlcpy(fsroot, argv[0], sizeof(fsroot)); if (stat(fsroot, &sb) != 0) { warn("cannot stat fs root: %s", fsroot); - close(fdin); - return (PEFS_ERR_NOENT); + error = PEFS_ERR_NOENT; + goto out; } if (S_ISDIR(sb.st_mode) == 0) { pefs_warn("fs root is not a directory: %s", fsroot); - close(fdin); - return (PEFS_ERR_SYS); + error = PEFS_ERR_SYS; + goto out; } } @@ -1252,9 +1267,13 @@ else pefs_warn("integrity verification encountered error(s)"); - close(fdin); - fclose(pk_fp); - fclose(sign_fp); +out: + if (fdin >= 0) + close(fdin); + if (pk_fp != NULL) + fclose(pk_fp); + if (sign_fp != NULL) + fclose(sign_fp); return (error); } @@ -1286,7 +1305,7 @@ " 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] [checksumpath filesystem]\n" +" pefs verify [-n/u] [-k pkey_file] [-s sign_file] [checksumpath filesystem]\n" ); exit(PEFS_ERR_USAGE); } Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Mon Jul 23 15:20:52 2012 (r239698) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Mon Jul 23 16:05:38 2012 (r239699) @@ -256,7 +256,9 @@ /* XXXgpf: What if user wants integrity checking for .pefs.db or .conf? */ if (strncmp(enc_name, ".pefs.db", enc_name_len) == 0 || strncmp(enc_name, ".pefs.conf", enc_name_len) == 0 || - strncmp(enc_name, ".pefs.checksum", enc_name_len) == 0) + strncmp(enc_name, ".pefs.checksum", enc_name_len) == 0 || + strncmp(enc_name, ".pefs.signature", enc_name_len) == 0 || + strncmp(enc_name, ".pefs.pkey", enc_name_len) == 0) goto not_found; enc_name++; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 17:47:07 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 7D6FB106566B for ; Mon, 23 Jul 2012 17:47:05 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 17:47:05 +0000 Date: Mon, 23 Jul 2012 17:47:05 +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: <20120723174705.7D6FB106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239701 - 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: Mon, 23 Jul 2012 17:47:07 -0000 Author: gpf Date: Mon Jul 23 17:47:04 2012 New Revision: 239701 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239701 Log: /sbin/pefs 'nameid' that retrieves the name checksum that is used as a unique file identifier by pefs integrity checking code. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Mon Jul 23 16:36:13 2012 (r239700) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Mon Jul 23 17:47:04 2012 (r239701) @@ -925,7 +925,6 @@ } strlcpy(fhp->dirpath, dirnamep, sizeof(fhp->dirpath)); - namep = basename(namebuf); if (namep == NULL) { pefs_warn("failed to extract filename of %s", fhp->path); @@ -943,7 +942,8 @@ if ((sb.st_flags & SF_IMMUTABLE) == 0 && (flags & PEFS_SETIMMUTABLE) == 0 && - (flags & PEFS_VERIFY) == 0) { + (flags & PEFS_VERIFY) == 0 && + (flags & PEFS_GETID) == 0) { pefs_warn("file %s does not have schg flag", fhp->path); return (PEFS_ERR_SYS); } @@ -1035,7 +1035,7 @@ return (PEFS_ERR_SYS); } - if (S_ISREG(sb.st_mode) == 0) { + if (S_ISREG(sb.st_mode) == 0 && (flags & PEFS_GETID) == 0) { pefs_warn("filename: %s is not a regular file", fhp->path); return (PEFS_ERR_INVALID); } @@ -1050,7 +1050,7 @@ } } - if ((flags & PEFS_UNMOUNTED) == 0) { + if ((flags & PEFS_UNMOUNTED) == 0 && (fsp != NULL)) { if (fstatfs(fhp->fd, &this_fs) == -1) { pefs_warn("statfs failed: %s: %s", fhp->path, strerror(errno)); return (PEFS_ERR_SYS); @@ -2177,6 +2177,11 @@ 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); @@ -2335,4 +2340,35 @@ return (error); } + +/* retrieve and then print the name checksum ID for a given filename */ +int +pefs_filename_to_id(char *file_path, int flags) +{ + struct file_header *fhp; + int error; + + fhp = pefs_allocate_file_header(); + if (fhp == NULL) { + error = PEFS_ERR_SYS; + goto out; + } + + strlcpy(fhp->path, file_path, sizeof(fhp->path)); + + error = pefs_open_semantic_checks(fhp, NULL, NULL, flags); + if (error != 0) + goto out; + + error = pefs_get_file_id(fhp, flags); + if (error != 0) + goto out; + + printf("id: %llu\n", fhp->file_id); + +out: + pefs_free_file_header(fhp); + return (error); +} + RB_GENERATE(hardlink_head, hardlink_counter, hardlink_entries, pefs_rb_cmp); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Mon Jul 23 16:36:13 2012 (r239700) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Mon Jul 23 17:47:04 2012 (r239701) @@ -78,6 +78,7 @@ static int pefs_showalgs(int argc, char *argv[]); static int pefs_addchecksum(int argc, char *argv[]); static int pefs_verify(int argc, char *argv[]); +static int pefs_nameid(int argc, char *argv[]); typedef int (*command_func_t)(int argc, char **argv); typedef int (*keyop_func_t)(struct pefs_keychain_head *kch, int fd, @@ -106,6 +107,7 @@ { "showalgs", pefs_showalgs }, { "addchecksum", pefs_addchecksum}, { "verify", pefs_verify}, + { "nameid", pefs_nameid}, { NULL, NULL }, }; @@ -1277,7 +1279,76 @@ return (error); } -/* XXXgpf: [TODO] a command that returns the file id of a file (name MAC) */ +/* + * XXXgpf: Instead of a man page entry: + * + * pefs nameid [-u/-n] filepath + * + * $command prints out the identifier for an encrypted pefs filename where + * pefs encrypted filename = XBase64(checksum || E(tweak || filename)). + * + * The id is the name checksum, meaning VMAC(E(tweak || filename)). + * + * This identifier is used as a primary key when a specific filename is handled + * by pefs for integrity checking purposes. + * + * Some warning messages produced by /sbin/pefs refer to files by their internal + * ID and not their unencrypted fullpath; e.g. when verifying an unmounted pefs + * filesystem. Therefore this command can be used to map fullpaths to internal + * IDs. + * + * -n flag should be used if filesystem is mounted but key has not been + * provided yet. + * + * -u flag should be used if filesystem is unmounted. + * + * In both of these scenarios the "filepath" that is provided by the user should + * be the encrypted filepath. + * + * flags -u and -n are mutually exclusive. + */ +static int +pefs_nameid(int argc, char *argv[]) +{ + char file_path[MAXPATHLEN + 1]; + int error, flags, i; + + flags = PEFS_GETID; + while ((i = getopt(argc, argv, "nu")) != -1) + switch(i) { + case 'n': + flags|= PEFS_NOKEY; + if ((flags & PEFS_UNMOUNTED) != 0) { + pefs_warn("flags -u and -n are mutually exclusive"); + return (PEFS_ERR_INVALID); + } + break; + case 'u': + flags|= PEFS_UNMOUNTED; + if ((flags & PEFS_NOKEY) != 0) { + pefs_warn("flags -u and -n are mutually exclusive"); + return (PEFS_ERR_INVALID); + } + break; + default: + pefs_usage(); + } + argc -= optind; + argv += optind; + + if (argc != 1) { + if (argc < 1) + warnx("too few arguments"); + else + warnx("too many arguments"); + pefs_usage(); + } + + strlcpy(file_path, argv[0], sizeof(file_path)); + error = pefs_filename_to_id(file_path, flags); + + return (error); +} static void pefs_usage_alg(void) @@ -1306,6 +1377,7 @@ " 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 nameid [-u/-n] [filepath]" ); exit(PEFS_ERR_USAGE); } Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Mon Jul 23 16:36:13 2012 (r239700) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Mon Jul 23 17:47:04 2012 (r239701) @@ -50,6 +50,7 @@ #define PEFS_UNMOUNTED 0x0002 #define PEFS_SETIMMUTABLE 0x0004 #define PEFS_VERIFY 0x0010 +#define PEFS_GETID 0x0020 #define PEFS_KEYCONF_ALG_IND 0 #define PEFS_KEYCONF_ITERATIONS_IND 1 @@ -106,6 +107,7 @@ char *pk_path, char *sign_path, const char *algo, int flags); int pefs_verify_checksum(int fdin, FILE *pk_fp, FILE *sign_fp, char *fsroot, int flags); +int pefs_filename_to_id(char *file_path, int flags); int pefs_name_pton(char const *src, size_t srclen, u_char *target, size_t targsize); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 19:15:12 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 A67D5106564A for ; Mon, 23 Jul 2012 19:15:11 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 19:15:11 +0000 Date: Mon, 23 Jul 2012 19:15:11 +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: <20120723191511.A67D5106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239702 - 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: Mon, 23 Jul 2012 19:15:12 -0000 Author: tzabal Date: Mon Jul 23 19:15:10 2012 New Revision: 239702 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239702 Log: Add the steps required for PostgreSQL and the lxml module regarding Python. 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 Mon Jul 23 17:47:04 2012 (r239701) +++ soc2012/tzabal/server-side/akcrs-setup/database.sql Mon Jul 23 19:15:10 2012 (r239702) @@ -10,7 +10,7 @@ CREATE TABLE Submitters ( - id integer, + id SERIAL, email varchar(254) NOT NULL, passwd varchar(12) NOT NULL, @@ -20,7 +20,7 @@ CREATE TABLE Bugs ( - id integer, + id SERIAL, state varchar(10) NOT NULL, reported integer NOT NULL, @@ -30,7 +30,7 @@ CREATE TABLE Reports ( - id integer, + id SERIAL, bug_id integer NOT NULL, submitter_id integer NOT NULL, received_date date DEFAULT CURRENT_DATE, Modified: soc2012/tzabal/server-side/akcrs-setup/setup ============================================================================== --- soc2012/tzabal/server-side/akcrs-setup/setup Mon Jul 23 17:47:04 2012 (r239701) +++ soc2012/tzabal/server-side/akcrs-setup/setup Mon Jul 23 19:15:10 2012 (r239702) @@ -69,7 +69,29 @@ ########################################################### # Part 3. PostgreSQL ########################################################### +# Install the default version of PostgreSQL server currently used in FreeBSD (PostgreSQL Server 9.0.8) +cd /usr/ports/databases/postgresql90-server +make config +make install clean +# Run the PostgreSQL Server at startup +echo 'postgresql_enable="YES"' >> /etc/rc.conf + +# Initialize the PostgreSQL database cluster for the first time. +# This command creates the initial database cluster in the /usr/local/pgsql/data directory by default +/usr/local/etc/rc.d/postgresql initdb + +# Start the database server +/usr/local/etc/rc.d/postgresql start + +# Swith to the (system) user that owns the PostgreSQL Server (or remain as root) +su pgsql + +# Create a new PostgreSQL user (role) that will NOT be superuser, create databases and create roles +createuser -P akcrs + +# Create a Unicode database that our PostgreSQL user will has access to +/usr/local/bin/createdb akcrs_db -O akcrs --encoding=UNICODE ########################################################### @@ -78,4 +100,10 @@ # Install Python (default: python 2.7.3) cd /usr/ports/lang/python -make -DBATCH install clean \ No newline at end of file +make -DBATCH install clean + +# Install the module psycopg2 (DB API 2.0 driver of PostgreSQL for Python) +easy_install psycopg2 + +# Install the module lxml (Library for processing XML and HTML in Python) +easy_install lxml \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 19:28:45 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 AFA16106564A for ; Mon, 23 Jul 2012 19:28:43 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 19:28:43 +0000 Date: Mon, 23 Jul 2012 19:28:43 +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: <20120723192843.AFA16106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239703 - in soc2012/jhagewood/diff3: . 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: Mon, 23 Jul 2012 19:28:46 -0000 Author: jhagewood Date: Mon Jul 23 19:28:42 2012 New Revision: 239703 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239703 Log: diff3prog to diff3 Modified: soc2012/jhagewood/diff3/diff3/Makefile soc2012/jhagewood/diff3/diff3/diff3.1 soc2012/jhagewood/diff3/diff3/diff3.ksh soc2012/jhagewood/diff3/diff3/diff3.sh soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/diff3/Makefile ============================================================================== --- soc2012/jhagewood/diff3/diff3/Makefile Mon Jul 23 19:15:10 2012 (r239702) +++ soc2012/jhagewood/diff3/diff3/Makefile Mon Jul 23 19:28:42 2012 (r239703) @@ -1,11 +1,11 @@ # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ -PROG= diff3prog +PROG= diff3 MAN= diff3.1 BINDIR= /usr/libexec beforeinstall: - install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + install diff3prog.c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${.CURDIR}/diff3.sh ${DESTDIR}/usr/bin/diff3 .include Modified: soc2012/jhagewood/diff3/diff3/diff3.1 ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3.1 Mon Jul 23 19:15:10 2012 (r239702) +++ soc2012/jhagewood/diff3/diff3/diff3.1 Mon Jul 23 19:28:42 2012 (r239703) @@ -168,7 +168,7 @@ as the temporary directory. .El .Sh FILES -.Bl -tag -width /usr/libexec/diff3prog -compact +.Bl -tag -width /usr/libexec/diff3 -compact .It Pa /tmp/d3a.XXXXXXXXXX temporary file .It Pa /tmp/d3b.XXXXXXXXXX Modified: soc2012/jhagewood/diff3/diff3/diff3.ksh ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3.ksh Mon Jul 23 19:15:10 2012 (r239702) +++ soc2012/jhagewood/diff3/diff3/diff3.ksh Mon Jul 23 19:28:42 2012 (r239703) @@ -25,7 +25,7 @@ OPTIND=1 # force getopts to reset itself export PATH=/bin:/usr/bin -diff3prog=/usr/libexec/diff3prog +diff3prog=/usr/libexec/diff3 USAGE="usage: diff3 [-3aEeXx] file1 file2 file3" # Pull out any command line flags (some for diff, some for diff3) Modified: soc2012/jhagewood/diff3/diff3/diff3.sh ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3.sh Mon Jul 23 19:15:10 2012 (r239702) +++ soc2012/jhagewood/diff3/diff3/diff3.sh Mon Jul 23 19:28:42 2012 (r239703) @@ -25,8 +25,8 @@ OPTIND=1 # force getopts to reset itself export PATH=/bin:/usr/bin -#diff3prog=/usr/libexec/diff3prog -diff3prog=$PWD/diff3prog +#diff3prog=/usr/libexec/diff3 +diff3prog=$PWD/diff3 USAGE="usage: diff3 [-3aEeXx] file1 file2 file3" # Pull out any command line flags (some for diff, some for diff3) Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Mon Jul 23 19:15:10 2012 (r239702) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Mon Jul 23 19:28:42 2012 (r239703) @@ -1,18 +1,31 @@ diff -rupN diff3-orig/Makefile diff3/Makefile --- diff3-orig/Makefile 2012-07-23 02:07:00.000000000 -0400 -+++ diff3/Makefile 2012-07-23 02:09:25.000000000 -0400 -@@ -6,6 +6,6 @@ BINDIR= /usr/libexec ++++ diff3/Makefile 2012-07-23 15:27:33.000000000 -0400 +@@ -1,11 +1,11 @@ + # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ + +-PROG= diff3prog ++PROG= diff3 + MAN= diff3.1 + BINDIR= /usr/libexec beforeinstall: - install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ +- install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/diff3.ksh ${DESTDIR}/usr/bin/diff3 ++ install diff3prog.c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/diff3.sh ${DESTDIR}/usr/bin/diff3 .include diff -rupN diff3-orig/diff3.1 diff3/diff3.1 --- diff3-orig/diff3.1 2012-07-23 02:07:00.000000000 -0400 -+++ diff3/diff3.1 2012-07-23 02:07:00.000000000 -0400 -@@ -173,7 +173,7 @@ as the temporary directory. ++++ diff3/diff3.1 2012-07-23 15:21:13.000000000 -0400 +@@ -168,12 +168,12 @@ will use the directory specified by + as the temporary directory. + .El + .Sh FILES +-.Bl -tag -width /usr/libexec/diff3prog -compact ++.Bl -tag -width /usr/libexec/diff3 -compact + .It Pa /tmp/d3a.XXXXXXXXXX temporary file .It Pa /tmp/d3b.XXXXXXXXXX temporary file @@ -21,6 +34,32 @@ the actual executable .El .Sh SEE ALSO +diff -rupN diff3-orig/diff3.ksh diff3/diff3.ksh +--- diff3-orig/diff3.ksh 2012-07-23 02:07:00.000000000 -0400 ++++ diff3/diff3.ksh 2012-07-23 15:21:48.000000000 -0400 +@@ -25,7 +25,7 @@ set -o posix # set POSIX mode to preven + OPTIND=1 # force getopts to reset itself + + export PATH=/bin:/usr/bin +-diff3prog=/usr/libexec/diff3prog ++diff3prog=/usr/libexec/diff3 + USAGE="usage: diff3 [-3aEeXx] file1 file2 file3" + + # Pull out any command line flags (some for diff, some for diff3) +diff -rupN diff3-orig/diff3.sh diff3/diff3.sh +--- diff3-orig/diff3.sh 2012-07-23 02:07:00.000000000 -0400 ++++ diff3/diff3.sh 2012-07-23 15:22:35.000000000 -0400 +@@ -25,8 +25,8 @@ + OPTIND=1 # force getopts to reset itself + + export PATH=/bin:/usr/bin +-#diff3prog=/usr/libexec/diff3prog +-diff3prog=$PWD/diff3prog ++#diff3prog=/usr/libexec/diff3 ++diff3prog=$PWD/diff3 + USAGE="usage: diff3 [-3aEeXx] file1 file2 file3" + + # Pull out any command line flags (some for diff, some for diff3) diff -rupN diff3-orig/diff3prog.c diff3/diff3prog.c --- diff3-orig/diff3prog.c 2012-07-23 02:07:00.000000000 -0400 +++ diff3/diff3prog.c 2012-07-23 02:07:00.000000000 -0400 From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:20: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 4C1B0106566B for ; Mon, 23 Jul 2012 20:20:05 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:20:05 +0000 Date: Mon, 23 Jul 2012 20:20:05 +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: <20120723202005.4C1B0106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239707 - in soc2012/gmiller/locking-head: . 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: Mon, 23 Jul 2012 20:20:06 -0000 Author: gmiller Date: Mon Jul 23 20:20:04 2012 New Revision: 239707 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239707 Log: r239741@FreeBSD-dev: root | 2012-07-23 11:33:40 -0500 Fix inverted parameter order in pthread_lockorder_set_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 23 19:23:49 2012 (r239706) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 23 20:20:04 2012 (r239707) @@ -384,7 +384,7 @@ _pthread_mutex_lock(&witness_mtx); - if (insert_lock(lookup_lock(first), lookup_lock(second)) < 0) { + if (insert_lock(lookup_lock(second), lookup_lock(first)) < 0) { ret = EINVAL; } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:20: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 5B8D710657F4 for ; Mon, 23 Jul 2012 20:20:25 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:20:25 +0000 Date: Mon, 23 Jul 2012 20:20:25 +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: <20120723202025.5B8D710657F4@hub.freebsd.org> Cc: Subject: socsvn commit: r239708 - in soc2012/gmiller/locking-head: . 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: Mon, 23 Jul 2012 20:20:27 -0000 Author: gmiller Date: Mon Jul 23 20:20:25 2012 New Revision: 239708 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239708 Log: r239742@FreeBSD-dev: root | 2012-07-23 12:54:43 -0500 Re-implement pthread_lockorder_begin_np(), pthread_lockorder_next_np(), and pthread_lockorder_end_np() using the lock_info structure. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 23 20:20:04 2012 (r239707) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 23 20:20:25 2012 (r239708) @@ -27,17 +27,6 @@ #include "witness.h" -struct lock_iter { - SLIST_ENTRY(lock_iter) iter_next; - void *lock; -}; - -struct _pthread_lockorder_private { - SLIST_HEAD(lock_iter_head, lock_iter) lock_iter_head; -}; - -struct lock_info *root = NULL; - static int scan_graph(struct lock_info *graph, struct lock_info *lock) { @@ -88,72 +77,3 @@ return (0); } - -static void -add_graph(struct pthread_lockorder_np *iter_node, struct lock_info *graph_node) -{ - struct lock_iter *iter; - - if (graph_node != NULL) { - iter = malloc(sizeof(struct pthread_lockorder_np)); - iter->lock = graph_node->lock; - SLIST_INSERT_HEAD(&iter_node->_pvt->lock_iter_head, iter, - iter_next); - - add_graph(iter_node, graph_node->sibling); - add_graph(iter_node, graph_node->child); - } -} - -void -pthread_lockorder_begin_np(struct pthread_lockorder_np *node) -{ - /* - The lock isn't needed to prevent races, but it is needed to ensure - that any locks grabbed by malloc() don't get logged. - */ - pthread_mutex_lock(&witness_mtx); - - node->_pvt = malloc(sizeof(struct _pthread_lockorder_private)); - - add_graph(node, root); - - pthread_mutex_unlock(&witness_mtx); -} - -int -pthread_lockorder_next_np(struct pthread_lockorder_np *node) -{ - struct lock_iter *iter; - - iter = SLIST_FIRST(&node->_pvt->lock_iter_head); - if (iter != NULL) { - SLIST_REMOVE_HEAD(&node->_pvt->lock_iter_head, iter_next); - - node->lock = iter->lock; - - free(iter); - - return (1); - } else { - return (0); - } -} - -void -pthread_lockorder_end_np(struct pthread_lockorder_np *node) -{ - struct lock_iter *iter; - - if (node->_pvt != NULL) { - while (!SLIST_EMPTY(&node->_pvt->lock_iter_head)) { - iter = SLIST_FIRST(&node->_pvt->lock_iter_head); - SLIST_REMOVE_HEAD(&node->_pvt->lock_iter_head, - iter_next); - free(iter); - } - - free(node->_pvt); - node->_pvt = NULL; - } -} Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:20:04 2012 (r239707) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:20:25 2012 (r239708) @@ -32,6 +32,10 @@ static SLIST_HEAD(lock_info_head, lock_info) lock_info_head = SLIST_HEAD_INITIALIZER(lock_info_head); +struct _pthread_lockorder_private { + struct lock_info *last_record; +}; + struct lock_info * lookup_lock(void *lock) { @@ -120,3 +124,44 @@ } } } + +void +pthread_lockorder_begin_np(struct pthread_lockorder_np *node) +{ + /* + The lock isn't needed to prevent races, but it is needed to ensure + that any locks grabbed by malloc() don't get logged. + */ + pthread_mutex_lock(&witness_mtx); + + node->_pvt = malloc(sizeof(struct _pthread_lockorder_private)); + node->_pvt->last_record = NULL; + + pthread_mutex_unlock(&witness_mtx); +} + +int +pthread_lockorder_next_np(struct pthread_lockorder_np *node) +{ + 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; + + return (1); + } else { + return (0); + } +} + +void +pthread_lockorder_end_np(struct pthread_lockorder_np *node) +{ + free(node->_pvt); + node->_pvt = NULL; +} From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:20:45 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 AEB9F1065697 for ; Mon, 23 Jul 2012 20:20:43 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:20:43 +0000 Date: Mon, 23 Jul 2012 20:20:43 +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: <20120723202043.AEB9F1065697@hub.freebsd.org> Cc: Subject: socsvn commit: r239709 - 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: Mon, 23 Jul 2012 20:20:45 -0000 Author: gmiller Date: Mon Jul 23 20:20:43 2012 New Revision: 239709 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239709 Log: r239743@FreeBSD-dev: root | 2012-07-23 12:57:15 -0500 Add tests for pthread_lockorder_set_np(). Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t - copied unchanged from r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:20:25 2012 (r239708) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:20:43 2012 (r239709) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lor-basic +TESTS= lor-basic setorder CFLAGS+= -g -Wall -Wextra -Werror -lwitness .PHONY: tests @@ -13,3 +13,6 @@ lor-basic: lor-basic.c check.c ${CC} -o lor-basic lor-basic.c check.c ${CFLAGS} + +setorder: setorder.c check.c + ${CC} -o setorder setorder.c check.c ${CFLAGS} Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:20:25 2012 (r239708) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:20:43 2012 (r239709) @@ -1,3 +1,29 @@ +/*- + * 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 Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c Mon Jul 23 20:20:43 2012 (r239709) @@ -0,0 +1,104 @@ +/*- + * 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 +unset_test(void) +{ + pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; + pthread_rwlock_t rwlock2 = PTHREAD_RWLOCK_INITIALIZER; + + pthread_rwlock_rdlock(&rwlock1); + pthread_rwlock_rdlock(&rwlock2); + + pthread_rwlock_unlock(&rwlock2); + pthread_rwlock_unlock(&rwlock1); +} + +void +set_test(void) +{ + pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; + pthread_rwlock_t rwlock2 = PTHREAD_RWLOCK_INITIALIZER; + + pthread_lockorder_reset_np(); + pthread_lockorder_set_np(&rwlock2, &rwlock1); + + pthread_rwlock_rdlock(&rwlock1); + pthread_rwlock_rdlock(&rwlock2); + + pthread_rwlock_unlock(&rwlock2); + pthread_rwlock_unlock(&rwlock1); +} + +void +check_unset(void) +{ + int record_count = 0; + struct pthread_lor_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + record_count++; + } + pthread_lor_end_np(&lor); + + check(record_count == 0); +} + +void +check_set(void) +{ + int record_count = 0; + struct pthread_lor_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + record_count++; + } + pthread_lor_end_np(&lor); + + check(record_count == 1); +} + +int +main(void) +{ + unset_test(); + check_unset(); + + set_test(); + check_set(); + + show_test_results(); + + return 0; +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t (from r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t Mon Jul 23 20:20:43 2012 (r239709, copy of r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.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 Mon Jul 23 20:20:58 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 1B0F81065680 for ; Mon, 23 Jul 2012 20:20:56 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:20:56 +0000 Date: Mon, 23 Jul 2012 20:20:56 +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: <20120723202056.1B0F81065680@hub.freebsd.org> Cc: Subject: socsvn commit: r239710 - in soc2012/gmiller/locking-head: . 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: Mon, 23 Jul 2012 20:20:58 -0000 Author: gmiller Date: Mon Jul 23 20:20:55 2012 New Revision: 239710 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239710 Log: r239750@FreeBSD-dev: root | 2012-07-23 13:22:31 -0500 Fix a memory leak with blessed locks. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:20:43 2012 (r239709) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:20:55 2012 (r239710) @@ -88,6 +88,8 @@ reset_lock_info(void) { struct lock_info *info; + struct blessing *bless; + struct blessing *bless_temp; while (!SLIST_EMPTY(&lock_info_head)) { info = SLIST_FIRST(&lock_info_head); @@ -97,6 +99,12 @@ if (info->name != NULL) { free(info->name); } + + SLIST_FOREACH_SAFE(bless, &info->bless_head, bless_next, + bless_temp) { + free(bless); + } + free(info); } } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:21: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 D5B81106568B for ; Mon, 23 Jul 2012 20:21:07 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:21:07 +0000 Date: Mon, 23 Jul 2012 20:21:07 +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: <20120723202107.D5B81106568B@hub.freebsd.org> Cc: Subject: socsvn commit: r239711 - 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: Mon, 23 Jul 2012 20:21:10 -0000 Author: gmiller Date: Mon Jul 23 20:21:07 2012 New Revision: 239711 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239711 Log: r239751@FreeBSD-dev: root | 2012-07-23 13:33:39 -0500 Add license boilerplate. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c Mon Jul 23 20:20:55 2012 (r239710) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c Mon Jul 23 20:21:07 2012 (r239711) @@ -1,3 +1,29 @@ +/*- + * 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 Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h Mon Jul 23 20:20:55 2012 (r239710) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h Mon Jul 23 20:21:07 2012 (r239711) @@ -1,3 +1,29 @@ +/*- + * 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. + * + */ void check(char cond); void show_test_results(void); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:21:23 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 A05321065670 for ; Mon, 23 Jul 2012 20:21:21 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:21:21 +0000 Date: Mon, 23 Jul 2012 20:21:21 +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: <20120723202121.A05321065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239712 - 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: Mon, 23 Jul 2012 20:21:23 -0000 Author: gmiller Date: Mon Jul 23 20:21:21 2012 New Revision: 239712 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239712 Log: r239752@FreeBSD-dev: root | 2012-07-23 13:34:25 -0500 Fix style nits. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:21:07 2012 (r239711) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:21:21 2012 (r239712) @@ -79,5 +79,5 @@ show_test_results(); - return 0; + return (0); } Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c Mon Jul 23 20:21:07 2012 (r239711) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c Mon Jul 23 20:21:21 2012 (r239712) @@ -100,5 +100,5 @@ show_test_results(); - return 0; + return (0); } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 23 20:21:39 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 D19F81065673 for ; Mon, 23 Jul 2012 20:21:37 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:21:37 +0000 Date: Mon, 23 Jul 2012 20:21:37 +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: <20120723202137.D19F81065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239713 - 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: Mon, 23 Jul 2012 20:21:40 -0000 Author: gmiller Date: Mon Jul 23 20:21:37 2012 New Revision: 239713 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239713 Log: r239753@FreeBSD-dev: root | 2012-07-23 13:35:03 -0500 Add tests for blessed locks. Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.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 Mon Jul 23 20:21:21 2012 (r239712) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:21:37 2012 (r239713) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lor-basic setorder +TESTS= lor-basic setorder bless CFLAGS+= -g -Wall -Wextra -Werror -lwitness .PHONY: tests @@ -16,3 +16,6 @@ setorder: setorder.c check.c ${CC} -o setorder setorder.c check.c ${CFLAGS} + +bless: bless.c check.c + ${CC} -o bless bless.c check.c ${CFLAGS} Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c Mon Jul 23 20:21:37 2012 (r239713) @@ -0,0 +1,121 @@ +/*- + * 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 + +#include "check.h" + +void +unbless_test(void) +{ + pthread_spinlock_t spin1; + pthread_spinlock_t spin2; + + pthread_spin_init(&spin1, PTHREAD_PROCESS_PRIVATE); + pthread_spin_init(&spin2, PTHREAD_PROCESS_PRIVATE); + + pthread_spin_lock(&spin1); + pthread_spin_lock(&spin2); + + pthread_spin_unlock(&spin2); + pthread_spin_unlock(&spin1); + + pthread_spin_lock(&spin2); + pthread_spin_lock(&spin1); + + pthread_spin_unlock(&spin1); + pthread_spin_unlock(&spin2); +} + +void +bless_test(void) +{ + pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; + + pthread_lor_clear_np(); + pthread_lockorder_reset_np(); + pthread_lockorder_bless_np(&mutex1, &mutex2); + + 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_unbless(void) +{ + int record_count = 0; + struct pthread_lor_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + record_count++; + } + pthread_lor_end_np(&lor); + + check(record_count == 1); +} + +void +check_bless(void) +{ + int record_count = 0; + struct pthread_lor_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + record_count++; + } + pthread_lor_end_np(&lor); + + check(record_count == 0); +} + +int +main(void) +{ + unbless_test(); + check_unbless(); + + bless_test(); + check_bless(); + + show_test_results(); + + return (0); +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.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/bless.t Mon Jul 23 20:21:37 2012 (r239713, 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 Mon Jul 23 20:22:02 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 107921065673 for ; Mon, 23 Jul 2012 20:22:00 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:22:00 +0000 Date: Mon, 23 Jul 2012 20:22:00 +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: <20120723202200.107921065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239714 - 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: Mon, 23 Jul 2012 20:22:02 -0000 Author: gmiller Date: Mon Jul 23 20:21:59 2012 New Revision: 239714 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239714 Log: r239754@FreeBSD-dev: root | 2012-07-23 14:28:03 -0500 Add lock names to pthread_lor_np, add a test for pthread_setname_np(), and fix the bugs that were found as a result. Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.t - copied unchanged from r239713, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.t Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/logs.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 23 20:21:59 2012 (r239714) @@ -64,6 +64,8 @@ struct _pthread_lor_private *_pvt; void *lock_first; void *lock_second; + const char *name_first; + const char *name_second; }; struct _pthread_lockorder_private; Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:21:59 2012 (r239714) @@ -115,10 +115,8 @@ struct lock_info *info; info = lookup_lock(lock); - if (info->name != NULL) { - info->name = realloc(info->name, strlen(name) + 1); - strcpy(info->name, name); - } + info->name = realloc(info->name, strlen(name) + 1); + strcpy(info->name, name); } void Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 23 20:21:59 2012 (r239714) @@ -81,8 +81,10 @@ } if (lor->_pvt->last_record != NULL) { - lor->lock_first = lor->_pvt->last_record->lock_first; - lor->lock_second = lor->_pvt->last_record->lock_second; + 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; res = 1; } Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c Mon Jul 23 20:21:59 2012 (r239714) @@ -1,3 +1,29 @@ +/*- + * 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 Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h Mon Jul 23 20:21:59 2012 (r239714) @@ -1,3 +1,29 @@ +/*- + * 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. + * + */ void check(char cond); void show_test_results(void); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c Mon Jul 23 20:21:59 2012 (r239714) @@ -1,3 +1,29 @@ +/*- + * 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 Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 23 20:21:59 2012 (r239714) @@ -1,3 +1,29 @@ +/*- + * 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 Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Mon Jul 23 20:21:59 2012 (r239714) @@ -1,3 +1,29 @@ +/*- + * 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 Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:21:59 2012 (r239714) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lor-basic setorder bless +TESTS= lor-basic setorder bless setname CFLAGS+= -g -Wall -Wextra -Werror -lwitness .PHONY: tests @@ -19,3 +19,6 @@ bless: bless.c check.c ${CC} -o bless bless.c check.c ${CFLAGS} + +setname: setname.c check.c + ${CC} -o setname setname.c check.c ${CFLAGS} Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c Mon Jul 23 20:21:37 2012 (r239713) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.c Mon Jul 23 20:21:59 2012 (r239714) @@ -27,7 +27,6 @@ #include #include -#include #include "check.h" Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.c Mon Jul 23 20:21:59 2012 (r239714) @@ -0,0 +1,85 @@ +/*- + * 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 + +#include "check.h" + +pthread_mutex_t mutex1; +pthread_mutex_t mutex2; + +void +setname_test(void) +{ + pthread_setname_np(&mutex1, "mutex 1"); + pthread_setname_np(&mutex2, "mutex 2"); + + 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_lock(&mutex1); + pthread_mutex_lock(&mutex2); +} + +void +check_setname(void) +{ + int record_count = 0; + struct pthread_lor_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + 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 +main(void) +{ + setname_test(); + check_setname(); + + show_test_results(); + + return (0); +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.t (from r239713, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.t) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setname.t Mon Jul 23 20:21:59 2012 (r239714, copy of r239713, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/bless.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 Mon Jul 23 20:22: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 66D671065673 for ; Mon, 23 Jul 2012 20:22:13 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 23 Jul 2012 20:22:13 +0000 Date: Mon, 23 Jul 2012 20:22:13 +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: <20120723202213.66D671065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239715 - in soc2012/gmiller/locking-head: . include 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: Mon, 23 Jul 2012 20:22:15 -0000 Author: gmiller Date: Mon Jul 23 20:22:13 2012 New Revision: 239715 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239715 Log: r239755@FreeBSD-dev: root | 2012-07-23 15:19:18 -0500 Handle memory allocation failures a bit more gracefully. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/graph.c 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/wrappers.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 23 20:22:13 2012 (r239715) @@ -106,17 +106,17 @@ int pthread_switch_add_np(pthread_switch_routine_t); int pthread_switch_delete_np(pthread_switch_routine_t); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); -void pthread_lor_begin_np(struct pthread_lor_np *); +int pthread_lor_begin_np(struct pthread_lor_np *); int pthread_lor_next_np(struct pthread_lor_np *); void pthread_lor_end_np(struct pthread_lor_np *); void pthread_lor_clear_np(void); int pthread_lockorder_bless_np(void *, void *); int pthread_lockorder_set_np(void *first, void *second); void pthread_lockorder_reset_np(void); -void pthread_lockorder_begin_np(struct pthread_lockorder_np *); +int pthread_lockorder_begin_np(struct pthread_lockorder_np *); int pthread_lockorder_next_np(struct pthread_lockorder_np *); void pthread_lockorder_end_np(struct pthread_lockorder_np *); -void pthread_setname_np(void *, const char *); +int pthread_setname_np(void *, const char *); #ifdef LOCK_PROFILING Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 23 20:22:13 2012 (r239715) @@ -62,7 +62,7 @@ int insert_lock(struct lock_info *from, struct lock_info *to) { - if (from == to) { + if (from == to || from == NULL || to == NULL) { return (0); } Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Mon Jul 23 20:22:13 2012 (r239715) @@ -44,9 +44,17 @@ struct lock_entry *entry; struct lock_entry *next; + if (lock == NULL) { + return; + } + next = SLIST_FIRST(&lock_head); entry = malloc(sizeof(*entry)); + if (entry == NULL) { + return; + } + entry->lock = lock; if (reset_count > thread_reset_count) { Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 23 20:22:13 2012 (r239715) @@ -49,13 +49,16 @@ if (info == NULL) { info = malloc(sizeof(struct lock_info)); - 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 (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); + } } return (info); @@ -67,7 +70,9 @@ struct lock_info *info; info = lookup_lock(lock); - info->active = 0; + if (info != NULL) { + info->active = 0; + } } int @@ -109,20 +114,30 @@ } } -void +int pthread_setname_np(void *lock, const char *name) { struct lock_info *info; info = lookup_lock(lock); - info->name = realloc(info->name, strlen(name) + 1); + if (info == NULL) { + return (ENOMEM); + } + + info->name = reallocf(info->name, strlen(name) + 1); + if (info->name == NULL) { + return (errno); + } + strcpy(info->name, name); + + return (0); } void check_default_name(struct lock_info *lock, const char *prefix) { - if (lock->name == NULL) { + 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", @@ -131,9 +146,11 @@ } } -void +int pthread_lockorder_begin_np(struct pthread_lockorder_np *node) { + 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. @@ -141,28 +158,37 @@ pthread_mutex_lock(&witness_mtx); node->_pvt = malloc(sizeof(struct _pthread_lockorder_private)); - node->_pvt->last_record = NULL; + if (node->_pvt == NULL) { + ret = ENOMEM; + } else { + node->_pvt->last_record = NULL; + } pthread_mutex_unlock(&witness_mtx); + + return (ret); } int pthread_lockorder_next_np(struct pthread_lockorder_np *node) { - 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 != 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 != NULL) { + node->lock = node->_pvt->last_record->lock; - return (1); - } else { - return (0); + return (1); + } } + + return (0); } void Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 23 20:22:13 2012 (r239715) @@ -45,15 +45,18 @@ struct lor_entry *entry; entry = malloc(sizeof(struct lor_entry)); - entry->lock_first = previous; - entry->lock_second = lock; + if (entry != NULL) { + entry->lock_first = previous; + entry->lock_second = lock; - STAILQ_INSERT_TAIL(&lor_head, entry, lor_next); + STAILQ_INSERT_TAIL(&lor_head, entry, lor_next); + } } -void +int 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. @@ -61,15 +64,21 @@ pthread_mutex_lock(&witness_mtx); lor->_pvt = malloc(sizeof(struct _pthread_lor_private)); - lor->_pvt->last_record = NULL; + if (lor->_pvt == NULL) { + ret = ENOMEM; + } else { + lor->_pvt->last_record = NULL; + } pthread_mutex_unlock(&witness_mtx); + + return (ret); } int pthread_lor_next_np(struct pthread_lor_np *lor) { - int res = 0; + int res = 0; pthread_mutex_lock(&witness_mtx); Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 23 20:21:59 2012 (r239714) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 23 20:22:13 2012 (r239715) @@ -53,7 +53,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -74,7 +74,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -95,7 +95,7 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -116,7 +116,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -133,7 +133,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -148,7 +148,7 @@ int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -169,7 +169,7 @@ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -190,7 +190,7 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -211,7 +211,7 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -232,7 +232,7 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -253,7 +253,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -274,7 +274,7 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -291,7 +291,7 @@ int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -306,7 +306,7 @@ int pthread_spin_lock(pthread_spinlock_t *spin) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -327,7 +327,7 @@ int pthread_spin_trylock(pthread_spinlock_t *spin) { - int ret; + int ret; struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); @@ -348,7 +348,7 @@ int pthread_spin_unlock(pthread_spinlock_t *spin) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -365,7 +365,7 @@ int pthread_spin_destroy(pthread_spinlock_t *spin) { - int ret; + int ret; _pthread_mutex_lock(&witness_mtx); @@ -398,7 +398,7 @@ { struct lock_info *first; struct lock_info *second; - struct blessing *first_bless; + struct blessing *first_bless = NULL; struct blessing *second_bless = NULL; int ret = 0; @@ -408,15 +408,23 @@ second = lookup_lock(second_addr); first_bless = malloc(sizeof(struct blessing)); - if (first_bless != NULL) { - second_bless = malloc(sizeof(struct blessing)); - if (second_bless == NULL) { - free(first_bless); - } - } + second_bless = malloc(sizeof(struct blessing)); - if (second_bless == NULL) { + if (first == NULL || second == NULL || first_bless == NULL || + second_bless == NULL) { ret = ENOMEM; + + if (first != NULL) { + free(first); + } + + if (second != NULL) { + free(second); + } + + if (first_bless != NULL) { + free(first_bless); + } } else { first_bless->lock = second; SLIST_INSERT_HEAD(&first->bless_head, first_bless, bless_next); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 24 01:36:51 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 EAFD3106564A for ; Tue, 24 Jul 2012 01:36:48 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 24 Jul 2012 01:36:48 +0000 Date: Tue, 24 Jul 2012 01:36:48 +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: <20120724013648.EAFD3106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239721 - in soc2012/jhagewood/diff: . 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: Tue, 24 Jul 2012 01:36:51 -0000 Author: jhagewood Date: Tue Jul 24 01:36:48 2012 New Revision: 239721 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239721 Log: Begun zdiff intergration in diff. Modified: soc2012/jhagewood/diff/TODO soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/diff/diff.h soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/diff/pathnames.h soc2012/jhagewood/diff/hagewood-diff.patch Modified: soc2012/jhagewood/diff/TODO ============================================================================== --- soc2012/jhagewood/diff/TODO Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/TODO Tue Jul 24 01:36:48 2012 (r239721) @@ -20,6 +20,8 @@ --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 + Notes: Modified: soc2012/jhagewood/diff/diff/diff.c ============================================================================== --- soc2012/jhagewood/diff/diff/diff.c Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diff.c Tue Jul 24 01:36:48 2012 (r239721) @@ -46,6 +46,7 @@ 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; @@ -204,10 +205,22 @@ main(int argc, char **argv) { char *ep, **oargv, *optfile; + const char *pn; long l; int ch, lastch, gotstdin, prevoptind, newarg; int oargc; + /* Check what is the program name of the binary. In this + way we can have all the funcionalities in one binary + without the need of scripting and using ugly hacks. */ + pn = getprogname(); + if (pn[0] == 'z') { + filebehave = FILE_GZIP; + pn += 1; + } else { + filebehave = FILE_NORMAL; + } + oargv = argv; oargc = argc; gotstdin = 0; Modified: soc2012/jhagewood/diff/diff/diff.h ============================================================================== --- soc2012/jhagewood/diff/diff/diff.h Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diff.h Tue Jul 24 01:36:48 2012 (r239721) @@ -72,6 +72,12 @@ #define D_SKIPPED1 8 /* path1 was a special file */ #define D_SKIPPED2 9 /* path2 was a special file */ +/* + * File input types + */ +#define FILE_NORMAL 0 +#define FILE_GZIP 1 + struct excludes { char *pattern; struct excludes *next; @@ -81,6 +87,7 @@ sflag, tflag, Tflag, Toflag, wflag; extern int Bflag, strip_cr, suppress_cl, tabsize; extern int format, context, status; +extern int filebehave; extern char ignore_file_case; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; extern struct stat stb1, stb2; Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diffreg.c Tue Jul 24 01:36:48 2012 (r239721) @@ -84,6 +84,11 @@ #include #include #include +#include + +#ifndef WITHOUT_BZIP2 +#include +#endif #include "diff.h" #include "pathnames.h" @@ -330,8 +335,12 @@ } } else if (strcmp(file1, "-") == 0) f1 = stdin; - else - f1 = fopen(file1, "r"); + else { + if (filebehave == FILE_NORMAL) + f1 = fopen(file1, "r"); + if (filebehave == FILE_GZIP) + f1 = gzopen(file1, "r"); + } } if (f1 == NULL) { warn("%s", file1); @@ -351,8 +360,12 @@ } } else if (strcmp(file2, "-") == 0) f2 = stdin; - else - f2 = fopen(file2, "r"); + else { + if (filebehave == FILE_NORMAL) + f2 = fopen(file2, "r"); + if (filebehave == FILE_GZIP) + f2 = gzopen(file2, "r"); + } } if (f2 == NULL) { warn("%s", file2); @@ -1351,7 +1364,7 @@ static int istextfile(FILE *f) { - int i, check_size; + int i; char ch; if (aflag || f == NULL) Modified: soc2012/jhagewood/diff/diff/pathnames.h ============================================================================== --- soc2012/jhagewood/diff/diff/pathnames.h Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/pathnames.h Tue Jul 24 01:36:48 2012 (r239721) @@ -23,5 +23,4 @@ #include #define _PATH_PR "/usr/bin/pr" -#define _PATH_DIFF "/usr/bin/diff" #define _PATH_SDIFF "/usr/bin/sdiff" Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/hagewood-diff.patch Tue Jul 24 01:36:48 2012 (r239721) @@ -1,6 +1,6 @@ -diff -rupN jhagewood/diff/diff-orig/diff.c jhagewood/diff/diff/diff.c ---- jhagewood/diff/diff-orig/diff.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diff.c 2012-07-16 05:03:03.000000000 -0400 +diff -rupN diff-orig/diff.c diff/diff.c +--- diff-orig/diff.c 2012-07-23 02:07:00.000000000 -0400 ++++ diff/diff.c 2012-07-23 21:17:49.000000000 -0400 @@ -1,4 +1,4 @@ -/*- +/* @@ -27,7 +27,7 @@ #include #include -@@ -45,20 +43,20 @@ __FBSDID("$FreeBSD$"); +@@ -45,20 +43,21 @@ __FBSDID("$FreeBSD$"); #include "diff.h" #include "pathnames.h" @@ -41,6 +41,7 @@ +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; @@ -56,7 +57,7 @@ /* Options which exceed manageable alphanumeric assignments */ -@@ -69,107 +67,151 @@ enum +@@ -69,107 +68,163 @@ enum OPT_STRIPCR, OPT_NORMAL, OPT_LEFTC, @@ -261,10 +262,22 @@ - int oargc; - + char *ep, **oargv, *optfile; ++ const char *pn; + long l; + int ch, lastch, gotstdin, prevoptind, newarg; + int oargc; + ++ /* Check what is the program name of the binary. In this ++ way we can have all the funcionalities in one binary ++ without the need of scripting and using ugly hacks. */ ++ pn = getprogname(); ++ if (pn[0] == 'z') { ++ filebehave = FILE_GZIP; ++ pn += 1; ++ } else { ++ filebehave = FILE_NORMAL; ++ } ++ oargv = argv; oargc = argc; gotstdin = 0; @@ -272,7 +285,7 @@ lastch = '\0'; prevoptind = 1; -@@ -197,6 +239,7 @@ main(int argc, char **argv) +@@ -197,6 +252,7 @@ main(int argc, char **argv) break; case 'C': case 'c': @@ -280,7 +293,7 @@ format = D_CONTEXT; if (optarg != NULL) { l = strtol(optarg, &ep, 10); -@@ -213,6 +256,9 @@ main(int argc, char **argv) +@@ -213,6 +269,9 @@ main(int argc, char **argv) case 'd': dflag = 1; break; @@ -290,7 +303,7 @@ case 'e': format = D_EDIT; break; -@@ -284,7 +330,7 @@ main(int argc, char **argv) +@@ -284,7 +343,7 @@ main(int argc, char **argv) case 'v': printf("FreeBSD diff 2.8.7\n"); exit(0); @@ -299,7 +312,7 @@ wflag = 1; break; case 'X': -@@ -296,15 +342,48 @@ main(int argc, char **argv) +@@ -296,15 +355,48 @@ main(int argc, char **argv) case 'y': yflag = 1; break; @@ -356,7 +369,7 @@ case OPT_STRIPCR: strip_cr=1; break; -@@ -315,11 +394,10 @@ main(int argc, char **argv) +@@ -315,11 +407,10 @@ main(int argc, char **argv) ignore_file_case = 0; break; case OPT_HELP: @@ -370,7 +383,7 @@ break; default: usage(); -@@ -328,22 +406,22 @@ main(int argc, char **argv) +@@ -328,22 +419,22 @@ main(int argc, char **argv) lastch = ch; newarg = optind != prevoptind; prevoptind = optind; @@ -399,7 +412,7 @@ } /* -@@ -380,7 +458,10 @@ main(int argc, char **argv) +@@ -380,7 +471,10 @@ main(int argc, char **argv) set_argstr(oargv, argv); if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) { if (format == D_IFDEF) @@ -411,7 +424,7 @@ diffdir(argv[0], argv[1]); } else { if (S_ISDIR(stb1.st_mode)) { -@@ -393,8 +474,26 @@ main(int argc, char **argv) +@@ -393,8 +487,26 @@ main(int argc, char **argv) if (stat(argv[1], &stb2) < 0) err(2, "%s", argv[1]); } @@ -440,7 +453,7 @@ } exit(status); } -@@ -402,11 +501,10 @@ main(int argc, char **argv) +@@ -402,11 +514,10 @@ main(int argc, char **argv) void * emalloc(size_t n) { @@ -453,7 +466,7 @@ if ((p = malloc(n)) == NULL) errx(2, NULL); return (p); -@@ -415,7 +513,7 @@ emalloc(size_t n) +@@ -415,7 +526,7 @@ emalloc(size_t n) void * erealloc(void *p, size_t n) { @@ -462,7 +475,7 @@ if (n == 0) errx(2, NULL); -@@ -431,13 +529,12 @@ erealloc(void *p, size_t n) +@@ -431,13 +542,12 @@ erealloc(void *p, size_t n) int easprintf(char **ret, const char *fmt, ...) { @@ -478,7 +491,7 @@ if (len < 0 || *ret == NULL) errx(2, NULL); return (len); -@@ -446,20 +543,21 @@ easprintf(char **ret, const char *fmt, . +@@ -446,20 +556,21 @@ easprintf(char **ret, const char *fmt, . char * estrdup(const char *str) { @@ -505,7 +518,7 @@ argsize = 4 + *ave - *av + 1; diffargs = emalloc(argsize); -@@ -475,12 +573,12 @@ set_argstr(char **av, char **ave) +@@ -475,12 +586,12 @@ set_argstr(char **av, char **ave) /* * Read in an excludes file and push each line. */ @@ -522,7 +535,7 @@ if (strcmp(file, "-") == 0) fp = stdin; -@@ -501,7 +599,7 @@ read_excludes_file(char *file) +@@ -501,7 +612,7 @@ read_excludes_file(char *file) /* * Push a pattern onto the excludes list. */ @@ -531,7 +544,7 @@ push_excludes(char *pattern) { struct excludes *entry; -@@ -512,10 +610,10 @@ push_excludes(char *pattern) +@@ -512,10 +623,10 @@ push_excludes(char *pattern) excludes_list = entry; } @@ -544,7 +557,7 @@ if (ignore_pats == NULL) ignore_pats = estrdup(pattern); -@@ -531,6 +629,7 @@ push_ignore_pats(char *pattern) +@@ -531,6 +642,7 @@ push_ignore_pats(char *pattern) void print_only(const char *path, size_t dirlen, const char *entry) { @@ -552,7 +565,7 @@ if (dirlen > 1) dirlen--; printf("Only in %.*s: %s\n", (int)dirlen, path, entry); -@@ -539,52 +638,54 @@ print_only(const char *path, size_t dirl +@@ -539,52 +651,54 @@ print_only(const char *path, size_t dirl void print_status(int val, char *path1, char *path2, char *entry) { @@ -619,16 +632,16 @@ (void)fprintf(stderr, "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n" " [-L label] file1 file2\n" -@@ -595,5 +696,5 @@ usage(void) +@@ -595,5 +709,5 @@ usage(void) " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n" " diff [-v]\n"); - exit(2); + exit(1); } -diff -rupN jhagewood/diff/diff-orig/diff.h jhagewood/diff/diff/diff.h ---- jhagewood/diff/diff-orig/diff.h 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diff.h 2012-07-14 03:47:29.000000000 -0400 +diff -rupN diff-orig/diff.h diff/diff.h +--- diff-orig/diff.h 2012-07-23 02:07:00.000000000 -0400 ++++ diff/diff.h 2012-07-23 21:13:42.000000000 -0400 @@ -48,6 +48,8 @@ #define D_NREVERSE 5 /* Reverse ed script with numbered lines and no trailing . */ @@ -638,7 +651,18 @@ /* * Output flags -@@ -75,9 +77,9 @@ struct excludes { +@@ -70,15 +72,22 @@ + #define D_SKIPPED1 8 /* path1 was a special file */ + #define D_SKIPPED2 9 /* path2 was a special file */ + ++/* ++ * File input types ++ */ ++#define FILE_NORMAL 0 ++#define FILE_GZIP 1 ++ + struct excludes { + char *pattern; struct excludes *next; }; @@ -649,11 +673,13 @@ + sflag, tflag, Tflag, Toflag, wflag; +extern int Bflag, strip_cr, suppress_cl, tabsize; extern int format, context, status; ++extern int filebehave; extern char ignore_file_case; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; -diff -rupN jhagewood/diff/diff-orig/diffdir.c jhagewood/diff/diff/diffdir.c ---- jhagewood/diff/diff-orig/diffdir.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diffdir.c 2012-07-16 05:03:32.000000000 -0400 + extern struct stat stb1, stb2; +diff -rupN diff-orig/diffdir.c diff/diffdir.c +--- diff-orig/diffdir.c 2012-07-23 02:07:00.000000000 -0400 ++++ diff/diffdir.c 2012-07-23 02:07:00.000000000 -0400 @@ -20,13 +20,13 @@ #include @@ -760,9 +786,9 @@ strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); if (stat(path1, &stb1) != 0) { -diff -rupN jhagewood/diff/diff-orig/diffreg.c jhagewood/diff/diff/diffreg.c ---- jhagewood/diff/diff-orig/diffreg.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diffreg.c 2012-07-16 05:51:05.000000000 -0400 +diff -rupN diff-orig/diffreg.c diff/diffreg.c +--- diff-orig/diffreg.c 2012-07-23 02:07:00.000000000 -0400 ++++ diff/diffreg.c 2012-07-23 21:32:34.000000000 -0400 @@ -62,15 +62,13 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ @@ -783,7 +809,16 @@ #include #include -@@ -90,6 +88,14 @@ __FBSDID("$FreeBSD"); +@@ -86,10 +84,23 @@ __FBSDID("$FreeBSD"); + #include + #include + #include ++#include ++ ++#ifndef WITHOUT_BZIP2 ++#include ++#endif + #include "diff.h" #include "pathnames.h" @@ -798,7 +833,7 @@ /* * diff - compare two files. */ -@@ -181,47 +187,47 @@ struct context_vec { +@@ -181,47 +192,47 @@ struct context_vec { }; static FILE *opentemp(const char *); @@ -881,7 +916,7 @@ static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ static u_char *chrtran; /* translation table for case-folding */ static struct context_vec *context_vec_start; -@@ -294,13 +300,13 @@ u_char cup2low[256] = { +@@ -294,13 +305,13 @@ u_char cup2low[256] = { int diffreg(char *ofile1, char *ofile2, int flags) { @@ -902,7 +937,7 @@ anychange = 0; lastline = 0; -@@ -310,7 +316,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -310,7 +321,7 @@ diffreg(char *ofile1, char *ofile2, int if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0) @@ -911,7 +946,7 @@ if (flags & D_EMPTY1) f1 = fopen(_PATH_DEVNULL, "r"); -@@ -320,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -320,17 +331,21 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f1), &stb1) < 0) { warn("%s", file1); status |= 2; @@ -920,7 +955,15 @@ } } else if (strcmp(file1, "-") == 0) f1 = stdin; -@@ -330,7 +336,7 @@ diffreg(char *ofile1, char *ofile2, int +- else +- f1 = fopen(file1, "r"); ++ else { ++ if (filebehave == FILE_NORMAL) ++ f1 = fopen(file1, "r"); ++ if (filebehave == FILE_GZIP) ++ f1 = gzopen(file1, "r"); ++ } + } if (f1 == NULL) { warn("%s", file1); status |= 2; @@ -929,7 +972,7 @@ } if (flags & D_EMPTY2) -@@ -341,7 +347,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -341,34 +356,37 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f2), &stb2) < 0) { warn("%s", file2); status |= 2; @@ -938,7 +981,15 @@ } } else if (strcmp(file2, "-") == 0) f2 = stdin; -@@ -351,24 +357,23 @@ diffreg(char *ofile1, char *ofile2, int +- else +- f2 = fopen(file2, "r"); ++ else { ++ if (filebehave == FILE_NORMAL) ++ f2 = fopen(file2, "r"); ++ if (filebehave == FILE_GZIP) ++ f2 = gzopen(file2, "r"); ++ } + } if (f2 == NULL) { warn("%s", file2); status |= 2; @@ -968,7 +1019,7 @@ } if (lflag) { /* redirect stdout to pr */ -@@ -452,7 +457,11 @@ diffreg(char *ofile1, char *ofile2, int +@@ -452,7 +470,11 @@ diffreg(char *ofile1, char *ofile2, int } waitpid(pid, &wstatus, 0); } @@ -981,7 +1032,7 @@ if (anychange) { status |= 1; if (rval == D_SAME) -@@ -477,8 +486,8 @@ closem: +@@ -477,8 +499,8 @@ closem: static int files_differ(FILE *f1, FILE *f2, int flags) { @@ -992,7 +1043,7 @@ if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) -@@ -503,9 +512,9 @@ files_differ(FILE *f1, FILE *f2, int fla +@@ -503,9 +525,9 @@ files_differ(FILE *f1, FILE *f2, int fla static FILE * opentemp(const char *file) { @@ -1005,7 +1056,7 @@ if (strcmp(file, "-") == 0) ifd = STDIN_FILENO; -@@ -541,7 +550,7 @@ opentemp(const char *file) +@@ -541,7 +563,7 @@ opentemp(const char *file) char * splice(char *dir, char *file) { @@ -1014,7 +1065,7 @@ if ((tail = strrchr(file, '/')) == NULL) tail = file; -@@ -555,8 +564,8 @@ static void +@@ -555,8 +577,8 @@ static void prepare(int i, FILE *fd, off_t filesize) { struct line *p; @@ -1025,7 +1076,7 @@ rewind(fd); -@@ -579,7 +588,7 @@ prepare(int i, FILE *fd, off_t filesize) +@@ -579,7 +601,7 @@ prepare(int i, FILE *fd, off_t filesize) static void prune(void) { @@ -1034,7 +1085,7 @@ for (pref = 0; pref < len[0] && pref < len[1] && file[0][pref + 1].value == file[1][pref + 1].value; -@@ -600,7 +609,7 @@ prune(void) +@@ -600,7 +622,7 @@ prune(void) static void equiv(struct line *a, int n, struct line *b, int m, int *c) { @@ -1043,7 +1094,7 @@ i = j = 1; while (i <= n && j <= m) { -@@ -629,7 +638,7 @@ equiv(struct line *a, int n, struct line +@@ -629,7 +651,7 @@ equiv(struct line *a, int n, struct line static int isqrt(int n) { @@ -1052,7 +1103,7 @@ if (n == 0) return (0); -@@ -647,9 +656,9 @@ isqrt(int n) +@@ -647,9 +669,9 @@ isqrt(int n) static int stone(int *a, int n, int *b, int *c) { @@ -1065,7 +1116,7 @@ const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n)); k = 0; -@@ -705,7 +714,7 @@ newcand(int x, int y, int pred) +@@ -705,7 +727,7 @@ newcand(int x, int y, int pred) static int search(int *c, int k, int y) { @@ -1074,7 +1125,7 @@ if (clist[c[k]].y < y) /* quick look for typical case */ return (k + 1); -@@ -730,7 +739,7 @@ static void +@@ -730,7 +752,7 @@ static void unravel(int p) { struct cand *q; @@ -1083,7 +1134,7 @@ for (i = 0; i <= len[0]; i++) J[i] = i <= pref ? i : -@@ -748,9 +757,10 @@ unravel(int p) +@@ -748,9 +770,10 @@ unravel(int p) static void check(char *file1, FILE *f1, char *file2, FILE *f2) { @@ -1097,7 +1148,7 @@ rewind(f1); rewind(f2); j = 1; -@@ -766,7 +776,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -766,7 +789,7 @@ check(char *file1, FILE *f1, char *file2 ixnew[j] = ctnew += skipline(f2); j++; } @@ -1106,7 +1157,7 @@ for (;;) { c = getc(f1); d = getc(f2); -@@ -781,6 +791,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -781,6 +804,7 @@ check(char *file1, FILE *f1, char *file2 } ctold++; ctnew++; @@ -1114,7 +1165,7 @@ if (bflag && isspace(c) && isspace(d)) { do { if (c == '\n') -@@ -792,6 +803,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -792,6 +816,7 @@ check(char *file1, FILE *f1, char *file2 break; ctnew++; } while (isspace(d = getc(f2))); @@ -1122,7 +1173,7 @@ } else if (wflag) { while (isspace(c) && c != '\n') { c = getc(f1); -@@ -801,31 +813,55 @@ check(char *file1, FILE *f1, char *file2 +@@ -801,31 +826,55 @@ check(char *file1, FILE *f1, char *file2 d = getc(f2); ctnew++; } @@ -1199,7 +1250,7 @@ if (chrtran[c] != chrtran[d]) { jackpot++; J[i] = 0; -@@ -872,7 +908,7 @@ static void +@@ -872,7 +921,7 @@ static void sort(struct line *a, int n) { struct line *ai, *aim, w; @@ -1208,7 +1259,7 @@ if (n == 0) return; -@@ -916,7 +952,7 @@ unsort(struct line *f, int l, int *b) +@@ -916,7 +965,7 @@ unsort(struct line *f, int l, int *b) static int skipline(FILE *f) { @@ -1217,7 +1268,7 @@ for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++) continue; -@@ -926,7 +962,7 @@ skipline(FILE *f) +@@ -926,7 +975,7 @@ skipline(FILE *f) static void output(char *file1, FILE *f1, char *file2, FILE *f2, int flags) { @@ -1226,7 +1277,7 @@ rewind(f1); rewind(f2); -@@ -965,7 +1001,7 @@ output(char *file1, FILE *f1, char *file +@@ -965,7 +1014,7 @@ output(char *file1, FILE *f1, char *file #define c i0 if ((c = getc(f1)) == EOF) return; @@ -1235,7 +1286,7 @@ } #undef c } -@@ -980,6 +1016,7 @@ output(char *file1, FILE *f1, char *file +@@ -980,6 +1029,7 @@ output(char *file1, FILE *f1, char *file static void range(int a, int b, char *separator) { @@ -1243,7 +1294,7 @@ printf("%d", a > b ? b : a); if (a < b) printf("%s%d", separator, b); -@@ -988,6 +1025,7 @@ range(int a, int b, char *separator) +@@ -988,6 +1038,7 @@ range(int a, int b, char *separator) static void uni_range(int a, int b) { @@ -1251,7 +1302,7 @@ if (a < b) printf("%d,%d", a, b - a + 1); else if (a == b) -@@ -999,22 +1037,22 @@ uni_range(int a, int b) +@@ -999,22 +1050,22 @@ uni_range(int a, int b) static char * preadline(int fd, size_t len, off_t off) { @@ -1278,7 +1329,7 @@ ret = regexec(&ignore_re, line, 0, NULL, 0); free(line); -@@ -1032,10 +1070,10 @@ static void +@@ -1032,10 +1083,10 @@ static void change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d, int *pflags) { @@ -1292,7 +1343,7 @@ if (format != D_IFDEF && a > b && c > d) return; if (ignore_pats != NULL) { -@@ -1050,7 +1088,7 @@ restart: +@@ -1050,7 +1101,7 @@ restart: line = preadline(fileno(f1), ixold[i] - ixold[i - 1], ixold[i - 1]); if (!ignoreline(line)) @@ -1301,7 +1352,7 @@ } } if (a > b || c <= d) { /* Changes and inserts. */ -@@ -1058,12 +1096,12 @@ restart: +@@ -1058,12 +1109,12 @@ restart: line = preadline(fileno(f2), ixnew[i] - ixnew[i - 1], ixnew[i - 1]); if (!ignoreline(line)) @@ -1316,7 +1367,7 @@ if (*pflags & D_HEADER) { printf("%s %s %s\n", diffargs, file1, file2); *pflags &= ~D_HEADER; -@@ -1113,15 +1151,15 @@ proceed: +@@ -1113,15 +1164,15 @@ proceed: case D_NORMAL: case D_EDIT: range(a, b, ","); @@ -1336,7 +1387,7 @@ break; case D_NREVERSE: if (a > b) -@@ -1137,7 +1175,7 @@ proceed: +@@ -1137,7 +1188,7 @@ proceed: if (format == D_NORMAL || format == D_IFDEF) { fetch(ixold, a, b, f1, '<', 1); if (a <= b && c <= d && format == D_NORMAL) @@ -1345,7 +1396,7 @@ } i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0); if (i != 0 && format == D_EDIT) { -@@ -1148,14 +1186,14 @@ proceed: +@@ -1148,14 +1199,14 @@ proceed: * it. We have to add a substitute command to change this * back and restart where we left off. */ @@ -1363,7 +1414,7 @@ if (inifdef) { printf("#endif /* %s */\n", ifdefname); inifdef = 0; -@@ -1165,8 +1203,8 @@ proceed: +@@ -1165,8 +1216,8 @@ proceed: static int fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile) { @@ -1374,7 +1425,7 @@ /* * When doing #ifdef's, copy down to current line -@@ -1177,7 +1215,7 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1177,7 +1228,7 @@ fetch(long *f, int a, int b, FILE *lb, i /* print through if append (a>b), else to (nb: 0 vs 1 orig) */ nc = f[a > b ? b : a - 1] - curpos; for (i = 0; i < nc; i++) @@ -1383,7 +1434,7 @@ } if (a > b) return (0); -@@ -1197,12 +1235,12 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1197,12 +1248,12 @@ fetch(long *f, int a, int b, FILE *lb, i fseek(lb, f[i - 1], SEEK_SET); nc = f[i] - f[i - 1]; if (format != D_IFDEF && ch != '\0') { @@ -1399,7 +1450,7 @@ } col = 0; for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { -@@ -1211,13 +1249,13 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1211,13 +1262,13 @@ fetch(long *f, int a, int b, FILE *lb, i format == D_NREVERSE) warnx("No newline at end of file"); else @@ -1415,7 +1466,7 @@ } while (++col < newcol); } else { if (format == D_EDIT && j == 1 && c == '\n' -@@ -1229,10 +1267,10 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1229,10 +1280,10 @@ fetch(long *f, int a, int b, FILE *lb, i * giving the caller an offset * from which to restart. */ @@ -1428,7 +1479,7 @@ col++; } } -@@ -1246,8 +1284,8 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1246,8 +1297,8 @@ fetch(long *f, int a, int b, FILE *lb, i static int readhash(FILE *f) { @@ -1439,7 +1490,7 @@ sum = 1; space = 0; -@@ -1305,20 +1343,28 @@ readhash(FILE *f) +@@ -1305,20 +1356,28 @@ readhash(FILE *f) return (sum == 0 ? 1 : sum); } @@ -1454,7 +1505,7 @@ { - char buf[BUFSIZ]; - int i, cnt; -+ int i, check_size; ++ int i; + char ch; if (aflag || f == NULL) @@ -1475,7 +1526,7 @@ return (1); } -@@ -1327,10 +1373,10 @@ asciifile(FILE *f) +@@ -1327,10 +1386,10 @@ asciifile(FILE *f) static char * match_function(const long *f, int pos, FILE *file) { @@ -1490,7 +1541,7 @@ lastline = pos; while (pos > last) { -@@ -1342,7 +1388,6 @@ match_function(const long *f, int pos, F +@@ -1342,7 +1401,6 @@ match_function(const long *f, int pos, F if (nc > 0) { buf[nc] = '\0'; buf[strcspn(buf, "\n")] = '\0'; @@ -1498,7 +1549,7 @@ if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) -@@ -1373,9 +1418,9 @@ static void +@@ -1373,9 +1431,9 @@ static void dump_context_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1511,7 +1562,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1390,8 +1435,8 @@ dump_context_vec(FILE *f1, FILE *f2) +@@ -1390,8 +1448,8 @@ dump_context_vec(FILE *f1, FILE *f2) if (pflag) { f = match_function(ixold, lowa-1, f1); if (f != NULL) { @@ -1522,7 +1573,7 @@ } } printf("\n*** "); -@@ -1478,9 +1523,9 @@ static void +@@ -1478,9 +1536,9 @@ static void dump_unified_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1535,7 +1586,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1491,19 +1536,19 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1491,19 +1549,19 @@ dump_unified_vec(FILE *f1, FILE *f2) lowc = MAX(1, cvp->c - context); upd = MIN(len[1], context_vec_ptr->d + context); @@ -1561,7 +1612,7 @@ /* * Output changes in "unified" diff format--the old and new lines -@@ -1551,16 +1596,43 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1551,16 +1609,43 @@ dump_unified_vec(FILE *f1, FILE *f2) static void print_header(const char *file1, const char *file2) { @@ -1611,12 +1662,3 @@ + printf("%s %s\t%s\n", format == D_CONTEXT ? "---" : "+++", + file2, buf2); } -diff -rupN jhagewood/diff/diff-orig/pathnames.h jhagewood/diff/diff/pathnames.h ---- jhagewood/diff/diff-orig/pathnames.h 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/pathnames.h 2012-07-14 03:47:29.000000000 -0400 -@@ -23,4 +23,5 @@ - #include - - #define _PATH_PR "/usr/bin/pr" -+#define _PATH_DIFF "/usr/bin/diff" - #define _PATH_SDIFF "/usr/bin/sdiff" From owner-svn-soc-all@FreeBSD.ORG Tue Jul 24 19:03:49 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 485971065672 for ; Tue, 24 Jul 2012 19:03:47 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 24 Jul 2012 19:03:47 +0000 Date: Tue, 24 Jul 2012 19:03:47 +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: <20120724190347.485971065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239739 - in soc2012/gmiller/locking-head: . 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, 24 Jul 2012 19:03:49 -0000 Author: gmiller Date: Tue Jul 24 19:03:47 2012 New Revision: 239739 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239739 Log: r239770@FreeBSD-dev: root | 2012-07-23 18:50:02 -0500 Produce an optimized lock order graph. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Tue Jul 24 18:53:28 2012 (r239738) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Tue Jul 24 19:03:47 2012 (r239739) @@ -27,6 +27,9 @@ #include "witness.h" +static SLIST_HEAD(graph_root_head, lock_info) graph_roots = + SLIST_HEAD_INITIALIZER(graph_roots); + static int scan_graph(struct lock_info *graph, struct lock_info *lock) { @@ -49,14 +52,44 @@ } static void +optimize_path(struct lock_info *from, struct lock_info *to) +{ + struct lock_info *child; + struct lock_info *previous; + struct lock_info *next; + + previous = NULL; + child = from->child; + while (child != NULL) { + next = child->sibling; + + if (child == to) { + if (previous == NULL) { + from->child = next; + } else { + previous->sibling = next; + } + + if (!scan_graph(from, to)) { + child->sibling = from->child; + from->child = child; + } + } + + child = next; + } +} + +static void optimize_links(struct lock_info *to) { - to = to; - /* - XXX find first node with multiple children, then start scanning for - multiple paths to "to" from any node with multiple children and - a link to "to" - */ + struct lock_info *from; + + SLIST_FOREACH(from, &graph_roots, root_next) { + if (scan_graph(from, to)) { + optimize_path(from, to); + } + } } int @@ -70,6 +103,8 @@ return (-1); } + SLIST_REMOVE(&graph_roots, from, lock_info, root_next); + to->sibling = from->child; from->child = to; @@ -77,3 +112,15 @@ return (0); } + +void +add_root(struct lock_info *root) +{ + SLIST_INSERT_HEAD(&graph_roots, root, root_next); +} + +void +reset_graph(void) +{ + SLIST_INIT(&graph_roots); +} Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 24 18:53:28 2012 (r239738) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 24 19:03:47 2012 (r239739) @@ -39,7 +39,7 @@ struct lock_info * lookup_lock(void *lock) { - struct lock_info *info; + struct lock_info *info = NULL; SLIST_FOREACH(info, &lock_info_head, lock_info_next) { if (info->lock == lock && info->active) { @@ -58,6 +58,7 @@ SLIST_INIT(&info->bless_head); SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); + add_root(info); } } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 24 18:53:28 2012 (r239738) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 24 19:03:47 2012 (r239739) @@ -41,6 +41,7 @@ struct lock_info { SLIST_ENTRY(lock_info) lock_info_next; + SLIST_ENTRY(lock_info) root_next; void *lock; int active; struct lock_info *child; @@ -51,10 +52,13 @@ extern pthread_mutex_t witness_mtx; +void add_root(struct lock_info *root); 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 reset_graph(void); + void reset_lists(void); void log_reversal(struct lock_info *lock, Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 24 18:53:28 2012 (r239738) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 24 19:03:47 2012 (r239739) @@ -445,6 +445,7 @@ _pthread_mutex_lock(&witness_mtx); reset_lists(); + reset_graph(); reset_lock_info(); _pthread_mutex_unlock(&witness_mtx); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 25 16:10: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 BB478106566C for ; Wed, 25 Jul 2012 16:10:20 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 25 Jul 2012 16:10:20 +0000 Date: Wed, 25 Jul 2012 16:10: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: <20120725161020.BB478106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239766 - 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, 25 Jul 2012 16:10:21 -0000 Author: jhagewood Date: Wed Jul 25 16:10:20 2012 New Revision: 239766 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239766 Log: trash Deleted: soc2012/jhagewood/diff/hagewood-fidd.patch From owner-svn-soc-all@FreeBSD.ORG Wed Jul 25 16:12: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 67F81106566B for ; Wed, 25 Jul 2012 16:12:02 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 25 Jul 2012 16:12:02 +0000 Date: Wed, 25 Jul 2012 16:12:02 +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: <20120725161202.67F81106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239767 - in soc2012/jhagewood/diff: . 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, 25 Jul 2012 16:12:04 -0000 Author: jhagewood Date: Wed Jul 25 16:12:02 2012 New Revision: 239767 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239767 Log: Added gz file opening to diff Modified: soc2012/jhagewood/diff/diff/Makefile soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/hagewood-diff.patch Modified: soc2012/jhagewood/diff/diff/Makefile ============================================================================== --- soc2012/jhagewood/diff/diff/Makefile Wed Jul 25 16:10:20 2012 (r239766) +++ soc2012/jhagewood/diff/diff/Makefile Wed Jul 25 16:12:02 2012 (r239767) @@ -3,7 +3,7 @@ DEBUG_FLAGS+= -g -PROG= diff +PROG= diff xdiff SRCS= diff.c diffdir.c diffreg.c CFLAGS+= -std=c99 -Wall -pedantic Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Wed Jul 25 16:10:20 2012 (r239766) +++ soc2012/jhagewood/diff/diff/diffreg.c Wed Jul 25 16:12:02 2012 (r239767) @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -305,10 +306,14 @@ int diffreg(char *ofile1, char *ofile2, int flags) { + char *buf; char *file1 = ofile1; char *file2 = ofile2; FILE *f1 = NULL; FILE *f2 = NULL; + gzFile *gz1 = NULL; + gzFile *gz2 = NULL; + int bytesread; int rval = D_SAME; int i, ostdout = -1; pid_t pid = -1; @@ -338,8 +343,11 @@ else { if (filebehave == FILE_NORMAL) f1 = fopen(file1, "r"); - if (filebehave == FILE_GZIP) - f1 = gzopen(file1, "r"); + if (filebehave == FILE_GZIP) { + gz1 = gzopen(file1, "r"); + gzread(gz1, buf, MAX_INT); + f1 = fdopen(buf, "r"); + } } } if (f1 == NULL) { @@ -364,7 +372,9 @@ if (filebehave == FILE_NORMAL) f2 = fopen(file2, "r"); if (filebehave == FILE_GZIP) - f2 = gzopen(file2, "r"); + gz2 = gzopen(file2, "r"); + gzread(gz2, buf, MAX_INT); + f2 = fdopen(buf, "r"); } } if (f2 == NULL) { Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Wed Jul 25 16:10:20 2012 (r239766) +++ soc2012/jhagewood/diff/hagewood-diff.patch Wed Jul 25 16:12:02 2012 (r239767) @@ -1,6 +1,6 @@ diff -rupN diff-orig/diff.c diff/diff.c ---- diff-orig/diff.c 2012-07-23 02:07:00.000000000 -0400 -+++ diff/diff.c 2012-07-23 21:17:49.000000000 -0400 +--- diff-orig/diff.c 2012-07-25 11:37:23.299991134 -0400 ++++ diff/diff.c 2012-07-25 11:37:23.727991128 -0400 @@ -1,4 +1,4 @@ -/*- +/* @@ -57,7 +57,7 @@ /* Options which exceed manageable alphanumeric assignments */ -@@ -69,107 +68,163 @@ enum +@@ -69,107 +68,163 @@ enum OPT_STRIPCR, OPT_NORMAL, OPT_LEFTC, @@ -639,47 +639,9 @@ - exit(2); + exit(1); } -diff -rupN diff-orig/diff.h diff/diff.h ---- diff-orig/diff.h 2012-07-23 02:07:00.000000000 -0400 -+++ diff/diff.h 2012-07-23 21:13:42.000000000 -0400 -@@ -48,6 +48,8 @@ - #define D_NREVERSE 5 /* Reverse ed script with numbered - lines and no trailing . */ - #define D_BRIEF 6 /* Say if the files differ */ -+#define D_GF 7 /* Group format */ -+#define D_LF 8 /* Line format */ - - /* - * Output flags -@@ -70,15 +72,22 @@ - #define D_SKIPPED1 8 /* path1 was a special file */ - #define D_SKIPPED2 9 /* path2 was a special file */ - -+/* -+ * File input types -+ */ -+#define FILE_NORMAL 0 -+#define FILE_GZIP 1 -+ - struct excludes { - char *pattern; - struct excludes *next; - }; - --extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag, -- sflag, tflag, Tflag, wflag; --extern int Bflag, strip_cr, tabsize; -+extern int aflag, bflag, cflag, dflag, Eflag, Fromflag, iflag, lflag, Nflag, Pflag, pflag, rflag, -+ sflag, tflag, Tflag, Toflag, wflag; -+extern int Bflag, strip_cr, suppress_cl, tabsize; - extern int format, context, status; -+extern int filebehave; - extern char ignore_file_case; - extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; - extern struct stat stb1, stb2; diff -rupN diff-orig/diffdir.c diff/diffdir.c ---- diff-orig/diffdir.c 2012-07-23 02:07:00.000000000 -0400 -+++ diff/diffdir.c 2012-07-23 02:07:00.000000000 -0400 +--- diff-orig/diffdir.c 2012-07-25 11:37:23.299991134 -0400 ++++ diff/diffdir.c 2012-07-25 11:37:23.726991126 -0400 @@ -20,13 +20,13 @@ #include @@ -786,9 +748,47 @@ strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); if (stat(path1, &stb1) != 0) { +diff -rupN diff-orig/diff.h diff/diff.h +--- diff-orig/diff.h 2012-07-25 11:37:23.300991134 -0400 ++++ diff/diff.h 2012-07-25 11:37:23.728991128 -0400 +@@ -48,6 +48,8 @@ + #define D_NREVERSE 5 /* Reverse ed script with numbered + lines and no trailing . */ + #define D_BRIEF 6 /* Say if the files differ */ ++#define D_GF 7 /* Group format */ ++#define D_LF 8 /* Line format */ + + /* + * Output flags +@@ -70,15 +72,22 @@ + #define D_SKIPPED1 8 /* path1 was a special file */ + #define D_SKIPPED2 9 /* path2 was a special file */ + ++/* ++ * File input types ++ */ ++#define FILE_NORMAL 0 ++#define FILE_GZIP 1 ++ + struct excludes { + char *pattern; + struct excludes *next; + }; + +-extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag, +- sflag, tflag, Tflag, wflag; +-extern int Bflag, strip_cr, tabsize; ++extern int aflag, bflag, cflag, dflag, Eflag, Fromflag, iflag, lflag, Nflag, Pflag, pflag, rflag, ++ sflag, tflag, Tflag, Toflag, wflag; ++extern int Bflag, strip_cr, suppress_cl, tabsize; + extern int format, context, status; ++extern int filebehave; + extern char ignore_file_case; + extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; + extern struct stat stb1, stb2; diff -rupN diff-orig/diffreg.c diff/diffreg.c ---- diff-orig/diffreg.c 2012-07-23 02:07:00.000000000 -0400 -+++ diff/diffreg.c 2012-07-23 21:32:34.000000000 -0400 +--- diff-orig/diffreg.c 2012-07-25 11:37:23.298991134 -0400 ++++ diff/diffreg.c 2012-07-25 12:07:51.966957049 -0400 @@ -62,15 +62,13 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ @@ -809,7 +809,14 @@ #include #include -@@ -86,10 +84,23 @@ __FBSDID("$FreeBSD"); +@@ -80,16 +78,30 @@ __FBSDID("$FreeBSD"); + #include + #include + #include ++#include + #include + #include + #include #include #include #include @@ -833,7 +840,7 @@ /* * diff - compare two files. */ -@@ -181,47 +192,47 @@ struct context_vec { +@@ -181,47 +193,47 @@ struct context_vec { }; static FILE *opentemp(const char *); @@ -916,7 +923,7 @@ static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ static u_char *chrtran; /* translation table for case-folding */ static struct context_vec *context_vec_start; -@@ -294,13 +305,13 @@ u_char cup2low[256] = { +@@ -294,13 +306,17 @@ u_char cup2low[256] = { int diffreg(char *ofile1, char *ofile2, int flags) { @@ -927,17 +934,21 @@ - int rval = D_SAME; - int i, ostdout = -1; - pid_t pid = -1; ++ char *buf; + char *file1 = ofile1; + char *file2 = ofile2; + FILE *f1 = NULL; + FILE *f2 = NULL; ++ gzFile *gz1 = NULL; ++ gzFile *gz2 = NULL; ++ int bytesread; + int rval = D_SAME; + int i, ostdout = -1; + pid_t pid = -1; anychange = 0; lastline = 0; -@@ -310,7 +321,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -310,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0) @@ -946,7 +957,7 @@ if (flags & D_EMPTY1) f1 = fopen(_PATH_DEVNULL, "r"); -@@ -320,17 +331,21 @@ diffreg(char *ofile1, char *ofile2, int +@@ -320,17 +336,24 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f1), &stb1) < 0) { warn("%s", file1); status |= 2; @@ -960,8 +971,11 @@ + else { + if (filebehave == FILE_NORMAL) + f1 = fopen(file1, "r"); -+ if (filebehave == FILE_GZIP) -+ f1 = gzopen(file1, "r"); ++ if (filebehave == FILE_GZIP) { ++ gz1 = gzopen(file1, "r"); ++ gzread(gz1, buf, MAX_INT); ++ f1 = fdopen(buf, "r"); ++ } + } } if (f1 == NULL) { @@ -972,7 +986,7 @@ } if (flags & D_EMPTY2) -@@ -341,34 +356,37 @@ diffreg(char *ofile1, char *ofile2, int +@@ -341,34 +364,39 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f2), &stb2) < 0) { warn("%s", file2); status |= 2; @@ -987,7 +1001,9 @@ + if (filebehave == FILE_NORMAL) + f2 = fopen(file2, "r"); + if (filebehave == FILE_GZIP) -+ f2 = gzopen(file2, "r"); ++ gz2 = gzopen(file2, "r"); ++ gzread(gz2, buf, MAX_INT); ++ f2 = fdopen(buf, "r"); + } } if (f2 == NULL) { @@ -1019,7 +1035,7 @@ } if (lflag) { /* redirect stdout to pr */ -@@ -452,7 +470,11 @@ diffreg(char *ofile1, char *ofile2, int +@@ -452,7 +480,11 @@ diffreg(char *ofile1, char *ofile2, int } waitpid(pid, &wstatus, 0); } @@ -1032,7 +1048,7 @@ if (anychange) { status |= 1; if (rval == D_SAME) -@@ -477,8 +499,8 @@ closem: +@@ -477,8 +509,8 @@ closem: static int files_differ(FILE *f1, FILE *f2, int flags) { @@ -1043,7 +1059,7 @@ if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) -@@ -503,9 +525,9 @@ files_differ(FILE *f1, FILE *f2, int fla +@@ -503,9 +535,9 @@ files_differ(FILE *f1, FILE *f2, int fla static FILE * opentemp(const char *file) { @@ -1056,7 +1072,7 @@ if (strcmp(file, "-") == 0) ifd = STDIN_FILENO; -@@ -541,7 +563,7 @@ opentemp(const char *file) +@@ -541,7 +573,7 @@ opentemp(const char *file) char * splice(char *dir, char *file) { @@ -1065,7 +1081,7 @@ if ((tail = strrchr(file, '/')) == NULL) tail = file; -@@ -555,8 +577,8 @@ static void +@@ -555,8 +587,8 @@ static void prepare(int i, FILE *fd, off_t filesize) { struct line *p; @@ -1076,7 +1092,7 @@ rewind(fd); -@@ -579,7 +601,7 @@ prepare(int i, FILE *fd, off_t filesize) +@@ -579,7 +611,7 @@ prepare(int i, FILE *fd, off_t filesize) static void prune(void) { @@ -1085,7 +1101,7 @@ for (pref = 0; pref < len[0] && pref < len[1] && file[0][pref + 1].value == file[1][pref + 1].value; -@@ -600,7 +622,7 @@ prune(void) +@@ -600,7 +632,7 @@ prune(void) static void equiv(struct line *a, int n, struct line *b, int m, int *c) { @@ -1094,7 +1110,7 @@ i = j = 1; while (i <= n && j <= m) { -@@ -629,7 +651,7 @@ equiv(struct line *a, int n, struct line +@@ -629,7 +661,7 @@ equiv(struct line *a, int n, struct line static int isqrt(int n) { @@ -1103,7 +1119,7 @@ if (n == 0) return (0); -@@ -647,9 +669,9 @@ isqrt(int n) +@@ -647,9 +679,9 @@ isqrt(int n) static int stone(int *a, int n, int *b, int *c) { @@ -1116,7 +1132,7 @@ const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n)); k = 0; -@@ -705,7 +727,7 @@ newcand(int x, int y, int pred) +@@ -705,7 +737,7 @@ newcand(int x, int y, int pred) static int search(int *c, int k, int y) { @@ -1125,7 +1141,7 @@ if (clist[c[k]].y < y) /* quick look for typical case */ return (k + 1); -@@ -730,7 +752,7 @@ static void +@@ -730,7 +762,7 @@ static void unravel(int p) { struct cand *q; @@ -1134,7 +1150,7 @@ for (i = 0; i <= len[0]; i++) J[i] = i <= pref ? i : -@@ -748,9 +770,10 @@ unravel(int p) +@@ -748,9 +780,10 @@ unravel(int p) static void check(char *file1, FILE *f1, char *file2, FILE *f2) { @@ -1148,7 +1164,7 @@ rewind(f1); rewind(f2); j = 1; -@@ -766,7 +789,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -766,7 +799,7 @@ check(char *file1, FILE *f1, char *file2 ixnew[j] = ctnew += skipline(f2); j++; } @@ -1157,7 +1173,7 @@ for (;;) { c = getc(f1); d = getc(f2); -@@ -781,6 +804,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -781,6 +814,7 @@ check(char *file1, FILE *f1, char *file2 } ctold++; ctnew++; @@ -1165,7 +1181,7 @@ if (bflag && isspace(c) && isspace(d)) { do { if (c == '\n') -@@ -792,6 +816,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -792,6 +826,7 @@ check(char *file1, FILE *f1, char *file2 break; ctnew++; } while (isspace(d = getc(f2))); @@ -1173,7 +1189,7 @@ } else if (wflag) { while (isspace(c) && c != '\n') { c = getc(f1); -@@ -801,31 +826,55 @@ check(char *file1, FILE *f1, char *file2 +@@ -801,31 +836,55 @@ check(char *file1, FILE *f1, char *file2 d = getc(f2); ctnew++; } @@ -1250,7 +1266,7 @@ if (chrtran[c] != chrtran[d]) { jackpot++; J[i] = 0; -@@ -872,7 +921,7 @@ static void +@@ -872,7 +931,7 @@ static void sort(struct line *a, int n) { struct line *ai, *aim, w; @@ -1259,7 +1275,7 @@ if (n == 0) return; -@@ -916,7 +965,7 @@ unsort(struct line *f, int l, int *b) +@@ -916,7 +975,7 @@ unsort(struct line *f, int l, int *b) static int skipline(FILE *f) { @@ -1268,7 +1284,7 @@ for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++) continue; -@@ -926,7 +975,7 @@ skipline(FILE *f) +@@ -926,7 +985,7 @@ skipline(FILE *f) static void output(char *file1, FILE *f1, char *file2, FILE *f2, int flags) { @@ -1277,7 +1293,7 @@ rewind(f1); rewind(f2); -@@ -965,7 +1014,7 @@ output(char *file1, FILE *f1, char *file +@@ -965,7 +1024,7 @@ output(char *file1, FILE *f1, char *file #define c i0 if ((c = getc(f1)) == EOF) return; @@ -1286,7 +1302,7 @@ } #undef c } -@@ -980,6 +1029,7 @@ output(char *file1, FILE *f1, char *file +@@ -980,6 +1039,7 @@ output(char *file1, FILE *f1, char *file static void range(int a, int b, char *separator) { @@ -1294,7 +1310,7 @@ printf("%d", a > b ? b : a); if (a < b) printf("%s%d", separator, b); -@@ -988,6 +1038,7 @@ range(int a, int b, char *separator) +@@ -988,6 +1048,7 @@ range(int a, int b, char *separator) static void uni_range(int a, int b) { @@ -1302,7 +1318,7 @@ if (a < b) printf("%d,%d", a, b - a + 1); else if (a == b) -@@ -999,22 +1050,22 @@ uni_range(int a, int b) +@@ -999,22 +1060,22 @@ uni_range(int a, int b) static char * preadline(int fd, size_t len, off_t off) { @@ -1329,7 +1345,7 @@ ret = regexec(&ignore_re, line, 0, NULL, 0); free(line); -@@ -1032,10 +1083,10 @@ static void +@@ -1032,10 +1093,10 @@ static void change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d, int *pflags) { @@ -1343,7 +1359,7 @@ if (format != D_IFDEF && a > b && c > d) return; if (ignore_pats != NULL) { -@@ -1050,7 +1101,7 @@ restart: +@@ -1050,7 +1111,7 @@ restart: line = preadline(fileno(f1), ixold[i] - ixold[i - 1], ixold[i - 1]); if (!ignoreline(line)) @@ -1352,7 +1368,7 @@ } } if (a > b || c <= d) { /* Changes and inserts. */ -@@ -1058,12 +1109,12 @@ restart: +@@ -1058,12 +1119,12 @@ restart: line = preadline(fileno(f2), ixnew[i] - ixnew[i - 1], ixnew[i - 1]); if (!ignoreline(line)) @@ -1367,7 +1383,7 @@ if (*pflags & D_HEADER) { printf("%s %s %s\n", diffargs, file1, file2); *pflags &= ~D_HEADER; -@@ -1113,15 +1164,15 @@ proceed: +@@ -1113,15 +1174,15 @@ proceed: case D_NORMAL: case D_EDIT: range(a, b, ","); @@ -1387,7 +1403,7 @@ break; case D_NREVERSE: if (a > b) -@@ -1137,7 +1188,7 @@ proceed: +@@ -1137,7 +1198,7 @@ proceed: if (format == D_NORMAL || format == D_IFDEF) { fetch(ixold, a, b, f1, '<', 1); if (a <= b && c <= d && format == D_NORMAL) @@ -1396,7 +1412,7 @@ } i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0); if (i != 0 && format == D_EDIT) { -@@ -1148,14 +1199,14 @@ proceed: +@@ -1148,14 +1209,14 @@ proceed: * it. We have to add a substitute command to change this * back and restart where we left off. */ @@ -1414,7 +1430,7 @@ if (inifdef) { printf("#endif /* %s */\n", ifdefname); inifdef = 0; -@@ -1165,8 +1216,8 @@ proceed: +@@ -1165,8 +1226,8 @@ proceed: static int fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile) { @@ -1425,7 +1441,7 @@ /* * When doing #ifdef's, copy down to current line -@@ -1177,7 +1228,7 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1177,7 +1238,7 @@ fetch(long *f, int a, int b, FILE *lb, i /* print through if append (a>b), else to (nb: 0 vs 1 orig) */ nc = f[a > b ? b : a - 1] - curpos; for (i = 0; i < nc; i++) @@ -1434,7 +1450,7 @@ } if (a > b) return (0); -@@ -1197,12 +1248,12 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1197,12 +1258,12 @@ fetch(long *f, int a, int b, FILE *lb, i fseek(lb, f[i - 1], SEEK_SET); nc = f[i] - f[i - 1]; if (format != D_IFDEF && ch != '\0') { @@ -1450,7 +1466,7 @@ } col = 0; for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { -@@ -1211,13 +1262,13 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1211,13 +1272,13 @@ fetch(long *f, int a, int b, FILE *lb, i format == D_NREVERSE) warnx("No newline at end of file"); else @@ -1466,7 +1482,7 @@ } while (++col < newcol); } else { if (format == D_EDIT && j == 1 && c == '\n' -@@ -1229,10 +1280,10 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1229,10 +1290,10 @@ fetch(long *f, int a, int b, FILE *lb, i * giving the caller an offset * from which to restart. */ @@ -1479,7 +1495,7 @@ col++; } } -@@ -1246,8 +1297,8 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1246,8 +1307,8 @@ fetch(long *f, int a, int b, FILE *lb, i static int readhash(FILE *f) { @@ -1490,7 +1506,7 @@ sum = 1; space = 0; -@@ -1305,20 +1356,28 @@ readhash(FILE *f) +@@ -1305,20 +1366,28 @@ readhash(FILE *f) return (sum == 0 ? 1 : sum); } @@ -1526,7 +1542,7 @@ return (1); } -@@ -1327,10 +1386,10 @@ asciifile(FILE *f) +@@ -1327,10 +1396,10 @@ asciifile(FILE *f) static char * match_function(const long *f, int pos, FILE *file) { @@ -1541,7 +1557,7 @@ lastline = pos; while (pos > last) { -@@ -1342,7 +1401,6 @@ match_function(const long *f, int pos, F +@@ -1342,7 +1411,6 @@ match_function(const long *f, int pos, F if (nc > 0) { buf[nc] = '\0'; buf[strcspn(buf, "\n")] = '\0'; @@ -1549,7 +1565,7 @@ if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) -@@ -1373,9 +1431,9 @@ static void +@@ -1373,9 +1441,9 @@ static void dump_context_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1562,7 +1578,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1390,8 +1448,8 @@ dump_context_vec(FILE *f1, FILE *f2) +@@ -1390,8 +1458,8 @@ dump_context_vec(FILE *f1, FILE *f2) if (pflag) { f = match_function(ixold, lowa-1, f1); if (f != NULL) { @@ -1573,7 +1589,7 @@ } } printf("\n*** "); -@@ -1478,9 +1536,9 @@ static void +@@ -1478,9 +1546,9 @@ static void dump_unified_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1586,7 +1602,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1491,19 +1549,19 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1491,19 +1559,19 @@ dump_unified_vec(FILE *f1, FILE *f2) lowc = MAX(1, cvp->c - context); upd = MIN(len[1], context_vec_ptr->d + context); @@ -1612,7 +1628,7 @@ /* * Output changes in "unified" diff format--the old and new lines -@@ -1551,16 +1609,43 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1551,16 +1619,43 @@ dump_unified_vec(FILE *f1, FILE *f2) static void print_header(const char *file1, const char *file2) { @@ -1662,3 +1678,15 @@ + printf("%s %s\t%s\n", format == D_CONTEXT ? "---" : "+++", + file2, buf2); } +diff -rupN diff-orig/Makefile diff/Makefile +--- diff-orig/Makefile 2012-07-25 11:37:23.300991134 -0400 ++++ diff/Makefile 2012-07-25 11:40:31.643987623 -0400 +@@ -3,7 +3,7 @@ + + DEBUG_FLAGS+= -g + +-PROG= diff ++PROG= diff xdiff + SRCS= diff.c diffdir.c diffreg.c + CFLAGS+= -std=c99 -Wall -pedantic + From owner-svn-soc-all@FreeBSD.ORG Wed Jul 25 16:12: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 B463B106566C for ; Wed, 25 Jul 2012 16:12:55 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 25 Jul 2012 16:12:55 +0000 Date: Wed, 25 Jul 2012 16:12:55 +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: <20120725161255.B463B106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239768 - 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, 25 Jul 2012 16:12:57 -0000 Author: jhagewood Date: Wed Jul 25 16:12:55 2012 New Revision: 239768 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239768 Log: Updated diff TODO Modified: soc2012/jhagewood/diff/TODO Modified: soc2012/jhagewood/diff/TODO ============================================================================== --- soc2012/jhagewood/diff/TODO Wed Jul 25 16:12:02 2012 (r239767) +++ soc2012/jhagewood/diff/TODO Wed Jul 25 16:12:55 2012 (r239768) @@ -20,7 +20,7 @@ --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 +Support for zdiff IN PROGRESS Needs testing. Notes: From owner-svn-soc-all@FreeBSD.ORG Wed Jul 25 22:59: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 0C7D71065675 for ; Wed, 25 Jul 2012 22:59:35 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 25 Jul 2012 22:59:35 +0000 Date: Wed, 25 Jul 2012 22:59:35 +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: <20120725225935.0C7D71065675@hub.freebsd.org> Cc: Subject: socsvn commit: r239777 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf arm/ti 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: Wed, 25 Jul 2012 22:59:37 -0000 Author: aleek Date: Wed Jul 25 22:59:34 2012 New Revision: 239777 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239777 Log: trying to fix the bug External Non-Linefetch Abort (S) in OMAP EHCI driver Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.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/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Wed Jul 25 21:59:10 2012 (r239776) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Wed Jul 25 22:59:34 2012 (r239777) @@ -48,7 +48,7 @@ options PREEMPTION # Debugging -makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols +#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols #makeoptions WERROR="-Werror" #makeoptions WERROR="" options BREAK_TO_DEBUGGER Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c Wed Jul 25 21:59:10 2012 (r239776) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_gpio.c Wed Jul 25 22:59:34 2012 (r239777) @@ -207,6 +207,8 @@ /* The following describes the H/W revision of each of the GPIO banks */ uint32_t sc_revision[MAX_GPIO_BANKS]; + char padding[512]; + struct mtx sc_mtx; }; @@ -446,7 +448,10 @@ return (EINVAL); + device_printf( sc->sc_dev, "locking mutex\n" ); + device_printf( sc->sc_dev, "adres mutexa: %p\n", &sc->sc_mtx ); TI_GPIO_LOCK(sc); + device_printf( sc->sc_dev, "mutex locked!!\n" ); /* Sanity check the pin number is valid */ if ((bank > MAX_GPIO_BANKS) || (sc->sc_mem_res[bank] == NULL)) { @@ -659,11 +664,15 @@ struct ti_gpio_softc *sc = device_get_softc(dev); unsigned int i; int err = 0; + memset( sc, 0, sizeof( struct ti_gpio_softc ) ); sc->sc_dev = dev; + device_printf(dev, "Inicjalizacja mutexa gpio\n"); TI_GPIO_LOCK_INIT(sc); + device_printf( dev, "Address do softc struct: %p\n", sc ); + /* There are up to 6 different GPIO register sets located in different * memory areas on the chip. The memory range should have been set for Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Wed Jul 25 21:59:10 2012 (r239776) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Wed Jul 25 22:59:34 2012 (r239777) @@ -527,8 +527,8 @@ DOMAIN_CLIENT); pmap_pa = kernel_l1pt.pv_pa; - //arm_early_puts( "Dumping memory layout!\n" ); - //dump_l1pagetable( kernel_l1pt.pv_pa ); + arm_early_puts( "Dumping memory layout!\n" ); + dump_l1pagetable( kernel_l1pt.pv_pa ); setttb(kernel_l1pt.pv_pa); cpu_tlb_flushID(); Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Wed Jul 25 21:59:10 2012 (r239776) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Wed Jul 25 22:59:34 2012 (r239777) @@ -125,6 +125,7 @@ int port_mode[3]; int phy_reset[3]; int reset_gpio_pin[3]; + struct mtx mtx; }; static device_attach_t omap_ehci_attach; @@ -787,6 +788,11 @@ int len, tuple_size; int i; + memset( &isc->mtx, 0, sizeof( struct mtx) ); + + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); + + mtx_init(&isc->mtx, "habababa", "ti_ehci_testowy", MTX_DEF); device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* initialise some bus fields */ @@ -797,12 +803,17 @@ /* save the device */ isc->sc_dev = dev; + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* get all DMA memory */ if (usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(dev), &ehci_iterate_hw_softc)) { return (ENOMEM); } - + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); + mtx_lock( &isc->mtx ); + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); + mtx_unlock( &isc->mtx ); + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* When the EHCI driver is added to the tree it is expected that 3 * memory resources and 1 interrupt resource is assigned. The memory * resources should be: @@ -881,6 +892,7 @@ device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); tuple_size = sizeof(pcell_t) * 3; node = ofw_bus_get_node(dev); + len = OF_getprop(node, "phy-config", phyconf, sizeof(phyconf)); if (len > 0) { if (len % tuple_size) @@ -897,7 +909,7 @@ phyconf_ptr += 3; } } - + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); /* Initialise the ECHI registers */ err = omap_ehci_init(isc); Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Wed Jul 25 21:59:10 2012 (r239776) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Wed Jul 25 22:59:34 2012 (r239777) @@ -173,7 +173,7 @@ interrupts = < 12 13 14 15 >; interrupt-parent = <&AINTC>; }; - +/* mmchs@4809c000 { compatible = "ti,mmchs"; reg =<0x4809c000 0x1000 >; @@ -181,7 +181,7 @@ interrupt-parent = <&AINTC>; mmchs-device-id = <1>; }; - +*/ i2c0: i2c@48070000 { #address-cells = <1>; From owner-svn-soc-all@FreeBSD.ORG Thu Jul 26 13:53: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 8984A1065670 for ; Thu, 26 Jul 2012 13:53:33 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 26 Jul 2012 13:53:33 +0000 Date: Thu, 26 Jul 2012 13:53:33 +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: <20120726135333.8984A1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239802 - in soc2012/exxo/freebsd-head: include/rpcsvc 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: Thu, 26 Jul 2012 13:53:35 -0000 Author: exxo Date: Thu Jul 26 13:53:32 2012 New Revision: 239802 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239802 Log: Complete rewrite of yp_ping.c (ypbind) Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp.x soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.c soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.h soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp.x ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp.x Thu Jul 26 12:18:23 2012 (r239801) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp.x Thu Jul 26 13:53:32 2012 (r239802) @@ -227,6 +227,8 @@ /* Backward compatibility for YPBIND protocol version 2 */ #ifdef YPBIND_COMPAT_V2 +const YPBINDVERS_2 = 2; + struct ypbind_binding_v2 { opaque ypbind_binding_addr[4]; /* In network order */ opaque ypbind_binding_port[2]; /* In network order */ Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Thu Jul 26 12:18:23 2012 (r239801) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Thu Jul 26 13:53:32 2012 (r239802) @@ -108,7 +108,7 @@ #endif static void -print_addr(union ypb_resp *ypbr, int version) +print_addr(const union ypb_resp *ypbr, int version) { struct hostent *hent = NULL; char str[ADDRSTRLEN]; Modified: soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.c Thu Jul 26 12:18:23 2012 (r239801) +++ soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.c Thu Jul 26 13:53:32 2012 (r239802) @@ -103,6 +103,8 @@ */ +#if 0 /* TODO : Does __yp_getport achieve the same result ? */ + static struct timeval timeout = { 1, 0 }; static struct timeval tottimeout = { 1, 0 }; @@ -145,6 +147,7 @@ address->sin_port = 0; return (port); } +#endif /* * Transmit to YPPROC_DOMAIN_NONACK, return immediately. @@ -207,104 +210,222 @@ */ struct ping_req { - struct sockaddr_in sin; + struct sockaddr_storage sst; u_int32_t xid; }; +struct transport { + CLIENT *clnt; + u_int32_t xid_lookup; + struct sockaddr_storage *any; + int sock; + struct netbuf addr; +}; +#define V4 0 +#define V6 1 +#ifdef INET6 +# define TSP_LEN (V6 + 1) +#else +# define TSP_LEN (V4 + 1) +#endif + +static u_short +__yp_getport(const struct sockaddr_storage *host, const char *netid) +{ + struct sockaddr_storage sst; + struct netconfig *nconf; + struct netbuf svcaddr; + u_short port; + char str[ADDRSTRLEN]; + int family; + char *ptr; + + svcaddr.len = 0; + svcaddr.maxlen = sizeof(sst); + svcaddr.buf = &sst; + if (ss_extract(host, &family, &ptr, 0)) + return (0); + inet_ntop(family, ptr, str, ADDRSTRLEN); + if ((nconf = getnetconfigent(netid)) == NULL || + !rpcb_getaddr(YPPROG, YPVERS, nconf, &svcaddr, str)) + return (0); + switch (svcaddr.len) { + case sizeof(struct sockaddr_in) : + port = ss_to_sinport(svcaddr.buf); + break; +#ifdef INET6 + case sizeof(struct sockaddr_in6) : + port = ss_to_sin6port(svcaddr.buf); + break; +#endif + default : + port = 0; + } + return (port); /* Network byte order */ +} + +static int +rpc_init(struct transport *tsp) +{ + static timeval timenull; + int async = TRUE; + int dontblock = 1; + int validtransp = 0; + int i; + + for (i = 0; i < TSP_LEN; ++i) { + if (tsp[i]->any == NULL) + continue; +#ifdef INET6 + if (i == V6) { + tsp[i]->sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); + tsp[i]->addr.len = sizeof(struct sockaddr_in6); + } + else /* V4 */ +#endif + { + tsp[i]->sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + tsp[i]->addr.len = sizeof(struct sockaddr_in); + } + if (tsp[i]->sock < 0) + return (1); + tsp[i]->addr.buf = tsp[i]->any; + tsp[i]->clnt = clnt_dg_create(tsp[i]->sock, &tsp[i]->addr, YPPROG, YPVERS, 0, 0); + if (tsp[i]->clnt == NULL) + return (1); + tsp[i]->clnt->cl_auth = authsys_create_default(); + clnt_control(tsp[i]->clnt, CLSET_TIMEOUT, (char *)&timenull); + clnt_control(tsp[i]->clnt, CLSET_ASYNC, (char *)&async); + ioctl(tsp[i]->sock, FIONBIO, &dontblock); + ++validtransp; + } + return (!validtransp); +} + +static void +rpc_destroy(struct transport *tsp) +{ + int i; + + for (i = 0; i < TSP_LEN; ++i) { + if (tsp[i]->clnt) { + auth_destroy(tsp[i]->clnt->cl_auth); + clnt_destroy(tsp[i]->clnt); + tsp[i]->clnt = NULL; + } + tsp[i]->xid_lookup = 0; + tsp[i]->any = NULL; + close(tsp[i]->sock); + tsp[i]->sock = -1; + tsp[i]->addr.buf = NULL; + } +} + int -__yp_ping(struct in_addr *restricted_addrs, int cnt, char *dom, short *port) +__yp_ping(struct sockaddr_storage *restricted_addrs, int cnt, char *dom, short *port) { - struct timeval tv = { 5, 0 }; struct ping_req **reqs; unsigned long i; - int async; - struct sockaddr_in sin, *any = NULL; - struct netbuf addr; + int n; + struct sockaddr_storage *req_addr; int winner = -1; - u_int32_t xid_seed, xid_lookup; - int sock, dontblock = 1; - CLIENT *clnt; + u_int32_t xid_seed; char *foo = dom; int validsrvs = 0; + u_short yp_port; + struct transport tsp[TSP_LEN] = { +#ifdef INET6 + {NULL, 0, NULL, -1}, +#endif + {NULL, 0, NULL, -1} + }; /* Set up handles. */ reqs = calloc(1, sizeof(struct ping_req *) * cnt); xid_seed = time(NULL) ^ getpid(); for (i = 0; i < cnt; i++) { - bzero((char *)&sin, sizeof(sin)); - sin.sin_family = AF_INET; - bcopy((char *)&restricted_addrs[i], - (char *)&sin.sin_addr, sizeof(struct in_addr)); - sin.sin_port = htons(__pmap_getport(&sin, YPPROG, - YPVERS, IPPROTO_UDP)); - if (sin.sin_port == 0) + yp_port = __yp_getport(&restricted_addrs[i], "udp"); + if (yp_port == 0) continue; reqs[i] = calloc(1, sizeof(struct ping_req)); - bcopy((char *)&sin, (char *)&reqs[i]->sin, sizeof(sin)); - any = &reqs[i]->sin; + req_addr = &reqs[i]->sst; + bcopy((char *)&restricted_addrs[i], (char *)req_addr, sizeof(*req_addr)); +#ifdef INET6 + if (ss_family(req_addr) == AF_INET6) { + ss_to_sin6port(req_addr) = yp_port; + tsp[V6].any = req_addr; + } + else /* AF_INET */ +#endif + { + ss_to_sinport(req_addr) = yp_port; + tsp[V4].any = req_addr; + } reqs[i]->xid = xid_seed; xid_seed++; validsrvs++; } /* Make sure at least one server was assigned */ - if (!validsrvs) { - free(reqs); - return(-1); - } - - /* Create RPC handle */ - sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - clnt = clntudp_create(any, YPPROG, YPVERS, tv, &sock); - if (clnt == NULL) { - close(sock); - for (i = 0; i < cnt; i++) - if (reqs[i] != NULL) - free(reqs[i]); - free(reqs); - return(-1); - } - clnt->cl_auth = authunix_create_default(); - tv.tv_sec = 0; + if (!validsrvs) + goto err; - clnt_control(clnt, CLSET_TIMEOUT, (char *)&tv); - async = TRUE; - clnt_control(clnt, CLSET_ASYNC, (char *)&async); - ioctl(sock, FIONBIO, &dontblock); + /* Create RPC transports + * an inet4 transport for any V4 address existing in `reqs' + * an inet6 transport for any V6 address existing in `reqs' + * otherwise, shutdown + * */ + if (rpc_init(tsp)) + goto err; /* Transmit */ - for (i = 0; i < cnt; i++) { + for (i = 0; i < cnt; i++) if (reqs[i] != NULL) { - clnt_control(clnt, CLSET_XID, (char *)&reqs[i]->xid); - addr.len = sizeof(reqs[i]->sin); - addr.buf = (char *) &reqs[i]->sin; - clnt_control(clnt, CLSET_SVC_ADDR, &addr); - ypproc_domain_nonack_2_send(&foo, clnt); + req_addr = &reqs[i]->sst; + n = (ss_family(req_addr) == AF_INET ? V4 : V6); + clnt_control(tsp[n].clnt, CLSET_XID, (char *)&reqs[i]->xid); + tsp[n].addr.buf = (char *) req_addr; + clnt_control(tsp[n].clnt, CLSET_SVC_ADDR, &tsp[n].addr); + ypproc_domain_nonack_2_send(&foo, tsp[n].clnt); } - } /* Receive reply */ - ypproc_domain_nonack_2_recv(&foo, clnt); + for (i = 0; i < TSP_LEN; ++i) + if (tsp[i].clnt) + ypproc_domain_nonack_2_recv(&foo, tsp[i].clnt); + + /* Get the winner */ + for (i = 0; i < TSP_LEN; ++i) + if (tsp[i].clnt) + clnt_control(tsp[i].clnt, CLGET_XID, (char *)&tsp[i].xid_lookup); - /* Got a winner -- look him up. */ - clnt_control(clnt, CLGET_XID, (char *)&xid_lookup); - for (i = 0; i < cnt; i++) { - if (reqs[i] != NULL && reqs[i]->xid == xid_lookup) { - winner = i; - *port = reqs[i]->sin.sin_port; + /* Look him up */ + for (i = 0; i < cnt; i++) + if (reqs[i] != NULL) { + for (n = 0; n < TSP_LEN; ++n) + if (reqs[i]->xid == tsp[n].xid_lookup) { +#ifdef INET6 + if (n == V6) + *port = ss_to_sin6port(&reqs[i]->sst); /* Network byte order */ + else /* V4 */ +#endif + *port = ss_to_sinport(&reqs[i]->sst); + winner = i; + break; + } + if (winner > 0) + break; } - } - + /* Shut everything down */ - auth_destroy(clnt->cl_auth); - clnt_destroy(clnt); - close(sock); - - for (i = 0; i < cnt; i++) - if (reqs[i] != NULL) - free(reqs[i]); +err: + rpc_destroy(tsp); + if (validsrvs) { + for (i = 0; i < cnt; i++) + if (reqs[i] != NULL) + free(reqs[i]); + } free(reqs); - return(winner); } Modified: soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.h ============================================================================== --- soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.h Thu Jul 26 12:18:23 2012 (r239801) +++ soc2012/exxo/freebsd-head/usr.sbin/ypbind/yp_ping.h Thu Jul 26 13:53:32 2012 (r239802) @@ -2,4 +2,39 @@ * $FreeBSD$ */ -extern int __yp_ping(struct in_addr *, int, char *, short *); +#ifdef INET6 +# define ADDRSTRLEN INET6_ADDRSTRLEN +#else +# define ADDRSTRLEN INET_ADDRSTRLEN +#endif + +#define ss_family(x) (((struct sockaddr *) x)->sa_family) +#define ss_to_sinaddr(x) ((char *) &((struct sockaddr_in *) x)->sin_addr) +#define ss_to_sin6addr(x) ((char *) &((struct sockaddr_in6 *) x)->sin6_addr) +#define ss_to_sinport(x) ((u_short) ((struct sockaddr_in *) x)->sin_port) +#define ss_to_sin6port(x) ((u_short) ((struct sockaddr_in6 *) x)->sin6_port) + +static inline int +ss_extract(const struct sockaddr_storage *ss, int *family, char **addr, size_t *len) +{ + *family = ss_family(ss); + switch (*family) { + case AF_INET: + *addr = ss_to_sinaddr(ss); + if (len) + *len = sizeof(struct sockaddr_in); + break; +#ifdef INET6 + case AF_INET6: + *addr = ss_to_sin6addr(ss); + if (len) + *len = sizeof(struct sockaddr_in6); + break; +#endif + default: + return (1); + } + return (0); +} + +extern int __yp_ping(struct sockaddr_storage *, int, char *, short *); Modified: soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Thu Jul 26 12:18:23 2012 (r239801) +++ soc2012/exxo/freebsd-head/usr.sbin/ypbind/ypbind.c Thu Jul 26 13:53:32 2012 (r239802) @@ -76,7 +76,7 @@ struct _dom_binding { struct _dom_binding *dom_pnext; char dom_domain[YPMAXDOMAIN + 1]; - struct sockaddr_in dom_server_addr; + struct sockaddr_storage dom_server_addr; /* TODO */ long int dom_vers; int dom_lockfd; int dom_alive; @@ -128,7 +128,7 @@ #define RESTRICTED_SERVERS 10 int yp_restricted = 0; int yp_manycast = 0; -struct in_addr restricted_addrs[RESTRICTED_SERVERS]; +struct sockaddr_storage restricted_addrs[RESTRICTED_SERVERS]; /* No more than MAX_CHILDREN child broadcasters at a time. */ #ifndef MAX_CHILDREN @@ -154,8 +154,6 @@ int yplockfd; fd_set fdsr; -SVCXPRT *udptransp, *tcptransp; - void * ypbindproc_null_2_yp(SVCXPRT *transp, void *argp, CLIENT *clnt) { @@ -372,10 +370,32 @@ } close(yplockfd); unlink(YPBINDLOCK); - pmap_unset(YPBINDPROG, YPBINDVERS); + rpcb_unset(YPBINDPROG, YPBINDVERS, NULL); +#ifdef YPBIND_COMPAT_V2 + rpcb_unset(YPBINDPROG, YPBINDVERS_2, NULL); +#endif exit(0); } +/* The string `message' is evaluated two times, thus the correct format to add the address is %%s + * Beware of side effects using other %% notations */ +static void +logwaddr(int priority, const struct sockaddr_storage *addr, const char *message, ...) +{ + char buf[256]; /* Maximum message length */ + va_list args; + int family; + char *ptr; + char str[ADDRSTRLEN]; + + if (ss_extract(addr, &family, &ptr, 0)) + return; + va_start(args, message); + vsnprintf(buf, sizeof(buf), message, args); + syslog(priority, buf, inet_ntop(family, ptr, str, ADDRSTRLEN)); + va_end(args); +} + int main(int argc, char *argv[]) { @@ -430,22 +450,20 @@ err(1, "fork"); #endif - pmap_unset(YPBINDPROG, YPBINDVERS); - - udptransp = svcudp_create(RPC_ANYSOCK); - if (udptransp == NULL) + rpcb_unset(YPBINDPROG, YPBINDVERS, NULL); +#ifdef YPBIND_COMPAT_V2 + rpcb_unset(YPBINDPROG, YPBINDVERS_2, NULL); +#endif + if (!svc_create(ypbindprog_2, YPBINDPROG, YPBINDVERS, "udp")) /* TODO see how to retrieve xp_port */ errx(1, "cannot create udp service"); - if (!svc_register(udptransp, YPBINDPROG, YPBINDVERS, ypbindprog_2, - IPPROTO_UDP)) - errx(1, "unable to register (YPBINDPROG, YPBINDVERS, udp)"); - - tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0); - if (tcptransp == NULL) + if (!svc_create(ypbindprog_2, YPBINDPROG, YPBINDVERS, "tcp")) errx(1, "cannot create tcp service"); - - if (!svc_register(tcptransp, YPBINDPROG, YPBINDVERS, ypbindprog_2, - IPPROTO_TCP)) - errx(1, "unable to register (YPBINDPROG, YPBINDVERS, tcp)"); +#ifdef YPBIND_COMPAT_V2 + if (!svc_create(ypbindprog_2, YPBINDPROG, YPBINDVERS_2, "udp")) + errx(1, "cannot create udp service"); + if (!svc_create(ypbindprog_2, YPBINDPROG, YPBINDVERS_2, "tcp")) + errx(1, "cannot create tcp service"); +#endif /* build initial domain binding, make it "unsuccessful" */ ypbindlist = (struct _dom_binding *)malloc(sizeof *ypbindlist); @@ -650,6 +668,7 @@ void broadcast(struct _dom_binding *ypdb) { + static struct sockaddr_storage null_addr; bool_t out = FALSE; enum clnt_stat stat; @@ -661,11 +680,13 @@ return; } - if (ypdb->dom_vers == -1 && (long)ypdb->dom_server_addr.sin_addr.s_addr) { + /* bcmp should be safe here due to the earlier dom_server_addr memset which + * prevents us from alignement issues */ + if (ypdb->dom_vers == -1 && bcmp(&ypdb->dom_server_addr, &null_addr, sizeof(null_addr))) { if (not_responding_count++ >= NOT_RESPONDING_HYSTERESIS) { not_responding_count = NOT_RESPONDING_HYSTERESIS; - syslog(LOG_WARNING, "NIS server [%s] for domain \"%s\" not responding", - inet_ntoa(ypdb->dom_server_addr.sin_addr), ypdb->dom_domain); + logwaddr(LOG_WARNING, &ypdb->dom_server_addr, + "NIS server [%%s] for domain \"%s\" not responding", ypdb->dom_domain); } } From owner-svn-soc-all@FreeBSD.ORG Thu Jul 26 19:20:02 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 1CB061065672 for ; Thu, 26 Jul 2012 19:20:00 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 26 Jul 2012 19:20:00 +0000 Date: Thu, 26 Jul 2012 19:20:00 +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: <20120726192000.1CB061065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239814 - in soc2012/gmiller/locking-head: . 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: Thu, 26 Jul 2012 19:20:02 -0000 Author: gmiller Date: Thu Jul 26 19:19:59 2012 New Revision: 239814 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239814 Log: r239869@FreeBSD-dev: root | 2012-07-23 19:11:32 -0500 Eliminate another source of suboptimal graphs. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Thu Jul 26 18:15:48 2012 (r239813) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Thu Jul 26 19:19:59 2012 (r239814) @@ -95,6 +95,8 @@ int insert_lock(struct lock_info *from, struct lock_info *to) { + struct lock_info *child; + if (from == to || from == NULL || to == NULL) { return (0); } @@ -108,6 +110,13 @@ to->sibling = from->child; from->child = to; + child = to->sibling; + while (child != NULL) { + optimize_links(child); + + child = child->sibling; + } + optimize_links(to); return (0); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 27 07:53:55 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 618BD1065670 for ; Fri, 27 Jul 2012 07:53:53 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 27 Jul 2012 07:53:53 +0000 Date: Fri, 27 Jul 2012 07:53:53 +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: <20120727075353.618BD1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239824 - 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: Fri, 27 Jul 2012 07:53:55 -0000 Author: rudot Date: Fri Jul 27 07:53:52 2012 New Revision: 239824 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239824 Log: fix includes and some other details 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 Fri Jul 27 05:48:42 2012 (r239823) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Jul 27 07:53:52 2012 (r239824) @@ -49,13 +49,14 @@ #include #include #include +#include #include +#include #include #include #include #include #include -#include #ifdef RCTL #include @@ -278,7 +279,7 @@ * of the ccpu variable. In ULE it is defined to be zero which saves us some * work. */ -u_int +static u_int racct_getpcpu(struct proc *p) { u_int swtime; @@ -938,10 +939,12 @@ break; case TDS_RUNNING: thread_lock(td); - cpuid = td->td_oncpu; td->td_flags |= TDF_NEEDRESCHED; +#ifdef SMP + cpuid = td->td_oncpu; if ((cpuid != NOCPU) && (td != curthread)) ipi_cpu(cpuid, IPI_AST); +#endif thread_unlock(td); break; default: Modified: soc2012/rudot/sys/sys/racct.h ============================================================================== --- soc2012/rudot/sys/sys/racct.h Fri Jul 27 05:48:42 2012 (r239823) +++ soc2012/rudot/sys/sys/racct.h Fri Jul 27 07:53:52 2012 (r239824) @@ -152,7 +152,6 @@ void racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, struct ucred *newcred); void racct_move(struct racct *dest, struct racct *src); -u_int racct_getpcpu(struct proc *p); int racct_proc_disabled(struct proc *p); #endif /* !_RACCT_H_ */ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 27 17:41: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 23515106566B for ; Fri, 27 Jul 2012 17:40:58 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 27 Jul 2012 17:40:58 +0000 Date: Fri, 27 Jul 2012 17:40: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: <20120727174058.23515106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239847 - in soc2012/jhagewood: diff/diff diff3 sdiff sdiff/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, 27 Jul 2012 17:41:00 -0000 Author: jhagewood Date: Fri Jul 27 17:40:57 2012 New Revision: 239847 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239847 Log: Added binary support for sdiff Modified: soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff3/TODO soc2012/jhagewood/sdiff/TODO soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Fri Jul 27 16:38:02 2012 (r239846) +++ soc2012/jhagewood/diff/diff/diffreg.c Fri Jul 27 17:40:57 2012 (r239847) @@ -78,7 +78,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +99,7 @@ # define TIMESPEC_NS(timespec) 0 #endif +#define MAX_INT 2147483647 #define MAX_CHECK 768 /* 3 kilobytes of chars. */ /* @@ -344,8 +344,8 @@ if (filebehave == FILE_NORMAL) f1 = fopen(file1, "r"); if (filebehave == FILE_GZIP) { - gz1 = gzopen(file1, "r"); - gzread(gz1, buf, MAX_INT); + gz1 = gzdopen(file1, "r"); + gzdread(gz1, buf, MAX_INT); f1 = fdopen(buf, "r"); } } @@ -372,8 +372,8 @@ if (filebehave == FILE_NORMAL) f2 = fopen(file2, "r"); if (filebehave == FILE_GZIP) - gz2 = gzopen(file2, "r"); - gzread(gz2, buf, MAX_INT); + gz2 = gzdopen(file2, "r"); + gzdread(gz2, buf, MAX_INT); f2 = fdopen(buf, "r"); } } Modified: soc2012/jhagewood/diff3/TODO ============================================================================== --- soc2012/jhagewood/diff3/TODO Fri Jul 27 16:38:02 2012 (r239846) +++ soc2012/jhagewood/diff3/TODO Fri Jul 27 17:40:57 2012 (r239847) @@ -11,4 +11,4 @@ - BUG: Goes to usage when argc < 5 FIX: argc < 3 - BUG: Would not open files correctly FIX: change which argv[] is passed to fopen() -- BUG: Seg faults. +- BUG: Seg faults. FIXED Modified: soc2012/jhagewood/sdiff/TODO ============================================================================== --- soc2012/jhagewood/sdiff/TODO Fri Jul 27 16:38:02 2012 (r239846) +++ soc2012/jhagewood/sdiff/TODO Fri Jul 27 17:40:57 2012 (r239847) @@ -4,7 +4,7 @@ Fix --width output indention COMPLETE --help COMPLETE Add more information to man file. COMPLETE -Fix sdiff to work with binary data INCOMPLETE +Fix sdiff to work with binary data COMPLETE TODO: Add some error checking Replace goto statements COMPLETE NOTES: Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Fri Jul 27 16:38:02 2012 (r239846) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Fri Jul 27 17:40:57 2012 (r239847) @@ -1,6 +1,6 @@ -diff -rupN jhagewood/sdiff/sdiff-orig/common.c jhagewood/sdiff/sdiff/common.c ---- jhagewood/sdiff/sdiff-orig/common.c 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/common.c 2012-07-16 19:27:40.000000000 -0400 +diff -rupN sdiff-orig/common.c sdiff/common.c +--- sdiff-orig/common.c 2012-07-26 03:11:02.000000000 -0400 ++++ sdiff/common.c 2012-07-26 03:11:02.000000000 -0400 @@ -5,16 +5,24 @@ * Public domain. */ @@ -28,9 +28,9 @@ - exit(2); + exit(1); } -diff -rupN jhagewood/sdiff/sdiff-orig/common.h jhagewood/sdiff/sdiff/common.h ---- jhagewood/sdiff/sdiff-orig/common.h 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/common.h 2012-07-16 19:27:30.000000000 -0400 +diff -rupN sdiff-orig/common.h sdiff/common.h +--- sdiff-orig/common.h 2012-07-26 03:11:02.000000000 -0400 ++++ sdiff/common.h 2012-07-26 03:11:02.000000000 -0400 @@ -5,8 +5,4 @@ * Public domain. */ @@ -41,9 +41,9 @@ - -__dead void cleanup(const char *); +void cleanup(const char *) __dead2; -diff -rupN jhagewood/sdiff/sdiff-orig/edit.c jhagewood/sdiff/sdiff/edit.c ---- jhagewood/sdiff/sdiff-orig/edit.c 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/edit.c 2012-07-16 19:29:10.000000000 -0400 +diff -rupN sdiff-orig/edit.c sdiff/edit.c +--- sdiff-orig/edit.c 2012-07-26 03:11:02.000000000 -0400 ++++ sdiff/edit.c 2012-07-26 03:11:02.000000000 -0400 @@ -4,6 +4,14 @@ * Written by Raymond Lai . * Public domain. @@ -59,9 +59,9 @@ #include #include -diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.1 jhagewood/sdiff/sdiff/sdiff.1 ---- jhagewood/sdiff/sdiff-orig/sdiff.1 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.1 2012-07-14 03:47:32.000000000 -0400 +diff -rupN sdiff-orig/sdiff.1 sdiff/sdiff.1 +--- sdiff-orig/sdiff.1 2012-07-26 03:11:02.000000000 -0400 ++++ sdiff/sdiff.1 2012-07-26 03:11:02.000000000 -0400 @@ -1,9 +1,10 @@ +.\" $FreeBSD$ .\" $OpenBSD: sdiff.1,v 1.15 2007/06/29 14:48:07 jmc Exp $ @@ -171,9 +171,9 @@ -.Nm -may not work with binary data. + -diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c ---- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-16 19:26:27.000000000 -0400 +diff -rupN sdiff-orig/sdiff.c sdiff/sdiff.c +--- sdiff-orig/sdiff.c 2012-07-26 03:11:02.000000000 -0400 ++++ sdiff/sdiff.c 2012-07-27 04:03:20.000000000 -0400 @@ -5,6 +5,14 @@ * Public domain. */ @@ -189,7 +189,26 @@ #include #include #include -@@ -62,81 +70,108 @@ static void printd(FILE *, size_t); +@@ -41,6 +49,9 @@ + */ + #define WIDTH_MIN 5 + ++/* 3 kilobytes of chars */ ++#define MAX_CHECK 768 ++ + /* A single diff line. */ + struct diffline { + SIMPLEQ_ENTRY(diffline) diffentries; +@@ -52,6 +63,8 @@ struct diffline { + static void astrcat(char **, const char *); + static void enqueue(char *, char, char *); + static char *mktmpcpy(const char *); ++static int istextfile(FILE *); ++static void binexec(char *, char *, char *); __dead2; + static void freediff(struct diffline *); + static void int_usage(void); + static int parsecmd(FILE *, FILE *, FILE *); +@@ -62,81 +75,108 @@ static void printd(FILE *, size_t); static void println(const char *, const char, const char *); static void processq(void); static void prompt(const char *, const char *); @@ -327,7 +346,7 @@ + { "ignore-all-space", no_argument, NULL, 'W' }, + + { NULL, 0, NULL, '\0'} -+}; + }; + +static const char *help_msg[] = { + "\nusage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n", @@ -350,13 +369,13 @@ + "\t\t--tabsize NUM, Change size of tabs (default 8.)", + + NULL, - }; ++}; +char **help_strs = (char **)help_msg; + /* * Create temporary file if source_file is not a regular file. * Returns temporary file name if one was malloced, NULL if unnecessary. -@@ -175,7 +210,7 @@ mktmpcpy(const char *source_file) +@@ -175,7 +215,7 @@ mktmpcpy(const char *source_file) err(2, "asprintf"); if ((ofd = mkstemp(target_file)) == -1) { warn("error opening %s", target_file); @@ -365,7 +384,7 @@ } while ((rcount = read(ifd, buf, sizeof(buf))) != -1 && rcount != 0) { -@@ -184,22 +219,18 @@ mktmpcpy(const char *source_file) +@@ -184,22 +224,18 @@ mktmpcpy(const char *source_file) wcount = write(ofd, buf, (size_t)rcount); if (-1 == wcount || rcount != wcount) { warn("error writing to %s", target_file); @@ -390,7 +409,16 @@ } int -@@ -240,18 +271,13 @@ main(int argc, char **argv) +@@ -211,7 +247,7 @@ main(int argc, char **argv) + pid_t pid=0; pid_t ppid =-1; + const char *outfile = NULL; + struct option *popt; +- char **diffargv, *diffprog = "diff", *filename1, *filename2, ++ char **diffargv, *diffprog = "/usr/bin/diff", *filename1, *filename2, + *tmp1, *tmp2, *s1, *s2; + + /* +@@ -240,18 +276,13 @@ main(int argc, char **argv) const char *errstr; switch (ch) { @@ -409,7 +437,7 @@ /* combine no-arg single switches */ case 'a': case 'B': -@@ -261,11 +287,17 @@ main(int argc, char **argv) +@@ -261,11 +292,17 @@ main(int argc, char **argv) case 'i': case 't': case 'H': @@ -430,7 +458,7 @@ case DIFFPROG_OPT: diffargv[0] = diffprog = optarg; break; -@@ -289,32 +321,27 @@ main(int argc, char **argv) +@@ -289,32 +326,27 @@ main(int argc, char **argv) if (errstr) errx(2, "width is %s: %s", errstr, optarg); break; @@ -470,7 +498,7 @@ diffargv[i] = diffargv[i+1]; } diffargv[diffargc-1] = NULL; -@@ -362,19 +389,18 @@ main(int argc, char **argv) +@@ -362,19 +394,18 @@ main(int argc, char **argv) /* Add NULL to end of array to indicate end of array. */ diffargv[diffargc++] = NULL; @@ -495,7 +523,7 @@ case 0: /* child */ /* We don't read from the pipe. */ -@@ -383,7 +409,6 @@ main(int argc, char **argv) +@@ -383,7 +414,6 @@ main(int argc, char **argv) err(2, "child could not duplicate descriptor"); /* Free unused descriptor. */ close(fd[1]); @@ -503,7 +531,64 @@ execvp(diffprog, diffargv); err(2, "could not execute diff: %s", diffprog); break; -@@ -461,6 +486,7 @@ main(int argc, char **argv) +@@ -406,6 +436,16 @@ main(int argc, char **argv) + if ((file2 = fopen(filename2, "r")) == NULL) + err(2, "could not open %s", filename2); + ++ if (!istextfile(file1) || !istextfile(file2)) { ++ fclose(file1); ++ fclose(file2); ++ fclose(diffpipe); ++ unlink(tmp1); ++ unlink(tmp2); ++ free(tmp1); ++ free(tmp2); ++ binexec(diffprog, filename1, filename2); ++ } + /* Line numbers start at one. */ + file1ln = file2ln = 1; + +@@ -452,6 +492,39 @@ main(int argc, char **argv) + return (WEXITSTATUS(status)); + } + ++static void ++binexec(char *diffprog, char *f1, char *f2) ++{ ++ ++ char *args[] = {diffprog, f1, f2, (char *) 0}; ++ ++ execv(diffprog, args); ++ printf("Could not execute diff process.\n"); ++ exit(1); ++} ++/* ++ * Checks whether a file appears to be a text file. ++ */ ++static int ++istextfile(FILE *f) ++{ ++ int i; ++ char ch; ++ ++ if (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); ++} ++ + /* + * Prints an individual column (left or right), taking into account + * that tabs are variable-width. Takes a string, the current column +@@ -461,6 +534,7 @@ main(int argc, char **argv) static void printcol(const char *s, size_t *col, const size_t col_max) { @@ -511,7 +596,7 @@ for (; *s && *col < col_max; ++s) { size_t new_col; -@@ -484,11 +510,9 @@ printcol(const char *s, size_t *col, con +@@ -484,11 +558,9 @@ printcol(const char *s, size_t *col, con return; *col = new_col; break; @@ -523,7 +608,7 @@ putchar(*s); } } -@@ -512,56 +536,47 @@ prompt(const char *s1, const char *s2) +@@ -512,56 +584,47 @@ prompt(const char *s1, const char *s2) /* Skip leading whitespace. */ for (p = cmd; isspace(*p); ++p) ; @@ -589,7 +674,7 @@ free(cmd); return; } -@@ -570,7 +585,7 @@ PROMPT: +@@ -570,7 +633,7 @@ PROMPT: * If there was no error, we received an EOF from stdin, so we * should quit. */ @@ -598,7 +683,7 @@ fclose(outfp); exit(0); } -@@ -678,7 +693,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -678,7 +741,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI /* A range is specified for file1. */ if (c == ',') { @@ -606,7 +691,7 @@ q = p; /* Go to character after file2end. */ while (isdigit(*p)) -@@ -690,7 +704,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -690,7 +752,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI errx(2, "file1 end is %s: %s", errstr, line); if (file1start > file1end) errx(2, "invalid line range in file1: %s", line); @@ -614,7 +699,7 @@ } else file1end = file1start; -@@ -809,17 +822,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -809,17 +870,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI printa(file2, file2end); n = file2end - file2start + 1; break; @@ -632,7 +717,7 @@ default: errx(2, "invalid diff command: %c: %s", cmd, line); } -@@ -854,6 +864,7 @@ enqueue(char *left, char div, char *righ +@@ -854,6 +912,7 @@ enqueue(char *left, char div, char *righ static void freediff(struct diffline *diffp) { @@ -640,7 +725,7 @@ free(diffp->left); free(diffp->right); free(diffp); -@@ -876,7 +887,6 @@ astrcat(char **s, const char *append) +@@ -876,7 +935,6 @@ astrcat(char **s, const char *append) static const char *oldstr = NULL; char *newstr; @@ -648,7 +733,7 @@ /* * First string is NULL, so just copy append. */ -@@ -1002,7 +1012,6 @@ printa(FILE *file, size_t line2) +@@ -1002,7 +1060,6 @@ printa(FILE *file, size_t line2) errx(2, "append ended early"); enqueue(NULL, '>', line); } @@ -656,7 +741,7 @@ processq(); } -@@ -1103,24 +1112,35 @@ printd(FILE *file1, size_t file1end) +@@ -1103,24 +1160,35 @@ printd(FILE *file1, size_t file1end) static void int_usage(void) { Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Fri Jul 27 16:38:02 2012 (r239846) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Fri Jul 27 17:40:57 2012 (r239847) @@ -49,6 +49,9 @@ */ #define WIDTH_MIN 5 +/* 3 kilobytes of chars */ +#define MAX_CHECK 768 + /* A single diff line. */ struct diffline { SIMPLEQ_ENTRY(diffline) diffentries; @@ -60,6 +63,8 @@ static void astrcat(char **, const char *); static void enqueue(char *, char, char *); static char *mktmpcpy(const char *); +static int istextfile(FILE *); +static void binexec(char *, char *, char *); __dead2; static void freediff(struct diffline *); static void int_usage(void); static int parsecmd(FILE *, FILE *, FILE *); @@ -242,7 +247,7 @@ pid_t pid=0; pid_t ppid =-1; const char *outfile = NULL; struct option *popt; - char **diffargv, *diffprog = "diff", *filename1, *filename2, + char **diffargv, *diffprog = "/usr/bin/diff", *filename1, *filename2, *tmp1, *tmp2, *s1, *s2; /* @@ -431,6 +436,16 @@ if ((file2 = fopen(filename2, "r")) == NULL) err(2, "could not open %s", filename2); + if (!istextfile(file1) || !istextfile(file2)) { + fclose(file1); + fclose(file2); + fclose(diffpipe); + unlink(tmp1); + unlink(tmp2); + free(tmp1); + free(tmp2); + binexec(diffprog, filename1, filename2); + } /* Line numbers start at one. */ file1ln = file2ln = 1; @@ -477,6 +492,39 @@ return (WEXITSTATUS(status)); } +static void +binexec(char *diffprog, char *f1, char *f2) +{ + + char *args[] = {diffprog, f1, f2, (char *) 0}; + + execv(diffprog, args); + printf("Could not execute diff process.\n"); + exit(1); +} +/* + * Checks whether a file appears to be a text file. + */ +static int +istextfile(FILE *f) +{ + int i; + char ch; + + if (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); +} + /* * Prints an individual column (left or right), taking into account * that tabs are variable-width. Takes a string, the current column From owner-svn-soc-all@FreeBSD.ORG Sat Jul 28 19:02:58 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 87932106566C for ; Sat, 28 Jul 2012 19:02:56 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 28 Jul 2012 19:02:56 +0000 Date: Sat, 28 Jul 2012 19:02:56 +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: <20120728190256.87932106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239870 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport 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, 28 Jul 2012 19:02:58 -0000 Author: tzabal Date: Sat Jul 28 19:02:55 2012 New Revision: 239870 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239870 Log: Minor changes and fix a bug related with the XML file of a textdump. Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Sat Jul 28 16:30:50 2012 (r239869) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Sat Jul 28 19:02:55 2012 (r239870) @@ -175,23 +175,23 @@ echo "" >> ${data} echo "
" >> ${data} +echo "" >> ${data} +echo "${_email}" >> ${data} +echo "" >> ${data} + echo "" >> ${data} output=`file "${_dumpdir}/${_file}"` if echo "${output}" | grep 'POSIX tar archive' > /dev/null; then - type='textdump' + type='textdump' elif echo "${output}" | grep 'text' > /dev/null; then - type='vmcore' + type='vmcore' else - error 'Unknown type of debugging information.' - exit 1 + error 'Unknown type of debugging information.' + exit 1 fi echo "${type}" >> ${data} echo "" >> ${data} -echo "" >> ${data} -echo "${_email}" >> ${data} -echo "" >> ${data} - echo "
" >> ${data} echo "" >> ${data} @@ -283,14 +283,14 @@ if [ -f "${tmp_dir}/ddb.txt" ]; then flag='false' while read line; do - echo "${line}" | egrep '^.+> [a-z ]+$' > /dev/null + echo "${line}" | egrep '^.+> [a-z ]+$' > /dev/null if [ $? -eq 0 ]; then if [ "${flag}" == false ]; then flag='true' echo "" >> ${data} echo "" >> ${data} echo "${line}" | \ - sed -E 's/^.+> ([a-z ]+)$/\1/' >> ${data} + sed -E 's/^.+> ([a-z ]+)$/\1/' >> ${data} echo "" >> ${data} echo "" >> ${data} else @@ -299,7 +299,7 @@ echo "" >> ${data} echo "" >> ${data} echo "${line}" | \ - sed -E 's/^.+> ([a-z ]+)$/\1/' >> ${data} + sed -E 's/^.+> ([a-z ]+)$/\1/' >> ${data} echo "" >> ${data} echo "" >> ${data} fi From owner-svn-soc-all@FreeBSD.ORG Sat Jul 28 19:11: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 0BA28106566B for ; Sat, 28 Jul 2012 19:11:19 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 28 Jul 2012 19:11:19 +0000 Date: Sat, 28 Jul 2012 19:11:19 +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: <20120728191119.0BA28106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239871 - 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: Sat, 28 Jul 2012 19:11:21 -0000 Author: rudot Date: Sat Jul 28 19:11:18 2012 New Revision: 239871 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239871 Log: small improvments Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Sat Jul 28 19:02:55 2012 (r239870) +++ soc2012/rudot/sys/kern/kern_racct.c Sat Jul 28 19:11:18 2012 (r239871) @@ -66,6 +66,8 @@ FEATURE(racct, "Resource Accounting"); +#define RACCT_PCTCPU_IGNORE 1 + struct mtx racct_lock; MTX_SYSINIT(racct_lock, &racct_lock, "racct lock", MTX_DEF); @@ -928,6 +930,13 @@ PROC_LOCK_ASSERT(p, MA_OWNED); mtx_assert(&racct_lock, MA_OWNED); + /* + * Do not block kernel processes. Also do not block processes with + * low %cpu utilization to improve interactivity. + */ + if (((p->p_flag & (P_SYSTEM | P_KTHREAD)) != 0) || + (p->p_racct->r_resources[RACCT_PCTCPU] <= RACCT_PCTCPU_IGNORE)) + return; p->p_racct->r_pflags |= R_PCPUEXCEEDED; FOREACH_THREAD_IN_PROC(p, td) { From owner-svn-soc-all@FreeBSD.ORG Sat Jul 28 22:29: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 A3E84106564A for ; Sat, 28 Jul 2012 22:29:50 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 28 Jul 2012 22:29:50 +0000 Date: Sat, 28 Jul 2012 22:29:50 +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: <20120728222950.A3E84106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239878 - 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: Sat, 28 Jul 2012 22:29:52 -0000 Author: rudot Date: Sat Jul 28 22:29:49 2012 New Revision: 239878 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239878 Log: do not count cpu idlethread in the %cpu of the root user Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Sat Jul 28 21:59:12 2012 (r239877) +++ soc2012/rudot/sys/kern/kern_racct.c Sat Jul 28 22:29:49 2012 (r239878) @@ -288,6 +288,10 @@ #ifdef SCHED_4BSD fixpt_t pctcpu, pctcpu_next; #endif +#ifdef SMP + struct pcpu *pc; + u_int cpuid; +#endif fixpt_t p_pctcpu; struct thread *td; @@ -297,6 +301,16 @@ p_pctcpu = 0; FOREACH_THREAD_IN_PROC(p, td) { + 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; + } +#endif thread_lock(td); #ifdef SCHED_4BSD pctcpu = sched_pctcpu(td);