From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:07:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4994BD7D for ; Sun, 28 Jul 2013 09:07:09 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1CC66261A for ; Sun, 28 Jul 2013 09:07:09 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S978CM051149 for ; Sun, 28 Jul 2013 09:07:08 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S97846051132 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:07:08 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:07:08 GMT Message-Id: <201307280907.r6S97846051132@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255257 - soc2013/zcore/head/sys/amd64/vmm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 09:07:09 -0000 Author: zcore Date: Sun Jul 28 09:07:08 2013 New Revision: 255257 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255257 Log: add "or" emulation For example, orl $2, (%rdx) Modified: soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Modified: soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c ============================================================================== --- soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Sun Jul 28 07:58:34 2013 (r255256) +++ soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Sun Jul 28 09:07:08 2013 (r255257) @@ -60,6 +60,7 @@ VIE_OP_TYPE_NONE = 0, VIE_OP_TYPE_MOV, VIE_OP_TYPE_AND, + VIE_OP_TYPE_OR, VIE_OP_TYPE_LAST }; @@ -94,7 +95,12 @@ .op_byte = 0x81, .op_type = VIE_OP_TYPE_AND, .op_flags = VIE_OP_F_IMM, - } + }, + [0x83] = { + .op_byte = 0x83, + .op_type = VIE_OP_TYPE_OR, + .op_flags = VIE_OP_F_IMM8, + }, }; /* struct vie.mod */ @@ -371,6 +377,52 @@ return (error); } +static int +emulate_or(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, + mem_region_read_t memread, mem_region_write_t memwrite, void *arg) +{ + int error, size; + uint64_t val1; + + size = 4; + error = EINVAL; + + switch (vie->op.op_byte) { + case 0x83: + /* + * OR reg (ModRM:reg) with immediate and store the + * result in reg + * + * 83/ OR r/m32, imm32 + * REX.W + 83/ OR r/m64, imm32 sign-extended to 64 + * + * Currently, only the OR operation of the 0x83 opcode + * is implemented (ModRM:reg = b100). + */ + if ((vie->reg & 7) != 4) + break; + + if (vie->rex_w) + size = 8; + + /* get the first operand */ + error = memread(vm, vcpuid, gpa, &val1, size, arg); + if (error) + break; + + /* + * perform the operation with the pre-fetched immediate + * operand and write the result + */ + val1 |= vie->immediate; + error = memwrite(vm, vcpuid, gpa, val1, size, arg); + break; + default: + break; + } + return (error); +} + int vmm_emulate_instruction(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, mem_region_read_t memread, mem_region_write_t memwrite, @@ -390,6 +442,10 @@ error = emulate_and(vm, vcpuid, gpa, vie, memread, memwrite, memarg); break; + case VIE_OP_TYPE_OR: + error = emulate_or(vm, vcpuid, gpa, vie, + memread, memwrite, memarg); + break; default: error = EINVAL; break; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:08:31 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 68227DA0 for ; Sun, 28 Jul 2013 09:08:31 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 54A862622 for ; Sun, 28 Jul 2013 09:08:31 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S98VB0089545 for ; Sun, 28 Jul 2013 09:08:31 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S98VAK089534 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:08:31 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:08:31 GMT Message-Id: <201307280908.r6S98VAK089534@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255258 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 09:08:31 -0000 Author: zcore Date: Sun Jul 28 09:08:31 2013 New Revision: 255258 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255258 Log: add reset and interrupt support Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:07:08 2013 (r255257) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:08:31 2013 (r255258) @@ -127,6 +127,27 @@ }; /* + * generate HBA intr depending on whether or not ports within + * the controller have an interrupt pending. + */ +static void +ahci_generate_intr(struct pci_ahci_softc *sc) +{ + int i; + + for (i = 0; i < sc->ports; i++) { + struct ahci_port *pr; + pr = &sc->port[i]; + if (pr->is & pr->ie) + sc->is |= (1 << i); + } + + DPRINTF(("%s %x\n", __func__, sc->is)); + if (sc->is && (sc->ghc & AHCI_GHC_IE)) + pci_generate_msi(sc->asc_pi, 0); +} + +/* * blockif callback routine - this runs in the context of the blockif * i/o thread, so the mutex needs to be acquired. */ @@ -146,6 +167,7 @@ /* TODO */ + ahci_generate_intr(sc); /* * Move the blockif request back to the free list */ @@ -154,7 +176,6 @@ pthread_mutex_unlock(&sc->mtx); DPRINTF(("%s exit\n", __func__)); - } static void @@ -180,6 +201,30 @@ } } +static void +ahci_port_reset(struct ahci_port *pr) +{ + memset(&pr->clb, 0, 17 * sizeof(uint32_t)); + pr->sig = 0xFFFFFFFF; + pr->tfd = 0x7F; + if (pr->bctx) + pr->ssts = ATA_SS_DET_PHY_ONLINE | ATA_SS_SPD_GEN2 | + ATA_SS_IPM_ACTIVE; + else + pr->ssts = ATA_SS_DET_NO_DEVICE; +} + +static void +ahci_reset(struct pci_ahci_softc *sc) +{ + int i; + + sc->ghc = AHCI_GHC_AE; + sc->is = 0; + for (i = 0; i < sc->ports; i++) + ahci_port_reset(&sc->port[i]); +} + static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { @@ -235,6 +280,7 @@ sc->pi = (1 << sc->ports) - 1; sc->vs = 0x10300; sc->cap2 = AHCI_CAP2_APST; + ahci_reset(sc); pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1c03); pci_set_cfgdata16(pi, PCIR_VENDOR, 0x8086); @@ -273,9 +319,11 @@ break; case AHCI_P_IS: p->is &= ~value; + ahci_generate_intr(sc); break; case AHCI_P_IE: - p->ie = value & 0xfdc000ff; + p->ie = value & 0xFDC000FF; + ahci_generate_intr(sc); break; case AHCI_P_CMD: /* TODO */ @@ -286,14 +334,20 @@ WPRINTF(("pci_ahci_port: read only registers 0x%lx\n", offset)); break; case AHCI_P_SCTL: - /* TODO */ + if (!(p->cmd & AHCI_P_CMD_ST)) { + if (value & ATA_SC_DET_RESET) + ahci_port_reset(p); + p->sctl = value; + } break; case AHCI_P_SERR: p->serr &= ~value; break; case AHCI_P_SACT: + p->sact |= value; break; case AHCI_P_CI: + p->ci |= value; /* TODO */ break; case AHCI_P_SNTF: @@ -316,6 +370,18 @@ case AHCI_CAP2: WPRINTF(("pci_ahci_host: read only registers 0x%lx\n", offset)); break; + case AHCI_GHC: + if (value & AHCI_GHC_HR) + ahci_reset(sc); + else if (value & AHCI_GHC_IE) { + sc->ghc |= AHCI_GHC_IE; + ahci_generate_intr(sc); + } + break; + case AHCI_IS: + sc->is &= ~value; + ahci_generate_intr(sc); + break; default: break; } @@ -396,6 +462,7 @@ case AHCI_P_SCTL: case AHCI_P_SERR: case AHCI_P_SACT: + /* TODO */ case AHCI_P_CI: case AHCI_P_SNTF: case AHCI_P_FBS: From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:09:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D43EEDB2 for ; Sun, 28 Jul 2013 09:09:18 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C084B2625 for ; Sun, 28 Jul 2013 09:09:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S99IKg011886 for ; Sun, 28 Jul 2013 09:09:18 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S99I8D011877 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:09:18 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:09:18 GMT Message-Id: <201307280909.r6S99I8D011877@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255259 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 09:09:18 -0000 Author: zcore Date: Sun Jul 28 09:09:18 2013 New Revision: 255259 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255259 Log: remove AHCI_CAP_EMS Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:08:31 2013 (r255258) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:09:18 2013 (r255259) @@ -275,8 +275,7 @@ AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| AHCI_CAP_PMD | AHCI_CAP_SSC | AHCI_CAP_PSC | - (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_EMS | - AHCI_CAP_SXS | (sc->ports - 1); + (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_SXS | (sc->ports - 1); sc->pi = (1 << sc->ports) - 1; sc->vs = 0x10300; sc->cap2 = AHCI_CAP2_APST; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:10:24 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 26D41DC9 for ; Sun, 28 Jul 2013 09:10:24 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EEECD2627 for ; Sun, 28 Jul 2013 09:10:23 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S9ANgN046989 for ; Sun, 28 Jul 2013 09:10:23 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S9AN8K046976 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:10:23 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:10:23 GMT Message-Id: <201307280910.r6S9AN8K046976@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255260 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 09:10:24 -0000 Author: zcore Date: Sun Jul 28 09:10:23 2013 New Revision: 255260 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255260 Log: add AHCI_P_CMD and AHCI_P_CI support Now, all registers seems supported Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:09:18 2013 (r255259) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:10:23 2013 (r255260) @@ -111,7 +111,6 @@ struct pci_devinst *asc_pi; pthread_mutex_t mtx; int ports; - int vbsc_lastq; uint32_t cap; uint32_t ghc; uint32_t is; @@ -206,7 +205,7 @@ { memset(&pr->clb, 0, 17 * sizeof(uint32_t)); pr->sig = 0xFFFFFFFF; - pr->tfd = 0x7F; + pr->tfd = 0; if (pr->bctx) pr->ssts = ATA_SS_DET_PHY_ONLINE | ATA_SS_SPD_GEN2 | ATA_SS_IPM_ACTIVE; @@ -225,6 +224,28 @@ ahci_port_reset(&sc->port[i]); } +static void +handle_slot(struct ahci_port *p, int slot) +{ + /* TODO */ +} + +static void +handle_cmd(struct ahci_port *p) +{ + int i; + + if (!(p->cmd & AHCI_P_CMD_ST) || !p->ci) + return; + + for (i = 0; (i < 32) && p->ci; i++) { + if (p->ci & (1 << i)) { + handle_slot(p, i); + p->ci &= ~(1 << i); + } + } +} + static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { @@ -325,7 +346,26 @@ ahci_generate_intr(sc); break; case AHCI_P_CMD: - /* TODO */ + p->cmd = value; + + if (!(value & AHCI_P_CMD_ST)) { + p->cmd &= ~(AHCI_P_CMD_CR | AHCI_P_CMD_CCS_MASK); + p->ci = 0; + p->sact = 0; + } else + p->cmd |= AHCI_P_CMD_CR; + + if (value & AHCI_P_CMD_FRE) + p->cmd |= AHCI_P_CMD_FR; + else + p->cmd &= ~AHCI_P_CMD_FR; + + if (value & AHCI_P_CMD_CLO) { + p->tfd = 0; + p->cmd &= ~AHCI_P_CMD_CLO; + } + + handle_cmd(p); break; case AHCI_P_TFD: case AHCI_P_SIG: @@ -347,7 +387,7 @@ break; case AHCI_P_CI: p->ci |= value; - /* TODO */ + handle_cmd(p); break; case AHCI_P_SNTF: case AHCI_P_FBS: From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:11:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E78EEDF4 for ; Sun, 28 Jul 2013 09:11:28 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D471A2635 for ; Sun, 28 Jul 2013 09:11:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S9BSLR083054 for ; Sun, 28 Jul 2013 09:11:28 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S9BSLJ083050 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:11:28 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:11:28 GMT Message-Id: <201307280911.r6S9BSLJ083050@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255261 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 09:11:29 -0000 Author: zcore Date: Sun Jul 28 09:11:28 2013 New Revision: 255261 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255261 Log: set AHCI_P_SIG to 0x00000101 a.k.a SIG_ATA This is just hard coding now. we will set the SIG depending on the device kind, ATA or ATAPI. Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:10:23 2013 (r255260) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 28 09:11:28 2013 (r255261) @@ -204,7 +204,8 @@ ahci_port_reset(struct ahci_port *pr) { memset(&pr->clb, 0, 17 * sizeof(uint32_t)); - pr->sig = 0xFFFFFFFF; + /* TODO set signature by the device kind */ + pr->sig = 0x00000101; pr->tfd = 0; if (pr->bctx) pr->ssts = ATA_SS_DET_PHY_ONLINE | ATA_SS_SPD_GEN2 | From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 13:56:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D3CA179E for ; Sun, 28 Jul 2013 13:56:59 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B1AF42D96 for ; Sun, 28 Jul 2013 13:56:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SDux4N054387 for ; Sun, 28 Jul 2013 13:56:59 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SDuxoa054382 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 13:56:59 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 28 Jul 2013 13:56:59 GMT Message-Id: <201307281356.r6SDuxoa054382@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255264 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 13:56:59 -0000 Author: mattbw Date: Sun Jul 28 13:56:59 2013 New Revision: 255264 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255264 Log: (untested) Add jobs.c features to add a full batch of PackageIDs to jobs. This will hopefully replace the jobs-from-query situation shortly, once the counterpart check-solution-for-PackageID-deficiencies comes along. Modified: soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sun Jul 28 12:29:10 2013 (r255263) +++ soc2013/mattbw/backend/jobs.c Sun Jul 28 13:56:59 2013 (r255264) @@ -21,6 +21,7 @@ /* Helpers for jobs that don't rely on the query system. */ #include /* assert */ +#include /* gchar, g_... */ #include /* bool, true, false */ #include "pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg_... */ @@ -30,24 +31,6 @@ #include "pkgutils.h" /* pkgutils_... */ #include "jobs.h" /* jobs_... */ -/* Emits each package queued up in a (solved) job. */ -void -jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, - pkg_info_ptr info) -{ - struct pkg *pkg; - - assert(jobs != NULL); - assert(backend != NULL); - assert(info != NULL); - - pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) { - assert(pkg != NULL); - pkgutils_emit(pkg, backend, info(pkg)); - } -} - /* Applies a job with the given error enums and the standard event callback. */ bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, @@ -71,3 +54,75 @@ return success; } + +/* Adds each PackageID into an already created job. Returns NULL on failure + * and a vector of added package name-versions to be freed after solution + * on success. + */ +char ** +jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids) +{ + bool success; + char **namevers; + guint count; + guint i; + + assert(jobs != NULL); + assert(package_ids != NULL); + + namevers = NULL; + success = false; + + count = g_strv_length(package_ids); + if (count == 0) + goto cleanup; + + /* Need to convert PackageIDs into name-version pairs. */ + namevers = calloc(count, sizeof(gchar *)); + if (namevers == NULL) + goto cleanup; + + for (i = 0; i < count; i++) { + namevers[i] = pkgutils_package_id_namever(package_ids[i]); + if (namevers[i] != NULL) + break; + } + + /* Make sure we successfully fished out every namever */ + if (i < count) + goto cleanup; + + if (pkg_jobs_add(jobs, MATCH_EXACT, namevers, (int)count) == EPKG_OK) + success = true; + +cleanup: + if (!success) { + if (namevers != NULL) { + for (i = 0; i < count; i++) + free(namevers[i]); + free(namevers); + } + namevers = NULL; + } + + return namevers; +} + +/* Emits each package queued up in a (solved) job. */ +void +jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, + pkg_info_ptr info) +{ + struct pkg *pkg; + + assert(jobs != NULL); + assert(backend != NULL); + assert(info != NULL); + + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) { + assert(pkg != NULL); + pkgutils_emit(pkg, backend, info(pkg)); + } +} + Modified: soc2013/mattbw/backend/jobs.h ============================================================================== --- soc2013/mattbw/backend/jobs.h Sun Jul 28 12:29:10 2013 (r255263) +++ soc2013/mattbw/backend/jobs.h Sun Jul 28 13:56:59 2013 (r255264) @@ -26,7 +26,8 @@ typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); -void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); -bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); +bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); +char **jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids); +void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); #endif /* !_PKGNG_BACKEND_JOBS_H_ */ Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sun Jul 28 12:29:10 2013 (r255263) +++ soc2013/mattbw/backend/pkgutils.c Sun Jul 28 13:56:59 2013 (r255264) @@ -101,6 +101,31 @@ } /* + * Allocates and returns a string of the form "name-version" that contains + * the name and version elements of a PackageID. + * + * To be freed using free(3). + */ +char * +pkgutils_package_id_namever(gchar *package_id) +{ + char *result; + gchar **id_splits; + + assert(package_id != NULL); + + id_splits = pk_package_id_split(package_id); + assert(id_splits != NULL); + + result = NULL; + asprintf(&result, "%s-%s", id_splits[PK_PACKAGE_ID_NAME], + id_splits[PK_PACKAGE_ID_VERSION]); + + g_strfreev(id_splits); + return result; +} + +/* * Allocates and returns a string of the form "name-version" that identifies * the given package's name and version. * Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sun Jul 28 12:29:10 2013 (r255263) +++ soc2013/mattbw/backend/pkgutils.h Sun Jul 28 13:56:59 2013 (r255264) @@ -24,10 +24,11 @@ #include #include "pk-backend.h" #include "pkg.h" - + PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); +char *pkgutils_package_id_namever(gchar *package_id); char *pkgutils_pkg_namever(struct pkg *pkg); const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 16:31:23 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0C6B392 for ; Sun, 28 Jul 2013 16:31:23 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DD208213D for ; Sun, 28 Jul 2013 16:31:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SGVMRK041135 for ; Sun, 28 Jul 2013 16:31:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SGVMAT041129 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 16:31:22 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 28 Jul 2013 16:31:22 GMT Message-Id: <201307281631.r6SGVMAT041129@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255265 - in soc2013/mattbw/backend: . query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 16:31:23 -0000 Author: mattbw Date: Sun Jul 28 16:31:22 2013 New Revision: 255265 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255265 Log: (*still untested*) Move ID-to-pkg match to pkgutils, implement job check. The checking of packages to see if they match PackageIDs is now in pkgutils.c as 'pkgutils_pkg_match_id'; the query system now uses this instead of doing its own check. Some very rough code in 'jobs.c' has been laid down for checking to see if packages added to a job match their PackageIDs. This needs to be checked for errors and also expanded so that other checks (for example, update status) can be added without significant overhead. Modified: soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/core.c Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sun Jul 28 13:56:59 2013 (r255264) +++ soc2013/mattbw/backend/jobs.c Sun Jul 28 16:31:22 2013 (r255265) @@ -23,6 +23,7 @@ #include /* assert */ #include /* gchar, g_... */ #include /* bool, true, false */ +#include /* strcmp */ #include "pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg_... */ @@ -55,6 +56,85 @@ return success; } +/* Checks a solved job against a string vector of PackageIDs to ensure any + * packages that match the PackageIDs match them fully. + */ +bool +jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids) +{ + bool success; + guint count; + guint i; + const char *name; + const char *version; + gchar *match_id; + struct pkg *pkg; + gchar ***id_splits; + + assert(jobs != NULL); + assert(package_ids != NULL); + + success = false; + pkg = NULL; + id_splits = NULL; + match_id = NULL; + + count = g_strv_length(package_ids); + if (count == 0) + goto cleanup; + + /* Split all the IDs first so we don't have to do it multiple times */ + id_splits = calloc(count, sizeof(gchar **)); + if (id_splits == NULL) + goto cleanup; + + for (i = 0; i < count; i++) { + id_splits[i] = pk_package_id_split(package_ids[i]); + if (id_splits[i] == NULL) + break; + } + + if (i < count) + goto cleanup; + + /* Now do the actual checking, per package. */ + success = true; + while (success && pkg_jobs(jobs, &pkg) == EPKG_OK) { + assert(pkg != NULL); + + name = version = NULL; + pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version); + + /* Does this package's name and version match a PackageID? */ + for (i = 0; i < count; i++) { + if ((strcmp(name, + id_splits[i][PK_PACKAGE_ID_NAME]) == 0) && + (strcmp(version, + id_splits[i][PK_PACKAGE_ID_VERSION]) == 0)) { + /* Does the rest of the PackageID match up? */ + match_id = pkgutils_pkg_match_id(pkg, + id_splits[i]); + + if (match_id == NULL) + success = false; + else + free(match_id); + } + } + } + +cleanup: + if (id_splits != NULL) { + for (i = 0; i < count; i++) + g_strfreev(id_splits[i]); + free(id_splits); + } + + /*pkg_free(pkg);*/ + + return success; +} + /* Adds each PackageID into an already created job. Returns NULL on failure * and a vector of added package name-versions to be freed after solution * on success. Modified: soc2013/mattbw/backend/jobs.h ============================================================================== --- soc2013/mattbw/backend/jobs.h Sun Jul 28 13:56:59 2013 (r255264) +++ soc2013/mattbw/backend/jobs.h Sun Jul 28 16:31:22 2013 (r255265) @@ -27,6 +27,7 @@ typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); +bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids); char **jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids); void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sun Jul 28 13:56:59 2013 (r255264) +++ soc2013/mattbw/backend/pkgutils.c Sun Jul 28 16:31:22 2013 (r255265) @@ -173,6 +173,61 @@ } /* + * Compares a package to a split PackageID; returns the package's canonical + * PackageID if they match and NULL otherwise. + */ +gchar * +pkgutils_pkg_match_id(struct pkg *pkg, gchar **split_id) +{ + bool success; + int i; + gchar *match_id; + const char **pkg_id_bits; + + assert(pkg != NULL); + assert(split_id != NULL); + assert(g_strv_length(split_id) == 4); + + success = false; + match_id = NULL; + + pkg_id_bits = calloc(4, sizeof(const char *)); + if (pkg_id_bits == NULL) + goto cleanup; + + match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); + if (match_id == NULL) + goto cleanup; + + /* + * Succeed if this package's PackageID fields match the + * original PackageID. Of course, the original ID might have + * missing fields (NULLs), so we treat a comparison involving + * one as a success. This means using our "weak strcmp" + * instead of normal strcmp or even g_strcmp0. + */ + for (success = true, i = PK_PACKAGE_ID_NAME; + success && i <= PK_PACKAGE_ID_DATA; + i++) + success = string_match(split_id[i], pkg_id_bits[i]); + +cleanup: + if (!success) { + if (match_id != NULL) { + g_free(match_id); + match_id = NULL; + } + } + assert (success || match_id == NULL); + assert (!success || match_id != NULL); + + /* The strings inside this are owned by 'pkg'. Don't free them */ + free(pkg_id_bits); + + return match_id; +} + +/* * Converts a package to a PackageID. */ gchar * Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sun Jul 28 13:56:59 2013 (r255264) +++ soc2013/mattbw/backend/pkgutils.h Sun Jul 28 16:31:22 2013 (r255265) @@ -24,13 +24,14 @@ #include #include "pk-backend.h" #include "pkg.h" - + PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); char *pkgutils_package_id_namever(gchar *package_id); char *pkgutils_pkg_namever(struct pkg *pkg); const char *pkgutils_pk_repo_of(struct pkg *pkg); +gchar *pkgutils_pkg_match_id(struct pkg *pkg, gchar **split_id); gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p); Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Sun Jul 28 13:56:59 2013 (r255264) +++ soc2013/mattbw/backend/query/core.c Sun Jul 28 16:31:22 2013 (r255265) @@ -346,42 +346,19 @@ static gchar * match_pkg(struct pkg *pkg, struct query *q) { - bool matches; - int i; gchar *match_id; - const char **pkg_id_bits; assert(pkg != NULL); assert(q != NULL); - pkg_id_bits = calloc(4, sizeof(const char *)); - match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); /* No need to do a PackageID match if we're looking for a name. */ if (q->s->type == QUERY_SINGLE_NAME) - matches = true; - else { - /* - * Succeed if this package's PackageID fields match the - * original PackageID. Of course, the original ID might have - * missing fields (NULLs), so we treat a comparison involving - * one as a success. This means using our "weak strcmp" - * instead of normal strcmp or even g_strcmp0. - */ - for (matches = true, i = PK_PACKAGE_ID_NAME; - matches && i <= PK_PACKAGE_ID_DATA; - i++) - matches = string_match((q->id_strv)[i], - pkg_id_bits[i]); - } + match_id = pkgutils_pkg_to_id(pkg); + else + match_id = pkgutils_pkg_match_id(pkg, q->id_strv); - free(pkg_id_bits); - - if (matches == false) { - g_free(match_id); - match_id = NULL; - } return match_id; } From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 16:51:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 304A379F for ; Sun, 28 Jul 2013 16:51:47 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1BBD521DB for ; Sun, 28 Jul 2013 16:51:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SGpk6B041946 for ; Sun, 28 Jul 2013 16:51:46 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SGpkd7041939 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 16:51:46 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 28 Jul 2013 16:51:46 GMT Message-Id: <201307281651.r6SGpkd7041939@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255266 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 16:51:47 -0000 Author: mattbw Date: Sun Jul 28 16:51:46 2013 New Revision: 255266 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255266 Log: Allow rejecting non-update packages at the jobs level. This is intended to be used for UpdatePackages and is a bolt-on addition to the jobs PackageID check, for now at least. Modified: soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sun Jul 28 16:31:22 2013 (r255265) +++ soc2013/mattbw/backend/jobs.c Sun Jul 28 16:51:46 2013 (r255266) @@ -60,7 +60,8 @@ * packages that match the PackageIDs match them fully. */ bool -jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids) +jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, + bool reject_non_updates) { bool success; guint count; @@ -120,6 +121,10 @@ else free(match_id); } + + if (success && reject_non_updates && + pkgutils_pkg_install_state(pkg) != PK_INFO_ENUM_UPDATING) + success = false; } } Modified: soc2013/mattbw/backend/jobs.h ============================================================================== --- soc2013/mattbw/backend/jobs.h Sun Jul 28 16:31:22 2013 (r255265) +++ soc2013/mattbw/backend/jobs.h Sun Jul 28 16:51:46 2013 (r255266) @@ -27,7 +27,7 @@ typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); -bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids); +bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, bool reject_non_updates); char **jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids); void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 17:24:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 040EBF3B for ; Sun, 28 Jul 2013 17:24:12 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E44C622A3 for ; Sun, 28 Jul 2013 17:24:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SHOB14088357 for ; Sun, 28 Jul 2013 17:24:11 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SHOBQ6088349 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 17:24:11 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 28 Jul 2013 17:24:11 GMT Message-Id: <201307281724.r6SHOBQ6088349@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255269 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 17:24:12 -0000 Author: bguan Date: Sun Jul 28 17:24:11 2013 New Revision: 255269 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255269 Log: debug method usbfront_connect() in usbfront Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Sun Jul 28 16:56:31 2013 (r255268) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Sun Jul 28 17:24:11 2013 (r255269) @@ -88,7 +88,14 @@ static int usbfront_detach(device_t dev); static int usbfront_suspend(device_t dev); static int usbfront_resume(device_t dev); +static int talk_to_backend(device_t dev, struct xenhci_softc *sc); +static int setup_rings(device_t dev, struct xenhci_softc *sc); +static void destroy_rings(struct xenhci_softc *sc); +static void xenhci_notify_work(struct xenhci_softc *sc); +static void xu_intr(void *xsc); +static int usbfront_connect(device_t dev); +#define virt_to_mfn(x) (vtomach(x) >> PAGE_SHIFT) /** * Entry point to this code when a new device is created. Allocate the basic @@ -168,6 +175,9 @@ printf("[gbdebug-pvusb]device_add_child() done!\n"); device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + /* usbfront IO lock TODO?? */ + mtx_init(&sc->lock, "usbfront i/o lock", NULL, MTX_DEF); + /* xen shared ring related stuff*/ err = xs_scanf(XST_NIL, backend_path, "num-ports", NULL, "%d", &num_ports); if (err) { @@ -234,8 +244,9 @@ { printf("[gbdebug-pvusb]usbfront_detach\n"); - //struct xenhci_softc *sc = device_get_softc(dev); + struct xenhci_softc *sc = device_get_softc(dev); + mtx_destroy(&sc->lock); DPRINTK("usbfront_remove: %s removed\n", xenbus_get_node(dev)); //TODO @@ -245,6 +256,59 @@ return 0; } + +static int +usbfront_connect(device_t dev) +{ + struct xenhci_softc *sc = device_get_softc(dev); + //struct usbfront_info *info = dev->dev.driver_data; + + usbif_conn_request_t *req; + int i, idx, err; + int notify; + //char name[TASK_COMM_LEN]; + //struct usb_hcd *hcd; + + //hcd = info_to_hcd(info); + //snprintf(name, TASK_COMM_LEN, "xenhcd.%d", sc->sc_bus.busnum); + + err = talk_to_backend(dev, sc); + if (err) + return err; + + //sc->kthread = kthread_run(xenhcd_schedule, sc, name); + //if (IS_ERR(sc->kthread)) { + // err = PTR_ERR(sc->kthread); + // sc->kthread = NULL; + // xenbus_dev_fatal(dev, err, "Error creating thread"); + // return err; + //} + + /* prepare ring for hotplug notification */ + for (idx = 0, i = 0; i < USB_CONN_RING_SIZE; i++) { + req = RING_GET_REQUEST(&sc->conn_ring, idx); + req->id = idx; + idx++; + } + sc->conn_ring.req_prod_pvt = idx; + + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&sc->conn_ring, notify); + if (notify) + notify_remote_via_irq(sc->irq); + + return 0; +} + +static void +usbfront_disconnect(device_t dev) +{ + xenbus_set_state(dev, XenbusStateClosing); + + DPRINTK("xusb_closing: %s removed\n", xenbus_get_node(dev)); + + xenbus_set_state(dev, XenbusStateClosed); +} + /** * Callback received when the backend's state changes. */ @@ -258,39 +322,204 @@ //DPRINTK("backend_state=%d\n", backend_state); switch (backend_state) { - case XenbusStateUnknown: + case XenbusStateInitialised: case XenbusStateInitialising: + case XenbusStateConnected: case XenbusStateReconfigured: case XenbusStateReconfiguring: + case XenbusStateUnknown: case XenbusStateClosed: break; case XenbusStateInitWait: - case XenbusStateInitialised: - //TODO - //usbfront_initialize(sc); - printf("[gbdebug-pvusb]usbfront_backend_changed: initialize(sc)\n"); + printf("[gbdebug-pvusb]usbfront_backend_changed: XenbusStateInitWait\n"); + if (xenbus_get_state(dev) != XenbusStateInitialising) + break; + //if (usbfront_connect(sc) != 0) + if (usbfront_connect(dev) != 0) { + printf("[gbdebug-pvusb]usbfront_connect(dev) error.\n"); + break; + } + xenbus_set_state(dev, XenbusStateConnected); //??? + printf("[gbdebug-pvusb]xenbus_set_state finished!\n"); break; - case XenbusStateConnected: - //TODO - //usbfront_initialize(sc); - //usbfront_connect(sc); - printf("[gbdebug-pvusb]usbfront_backend_changed: initialize(sc);connect(sc)\n"); + case XenbusStateClosing: + usbfront_disconnect(dev); break; - case XenbusStateClosing: - //if (sc->users > 0) { - // xenbus_dev_error(dev, -EBUSY, "Device in use; refusing to close"); - //} else { - //TODO - //usbfront_closing(dev); - printf("[gbdebug-pvusb]usbfront_backend_changed: closing(dev)\n"); - //} - break; + default: + xenbus_dev_fatal(dev, EINVAL, "get state %d at usb frontend", + backend_state); + break; } + printf("[gbdebug-pvusb]usbfront_backend_changed finished!\n"); } +/* Common code used when first setting up, and when resuming. */ +static int +talk_to_backend(device_t dev, struct xenhci_softc *sc) +{ + const char *message; + struct xs_transaction xst; + const char *node = xenbus_get_node(dev); + int err; + + printf("[gbdebug-pvusb]takl_to_backend()\n"); + /* Create shared ring, alloc event channel. */ + err = setup_rings(dev, sc); + if (err) + goto out; + +again: + err = xs_transaction_start(&xst); + if (err) { + xenbus_dev_fatal(dev, err, "starting transaction"); + goto destroy_ring; + } + + err = xs_printf(xst, node, "urb-ring-ref", "%u", + sc->urb_ring_ref); + if (err) { + message = "writing urb-ring-ref"; + goto abort_transaction; + } + + err = xs_printf(xst, node, "conn-ring-ref", "%u", + sc->conn_ring_ref); + if (err) { + message = "writing conn-ring-ref"; + goto abort_transaction; + } + + err = xs_printf(xst, node, "event-channel", "%u", + irq_to_evtchn_port(sc->irq)); + if (err) { + message = "writing event-channel"; + goto abort_transaction; + } + + err = xs_transaction_end(xst, 0); + if (err) { + if (err == EAGAIN) + goto again; + xenbus_dev_fatal(dev, err, "completing transaction"); + goto destroy_ring; + } + + return 0; + +abort_transaction: + xs_transaction_end(xst, 1); + xenbus_dev_fatal(dev, err, "%s", message); + +destroy_ring: + destroy_rings(sc); + +out: + return err; +} + +static void +destroy_rings(struct xenhci_softc *sc) +{ + if (sc->irq) + unbind_from_irqhandler(sc->irq); + sc->irq = 0; + + if (sc->urb_ring_ref != GRANT_INVALID_REF) { + /* This API frees the associated ??TODO. */ + gnttab_end_foreign_access(sc->urb_ring_ref, + (void *)sc->urb_ring.sring); + sc->urb_ring_ref = GRANT_INVALID_REF; + } + sc->urb_ring.sring = NULL; + + if (sc->conn_ring_ref != GRANT_INVALID_REF) { + gnttab_end_foreign_access(sc->conn_ring_ref, + (void *)sc->conn_ring.sring); + sc->conn_ring_ref = GRANT_INVALID_REF; + } + sc->conn_ring.sring = NULL; +} + +/* Create shared ring, alloc event channel. */ +static int +setup_rings(device_t dev, struct xenhci_softc *sc) +{ + usbif_urb_sring_t *urb_sring; + usbif_conn_sring_t *conn_sring; + int otherend_id = 0; + int err; + + printf("[gbdebug-pvusb]setup_rings()\n"); + sc->urb_ring_ref = GRANT_INVALID_REF; + sc->conn_ring_ref = GRANT_INVALID_REF; + + //urb_sring = (usbif_urb_sring_t *)get_zeroed_page(GFP_NOIO|__GFP_HIGH); + urb_sring = (usbif_urb_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); + if (!urb_sring) { + xenbus_dev_fatal(dev, ENOMEM, "allocating urb ring"); + return ENOMEM; + } + SHARED_RING_INIT(urb_sring); + FRONT_RING_INIT(&sc->urb_ring, urb_sring, PAGE_SIZE); + + err = xenbus_grant_ring(dev, virt_to_mfn(urb_sring), &sc->urb_ring_ref); + if (err < 0) { + //free_page((unsigned long)urb_sring);//TODO + //sc->urb_ring.sring = NULL; + goto fail; + } + sc->urb_ring_ref = err; + + //conn_sring = (usbif_conn_sring_t *)get_zeroed_page(GFP_NOIO|__GFP_HIGH); + conn_sring = (usbif_conn_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); + if (!conn_sring) { + xenbus_dev_fatal(dev, ENOMEM, "allocating conn ring"); + return ENOMEM; + } + SHARED_RING_INIT(conn_sring); + FRONT_RING_INIT(&sc->conn_ring, conn_sring, PAGE_SIZE); + + err = xenbus_grant_ring(dev, virt_to_mfn(conn_sring), &sc->conn_ring_ref); + if (err < 0) { + //free_page((unsigned long)conn_sring);//TODO + //sc->conn_ring.sring = NULL; + goto fail; + } + sc->conn_ring_ref = err; + + otherend_id = xenbus_get_otherend_id(dev); + err = bind_listening_port_to_irqhandler(otherend_id, "xu", xu_intr, + sc, INTR_TYPE_BIO | INTR_MPSAFE, &sc->irq); + if (err <= 0) { + xenbus_dev_fatal(dev, err, + "bind_listening_port_to_irqhandler"); + goto fail; + } + sc->irq = err; + + return 0; +fail: + destroy_rings(sc); + return err; +} + +static void +xenhci_notify_work(struct xenhci_softc *sc) +{ + sc->waiting_resp = 1; + wakeup(&sc->wait_taskqueue); +} + +static void +xu_intr(void *xsc) +{ + struct xenhci_softc *sc = xsc; + xenhci_notify_work(sc); +} + /* ** Driver registration ** */ static device_method_t usbfront_methods[] = { From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 17:24:24 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A5E59F4B for ; Sun, 28 Jul 2013 17:24:24 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 78D9F22A4 for ; Sun, 28 Jul 2013 17:24:24 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SHOO85090788 for ; Sun, 28 Jul 2013 17:24:24 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SHOOPk090782 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 17:24:24 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 28 Jul 2013 17:24:24 GMT Message-Id: <201307281724.r6SHOOPk090782@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255270 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 17:24:24 -0000 Author: bguan Date: Sun Jul 28 17:24:24 2013 New Revision: 255270 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255270 Log: add struct mtx for usbfront Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Sun Jul 28 17:24:11 2013 (r255269) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Sun Jul 28 17:24:24 2013 (r255270) @@ -35,6 +35,13 @@ #define XENHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) +#define XENHCI_PAGE_SIZE 4096 /* bytes */ + +//#define TASK_COMM_LEN 16 /* Task command name length */ + +#define GRANT_INVALID_REF 0 + + /* USB ports. This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. @@ -50,6 +57,7 @@ #endif #define USB_URB_RING_SIZE __RING_SIZE((usbif_urb_sring_t *)0, PAGE_SIZE) +#define USB_CONN_RING_SIZE __RING_SIZE((usbif_conn_sring_t *)0, PAGE_SIZE) LIST_HEAD(list_head, list_head); @@ -74,7 +82,24 @@ enum usb_dev_speed speed; }; +/* + The "hardware" in Xen host controller is the shared ring to + the backend driver and the data you can send and receive across it +*/ +//struct xenhci_hw_softc { + //struct usb_page_cache root_pc; + //struct usb_page_cache ctx_pc; + //struct usb_page_cache scratch_pc[XHCI_MAX_SCRATCHPADS]; + + //struct usb_page root_pg; + //struct usb_page ctx_pg; + //struct usb_page scratch_pg[XHCI_MAX_SCRATCHPADS]; + + //struct xhci_hw_dev devs[XHCI_MAX_DEVICES + 1]; +//}; + struct xenhci_softc { + //struct xenhci_hw_softc sc_hw; /* base device */ struct usb_bus sc_bus; /* configure message */ @@ -90,7 +115,7 @@ LIST_ENTRY(list_head) in_progress_list; //?? LIST_ENTRY(list_head) giveback_waiting_list; //?? - //spinlock_t lock; + struct mtx lock; //spinlock_t lock; /* timer that kick pending and giveback waiting urbs */ //struct timer_list watchdog;//?? @@ -115,8 +140,9 @@ unsigned long shadow_free; /* ring response thread */ - struct task *ringthread;//struct task_struct *kthread; - LIST_ENTRY(list_head) *wait_list; //wait_queue_head_t wq;?? + struct task *kthread;//struct task_struct *kthread; + //LIST_ENTRY(list_head) *wait_list; //wait_queue_head_t wq;?? + struct taskqueue *wait_taskqueue; unsigned int waiting_resp;// }; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 17:24:37 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8A6A39C for ; Sun, 28 Jul 2013 17:24:37 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 76C3E22AC for ; Sun, 28 Jul 2013 17:24:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SHObmm093413 for ; Sun, 28 Jul 2013 17:24:37 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SHObYr093408 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 17:24:37 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 28 Jul 2013 17:24:37 GMT Message-Id: <201307281724.r6SHObYr093408@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255271 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 17:24:37 -0000 Author: bguan Date: Sun Jul 28 17:24:37 2013 New Revision: 255271 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255271 Log: more initalization for usbfront driver Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 28 17:24:24 2013 (r255270) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 28 17:24:37 2013 (r255271) @@ -51,7 +51,7 @@ #include #include -//#define USB_DEBUG_VAR xhcidebug +#define USB_DEBUG_VAR xenhcidebug #include #include @@ -68,8 +68,49 @@ #include +#define XENHCI_BUS2SC(bus) \ + ((struct xenhci_softc *)(((uint8_t *)(bus)) - \ + ((uint8_t *)&(((struct xenhci_softc *)0)->sc_bus)))) + +#ifdef USB_DEBUG +static int xenhcidebug; +static int xenhciroute; +static int xenhcipolling; + +static SYSCTL_NODE(_hw_usb, OID_AUTO, xenhci, CTLFLAG_RW, 0, "USB XENHCI"); +SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, + &xenhcidebug, 0, "Debug level"); +TUNABLE_INT("hw.usb.xenhci.debug", &xenhcidebug); +SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, xenhci_port_route, CTLFLAG_RW | CTLFLAG_TUN, + &xenhciroute, 0, "Routing bitmap for switching EHCI ports to XENHCI controller"); +TUNABLE_INT("hw.usb.xenhci.xenhci_port_route", &xenhciroute); +SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, use_polling, CTLFLAG_RW | CTLFLAG_TUN, + &xenhcipolling, 0, "Set to enable software interrupt polling for XENHCI controller"); +TUNABLE_INT("hw.usb.xenhci.use_polling", &xenhcipolling); +#endif + extern struct usb_bus_methods xenhci_bus_methods; + +/* +static void +xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) +{ + struct xhci_softc *sc = XENHCI_BUS2SC(bus); + uint8_t i; + + cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg, + sizeof(struct xhci_hw_root), XENHCI_PAGE_SIZE); + + cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg, + sizeof(struct xhci_dev_ctx_addr), XENHCI_PAGE_SIZE); + + for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) { + cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i], + XENHCI_PAGE_SIZE, XENHCI_PAGE_SIZE); + } +}*/ + usb_error_t xenhci_init(struct xenhci_softc *sc, device_t dev) { @@ -83,6 +124,14 @@ sc->sc_bus.devices = sc->sc_devices; sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + /* get all DMA memory */ + //if (usb_bus_mem_alloc_all(&sc->sc_bus, + // USB_GET_DMA_TAG(dev), &xenhci_iterate_hw_softc)) { + if (usb_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(dev), NULL)) { + return (ENOMEM); + } + return (0); } @@ -105,9 +154,6 @@ xenhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address) { printf("[gbtest-pv]xenhci.c: xenhci_set_address()\n"); - //usb_error_t err; - - //return (err); //TODO return (0); } @@ -132,42 +178,67 @@ static void xenhci_xfer_setup(struct usb_setup_params *parm) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_xfer_setup()\n"); //TODO } static void xenhci_xfer_unsetup(struct usb_xfer *xfer) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_xfer_unsetup()\n"); return; } static void xenhci_start_dma_delay(struct usb_xfer *xfer) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_start_dma_delay()\n"); //TODO } + +//TODO ??? static void xenhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_ep_init()\n"); + + //struct xhci_endpoint_ext *pepext; + + DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n", + ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode); + + printf("[gb-test]endpoint=%p, addr=%d, endpt=%d, mode=%d\n", + ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode); + if (udev->parent_hub == NULL) { + /* root HUB has special endpoint handling */ + printf("[gb-test]xenhci.c: xenhci_ep_init():udev->parent_hub == NULL\n"); + return; + } + + //ep->methods = &xhci_device_generic_methods; + + //pepext = xhci_get_endpoint_ext(udev, edesc); + + //USB_BUS_LOCK(udev->bus); + //pepext->trb_halted = 1; + //pepext->trb_running = 0; + //USB_BUS_UNLOCK(udev->bus); + //TODO } static void xenhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_ep_uninit()\n"); } static void xenhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) { - printf("[gbtest-pv]xenhci.c: ()\n"); + printf("[gbtest-pv]xenhci.c: xenhci_ep_clear_stal()\n"); //TODO } @@ -179,7 +250,7 @@ //uint8_t temp; //return (err); - //TODO + //TODO or not?? return (0); } @@ -211,18 +282,59 @@ //TODO } +//DONE! static void xenhci_set_hw_power(struct usb_bus *bus) { printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power()\n"); //DPRINTF("\n"); - //TODO?? } +//TODO or not ?? static void xenhci_device_state_change(struct usb_device *udev) { + //struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); + //struct usb_page_search buf_inp; + //usb_error_t err; + //uint8_t index; + printf("[gbtest-pv]xenhci.c: xenhci_device_state_change()\n"); + + /* check for root HUB */ + if (udev->parent_hub == NULL) { + printf("[gb-test]xenhci.c: xenhci_device_state_change(): udev->parent_hub == NULL\n"); + return; + } + + //index = udev->controller_slot_id; + + //DPRINTF("\n"); + + if (usb_get_device_state(udev) == USB_STATE_CONFIGURED) { + printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n"); + } + + //XHCI_CMD_LOCK(sc); + + switch (usb_get_device_state(udev)) { + case USB_STATE_POWERED: + printf("[gb-test]state(udev) == USB_STATE_POWERED\n"); + break; + + case USB_STATE_ADDRESSED: + printf("[gb-test]state(udev) == USB_STATE_ADDRESSED\n"); + break; + + case USB_STATE_CONFIGURED: + printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n"); + break; + + default: + printf("[gb-test]state(udev) == other!!\n"); + break; + } + //XHCI_CMD_UNLOCK(sc); //TODO } From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 17:49:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CBB738B6 for ; Sun, 28 Jul 2013 17:49:06 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9E7752378 for ; Sun, 28 Jul 2013 17:49:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SHn68r072553 for ; Sun, 28 Jul 2013 17:49:06 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SHn6sq072534 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 17:49:06 GMT (envelope-from def@FreeBSD.org) Date: Sun, 28 Jul 2013 17:49:06 GMT Message-Id: <201307281749.r6SHn6sq072534@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255272 - in soc2013/def/crashdump-head: sbin/savecore sys/kern sys/sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 17:49:07 -0000 Author: def Date: Sun Jul 28 17:49:06 2013 New Revision: 255272 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255272 Log: Save a decrypted crash dump using funopen(3). Encrypt with offset set to 0 in the beginning. Added: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile soc2013/def/crashdump-head/sbin/savecore/savecore.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/Makefile Sun Jul 28 17:24:37 2013 (r255271) +++ soc2013/def/crashdump-head/sbin/savecore/Makefile Sun Jul 28 17:49:06 2013 (r255272) @@ -4,7 +4,7 @@ .PATH: ${SYS}/crypto/camellia ${SYS}/crypto/rijndael ${SYS}/crypto PROG= savecore -SRCS= ${PROG}.c +SRCS= ${PROG}.c decryptfile.c SRCS+= rijndael-api.c rijndael-api-fst.c rijndael-alg-fst.c SRCS+= camellia.c SRCS+= xts.c Added: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Sun Jul 28 17:49:06 2013 (r255272) @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include "decryptfile.h" + +int +dwrite(void *cookie, const char *data, int size) +{ + decFile *fd = (decFile *)cookie; + int resid, saved; + + saved = 0; + + while (size + fd->buf_used >= PEFS_SECTOR_SIZE) { + resid = PEFS_SECTOR_SIZE - fd->buf_used; + memcpy(fd->buf + fd->buf_used, data, resid); + fd->buf_used += resid; + + xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx, + fd->offset, fd->tweak, PEFS_SECTOR_SIZE, + fd->buf, fd->buf); + + if (fwrite(fd->buf, 1, PEFS_SECTOR_SIZE, fd->fp) != PEFS_SECTOR_SIZE) + return (0); + + data += resid; + size -= resid; + fd->buf_used = 0; + fd->offset += PEFS_SECTOR_SIZE; + saved += resid; + } + + if (size > 0) { + memcpy(fd->buf + fd->buf_used, data, size); + fd->buf_used += size; + saved += size; + } + + return (saved); +} + +FILE * +dopen(const char *fname, const char *mode, const struct kerneldumpheader *h) +{ + decFile *fd; + FILE *fp; + + /* Currently other modes are not implemented. */ + if (*mode != 'w') + return (NULL); + + fp = fopen(fname, mode); + + if (fp == NULL) + return (NULL); + + fd = (decFile *)malloc(sizeof(decFile)); + fd->fp = fp; + fd->keysize = h->keysize; + memcpy(fd->key, h->key, KERNELDUMP_KEY_SIZE); + fd->tweaksize = h->tweaksize; + memcpy(fd->tweak, h->tweak, KERNELDUMP_TWEAK_SIZE); + fd->offset = 0; + fd->buf_used = 0; + + rijndael_set_key(&fd->tweak_ctx, fd->key, fd->keysize << 3); + rijndael_set_key(&fd->data_ctx, fd->key, fd->keysize << 3); + + return (funopen(fd, NULL, dwrite, NULL, dclose)); +} + +int +dclose(void *cookie) +{ + decFile *fd = (decFile *)cookie; + int error; + + if (fd->buf_used > 0) { + xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx, + fd->offset, fd->tweak, fd->buf_used, + fd->buf, fd->buf); + + if (fwrite(fd->buf, 1, fd->buf_used, fd->fp) != 1) + return (0); + + fd->offset += fd->buf_used; + fd->buf_used = 0; + } + + error = fclose(fd->fp); + + if (error < 0) + return (error); + + free(fd); + + return (error); +} Added: soc2013/def/crashdump-head/sbin/savecore/decryptfile.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Sun Jul 28 17:49:06 2013 (r255272) @@ -0,0 +1,25 @@ +#ifndef _FILEDECRYPT_H +#define _FILEDECRYPT_H + +#include +#include + +typedef struct _decFile { + FILE *fp; + int keysize; + char key[KERNELDUMP_KEY_SIZE]; + int tweaksize; + char tweak[KERNELDUMP_TWEAK_SIZE]; + rijndael_ctx tweak_ctx; + rijndael_ctx data_ctx; + off_t offset; +#define PEFS_SECTOR_SIZE 4096 + char buf[PEFS_SECTOR_SIZE]; + int buf_used; +} decFile; + +int dwrite(void *cookie, const char *data, int size); +FILE *dopen(const char *fname, const char *mode, const struct kerneldumpheader *h); +int dclose(void *cookie); + +#endif /* _FILEDECRYPT_H */ Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jul 28 17:24:37 2013 (r255271) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jul 28 17:49:06 2013 (r255272) @@ -68,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -81,6 +80,7 @@ #include #include #include +#include "decryptfile.h" /* The size of the buffer used for I/O. */ #define BUFFERSIZE (1024*1024) @@ -89,7 +89,7 @@ #define STATUS_GOOD 1 #define STATUS_UNKNOWN 2 -static int checkfor, compress, clear, force, keep, verbose; /* flags */ +static int checkfor, compress, clear, decrypt, force, keep, verbose; /* flags */ static int nfound, nsaved, nerr; /* statistics */ static int maxdumps; @@ -292,22 +292,16 @@ static int DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device, - const char *filename, FILE *fp, FILE *fp_enc, struct kerneldumpheader *kdh, - off_t offset) + const char *filename, FILE *fp) { int he, hs, nr, nw, wl; off_t dmpcnt, origsize; - rijndael_ctx tweak_ctx, data_ctx; - - rijndael_set_key(&tweak_ctx, kdh->key, kdh->keysize << 3); - rijndael_set_key(&data_ctx, kdh->key, kdh->keysize << 3); dmpcnt = 0; origsize = dumpsize; he = 0; while (dumpsize > 0) { - // wl = BUFFERSIZE; - wl = 512; + wl = BUFFERSIZE; if (wl > dumpsize) wl = dumpsize; nr = read(fd, buf, wl); @@ -322,6 +316,8 @@ } if (compress) { nw = fwrite(buf, 1, wl, fp); + } else if (decrypt) { + nw = fwrite(buf, 1, wl, fp); } else { for (nw = 0; nw < nr; nw = he) { /* find a contiguous block of zeroes */ @@ -352,18 +348,10 @@ * If hs > nw, buf[nw..hs] contains non-zero data. * If he > hs, buf[hs..he] is all zeroes. */ - if (hs > nw) { - if (fwrite(buf + nw, hs - nw, 1, fp_enc) - != 1) - break; - xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&tweak_ctx, (struct xts_ctx *)&data_ctx, - offset, kdh->tweak, hs - nw, - buf + nw, buf + nw); - offset += hs - nw; + if (hs > nw) if (fwrite(buf + nw, hs - nw, 1, fp) != 1) break; - } if (he > hs) if (fseeko(fp, he - hs, SEEK_CUR) == -1) break; @@ -447,12 +435,11 @@ static void DoFile(const char *savedir, const char *device) { - static char infoname[PATH_MAX], corename[PATH_MAX], - corename_enc[PATH_MAX], linkname[PATH_MAX]; + static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX]; static char *buf = NULL; struct kerneldumpheader kdhf, kdhl; off_t mediasize, dumpsize, firsthd, lasthd; - FILE *info, *fp, *fp_enc; + FILE *info, *fp; mode_t oumask; int fd, fdinfo, error; int bounds, status; @@ -645,15 +632,16 @@ snprintf(corename, sizeof(corename), "%s.%d.gz", istextdump ? "textdump.tar" : "vmcore", bounds); fp = zopen(corename, "w"); - } else { + } else if (decrypt) { snprintf(corename, sizeof(corename), "%s.%d", istextdump ? "textdump.tar" : "vmcore", bounds); - snprintf(corename_enc, sizeof(corename_enc), "%s_encrypted.%d", + fp = dopen(corename, "w", &kdhl); + } else { + snprintf(corename, sizeof(corename), "%s.%d", istextdump ? "textdump.tar" : "vmcore", bounds); fp = fopen(corename, "w"); - fp_enc = fopen(corename_enc, "w"); } - if (fp == NULL || fp_enc == NULL) { + if (fp == NULL) { syslog(LOG_ERR, "%s: %m", corename); close(fdinfo); nerr++; @@ -676,15 +664,14 @@ fclose(info); syslog(LOG_NOTICE, "writing %score to %s/%s", - compress ? "compressed " : "", savedir, corename); + compress ? "compressed " : (decrypt ? "decrypted " : ""), savedir, corename); if (istextdump) { if (DoTextdumpFile(fd, dumpsize, lasthd, buf, device, corename, fp) < 0) goto closeall; } else { - if (DoRegularFile(fd, dumpsize, buf, device, corename, - fp, fp_enc, &kdhl, firsthd + sizeof(kdhf)) + if (DoRegularFile(fd, dumpsize, buf, device, corename, fp) < 0) goto closeall; } @@ -697,12 +684,6 @@ goto closeall; } - if (fp_enc != NULL && fclose(fp_enc) < 0) { - syslog(LOG_ERR, "error on %s: %m", corename_enc); - nerr++; - goto closeall; - } - symlinks_remove(); if (symlink(infoname, "info.last") == -1) { syslog(LOG_WARNING, "unable to create symlink %s/%s: %m", @@ -711,6 +692,9 @@ if (compress) { snprintf(linkname, sizeof(linkname), "%s.last.gz", istextdump ? "textdump.tar" : "vmcore"); + } else if (decrypt) { + snprintf(linkname, sizeof(linkname), "%s.last", + istextdump ? "textdump.tar" : "vmcore"); } else { snprintf(linkname, sizeof(linkname), "%s.last", istextdump ? "textdump.tar" : "vmcore"); @@ -741,7 +725,6 @@ closeall: fclose(fp); - fclose(fp_enc); closefd: close(fd); @@ -753,7 +736,7 @@ fprintf(stderr, "%s\n%s\n%s\n", "usage: savecore -c [-v] [device ...]", " savecore -C [-v] [device ...]", - " savecore [-fkvz] [-m maxdumps] [directory [device ...]]"); + " savecore [-dfkvz] [-m maxdumps] [directory [device ...]]"); exit(1); } @@ -764,13 +747,13 @@ struct fstab *fsp; int i, ch, error; - checkfor = compress = clear = force = keep = verbose = 0; + checkfor = compress = clear = decrypt = force = keep = verbose = 0; nfound = nsaved = nerr = 0; openlog("savecore", LOG_PERROR, LOG_DAEMON); signal(SIGINFO, infohandler); - while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1) + while ((ch = getopt(argc, argv, "Ccdfkm:vz")) != -1) switch(ch) { case 'C': checkfor = 1; @@ -778,6 +761,9 @@ case 'c': clear = 1; break; + case 'd': + decrypt = 1; + break; case 'f': force = 1; break; Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jul 28 17:24:37 2013 (r255271) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jul 28 17:49:06 2013 (r255272) @@ -880,8 +880,9 @@ } /* Write kernel dump headers. */ - if (di->offset == 0 || offset == di->kdhoffset) { - di->offset = offset + length; + if (di->realoffset == 0 || offset == di->mediaoffset + di->mediasize - + sizeof(struct kerneldumpheader)) { + di->realoffset = offset + length; return (di->dumper(di->priv, virtual, physical, offset, length)); } @@ -890,28 +891,28 @@ xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, di->offset, di->tweak, di->buf_used, di->buf, di->buf); - return (di->dumper(di->priv, di->buf, physical, di->offset, di->buf_used)); + return (di->dumper(di->priv, di->buf, physical, di->realoffset, di->buf_used)); } - offset = di->offset; - - while (length + di->buf_used >= di->blocksize) { - resid = qmin(length, di->blocksize - di->buf_used); + while (length + di->buf_used >= DUMPER_BUFSIZE) { + resid = DUMPER_BUFSIZE - di->buf_used; memcpy(di->buf + di->buf_used, virtual, resid); di->buf_used += resid; + xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, - offset, di->tweak, di->blocksize, + di->offset, di->tweak, DUMPER_BUFSIZE, di->buf, di->buf); - error = (di->dumper(di->priv, di->buf, physical, offset, di->buf_used)); + + error = (di->dumper(di->priv, di->buf, physical, di->realoffset, DUMPER_BUFSIZE)); if (error) return (error); virtual = (void *)((char *)virtual + resid); - offset += resid; length -= resid; di->buf_used = 0; - di->offset = offset; + di->realoffset += resid; + di->offset += DUMPER_BUFSIZE; } /* We still have less than blocksize of data to dump. */ @@ -933,8 +934,8 @@ di->tweak_ctx = &dumper_tweak_ctx; di->data_ctx = &dumper_data_ctx; di->buf_used = 0; + di->realoffset = 0; di->offset = 0; - di->kdhoffset = 0; rijndael_set_key(di->tweak_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); rijndael_set_key(di->data_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); } @@ -961,6 +962,4 @@ kdh->tweaksize = KERNELDUMP_TWEAK_SIZE; strncpy(kdh->tweak, dumper.tweak, kdh->tweaksize); kdh->parity = kerneldump_parity(kdh); - - dumper.kdhoffset = dumper.mediaoffset + dumper.mediasize - sizeof(*kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Sun Jul 28 17:24:37 2013 (r255271) +++ soc2013/def/crashdump-head/sys/sys/conf.h Sun Jul 28 17:49:06 2013 (r255272) @@ -323,22 +323,23 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* Stuff relating to kernel-dump */ +#define DUMPER_BUFSIZE 4096 struct dumperinfo { - dumper_t *dumper; /* Dumping function. */ - void *priv; /* Private parts. */ - u_int blocksize; /* Size of block in bytes. */ - u_int maxiosize; /* Max size allowed for an individual I/O */ - off_t mediaoffset; /* Initial offset in bytes. */ - off_t mediasize; /* Space available in bytes. */ - char *key; /* Key information. */ - char *tweak; /* Tweak. */ - void *tweak_ctx; /* Tweak context. */ - void *data_ctx; /* Data context. */ - uint8_t buf[512]; /* Raw data buffer. */ - u_int buf_used; /* Number of bytes used in the buffer. */ - off_t offset; /* Last used offset in a dump_write call. */ - off_t kdhoffset; /* Offset of the second kernel dump header. */ + dumper_t *dumper; /* Dumping function. */ + void *priv; /* Private parts. */ + u_int blocksize; /* Size of block in bytes. */ + u_int maxiosize; /* Max size allowed for an individual I/O */ + off_t mediaoffset; /* Initial offset in bytes. */ + off_t mediasize; /* Space available in bytes. */ + char *key; /* Key information. */ + char *tweak; /* Tweak. */ + void *tweak_ctx; /* Tweak context. */ + void *data_ctx; /* Data context. */ + uint8_t buf[DUMPER_BUFSIZE]; /* Raw data buffer. */ + u_int buf_used; /* Number of bytes used in the buffer. */ + off_t offset; /* Last used offset in a xts_block_encrypt call. */ + off_t realoffset; /* Last used offset in a dump_write call. */ }; int set_dumper(struct dumperinfo *, const char *_devname); From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 18:06:27 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 975D8F59 for ; Sun, 28 Jul 2013 18:06:27 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6B170241F for ; Sun, 28 Jul 2013 18:06:27 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SI6RHU086900 for ; Sun, 28 Jul 2013 18:06:27 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SI6RmU086880 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 18:06:27 GMT (envelope-from def@FreeBSD.org) Date: Sun, 28 Jul 2013 18:06:27 GMT Message-Id: <201307281806.r6SI6RmU086880@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255276 - soc2013/def/crashdump-head/sys/crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 18:06:27 -0000 Author: def Date: Sun Jul 28 18:06:27 2013 New Revision: 255276 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255276 Log: Remove xts_smallblock because it's not a part of the standard and crash dumps are larger than 16B. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Sun Jul 28 17:54:42 2013 (r255275) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Sun Jul 28 18:06:27 2013 (r255276) @@ -125,26 +125,6 @@ } static __inline void -xts_smallblock(const struct xts_alg *alg, const struct xts_ctx *data_ctx, - uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len) -{ - uint8_t buf[XTS_BLK_BYTES], *p; - - /* - * Encryption/decryption of sectors smaller then 128 bits is not defined - * by IEEE P1619 standard. - * To work around it encrypt such sector in CTR mode. - * CTR tweak (counter) value is XTS-tweak xor'ed with block length, i.e. - * entire small block has to be reencrypted after length change. - */ - memset(buf, len, XTS_BLK_BYTES); - xor128(buf, buf, tweak); - alg->pa_encrypt(data_ctx, buf, buf); - for (p = buf; len > 0; len--) - *(dst++) = *(src++) ^ *(p++); -} - -static __inline void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) { @@ -165,11 +145,6 @@ xts_start(alg, tweak_ctx, tweak, sector, xtweak); - if (len < XTS_BLK_BYTES) { - xts_smallblock(alg, data_ctx, tweak, src, dst, len); - return; - } - while (len >= XTS_BLK_BYTES) { xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); dst += XTS_BLK_BYTES; @@ -192,11 +167,6 @@ xts_start(alg, tweak_ctx, tweak, sector, xtweak); - if (len < XTS_BLK_BYTES) { - xts_smallblock(alg, data_ctx, tweak, src, dst, len); - return; - } - if ((len & XTS_BLK_MASK) != 0) len -= XTS_BLK_BYTES; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 22:05:51 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 22283FC0 for ; Sun, 28 Jul 2013 22:05:51 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0C1FC2CFB for ; Sun, 28 Jul 2013 22:05:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6SM5pUU058508 for ; Sun, 28 Jul 2013 22:05:51 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6SM5oil058481 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 22:05:50 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 28 Jul 2013 22:05:50 GMT Message-Id: <201307282205.r6SM5oil058481@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255285 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 28 Jul 2013 22:05:51 -0000 Author: mattbw Date: Sun Jul 28 22:05:50 2013 New Revision: 255285 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255285 Log: Complete and use new-style job processing boilerplate. Jobs now go entirely through 'job.c' without touching 'query.c'. UpdatePackages has been implemented, but not yet properly tested, and will likely need some more work. There do seem to be some teething problems with this, which I'll hopefully fix on Monday/Tuesday or at the start of next half-term. Resolution seems to be a bit broken, for instance. The old-style jobs system code is still intact and will be pulled down later. Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/actions/update_packages.c soc2013/mattbw/backend/actions/update_system.c soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/Makefile Sun Jul 28 22:05:50 2013 (r255285) @@ -45,6 +45,7 @@ actions/search_files.c \ actions/search_groups.c \ actions/search_names.c \ + actions/update_packages.c \ actions/update_system.c SRCS+= \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/actions.h Sun Jul 28 22:05:50 2013 (r255285) @@ -43,6 +43,8 @@ gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); gboolean simulate_remove_packages_thread(PkBackend *backend); +gboolean simulate_update_packages_thread(PkBackend *backend); +gboolean update_packages_thread(PkBackend *backend); gboolean update_system_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/actions/install_packages.c Sun Jul 28 22:05:50 2013 (r255285) @@ -25,11 +25,10 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* install_packages_thread prototype */ +#include "../jobs.h" /* jobs_... */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query.h" /* query_... */ -static bool job(struct pkg_jobs *jobs, struct query *q); -static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static gboolean install_packages(PkBackend *backend, bool simulate); /* * The thread that performs an InstallPackages operation. Should be invoked @@ -38,63 +37,42 @@ gboolean install_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return install_packages(backend, false); } /* - * The thread that performs a Simulate InstallPackages operation. Should be + * The thread that performs a SimulateInstallPackages operation. Should be * invoked by the pk_backend_simulate_install_packages hook. */ gboolean simulate_install_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return install_packages(backend, true); } -/* - * Tries to process the given solved installation jobs. - */ -static bool -job(struct pkg_jobs *jobs, struct query *q) +static gboolean +install_packages(PkBackend *backend, bool simulate) { + struct jobs_spec spec; + bool success; - assert(jobs != NULL); - assert(q != NULL); + assert(backend != NULL); - return query_jobs_apply_emitter(jobs, - q, - PK_STATUS_ENUM_INSTALL, - PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); -} + spec.backend = backend; + spec.info = pkgutils_pkg_install_state; + spec.jobs_failed_error = PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL; + spec.no_jobs_error = PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED; + spec.reject_non_updates = false; + spec.simulate = simulate; + spec.status = PK_STATUS_ENUM_INSTALL; + spec.type = PKG_JOBS_INSTALL; + spec.use_package_ids = true; -/* - * Tries to simulate processing the given installation jobs. - */ -static bool -sim_job(struct pkg_jobs *jobs, struct query *q) -{ - - assert(jobs != NULL); - assert(q != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = jobs_do(&spec); + (void)pk_backend_finished(backend); - return query_jobs_simulate_emitter(jobs, - q, - pkgutils_pkg_install_state); + return success ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/actions/remove_packages.c Sun Jul 28 22:05:50 2013 (r255285) @@ -25,11 +25,10 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* remove_packages_thread prototype */ +#include "../jobs.h" /* jobs... */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query.h" /* query_... */ -static bool job (struct pkg_jobs *jobs, struct query *q); -static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static gboolean remove_packages(PkBackend *backend, bool simulate); /* * The thread that performs an removePackages operation. Should be invoked @@ -38,63 +37,42 @@ gboolean remove_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return remove_packages(backend, false); } /* - * The thread that performs a Simulate RemovePackages operation. Should be + * The thread that performs a SimulateRemovePackages operation. Should be * invoked by the pk_backend_simulate_remove_packages hook. */ gboolean simulate_remove_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, sim_job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return remove_packages(backend, true); } -/* - * Tries to process the given solved removeation jobs. - */ -static bool -job(struct pkg_jobs *jobs, struct query *q) +static gboolean +remove_packages(PkBackend *backend, bool simulate) { + struct jobs_spec spec; + bool success; - assert(jobs != NULL); - assert(q != NULL); + assert(backend != NULL); - return query_jobs_apply_emitter(jobs, - q, - PK_STATUS_ENUM_REMOVE, - PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE); -} + spec.backend = backend; + spec.info = pkgutils_pkg_remove_state; + spec.jobs_failed_error = PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE; + spec.no_jobs_error = PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED; + spec.reject_non_updates = false; + spec.simulate = simulate; + spec.status = PK_STATUS_ENUM_REMOVE; + spec.type = PKG_JOBS_DEINSTALL; + spec.use_package_ids = true; -/* - * Tries to simulate processing the given removal jobs. - */ -static bool -sim_job(struct pkg_jobs *jobs, struct query *q) -{ - - assert(jobs != NULL); - assert(q != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = jobs_do(&spec); + (void)pk_backend_finished(backend); - return query_jobs_simulate_emitter(jobs, - q, - pkgutils_pkg_remove_state); + return success ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/actions/update_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/update_packages.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/actions/update_packages.c Sun Jul 28 22:05:50 2013 (r255285) @@ -25,76 +25,53 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* update_packages_thread prototype */ +#include "../jobs.h" /* jobs_... */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query.h" /* query_... */ -static bool job(struct pkg_jobs *jobs, struct query *q); -static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static gboolean update_packages(PkBackend *backend, bool simulate); /* - * The thread that performs an UpdatePackages operation. Should be invoked + * The thread that performs an InstallPackages operation. Should be invoked * by the pk_backend_update_packages hook. */ gboolean update_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return update_packages(backend, false); } /* - * The thread that performs a SimulateUpdatePackages operation. Should be + * The thread that performs a SimulateInstallPackages operation. Should be * invoked by the pk_backend_simulate_update_packages hook. */ gboolean simulate_update_packages_thread(PkBackend *backend) { - bool success; - - assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_UPGRADE, sim_job); - - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return update_packages(backend, true); } -/* - * Tries to process the given solved installation jobs. - */ -static bool -job(struct pkg_jobs *jobs, struct query *q) +static gboolean +update_packages(PkBackend *backend, bool simulate) { + struct jobs_spec spec; + bool success; - assert(jobs != NULL); - assert(q != NULL); + assert(backend != NULL); - return query_jobs_apply_emitter(jobs, - q, - PK_STATUS_ENUM_UPDATE, - PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); -} + spec.backend = backend; + spec.info = pkgutils_pkg_install_state; + spec.jobs_failed_error = PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL; + spec.no_jobs_error = PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE; + spec.reject_non_updates = true; + spec.simulate = simulate; + spec.type = PKG_JOBS_INSTALL; + spec.use_package_ids = true; -/* - * Tries to simulate processing the given installation jobs. - */ -static bool -sim_job(struct pkg_jobs *jobs, struct query *q) -{ - - assert(jobs != NULL); - assert(q != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = jobs_do(&spec); + (void)pk_backend_finished(backend); - return query_jobs_simulate_emitter(jobs, - q, - pkgutils_pkg_install_state); + return success ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/actions/update_system.c ============================================================================== --- soc2013/mattbw/backend/actions/update_system.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/actions/update_system.c Sun Jul 28 22:05:50 2013 (r255285) @@ -25,10 +25,8 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* update_system_thread prototype */ -#include "../db.h" /* db_open_remote */ -#include "../utils.h" /* ERR */ -#include "../pkgutils.h" /* pkgutils_... */ #include "../jobs.h" /* jobs_... */ +#include "../pkgutils.h" /* pkgutils_... */ /* * The thread that performs an UpdateSystem operation. Should be invoked @@ -37,42 +35,24 @@ gboolean update_system_thread(PkBackend *backend) { + struct jobs_spec spec; bool success; - struct pkgdb *db; - struct pkg_jobs *jobs; assert(backend != NULL); - success = false; + spec.backend = backend; + spec.info = pkgutils_pkg_install_state; + spec.jobs_failed_error = PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL; + spec.no_jobs_error = PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE; + spec.reject_non_updates = false; + spec.simulate = false; + spec.status = PK_STATUS_ENUM_UPDATE; + spec.type = PKG_JOBS_UPGRADE; + spec.use_package_ids = false; - db = db_open_remote(backend); - if (db == NULL) - goto cleanup; - - /* UpdateSystem is a job with no packages, so there's no need to use - * the full query approach. - */ - jobs = NULL; - if (pkg_jobs_new(&jobs, PKG_JOBS_UPGRADE, db) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not init pkg_jobs"); - goto cleanup; - } - if (pkg_jobs_solve(jobs) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); - goto cleanup; - } - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); - - success = jobs_apply(jobs, backend, - PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); - -cleanup: + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = jobs_do(&spec); (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/jobs.c Sun Jul 28 22:05:50 2013 (r255285) @@ -27,10 +27,13 @@ #include "pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg_... */ +#include "db.h" /* db_... */ #include "event.h" /* event_cb */ #include "utils.h" /* ERR */ -#include "pkgutils.h" /* pkgutils_... */ #include "jobs.h" /* jobs_... */ +#include "pkgutils.h" /* pkgutils_... */ + +static void free_namevers(char ***namev_p, unsigned int namec); /* Applies a job with the given error enums and the standard event callback. */ bool @@ -140,6 +143,91 @@ return success; } +/* Performs a job from a job specification. */ +bool +jobs_do(const struct jobs_spec *spec) +{ + bool success; + unsigned int count; + gchar **package_ids; + struct pkgdb *db; + struct pkg_jobs *jobs; + char **namevers; + + assert(spec != NULL); + assert(spec->backend != NULL); + assert(spec->info != NULL); + + success = false; + namevers = NULL; + jobs = NULL; + + package_ids = NULL; + if (spec->use_package_ids) + package_ids = pk_backend_get_strv(spec->backend, "package_ids"); + + count = 0; + if (package_ids != NULL) + count = g_strv_length(package_ids); + + db = db_open_remote(spec->backend); + if (db == NULL) + goto cleanup; + + /* UpdateSystem is a job with no packages, so there's no need to use + * the full query approach. + */ + jobs = NULL; + if (pkg_jobs_new(&jobs, spec->type, db) != EPKG_OK) { + ERR(spec->backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (package_ids != NULL) { + STATUS(spec->backend, PK_STATUS_ENUM_DEP_RESOLVE); + + namevers = jobs_add_package_ids(jobs, package_ids); + if (namevers == NULL) { + ERR(spec->backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not find all requested packages"); + goto cleanup; + } + } + if (pkg_jobs_solve(jobs) != EPKG_OK) { + ERR(spec->backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + goto cleanup; + } + if (package_ids != NULL && + (jobs_check_package_ids(jobs, package_ids, + spec->reject_non_updates) == false)) { + ERR(spec->backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "packages failed suitability check"); + goto cleanup; + } + + STATUS(spec->backend, spec->status); + + if (spec->simulate) { + success = true; + jobs_emit_packages(jobs, spec->backend, spec->info); + } else + success = jobs_apply(jobs, spec->backend, + PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); + +cleanup: + pkg_jobs_free(jobs); + pkgdb_close(db); + free_namevers(&namevers, count); + + return success; +} + /* Adds each PackageID into an already created job. Returns NULL on failure * and a vector of added package name-versions to be freed after solution * on success. @@ -163,13 +251,13 @@ goto cleanup; /* Need to convert PackageIDs into name-version pairs. */ - namevers = calloc(count, sizeof(gchar *)); + namevers = calloc(count, sizeof(char *)); if (namevers == NULL) goto cleanup; for (i = 0; i < count; i++) { namevers[i] = pkgutils_package_id_namever(package_ids[i]); - if (namevers[i] != NULL) + if (namevers[i] == NULL) break; } @@ -182,12 +270,8 @@ cleanup: if (!success) { - if (namevers != NULL) { - for (i = 0; i < count; i++) - free(namevers[i]); - free(namevers); - } - namevers = NULL; + if (namevers != NULL) + free_namevers(&namevers, count); } return namevers; @@ -211,3 +295,17 @@ } } +static void +free_namevers(char ***namev_p, unsigned int namec) +{ + unsigned int i; + + assert(namev_p != NULL); + + if (*namev_p != NULL) { + for (i = 0; i < namec; i++) + free(*namev_p[i]); + free(*namev_p); + *namev_p = NULL; + } +} Modified: soc2013/mattbw/backend/jobs.h ============================================================================== --- soc2013/mattbw/backend/jobs.h Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/jobs.h Sun Jul 28 22:05:50 2013 (r255285) @@ -26,8 +26,22 @@ typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); -bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); +struct jobs_spec { + pkg_jobs_t type; + PkErrorEnum jobs_failed_error; + PkErrorEnum no_jobs_error; + PkStatusEnum status; + PkBackend *backend; + pkg_info_ptr info; + bool reject_non_updates; + bool simulate; + bool use_package_ids; + bool ignore; /* Alignment */ +}; + +bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum jobs_failed); bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, bool reject_non_updates); +bool jobs_do(const struct jobs_spec *spec); char **jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids); void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 28 20:11:31 2013 (r255284) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 28 22:05:50 2013 (r255285) @@ -270,8 +270,6 @@ THREAD(backend, simulate_remove_packages_thread); } -#if 0 - void pk_backend_simulate_update_packages(PkBackend *backend, gchar **package_ids) { @@ -292,8 +290,6 @@ THREAD(backend, update_packages_thread); } -#endif - void pk_backend_update_system(PkBackend *backend, gboolean only_trusted) { From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 12:52:05 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 731E3F3 for ; Mon, 29 Jul 2013 12:52:05 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5FA5024AA for ; Mon, 29 Jul 2013 12:52:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TCq4R5000370 for ; Mon, 29 Jul 2013 12:52:04 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TCq47c000360 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 12:52:04 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 29 Jul 2013 12:52:04 GMT Message-Id: <201307291252.r6TCq47c000360@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255296 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 12:52:05 -0000 Author: jmuniz Date: Mon Jul 29 12:52:04 2013 New Revision: 255296 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255296 Log: Created BUGS file to contain a list of known bugs for the repository, sorted by area affected. I have populated the file with a list that had previously existed on paper. Added: soc2013/jmuniz/BUGS Added: soc2013/jmuniz/BUGS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/BUGS Mon Jul 29 12:52:04 2013 (r255296) @@ -0,0 +1,37 @@ +Bugs in this Repository +----------------------- + +PackageKit +---------- +- download +- remove +- get-depends +- add dependency check for libffi.so.5 (symlink for now) ++ bugs that may already be resolved (test once possible) +-- may have trouble queuing multiple transactions +-- may crash when no file list is available for a given package + +gnome-packagekit +---------------- +- help functionality requires yelp to be properly installed (certain shared library versions) ++ gpk-update-icon +-- (13180) DBus warning, error sending message; did not receive a reply +-- crashes before ever showing the tray icon +-- make sure this is set to start at boot (if user prefers) ++ gpk-application +-- no icon in application launcher (perhaps related to a .desktop file) +-+ non-critical +--- icons for categories move to the right if application is opened more than once + +KPackageKit +----------- +- crashes when clicking on category in list box +- crashes when clicking "pending changes" ++ non-critical +-- warning: session DBus connection created before QCoreApplication +-- description glitches when rising after being hidden + +PackageKit-qt4 +-------------- +- does not build with Qt-4.8 + From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 13:21:24 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BA2528FB for ; Mon, 29 Jul 2013 13:21:24 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A6AA925E0 for ; Mon, 29 Jul 2013 13:21:24 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TDLOdi040529 for ; Mon, 29 Jul 2013 13:21:24 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TDLOQ5040516 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 13:21:24 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 29 Jul 2013 13:21:24 GMT Message-Id: <201307291321.r6TDLOQ5040516@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255300 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 13:21:24 -0000 Author: jmuniz Date: Mon Jul 29 13:21:24 2013 New Revision: 255300 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255300 Log: Created five initial documentation files to better organize information regarding this repository. Added: soc2013/jmuniz/FAQ soc2013/jmuniz/INSTALL soc2013/jmuniz/NEWS soc2013/jmuniz/TESTING soc2013/jmuniz/THANKS Added: soc2013/jmuniz/FAQ ============================================================================== Added: soc2013/jmuniz/INSTALL ============================================================================== Added: soc2013/jmuniz/NEWS ============================================================================== Added: soc2013/jmuniz/TESTING ============================================================================== Added: soc2013/jmuniz/THANKS ============================================================================== From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 13:24:17 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6E7D0940 for ; Mon, 29 Jul 2013 13:24:17 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 58A1C25FE for ; Mon, 29 Jul 2013 13:24:17 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TDOHvt076319 for ; Mon, 29 Jul 2013 13:24:17 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TDOHTi076314 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 13:24:17 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 29 Jul 2013 13:24:17 GMT Message-Id: <201307291324.r6TDOHTi076314@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255301 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 13:24:17 -0000 Author: jmuniz Date: Mon Jul 29 13:24:17 2013 New Revision: 255301 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255301 Log: Created an automatically generated change log, which is useful when accessing the code repository from an offline setting. Added: soc2013/jmuniz/ChangeLog Added: soc2013/jmuniz/ChangeLog ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/ChangeLog Mon Jul 29 13:24:17 2013 (r255301) @@ -0,0 +1,173 @@ +2013-07-17 12:59 jmuniz + + * PackageKit/PackageKit-0.6.11/packagekit/pkg-plist: Updated + pkg-plist: added all files installed for temporary pkgng backend; + enhanced tags; removed tags from a couple of files that were not + part of a back end; performed satisfactory initial testing. + +2013-07-17 12:52 jmuniz + + * PackageKit/PackageKit-0.6.11/packagekit/Makefile: Updated + PackageKit port Makefile: added pkgng option; enhanced back end + selection; fixed manpages option, by adding docbook-xml to its + dependencies; incremented the revision number; removed invalid + argument: --disable-managed; performed satisfactory initial + testing; and removed an empty line. + +2013-07-13 01:55 jmuniz + + * PackageKit-Setter/packagekit-setter/Makefile: Fixed the nits :) + Moved the archive off-site, to sourceforge -- for their many + mirrors; removed empty comment line; Changed archive name to + default, and removed the filename variables; Removed + LICENSE_FILE. + +2013-07-12 20:14 jmuniz + + * PackageKit-Setter/packagekit-setter-latest.txz: Changed name of + archive to conform, moved archive to another server. + +2013-07-12 19:14 jmuniz + + * PackageKit-Setter/packagekit-setter/Makefile: Forgot to include + the updated Makefile for packagekit-setter last time. This one + works. + +2013-07-11 14:58 jmuniz + + * PackageKit-Setter/pk-setter: Fixed mispelling of desktop in the + gdbus call, pk-setter now seems to function flawlessly. + +2013-07-11 14:06 jmuniz + + * PackageKit-Setter/COPYING: Added GPL license file to + packagekit-setter source folder. + +2013-07-11 14:00 jmuniz + + * PackageKit-Setter/packagekit-setter, + PackageKit-Setter/packagekit-setter/Makefile, + PackageKit-Setter/packagekit-setter/distinfo, + PackageKit-Setter/packagekit-setter/pkg-descr: Added initial + ports collection files for packagekit-setter. + +2013-07-11 13:58 jmuniz + + * PackageKit-Setter/packagekit-setter-latest.txz: Created an + archive to distribute pk-setter for ports collection. + +2013-07-11 13:56 jmuniz + + * PackageKit-Setter/pk-setter: Corrected the usage of the sed + command, fixing the bug that wiped out the configuration file + when it should have updated it. + +2013-07-01 10:08 jmuniz + + * PackageKit-Setter/pk-setter, TODO: pk-setter now restarts the + daemon. Updated TODO. + +2013-07-01 09:02 jmuniz + + * PackageKit-Setter/pk-setter, TODO: Fixed several issues with + pk-setter, getting it to a stable point. Updated and moved task + list from pk-setter to TODO. + +2013-06-30 12:11 jmuniz + + * PackageKit-Setter/pk-setter: Fixed strange spacing issue + +2013-06-30 12:05 jmuniz + + * PackageKit-Setter/pk-setter: Corrected spelling errors, updated + task list for pk-setter + +2013-06-26 04:35 jmuniz + + * PackageKit-Setter/pk-setter: created initial pk-setter script + +2013-06-19 14:38 jmuniz + + * PackageKit/PackageKit-0.6.11/packagekit, + PackageKit/PackageKit-0.6.11/packagekit/Makefile, + PackageKit/PackageKit-0.6.11/packagekit/distinfo, + PackageKit/PackageKit-0.6.11/packagekit/files, + PackageKit/PackageKit-0.6.11/packagekit/files/patch-etc_Vendor.conf, + PackageKit/PackageKit-0.6.11/packagekit/files/patch-src_pk-lsof.c, + PackageKit/PackageKit-0.6.11/packagekit/pkg-descr, + PackageKit/PackageKit-0.6.11/packagekit/pkg-plist, + PackageKit/PackageKit-0.8.9/packagekit/pkg-plist: Deleted empty + lines in PackageKit-0.8.9 pkg-plist, added base file for + PackageKit-0.6.11 port + +2013-06-19 13:00 jmuniz + + * README: Added information about the project to the readme + +2013-06-19 12:52 jmuniz + + * TODO: Introduced TODO list + +2013-06-19 12:50 jmuniz + + * COPYING: Added the GPLv2 content to COPYING + +2013-06-19 12:33 jmuniz + + * COPYING, KPackageKit, KPackageKit/Apper-0.7.2, + KPackageKit/Apper-0.7.2/apper, KPackageKit/KPackageKit-0.6.3.3, + KPackageKit/KPackageKit-0.6.3.3/kpackagekit, + KPackageKit/KPackageKit-0.6.3.3/kpackagekit/Makefile, + KPackageKit/KPackageKit-0.6.3.3/kpackagekit/distinfo, + KPackageKit/KPackageKit-0.6.3.3/kpackagekit/pkg-descr, + KPackageKit/KPackageKit-0.6.3.3/kpackagekit/pkg-plist, + PackageKit, PackageKit-Setter, PackageKit-qt4, + PackageKit-qt4/PackageKit-qt4-0.6.11, + PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4, + PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile, + PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/pkg-plist, + PackageKit-qt4/PackageKit-qt4-0.8.9, + PackageKit/PackageKit-0.6.11, PackageKit/PackageKit-0.8.9, + PackageKit/PackageKit-0.8.9/packagekit, + PackageKit/PackageKit-0.8.9/packagekit/Makefile, + PackageKit/PackageKit-0.8.9/packagekit/distinfo, + PackageKit/PackageKit-0.8.9/packagekit/pkg-descr, + PackageKit/PackageKit-0.8.9/packagekit/pkg-plist, README, + gnome-packagekit, gnome-packagekit/gnome-packagekit-2.32.0, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/distinfo, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-data_gnome-packagekit.schemas.in, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-check-update.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-dbus-task.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-dbus.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-firmware.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-hardware.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-src_gpk-watch.c, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/pkg-descr, + gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/pkg-plist, + gnome-packagekit/gnome-packagekit-3.8.2, + gnome-packagekit/gnome-packagekit-3.8.2/gnome-packagekit: + Finished creating initial directory structure, added base files + for all related ports + +2013-06-19 12:09 jmuniz + + * PackageKit/PackageKit-0.8.9/packagekit, + PackageKit/PackageKit-0.8.9/packagekit/Makefile, + PackageKit/PackageKit-0.8.9/packagekit/distinfo, + PackageKit/PackageKit-0.8.9/packagekit/pkg-descr, + PackageKit/PackageKit-0.8.9/packagekit/pkg-plist: Some initial + progress towards porting the latest version + +2013-06-19 11:25 jmuniz + + * COPYING, PackageKit, PackageKit/PackageKit-0.6.11, + PackageKit/PackageKit-0.8.9, README: Creating beginnings of the + directory structure and important resource documents + +2013-06-19 11:08 jmuniz + + * .: + From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 14:59:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 73D58B3C for ; Mon, 29 Jul 2013 14:59:18 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6013B2C39 for ; Mon, 29 Jul 2013 14:59:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TExIXf080286 for ; Mon, 29 Jul 2013 14:59:18 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TExIFi080284 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 14:59:18 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 29 Jul 2013 14:59:18 GMT Message-Id: <201307291459.r6TExIFi080284@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255303 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 14:59:18 -0000 Author: jmuniz Date: Mon Jul 29 14:59:18 2013 New Revision: 255303 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255303 Log: Greatly expanded on the task list in TODO. I added most of the current files and sub-projects to the document; and for each area, I listed all of the current tasks. I updated the task list for pk-setter. Note that now optional tasks are labeled as such, and the whole document has moved from a list structure to a tree structure. Modified: soc2013/jmuniz/TODO Modified: soc2013/jmuniz/TODO ============================================================================== --- soc2013/jmuniz/TODO Mon Jul 29 13:17:18 2013 (r255302) +++ soc2013/jmuniz/TODO Mon Jul 29 14:59:18 2013 (r255303) @@ -1,11 +1,232 @@ Task list for this repository ----------------------------- -pk-setter: -- generate backend list without hardcoding it -- determine if the BSD license can be used this intimately with GPLv2 -- verify that packagekitd starts with new configuration, or roll back to last known good configuration -- create a new port to share this script -- determine if 'pkcon refresh' is needed when changing backends, it doesn't seem to want to work in 0.6.11 -- make script more robust in the face of missing dependencies +Underlined headers identify the portion of this undertaking that each task corresponds with. +Tasks are ordered hierarchically: the hyphens indicate the level of each node and any leafs +they contain, and plus signs identify nodes with leafs. + +This document +------------- +- delve more into specifics ++ areas that need work +-- README +-+ TESTING +--- instructions on configuring, building, and installing development sources +-+ NEWS +--- track user oriented changes in this log to show current progress +-+ INSTALL +--- instructions on configuring, building, and installing official releases +-+ THANKS +--- add credits, urls, and licenses of works used +-- FAQ +-- Wiki +-- Makefile +-- PK-0.6.11 patches +-- PK-qt +-- KPackageKit port +-- KPackageKit patches +-- gnome-packagekit port +-- gnome-packagekit patches +-- Patches for both front ends + +README +------ +- repository description +- contact information +- link to wiki for more information ++ optional +-- bug tracking + +BUGS +---- ++ document all bugs and limitations +-- any bugs that are discovered during testing + +NEWS +---- + +INSTALL +------- + +THANKS +------ + +FAQ +--- +- troubleshooting +- usage +- requirements +- bug tracking +- repository hierarchy + +TESTING +------- +- how to acquire and update the source code +- how to prepare pkg to use a default repo +- how to configure the projects +- how to build and install the projects for testing +- upgrading the testing installations to the latest socsvn revision +- how to remove and clean testing installations and files +- how to test projects for functionality and regression +- performance testing +- debugging + +Wiki +---- +- reword content to be more widely user-friendly +- make sure that milestones are appropriate +- present reflective journals +- request feedback in the form of bug reports, suggestions, feature requests, patches, regression alerts, and other potentially useful information +- add screenshots to present progress +- instructions for using pk-setter +- use cases for overall project +- test results (with seed data, test output, and performance results) +- link to Google-Melange project page +- add more links to external documentation (for related work) + +Makefile +-------- +- contain all operations to test code +- running 'make' in the root of the repository will provide instructions on using the Makefile + +pk-setter +--------- +- validate port with portlint and poudriere ++ optional +-- return currently selected back end +-- create back end list from file saved during PK installation +-- verify that packagekitd starts with each new configuration, or roll back to last known good configuration +-- use GetDaemonState() to determine if packagekitd needs to be closed? +-- make script more robust in the face of missing dependencies +-- detect pkg, and if pkg2ng needs to be run +-- configure pkg to use default repository +-- create a manual page +-- a way to reset PackageKit.conf to default using PackageKit.conf.sample + +PackageKit-0.6.11 patches +------------------------- ++ ports back end +-- fix plethora of bugs, listed in BUGS +-- patch changes into new port revision +-- find out if packagekit-cron could work +-- get-files for non-installed software ++ pkgng back end +-- evaluate necessity of additional functions (not used in ports back end) +-- patch new back end into new port revision +-- detect pkg installation, and if pkg2ng needs to be run ++ pk-backend-pkgng.c +-- comment, add header +-- test ++ configure / configure.ac +-- once the pkgng back end is finished, the pkgng back end can be default over the ports back end +-- test, make sure that these files are enough or even necessary to include the pkgng back end ++ pkgngBackend.rb +-+ optional +--- show unavailable file lists by downloading the plist from freebsd.org + +PackageKit-0.6.11 port +---------------------- +- test with portlint and poudriere +- make sure the back ends play nice with PC-BSD, since it relies on overlays +- create a file on installation to contain a list of installed back ends for pk-setter ++ Makefile +- find a better way to add site_ruby/1.8/pkgtools to ruby 1.9 include path +-+ optional +--- set appropriate option defaults +--- create an option to install pk-setter AFTER PK; this should prevent circular dependency +--- back end options should be in a multiple choice list that tolerates no less than one back end +--- move manpages to DOC option, and replace manpage generation with a manpage patch +--- save a copy of PackageKit.conf to PackageKit.conf.sample for default configuration recovery ++ pkg-plist +-- edit to reflect permanent pkgng back end files, in the future ++ files/ +-- add temporary pkgng back end patches +-- update patches to permanent pkgng back end, in the future ++ optional +-- update port to version 0.8.9 + +KPackageKit-0.6.3.3 port +------------------------ ++ files/ +-- add patches ++ optional +-- clicking on an item in a dependency list should open that items information +-- easy method of setting an option to automatically start tray icon at login +-- update port to Apper-0.8.0 + +gnome-packagekit-2.32.0 port +---------------------------- +- make sure that libgcrypt dependency is taken care of ++ optional +-- upgrade port to latest version + +PackageKit-qt4-0.6.11 port +-------------------------- + +KPackageKit-0.6.3.3 patches +--------------------------- +- enable help button, patch in help files ++ user interface files +-+ +-+ optional +--- combine main window with update window using tabs +--- preference option available to keep selections when navigating tabs (default: true) ++ source code files + +gnome-packagekit-2.32.0 patches +------------------------------- ++ user interface files +-+ gpk-application.ui +--- convenient access to view updates, install from local file, and preferences +-+ gpk-backend-status.ui +-+ gpk-client.ui +-+ gpk-error.ui +-+ gpk-eula.ui +-+ gpk-log.ui +-+ gpk-prefs.ui +-+ gpk-repo.ui +-+ gpk-service-pack.ui +-+ gpk-signature.ui +-+ gpk-update-viewer.ui ++ source code files ++ optional features to look into +-- service packs (perhaps replace tarball with PBI) +-- mime type installation +-- catalogs (would allow for sharing of toolkits for example) + +Patches for both front ends +--------------------------- +- have front ends remember with which back end a port was installed with, and use that back end for updates +- customizable permissions (so some users may only update packages, or view data) +- create a confirmation report, listing all changes +- easy repository management +- easily switch between ports and binary packages +- create mock up concepts +- if front ends are new ports, combine the appearance of the front ends +- update search results after each keystroke (using a timer delay to prevent extra overhead) +- option to automatically start tray icons at boot +- configure a port to change from development version to stable version once a specific stable version is released +- add jail support, and easy selection of one or more jails to modify +- manage remote systems and their jails in a centralized way +- improve transaction history to include more information on each transaction +- import and export packagekit and front end configuration files +- install specific available versions of software (over the internet) +- fail over to another back end if version is not available (help to get latest versions) +- register packages +- build a repository, or a part of a repository, from ports +- test and validate new or modified ports +- check archives to make sure they are packages for pkgng +- create binary packages from ports +- roll back package update(s) +- install multiple versions of a program at once +- roll packages back to certain configuration, saved in a catalog file +- assign specific package versions to skip over, and wait for later versions +- freeze a package to prevent it from being updated +- an extra simple, "normal" mode (as opposed to "expert" mode) +- fix the way that the front ends interact with the transactions.db, currently both back ends cannot be installed simultaneously +- allow user to set a default prefix to affect future installs +- allow user to easily move a package from one disk to another (after it is installed on the system) +- easy means of deleting distfiles +- easy means of removing orphaned dependencies +- let user reinstall a package From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 18:02:29 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 696F110D for ; Mon, 29 Jul 2013 18:02:29 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 47F8925F9 for ; Mon, 29 Jul 2013 18:02:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TI2TDp037137 for ; Mon, 29 Jul 2013 18:02:29 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TI2TkB037125 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 18:02:29 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 29 Jul 2013 18:02:29 GMT Message-Id: <201307291802.r6TI2TkB037125@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255308 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 18:02:29 -0000 Author: mattbw Date: Mon Jul 29 18:02:29 2013 New Revision: 255308 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255308 Log: Quick-fixed a logical error in the new jobs handling. I forgot that jobs need to be set up to use a specific repository, and that as PackageIDs have individual repositories specified then one cannot just send all the PackageIDs to the default repository. For now, the old behaviour of one job per PackageID has been quickly pencilled back in. A possible workaround would be to sort through the PackageIDs and sift them into separate repository piles with one job for each, but this will take some implementing and would complicate the backend code. Modified: soc2013/mattbw/backend/jobs.c Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Mon Jul 29 17:03:42 2013 (r255307) +++ soc2013/mattbw/backend/jobs.c Mon Jul 29 18:02:29 2013 (r255308) @@ -33,6 +33,7 @@ #include "jobs.h" /* jobs_... */ #include "pkgutils.h" /* pkgutils_... */ +static bool jobs_do_repo(struct pkgdb *db, const struct jobs_spec *spec, gchar **idv, unsigned int idc, const char *reponame); static void free_namevers(char ***namev_p, unsigned int namec); /* Applies a job with the given error enums and the standard event callback. */ @@ -126,7 +127,8 @@ } if (success && reject_non_updates && - pkgutils_pkg_install_state(pkg) != PK_INFO_ENUM_UPDATING) + pkgutils_pkg_install_state(pkg) != + PK_INFO_ENUM_UPDATING) success = false; } } @@ -149,18 +151,18 @@ { bool success; unsigned int count; - gchar **package_ids; + unsigned int i; + char *repo; struct pkgdb *db; - struct pkg_jobs *jobs; - char **namevers; + gchar **package_ids; + gchar **splits; + assert(spec != NULL); assert(spec->backend != NULL); assert(spec->info != NULL); success = false; - namevers = NULL; - jobs = NULL; package_ids = NULL; if (spec->use_package_ids) @@ -174,20 +176,77 @@ if (db == NULL) goto cleanup; - /* UpdateSystem is a job with no packages, so there's no need to use - * the full query approach. + /* + * HACK ALERT + * + * We'd ideally like to do one job for all PackageIDs but, because + * there could be more than one repo being used (as each PackageID has + * its own repo), we need to do one job per PackageID. + * TODO: consider bundling PackageIDs up into separate jobs per repo? */ + if (package_ids == NULL) + success = jobs_do_repo(db, spec, NULL, 0, ""); + else { + + for (i = 0, success = true; i < count && success; i++) { + /* Nastily inefficient */ + splits = pk_package_id_split(package_ids[i]); + if (splits == NULL) + repo = strdup(""); + else + repo = strdup(splits[PK_PACKAGE_ID_DATA]); + g_strfreev(splits); + + success = jobs_do_repo(db, spec, package_ids + i, + 1, repo); + free(repo); + } + } + +cleanup: + pkgdb_close(db); + + return success; +} + +/* + * Performs a job on a certain batch of PackageIDs, each with the same repo. + * count can be 0, in which case no PackageIDs are used. + */ +bool +jobs_do_repo(struct pkgdb *db, const struct jobs_spec *spec, gchar **idv, + unsigned int idc, const char *reponame) +{ + bool success; + struct pkg_jobs *jobs; + char **namevers; + + assert(db != NULL); + assert(spec != NULL); + assert(idv == NULL || idc > 0); + assert(idv != NULL || idc == 0); + + success = NULL; + namevers = NULL; jobs = NULL; + if (pkg_jobs_new(&jobs, spec->type, db) != EPKG_OK) { ERR(spec->backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not init pkg_jobs"); goto cleanup; } - if (package_ids != NULL) { + if (reponame != NULL && + (pkg_jobs_set_repository(jobs, reponame) != EPKG_OK)) { + ERR(spec->backend, + PK_ERROR_ENUM_REPO_NOT_FOUND, + "could not set repo"); + goto cleanup; + } + if (idv != NULL) { STATUS(spec->backend, PK_STATUS_ENUM_DEP_RESOLVE); - namevers = jobs_add_package_ids(jobs, package_ids); + namevers = jobs_add_package_ids(jobs, idv); if (namevers == NULL) { ERR(spec->backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, @@ -201,8 +260,8 @@ "could not solve the job"); goto cleanup; } - if (package_ids != NULL && - (jobs_check_package_ids(jobs, package_ids, + if (idv != NULL && + (jobs_check_package_ids(jobs, idv, spec->reject_non_updates) == false)) { ERR(spec->backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, @@ -222,8 +281,7 @@ cleanup: pkg_jobs_free(jobs); - pkgdb_close(db); - free_namevers(&namevers, count); + free_namevers(&namevers, idc); return success; } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 29 18:21:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D6B355AD for ; Mon, 29 Jul 2013 18:21:26 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C18AF26F3 for ; Mon, 29 Jul 2013 18:21:26 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TILQcw075990 for ; Mon, 29 Jul 2013 18:21:26 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6TILQGS075957 for svn-soc-all@FreeBSD.org; Mon, 29 Jul 2013 18:21:26 GMT (envelope-from def@FreeBSD.org) Date: Mon, 29 Jul 2013 18:21:26 GMT Message-Id: <201307291821.r6TILQGS075957@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255309 - in soc2013/def/crashdump-head: sbin/savecore sys/conf sys/crypto sys/crypto/hmac sys/kern sys/sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 29 Jul 2013 18:21:27 -0000 Author: def Date: Mon Jul 29 18:21:26 2013 New Revision: 255309 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255309 Log: Import pefs' key derivation function. Assume a constant size of tweak. Added: soc2013/def/crashdump-head/sys/crypto/hmac/ soc2013/def/crashdump-head/sys/crypto/hmac/hmac.c soc2013/def/crashdump-head/sys/crypto/hmac/hmac.h Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile soc2013/def/crashdump-head/sbin/savecore/decryptfile.c soc2013/def/crashdump-head/sbin/savecore/decryptfile.h soc2013/def/crashdump-head/sbin/savecore/savecore.c soc2013/def/crashdump-head/sys/conf/files soc2013/def/crashdump-head/sys/crypto/xts.h soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/Makefile Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sbin/savecore/Makefile Mon Jul 29 18:21:26 2013 (r255309) @@ -1,12 +1,14 @@ # $FreeBSD$ SYS= ${.CURDIR}/../../sys -.PATH: ${SYS}/crypto/camellia ${SYS}/crypto/rijndael ${SYS}/crypto +.PATH: ${SYS}/crypto/camellia ${SYS}/crypto/rijndael +.PATH: ${SYS}/crypto/hmac ${SYS}/crypto/sha2 ${SYS}/crypto PROG= savecore SRCS= ${PROG}.c decryptfile.c SRCS+= rijndael-api.c rijndael-api-fst.c rijndael-alg-fst.c SRCS+= camellia.c +SRCS+= hmac.c sha2.c SRCS+= xts.c DPADD= ${LIBZ} LDADD= -lz Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Mon Jul 29 18:21:26 2013 (r255309) @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "decryptfile.h" int @@ -40,9 +42,25 @@ return (saved); } +void +hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, + int idx, const uint8_t *magic, size_t magicsize) +{ + uint8_t byte_idx = idx; + + hmac_init(&ctx->o.pctx_hmac, CRYPTO_SHA2_512_HMAC, + masterkey, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, magic, magicsize); + hmac_update(&ctx->o.pctx_hmac, &byte_idx, sizeof(byte_idx)); + hmac_final(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); +} + FILE * dopen(const char *fname, const char *mode, const struct kerneldumpheader *h) { + uint8_t key[KERNELDUMP_KEY_SIZE]; + struct xts_ctx ctx; decFile *fd; FILE *fp; @@ -57,16 +75,26 @@ fd = (decFile *)malloc(sizeof(decFile)); fd->fp = fp; + fd->keysize = h->keysize; - memcpy(fd->key, h->key, KERNELDUMP_KEY_SIZE); - fd->tweaksize = h->tweaksize; + memcpy(fd->key, h->key, fd->keysize); memcpy(fd->tweak, h->tweak, KERNELDUMP_TWEAK_SIZE); + bzero(&fd->tweak_ctx, sizeof(fd->tweak_ctx)); + bzero(&fd->data_ctx, sizeof(fd->data_ctx)); + bzero(key, KERNELDUMP_KEY_SIZE); + + hkdf_expand(&ctx, fd->key, key, 1, kerneldump_magic, sizeof(kerneldump_magic)); + xts_alg_aes.pa_keysetup(&fd->data_ctx, key, fd->keysize << 3); + + hkdf_expand(&ctx, fd->key, key, 2, kerneldump_magic, sizeof(kerneldump_magic)); + xts_alg_aes.pa_keysetup(&fd->tweak_ctx, key, fd->keysize << 3); + + bzero(&ctx, sizeof(ctx)); + bzero(key, KERNELDUMP_KEY_SIZE); + fd->offset = 0; fd->buf_used = 0; - rijndael_set_key(&fd->tweak_ctx, fd->key, fd->keysize << 3); - rijndael_set_key(&fd->data_ctx, fd->key, fd->keysize << 3); - return (funopen(fd, NULL, dwrite, NULL, dclose)); } Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.h ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Mon Jul 29 18:21:26 2013 (r255309) @@ -8,10 +8,9 @@ FILE *fp; int keysize; char key[KERNELDUMP_KEY_SIZE]; - int tweaksize; char tweak[KERNELDUMP_TWEAK_SIZE]; - rijndael_ctx tweak_ctx; - rijndael_ctx data_ctx; + struct xts_ctx tweak_ctx; + struct xts_ctx data_ctx; off_t offset; #define PEFS_SECTOR_SIZE 4096 char buf[PEFS_SECTOR_SIZE]; Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Jul 29 18:21:26 2013 (r255309) @@ -123,7 +123,6 @@ fprintf(f, " Dump Parity: %u\n", h->parity); fprintf(f, " Bounds: %d\n", bounds); fprintf(f, " Key length: %d bits\n", h->keysize << 3); - fprintf(f, " Tweak length: %d bits\n", h->tweaksize << 3); switch(status) { case STATUS_BAD: Modified: soc2013/def/crashdump-head/sys/conf/files ============================================================================== --- soc2013/def/crashdump-head/sys/conf/files Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sys/conf/files Mon Jul 29 18:21:26 2013 (r255309) @@ -537,6 +537,7 @@ crypto/camellia/camellia-api.c optional crypto | ipsec crypto/des/des_ecb.c optional crypto | ipsec crypto/des/des_setkey.c optional crypto | ipsec +crypto/hmac/hmac.c optional crypto | encrypt_crash crypto/rc4/rc4.c optional netgraph_mppc_encryption | kgssapi crypto/rijndael/rijndael-alg-fst.c optional crypto | geom_bde | \ ipsec | random | wlan_ccmp Added: soc2013/def/crashdump-head/sys/crypto/hmac/hmac.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sys/crypto/hmac/hmac.c Mon Jul 29 18:21:26 2013 (r255309) @@ -0,0 +1,179 @@ +/*- + * Copyright (c) 2005-2010 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#ifdef _KERNEL +#include +#include +#else +#include +#include +#include +#endif + +#include + +#include + +#ifndef _KERNEL +#define panic(...) do { \ + fprintf(stderr, __VA_ARGS__); \ + abort(); \ +} while (0) +#endif + +typedef void hmac_hash_init_t(union hmac_hash_ctx *ctx); +typedef void hmac_hash_update_t(union hmac_hash_ctx *ctx, const uint8_t *, + size_t); +typedef void hmac_hash_final_t(uint8_t *, union hmac_hash_ctx *ctx); + +struct hmac_hash { + u_int block_len; + u_int digest_len; + hmac_hash_init_t *init; + hmac_hash_update_t *update; + hmac_hash_final_t *final; +}; + +static const struct hmac_hash hmac_hash_sha256 = { + .block_len = SHA256_BLOCK_LENGTH, + .digest_len = SHA256_DIGEST_LENGTH, + .init = (hmac_hash_init_t *)&SHA256_Init, + .update = (hmac_hash_update_t *)&SHA256_Update, + .final = (hmac_hash_final_t *)&SHA256_Final, +}; + +static const struct hmac_hash hmac_hash_sha384 = { + .block_len = SHA384_BLOCK_LENGTH, + .digest_len = SHA384_DIGEST_LENGTH, + .init = (hmac_hash_init_t *)&SHA384_Init, + .update = (hmac_hash_update_t *)&SHA384_Update, + .final = (hmac_hash_final_t *)&SHA384_Final, +}; + +static const struct hmac_hash hmac_hash_sha512 = { + .block_len = SHA512_BLOCK_LENGTH, + .digest_len = SHA512_DIGEST_LENGTH, + .init = (hmac_hash_init_t *)&SHA512_Init, + .update = (hmac_hash_update_t *)&SHA512_Update, + .final = (hmac_hash_final_t *)&SHA512_Final, +}; + +void +hmac_init(struct hmac_ctx *ctx, int algo, const uint8_t *hkey, size_t hkeylen) +{ + const struct hmac_hash *hash; + u_int i; + + switch (algo) { + case CRYPTO_SHA2_256_HMAC: + hash = &hmac_hash_sha256; + break; + case CRYPTO_SHA2_384_HMAC: + hash = &hmac_hash_sha384; + break; + case CRYPTO_SHA2_512_HMAC: + hash = &hmac_hash_sha512; + break; + default: + panic("HMAC: invalid alorithm: %d.", algo); + return; + } + + ctx->hash = hash; + bzero(ctx->k_opad, hash->block_len); + if (hkeylen == 0) + ; /* do nothing */ + else if (hkeylen <= hash->block_len) + bcopy(hkey, ctx->k_opad, hkeylen); + else { + /* + * If key is longer than HMAC_BLOCK_LENGTH_MAX bytes + * reset it to key = HASH(key). + */ + hash->init(&ctx->hash_ctx); + hash->update(&ctx->hash_ctx, hkey, hkeylen); + hash->final(ctx->k_opad, &ctx->hash_ctx); + } + + /* Perform inner SHA512. */ + hash->init(&ctx->hash_ctx); + /* XOR key ipad value. */ + for (i = 0; i < hash->block_len; i++) + ctx->k_opad[i] ^= 0x36; + hash->update(&ctx->hash_ctx, ctx->k_opad, hash->block_len); + /* XOR key opad value. */ + for (i = 0; i < hash->block_len; i++) + ctx->k_opad[i] ^= 0x36 ^ 0x5c; +} + +void +hmac_update(struct hmac_ctx *ctx, const uint8_t *data, + size_t datasize) +{ + + ctx->hash->update(&ctx->hash_ctx, data, datasize); +} + +void +hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize) +{ + const struct hmac_hash *hash = ctx->hash; + u_char digest[HMAC_DIGEST_LENGTH_MAX]; + + if (mdsize == 0 || mdsize > hash->digest_len) { + panic("HMAC: invalid digest buffer size: %zu (digest length %u).", + mdsize, hash->digest_len); + return; + } + + hash->final(digest, &ctx->hash_ctx); + /* Perform outer SHA512. */ + hash->init(&ctx->hash_ctx); + hash->update(&ctx->hash_ctx, ctx->k_opad, hash->block_len); + hash->update(&ctx->hash_ctx, digest, sizeof(digest)); + hash->final(digest, &ctx->hash_ctx); + bzero(ctx, sizeof(*ctx)); + + bcopy(digest, md, mdsize); +} + +void +hmac(int algo, const uint8_t *hkey, size_t hkeysize, const uint8_t *data, + size_t datasize, uint8_t *md, size_t mdsize) +{ + struct hmac_ctx ctx; + + hmac_init(&ctx, algo, hkey, hkeysize); + hmac_update(&ctx, data, datasize); + /* mdsize == 0 means "Give me the whole hash!" */ + if (mdsize == 0) + mdsize = ctx.hash->digest_len; + hmac_final(&ctx, md, mdsize); +} Added: soc2013/def/crashdump-head/sys/crypto/hmac/hmac.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sys/crypto/hmac/hmac.h Mon Jul 29 18:21:26 2013 (r255309) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2005-2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS_CRYPTO_HMAC_H +#define _SYS_CRYPTO_HMAC_H + +#include + +#define HMAC_BLOCK_LENGTH_MAX SHA512_BLOCK_LENGTH +#define HMAC_DIGEST_LENGTH_MAX SHA512_DIGEST_LENGTH + +struct hmac_hash; + +struct hmac_ctx { + const struct hmac_hash *hash; + union hmac_hash_ctx { + SHA256_CTX sha256_ctx; + SHA384_CTX sha384_ctx; + SHA512_CTX sha512_ctx; + } hash_ctx; + u_char k_opad[HMAC_BLOCK_LENGTH_MAX]; +}; + +void hmac_init(struct hmac_ctx *ctx, int algo, const uint8_t *hkey, + size_t hkeylen); +void hmac_update(struct hmac_ctx *ctx, const uint8_t *data, + size_t datasize); +void hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize); +void hmac(int algo, const uint8_t *hkey, size_t hkeysize, + const uint8_t *data, size_t datasize, uint8_t *md, size_t mdsize); + +#endif /* _SYS_CRYPTO_HMAC_H */ Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Mon Jul 29 18:21:26 2013 (r255309) @@ -31,6 +31,7 @@ #include #include +#include #define XTS_BLK_BYTES 16 #define XTS_BLK_MASK (XTS_BLK_BYTES - 1) @@ -42,6 +43,7 @@ union { camellia_ctx pctx_camellia; rijndael_ctx pctx_aes; + struct hmac_ctx pctx_hmac; } o; } __aligned(CACHE_LINE_SIZE); Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Jul 29 18:21:26 2013 (r255309) @@ -86,7 +86,7 @@ #include -#include +#include #ifndef PANIC_REBOOT_WAIT_TIME #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ @@ -145,8 +145,8 @@ int dumping; /* system is dumping */ int rebooting; /* system is rebooting */ static struct dumperinfo dumper; /* our selected dumper */ -static rijndael_ctx dumper_tweak_ctx; -static rijndael_ctx dumper_data_ctx; +static struct kerneldumpkey dumperkey; +static struct kerneldumpbuffer dumperbuffer; /* Context information for dump-debuggers. */ static struct pcb dumppcb; /* Registers. */ @@ -851,6 +851,8 @@ if (dumper.dumper != NULL) return (EBUSY); dumper = *di; + dumper.kdk = &dumperkey; + dumper.kdb = &dumperbuffer; kerneldump_crypto_init(&dumper); @@ -867,6 +869,8 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, off_t offset, size_t length) { + struct kerneldumpkey *kdk; + struct kerneldumpbuffer *kdb; size_t resid; int error; @@ -879,65 +883,126 @@ return (ENOSPC); } + kdk = di->kdk; + kdb = di->kdb; + /* Write kernel dump headers. */ - if (di->realoffset == 0 || offset == di->mediaoffset + di->mediasize - + if (kdb->realoffset == 0 || offset == di->mediaoffset + di->mediasize - sizeof(struct kerneldumpheader)) { - di->realoffset = offset + length; + kdb->realoffset = offset + length; return (di->dumper(di->priv, virtual, physical, offset, length)); } /* The last dump_write call in the current crash. */ if (virtual == NULL && physical == 0 && offset == 0 && length == 0) { - xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, - di->offset, di->tweak, di->buf_used, - di->buf, di->buf); - return (di->dumper(di->priv, di->buf, physical, di->realoffset, di->buf_used)); - } - - while (length + di->buf_used >= DUMPER_BUFSIZE) { - resid = DUMPER_BUFSIZE - di->buf_used; - memcpy(di->buf + di->buf_used, virtual, resid); - di->buf_used += resid; - - xts_block_encrypt(&xts_alg_aes, di->tweak_ctx, di->data_ctx, - di->offset, di->tweak, DUMPER_BUFSIZE, - di->buf, di->buf); + xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, + kdb->offset, kdk->tweak, kdb->used, + kdb->buf, kdb->buf); + return (di->dumper(di->priv, di->kdb->buf, physical, kdb->realoffset, kdb->used)); + } + + while (length + kdb->used >= KERNELDUMP_BUFFER_SIZE) { + resid = KERNELDUMP_BUFFER_SIZE - kdb->used; + memcpy(kdb->buf + kdb->used, virtual, resid); + kdb->used += resid; + + xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, + kdb->offset, kdk->tweak, KERNELDUMP_BUFFER_SIZE, + kdb->buf, kdb->buf); - error = (di->dumper(di->priv, di->buf, physical, di->realoffset, DUMPER_BUFSIZE)); + error = (di->dumper(di->priv, kdb->buf, physical, kdb->realoffset, KERNELDUMP_BUFFER_SIZE)); if (error) return (error); virtual = (void *)((char *)virtual + resid); length -= resid; - di->buf_used = 0; - di->realoffset += resid; - di->offset += DUMPER_BUFSIZE; + kdb->used = 0; + kdb->realoffset += resid; + kdb->offset += KERNELDUMP_BUFFER_SIZE; } /* We still have less than blocksize of data to dump. */ if (length > 0) { - memcpy(di->buf + di->buf_used, virtual, length); - di->buf_used += length; + memcpy(kdb->buf + kdb->used, virtual, length); + kdb->used += length; } return (0); } +static void +kerneldump_hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, + int idx, const uint8_t *magic, size_t magicsize) +{ + uint8_t byte_idx = idx; + + hmac_init(&ctx->o.pctx_hmac, CRYPTO_SHA2_512_HMAC, + masterkey, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, magic, magicsize); + hmac_update(&ctx->o.pctx_hmac, &byte_idx, sizeof(byte_idx)); + hmac_final(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); +} + void kerneldump_crypto_init(struct dumperinfo *di) { + if (di->kdk == NULL || di->kdb == NULL) { + printf("Attempt to initialize a non-existing kernel dump key and buffer."); + return; + } + /* In the future the tweak will be set via sysctl. */ - arc4rand(kerneldumptweak, KERNELDUMP_TWEAK_SIZE, 0); - di->key = (char *)kerneldumpkey; - di->tweak = kerneldumptweak; - di->tweak_ctx = &dumper_tweak_ctx; - di->data_ctx = &dumper_data_ctx; - di->buf_used = 0; - di->realoffset = 0; - di->offset = 0; - rijndael_set_key(di->tweak_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); - rijndael_set_key(di->data_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); + arc4rand(kerneldump_tweak, KERNELDUMP_TWEAK_SIZE, 0); + + di->kdk = kerneldump_set_key(di->kdk, KERNELDUMP_KEY_SIZE, kerneldump_key, kerneldump_tweak); + di->kdb = kerneldump_set_buffer(di->kdb); +} + +struct kerneldumpkey * +kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *masterkey, char *tweak) +{ + uint8_t key[KERNELDUMP_KEY_SIZE]; + struct xts_ctx ctx; + + if (kdk == NULL) { + printf("Cannot initialize kernel dump key."); + return (NULL); + } + + kdk->keysize = keysize; + memcpy(kdk->key, masterkey, kdk->keysize); + memcpy(kdk->tweak, tweak, KERNELDUMP_TWEAK_SIZE); + bzero(&kdk->tweak_ctx, sizeof(kdk->tweak_ctx)); + bzero(&kdk->data_ctx, sizeof(kdk->data_ctx)); + bzero(key, KERNELDUMP_KEY_SIZE); + + kerneldump_hkdf_expand(&ctx, kdk->key, key, 1, kerneldump_magic, sizeof(kerneldump_magic)); + xts_alg_aes.pa_keysetup(&kdk->data_ctx, key, kdk->keysize << 3); + + kerneldump_hkdf_expand(&ctx, kdk->key, key, 2, kerneldump_magic, sizeof(kerneldump_magic)); + xts_alg_aes.pa_keysetup(&kdk->tweak_ctx, key, kdk->keysize << 3); + + bzero(&ctx, sizeof(ctx)); + bzero(key, KERNELDUMP_KEY_SIZE); + + return (kdk); +} + +struct kerneldumpbuffer * +kerneldump_set_buffer(struct kerneldumpbuffer *kdb) +{ + if (kdb == NULL) { + printf("Cannot initialize kernel dump buffer."); + return (NULL); + } + + kdb->used = 0; + kdb->realoffset = 0; + kdb->offset = 0; + + return (kdb); } void @@ -957,9 +1022,8 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); - kdh->keysize = KERNELDUMP_KEY_SIZE; - strncpy(kdh->key, dumper.key, kdh->keysize); - kdh->tweaksize = KERNELDUMP_TWEAK_SIZE; - strncpy(kdh->tweak, dumper.tweak, kdh->tweaksize); + kdh->keysize = dumper.kdk->keysize; + strncpy(kdh->key, dumper.kdk->key, kdh->keysize); + strncpy(kdh->tweak, dumper.kdk->tweak, KERNELDUMP_TWEAK_SIZE); kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sys/sys/conf.h Mon Jul 29 18:21:26 2013 (r255309) @@ -323,7 +323,8 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* Stuff relating to kernel-dump */ -#define DUMPER_BUFSIZE 4096 +struct kerneldumpkey; +struct kerneldumpbuffer; struct dumperinfo { dumper_t *dumper; /* Dumping function. */ @@ -332,14 +333,8 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ - char *key; /* Key information. */ - char *tweak; /* Tweak. */ - void *tweak_ctx; /* Tweak context. */ - void *data_ctx; /* Data context. */ - uint8_t buf[DUMPER_BUFSIZE]; /* Raw data buffer. */ - u_int buf_used; /* Number of bytes used in the buffer. */ - off_t offset; /* Last used offset in a xts_block_encrypt call. */ - off_t realoffset; /* Last used offset in a dump_write call. */ + struct kerneldumpkey *kdk; /* Kernel dump key. */ + struct kerneldumpbuffer *kdb; /* Kernel dump buffer. */ }; int set_dumper(struct dumperinfo *, const char *_devname); Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Mon Jul 29 18:02:29 2013 (r255308) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Mon Jul 29 18:21:26 2013 (r255309) @@ -39,6 +39,7 @@ #define _SYS_KERNELDUMP_H #include +#include #if BYTE_ORDER == LITTLE_ENDIAN #define dtoh32(x) __bswap32(x) @@ -81,15 +82,16 @@ uint64_t dumptime; uint32_t blocksize; char hostname[64]; - char versionstring[168]; - char panicstring[168]; + char versionstring[170]; + char panicstring[170]; int keysize; char key[KERNELDUMP_KEY_SIZE]; - int tweaksize; char tweak[KERNELDUMP_TWEAK_SIZE]; uint32_t parity; }; +static const char kerneldump_magic[] = "PEFSKEY-V1"; + /* * Parity calculation is endian insensitive. */ @@ -110,15 +112,33 @@ /* * Constant key for kernel crash dumps. */ -static const char kerneldumpkey[32] = { +static char kerneldump_key[KERNELDUMP_KEY_SIZE] = { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }; -static char kerneldumptweak[KERNELDUMP_TWEAK_SIZE]; +static char kerneldump_tweak[KERNELDUMP_TWEAK_SIZE]; + +struct kerneldumpkey { + int keysize; + char key[KERNELDUMP_KEY_SIZE]; + char tweak[KERNELDUMP_TWEAK_SIZE]; + struct xts_ctx data_ctx; + struct xts_ctx tweak_ctx; +}; + +struct kerneldumpbuffer { +#define KERNELDUMP_BUFFER_SIZE 4096 + uint8_t buf[KERNELDUMP_BUFFER_SIZE]; /* Raw data buffer. */ + u_int used; /* Number of bytes used in the buffer. */ + off_t offset; /* Last used offset in a xts_block_encrypt call. */ + off_t realoffset; /* Last used offset in a dump_write call. */ +}; void kerneldump_crypto_init(struct dumperinfo *di); +struct kerneldumpkey *kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *key, char *tweak); +struct kerneldumpbuffer *kerneldump_set_buffer(struct kerneldumpbuffer *kdb); void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 03:18:32 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A1F38783 for ; Tue, 30 Jul 2013 03:18:32 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8EA6D2FEB for ; Tue, 30 Jul 2013 03:18:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U3IWdN085286 for ; Tue, 30 Jul 2013 03:18:32 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U3IW9i085271 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 03:18:32 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 03:18:32 GMT Message-Id: <201307300318.r6U3IW9i085271@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255327 - soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 03:18:32 -0000 Author: jmuniz Date: Tue Jul 30 03:18:32 2013 New Revision: 255327 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255327 Log: Updated PackageKit-qt4 port Makefile. Removed the IGNORE variable, as the port now works with Qt 4.8. Changed the revision number. Modified: soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile Modified: soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile Tue Jul 30 02:26:06 2013 (r255326) +++ soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile Tue Jul 30 03:18:32 2013 (r255327) @@ -6,13 +6,11 @@ # $MCom: ports/ports-mgmt/packagekit-qt4/Makefile,v 1.1 2010/01/08 02:16:38 kwm Exp $ # -PORTREVISION= 1 +PORTREVISION= 2 PKGNAMESUFFIX= -qt4 COMMENT= Qt4 bindings to packagekit -IGNORE= does not build with Qt 4.8 - MASTERDIR= ${.CURDIR}/../../ports-mgmt/packagekit BUILD_WRKSRC= ${WRKSRC}/lib/packagekit-qt INSTALL_WRKSRC= ${WRKSRC}/lib/packagekit-qt From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 03:33:43 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5A82C9F3 for ; Tue, 30 Jul 2013 03:33:43 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 474E8207F for ; Tue, 30 Jul 2013 03:33:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U3XhgR090054 for ; Tue, 30 Jul 2013 03:33:43 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U3XhS9090052 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 03:33:43 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 03:33:43 GMT Message-Id: <201307300333.r6U3XhS9090052@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255328 - soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 03:33:43 -0000 Author: jmuniz Date: Tue Jul 30 03:33:42 2013 New Revision: 255328 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255328 Log: Improved the PackageKit port Makefile. Removed '?'s because this is not a slave port. Moved docbook-utils dependency to where it belongs: DOCS. Added p5-SGMLSpm, libffi, and p5-XML-Parser to dependencies. Fixed a few variables that were not in braces. Moved manpages to DOCS option, making it default. Combined the back end options into a single selection group. Updated the descriptions of the options to prepare for Matt's back end. Worked on standardizing the syntax. Got rid of the tests to determine the default back end. Simplified the back end option code. Fixed issue where PackageKit-qt4 could not be built with Qt 4.8; it was a simple matter of regenerating the moc files. Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Tue Jul 30 03:18:32 2013 (r255327) +++ soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Tue Jul 30 03:33:42 2013 (r255328) @@ -4,19 +4,22 @@ PORTNAME= PackageKit PORTVERSION= 0.6.11 -PORTREVISION?= 4 +PORTREVISION= 4 CATEGORIES= ports-mgmt sysutils MASTER_SITES= http://www.packagekit.org/releases/ MAINTAINER= gnome@FreeBSD.org -COMMENT?= DBUS packaging abstraction layer +COMMENT= DBUS packaging abstraction layer -BUILD_DEPENDS= ${LOCALBASE}/bin/docbook2man:${PORTSDIR}/textproc/docbook-utils \ - ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection +BUILD_DEPENDS= ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ + ${LOCALBASE}/bin/sgmlspl:${PORTSDIR}/textproc/p5-SGMLSpm/pkg-plist LIB_DEPENDS= execinfo:${PORTSDIR}/devel/libexecinfo \ dbus-glib-1:${PORTSDIR}/devel/dbus-glib \ polkit-gobject-1:${PORTSDIR}/sysutils/polkit \ - ck-connector:${PORTSDIR}/sysutils/consolekit + ck-connector:${PORTSDIR}/sysutils/consolekit \ + libffi:${PORTSDIR}/devel/libffi \ + Expat:${PORTSDIR}/textproc/p5-XML-Parser + RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof \ ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ ${LOCALBASE}/share/mime/magic:${PORTSDIR}/misc/shared-mime-info @@ -42,80 +45,78 @@ MAKE_JOBS_UNSAFE=yes -.if !defined(SLAVEPORT) -OPTIONS_DEFINE= MANPAGES PORTS PKGNG DUMMY + +.if !defined(${SLAVEPORT}) +OPTIONS_DEFINE= DOCS +OPTIONS_SINGLE= BACKEND +OPTIONS_SINGLE_BAKCEND= PORTS PKGNG DUMMY OPTIONS_DEFAULT=PORTS -PORTS_DESC= Include back end to use portupgrade and pkg -PKGNG_DESC= Include pkgng back end for software management -DUMMY_DESC= Include dummy back end for testing purposes +PORTS_DESC= Ruby back end for traditional or new binary packages +PKGNG_DESC= C back end for PGN Next Generation, specifically +DUMMY_DESC= The dummy back end for developers .include -. if ${PORT_OPTIONS:MMANPAGES} -BUILD_DEPENDS+= ${LOCALBASE}/share/sgml/docbook/4.1/dtd/catalog:${PORTSDIR}/textproc/docbook-410 \ +.if ${PORT_OPTIONS:MDOCS} +BUILD_DEPENDS+= ${LOCALBASE}/bin/docbook2man:${PORTSDIR}/textproc/docbook-utils \ + ${LOCALBASE}/share/sgml/docbook/4.1/dtd/catalog:${PORTSDIR}/textproc/docbook-410 \ xsltproc:${PORTSDIR}/textproc/libxslt \ ${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl \ ${LOCALBASE}/share/xml/docbook/4.2/catalog.xml:${PORTSDIR}/textproc/docbook-xml MAN1= pkcon.1 pkmon.1 pkgenpack.1 pk-debuginfo-install.1 -. else +.else CONFIGURE_ARGS+=--disable-man-pages -. endif +.endif -. if ${PORT_OPTIONS:MDUMMY} || ( ! ${PORT_OPTIONS:MDUMMY} && ! ${PORT_OPTIONS:MPORTS} && ! ${PORT_OPTIONS:MPKGNG} ) -. if ! ${PORT_OPTIONS:MPORTS} && ! ${PORT_OPTIONS:MPKGNG} -CONFIGURE_ARGS+=--with-default-backend=dummy +.if ${PORT_OPTIONS:MDUMMY} +CONFIGURE_ARGS+=--with-default-backend=dummy \ + --enable-dummy PLIST_SUB+= BACKENDS="@comment " -.endif -CONFIGURE_ARGS+=--enable-dummy .else CONFIGURE_ARGS+=--disable-dummy .endif -. if ${PORT_OPTIONS:MPORTS} || ${PORT_OPTIONS:MPKGNG -PLIST_SUB+= BACKENDS="" -. endif - -. if ! ${PORT_OPTIONS:MPORTS} -CONFIGURE_ARGS+=--disable-ports -PLIST_SUB+= PORTS="@comment " -. endif - -. if ! ${PORT_OPTIONS:MPKGNG} -CONFIGURE_ARGS+=--disable-pkgng -PLIST_SUB+= PKGNG="@comment " -. endif - -. if ${PORT_OPTIONS:MPORTS} -. if ! ${PORT_OPTIONS:MPKGNG} -CONFIGURE_ARGS+=--with-default-backend=ports -. endif +.if ${PORT_OPTIONS:MPORTS} RUN_DEPENDS+= ${LOCALBASE}/sbin/portupgrade:${PORTSDIR}/ports-mgmt/portupgrade USE_RUBY= yes -CONFIGURE_ARGS+=--enable-ports -PLIST_SUB+= PORTS="" -. endif +CONFIGURE_ARGS+=--enable-ports \ + --with-default-backend=ports +PLIST_SUB+= PORTS="" \ + BACKENDS="" +.endif -. if ${PORT_OPTIONS:MPKGNG} +.if ${PORT_OPTIONS:MPKGNG} RUN_DEPENDS+= ${LOCALBASE}/sbin/pkg:${PORTSDIR}/ports-mgmt/pkg CONFIGURE_ARGS+=--enable-pkgng \ --with-default-backend=pkgng -PLIST_SUB+= PKGNG="" +PLIST_SUB+= PKGNG="" \ + BACKENDS="" .endif CONFIGURE_ARGS+=--disable-gtk-module PLIST_SUB+= GTK="@comment " - CONFIGURE_ARGS+=--disable-qt .elif defined(${SLAVEPORT}) && ${SLAVEPORT}=="qt4" LIB_DEPENDS+= packagekit-glib2:${PORTSDIR}/ports-mgmt/packagekit - CONFIGURE_ARGS+=--enable-qt LIB_DEPENDS+= cppunit-1.12:${PORTSDIR}/devel/cppunit USE_QT4+= dbus gui xml sql moc_build #.include "${PORTSDIR}/Mk/bsd.qt.mk" .endif +post-fetch: +.if defined(${SLAVEPORT}) && ${SLAVEPORT}=="qt4" + (cd ${WRKSRC}/lib/packagekit-qt/src && \ + moc-qt4 ./client.h -o ./client.moc && \ + moc-qt4 ./clientprivate.h -o ./clientprivate.moc && \ + moc-qt4 ./daemonproxy.h -o ./daemonproxy.moc && \ + moc-qt4 ./enum.h -o ./enum.moc && \ + moc-qt4 ./transaction.h -o ./transaction.moc && \ + moc-qt4 ./transactionprivate.h -o ./transactionprivate.moc && \ + moc-qt4 ./transactionproxy.h -o ./transactionproxy.moc) +.endif + post-patch: @${REINPLACE_CMD} -E -e 's/.*WARNINGFLAGS_CPP.*-Werror/#$$&/' \ -e 's|-Wmissing-include-dirs||g' ${WRKSRC}/configure @@ -127,7 +128,7 @@ '/xsltproc/s|.xsl [$$]? &> /dev|.xsl $$? > /dev|g' post-install: -.if !defined(SLAVEPORT) +.if !defined(${SLAVEPORT}) @${INSTALL_DATA} ${WRKSRC}/data/transactions.db \ ${PREFIX}/share/PackageKit/transactions.db @-update-mime-database ${PREFIX}/share/mime > /dev/null From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 03:50:11 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 42B23D54 for ; Tue, 30 Jul 2013 03:50:11 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D1B352107 for ; Tue, 30 Jul 2013 03:50:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U3oAqb047780 for ; Tue, 30 Jul 2013 03:50:10 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U3oAtk047768 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 03:50:10 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 03:50:10 GMT Message-Id: <201307300350.r6U3oAtk047768@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255329 - soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 03:50:11 -0000 Author: jmuniz Date: Tue Jul 30 03:50:10 2013 New Revision: 255329 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255329 Log: Removed an extra line in the PackageKit port Makefile. Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Tue Jul 30 03:33:42 2013 (r255328) +++ soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Tue Jul 30 03:50:10 2013 (r255329) @@ -19,7 +19,6 @@ ck-connector:${PORTSDIR}/sysutils/consolekit \ libffi:${PORTSDIR}/devel/libffi \ Expat:${PORTSDIR}/textproc/p5-XML-Parser - RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof \ ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ ${LOCALBASE}/share/mime/magic:${PORTSDIR}/misc/shared-mime-info From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 03:59:49 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A9680DEF for ; Tue, 30 Jul 2013 03:59:49 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7D50C214D for ; Tue, 30 Jul 2013 03:59:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U3xn1Z042927 for ; Tue, 30 Jul 2013 03:59:49 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U3xnZv042925 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 03:59:49 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 03:59:49 GMT Message-Id: <201307300359.r6U3xnZv042925@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255330 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 03:59:49 -0000 Author: jmuniz Date: Tue Jul 30 03:59:49 2013 New Revision: 255330 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255330 Log: Updated BUGS. Moved tray icon auto-start setting to TODO. Removed PackageKit-qt4 bug, which was fixed in one of the latest revisions. Removed the DBus session connection warning from the bug list: it is common for programs built with Qt 4.8 and is nothing to worry about. 'pending change' button works just fine now. Added dependnecies, which removed bugs from PackageKit, and gnome-packagekit. Icons now all appear in the application launcher. Modified: soc2013/jmuniz/BUGS Modified: soc2013/jmuniz/BUGS ============================================================================== --- soc2013/jmuniz/BUGS Tue Jul 30 03:50:10 2013 (r255329) +++ soc2013/jmuniz/BUGS Tue Jul 30 03:59:49 2013 (r255330) @@ -6,32 +6,18 @@ - download - remove - get-depends -- add dependency check for libffi.so.5 (symlink for now) + bugs that may already be resolved (test once possible) -- may have trouble queuing multiple transactions -- may crash when no file list is available for a given package gnome-packagekit ---------------- -- help functionality requires yelp to be properly installed (certain shared library versions) + gpk-update-icon --- (13180) DBus warning, error sending message; did not receive a reply --- crashes before ever showing the tray icon --- make sure this is set to start at boot (if user prefers) +-- (13180) DBus warning, error sending message; did not receive a reply. Tray icon can never launch. + gpk-application --- no icon in application launcher (perhaps related to a .desktop file) --+ non-critical ---- icons for categories move to the right if application is opened more than once +-- icons for categories move to the right if application is opened more than once KPackageKit ----------- - crashes when clicking on category in list box -- crashes when clicking "pending changes" -+ non-critical --- warning: session DBus connection created before QCoreApplication --- description glitches when rising after being hidden - -PackageKit-qt4 --------------- -- does not build with Qt-4.8 - +- description glitches when rising after being hidden From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 04:05:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5AE45E6A for ; Tue, 30 Jul 2013 04:05:26 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 39CC52184 for ; Tue, 30 Jul 2013 04:05:26 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U45PI8048388 for ; Tue, 30 Jul 2013 04:05:25 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U45Plg048382 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 04:05:25 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 04:05:25 GMT Message-Id: <201307300405.r6U45Plg048382@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255331 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 04:05:26 -0000 Author: jmuniz Date: Tue Jul 30 04:05:25 2013 New Revision: 255331 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255331 Log: Updated ChangeLog to contain recent commits. Modified: soc2013/jmuniz/ChangeLog Modified: soc2013/jmuniz/ChangeLog ============================================================================== --- soc2013/jmuniz/ChangeLog Tue Jul 30 03:59:49 2013 (r255330) +++ soc2013/jmuniz/ChangeLog Tue Jul 30 04:05:25 2013 (r255331) @@ -1,3 +1,68 @@ +2013-07-30 03:59 jmuniz + + * BUGS: Updated BUGS. Moved tray icon auto-start setting to TODO. + Removed PackageKit-qt4 bug, which was fixed in one of the latest + revisions. Removed the DBus session connection warning from the + bug list: it is common for programs built with Qt 4.8 and is + nothing to worry about. 'pending change' button works just fine + now. Added dependnecies, which removed bugs from PackageKit, and + gnome-packagekit. Icons now all appear in the application + launcher. + +2013-07-30 03:50 jmuniz + + * PackageKit/PackageKit-0.6.11/packagekit/Makefile: Removed an + extra line in the PackageKit port Makefile. + +2013-07-30 03:33 jmuniz + + * PackageKit/PackageKit-0.6.11/packagekit/Makefile: Improved the + PackageKit port Makefile. Removed '?'s because this is not a + slave port. Moved docbook-utils dependency to where it belongs: + DOCS. Added p5-SGMLSpm, libffi, and p5-XML-Parser to + dependencies. Fixed a few variables that were not in braces. + Moved manpages to DOCS option, making it default. Combined the + back end options into a single selection group. Updated the + descriptions of the options to prepare for Matt's back end. + Worked on standardizing the syntax. Got rid of the tests to + determine the default back end. Simplified the back end option + code. Fixed issue where PackageKit-qt4 could not be built with Qt + 4.8; it was a simple matter of regenerating the moc files. + +2013-07-30 03:18 jmuniz + + * PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile: + Updated PackageKit-qt4 port Makefile. Removed the IGNORE + variable, as the port now works with Qt 4.8. Changed the revision + number. + +2013-07-29 14:59 jmuniz + + * TODO: Greatly expanded on the task list in TODO. I added most of + the current files and sub-projects to the document; and for each + area, I listed all of the current tasks. I updated the task list + for pk-setter. Note that now optional tasks are labeled as such, + and the whole document has moved from a list structure to a tree + structure. + +2013-07-29 13:24 jmuniz + + * ChangeLog: Created an automatically generated change log, which + is useful when accessing the code repository from an offline + setting. + +2013-07-29 13:21 jmuniz + + * FAQ, INSTALL, NEWS, TESTING, THANKS: Created five initial + documentation files to better organize information regarding this + repository. + +2013-07-29 12:52 jmuniz + + * BUGS: Created BUGS file to contain a list of known bugs for the + repository, sorted by area affected. I have populated the file + with a list that had previously existed on paper. + 2013-07-17 12:59 jmuniz * PackageKit/PackageKit-0.6.11/packagekit/pkg-plist: Updated From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 06:28:21 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3B36DF8F for ; Tue, 30 Jul 2013 06:28:21 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0DBAE25E5 for ; Tue, 30 Jul 2013 06:28:21 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U6SKV5037425 for ; Tue, 30 Jul 2013 06:28:20 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U6SKXj037423 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 06:28:20 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 06:28:20 GMT Message-Id: <201307300628.r6U6SKXj037423@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255332 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 06:28:21 -0000 Author: jmuniz Date: Tue Jul 30 06:28:20 2013 New Revision: 255332 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255332 Log: Tidied up TODO. Removed recently completed tasks, consolidated some others. Modified: soc2013/jmuniz/TODO Modified: soc2013/jmuniz/TODO ============================================================================== --- soc2013/jmuniz/TODO Tue Jul 30 04:05:25 2013 (r255331) +++ soc2013/jmuniz/TODO Tue Jul 30 06:28:20 2013 (r255332) @@ -22,7 +22,6 @@ -- Wiki -- Makefile -- PK-0.6.11 patches --- PK-qt -- KPackageKit port -- KPackageKit patches -- gnome-packagekit port @@ -113,13 +112,9 @@ + pkgng back end -- evaluate necessity of additional functions (not used in ports back end) -- patch new back end into new port revision --- detect pkg installation, and if pkg2ng needs to be run + pk-backend-pkgng.c -- comment, add header -- test -+ configure / configure.ac --- once the pkgng back end is finished, the pkgng back end can be default over the ports back end --- test, make sure that these files are enough or even necessary to include the pkgng back end + pkgngBackend.rb -+ optional --- show unavailable file lists by downloading the plist from freebsd.org @@ -132,10 +127,8 @@ + Makefile - find a better way to add site_ruby/1.8/pkgtools to ruby 1.9 include path -+ optional ---- set appropriate option defaults --- create an option to install pk-setter AFTER PK; this should prevent circular dependency ---- back end options should be in a multiple choice list that tolerates no less than one back end ---- move manpages to DOC option, and replace manpage generation with a manpage patch +--- replace manpage generation with a manpage patch --- save a copy of PackageKit.conf to PackageKit.conf.sample for default configuration recovery + pkg-plist -- edit to reflect permanent pkgng back end files, in the future @@ -150,19 +143,13 @@ + files/ -- add patches + optional --- clicking on an item in a dependency list should open that items information --- easy method of setting an option to automatically start tray icon at login -- update port to Apper-0.8.0 gnome-packagekit-2.32.0 port ---------------------------- -- make sure that libgcrypt dependency is taken care of + optional -- upgrade port to latest version -PackageKit-qt4-0.6.11 port --------------------------- - KPackageKit-0.6.3.3 patches --------------------------- - enable help button, patch in help files @@ -171,6 +158,7 @@ -+ optional --- combine main window with update window using tabs --- preference option available to keep selections when navigating tabs (default: true) +--- clicking on an item in a dependency list should open that items information + source code files gnome-packagekit-2.32.0 patches From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 06:36:39 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 65F4F24B for ; Tue, 30 Jul 2013 06:36:39 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 523AD2645 for ; Tue, 30 Jul 2013 06:36:39 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U6adxj014005 for ; Tue, 30 Jul 2013 06:36:39 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6U6ad9Y014000 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 06:36:39 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 06:36:39 GMT Message-Id: <201307300636.r6U6ad9Y014000@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255333 - soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 06:36:39 -0000 Author: jmuniz Date: Tue Jul 30 06:36:39 2013 New Revision: 255333 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255333 Log: Added two dependencies to gnome-packagekit port Makefile. These help better round out the installation, and fix problems building and running the application. Modified: soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile Modified: soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile ============================================================================== --- soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile Tue Jul 30 06:28:20 2013 (r255332) +++ soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile Tue Jul 30 06:36:39 2013 (r255333) @@ -20,7 +20,9 @@ notify.4:${PORTSDIR}/devel/libnotify \ unique-1.0:${PORTSDIR}/x11-toolkits/unique \ upower-glib.1:${PORTSDIR}/sysutils/upower \ - canberra-gtk.0:${PORTSDIR}/audio/libcanberra + canberra-gtk.0:${PORTSDIR}/audio/libcanberra \ + libgcrypt.18:${PORTSDIR}/security/libgcrypt +RUN_DEPENDS= yelp:${PORTSDIR}/x11/yelp USE_GMAKE= yes USE_BZIP2= yes From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 15:08:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 195C0BB3 for ; Tue, 30 Jul 2013 15:08:18 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 04E6F298D for ; Tue, 30 Jul 2013 15:08:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UF8HNb008792 for ; Tue, 30 Jul 2013 15:08:17 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6UF8HkF008754 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 15:08:17 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 30 Jul 2013 15:08:17 GMT Message-Id: <201307301508.r6UF8HkF008754@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255350 - in soc2013/dpl: . libnv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 15:08:18 -0000 Author: dpl Date: Tue Jul 30 15:08:17 2013 New Revision: 255350 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255350 Log: Adding pjd's libnv, since it will be used from now on to serializing the commands arguments sent to the client. Added: soc2013/dpl/libnv/ soc2013/dpl/libnv/Makefile soc2013/dpl/libnv/msgio.c soc2013/dpl/libnv/msgio.h soc2013/dpl/libnv/nv.h soc2013/dpl/libnv/nv_impl.h soc2013/dpl/libnv/nvlist.c soc2013/dpl/libnv/nvlist_impl.h soc2013/dpl/libnv/nvpair.c soc2013/dpl/libnv/nvpair_impl.h Modified: soc2013/dpl/caller.c Modified: soc2013/dpl/caller.c ============================================================================== --- soc2013/dpl/caller.c Tue Jul 30 14:50:44 2013 (r255349) +++ soc2013/dpl/caller.c Tue Jul 30 15:08:17 2013 (r255350) @@ -11,12 +11,9 @@ #include -struct pollfd fdread[1], fdwrite[1]; pid_t child = 0; int sv[2], i; -int *buf[32]; - pid_t startChild(); void waitCommand(); void killChild(); @@ -30,19 +27,17 @@ { int ret, a = 1; ret = sum(a); - fflush(stdout); printf("ret: %d (should be 2)\n", ret); - fflush(stdout); - atexit(killChild); return 0; } int sum(int a) { + struct pollfd fdread[1], fdwrite[1]; + int buf[32]; /* Caller overhead */ /* Much better if we do this in a function */ - int ptr = (int)sum_; fdwrite[0].fd = sv[0]; fdwrite[0].events = POLLOUT; fdwrite[0].revents = 0; @@ -53,8 +48,8 @@ startChild(); /* Real stuff */ - buf[0] = &ptr; - buf[1] = &a; + buf[0] = 1; + buf[1] = a; /* Should be in a function as well */ /* sendAndWait() (?) */ @@ -71,9 +66,9 @@ break; } } - printf("done: %d\n", *buf[0]); + printf("done: %d\n", buf[0]); - return *buf[0]; + return buf[0]; } int sum_(int a) @@ -90,7 +85,9 @@ close(STDERR_FILENO); cap_enter(); waitCommand(); - } + } else + atexit(killChild); + return child; } @@ -100,6 +97,7 @@ waitCommand() { struct pollfd fdread[1], fdwrite[1]; + int buf[32]; fdread[0].fd = sv[1]; fdread[0].events = POLLIN|POLLPRI; fdread[0].revents = 0; @@ -114,14 +112,13 @@ } } - if( (void *)*buf[0] == (void *) sum_ ){ - /* This is a C exercise }:-) */ - int ret = ((int (*) (int)) *buf[0])(*buf[1]); - /* int ret = sum_(*buf[1]); */ + if( buf[0] == 1 ){ + /* We still have to take recv nvlist */ + int ret = sum(buf[1]); printf("ret:%d\n", ret); fflush(stdout); bzero(&buf, sizeof(buf)); - buf[0] = &ret; + buf[0] = ret; } while(1) { @@ -136,5 +133,5 @@ void killChild() { - kill(child, SIGINT); + kill(child, SIGKILL); } \ No newline at end of file Added: soc2013/dpl/libnv/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/Makefile Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +LIB= nv +SHLIBDIR?= /lib +SHLIB_MAJOR= 0 + +SRCS= msgio.c +SRCS+= nvlist.c +SRCS+= nvpair.c +INCS= nv.h + +CFLAGS+=-ggdb + +.include Added: soc2013/dpl/libnv/msgio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/msgio.c Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,350 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_PJDLOG +#include +#endif + +#include "msgio.h" + +#ifndef HAVE_PJDLOG +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#define PJDLOG_RASSERT(expr, ...) assert(expr) +#define PJDLOG_ABORT(...) abort() +#endif + +int +msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov) +{ + int serrno; + + bzero(msg, sizeof(*msg)); + bzero(iov, sizeof(*iov)); + + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + if (datasize == 0) + return (0); + + if (nfds > 0) { + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + } + + iov->iov_len = datasize; + iov->iov_base = malloc(iov->iov_len); + if (iov->iov_base == NULL) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + + return (0); +} + +static bool +fd_is_valid(int fd) +{ + + return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); +} + +static int +msghdr_add_fd(struct msghdr *msg, struct cmsghdr **cmsgp, int fd) +{ + struct cmsghdr *cmsg; + + PJDLOG_ASSERT(fd >= 0); + + if (!fd_is_valid(fd)) { + errno = EBADF; + return (-1); + } + + cmsg = *cmsgp; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); + bcopy(&fd, CMSG_DATA(cmsg), sizeof(fd)); + *cmsgp = CMSG_NXTHDR(msg, cmsg); + + return (0); +} + +int +msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int serrno; + + if (nfds == 0) { + msg->msg_control = NULL; + msg->msg_controllen = 0; + return (0); + } + + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds; ii++) { + if (msghdr_add_fd(msg, &cmsg, fds[ii]) == -1) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + } + + return (0); +} + +static struct cmsghdr * +msghdr_get_fd(struct msghdr *msg, struct cmsghdr *cmsg, int *fdp) +{ + + if (cmsg == NULL || cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_RIGHTS) { + return (NULL); + } + + bcopy(CMSG_DATA(cmsg), fdp, sizeof(*fdp)); +#ifndef MSG_CMSG_CLOEXEC + /* + * If the MSG_CMSG_CLOEXEC flag is not available we cannot set the + * close-on-exec flag atomically, but we still want to set it for + * consistency. + */ + (void) fcntl(*fdp, F_SETFD, FD_CLOEXEC); +#endif + + return (CMSG_NXTHDR(msg, cmsg)); +} + +int * +msghdr_fds_to_array(struct msghdr *msg, size_t nfds) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int *fds; + + fds = malloc(sizeof(fds[0]) * nfds); + if (fds == NULL) + return (NULL); + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds && cmsg != NULL; ii++) + cmsg = msghdr_get_fd(msg, cmsg, &fds[ii]); + if (cmsg != NULL || ii < nfds) { + free(fds); + fds = NULL; + } + + return (fds); +} + +void +msghdr_fds_free(struct msghdr *msg) +{ + struct cmsghdr *cmsg; + int fd; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(msg, cmsg)) { + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_RIGHTS) { + bcopy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + close(fd); + } + } +} + +static void +fd_wait(int fd, bool doread) +{ + fd_set fds; + + PJDLOG_ASSERT(fd >= 0); + + FD_ZERO(&fds); + FD_SET(fd, &fds); + (void)select(fd + 1, doread ? &fds : NULL, doread ? NULL : &fds, + NULL, NULL); +} + +int +msg_peek(int sock, void *buf, size_t size) +{ + unsigned char *ptr; + ssize_t done; + + PJDLOG_ASSERT(sock >= 0); + PJDLOG_ASSERT(size > 0); + + ptr = buf; + do { + fd_wait(sock, true); + done = recv(sock, ptr, size, MSG_PEEK); + if (done == -1) { + if (errno == EINTR) + continue; + return (-1); + } else if (done == 0) { + errno = ENOTCONN; + return (-1); + } + size -= done; + ptr += done; + } while (size > 0); + + return (0); +} + +int +msg_recv(int sock, struct msghdr *msg) +{ + int flags; + + PJDLOG_ASSERT(sock >= 0); + +#ifdef MSG_CMSG_CLOEXEC + flags = MSG_CMSG_CLOEXEC; +#else + flags = 0; +#endif + + for (;;) { + fd_wait(sock, true); + if (recvmsg(sock, msg, flags) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +msg_send(int sock, const struct msghdr *msg) +{ + + PJDLOG_ASSERT(sock >= 0); + + for (;;) { + fd_wait(sock, false); + if (sendmsg(sock, msg, 0) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +cred_send(int sock) +{ + struct msghdr msg; + struct cmsghdr *cmsg; + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(struct cmsgcred)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_CREDS; + + if (msg_send(sock, &msg) == -1) + return (-1); + + return (0); +} + +int +cred_recv(int sock, struct cmsgcred *cred) +{ + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + struct msghdr msg; + struct cmsghdr *cmsg; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + if (msg_recv(sock, &msg) == -1) + return (-1); + + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct cmsgcred)) || + cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_CREDS) { + errno = EINVAL; + return (-1); + } + bcopy(CMSG_DATA(cmsg), cred, sizeof(*cred)); + + return (0); +} Added: soc2013/dpl/libnv/msgio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/msgio.h Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MSGIO_H_ +#define _MSGIO_H_ + +struct cmsgcred; +struct iovec; +struct msghdr; + +int msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov); + +int msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg); +int *msghdr_fds_to_array(struct msghdr *msg, size_t nfds); +void msghdr_fds_free(struct msghdr *msg); + +int msg_peek(int sock, void *buf, size_t size); +int msg_recv(int sock, struct msghdr *msg); +int msg_send(int sock, const struct msghdr *msg); + +int cred_send(int sock); +int cred_recv(int sock, struct cmsgcred *cred); + +#endif /* !_MSGIO_H_ */ Added: soc2013/dpl/libnv/nv.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/nv.h Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,477 @@ +/*- + * Copyright (c) 2009-2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _NV_H_ +#define _NV_H_ + +#include + +#include +#include +#include +#include + +#ifndef _NVPAIR_T_DECLARED +#define _NVPAIR_T_DECLARED +struct nvpair; + +typedef struct nvpair nvpair_t; +#endif + +#ifndef _NVLIST_T_DECLARED +#define _NVLIST_T_DECLARED +struct nvlist; + +typedef struct nvlist nvlist_t; +#endif + +#define NVPAIR_NAME_MAX 256 + +#define NV_TYPE_NONE 0 + +#define NV_TYPE_NULL 1 +#define NV_TYPE_BOOL 2 +#define NV_TYPE_NUMBER 3 +#define NV_TYPE_STRING 4 +#define NV_TYPE_NVLIST 5 +#define NV_TYPE_DESCRIPTOR 6 +#define NV_TYPE_BINARY 7 +#define NV_TYPE_ARRAY_BOOL 8 +#define NV_TYPE_ARRAY_NUMBER 9 +#define NV_TYPE_ARRAY_STRING 10 +#define NV_TYPE_ARRAY_NVLIST 11 +#define NV_TYPE_ARRAY_DESCRIPTOR 12 + +/* Duplicated names are not allowed. */ +#define NV_FLAG_UNIQUE_NAME 0x01 +/* Duplicated names of the same type are not allowed. */ +#define NV_FLAG_UNIQUE_NAME_TYPE 0x02 +/* + * NULL values for arrays and strings as well as -1 for descriptors + * are allowed. Note that individual entries in nvlist array, string + * array or descriptor array can still be NULL/-1. + */ +#define NV_FLAG_NO_VALUE 0x04 + +nvlist_t *nvlist_create(int flags); +void nvlist_destroy(nvlist_t *nvl); +int nvlist_error(const nvlist_t *nvl); + +bool nvlist_exists_type(const nvlist_t *nvl, const char *name, int type); +bool nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +bool nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +int nvlist_free_type(nvlist_t *nvl, const char *name, int type); +int nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +int nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +nvlist_t *nvlist_clone(const nvlist_t *nvl); + +void nvlist_dump(const nvlist_t *nvl, int fd); +void nvlist_fdump(const nvlist_t *nvl, FILE *out); + +size_t nvlist_size(const nvlist_t *nvl); +int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp); +size_t nvlist_ndescriptors(const nvlist_t *nvl); +void *nvlist_pack(const nvlist_t *nvl, size_t *sizep); +nvlist_t *nvlist_unpack(const void *buf, size_t size); + +int nvlist_send(int sock, const nvlist_t *nvl); +nvlist_t *nvlist_recv(int sock); +nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl); + +nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl); +nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); +nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); + +/* + * The nvlist_exists functions check if the given name (optionally of the given + * type) exists on nvlist. + */ + +bool nvlist_exists(const nvlist_t *nvl, const char *name); +bool nvlist_exists_null(const nvlist_t *nvl, const char *name); +bool nvlist_exists_bool(const nvlist_t *nvl, const char *name); +bool nvlist_exists_number(const nvlist_t *nvl, const char *name); +bool nvlist_exists_string(const nvlist_t *nvl, const char *name); +bool nvlist_exists_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_descriptor(const nvlist_t *nvl, const char *name); +bool nvlist_exists_binary(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_bool(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_number(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_string(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_descriptor(const nvlist_t *nvl, const char *name); + +bool nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_null(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_binary(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); + +bool nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_null(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_binary(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +/* + * The nvlist_add functions add the given name/value pair. + * If a pointer is provided, nvlist_add will internally allocate memory for the + * given data (in other words it won't consume provided buffer). + */ + +void nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp); +void nvlist_add_null(nvlist_t *nvl, const char *name); +void nvlist_add_bool(nvlist_t *nvl, const char *name, bool value); +void nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value); +void nvlist_add_string(nvlist_t *nvl, const char *name, const char *value); +void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...) __printflike(3, 4); +void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0); +void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value); +void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size); +void nvlist_add_array_bool(nvlist_t *nvl, const char *name, const bool *value, size_t nitems); +void nvlist_add_array_number(nvlist_t *nvl, const char *name, const uint64_t *value, size_t nitems); +void nvlist_add_array_string(nvlist_t *nvl, const char *name, const char * const *value, size_t nitems); +void nvlist_add_array_nvlist(nvlist_t *nvl, const char *name, const nvlist_t * const *value, size_t nitems); +void nvlist_add_array_descriptor(nvlist_t *nvl, const char *name, const int *value, size_t nitems); + +void nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +void nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +void nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +void nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_move functions add the given name/value pair. + * The functions consumes provided buffer. + */ + +void nvlist_move_string(nvlist_t *nvl, const char *name, char *value); +void nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value); +void nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size); +void nvlist_move_array_bool(nvlist_t *nvl, const char *name, bool *value, size_t nitems); +void nvlist_move_array_number(nvlist_t *nvl, const char *name, uint64_t *value, size_t nitems); +void nvlist_move_array_string(nvlist_t *nvl, const char *name, char **value, size_t nitems); +void nvlist_move_array_nvlist(nvlist_t *nvl, const char *name, nvlist_t **value, size_t nitems); +void nvlist_move_array_descriptor(nvlist_t *nvl, const char *name, int *value, size_t nitems); + +void nvlist_movef_string(nvlist_t *nvl, char *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +void nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_get functions returns value associated with the given name. + * If it returns a pointer, the pointer represents internal buffer and should + * not be freed by the caller. + */ + +nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name); +bool nvlist_get_bool(const nvlist_t *nvl, const char *name); +uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name); +const char *nvlist_get_string(const nvlist_t *nvl, const char *name); +const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name); +int nvlist_get_descriptor(const nvlist_t *nvl, const char *name); +const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep); +const bool *nvlist_get_array_bool(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const uint64_t *nvlist_get_array_number(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const char * const *nvlist_get_array_string(const nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t * const *nvlist_get_array_nvlist(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const int *nvlist_get_array_descriptor(const nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_getf_nvpair(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_getf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +uint64_t nvlist_getf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const char *nvlist_getf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const nvlist_t *nvlist_getf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_getf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const void *nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4); +const bool *nvlist_getf_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const uint64_t *nvlist_getf_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const char * const *nvlist_getf_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t * const *nvlist_getf_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const int *nvlist_getf_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_getv_nvpair(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_getv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +uint64_t nvlist_getv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const char *nvlist_getv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const nvlist_t *nvlist_getv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_getv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const void *nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0); +const bool *nvlist_getv_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const uint64_t *nvlist_getv_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const char * const *nvlist_getv_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t * const *nvlist_getv_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const int *nvlist_getv_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* + * The nvlist_take functions returns value associated with the given name and + * remove the given entry from the nvlist. + * The caller is responsible for freeing received data. + */ + +nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name); +bool nvlist_take_bool(nvlist_t *nvl, const char *name); +uint64_t nvlist_take_number(nvlist_t *nvl, const char *name); +char *nvlist_take_string(nvlist_t *nvl, const char *name); +nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name); +int nvlist_take_descriptor(nvlist_t *nvl, const char *name); +void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep); +bool *nvlist_take_array_bool(nvlist_t *nvl, const char *name, size_t *nitemsp); +uint64_t *nvlist_take_array_number(nvlist_t *nvl, const char *name, size_t *nitemsp); +char **nvlist_take_array_string(nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t **nvlist_take_array_nvlist(nvlist_t *nvl, const char *name, size_t *nitemsp); +int *nvlist_take_array_descriptor(nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_takef_nvpair(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_takef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +uint64_t nvlist_takef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +char *nvlist_takef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +nvlist_t *nvlist_takef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_takef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +void *nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4); +bool *nvlist_takef_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +uint64_t *nvlist_takef_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +char **nvlist_takef_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t **nvlist_takef_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +int *nvlist_takef_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_takev_nvpair(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_takev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +uint64_t nvlist_takev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +char *nvlist_takev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +nvlist_t *nvlist_takev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_takev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +void *nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0); +bool *nvlist_takev_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +uint64_t *nvlist_takev_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +char **nvlist_takev_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t **nvlist_takev_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +int *nvlist_takev_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* Function removes the given nvpair from the nvlist. */ +void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +/* + * The nvlist_free functions removes the given name/value pair from the nvlist + * and frees memory associated with it. + */ + +int nvlist_free(nvlist_t *nvl, const char *name); +int nvlist_free_null(nvlist_t *nvl, const char *name); +int nvlist_free_bool(nvlist_t *nvl, const char *name); +int nvlist_free_number(nvlist_t *nvl, const char *name); +int nvlist_free_string(nvlist_t *nvl, const char *name); +int nvlist_free_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_descriptor(nvlist_t *nvl, const char *name); +int nvlist_free_binary(nvlist_t *nvl, const char *name); +int nvlist_free_array_bool(nvlist_t *nvl, const char *name); +int nvlist_free_array_number(nvlist_t *nvl, const char *name); +int nvlist_free_array_string(nvlist_t *nvl, const char *name); +int nvlist_free_array_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_array_descriptor(nvlist_t *nvl, const char *name); + +int nvlist_freef(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_binary(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); + +int nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +void nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +int nvpair_type(const nvpair_t *nvp); +const char *nvpair_name(const nvpair_t *nvp); + +nvpair_t *nvpair_clone(const nvpair_t *nvp); + +nvpair_t *nvpair_create_null(const char *name); +nvpair_t *nvpair_create_bool(const char *name, bool value); +nvpair_t *nvpair_create_number(const char *name, uint64_t value); +nvpair_t *nvpair_create_string(const char *name, const char *value); +nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0); +nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value); +nvpair_t *nvpair_create_descriptor(const char *name, int value); +nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size); +nvpair_t *nvpair_create_array_bool(const char *name, const bool *value, size_t nitems); +nvpair_t *nvpair_create_array_number(const char *name, const uint64_t *value, size_t nitems); +nvpair_t *nvpair_create_array_string(const char *name, const char * const *value, size_t nitems); +nvpair_t *nvpair_create_array_nvlist(const char *name, const nvlist_t * const *value, size_t nitems); +nvpair_t *nvpair_create_array_descriptor(const char *name, const int *value, size_t nitems); + +nvpair_t *nvpair_createf_null(const char *namefmt, ...) __printflike(1, 2); +nvpair_t *nvpair_createf_bool(bool value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_number(uint64_t value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_string(const char *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_descriptor(int value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_bool(const bool *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_number(const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_string(const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_nvlist(const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_descriptor(const int *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvpair_createv_null(const char *namefmt, va_list nameap) __printflike(1, 0); +nvpair_t *nvpair_createv_bool(bool value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_string(const char *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_binary(const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_bool(const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_number(const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_string(const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_nvlist(const nvlist_t * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_descriptor(const int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); + +nvpair_t *nvpair_move_string(const char *name, char *value); +nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value); +nvpair_t *nvpair_move_descriptor(const char *name, int value); +nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size); +nvpair_t *nvpair_move_array_bool(const char *name, bool *value, size_t nitems); +nvpair_t *nvpair_move_array_number(const char *name, uint64_t *value, size_t nitems); +nvpair_t *nvpair_move_array_string(const char *name, char **value, size_t nitems); +nvpair_t *nvpair_move_array_nvlist(const char *name, nvlist_t **value, size_t nitems); +nvpair_t *nvpair_move_array_descriptor(const char *name, int *value, size_t nitems); + +nvpair_t *nvpair_movef_string(char *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_movef_nvlist(nvlist_t *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_movef_descriptor(int value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_movef_binary(void *value, size_t size, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_bool(bool *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_number(uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_string(char **value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_nvlist(nvlist_t **value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_descriptor(int *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvpair_movev_string(char *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_movev_binary(void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_bool(bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_number(uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_string(char **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_nvlist(nvlist_t **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_descriptor(int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); + +bool nvpair_get_bool(const nvpair_t *nvp); +uint64_t nvpair_get_number(const nvpair_t *nvp); +const char *nvpair_get_string(const nvpair_t *nvp); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 15:30:01 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8F21723C for ; Tue, 30 Jul 2013 15:30:01 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7ADD82B13 for ; Tue, 30 Jul 2013 15:30:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UFU1ed012639 for ; Tue, 30 Jul 2013 15:30:01 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6UFU12Z012557 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 15:30:01 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 30 Jul 2013 15:30:01 GMT Message-Id: <201307301530.r6UFU12Z012557@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255351 - in soc2013/dpl: . caller caller/libnv libnv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 15:30:01 -0000 Author: dpl Date: Tue Jul 30 15:30:01 2013 New Revision: 255351 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255351 Log: Putting everything nicely. Added: soc2013/dpl/caller/ soc2013/dpl/caller/caller.c soc2013/dpl/caller/libnv/ soc2013/dpl/caller/libnv/Makefile soc2013/dpl/caller/libnv/msgio.c soc2013/dpl/caller/libnv/msgio.h soc2013/dpl/caller/libnv/nv.h soc2013/dpl/caller/libnv/nv_impl.h soc2013/dpl/caller/libnv/nvlist.c soc2013/dpl/caller/libnv/nvlist_impl.h soc2013/dpl/caller/libnv/nvpair.c soc2013/dpl/caller/libnv/nvpair_impl.h soc2013/dpl/caller/nv.h Deleted: soc2013/dpl/caller.c soc2013/dpl/libnv/ Added: soc2013/dpl/caller/caller.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller/caller.c Tue Jul 30 15:30:01 2013 (r255351) @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +pid_t child = 0; +int sv[2], i; + +pid_t startChild(); +void waitCommand(); +void killChild(); + +/* Toy lib */ +int sum(int a); +int sum_(int a); + +int +main() +{ + int ret, a = 1; + ret = sum(a); + printf("ret: %d (should be 2)\n", ret); + + return 0; +} + +int sum(int a) +{ + struct pollfd fdread[1], fdwrite[1]; + int buf[32]; + /* Caller overhead */ + /* Much better if we do this in a function */ + fdwrite[0].fd = sv[0]; + fdwrite[0].events = POLLOUT; + fdwrite[0].revents = 0; + fdread[0].fd = sv[0]; + fdread[0].events = POLLIN|POLLPRI; + fdread[0].revents = 0; + if( child == 0) + startChild(); + + /* Real stuff */ + buf[0] = 1; + buf[1] = a; + + /* Should be in a function as well */ + /* sendAndWait() (?) */ + while(1){ + if(poll(fdwrite, 1, 0) > 0 ){ + write(sv[0], buf, sizeof(buf)); + break; + } + } + /* Here, the stuff gets done in child. */ + while(1){ + if(poll(fdread, 1, 0) > 0 ){ + read(sv[0], buf, sizeof(buf)); + break; + } + } + printf("done: %d\n", buf[0]); + + return buf[0]; +} + +int sum_(int a) +{ + return ++a; +} + +int startChild() +{ + socketpair(PF_LOCAL, SOCK_STREAM, 0, sv); + if( (child = fork()) == 0 ){ + cap_rights_limit(STDOUT_FILENO, CAP_WRITE); + close(STDIN_FILENO); + close(STDERR_FILENO); + cap_enter(); + waitCommand(); + } else + atexit(killChild); + + + return child; +} + +/* Wait for commands, and execute them */ +void +waitCommand() +{ + struct pollfd fdread[1], fdwrite[1]; + int buf[32]; + fdread[0].fd = sv[1]; + fdread[0].events = POLLIN|POLLPRI; + fdread[0].revents = 0; + fdwrite[0].fd = sv[1]; + fdwrite[0].events = POLLOUT; + fdwrite[0].revents = 0; + while(1) { + while(1){ + if( poll(fdread, 1, 0) > 0){ + read(sv[1], buf, sizeof(buf)); + break; + } + } + + if( buf[0] == 1 ){ + /* We still have to take recv nvlist */ + int ret = sum(buf[1]); + printf("ret:%d\n", ret); + fflush(stdout); + bzero(&buf, sizeof(buf)); + buf[0] = ret; + } + + while(1) { + if (poll(fdwrite, 1, 0) > 0){ + write(sv[1], buf, sizeof(buf)); + break; + } + } + } +} + +void +killChild() +{ + kill(child, SIGKILL); +} \ No newline at end of file Added: soc2013/dpl/caller/libnv/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller/libnv/Makefile Tue Jul 30 15:30:01 2013 (r255351) @@ -0,0 +1,15 @@ +# $FreeBSD$ + +LIB= nv +#SHLIBDIR?= /lib +SHLIBDIR?= . +SHLIB_MAJOR= 0 + +SRCS= msgio.c +SRCS+= nvlist.c +SRCS+= nvpair.c +INCS= nv.h + +CFLAGS+=-ggdb + +.include Added: soc2013/dpl/caller/libnv/msgio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller/libnv/msgio.c Tue Jul 30 15:30:01 2013 (r255351) @@ -0,0 +1,350 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_PJDLOG +#include +#endif + +#include "msgio.h" + +#ifndef HAVE_PJDLOG +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#define PJDLOG_RASSERT(expr, ...) assert(expr) +#define PJDLOG_ABORT(...) abort() +#endif + +int +msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov) +{ + int serrno; + + bzero(msg, sizeof(*msg)); + bzero(iov, sizeof(*iov)); + + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + if (datasize == 0) + return (0); + + if (nfds > 0) { + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + } + + iov->iov_len = datasize; + iov->iov_base = malloc(iov->iov_len); + if (iov->iov_base == NULL) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + + return (0); +} + +static bool +fd_is_valid(int fd) +{ + + return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); +} + +static int +msghdr_add_fd(struct msghdr *msg, struct cmsghdr **cmsgp, int fd) +{ + struct cmsghdr *cmsg; + + PJDLOG_ASSERT(fd >= 0); + + if (!fd_is_valid(fd)) { + errno = EBADF; + return (-1); + } + + cmsg = *cmsgp; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); + bcopy(&fd, CMSG_DATA(cmsg), sizeof(fd)); + *cmsgp = CMSG_NXTHDR(msg, cmsg); + + return (0); +} + +int +msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int serrno; + + if (nfds == 0) { + msg->msg_control = NULL; + msg->msg_controllen = 0; + return (0); + } + + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds; ii++) { + if (msghdr_add_fd(msg, &cmsg, fds[ii]) == -1) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + } + + return (0); +} + +static struct cmsghdr * +msghdr_get_fd(struct msghdr *msg, struct cmsghdr *cmsg, int *fdp) +{ + + if (cmsg == NULL || cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_RIGHTS) { + return (NULL); + } + + bcopy(CMSG_DATA(cmsg), fdp, sizeof(*fdp)); +#ifndef MSG_CMSG_CLOEXEC + /* + * If the MSG_CMSG_CLOEXEC flag is not available we cannot set the + * close-on-exec flag atomically, but we still want to set it for + * consistency. + */ + (void) fcntl(*fdp, F_SETFD, FD_CLOEXEC); +#endif + + return (CMSG_NXTHDR(msg, cmsg)); +} + +int * +msghdr_fds_to_array(struct msghdr *msg, size_t nfds) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int *fds; + + fds = malloc(sizeof(fds[0]) * nfds); + if (fds == NULL) + return (NULL); + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds && cmsg != NULL; ii++) + cmsg = msghdr_get_fd(msg, cmsg, &fds[ii]); + if (cmsg != NULL || ii < nfds) { + free(fds); + fds = NULL; + } + + return (fds); +} + +void +msghdr_fds_free(struct msghdr *msg) +{ + struct cmsghdr *cmsg; + int fd; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(msg, cmsg)) { + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_RIGHTS) { + bcopy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + close(fd); + } + } +} + +static void +fd_wait(int fd, bool doread) +{ + fd_set fds; + + PJDLOG_ASSERT(fd >= 0); + + FD_ZERO(&fds); + FD_SET(fd, &fds); + (void)select(fd + 1, doread ? &fds : NULL, doread ? NULL : &fds, + NULL, NULL); +} + +int +msg_peek(int sock, void *buf, size_t size) +{ + unsigned char *ptr; + ssize_t done; + + PJDLOG_ASSERT(sock >= 0); + PJDLOG_ASSERT(size > 0); + + ptr = buf; + do { + fd_wait(sock, true); + done = recv(sock, ptr, size, MSG_PEEK); + if (done == -1) { + if (errno == EINTR) + continue; + return (-1); + } else if (done == 0) { + errno = ENOTCONN; + return (-1); + } + size -= done; + ptr += done; + } while (size > 0); + + return (0); +} + +int +msg_recv(int sock, struct msghdr *msg) +{ + int flags; + + PJDLOG_ASSERT(sock >= 0); + +#ifdef MSG_CMSG_CLOEXEC + flags = MSG_CMSG_CLOEXEC; +#else + flags = 0; +#endif + + for (;;) { + fd_wait(sock, true); + if (recvmsg(sock, msg, flags) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +msg_send(int sock, const struct msghdr *msg) +{ + + PJDLOG_ASSERT(sock >= 0); + + for (;;) { + fd_wait(sock, false); + if (sendmsg(sock, msg, 0) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +cred_send(int sock) +{ + struct msghdr msg; + struct cmsghdr *cmsg; + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(struct cmsgcred)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_CREDS; + + if (msg_send(sock, &msg) == -1) + return (-1); + + return (0); +} + +int +cred_recv(int sock, struct cmsgcred *cred) +{ + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + struct msghdr msg; + struct cmsghdr *cmsg; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + if (msg_recv(sock, &msg) == -1) + return (-1); + + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct cmsgcred)) || + cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_CREDS) { + errno = EINVAL; + return (-1); + } + bcopy(CMSG_DATA(cmsg), cred, sizeof(*cred)); + + return (0); +} Added: soc2013/dpl/caller/libnv/msgio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller/libnv/msgio.h Tue Jul 30 15:30:01 2013 (r255351) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MSGIO_H_ +#define _MSGIO_H_ + +struct cmsgcred; +struct iovec; +struct msghdr; + +int msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov); + +int msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg); +int *msghdr_fds_to_array(struct msghdr *msg, size_t nfds); +void msghdr_fds_free(struct msghdr *msg); + +int msg_peek(int sock, void *buf, size_t size); +int msg_recv(int sock, struct msghdr *msg); +int msg_send(int sock, const struct msghdr *msg); + +int cred_send(int sock); +int cred_recv(int sock, struct cmsgcred *cred); + +#endif /* !_MSGIO_H_ */ Added: soc2013/dpl/caller/libnv/nv.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller/libnv/nv.h Tue Jul 30 15:30:01 2013 (r255351) @@ -0,0 +1,477 @@ +/*- + * Copyright (c) 2009-2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _NV_H_ +#define _NV_H_ + +#include + +#include +#include +#include +#include + +#ifndef _NVPAIR_T_DECLARED +#define _NVPAIR_T_DECLARED +struct nvpair; + +typedef struct nvpair nvpair_t; +#endif + +#ifndef _NVLIST_T_DECLARED +#define _NVLIST_T_DECLARED +struct nvlist; + +typedef struct nvlist nvlist_t; +#endif + +#define NVPAIR_NAME_MAX 256 + +#define NV_TYPE_NONE 0 + +#define NV_TYPE_NULL 1 +#define NV_TYPE_BOOL 2 +#define NV_TYPE_NUMBER 3 +#define NV_TYPE_STRING 4 +#define NV_TYPE_NVLIST 5 +#define NV_TYPE_DESCRIPTOR 6 +#define NV_TYPE_BINARY 7 +#define NV_TYPE_ARRAY_BOOL 8 +#define NV_TYPE_ARRAY_NUMBER 9 +#define NV_TYPE_ARRAY_STRING 10 +#define NV_TYPE_ARRAY_NVLIST 11 +#define NV_TYPE_ARRAY_DESCRIPTOR 12 + +/* Duplicated names are not allowed. */ +#define NV_FLAG_UNIQUE_NAME 0x01 +/* Duplicated names of the same type are not allowed. */ +#define NV_FLAG_UNIQUE_NAME_TYPE 0x02 +/* + * NULL values for arrays and strings as well as -1 for descriptors + * are allowed. Note that individual entries in nvlist array, string + * array or descriptor array can still be NULL/-1. + */ +#define NV_FLAG_NO_VALUE 0x04 + +nvlist_t *nvlist_create(int flags); +void nvlist_destroy(nvlist_t *nvl); +int nvlist_error(const nvlist_t *nvl); + +bool nvlist_exists_type(const nvlist_t *nvl, const char *name, int type); +bool nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +bool nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +int nvlist_free_type(nvlist_t *nvl, const char *name, int type); +int nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +int nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +nvlist_t *nvlist_clone(const nvlist_t *nvl); + +void nvlist_dump(const nvlist_t *nvl, int fd); +void nvlist_fdump(const nvlist_t *nvl, FILE *out); + +size_t nvlist_size(const nvlist_t *nvl); +int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp); +size_t nvlist_ndescriptors(const nvlist_t *nvl); +void *nvlist_pack(const nvlist_t *nvl, size_t *sizep); +nvlist_t *nvlist_unpack(const void *buf, size_t size); + +int nvlist_send(int sock, const nvlist_t *nvl); +nvlist_t *nvlist_recv(int sock); +nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl); + +nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl); +nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); +nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); + +/* + * The nvlist_exists functions check if the given name (optionally of the given + * type) exists on nvlist. + */ + +bool nvlist_exists(const nvlist_t *nvl, const char *name); +bool nvlist_exists_null(const nvlist_t *nvl, const char *name); +bool nvlist_exists_bool(const nvlist_t *nvl, const char *name); +bool nvlist_exists_number(const nvlist_t *nvl, const char *name); +bool nvlist_exists_string(const nvlist_t *nvl, const char *name); +bool nvlist_exists_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_descriptor(const nvlist_t *nvl, const char *name); +bool nvlist_exists_binary(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_bool(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_number(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_string(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_descriptor(const nvlist_t *nvl, const char *name); + +bool nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_null(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_binary(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); + +bool nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_null(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_binary(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +/* + * The nvlist_add functions add the given name/value pair. + * If a pointer is provided, nvlist_add will internally allocate memory for the + * given data (in other words it won't consume provided buffer). + */ + +void nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp); +void nvlist_add_null(nvlist_t *nvl, const char *name); +void nvlist_add_bool(nvlist_t *nvl, const char *name, bool value); +void nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value); +void nvlist_add_string(nvlist_t *nvl, const char *name, const char *value); +void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...) __printflike(3, 4); +void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0); +void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value); +void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size); +void nvlist_add_array_bool(nvlist_t *nvl, const char *name, const bool *value, size_t nitems); +void nvlist_add_array_number(nvlist_t *nvl, const char *name, const uint64_t *value, size_t nitems); +void nvlist_add_array_string(nvlist_t *nvl, const char *name, const char * const *value, size_t nitems); +void nvlist_add_array_nvlist(nvlist_t *nvl, const char *name, const nvlist_t * const *value, size_t nitems); +void nvlist_add_array_descriptor(nvlist_t *nvl, const char *name, const int *value, size_t nitems); + +void nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +void nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +void nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +void nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_move functions add the given name/value pair. + * The functions consumes provided buffer. + */ + +void nvlist_move_string(nvlist_t *nvl, const char *name, char *value); +void nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value); +void nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size); +void nvlist_move_array_bool(nvlist_t *nvl, const char *name, bool *value, size_t nitems); +void nvlist_move_array_number(nvlist_t *nvl, const char *name, uint64_t *value, size_t nitems); +void nvlist_move_array_string(nvlist_t *nvl, const char *name, char **value, size_t nitems); +void nvlist_move_array_nvlist(nvlist_t *nvl, const char *name, nvlist_t **value, size_t nitems); +void nvlist_move_array_descriptor(nvlist_t *nvl, const char *name, int *value, size_t nitems); + +void nvlist_movef_string(nvlist_t *nvl, char *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +void nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_get functions returns value associated with the given name. + * If it returns a pointer, the pointer represents internal buffer and should + * not be freed by the caller. + */ + +nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name); +bool nvlist_get_bool(const nvlist_t *nvl, const char *name); +uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name); +const char *nvlist_get_string(const nvlist_t *nvl, const char *name); +const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name); +int nvlist_get_descriptor(const nvlist_t *nvl, const char *name); +const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep); +const bool *nvlist_get_array_bool(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const uint64_t *nvlist_get_array_number(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const char * const *nvlist_get_array_string(const nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t * const *nvlist_get_array_nvlist(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const int *nvlist_get_array_descriptor(const nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_getf_nvpair(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_getf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +uint64_t nvlist_getf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const char *nvlist_getf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const nvlist_t *nvlist_getf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_getf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +const void *nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4); +const bool *nvlist_getf_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const uint64_t *nvlist_getf_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const char * const *nvlist_getf_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t * const *nvlist_getf_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const int *nvlist_getf_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_getv_nvpair(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_getv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +uint64_t nvlist_getv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const char *nvlist_getv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const nvlist_t *nvlist_getv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_getv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +const void *nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0); +const bool *nvlist_getv_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const uint64_t *nvlist_getv_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const char * const *nvlist_getv_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t * const *nvlist_getv_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const int *nvlist_getv_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* + * The nvlist_take functions returns value associated with the given name and + * remove the given entry from the nvlist. + * The caller is responsible for freeing received data. + */ + +nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name); +bool nvlist_take_bool(nvlist_t *nvl, const char *name); +uint64_t nvlist_take_number(nvlist_t *nvl, const char *name); +char *nvlist_take_string(nvlist_t *nvl, const char *name); +nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name); +int nvlist_take_descriptor(nvlist_t *nvl, const char *name); +void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep); +bool *nvlist_take_array_bool(nvlist_t *nvl, const char *name, size_t *nitemsp); +uint64_t *nvlist_take_array_number(nvlist_t *nvl, const char *name, size_t *nitemsp); +char **nvlist_take_array_string(nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t **nvlist_take_array_nvlist(nvlist_t *nvl, const char *name, size_t *nitemsp); +int *nvlist_take_array_descriptor(nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_takef_nvpair(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_takef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +uint64_t nvlist_takef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +char *nvlist_takef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +nvlist_t *nvlist_takef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_takef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +void *nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4); +bool *nvlist_takef_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +uint64_t *nvlist_takef_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +char **nvlist_takef_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t **nvlist_takef_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +int *nvlist_takef_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_takev_nvpair(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_takev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +uint64_t nvlist_takev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +char *nvlist_takev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +nvlist_t *nvlist_takev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_takev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +void *nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0); +bool *nvlist_takev_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +uint64_t *nvlist_takev_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +char **nvlist_takev_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t **nvlist_takev_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +int *nvlist_takev_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* Function removes the given nvpair from the nvlist. */ +void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +/* + * The nvlist_free functions removes the given name/value pair from the nvlist + * and frees memory associated with it. + */ + +int nvlist_free(nvlist_t *nvl, const char *name); +int nvlist_free_null(nvlist_t *nvl, const char *name); +int nvlist_free_bool(nvlist_t *nvl, const char *name); +int nvlist_free_number(nvlist_t *nvl, const char *name); +int nvlist_free_string(nvlist_t *nvl, const char *name); +int nvlist_free_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_descriptor(nvlist_t *nvl, const char *name); +int nvlist_free_binary(nvlist_t *nvl, const char *name); +int nvlist_free_array_bool(nvlist_t *nvl, const char *name); +int nvlist_free_array_number(nvlist_t *nvl, const char *name); +int nvlist_free_array_string(nvlist_t *nvl, const char *name); +int nvlist_free_array_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_array_descriptor(nvlist_t *nvl, const char *name); + +int nvlist_freef(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_binary(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); + +int nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +void nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +int nvpair_type(const nvpair_t *nvp); +const char *nvpair_name(const nvpair_t *nvp); + +nvpair_t *nvpair_clone(const nvpair_t *nvp); + +nvpair_t *nvpair_create_null(const char *name); +nvpair_t *nvpair_create_bool(const char *name, bool value); +nvpair_t *nvpair_create_number(const char *name, uint64_t value); +nvpair_t *nvpair_create_string(const char *name, const char *value); +nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0); +nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value); +nvpair_t *nvpair_create_descriptor(const char *name, int value); +nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size); +nvpair_t *nvpair_create_array_bool(const char *name, const bool *value, size_t nitems); +nvpair_t *nvpair_create_array_number(const char *name, const uint64_t *value, size_t nitems); +nvpair_t *nvpair_create_array_string(const char *name, const char * const *value, size_t nitems); +nvpair_t *nvpair_create_array_nvlist(const char *name, const nvlist_t * const *value, size_t nitems); +nvpair_t *nvpair_create_array_descriptor(const char *name, const int *value, size_t nitems); + +nvpair_t *nvpair_createf_null(const char *namefmt, ...) __printflike(1, 2); +nvpair_t *nvpair_createf_bool(bool value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_number(uint64_t value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_string(const char *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_descriptor(int value, const char *namefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_bool(const bool *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_number(const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_string(const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_nvlist(const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_descriptor(const int *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvpair_createv_null(const char *namefmt, va_list nameap) __printflike(1, 0); +nvpair_t *nvpair_createv_bool(bool value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_string(const char *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0); +nvpair_t *nvpair_createv_binary(const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_bool(const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_number(const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_string(const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 22:37:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5B9AD277 for ; Tue, 30 Jul 2013 22:37:07 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 46E962E76 for ; Tue, 30 Jul 2013 22:37:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UMb7ZL040947 for ; Tue, 30 Jul 2013 22:37:07 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6UMb7bA040941 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 22:37:07 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 22:37:07 GMT Message-Id: <201307302237.r6UMb7bA040941@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255367 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 22:37:07 -0000 Author: jmuniz Date: Tue Jul 30 22:37:07 2013 New Revision: 255367 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255367 Log: Changes to BUGS. The tray icon issue is resolved for gnome-packagekit. Added detail to other front end bugs. Modified: soc2013/jmuniz/BUGS Modified: soc2013/jmuniz/BUGS ============================================================================== --- soc2013/jmuniz/BUGS Tue Jul 30 21:35:02 2013 (r255366) +++ soc2013/jmuniz/BUGS Tue Jul 30 22:37:07 2013 (r255367) @@ -12,12 +12,9 @@ gnome-packagekit ---------------- -+ gpk-update-icon --- (13180) DBus warning, error sending message; did not receive a reply. Tray icon can never launch. -+ gpk-application --- icons for categories move to the right if application is opened more than once +- the groups treelist in gpk-application doesn't fill the width of it's parent container, offsetting the icon column (minor bug) KPackageKit ----------- -- crashes when clicking on category in list box -- description glitches when rising after being hidden +- crashes when clicking on category in AppRm +- description panel in AddRm glitches when performing the rising animation; the animation for the description panel in Updater works fine, and uses much of the same code so it is a helpful resource. They differ in the way they handle opacity, and the answer is probably there. From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 22:42:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 000B42F2 for ; Tue, 30 Jul 2013 22:42:05 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D2AB42E8F for ; Tue, 30 Jul 2013 22:42:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UMg5Zf017030 for ; Tue, 30 Jul 2013 22:42:05 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6UMg5Pw017028 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 22:42:05 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 22:42:05 GMT Message-Id: <201307302242.r6UMg5Pw017028@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255368 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 22:42:06 -0000 Author: jmuniz Date: Tue Jul 30 22:42:05 2013 New Revision: 255368 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255368 Log: Updated TODO to show recent developments. Also moved some items from optional status. Modified: soc2013/jmuniz/TODO Modified: soc2013/jmuniz/TODO ============================================================================== --- soc2013/jmuniz/TODO Tue Jul 30 22:37:07 2013 (r255367) +++ soc2013/jmuniz/TODO Tue Jul 30 22:42:05 2013 (r255368) @@ -33,8 +33,7 @@ - repository description - contact information - link to wiki for more information -+ optional --- bug tracking +- bug tracking BUGS ---- @@ -82,6 +81,7 @@ - test results (with seed data, test output, and performance results) - link to Google-Melange project page - add more links to external documentation (for related work) +- point out that svnweb is not synchronized as well as socsvn.freebsd.org Makefile -------- @@ -91,33 +91,20 @@ pk-setter --------- - validate port with portlint and poudriere -+ optional --- return currently selected back end --- create back end list from file saved during PK installation --- verify that packagekitd starts with each new configuration, or roll back to last known good configuration --- use GetDaemonState() to determine if packagekitd needs to be closed? --- make script more robust in the face of missing dependencies --- detect pkg, and if pkg2ng needs to be run --- configure pkg to use default repository --- create a manual page --- a way to reset PackageKit.conf to default using PackageKit.conf.sample +- return currently selected back end +- create back end list from file saved during PK installation +- verify that packagekitd starts with each new configuration, or roll back to last known good configuration +- use GetDaemonState() to determine if packagekitd needs to be closed? +- make script more robust in the face of missing dependencies +- detect pkg, and if pkg2ng needs to be run +- configure pkg to use default repository +- create a manual page +- a way to reset PackageKit.conf to default using PackageKit.conf.sample PackageKit-0.6.11 patches ------------------------- -+ ports back end --- fix plethora of bugs, listed in BUGS --- patch changes into new port revision --- find out if packagekit-cron could work --- get-files for non-installed software -+ pkgng back end --- evaluate necessity of additional functions (not used in ports back end) --- patch new back end into new port revision -+ pk-backend-pkgng.c --- comment, add header --- test -+ pkgngBackend.rb --+ optional ---- show unavailable file lists by downloading the plist from freebsd.org +- show unavailable file lists by downloading the plist from freebsd.org +- find out if packagekit-cron could work PackageKit-0.6.11 port ---------------------- @@ -125,23 +112,18 @@ - make sure the back ends play nice with PC-BSD, since it relies on overlays - create a file on installation to contain a list of installed back ends for pk-setter + Makefile -- find a better way to add site_ruby/1.8/pkgtools to ruby 1.9 include path --+ optional ---- create an option to install pk-setter AFTER PK; this should prevent circular dependency ---- replace manpage generation with a manpage patch ---- save a copy of PackageKit.conf to PackageKit.conf.sample for default configuration recovery -+ pkg-plist --- edit to reflect permanent pkgng back end files, in the future -+ files/ --- add temporary pkgng back end patches --- update patches to permanent pkgng back end, in the future +-- find a better way to add site_ruby/1.8/pkgtools to ruby 1.9 include path +-- create an option to install pk-setter AFTER PK; this should prevent circular dependency +-- replace manpage generation with a manpage patch +-- save a copy of PackageKit.conf to PackageKit.conf.sample for default configuration recovery ++ when Matt finishes the C back end +-- update patches to permanent pkgng back end +-- update pkg-plist to include the new files + optional -- update port to version 0.8.9 KPackageKit-0.6.3.3 port ------------------------ -+ files/ --- add patches + optional -- update port to Apper-0.8.0 @@ -154,12 +136,9 @@ --------------------------- - enable help button, patch in help files + user interface files --+ --+ optional ---- combine main window with update window using tabs ---- preference option available to keep selections when navigating tabs (default: true) ---- clicking on an item in a dependency list should open that items information -+ source code files +-- combine main window with update window using tabs +-- preference option available to keep selections when navigating tabs (default: true) +-- clicking on an item in a dependency list should open that items information gnome-packagekit-2.32.0 patches ------------------------------- From owner-svn-soc-all@FreeBSD.ORG Tue Jul 30 22:55:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E491A3E2 for ; Tue, 30 Jul 2013 22:55:04 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D187E2EE7 for ; Tue, 30 Jul 2013 22:55:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UMt49d038757 for ; Tue, 30 Jul 2013 22:55:04 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6UMt4Sm038752 for svn-soc-all@FreeBSD.org; Tue, 30 Jul 2013 22:55:04 GMT (envelope-from jmuniz@FreeBSD.org) Date: Tue, 30 Jul 2013 22:55:04 GMT Message-Id: <201307302255.r6UMt4Sm038752@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255369 - soc2013/jmuniz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 30 Jul 2013 22:55:05 -0000 Author: jmuniz Date: Tue Jul 30 22:55:04 2013 New Revision: 255369 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255369 Log: Changes to BUGS. Transactions are queued properly, get-files doesn't misbehave anymore. Modified: soc2013/jmuniz/BUGS Modified: soc2013/jmuniz/BUGS ============================================================================== --- soc2013/jmuniz/BUGS Tue Jul 30 22:42:05 2013 (r255368) +++ soc2013/jmuniz/BUGS Tue Jul 30 22:55:04 2013 (r255369) @@ -6,9 +6,6 @@ - download - remove - get-depends -+ bugs that may already be resolved (test once possible) --- may have trouble queuing multiple transactions --- may crash when no file list is available for a given package gnome-packagekit ---------------- From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 07:50:32 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 81CE06EF for ; Wed, 31 Jul 2013 07:50:32 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 60C002F81 for ; Wed, 31 Jul 2013 07:50:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V7oWqE017824 for ; Wed, 31 Jul 2013 07:50:32 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6V7oWlV017799 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 07:50:32 GMT (envelope-from bguan@FreeBSD.org) Date: Wed, 31 Jul 2013 07:50:32 GMT Message-Id: <201307310750.r6V7oWlV017799@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255381 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 07:50:32 -0000 Author: bguan Date: Wed Jul 31 07:50:32 2013 New Revision: 255381 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255381 Log: debug xen usb root hub Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Wed Jul 31 06:23:10 2013 (r255380) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Wed Jul 31 07:50:32 2013 (r255381) @@ -82,7 +82,6 @@ #include "xenbus_if.h" - static int usbfront_probe(device_t dev); static int usbfront_attach(device_t dev); static int usbfront_detach(device_t dev); @@ -107,7 +106,7 @@ usbfront_probe(device_t dev) { - printf("[gbdebug-pvusb]probe:xenbus_get_type: %s\n", xenbus_get_type(dev)); + printf("[gbdebug-pvusb]usbfront_probe:xenbus_get_type: %s\n", xenbus_get_type(dev)); if (!strcmp(xenbus_get_type(dev), "vusb")) { device_set_desc(dev, "Virtual PV USB Device"); //device_quiet(dev); @@ -128,7 +127,6 @@ { struct xenhci_softc *sc; int err; - //int rid; int i; int num_ports; @@ -152,7 +150,7 @@ xenbus_dev_fatal(dev, err, "reading usb-ver"); return (err); } - printf("[gbdebug-pvusb]usbfront_attach:usb_version=%d\n", usb_version); + DPRINTK("xen usb_version=%d\n", usb_version); switch (usb_version) { case USB_VER_USB11: @@ -184,7 +182,7 @@ xenbus_dev_fatal(dev, err, "reading num-ports"); goto error; } - printf("[gbdebug-pvusb]create_hcdev_1:num_ports=%d\n", num_ports); + DPRINTK("xen num_ports=%d\n", num_ports); if (num_ports < 1 || num_ports > USB_MAXCHILDREN) { xenbus_dev_fatal(dev, err, "invalid num-ports"); @@ -193,6 +191,8 @@ sc->xb_dev = dev; sc->rh_numports = num_ports; + sc->sc_noport = num_ports; + sprintf(sc->sc_vendor, "0x%04x", pci_get_vendor(dev)); for (i = 0; i < USB_URB_RING_SIZE; i++) { sc->shadow[i].req.id = i + 1; @@ -247,7 +247,7 @@ struct xenhci_softc *sc = device_get_softc(dev); mtx_destroy(&sc->lock); - DPRINTK("usbfront_remove: %s removed\n", xenbus_get_node(dev)); + DPRINTK("usbfront_detach: %s removed\n", xenbus_get_node(dev)); //TODO //usbfront_free(sc); @@ -261,7 +261,6 @@ usbfront_connect(device_t dev) { struct xenhci_softc *sc = device_get_softc(dev); - //struct usbfront_info *info = dev->dev.driver_data; usbif_conn_request_t *req; int i, idx, err; @@ -272,6 +271,7 @@ //hcd = info_to_hcd(info); //snprintf(name, TASK_COMM_LEN, "xenhcd.%d", sc->sc_bus.busnum); + err = talk_to_backend(dev, sc); if (err) return err; @@ -302,10 +302,28 @@ static void usbfront_disconnect(device_t dev) { + //struct xenhci_softc *sc = device_get_softc(dev); + + //struct usbfront_info *info = dev->dev.driver_data; + //struct usb_hcd *hcd = info_to_hcd(info); + + //usb_remove_hcd(hcd); + //if (info->kthread) { + // kthread_stop(info->kthread); + // info->kthread = NULL; + //} + //xenbus_frontend_closed(dev); + xenbus_set_state(dev, XenbusStateClosing); DPRINTK("xusb_closing: %s removed\n", xenbus_get_node(dev)); + //TODO!! + //if (sc->xbd_disk != NULL) { + // disk_destroy(sc->xbd_disk); + // sc->xbd_disk = NULL; + //} + xenbus_set_state(dev, XenbusStateClosed); } @@ -319,41 +337,39 @@ //struct xenhci_softc *sc = device_get_softc(dev); - //DPRINTK("backend_state=%d\n", backend_state); + DPRINTK("backend_state=%d\n", backend_state); switch (backend_state) { - case XenbusStateInitialised: - case XenbusStateInitialising: - case XenbusStateConnected: - case XenbusStateReconfigured: - case XenbusStateReconfiguring: - case XenbusStateUnknown: - case XenbusStateClosed: + case XenbusStateInitialised://3 + case XenbusStateInitialising://1 + case XenbusStateConnected://4 + case XenbusStateReconfigured://8 + case XenbusStateReconfiguring://7 + case XenbusStateUnknown://0 + case XenbusStateClosed://6 break; - case XenbusStateInitWait: - printf("[gbdebug-pvusb]usbfront_backend_changed: XenbusStateInitWait\n"); + case XenbusStateInitWait://2 if (xenbus_get_state(dev) != XenbusStateInitialising) break; - //if (usbfront_connect(sc) != 0) if (usbfront_connect(dev) != 0) { - printf("[gbdebug-pvusb]usbfront_connect(dev) error.\n"); + printf("[gbdebug-pvusb]usbfront_connect() error.\n"); break; } - xenbus_set_state(dev, XenbusStateConnected); //??? - printf("[gbdebug-pvusb]xenbus_set_state finished!\n"); + xenbus_set_state(dev, XenbusStateConnected); + printf("[gbdebug-pvusb]xenbus_set_state() exit!\n"); break; - case XenbusStateClosing: + case XenbusStateClosing://5 usbfront_disconnect(dev); + printf("[gbdebug-pvusb]usbfront_disconnect() exit!\n"); break; default: - xenbus_dev_fatal(dev, EINVAL, "get state %d at usb frontend", + xenbus_dev_fatal(dev, EINVAL, "get backend state %d at usb frontend", backend_state); break; } - printf("[gbdebug-pvusb]usbfront_backend_changed finished!\n"); } /* Common code used when first setting up, and when resuming. */ @@ -365,7 +381,7 @@ const char *node = xenbus_get_node(dev); int err; - printf("[gbdebug-pvusb]takl_to_backend()\n"); + printf("[gbdebug-pvusb]talk_to_backend()\n"); /* Create shared ring, alloc event channel. */ err = setup_rings(dev, sc); if (err) @@ -449,14 +465,11 @@ { usbif_urb_sring_t *urb_sring; usbif_conn_sring_t *conn_sring; - int otherend_id = 0; int err; - printf("[gbdebug-pvusb]setup_rings()\n"); sc->urb_ring_ref = GRANT_INVALID_REF; sc->conn_ring_ref = GRANT_INVALID_REF; - //urb_sring = (usbif_urb_sring_t *)get_zeroed_page(GFP_NOIO|__GFP_HIGH); urb_sring = (usbif_urb_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); if (!urb_sring) { xenbus_dev_fatal(dev, ENOMEM, "allocating urb ring"); @@ -466,14 +479,13 @@ FRONT_RING_INIT(&sc->urb_ring, urb_sring, PAGE_SIZE); err = xenbus_grant_ring(dev, virt_to_mfn(urb_sring), &sc->urb_ring_ref); - if (err < 0) { + if (err) { //free_page((unsigned long)urb_sring);//TODO //sc->urb_ring.sring = NULL; goto fail; } sc->urb_ring_ref = err; - //conn_sring = (usbif_conn_sring_t *)get_zeroed_page(GFP_NOIO|__GFP_HIGH); conn_sring = (usbif_conn_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); if (!conn_sring) { xenbus_dev_fatal(dev, ENOMEM, "allocating conn ring"); @@ -483,17 +495,17 @@ FRONT_RING_INIT(&sc->conn_ring, conn_sring, PAGE_SIZE); err = xenbus_grant_ring(dev, virt_to_mfn(conn_sring), &sc->conn_ring_ref); - if (err < 0) { + if (err) { //free_page((unsigned long)conn_sring);//TODO //sc->conn_ring.sring = NULL; goto fail; } sc->conn_ring_ref = err; - otherend_id = xenbus_get_otherend_id(dev); - err = bind_listening_port_to_irqhandler(otherend_id, "xu", xu_intr, - sc, INTR_TYPE_BIO | INTR_MPSAFE, &sc->irq); - if (err <= 0) { + err = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev), + "xu", xu_intr, sc, INTR_TYPE_BIO | INTR_MPSAFE, &sc->irq); + + if (err) { xenbus_dev_fatal(dev, err, "bind_listening_port_to_irqhandler"); goto fail; @@ -509,6 +521,7 @@ static void xenhci_notify_work(struct xenhci_softc *sc) { + printf("[gbdebug-pvusb]xenhci_notify_work()\n"); sc->waiting_resp = 1; wakeup(&sc->wait_taskqueue); } @@ -516,6 +529,7 @@ static void xu_intr(void *xsc) { + printf("[gbdebug-pvusb]xu_intr()\n"); struct xenhci_softc *sc = xsc; xenhci_notify_work(sc); } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 07:50:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 34811700 for ; Wed, 31 Jul 2013 07:50:45 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 076272F83 for ; Wed, 31 Jul 2013 07:50:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V7oimO030608 for ; Wed, 31 Jul 2013 07:50:44 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6V7oiua030592 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 07:50:44 GMT (envelope-from bguan@FreeBSD.org) Date: Wed, 31 Jul 2013 07:50:44 GMT Message-Id: <201307310750.r6V7oiua030592@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255382 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 07:50:45 -0000 Author: bguan Date: Wed Jul 31 07:50:44 2013 New Revision: 255382 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255382 Log: initialization for xen usb root hub Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Wed Jul 31 07:50:32 2013 (r255381) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Wed Jul 31 07:50:44 2013 (r255382) @@ -82,6 +82,31 @@ enum usb_dev_speed speed; }; +/* + * xenhci root HUB support +*/ +struct xenhci_config_desc { + struct usb_config_descriptor confd; + struct usb_interface_descriptor ifcd; + struct usb_endpoint_descriptor endpd; + //struct usb_endpoint_ss_comp_descriptor endpcd; +} __packed; + +/* +struct xhci_bos_desc { + struct usb_bos_descriptor bosd; + struct usb_devcap_usb2ext_descriptor usb2extd; + struct usb_devcap_ss_descriptor usbdcd; + struct usb_devcap_container_id_descriptor cidd; +} __packed;*/ + +union xenhci_hub_desc { + struct usb_status stat; + struct usb_port_status ps; + //struct usb_hub_ss_descriptor hubd; + uint8_t temp[128]; +}; + /* The "hardware" in Xen host controller is the shared ring to the backend driver and the data you can send and receive across it @@ -99,16 +124,30 @@ //}; struct xenhci_softc { - //struct xenhci_hw_softc sc_hw; + //struct xenhci_hw_softc sc_hw; //need it in xen? /* base device */ struct usb_bus sc_bus; /* configure message */ struct usb_bus_msg sc_config_msg[2]; - struct usb_callout sc_callout; + union xenhci_hub_desc sc_hub_desc; struct usb_device *sc_devices[XENHCI_MAX_DEVICES]; + /* number of XHCI device slots */ + uint8_t sc_noslot; + /* number of ports on root HUB */ + uint8_t sc_noport; //<32 in xen + /* number of scratch pages */ + uint8_t sc_noscratch; + /* root HUB device configuration */ + uint8_t sc_conf; + uint8_t sc_hub_idata[2]; + + /* vendor string for root HUB */ + char sc_vendor[16]; + + /* Virtual Host Controller has 4 urb queues */ LIST_ENTRY(list_head) pending_submit_list; //?? LIST_ENTRY(list_head) pending_unlink_list; //?? From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 07:51:55 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6888A750 for ; Wed, 31 Jul 2013 07:51:55 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 552342F90 for ; Wed, 31 Jul 2013 07:51:55 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V7ptSd058550 for ; Wed, 31 Jul 2013 07:51:55 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6V7ptix058544 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 07:51:55 GMT (envelope-from bguan@FreeBSD.org) Date: Wed, 31 Jul 2013 07:51:55 GMT Message-Id: <201307310751.r6V7ptix058544@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255383 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 07:51:55 -0000 Author: bguan Date: Wed Jul 31 07:51:55 2013 New Revision: 255383 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255383 Log: head file for xenhci.c Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhcireg.h Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhcireg.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhcireg.h Wed Jul 31 07:51:55 2013 (r255383) @@ -0,0 +1,223 @@ +/* $FreeBSD: head/sys/dev/xen/usbfront/xenhcireg.h 251252 2013-06-02 12:00:16Z hselasky $ */ + +/*- + * Copyright (c) 2013 Bei Guan. All rights reserved. + * Taken from the dev/usb/controller/xhcireg.h + * TODO Need to modify as required. + * + * 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. + */ + +#ifndef _XENHCIREG_H_ +#define _XENHCIREG_H_ + +/* XHCI PCI config registers */ +#define PCI_XHCI_CBMEM 0x10 /* configuration base MEM */ +#define PCI_XHCI_USBREV 0x60 /* RO USB protocol revision */ +#define PCI_USB_REV_3_0 0x30 /* USB 3.0 */ +#define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ + +#define PCI_XHCI_INTEL_XUSB2PR 0xD0 /* Intel USB2 Port Routing */ +#define PCI_XHCI_INTEL_USB3_PSSEN 0xD8 /* Intel USB3 Port SuperSpeed Enable */ + +/* XHCI capability registers */ +#define XHCI_CAPLENGTH 0x00 /* RO capability */ +#define XHCI_RESERVED 0x01 /* Reserved */ +#define XHCI_HCIVERSION 0x02 /* RO Interface version number */ +#define XHCI_HCIVERSION_0_9 0x0090 /* xHCI version 0.9 */ +#define XHCI_HCIVERSION_1_0 0x0100 /* xHCI version 1.0 */ +#define XHCI_HCSPARAMS1 0x04 /* RO structual parameters 1 */ +#define XHCI_HCS1_DEVSLOT_MAX(x)((x) & 0xFF) +#define XHCI_HCS1_IRQ_MAX(x) (((x) >> 8) & 0x3FF) +#define XHCI_HCS1_N_PORTS(x) (((x) >> 24) & 0xFF) +#define XHCI_HCSPARAMS2 0x08 /* RO structual parameters 2 */ +#define XHCI_HCS2_IST(x) ((x) & 0xF) +#define XHCI_HCS2_ERST_MAX(x) (((x) >> 4) & 0xF) +#define XHCI_HCS2_SPR(x) (((x) >> 24) & 0x1) +#define XHCI_HCS2_SPB_MAX(x) (((x) >> 27) & 0x7F) +#define XHCI_HCSPARAMS3 0x0C /* RO structual parameters 3 */ +#define XHCI_HCS3_U1_DEL(x) ((x) & 0xFF) +#define XHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0xFFFF) +#define XHCI_HCSPARAMS0 0x10 /* RO capability parameters */ +#define XHCI_HCS0_AC64(x) ((x) & 0x1) /* 64-bit capable */ +#define XHCI_HCS0_BNC(x) (((x) >> 1) & 0x1) /* BW negotiation */ +#define XHCI_HCS0_CSZ(x) (((x) >> 2) & 0x1) /* context size */ +#define XHCI_HCS0_PPC(x) (((x) >> 3) & 0x1) /* port power control */ +#define XHCI_HCS0_PIND(x) (((x) >> 4) & 0x1) /* port indicators */ +#define XHCI_HCS0_LHRC(x) (((x) >> 5) & 0x1) /* light HC reset */ +#define XHCI_HCS0_LTC(x) (((x) >> 6) & 0x1) /* latency tolerance msg */ +#define XHCI_HCS0_NSS(x) (((x) >> 7) & 0x1) /* no secondary sid */ +#define XHCI_HCS0_PSA_SZ_MAX(x) (((x) >> 12) & 0xF) /* max pri. stream array size */ +#define XHCI_HCS0_XECP(x) (((x) >> 16) & 0xFFFF) /* extended capabilities pointer */ +#define XHCI_DBOFF 0x14 /* RO doorbell offset */ +#define XHCI_RTSOFF 0x18 /* RO runtime register space offset */ + +/* XHCI operational registers. Offset given by XHCI_CAPLENGTH register */ +#define XHCI_USBCMD 0x00 /* XHCI command */ +#define XHCI_CMD_RS 0x00000001 /* RW Run/Stop */ +#define XHCI_CMD_HCRST 0x00000002 /* RW Host Controller Reset */ +#define XHCI_CMD_INTE 0x00000004 /* RW Interrupter Enable */ +#define XHCI_CMD_HSEE 0x00000008 /* RW Host System Error Enable */ +#define XHCI_CMD_LHCRST 0x00000080 /* RO/RW Light Host Controller Reset */ +#define XHCI_CMD_CSS 0x00000100 /* RW Controller Save State */ +#define XHCI_CMD_CRS 0x00000200 /* RW Controller Restore State */ +#define XHCI_CMD_EWE 0x00000400 /* RW Enable Wrap Event */ +#define XHCI_CMD_EU3S 0x00000800 /* RW Enable U3 MFINDEX Stop */ +#define XHCI_USBSTS 0x04 /* XHCI status */ +#define XHCI_STS_HCH 0x00000001 /* RO - Host Controller Halted */ +#define XHCI_STS_HSE 0x00000004 /* RW - Host System Error */ +#define XHCI_STS_EINT 0x00000008 /* RW - Event Interrupt */ +#define XHCI_STS_PCD 0x00000010 /* RW - Port Change Detect */ +#define XHCI_STS_SSS 0x00000100 /* RO - Save State Status */ +#define XHCI_STS_RSS 0x00000200 /* RO - Restore State Status */ +#define XHCI_STS_SRE 0x00000400 /* RW - Save/Restore Error */ +#define XHCI_STS_CNR 0x00000800 /* RO - Controller Not Ready */ +#define XHCI_STS_HCE 0x00001000 /* RO - Host Controller Error */ +#define XHCI_PAGESIZE 0x08 /* XHCI page size mask */ +#define XHCI_PAGESIZE_4K 0x00000001 /* 4K Page Size */ +#define XHCI_PAGESIZE_8K 0x00000002 /* 8K Page Size */ +#define XHCI_PAGESIZE_16K 0x00000004 /* 16K Page Size */ +#define XHCI_PAGESIZE_32K 0x00000008 /* 32K Page Size */ +#define XHCI_PAGESIZE_64K 0x00000010 /* 64K Page Size */ +#define XHCI_DNCTRL 0x14 /* XHCI device notification control */ +#define XHCI_DNCTRL_MASK(n) (1U << (n)) +#define XHCI_CRCR_LO 0x18 /* XHCI command ring control */ +#define XHCI_CRCR_LO_RCS 0x00000001 /* RW - consumer cycle state */ +#define XHCI_CRCR_LO_CS 0x00000002 /* RW - command stop */ +#define XHCI_CRCR_LO_CA 0x00000004 /* RW - command abort */ +#define XHCI_CRCR_LO_CRR 0x00000008 /* RW - command ring running */ +#define XHCI_CRCR_LO_MASK 0x0000000F +#define XHCI_CRCR_HI 0x1C /* XHCI command ring control */ +#define XHCI_DCBAAP_LO 0x30 /* XHCI dev context BA pointer */ +#define XHCI_DCBAAP_HI 0x34 /* XHCI dev context BA pointer */ +#define XHCI_CONFIG 0x38 +#define XHCI_CONFIG_SLOTS_MASK 0x000000FF /* RW - number of device slots enabled */ + +/* XHCI port status registers */ +#define XENHCI_PORTSC(n) (0x3F0 + (0x10 * (n))) /* XHCI port status */ +#define XENHCI_PS_CCS 0x00000001 /* RO - current connect status */ +#define XENHCI_PS_PED 0x00000002 /* RW - port enabled / disabled */ +#define XENHCI_PS_OCA 0x00000008 /* RO - over current active */ +#define XENHCI_PS_PR 0x00000010 /* RW - port reset */ +#define XENHCI_PS_PLS_GET(x) (((x) >> 5) & 0xF) /* RW - port link state */ +#define XHCI_PS_PLS_SET(x) (((x) & 0xF) << 5) /* RW - port link state */ +#define XENHCI_PS_PP 0x00000200 /* RW - port power */ +#define XENHCI_PS_SPEED_GET(x) (((x) >> 10) & 0xF) /* RO - port speed */ +#define XHCI_PS_PIC_GET(x) (((x) >> 14) & 0x3) /* RW - port indicator */ +#define XHCI_PS_PIC_SET(x) (((x) & 0x3) << 14) /* RW - port indicator */ +#define XHCI_PS_LWS 0x00010000 /* RW - port link state write strobe */ +#define XENHCI_PS_CSC 0x00020000 /* RW - connect status change */ +#define XENHCI_PS_PEC 0x00040000 /* RW - port enable/disable change */ +#define XENHCI_PS_WRC 0x00080000 /* RW - warm port reset change */ +#define XENHCI_PS_OCC 0x00100000 /* RW - over-current change */ +#define XENHCI_PS_PRC 0x00200000 /* RW - port reset change */ +#define XENHCI_PS_PLC 0x00400000 /* RW - port link state change */ +#define XENHCI_PS_CEC 0x00800000 /* RW - config error change */ +#define XHCI_PS_CAS 0x01000000 /* RO - cold attach status */ +#define XHCI_PS_WCE 0x02000000 /* RW - wake on connect enable */ +#define XHCI_PS_WDE 0x04000000 /* RW - wake on disconnect enable */ +#define XHCI_PS_WOE 0x08000000 /* RW - wake on over-current enable */ +#define XHCI_PS_DR 0x40000000 /* RO - device removable */ +#define XHCI_PS_WPR 0x80000000U /* RW - warm port reset */ +#define XENHCI_PS_CLEAR 0x80FF01FFU /* command bits */ + +#define XHCI_PORTPMSC(n) (0x3F4 + (0x10 * (n))) /* XHCI status and control */ +#define XHCI_PM3_U1TO_GET(x) (((x) >> 0) & 0xFF) /* RW - U1 timeout */ +#define XHCI_PM3_U1TO_SET(x) (((x) & 0xFF) << 0) /* RW - U1 timeout */ +#define XHCI_PM3_U2TO_GET(x) (((x) >> 8) & 0xFF) /* RW - U2 timeout */ +#define XHCI_PM3_U2TO_SET(x) (((x) & 0xFF) << 8) /* RW - U2 timeout */ +#define XHCI_PM3_FLA 0x00010000 /* RW - Force Link PM Accept */ +#define XHCI_PM2_L1S_GET(x) (((x) >> 0) & 0x7) /* RO - L1 status */ +#define XHCI_PM2_RWE 0x00000008 /* RW - remote wakup enable */ +#define XHCI_PM2_HIRD_GET(x) (((x) >> 4) & 0xF) /* RW - host initiated resume duration */ +#define XHCI_PM2_HIRD_SET(x) (((x) & 0xF) << 4) /* RW - host initiated resume duration */ +#define XHCI_PM2_L1SLOT_GET(x) (((x) >> 8) & 0xFF) /* RW - L1 device slot */ +#define XHCI_PM2_L1SLOT_SET(x) (((x) & 0xFF) << 8) /* RW - L1 device slot */ +#define XHCI_PM2_HLE 0x00010000 /* RW - hardware LPM enable */ +#define XHCI_PORTLI(n) (0x3F8 + (0x10 * (n))) /* XHCI port link info */ +#define XHCI_PLI3_ERR_GET(x) (((x) >> 0) & 0xFFFF) /* RO - port link errors */ +#define XHCI_PORTRSV(n) (0x3FC + (0x10 * (n))) /* XHCI port reserved */ + +/* XHCI runtime registers. Offset given by XHCI_CAPLENGTH + XHCI_RTSOFF registers */ +#define XHCI_MFINDEX 0x0000 /* RO - microframe index */ +#define XHCI_MFINDEX_GET(x) ((x) & 0x3FFF) +#define XHCI_IMAN(n) (0x0020 + (0x20 * (n))) /* XHCI interrupt management */ +#define XHCI_IMAN_INTR_PEND 0x00000001 /* RW - interrupt pending */ +#define XHCI_IMAN_INTR_ENA 0x00000002 /* RW - interrupt enable */ +#define XHCI_IMOD(n) (0x0024 + (0x20 * (n))) /* XHCI interrupt moderation */ +#define XHCI_IMOD_IVAL_GET(x) (((x) >> 0) & 0xFFFF) /* 250ns unit */ +#define XHCI_IMOD_IVAL_SET(x) (((x) & 0xFFFF) << 0) /* 250ns unit */ +#define XHCI_IMOD_ICNT_GET(x) (((x) >> 16) & 0xFFFF) /* 250ns unit */ +#define XHCI_IMOD_ICNT_SET(x) (((x) & 0xFFFF) << 16) /* 250ns unit */ +#define XHCI_IMOD_DEFAULT 0x000003E8U /* 8000 IRQ/second */ +#define XHCI_ERSTSZ(n) (0x0028 + (0x20 * (n))) /* XHCI event ring segment table size */ +#define XHCI_ERSTS_GET(x) ((x) & 0xFFFF) +#define XHCI_ERSTS_SET(x) ((x) & 0xFFFF) +#define XHCI_ERSTBA_LO(n) (0x0030 + (0x20 * (n))) /* XHCI event ring segment table BA */ +#define XHCI_ERSTBA_HI(n) (0x0034 + (0x20 * (n))) /* XHCI event ring segment table BA */ +#define XHCI_ERDP_LO(n) (0x0038 + (0x20 * (n))) /* XHCI event ring dequeue pointer */ +#define XHCI_ERDP_LO_SINDEX(x) ((x) & 0x7) /* RO - dequeue segment index */ +#define XHCI_ERDP_LO_BUSY 0x00000008 /* RW - event handler busy */ +#define XHCI_ERDP_HI(n) (0x003C + (0x20 * (n))) /* XHCI event ring dequeue pointer */ + +/* XHCI doorbell registers. Offset given by XHCI_CAPLENGTH + XHCI_DBOFF registers */ +#define XHCI_DOORBELL(n) (0x0000 + (4 * (n))) +#define XHCI_DB_TARGET_GET(x) ((x) & 0xFF) /* RW - doorbell target */ +#define XHCI_DB_TARGET_SET(x) ((x) & 0xFF) /* RW - doorbell target */ +#define XHCI_DB_SID_GET(x) (((x) >> 16) & 0xFFFF) /* RW - doorbell stream ID */ +#define XHCI_DB_SID_SET(x) (((x) & 0xFFFF) << 16) /* RW - doorbell stream ID */ + +/* XHCI legacy support */ +#define XHCI_XECP_ID(x) ((x) & 0xFF) +#define XHCI_XECP_NEXT(x) (((x) >> 8) & 0xFF) +#define XHCI_XECP_BIOS_SEM 0x0002 +#define XHCI_XECP_OS_SEM 0x0003 + +/* XHCI capability ID's */ +#define XHCI_ID_USB_LEGACY 0x0001 +#define XHCI_ID_PROTOCOLS 0x0002 +#define XHCI_ID_POWER_MGMT 0x0003 +#define XHCI_ID_VIRTUALIZATION 0x0004 +#define XHCI_ID_MSG_IRQ 0x0005 +#define XHCI_ID_USB_LOCAL_MEM 0x0006 + +/* XHCI register R/W wrappers */ +#define XREAD1(sc, what, a) \ + bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off) +#define XREAD2(sc, what, a) \ + bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off) +#define XREAD4(sc, what, a) \ + bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off) +#define XWRITE1(sc, what, a, x) \ + bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off, (x)) +#define XWRITE2(sc, what, a, x) \ + bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off, (x)) +#define XWRITE4(sc, what, a, x) \ + bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, \ + (a) + (sc)->sc_##what##_off, (x)) + +#endif /* _XENHCIREG_H_ */ From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 07:52:08 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6FB02764 for ; Wed, 31 Jul 2013 07:52:08 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4097E2F94 for ; Wed, 31 Jul 2013 07:52:08 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V7q8dg061450 for ; Wed, 31 Jul 2013 07:52:08 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6V7q8pQ061443 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 07:52:08 GMT (envelope-from bguan@FreeBSD.org) Date: Wed, 31 Jul 2013 07:52:08 GMT Message-Id: <201307310752.r6V7q8pQ061443@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255384 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 07:52:08 -0000 Author: bguan Date: Wed Jul 31 07:52:07 2013 New Revision: 255384 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255384 Log: debug method xenhci_roothub_exec() for xen usb host controller Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Wed Jul 31 07:51:55 2013 (r255383) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Wed Jul 31 07:52:07 2013 (r255384) @@ -67,6 +67,7 @@ #endif /* USB_GLOBAL_INCLUDE_FILE */ #include +#include #define XENHCI_BUS2SC(bus) \ ((struct xenhci_softc *)(((uint8_t *)(bus)) - \ @@ -89,6 +90,8 @@ TUNABLE_INT("hw.usb.xenhci.use_polling", &xenhcipolling); #endif +#define XENHCI_INTR_ENDPT 1 + extern struct usb_bus_methods xenhci_bus_methods; @@ -96,19 +99,7 @@ static void xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) { - struct xhci_softc *sc = XENHCI_BUS2SC(bus); - uint8_t i; - - cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg, - sizeof(struct xhci_hw_root), XENHCI_PAGE_SIZE); - - cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg, - sizeof(struct xhci_dev_ctx_addr), XENHCI_PAGE_SIZE); - - for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) { - cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i], - XENHCI_PAGE_SIZE, XENHCI_PAGE_SIZE); - } + //TODO need this method()? }*/ usb_error_t @@ -157,22 +148,444 @@ //TODO return (0); } + /*------------------------------------------------------------------------* * xenhci root HUB support *------------------------------------------------------------------------* * Simulate a HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------* + * xenhci root HUB support + *------------------------------------------------------------------------* + * Simulate a hardware HUB by handling all the necessary requests. + *------------------------------------------------------------------------*/ + +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + +static const +struct usb_device_descriptor xenhci_devd = +{ + .bLength = sizeof(xenhci_devd), + .bDescriptorType = UDESC_DEVICE, /* type */ + HSETW(.bcdUSB, 0x0200), /* USB version */ + .bDeviceClass = UDCLASS_HUB, /* class */ + .bDeviceSubClass = UDSUBCLASS_HUB, /* subclass */ + .bDeviceProtocol = UDPROTO_HSHUBSTT, /* protocol */ + .bMaxPacketSize = 64, /* max packet size */ + HSETW(.idVendor, 0x0000), /* vendor */ + HSETW(.idProduct, 0x0000), /* product */ + HSETW(.bcdDevice, 0x0100), /* device version */ + .iManufacturer = 1, + .iProduct = 2, + .iSerialNumber = 0, + .bNumConfigurations = 1, /* # of configurations */ +}; + +static const +struct xenhci_config_desc xenhci_confd = { + .confd = { + .bLength = sizeof(xenhci_confd.confd), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(xenhci_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0 /* max power */ + }, + .ifcd = { + .bLength = sizeof(xenhci_confd.ifcd), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = 0, + }, + .endpd = { + .bLength = sizeof(xenhci_confd.endpd), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = UE_DIR_IN | XENHCI_INTR_ENDPT, + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 5, /* max 63 ports */ + .bInterval = 255, + }, + /*.endpcd = { + .bLength = sizeof(xenhci_confd.endpcd), + .bDescriptorType = UDESC_ENDPOINT_SS_COMP, + .bMaxBurst = 0, + .bmAttributes = 0, + },*/ +}; + +static const +struct usb_hub_descriptor xenhci_hubd = +{ + .bDescLength = 0, /* dynamic length */ + .bDescriptorType = UDESC_HUB, +}; static usb_error_t xenhci_roothub_exec(struct usb_device *udev, struct usb_device_request *req, const void **pptr, uint16_t *plength) { printf("[gbtest-pv]xenhci.c: xenhci_roothub_exec()\n"); - //usb_error_t err; - //return (err); - //TODO - return (0); + struct xenhci_softc *sc = XENHCI_BUS2SC(udev->bus); + const char *str_ptr; + const void *ptr; + uint32_t port; + //uint32_t v; + uint16_t len; + uint16_t i=0; + uint16_t value; + uint16_t index; + //uint8_t j; + usb_error_t err; + + USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); + + /* buffer reset */ + ptr = (const void *)&sc->sc_hub_desc; + len = 0; + err = 0; + + value = UGETW(req->wValue); + index = UGETW(req->wIndex); + + DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x " + "wValue=0x%04x wIndex=0x%04x\n", + req->bmRequestType, req->bRequest, + UGETW(req->wLength), value, index); + +#define C(x,y) ((x) | ((y) << 8)) + switch (C(req->bRequest, req->bmRequestType)) { + case C(UR_CLEAR_FEATURE, UT_WRITE_DEVICE): + case C(UR_CLEAR_FEATURE, UT_WRITE_INTERFACE): + case C(UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT): + /* + * DEVICE_REMOTE_WAKEUP and ENDPOINT_HALT are no-ops + * for the integrated root hub. + */ + break; + case C(UR_GET_CONFIG, UT_READ_DEVICE): + len = 1; + sc->sc_hub_desc.temp[0] = sc->sc_conf; + break; + case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE): + switch (value >> 8) { + case UDESC_DEVICE: + if ((value & 0xff) != 0) { + err = USB_ERR_IOERROR; + goto done; + } + len = sizeof(xenhci_devd); + ptr = (const void *)&xenhci_devd; + break; + + //TODO require these? + /*case UDESC_BOS: + if ((value & 0xff) != 0) { + err = USB_ERR_IOERROR; + goto done; + } + len = sizeof(xhci_bosd); + ptr = (const void *)&xhci_bosd; + break; + */ + + /* + * We can't really operate at another speed, + * but the specification says we need this + * descriptor: + */ + /*case UDESC_DEVICE_QUALIFIER: + if ((value & 0xff) != 0) { + err = USB_ERR_IOERROR; + goto done; + } + len = sizeof(ehci_odevd); + ptr = (const void *)&ehci_odevd; + break; + */ + + case UDESC_CONFIG: + if ((value & 0xff) != 0) { + err = USB_ERR_IOERROR; + goto done; + } + len = sizeof(xenhci_confd); + ptr = (const void *)&xenhci_confd; + break; + + case UDESC_STRING: + switch (value & 0xff) { + case 0: /* Language table */ + str_ptr = "\001"; + break; + + case 1: /* Vendor */ + str_ptr = sc->sc_vendor; + break; + + case 2: /* Product */ + str_ptr = "XENHCI root HUB"; + break; + + default: + str_ptr = ""; + break; + } + + len = usb_make_str_desc( + sc->sc_hub_desc.temp, + sizeof(sc->sc_hub_desc.temp), + str_ptr); + break; + + default: + err = USB_ERR_IOERROR; + goto done; + } + break; + case C(UR_GET_INTERFACE, UT_READ_INTERFACE): + len = 1; + sc->sc_hub_desc.temp[0] = 0; + break; + case C(UR_GET_STATUS, UT_READ_DEVICE): + len = 2; + USETW(sc->sc_hub_desc.stat.wStatus, UDS_SELF_POWERED); + break; + case C(UR_GET_STATUS, UT_READ_INTERFACE): + case C(UR_GET_STATUS, UT_READ_ENDPOINT): + len = 2; + USETW(sc->sc_hub_desc.stat.wStatus, 0); + break; + case C(UR_SET_ADDRESS, UT_WRITE_DEVICE): + if (value >= XENHCI_MAX_DEVICES) { + err = USB_ERR_IOERROR; + goto done; + } + break; + case C(UR_SET_CONFIG, UT_WRITE_DEVICE): + if (value != 0 && value != 1) { + err = USB_ERR_IOERROR; + goto done; + } + sc->sc_conf = value; + break; + case C(UR_SET_DESCRIPTOR, UT_WRITE_DEVICE): + break; + case C(UR_SET_FEATURE, UT_WRITE_DEVICE): + case C(UR_SET_FEATURE, UT_WRITE_INTERFACE): + case C(UR_SET_FEATURE, UT_WRITE_ENDPOINT): + err = USB_ERR_IOERROR; + goto done; + case C(UR_SET_INTERFACE, UT_WRITE_INTERFACE): + break; + case C(UR_SYNCH_FRAME, UT_WRITE_ENDPOINT): + break; + /* Hub requests */ + case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_DEVICE): + break; + case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_OTHER): + DPRINTFN(9, "UR_CLEAR_PORT_FEATURE\n"); + + if ((index < 1) || + (index > sc->sc_noport)) { + err = USB_ERR_IOERROR; + goto done; + } + port = XENHCI_PORTSC(index); + + //v = XREAD4(sc, oper, port); + //i = XENHCI_PS_PLS_GET(v); + //v &= ~XENHCI_PS_CLEAR; + + //TODO how to set all the "case" according to "value" + switch (value) { + case UHF_C_PORT_SUSPEND: + printf("UHF_PORT_SUSPEND\n");//TODO + break; + case UHF_C_PORT_CONNECTION: + printf("UHF_PORT_CONNECTION\n");//TODO + break; + case UHF_C_PORT_ENABLE: + printf("UHF_PORT_ENABLE\n");//TODO + break; + case UHF_C_PORT_OVER_CURRENT: + printf("UHF_PORT_OVER_CURRENT\n");//TODO + break; + case UHF_C_PORT_RESET: + printf("UHF_PORT_RESET\n");//TODO + break; + case UHF_PORT_ENABLE: + printf("UHF_PORT_ENABLE\n");//TODO + break; + case UHF_PORT_POWER: + printf("UHF_PORT_POWER\n");//TODO + break; + case UHF_PORT_INDICATOR: + printf("UHF_PORT_INDICATOR\n");//TODO + break; + case UHF_PORT_SUSPEND: + printf("UHF_PORT_SUSPEND\n");//TODO + break; + case UHF_PORT_TEST: + printf("UHF_PORT_TEST\n");//TODO + break; + default: + err = USB_ERR_IOERROR; + goto done; + } + break; + + case C(UR_GET_DESCRIPTOR, UT_READ_CLASS_DEVICE): + printf("[gbtest-pv]case C(UR_GET_DESCRIPTOR, UT_READ_CLASS_DEVICE)\n"); + if ((value & 0xff) != 0) { + err = USB_ERR_IOERROR; + goto done; + } + //TODO? + //len = sizeof(uhci_hubd_piix); + //ptr = (const void *)&uhci_hubd_piix; + break; + + case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE): + len = 16; + memset(sc->sc_hub_desc.temp, 0, 16); + break; + + case C(UR_GET_STATUS, UT_READ_CLASS_OTHER): //TODO? + DPRINTFN(9, "UR_GET_STATUS i=%d\n", index); + + if ((index < 1) || + (index > sc->sc_noport)) { + err = USB_ERR_IOERROR; + goto done; + } + + printf("[gbtest-pv]case C(UR_GET_STATUS, UT_READ_CLASS_OTHER)\n"); + //v = XREAD4(sc, oper, XENHCI_PORTSC(index)); + //DPRINTFN(9, "port status=0x%08x\n", v); + + /*i = UPS_PORT_LINK_STATE_SET(XENHCI_PS_PLS_GET(v)); + + switch (XENHCI_PS_SPEED_GET(v)) { + case 3: + i |= UPS_HIGH_SPEED; + break; + case 2: + i |= UPS_LOW_SPEED; + break; + case 1: + */ /* FULL speed */ + /* break; + default: + i |= UPS_OTHER_SPEED; + break; + } + + if (v & XENHCI_PS_CCS) + i |= UPS_CURRENT_CONNECT_STATUS; + if (v & XENHCI_PS_PED) + i |= UPS_PORT_ENABLED; + if (v & XENHCI_PS_OCA) + i |= UPS_OVERCURRENT_INDICATOR; + if (v & XENHCI_PS_PR) + i |= UPS_RESET; + if (v & XENHCI_PS_PP) { + */ /* + * The USB 3.0 RH is using the + * USB 2.0's power bit + */ + /* i |= UPS_PORT_POWER; + } + */ + USETW(sc->sc_hub_desc.ps.wPortStatus, i); + + i = 0; + /*if (v & XENHCI_PS_CSC) + i |= UPS_C_CONNECT_STATUS; + if (v & XENHCI_PS_PEC) + i |= UPS_C_PORT_ENABLED; + if (v & XENHCI_PS_OCC) + i |= UPS_C_OVERCURRENT_INDICATOR; + if (v & XENHCI_PS_WRC) + i |= UPS_C_BH_PORT_RESET; + if (v & XENHCI_PS_PRC) + i |= UPS_C_PORT_RESET; + if (v & XENHCI_PS_PLC) + i |= UPS_C_PORT_LINK_STATE; + if (v & XENHCI_PS_CEC) + i |= UPS_C_PORT_CONFIG_ERROR; + */ + USETW(sc->sc_hub_desc.ps.wPortChange, i); + len = sizeof(sc->sc_hub_desc.ps); + break; + + case C(UR_SET_DESCRIPTOR, UT_WRITE_CLASS_DEVICE): + err = USB_ERR_IOERROR; + goto done; + + case C(UR_SET_FEATURE, UT_WRITE_CLASS_DEVICE): + break; + + case C(UR_SET_FEATURE, UT_WRITE_CLASS_OTHER): + + i = index >> 8; + index &= 0x00FF; + + if ((index < 1) || + (index > sc->sc_noport)) { + err = USB_ERR_IOERROR; + goto done; + } + + //port = XENHCI_PORTSC(index); + //v = XREAD4(sc, oper, port) & ~XENHCI_PS_CLEAR; + + //TODO how to set all the "case" according to "value" + switch (value) { + case UHF_PORT_LINK_STATE: + printf("UHF_PORT_LINK_STATE\n");//TODO + break; + case UHF_PORT_ENABLE: + printf("UHF_PORT_ENABLE\n");//TODO + break; + case UHF_PORT_SUSPEND: + printf("UHF_PORT_SUSPEND\n");//TODO + break; + case UHF_PORT_RESET: + printf("UHF_PORT_RESET\n");//TODO + break; + case UHF_PORT_POWER: + printf("UHF_PORT_POWER\n");//TODO + break; + case UHF_PORT_TEST: + printf("UHF_PORT_TEST\n");//TODO + break; + case UHF_PORT_INDICATOR: + printf("UHF_PORT_INDICATOR\n");//TODO + break; + default: + err = USB_ERR_IOERROR; + goto done; + } + break; + + case C(UR_CLEAR_TT_BUFFER, UT_WRITE_CLASS_OTHER): + case C(UR_RESET_TT, UT_WRITE_CLASS_OTHER): + case C(UR_GET_TT_STATE, UT_READ_CLASS_OTHER): + case C(UR_STOP_TT, UT_WRITE_CLASS_OTHER): + break; + default: + err = USB_ERR_IOERROR; + goto done; + } +done: + *plength = len; + *pptr = ptr; + return (err); } static void @@ -209,14 +622,15 @@ DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n", ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode); - printf("[gb-test]endpoint=%p, addr=%d, endpt=%d, mode=%d\n", + printf("[gbtest-pv]endpoint=%p, addr=%d, endpt=%d, mode=%d\n", ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode); if (udev->parent_hub == NULL) { /* root HUB has special endpoint handling */ - printf("[gb-test]xenhci.c: xenhci_ep_init():udev->parent_hub == NULL\n"); + printf("[gbtest-pv]xenhci.c: xenhci_ep_init():udev->parent_hub == NULL\n"); return; } + printf("[gbtest-pv]xenhci.c: xenhci_ep_init():TODO?...\n"); //ep->methods = &xhci_device_generic_methods; //pepext = xhci_get_endpoint_ext(udev, edesc); @@ -303,7 +717,7 @@ /* check for root HUB */ if (udev->parent_hub == NULL) { - printf("[gb-test]xenhci.c: xenhci_device_state_change(): udev->parent_hub == NULL\n"); + printf("[gbtest-pv]xenhci.c: xenhci_device_state_change(): udev->parent_hub == NULL\n"); return; } @@ -312,26 +726,27 @@ //DPRINTF("\n"); if (usb_get_device_state(udev) == USB_STATE_CONFIGURED) { - printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n"); + printf("[gbtest-pv]state(udev) == USB_STATE_CONFIGURED\n"); } //XHCI_CMD_LOCK(sc); + //TODO how to? switch (usb_get_device_state(udev)) { case USB_STATE_POWERED: - printf("[gb-test]state(udev) == USB_STATE_POWERED\n"); + printf("[gbtest-pv]state(udev) == USB_STATE_POWERED\n"); break; case USB_STATE_ADDRESSED: - printf("[gb-test]state(udev) == USB_STATE_ADDRESSED\n"); + printf("[gbtest-pv]state(udev) == USB_STATE_ADDRESSED\n"); break; case USB_STATE_CONFIGURED: - printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n"); + printf("[gbtest-pv]state(udev) == USB_STATE_CONFIGURED\n"); break; default: - printf("[gb-test]state(udev) == other!!\n"); + printf("[gbtest-pv]state(udev) == other!!\n"); break; } //XHCI_CMD_UNLOCK(sc); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 15:28:40 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9249D595 for ; Wed, 31 Jul 2013 15:28:40 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7E5352810 for ; Wed, 31 Jul 2013 15:28:40 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VFSedg063546 for ; Wed, 31 Jul 2013 15:28:40 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VFSewT063544 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 15:28:40 GMT (envelope-from bguan@FreeBSD.org) Date: Wed, 31 Jul 2013 15:28:40 GMT Message-Id: <201307311528.r6VFSewT063544@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255392 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 15:28:40 -0000 Author: bguan Date: Wed Jul 31 15:28:39 2013 New Revision: 255392 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255392 Log: debug method xenhci_roothub_exec() for xen usb host controller Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Wed Jul 31 12:35:06 2013 (r255391) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Wed Jul 31 15:28:39 2013 (r255392) @@ -257,6 +257,10 @@ req->bmRequestType, req->bRequest, UGETW(req->wLength), value, index); + printf("[gbtest-pv]type=0x%02x request=0x%02x wLen=0x%04x " + "wValue=0x%04x wIndex=0x%04x\n", + req->bmRequestType, req->bRequest, + UGETW(req->wLength), value, index); #define C(x,y) ((x) | ((y) << 8)) switch (C(req->bRequest, req->bmRequestType)) { case C(UR_CLEAR_FEATURE, UT_WRITE_DEVICE): From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 17:50:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BE002214 for ; Wed, 31 Jul 2013 17:50:48 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 90B582FC2 for ; Wed, 31 Jul 2013 17:50:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VHomR3014912 for ; Wed, 31 Jul 2013 17:50:48 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VHomeX014877 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 17:50:48 GMT (envelope-from def@FreeBSD.org) Date: Wed, 31 Jul 2013 17:50:48 GMT Message-Id: <201307311750.r6VHomeX014877@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255398 - soc2013/def/crashdump-head/sbin/savecore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 17:50:48 -0000 Author: def Date: Wed Jul 31 17:50:48 2013 New Revision: 255398 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255398 Log: Decrypt a crash dump with a custom offset. Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c soc2013/def/crashdump-head/sbin/savecore/decryptfile.h soc2013/def/crashdump-head/sbin/savecore/savecore.c Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Wed Jul 31 16:27:56 2013 (r255397) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Wed Jul 31 17:50:48 2013 (r255398) @@ -57,7 +57,7 @@ } FILE * -dopen(const char *fname, const char *mode, const struct kerneldumpheader *h) +dopen(const char *fname, const char *mode, const struct kerneldumpheader *h, off_t offset) { uint8_t key[KERNELDUMP_KEY_SIZE]; struct xts_ctx ctx; @@ -92,7 +92,7 @@ bzero(&ctx, sizeof(ctx)); bzero(key, KERNELDUMP_KEY_SIZE); - fd->offset = 0; + fd->offset = offset; fd->buf_used = 0; return (funopen(fd, NULL, dwrite, NULL, dclose)); Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.h ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Wed Jul 31 16:27:56 2013 (r255397) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.h Wed Jul 31 17:50:48 2013 (r255398) @@ -18,7 +18,7 @@ } decFile; int dwrite(void *cookie, const char *data, int size); -FILE *dopen(const char *fname, const char *mode, const struct kerneldumpheader *h); +FILE *dopen(const char *fname, const char *mode, const struct kerneldumpheader *h, off_t offset); int dclose(void *cookie); #endif /* _FILEDECRYPT_H */ Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Wed Jul 31 16:27:56 2013 (r255397) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Wed Jul 31 17:50:48 2013 (r255398) @@ -634,7 +634,7 @@ } else if (decrypt) { snprintf(corename, sizeof(corename), "%s.%d", istextdump ? "textdump.tar" : "vmcore", bounds); - fp = dopen(corename, "w", &kdhl); + fp = dopen(corename, "w", &kdhl, firsthd + sizeof(kdhf)); } else { snprintf(corename, sizeof(corename), "%s.%d", istextdump ? "textdump.tar" : "vmcore", bounds); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 17:55:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 90D342A1 for ; Wed, 31 Jul 2013 17:55:47 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7D7522FEF for ; Wed, 31 Jul 2013 17:55:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VHtlxt081248 for ; Wed, 31 Jul 2013 17:55:47 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VHtlsr081245 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 17:55:47 GMT (envelope-from def@FreeBSD.org) Date: Wed, 31 Jul 2013 17:55:47 GMT Message-Id: <201307311755.r6VHtlsr081245@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255399 - soc2013/def/crashdump-head/sys/crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 17:55:47 -0000 Author: def Date: Wed Jul 31 17:55:47 2013 New Revision: 255399 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255399 Log: Change xts_start, xts_lastblock, xts_fullblock to be non-static. Move inline functions of XTS to a header file. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Wed Jul 31 17:50:48 2013 (r255398) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Wed Jul 31 17:55:47 2013 (r255399) @@ -32,12 +32,6 @@ #include #include -#ifdef _KERNEL -#include -#else -#include -#endif - void xts_aes_keysetup(struct xts_ctx *ctx, const uint8_t *key, uint32_t keybits) { @@ -63,42 +57,7 @@ .pa_id = XTS_ALG_AES, }; -static __inline void -xor128(void *dst, const void *src1, const void *src2) -{ - const uint64_t *s1 = (const uint64_t *)src1; - const uint64_t *s2 = (const uint64_t *)src2; - uint64_t *d = (uint64_t *)dst; - - d[0] = s1[0] ^ s2[0]; - d[1] = s1[1] ^ s2[1]; -} - -static __inline int -shl128(uint64_t *d, const uint64_t *s) -{ - int c0, c1; - - c0 = s[0] & (1ULL << 63) ? 1 : 0; - c1 = s[1] & (1ULL << 63) ? 1 : 0; - d[0] = s[0] << 1; - d[1] = s[1] << 1 | c0; - - return (c1); -} - -static __inline void -gf_mul128(uint64_t *dst, const uint64_t *src) -{ - static const uint8_t gf_128_fdbk = 0x87; - int carry; - - carry = shl128(dst, src); - if (carry != 0) - ((uint8_t *)dst)[0] ^= gf_128_fdbk; -} - -static __inline void +void xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, uint64_t *tweak, const uint8_t *src, uint8_t *dst) { @@ -108,7 +67,7 @@ gf_mul128(tweak, tweak); } -static __inline void +void xts_lastblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len) { @@ -124,7 +83,7 @@ xor128(dst, dst, tweak); } -static __inline void +void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) { Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Wed Jul 31 17:50:48 2013 (r255398) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Wed Jul 31 17:55:47 2013 (r255399) @@ -32,6 +32,13 @@ #include #include #include +#include + +#ifdef _KERNEL +#include +#else +#include +#endif #define XTS_BLK_BYTES 16 #define XTS_BLK_MASK (XTS_BLK_BYTES - 1) @@ -58,6 +65,50 @@ int pa_id; }; +static __inline void +xor128(void *dst, const void *src1, const void *src2) +{ + const uint64_t *s1 = (const uint64_t *)src1; + const uint64_t *s2 = (const uint64_t *)src2; + uint64_t *d = (uint64_t *)dst; + + d[0] = s1[0] ^ s2[0]; + d[1] = s1[1] ^ s2[1]; +} + +static __inline int +shl128(uint64_t *d, const uint64_t *s) +{ + int c0, c1; + + c0 = s[0] & (1ULL << 63) ? 1 : 0; + c1 = s[1] & (1ULL << 63) ? 1 : 0; + d[0] = s[0] << 1; + d[1] = s[1] << 1 | c0; + + return (c1); +} + +static __inline void +gf_mul128(uint64_t *dst, const uint64_t *src) +{ + static const uint8_t gf_128_fdbk = 0x87; + int carry; + + carry = shl128(dst, src); + if (carry != 0) + ((uint8_t *)dst)[0] ^= gf_128_fdbk; +} + +void xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst); + +void xts_lastblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len); + +void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, + uint64_t *tweak, uint64_t sector, const uint8_t *xtweak); + void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, uint64_t sector, const uint8_t *xtweak, int len, From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 19:11:31 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id ECEDC173 for ; Wed, 31 Jul 2013 19:11:30 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CB4A52356 for ; Wed, 31 Jul 2013 19:11:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VJBU9Y034625 for ; Wed, 31 Jul 2013 19:11:30 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VJBUPV034620 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 19:11:30 GMT (envelope-from def@FreeBSD.org) Date: Wed, 31 Jul 2013 19:11:30 GMT Message-Id: <201307311911.r6VJBUPV034620@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255402 - in soc2013/def/crashdump-head/sys: amd64/conf kern sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 19:11:31 -0000 Author: def Date: Wed Jul 31 19:11:30 2013 New Revision: 255402 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255402 Log: Encrypt 512-byte chunks in 4096-byte data units. Enable the encryption when ENCRYPT_CRASH option is added. Modified: soc2013/def/crashdump-head/sys/amd64/conf/GENERIC soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sys/amd64/conf/GENERIC ============================================================================== --- soc2013/def/crashdump-head/sys/amd64/conf/GENERIC Wed Jul 31 18:18:02 2013 (r255401) +++ soc2013/def/crashdump-head/sys/amd64/conf/GENERIC Wed Jul 31 19:11:30 2013 (r255402) @@ -341,4 +341,4 @@ device virtio_balloon # VirtIO Memory Balloon device # Unattended encrypted kernel crash dumps -option ENCRYPT_CRASH +options ENCRYPT_CRASH Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Wed Jul 31 18:18:02 2013 (r255401) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Wed Jul 31 19:11:30 2013 (r255402) @@ -42,6 +42,7 @@ #include "opt_panic.h" #include "opt_sched.h" #include "opt_watchdog.h" +#include "opt_crash.h" #include #include @@ -145,8 +146,10 @@ int dumping; /* system is dumping */ int rebooting; /* system is rebooting */ static struct dumperinfo dumper; /* our selected dumper */ +#ifdef ENCRYPT_CRASH static struct kerneldumpkey dumperkey; static struct kerneldumpbuffer dumperbuffer; +#endif /* Context information for dump-debuggers. */ static struct pcb dumppcb; /* Registers. */ @@ -851,10 +854,12 @@ if (dumper.dumper != NULL) return (EBUSY); dumper = *di; + +#ifdef ENCRYPT_CRASH dumper.kdk = &dumperkey; dumper.kdb = &dumperbuffer; - kerneldump_crypto_init(&dumper); +#endif wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname)); if (wantcopy >= sizeof(dumpdevname)) { @@ -869,10 +874,13 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, off_t offset, size_t length) { +#ifdef ENCRYPT_CRASH struct kerneldumpkey *kdk; struct kerneldumpbuffer *kdb; - size_t resid; - int error; + int error, len; + off_t sector_index, devblk_index; + char *ptr; +#endif if (length != 0 && (offset < di->mediaoffset || offset - di->mediaoffset + length > di->mediasize)) { @@ -883,54 +891,52 @@ return (ENOSPC); } +#ifdef ENCRYPT_CRASH kdk = di->kdk; kdb = di->kdb; /* Write kernel dump headers. */ - if (kdb->realoffset == 0 || offset == di->mediaoffset + di->mediasize - + if (kdb->kdhoffset == 0 || offset == di->mediaoffset + di->mediasize - sizeof(struct kerneldumpheader)) { - kdb->realoffset = offset + length; + kdb->kdhoffset = offset + length; return (di->dumper(di->priv, virtual, physical, offset, length)); } - /* The last dump_write call in the current crash. */ - if (virtual == NULL && physical == 0 && offset == 0 && length == 0) { - xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, - kdb->offset, kdk->tweak, kdb->used, - kdb->buf, kdb->buf); - return (di->dumper(di->priv, di->kdb->buf, physical, kdb->realoffset, kdb->used)); - } - - while (length + kdb->used >= KERNELDUMP_BUFFER_SIZE) { - resid = KERNELDUMP_BUFFER_SIZE - kdb->used; - memcpy(kdb->buf + kdb->used, virtual, resid); - kdb->used += resid; - - xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, - kdb->offset, kdk->tweak, KERNELDUMP_BUFFER_SIZE, - kdb->buf, kdb->buf); + sector_index = (offset - kdb->kdhoffset)/KERNELDUMP_SECTOR_SIZE; + devblk_index = (offset - kdb->kdhoffset - sector_index*KERNELDUMP_SECTOR_SIZE)/KERNELDUMP_DEVBLK_SIZE; + + while (length > 0) { + memcpy(kdb->buf, virtual, KERNELDUMP_DEVBLK_SIZE); - error = (di->dumper(di->priv, kdb->buf, physical, kdb->realoffset, KERNELDUMP_BUFFER_SIZE)); + if (devblk_index == 0) + xts_start(&xts_alg_aes, &kdk->tweak_ctx, kdb->tweak, offset, kdk->tweak); + + ptr = kdb->buf; + len = KERNELDUMP_DEVBLK_SIZE; + while (len > 0) { + xts_fullblock(xts_alg_aes.pa_encrypt, &kdk->data_ctx, kdb->tweak, ptr, ptr); + ptr += XTS_BLK_BYTES; + len -= XTS_BLK_BYTES; + } + + error = (di->dumper(di->priv, kdb->buf, physical, offset, KERNELDUMP_DEVBLK_SIZE)); if (error) return (error); - virtual = (void *)((char *)virtual + resid); - length -= resid; - kdb->used = 0; - kdb->realoffset += resid; - kdb->offset += KERNELDUMP_BUFFER_SIZE; - } - - /* We still have less than blocksize of data to dump. */ - if (length > 0) { - memcpy(kdb->buf + kdb->used, virtual, length); - kdb->used += length; + virtual = (void *)((char *)virtual + KERNELDUMP_DEVBLK_SIZE); + length -= KERNELDUMP_DEVBLK_SIZE; + offset += KERNELDUMP_DEVBLK_SIZE; + devblk_index = (devblk_index+1)%(KERNELDUMP_SECTOR_SIZE/KERNELDUMP_DEVBLK_SIZE); } return (0); +#else /* ENCRYPT_CRASH */ + return (di->dumper(di->priv, virtual, physical, offset, length)); +#endif /* ENCRYPT_CRASH */ } +#ifdef ENCRYPT_CRASH static void kerneldump_hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, int idx, const uint8_t *magic, size_t magicsize) @@ -998,12 +1004,11 @@ return (NULL); } - kdb->used = 0; - kdb->realoffset = 0; - kdb->offset = 0; + kdb->kdhoffset = 0; return (kdb); } +#endif /* ENCRYPT_CRASH */ void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, @@ -1022,8 +1027,10 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); +#ifdef ENCRYPT_CRASH kdh->keysize = dumper.kdk->keysize; strncpy(kdh->key, dumper.kdk->key, kdh->keysize); strncpy(kdh->tweak, dumper.kdk->tweak, KERNELDUMP_TWEAK_SIZE); +#endif kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Wed Jul 31 18:18:02 2013 (r255401) +++ soc2013/def/crashdump-head/sys/sys/conf.h Wed Jul 31 19:11:30 2013 (r255402) @@ -323,8 +323,10 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* Stuff relating to kernel-dump */ +#ifdef ENCRYPT_CRASH struct kerneldumpkey; struct kerneldumpbuffer; +#endif struct dumperinfo { dumper_t *dumper; /* Dumping function. */ @@ -333,8 +335,10 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ +#ifdef ENCRYPT_CRASH struct kerneldumpkey *kdk; /* Kernel dump key. */ struct kerneldumpbuffer *kdb; /* Kernel dump buffer. */ +#endif }; int set_dumper(struct dumperinfo *, const char *_devname); Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Wed Jul 31 18:18:02 2013 (r255401) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Wed Jul 31 19:11:30 2013 (r255402) @@ -109,6 +109,7 @@ } #ifdef _KERNEL +#ifdef ENCRYPT_CRASH /* * Constant key for kernel crash dumps. */ @@ -129,16 +130,17 @@ }; struct kerneldumpbuffer { -#define KERNELDUMP_BUFFER_SIZE 4096 - uint8_t buf[KERNELDUMP_BUFFER_SIZE]; /* Raw data buffer. */ - u_int used; /* Number of bytes used in the buffer. */ - off_t offset; /* Last used offset in a xts_block_encrypt call. */ - off_t realoffset; /* Last used offset in a dump_write call. */ +#define KERNELDUMP_DEVBLK_SIZE 512 +#define KERNELDUMP_SECTOR_SIZE 4096 + uint8_t buf[KERNELDUMP_DEVBLK_SIZE]; /* Raw data buffer. */ + uint64_t tweak[XTS_BLK_BYTES / 8]; /* Tweak value used in XTS. */ + off_t kdhoffset; /* Offset value of the first kdh. */ }; void kerneldump_crypto_init(struct dumperinfo *di); struct kerneldumpkey *kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *key, char *tweak); struct kerneldumpbuffer *kerneldump_set_buffer(struct kerneldumpbuffer *kdb); +#endif /* ENCRYPT_CRASH */ void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 20:07:05 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 35A85EBD for ; Wed, 31 Jul 2013 20:07:05 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1E61F2585 for ; Wed, 31 Jul 2013 20:07:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VK746j072707 for ; Wed, 31 Jul 2013 20:07:04 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VK74x6072693 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 20:07:04 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 31 Jul 2013 20:07:04 GMT Message-Id: <201307312007.r6VK74x6072693@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255404 - in soc2013/dpl: . caller head/lib/libz head/lib/libz/capsicumized head/lib/libz/capsicumized/contrib head/lib/libz/capsicumized/contrib/asm686 head/lib/libz/capsicumized/co... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 20:07:05 -0000 Author: dpl Date: Wed Jul 31 20:07:04 2013 New Revision: 255404 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255404 Log: caller.c works using libnv (much easier now). I also copied a directory in libz called "capsicumized" where the new protected library will live (I'll have to make lots of changes, and having it separated in another dir seems like a good idea) Added: soc2013/dpl/caller.c soc2013/dpl/head/lib/libz/capsicumized/ soc2013/dpl/head/lib/libz/capsicumized/ChangeLog soc2013/dpl/head/lib/libz/capsicumized/FAQ soc2013/dpl/head/lib/libz/capsicumized/FREEBSD-upgrade soc2013/dpl/head/lib/libz/capsicumized/Makefile soc2013/dpl/head/lib/libz/capsicumized/README soc2013/dpl/head/lib/libz/capsicumized/Symbol.map soc2013/dpl/head/lib/libz/capsicumized/Versions.def soc2013/dpl/head/lib/libz/capsicumized/adler32.c soc2013/dpl/head/lib/libz/capsicumized/capsicum.c soc2013/dpl/head/lib/libz/capsicumized/capsicum.h soc2013/dpl/head/lib/libz/capsicumized/compress.c soc2013/dpl/head/lib/libz/capsicumized/contrib/ soc2013/dpl/head/lib/libz/capsicumized/contrib/README.contrib soc2013/dpl/head/lib/libz/capsicumized/contrib/asm686/ soc2013/dpl/head/lib/libz/capsicumized/contrib/asm686/README.686 soc2013/dpl/head/lib/libz/capsicumized/contrib/asm686/match.S soc2013/dpl/head/lib/libz/capsicumized/contrib/gcc_gvmat64/ soc2013/dpl/head/lib/libz/capsicumized/contrib/gcc_gvmat64/gvmat64.S soc2013/dpl/head/lib/libz/capsicumized/crc32.c soc2013/dpl/head/lib/libz/capsicumized/crc32.h soc2013/dpl/head/lib/libz/capsicumized/deflate.c soc2013/dpl/head/lib/libz/capsicumized/deflate.h soc2013/dpl/head/lib/libz/capsicumized/doc/ soc2013/dpl/head/lib/libz/capsicumized/doc/algorithm.txt soc2013/dpl/head/lib/libz/capsicumized/doc/rfc1950.txt soc2013/dpl/head/lib/libz/capsicumized/doc/rfc1951.txt soc2013/dpl/head/lib/libz/capsicumized/doc/rfc1952.txt soc2013/dpl/head/lib/libz/capsicumized/doc/txtvsbin.txt soc2013/dpl/head/lib/libz/capsicumized/gzclose.c soc2013/dpl/head/lib/libz/capsicumized/gzguts.h soc2013/dpl/head/lib/libz/capsicumized/gzlib.c soc2013/dpl/head/lib/libz/capsicumized/gzread.c soc2013/dpl/head/lib/libz/capsicumized/gzwrite.c soc2013/dpl/head/lib/libz/capsicumized/infback.c soc2013/dpl/head/lib/libz/capsicumized/inffast.c soc2013/dpl/head/lib/libz/capsicumized/inffast.h soc2013/dpl/head/lib/libz/capsicumized/inffixed.h soc2013/dpl/head/lib/libz/capsicumized/inflate.c soc2013/dpl/head/lib/libz/capsicumized/inflate.h soc2013/dpl/head/lib/libz/capsicumized/inftrees.c soc2013/dpl/head/lib/libz/capsicumized/inftrees.h soc2013/dpl/head/lib/libz/capsicumized/test/ soc2013/dpl/head/lib/libz/capsicumized/test/example.c soc2013/dpl/head/lib/libz/capsicumized/test/infcover.c soc2013/dpl/head/lib/libz/capsicumized/test/minigzip.c soc2013/dpl/head/lib/libz/capsicumized/trees.c soc2013/dpl/head/lib/libz/capsicumized/trees.h soc2013/dpl/head/lib/libz/capsicumized/uncompr.c soc2013/dpl/head/lib/libz/capsicumized/zconf.h soc2013/dpl/head/lib/libz/capsicumized/zlib.3 soc2013/dpl/head/lib/libz/capsicumized/zlib.h soc2013/dpl/head/lib/libz/capsicumized/zopen.c soc2013/dpl/head/lib/libz/capsicumized/zutil.c soc2013/dpl/head/lib/libz/capsicumized/zutil.h soc2013/dpl/libnv/ soc2013/dpl/libnv/Makefile soc2013/dpl/libnv/msgio.c soc2013/dpl/libnv/msgio.h soc2013/dpl/libnv/nv.h soc2013/dpl/libnv/nv_impl.h soc2013/dpl/libnv/nvlist.c soc2013/dpl/libnv/nvlist_impl.h soc2013/dpl/libnv/nvpair.c soc2013/dpl/libnv/nvpair_impl.h Deleted: soc2013/dpl/caller/ soc2013/dpl/head/lib/libz/capsicum.c soc2013/dpl/head/lib/libz/capsicum.h Modified: soc2013/dpl/head/lib/libz/zconf.h Added: soc2013/dpl/caller.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller.c Wed Jul 31 20:07:04 2013 (r255404) @@ -0,0 +1,141 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +#define SUM 1 + + +pid_t child = 0; +int sv[2], i; + + +pid_t startChild(); +void waitCommand(); +void killChild(); + +/* Toy lib */ +int sum(int a); +int sum_(int a); + +int +main() +{ + int ret, a = 1; + ret = sum(a); + printf("ret: %d (should be 2)\n", ret); + + return 0; +} + +int sum(int a) +{ + nvlist_t *nvl; + nvlist_t *args; + + if( child == 0) + startChild(); + + if( (nvl = nvlist_create(0)) == NULL ) + perror("sum:nvlist_create:nvl"); + if( (args = nvlist_create(0)) == NULL ) + perror("sum:nvlist_create:args"); + + /* Real stuff */ + nvlist_add_number(args, "a", a); + nvlist_add_nvlist(nvl, "args", args); + + nvlist_add_number(nvl, "com", SUM); + + /* send nvlist*/ + while(1){ + if( nvlist_send(sv[0], nvl) == 0 ) + break; + ; + } + + /* recv results */ + while(1){ + if ((nvl = nvlist_recv(sv[0])) != NULL) + if (nvlist_exists(nvl, "result")) + break; + ; + } + + return nvlist_take_number(nvl, "result"); +} + +int sum_(int a) +{ + return ++a; +} + +int startChild() +{ + if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) + perror("socketpair"); + + if( (child = fork()) == 0 ){ + cap_rights_limit(STDOUT_FILENO, CAP_WRITE); + close(STDIN_FILENO); + close(STDERR_FILENO); + cap_enter(); + waitCommand(); + } else + atexit(killChild); + + return child; +} + +/* Wait for commands, and execute them */ +void +waitCommand() +{ + nvlist_t *nvl, *args; + + while(1) { + while(1){ + if ((nvl = nvlist_recv(sv[1])) != NULL) + if (nvlist_exists(nvl, "com")) + if (nvlist_exists(nvl, "args")) + break; + ; + } + + /* Switch for "command" */ + /* Get args, and call the real lib */ + switch( nvlist_take_number(nvl, "com")){ + case SUM: + if ((args = nvlist_take_nvlist(nvl, "args")) == NULL) { + perror("CHILD: nvlist_take_nvlist(nvl, 'args')"); + break; + } + nvlist_add_number(nvl, "result", sum_(nvlist_take_number(args, "a"))); + break; + default: + break; + } + + + while(1){ + if( nvlist_send(sv[1], nvl) == 0 ) + break; + ; + } + ; + } +} + +void +killChild() +{ + kill(child, SIGKILL); +} \ No newline at end of file Added: soc2013/dpl/head/lib/libz/capsicumized/ChangeLog ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libz/capsicumized/ChangeLog Wed Jul 31 20:07:04 2013 (r255404) @@ -0,0 +1,1472 @@ + + ChangeLog file for zlib + +Changes in 1.2.8 (28 Apr 2013) +- Update contrib/minizip/iowin32.c for Windows RT [Vollant] +- Do not force Z_CONST for C++ +- Clean up contrib/vstudio [Ro§] +- Correct spelling error in zlib.h +- Fix mixed line endings in contrib/vstudio + +Changes in 1.2.7.3 (13 Apr 2013) +- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc + +Changes in 1.2.7.2 (13 Apr 2013) +- Change check for a four-byte type back to hexadecimal +- Fix typo in win32/Makefile.msc +- Add casts in gzwrite.c for pointer differences + +Changes in 1.2.7.1 (24 Mar 2013) +- Replace use of unsafe string functions with snprintf if available +- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink] +- Fix gzgetc undefine when Z_PREFIX set [Turk] +- Eliminate use of mktemp in Makefile (not always available) +- Fix bug in 'F' mode for gzopen() +- Add inflateGetDictionary() function +- Correct comment in deflate.h +- Use _snprintf for snprintf in Microsoft C +- On Darwin, only use /usr/bin/libtool if libtool is not Apple +- Delete "--version" file if created by "ar --version" [Richard G.] +- Fix configure check for veracity of compiler error return codes +- Fix CMake compilation of static lib for MSVC2010 x64 +- Remove unused variable in infback9.c +- Fix argument checks in gzlog_compress() and gzlog_write() +- Clean up the usage of z_const and respect const usage within zlib +- Clean up examples/gzlog.[ch] comparisons of different types +- Avoid shift equal to bits in type (caused endless loop) +- Fix unintialized value bug in gzputc() introduced by const patches +- Fix memory allocation error in examples/zran.c [Nor] +- Fix bug where gzopen(), gzclose() would write an empty file +- Fix bug in gzclose() when gzwrite() runs out of memory +- Check for input buffer malloc failure in examples/gzappend.c +- Add note to contrib/blast to use binary mode in stdio +- Fix comparisons of differently signed integers in contrib/blast +- Check for invalid code length codes in contrib/puff +- Fix serious but very rare decompression bug in inftrees.c +- Update inflateBack() comments, since inflate() can be faster +- Use underscored I/O function names for WINAPI_FAMILY +- Add _tr_flush_bits to the external symbols prefixed by --zprefix +- Add contrib/vstudio/vc10 pre-build step for static only +- Quote --version-script argument in CMakeLists.txt +- Don't specify --version-script on Apple platforms in CMakeLists.txt +- Fix casting error in contrib/testzlib/testzlib.c +- Fix types in contrib/minizip to match result of get_crc_table() +- Simplify contrib/vstudio/vc10 with 'd' suffix +- Add TOP support to win32/Makefile.msc +- Suport i686 and amd64 assembler builds in CMakeLists.txt +- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h +- Add vc11 and vc12 build files to contrib/vstudio +- Add gzvprintf() as an undocumented function in zlib +- Fix configure for Sun shell +- Remove runtime check in configure for four-byte integer type +- Add casts and consts to ease user conversion to C++ +- Add man pages for minizip and miniunzip +- In Makefile uninstall, don't rm if preceding cd fails +- Do not return Z_BUF_ERROR if deflateParam() has nothing to write + +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no libary use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminancy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assmebler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + +Changes in 1.2.5 (19 Apr 2010) +- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] +- Default to libdir as sharedlibdir in configure [Nieder] +- Update copyright dates on modified source files +- Update trees.c to be able to generate modified trees.h +- Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] + +Changes in 1.2.4.5 (18 Apr 2010) +- Set sharedlibdir in configure [Torok] +- Set LDFLAGS in Makefile.in [Bar-Lev] +- Avoid mkdir objs race condition in Makefile.in [Bowler] +- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays +- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C +- Don't use hidden attribute when it is a warning generator (e.g. Solaris) + +Changes in 1.2.4.4 (18 Apr 2010) +- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok] +- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty +- Try to use bash or ksh regardless of functionality of /bin/sh +- Fix configure incompatibility with NetBSD sh +- Remove attempt to run under bash or ksh since have better NetBSD fix +- Fix win32/Makefile.gcc for MinGW [Bar-Lev] +- Add diagnostic messages when using CROSS_PREFIX in configure +- Added --sharedlibdir option to configure [Weigelt] +- Use hidden visibility attribute when available [Frysinger] + +Changes in 1.2.4.3 (10 Apr 2010) +- Only use CROSS_PREFIX in configure for ar and ranlib if they exist +- Use CROSS_PREFIX for nm [Bar-Lev] +- Assume _LARGEFILE64_SOURCE defined is equivalent to true +- Avoid use of undefined symbols in #if with && and || +- Make *64 prototypes in gzguts.h consistent with functions +- Add -shared load option for MinGW in configure [Bowler] +- Move z_off64_t to public interface, use instead of off64_t +- Remove ! from shell test in configure (not portable to Solaris) +- Change +0 macro tests to -0 for possibly increased portability + +Changes in 1.2.4.2 (9 Apr 2010) +- Add consistent carriage returns to readme.txt's in masmx86 and masmx64 +- Really provide prototypes for *64 functions when building without LFS +- Only define unlink() in minigzip.c if unistd.h not included +- Update README to point to contrib/vstudio project files +- Move projects/vc6 to old/ and remove projects/ +- Include stdlib.h in minigzip.c for setmode() definition under WinCE +- Clean up assembler builds in win32/Makefile.msc [Rowe] +- Include sys/types.h for Microsoft for off_t definition +- Fix memory leak on error in gz_open() +- Symbolize nm as $NM in configure [Weigelt] +- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt] +- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined +- Fix bug in gzeof() to take into account unused input data +- Avoid initialization of structures with variables in puff.c +- Updated win32/README-WIN32.txt [Rowe] + +Changes in 1.2.4.1 (28 Mar 2010) +- Remove the use of [a-z] constructs for sed in configure [gentoo 310225] +- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech] +- Restore "for debugging" comment on sprintf() in gzlib.c +- Remove fdopen for MVS from gzguts.h +- Put new README-WIN32.txt in win32 [Rowe] +- Add check for shell to configure and invoke another shell if needed +- Fix big fat stinking bug in gzseek() on uncompressed files +- Remove vestigial F_OPEN64 define in zutil.h +- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE +- Avoid errors on non-LFS systems when applications define LFS macros +- Set EXE to ".exe" in configure for MINGW [Kahle] +- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill] +- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev] +- Add DLL install in win32/makefile.gcc [Bar-Lev] +- Allow Linux* or linux* from uname in configure [Bar-Lev] +- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev] +- Add cross-compilation prefixes to configure [Bar-Lev] +- Match type exactly in gz_load() invocation in gzread.c +- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func +- Provide prototypes for *64 functions when building zlib without LFS +- Don't use -lc when linking shared library on MinGW +- Remove errno.h check in configure and vestigial errno code in zutil.h + +Changes in 1.2.4 (14 Mar 2010) +- Fix VER3 extraction in configure for no fourth subversion +- Update zlib.3, add docs to Makefile.in to make .pdf out of it +- Add zlib.3.pdf to distribution +- Don't set error code in gzerror() if passed pointer is NULL +- Apply destination directory fixes to CMakeLists.txt [Lowman] +- Move #cmakedefine's to a new zconf.in.cmakein +- Restore zconf.h for builds that don't use configure or cmake +- Add distclean to dummy Makefile for convenience +- Update and improve INDEX, README, and FAQ +- Update CMakeLists.txt for the return of zconf.h [Lowman] +- Update contrib/vstudio/vc9 and vc10 [Vollant] +- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc +- Apply license and readme changes to contrib/asm686 [Raiter] +- Check file name lengths and add -c option in minigzip.c [Li] +- Update contrib/amd64 and contrib/masmx86/ [Vollant] +- Avoid use of "eof" parameter in trees.c to not shadow library variable +- Update make_vms.com for removal of zlibdefs.h [Zinser] +- Update assembler code and vstudio projects in contrib [Vollant] +- Remove outdated assembler code contrib/masm686 and contrib/asm586 +- Remove old vc7 and vc8 from contrib/vstudio +- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe] +- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open() +- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant] +- Remove *64 functions from win32/zlib.def (they're not 64-bit yet) +- Fix bug in void-returning vsprintf() case in gzwrite.c +- Fix name change from inflate.h in contrib/inflate86/inffas86.c +- Check if temporary file exists before removing in make_vms.com [Zinser] +- Fix make install and uninstall for --static option +- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta] +- Update readme.txt in contrib/masmx64 and masmx86 to assemble + +Changes in 1.2.3.9 (21 Feb 2010) +- Expunge gzio.c +- Move as400 build information to old +- Fix updates in contrib/minizip and contrib/vstudio +- Add const to vsnprintf test in configure to avoid warnings [Weigelt] +- Delete zconf.h (made by configure) [Weigelt] +- Change zconf.in.h to zconf.h.in per convention [Weigelt] +- Check for NULL buf in gzgets() +- Return empty string for gzgets() with len == 1 (like fgets()) +- Fix description of gzgets() in zlib.h for end-of-file, NULL return +- Update minizip to 1.1 [Vollant] +- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c +- Note in zlib.h that gzerror() should be used to distinguish from EOF +- Remove use of snprintf() from gzlib.c +- Fix bug in gzseek() +- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant] +- Fix zconf.h generation in CMakeLists.txt [Lowman] +- Improve comments in zconf.h where modified by configure + +Changes in 1.2.3.8 (13 Feb 2010) +- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer] +- Use z_off64_t in gz_zero() and gz_skip() to match state->skip +- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t) +- Revert to Makefile.in from 1.2.3.6 (live with the clutter) +- Fix missing error return in gzflush(), add zlib.h note +- Add *64 functions to zlib.map [Levin] +- Fix signed/unsigned comparison in gz_comp() +- Use SFLAGS when testing shared linking in configure +- Add --64 option to ./configure to use -m64 with gcc +- Fix ./configure --help to correctly name options +- Have make fail if a test fails [Levin] +- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson] +- Remove assembler object files from contrib + +Changes in 1.2.3.7 (24 Jan 2010) +- Always gzopen() with O_LARGEFILE if available +- Fix gzdirect() to work immediately after gzopen() or gzdopen() +- Make gzdirect() more precise when the state changes while reading +- Improve zlib.h documentation in many places +- Catch memory allocation failure in gz_open() +- Complete close operation if seek forward in gzclose_w() fails +- Return Z_ERRNO from gzclose_r() if close() fails +- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL +- Return zero for gzwrite() errors to match zlib.h description +- Return -1 on gzputs() error to match zlib.h description +- Add zconf.in.h to allow recovery from configure modification [Weigelt] +- Fix static library permissions in Makefile.in [Weigelt] +- Avoid warnings in configure tests that hide functionality [Weigelt] +- Add *BSD and DragonFly to Linux case in configure [gentoo 123571] +- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212] +- Avoid access of uninitialized data for first inflateReset2 call [Gomes] +- Keep object files in subdirectories to reduce the clutter somewhat +- Remove default Makefile and zlibdefs.h, add dummy Makefile +- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_ +- Remove zlibdefs.h completely -- modify zconf.h instead + +Changes in 1.2.3.6 (17 Jan 2010) +- Avoid void * arithmetic in gzread.c and gzwrite.c +- Make compilers happier with const char * for gz_error message +- Avoid unused parameter warning in inflate.c +- Avoid signed-unsigned comparison warning in inflate.c +- Indent #pragma's for traditional C +- Fix usage of strwinerror() in glib.c, change to gz_strwinerror() +- Correct email address in configure for system options +- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser] +- Update zlib.map [Brown] +- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok] +- Apply various fixes to CMakeLists.txt [Lowman] +- Add checks on len in gzread() and gzwrite() +- Add error message for no more room for gzungetc() +- Remove zlib version check in gzwrite() +- Defer compression of gzprintf() result until need to +- Use snprintf() in gzdopen() if available +- Remove USE_MMAP configuration determination (only used by minigzip) +- Remove examples/pigz.c (available separately) +- Update examples/gun.c to 1.6 + +Changes in 1.2.3.5 (8 Jan 2010) +- Add space after #if in zutil.h for some compilers +- Fix relatively harmless bug in deflate_fast() [Exarevsky] +- Fix same problem in deflate_slow() +- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown] +- Add deflate_rle() for faster Z_RLE strategy run-length encoding +- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding +- Change name of "write" variable in inffast.c to avoid library collisions +- Fix premature EOF from gzread() in gzio.c [Brown] +- Use zlib header window size if windowBits is 0 in inflateInit2() +- Remove compressBound() call in deflate.c to avoid linking compress.o +- Replace use of errno in gz* with functions, support WinCE [Alves] +- Provide alternative to perror() in minigzip.c for WinCE [Alves] +- Don't use _vsnprintf on later versions of MSVC [Lowman] +- Add CMake build script and input file [Lowman] +- Update contrib/minizip to 1.1 [Svensson, Vollant] +- Moved nintendods directory from contrib to . +- Replace gzio.c with a new set of routines with the same functionality +- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above +- Update contrib/minizip to 1.1b +- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h + +Changes in 1.2.3.4 (21 Dec 2009) +- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility +- Update comments in configure and Makefile.in for default --shared +- Fix test -z's in configure [Marquess] +- Build examplesh and minigzipsh when not testing +- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h +- Import LDFLAGS from the environment in configure +- Fix configure to populate SFLAGS with discovered CFLAGS options +- Adapt make_vms.com to the new Makefile.in [Zinser] +- Add zlib2ansi script for C++ compilation [Marquess] +- Add _FILE_OFFSET_BITS=64 test to make test (when applicable) +- Add AMD64 assembler code for longest match to contrib [Teterin] +- Include options from $SFLAGS when doing $LDSHARED +- Simplify 64-bit file support by introducing z_off64_t type +- Make shared object files in objs directory to work around old Sun cc +- Use only three-part version number for Darwin shared compiles +- Add rc option to ar in Makefile.in for when ./configure not run +- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4* +- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile +- Protect against _FILE_OFFSET_BITS being defined when compiling zlib +- Rename Makefile.in targets allstatic to static and allshared to shared +- Fix static and shared Makefile.in targets to be independent +- Correct error return bug in gz_open() by setting state [Brown] +- Put spaces before ;;'s in configure for better sh compatibility +- Add pigz.c (parallel implementation of gzip) to examples/ +- Correct constant in crc32.c to UL [Leventhal] +- Reject negative lengths in crc32_combine() +- Add inflateReset2() function to work like inflateEnd()/inflateInit2() +- Include sys/types.h for _LARGEFILE64_SOURCE [Brown] +- Correct typo in doc/algorithm.txt [Janik] +- Fix bug in adler32_combine() [Zhu] +- Catch missing-end-of-block-code error in all inflates and in puff + Assures that random input to inflate eventually results in an error +- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/ +- Update ENOUGH and its usage to reflect discovered bounds +- Fix gzerror() error report on empty input file [Brown] +- Add ush casts in trees.c to avoid pedantic runtime errors +- Fix typo in zlib.h uncompress() description [Reiss] +- Correct inflate() comments with regard to automatic header detection +- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays) +- Put new version of gzlog (2.0) in examples with interruption recovery +- Add puff compile option to permit invalid distance-too-far streams +- Add puff TEST command options, ability to read piped input +- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but + _LARGEFILE64_SOURCE not defined +- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart +- Fix deflateSetDictionary() to use all 32K for output consistency +- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h) +- Clear bytes after deflate lookahead to avoid use of uninitialized data +- Change a limit in inftrees.c to be more transparent to Coverity Prevent +- Update win32/zlib.def with exported symbols from zlib.h +- Correct spelling errors in zlib.h [Willem, Sobrado] +- Allow Z_BLOCK for deflate() to force a new block +- Allow negative bits in inflatePrime() to delete existing bit buffer +- Add Z_TREES flush option to inflate() to return at end of trees +- Add inflateMark() to return current state information for random access +- Add Makefile for NintendoDS to contrib [Costa] +- Add -w in configure compile tests to avoid spurious warnings [Beucler] +- Fix typos in zlib.h comments for deflateSetDictionary() +- Fix EOF detection in transparent gzread() [Maier] + +Changes in 1.2.3.3 (2 October 2006) +- Make --shared the default for configure, add a --static option +- Add compile option to permit invalid distance-too-far streams +- Add inflateUndermine() function which is required to enable above +- Remove use of "this" variable name for C++ compatibility [Marquess] +- Add testing of shared library in make test, if shared library built +- Use ftello() and fseeko() if available instead of ftell() and fseek() +- Provide two versions of all functions that use the z_off_t type for + binary compatibility -- a normal version and a 64-bit offset version, + per the Large File Support Extension when _LARGEFILE64_SOURCE is + defined; use the 64-bit versions by default when _FILE_OFFSET_BITS + is defined to be 64 +- Add a --uname= option to configure to perhaps help with cross-compiling + +Changes in 1.2.3.2 (3 September 2006) +- Turn off silly Borland warnings [Hay] +- Use off64_t and define _LARGEFILE64_SOURCE when present +- Fix missing dependency on inffixed.h in Makefile.in +- Rig configure --shared to build both shared and static [Teredesai, Truta] +- Remove zconf.in.h and instead create a new zlibdefs.h file +- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant] +- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt] + +Changes in 1.2.3.1 (16 August 2006) +- Add watcom directory with OpenWatcom make files [Daniel] +- Remove #undef of FAR in zconf.in.h for MVS [Fedtke] +- Update make_vms.com [Zinser] +- Use -fPIC for shared build in configure [Teredesai, Nicholson] +- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] +- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck] +- Add some FAQ entries about the contrib directory +- Update the MVS question in the FAQ +- Avoid extraneous reads after EOF in gzio.c [Brown] +- Correct spelling of "successfully" in gzio.c [Randers-Pehrson] +- Add comments to zlib.h about gzerror() usage [Brown] +- Set extra flags in gzip header in gzopen() like deflate() does +- Make configure options more compatible with double-dash conventions + [Weigelt] +- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen] +- Fix uninstall target in Makefile.in [Truta] +- Add pkgconfig support [Weigelt] +- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt] +- Replace set_data_type() with a more accurate detect_data_type() in + trees.c, according to the txtvsbin.txt document [Truta] +- Swap the order of #include and #include "zlib.h" in + gzio.c, example.c and minigzip.c [Truta] +- Shut up annoying VS2005 warnings about standard C deprecation [Rowe, + Truta] (where?) +- Fix target "clean" from win32/Makefile.bor [Truta] +- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe] +- Update zlib www home address in win32/DLL_FAQ.txt [Truta] +- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove] +- Enable browse info in the "Debug" and "ASM Debug" configurations in + the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta] +- Add pkgconfig support [Weigelt] +- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h, + for use in win32/zlib1.rc [Polushin, Rowe, Truta] +- Add a document that explains the new text detection scheme to + doc/txtvsbin.txt [Truta] +- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta] +- Move algorithm.txt into doc/ [Truta] +- Synchronize FAQ with website +- Fix compressBound(), was low for some pathological cases [Fearnley] +- Take into account wrapper variations in deflateBound() +- Set examples/zpipe.c input and output to binary mode for Windows +- Update examples/zlib_how.html with new zpipe.c (also web site) +- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems + that gcc became pickier in 4.0) +- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain + un-versioned, the patch adds versioning only for symbols introduced in + zlib-1.2.0 or later. It also declares as local those symbols which are + not designed to be exported." [Levin] +- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure +- Do not initialize global static by default in trees.c, add a response + NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess] +- Don't use strerror() in gzio.c under WinCE [Yakimov] +- Don't use errno.h in zutil.h under WinCE [Yakimov] +- Move arguments for AR to its usage to allow replacing ar [Marot] +- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson] +- Improve inflateInit() and inflateInit2() documentation +- Fix structure size comment in inflate.h +- Change configure help option from --h* to --help [Santos] + +Changes in 1.2.3 (18 July 2005) +- Apply security vulnerability fixes to contrib/infback9 as well +- Clean up some text files (carriage returns, trailing space) +- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] + +Changes in 1.2.2.4 (11 July 2005) +- Add inflatePrime() function for starting inflation at bit boundary +- Avoid some Visual C warnings in deflate.c +- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit + compile +- Fix some spelling errors in comments [Betts] +- Correct inflateInit2() error return documentation in zlib.h +- Add zran.c example of compressed data random access to examples + directory, shows use of inflatePrime() +- Fix cast for assignments to strm->state in inflate.c and infback.c +- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] +- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] +- Add cast in trees.c t avoid a warning [Oberhumer] +- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] +- Update make_vms.com [Zinser] +- Initialize state->write in inflateReset() since copied in inflate_fast() +- Be more strict on incomplete code sets in inflate_table() and increase + ENOUGH and MAXD -- this repairs a possible security vulnerability for + invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for + discovering the vulnerability and providing test cases. +- Add ia64 support to configure for HP-UX [Smith] +- Add error return to gzread() for format or i/o error [Levin] +- Use malloc.h for OS/2 [Necasek] + +Changes in 1.2.2.3 (27 May 2005) +- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile +- Typecast fread() return values in gzio.c [Vollant] +- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) +- Fix crc check bug in gzread() after gzungetc() [Heiner] +- Add the deflateTune() function to adjust internal compression parameters +- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) +- Remove an incorrect assertion in examples/zpipe.c +- Add C++ wrapper in infback9.h [Donais] +- Fix bug in inflateCopy() when decoding fixed codes +- Note in zlib.h how much deflateSetDictionary() actually uses +- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) +- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] +- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] +- Add gzdirect() function to indicate transparent reads +- Update contrib/minizip [Vollant] +- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] +- Add casts in crc32.c to avoid warnings [Oberhumer] +- Add contrib/masmx64 [Vollant] +- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] + +Changes in 1.2.2.2 (30 December 2004) +- Replace structure assignments in deflate.c and inflate.c with zmemcpy to + avoid implicit memcpy calls (portability for no-library compilation) +- Increase sprintf() buffer size in gzdopen() to allow for large numbers +- Add INFLATE_STRICT to check distances against zlib header +- Improve WinCE errno handling and comments [Chang] +- Remove comment about no gzip header processing in FAQ +- Add Z_FIXED strategy option to deflateInit2() to force fixed trees +- Add updated make_vms.com [Coghlan], update README +- Create a new "examples" directory, move gzappend.c there, add zpipe.c, + fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. +- Add FAQ entry and comments in deflate.c on uninitialized memory access +- Add Solaris 9 make options in configure [Gilbert] +- Allow strerror() usage in gzio.c for STDC +- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] +- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] +- Use z_off_t for adler32_combine() and crc32_combine() lengths +- Make adler32() much faster for small len +- Use OS_CODE in deflate() default gzip header + +Changes in 1.2.2.1 (31 October 2004) +- Allow inflateSetDictionary() call for raw inflate +- Fix inflate header crc check bug for file names and comments +- Add deflateSetHeader() and gz_header structure for custom gzip headers +- Add inflateGetheader() to retrieve gzip headers +- Add crc32_combine() and adler32_combine() functions +- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list +- Use zstreamp consistently in zlib.h (inflate_back functions) +- Remove GUNZIP condition from definition of inflate_mode in inflate.h + and in contrib/inflate86/inffast.S [Truta, Anderson] +- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] +- Update projects/README.projects and projects/visualc6 [Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] +- Deprecate Z_ASCII; use Z_TEXT instead [Truta] +- Use a new algorithm for setting strm->data_type in trees.c [Truta] +- Do not define an exit() prototype in zutil.c unless DEBUG defined +- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] +- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() +- Fix Darwin build version identification [Peterson] + +Changes in 1.2.2 (3 October 2004) +- Update zlib.h comments on gzip in-memory processing +- Set adler to 1 in inflateReset() to support Java test suite [Walles] +- Add contrib/dotzlib [Ravn] +- Update win32/DLL_FAQ.txt [Truta] +- Update contrib/minizip [Vollant] +- Move contrib/visual-basic.txt to old/ [Truta] +- Fix assembler builds in projects/visualc6/ [Truta] + +Changes in 1.2.1.2 (9 September 2004) +- Update INDEX file +- Fix trees.c to update strm->data_type (no one ever noticed!) +- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] +- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) +- Add limited multitasking protection to DYNAMIC_CRC_TABLE +- Add NO_vsnprintf for VMS in zutil.h [Mozilla] +- Don't declare strerror() under VMS [Mozilla] +- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize +- Update contrib/ada [Anisimkov] +- Update contrib/minizip [Vollant] +- Fix configure to not hardcode directories for Darwin [Peterson] +- Fix gzio.c to not return error on empty files [Brown] +- Fix indentation; update version in contrib/delphi/ZLib.pas and + contrib/pascal/zlibpas.pas [Truta] +- Update mkasm.bat in contrib/masmx86 [Truta] +- Update contrib/untgz [Truta] +- Add projects/README.projects [Truta] +- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] +- Remove an unnecessary assignment to curr in inftrees.c [Truta] +- Add OS/2 to exe builds in configure [Poltorak] +- Remove err dummy parameter in zlib.h [Kientzle] + +Changes in 1.2.1.1 (9 January 2004) +- Update email address in README +- Several FAQ updates +- Fix a big fat bug in inftrees.c that prevented decoding valid + dynamic blocks with only literals and no distance codes -- + Thanks to "Hot Emu" for the bug report and sample file +- Add a note to puff.c on no distance codes case. + +Changes in 1.2.1 (17 November 2003) +- Remove a tab in contrib/gzappend/gzappend.c +- Update some interfaces in contrib for new zlib functions +- Update zlib version number in some contrib entries +- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] +- Support shared libraries on Hurd and KFreeBSD [Brown] +- Fix error in NO_DIVIDE option of adler32.c + +Changes in 1.2.0.8 (4 November 2003) +- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas +- Add experimental NO_DIVIDE #define in adler32.c + - Possibly faster on some processors (let me know if it is) +- Correct Z_BLOCK to not return on first inflate call if no wrap +- Fix strm->data_type on inflate() return to correctly indicate EOB +- Add deflatePrime() function for appending in the middle of a byte +- Add contrib/gzappend for an example of appending to a stream +- Update win32/DLL_FAQ.txt [Truta] +- Delete Turbo C comment in README [Truta] +- Improve some indentation in zconf.h [Truta] +- Fix infinite loop on bad input in configure script [Church] +- Fix gzeof() for concatenated gzip files [Johnson] +- Add example to contrib/visual-basic.txt [Michael B.] +- Add -p to mkdir's in Makefile.in [vda] +- Fix configure to properly detect presence or lack of printf functions +- Add AS400 support [Monnerat] +- Add a little Cygwin support [Wilson] + +Changes in 1.2.0.7 (21 September 2003) +- Correct some debug formats in contrib/infback9 +- Cast a type in a debug statement in trees.c +- Change search and replace delimiter in configure from % to # [Beebe] +- Update contrib/untgz to 0.2 with various fixes [Truta] +- Add build support for Amiga [Nikl] +- Remove some directories in old that have been updated to 1.2 +- Add dylib building for Mac OS X in configure and Makefile.in +- Remove old distribution stuff from Makefile +- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X +- Update links in README + +Changes in 1.2.0.6 (13 September 2003) +- Minor FAQ updates +- Update contrib/minizip to 1.00 [Vollant] +- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] +- Update POSTINC comment for 68060 [Nikl] +- Add contrib/infback9 with deflate64 decoding (unsupported) +- For MVS define NO_vsnprintf and undefine FAR [van Burik] +- Add pragma for fdopen on MVS [van Burik] + +Changes in 1.2.0.5 (8 September 2003) +- Add OF to inflateBackEnd() declaration in zlib.h +- Remember start when using gzdopen in the middle of a file +- Use internal off_t counters in gz* functions to properly handle seeks +- Perform more rigorous check for distance-too-far in inffast.c +- Add Z_BLOCK flush option to return from inflate at block boundary +- Set strm->data_type on return from inflate + - Indicate bits unused, if at block boundary, and if in last block +- Replace size_t with ptrdiff_t in crc32.c, and check for correct size +- Add condition so old NO_DEFLATE define still works for compatibility +- FAQ update regarding the Windows DLL [Truta] +- INDEX update: add qnx entry, remove aix entry [Truta] +- Install zlib.3 into mandir [Wilson] +- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] +- Adapt the zlib interface to the new DLL convention guidelines [Truta] +- Introduce ZLIB_WINAPI macro to allow the export of functions using + the WINAPI calling convention, for Visual Basic [Vollant, Truta] +- Update msdos and win32 scripts and makefiles [Truta] +- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] +- Add contrib/ada [Anisimkov] +- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] +- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] +- Add contrib/masm686 [Truta] +- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm + [Truta, Vollant] +- Update contrib/delphi; rename to contrib/pascal; add example [Truta] +- Remove contrib/delphi2; add a new contrib/delphi [Truta] +- Avoid inclusion of the nonstandard in contrib/iostream, + and fix some method prototypes [Truta] +- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip + [Truta] +- Avoid the use of backslash (\) in contrib/minizip [Vollant] +- Fix file time handling in contrib/untgz; update makefiles [Truta] +- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines + [Vollant] +- Remove contrib/vstudio/vc15_16 [Vollant] +- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] +- Update README.contrib [Truta] +- Invert the assignment order of match_head and s->prev[...] in + INSERT_STRING [Truta] +- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings + [Truta] +- Compare function pointers with 0, not with NULL or Z_NULL [Truta] +- Fix prototype of syncsearch in inflate.c [Truta] +- Introduce ASMINF macro to be enabled when using an ASM implementation + of inflate_fast [Truta] +- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] +- Modify test_gzio in example.c to take a single file name as a + parameter [Truta] +- Exit the example.c program if gzopen fails [Truta] +- Add type casts around strlen in example.c [Truta] *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 21:13:33 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F1FD4FDB for ; Wed, 31 Jul 2013 21:13:33 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DC45727B3 for ; Wed, 31 Jul 2013 21:13:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VLDXYM014003 for ; Wed, 31 Jul 2013 21:13:33 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VLDXxm013991 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 21:13:33 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 31 Jul 2013 21:13:33 GMT Message-Id: <201307312113.r6VLDXxm013991@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255405 - in soc2013/dpl/head/lib: libz/capsicumized libzcap libzcap/contrib libzcap/contrib/asm686 libzcap/contrib/gcc_gvmat64 libzcap/doc libzcap/test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 31 Jul 2013 21:13:34 -0000 Author: dpl Date: Wed Jul 31 21:13:33 2013 New Revision: 255405 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255405 Log: Swapped "capsicumized" directory with libzcap, wich will be the protected library. Added: soc2013/dpl/head/lib/libzcap/ soc2013/dpl/head/lib/libzcap/ChangeLog soc2013/dpl/head/lib/libzcap/FAQ soc2013/dpl/head/lib/libzcap/FREEBSD-upgrade soc2013/dpl/head/lib/libzcap/Makefile soc2013/dpl/head/lib/libzcap/README soc2013/dpl/head/lib/libzcap/Symbol.map soc2013/dpl/head/lib/libzcap/Versions.def soc2013/dpl/head/lib/libzcap/adler32.c soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/capsicum.h soc2013/dpl/head/lib/libzcap/compress.c soc2013/dpl/head/lib/libzcap/contrib/ soc2013/dpl/head/lib/libzcap/contrib/README.contrib soc2013/dpl/head/lib/libzcap/contrib/asm686/ soc2013/dpl/head/lib/libzcap/contrib/asm686/README.686 soc2013/dpl/head/lib/libzcap/contrib/asm686/match.S soc2013/dpl/head/lib/libzcap/contrib/gcc_gvmat64/ soc2013/dpl/head/lib/libzcap/contrib/gcc_gvmat64/gvmat64.S soc2013/dpl/head/lib/libzcap/crc32.c soc2013/dpl/head/lib/libzcap/crc32.h soc2013/dpl/head/lib/libzcap/deflate.c soc2013/dpl/head/lib/libzcap/deflate.h soc2013/dpl/head/lib/libzcap/doc/ soc2013/dpl/head/lib/libzcap/doc/algorithm.txt soc2013/dpl/head/lib/libzcap/doc/rfc1950.txt soc2013/dpl/head/lib/libzcap/doc/rfc1951.txt soc2013/dpl/head/lib/libzcap/doc/rfc1952.txt soc2013/dpl/head/lib/libzcap/doc/txtvsbin.txt soc2013/dpl/head/lib/libzcap/gzclose.c soc2013/dpl/head/lib/libzcap/gzguts.h soc2013/dpl/head/lib/libzcap/gzlib.c soc2013/dpl/head/lib/libzcap/gzread.c soc2013/dpl/head/lib/libzcap/gzwrite.c soc2013/dpl/head/lib/libzcap/infback.c soc2013/dpl/head/lib/libzcap/inffast.c soc2013/dpl/head/lib/libzcap/inffast.h soc2013/dpl/head/lib/libzcap/inffixed.h soc2013/dpl/head/lib/libzcap/inflate.c soc2013/dpl/head/lib/libzcap/inflate.h soc2013/dpl/head/lib/libzcap/inftrees.c soc2013/dpl/head/lib/libzcap/inftrees.h soc2013/dpl/head/lib/libzcap/test/ soc2013/dpl/head/lib/libzcap/test/example.c soc2013/dpl/head/lib/libzcap/test/infcover.c soc2013/dpl/head/lib/libzcap/test/minigzip.c soc2013/dpl/head/lib/libzcap/trees.c soc2013/dpl/head/lib/libzcap/trees.h soc2013/dpl/head/lib/libzcap/uncompr.c soc2013/dpl/head/lib/libzcap/zconf.h soc2013/dpl/head/lib/libzcap/zlib.3 soc2013/dpl/head/lib/libzcap/zlib.h soc2013/dpl/head/lib/libzcap/zopen.c soc2013/dpl/head/lib/libzcap/zutil.c soc2013/dpl/head/lib/libzcap/zutil.h Deleted: soc2013/dpl/head/lib/libz/capsicumized/ Added: soc2013/dpl/head/lib/libzcap/ChangeLog ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libzcap/ChangeLog Wed Jul 31 21:13:33 2013 (r255405) @@ -0,0 +1,1472 @@ + + ChangeLog file for zlib + +Changes in 1.2.8 (28 Apr 2013) +- Update contrib/minizip/iowin32.c for Windows RT [Vollant] +- Do not force Z_CONST for C++ +- Clean up contrib/vstudio [Ro§] +- Correct spelling error in zlib.h +- Fix mixed line endings in contrib/vstudio + +Changes in 1.2.7.3 (13 Apr 2013) +- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc + +Changes in 1.2.7.2 (13 Apr 2013) +- Change check for a four-byte type back to hexadecimal +- Fix typo in win32/Makefile.msc +- Add casts in gzwrite.c for pointer differences + +Changes in 1.2.7.1 (24 Mar 2013) +- Replace use of unsafe string functions with snprintf if available +- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink] +- Fix gzgetc undefine when Z_PREFIX set [Turk] +- Eliminate use of mktemp in Makefile (not always available) +- Fix bug in 'F' mode for gzopen() +- Add inflateGetDictionary() function +- Correct comment in deflate.h +- Use _snprintf for snprintf in Microsoft C +- On Darwin, only use /usr/bin/libtool if libtool is not Apple +- Delete "--version" file if created by "ar --version" [Richard G.] +- Fix configure check for veracity of compiler error return codes +- Fix CMake compilation of static lib for MSVC2010 x64 +- Remove unused variable in infback9.c +- Fix argument checks in gzlog_compress() and gzlog_write() +- Clean up the usage of z_const and respect const usage within zlib +- Clean up examples/gzlog.[ch] comparisons of different types +- Avoid shift equal to bits in type (caused endless loop) +- Fix unintialized value bug in gzputc() introduced by const patches +- Fix memory allocation error in examples/zran.c [Nor] +- Fix bug where gzopen(), gzclose() would write an empty file +- Fix bug in gzclose() when gzwrite() runs out of memory +- Check for input buffer malloc failure in examples/gzappend.c +- Add note to contrib/blast to use binary mode in stdio +- Fix comparisons of differently signed integers in contrib/blast +- Check for invalid code length codes in contrib/puff +- Fix serious but very rare decompression bug in inftrees.c +- Update inflateBack() comments, since inflate() can be faster +- Use underscored I/O function names for WINAPI_FAMILY +- Add _tr_flush_bits to the external symbols prefixed by --zprefix +- Add contrib/vstudio/vc10 pre-build step for static only +- Quote --version-script argument in CMakeLists.txt +- Don't specify --version-script on Apple platforms in CMakeLists.txt +- Fix casting error in contrib/testzlib/testzlib.c +- Fix types in contrib/minizip to match result of get_crc_table() +- Simplify contrib/vstudio/vc10 with 'd' suffix +- Add TOP support to win32/Makefile.msc +- Suport i686 and amd64 assembler builds in CMakeLists.txt +- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h +- Add vc11 and vc12 build files to contrib/vstudio +- Add gzvprintf() as an undocumented function in zlib +- Fix configure for Sun shell +- Remove runtime check in configure for four-byte integer type +- Add casts and consts to ease user conversion to C++ +- Add man pages for minizip and miniunzip +- In Makefile uninstall, don't rm if preceding cd fails +- Do not return Z_BUF_ERROR if deflateParam() has nothing to write + +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no libary use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminancy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assmebler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + +Changes in 1.2.5 (19 Apr 2010) +- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] +- Default to libdir as sharedlibdir in configure [Nieder] +- Update copyright dates on modified source files +- Update trees.c to be able to generate modified trees.h +- Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] + +Changes in 1.2.4.5 (18 Apr 2010) +- Set sharedlibdir in configure [Torok] +- Set LDFLAGS in Makefile.in [Bar-Lev] +- Avoid mkdir objs race condition in Makefile.in [Bowler] +- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays +- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C +- Don't use hidden attribute when it is a warning generator (e.g. Solaris) + +Changes in 1.2.4.4 (18 Apr 2010) +- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok] +- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty +- Try to use bash or ksh regardless of functionality of /bin/sh +- Fix configure incompatibility with NetBSD sh +- Remove attempt to run under bash or ksh since have better NetBSD fix +- Fix win32/Makefile.gcc for MinGW [Bar-Lev] +- Add diagnostic messages when using CROSS_PREFIX in configure +- Added --sharedlibdir option to configure [Weigelt] +- Use hidden visibility attribute when available [Frysinger] + +Changes in 1.2.4.3 (10 Apr 2010) +- Only use CROSS_PREFIX in configure for ar and ranlib if they exist +- Use CROSS_PREFIX for nm [Bar-Lev] +- Assume _LARGEFILE64_SOURCE defined is equivalent to true +- Avoid use of undefined symbols in #if with && and || +- Make *64 prototypes in gzguts.h consistent with functions +- Add -shared load option for MinGW in configure [Bowler] +- Move z_off64_t to public interface, use instead of off64_t +- Remove ! from shell test in configure (not portable to Solaris) +- Change +0 macro tests to -0 for possibly increased portability + +Changes in 1.2.4.2 (9 Apr 2010) +- Add consistent carriage returns to readme.txt's in masmx86 and masmx64 +- Really provide prototypes for *64 functions when building without LFS +- Only define unlink() in minigzip.c if unistd.h not included +- Update README to point to contrib/vstudio project files +- Move projects/vc6 to old/ and remove projects/ +- Include stdlib.h in minigzip.c for setmode() definition under WinCE +- Clean up assembler builds in win32/Makefile.msc [Rowe] +- Include sys/types.h for Microsoft for off_t definition +- Fix memory leak on error in gz_open() +- Symbolize nm as $NM in configure [Weigelt] +- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt] +- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined +- Fix bug in gzeof() to take into account unused input data +- Avoid initialization of structures with variables in puff.c +- Updated win32/README-WIN32.txt [Rowe] + +Changes in 1.2.4.1 (28 Mar 2010) +- Remove the use of [a-z] constructs for sed in configure [gentoo 310225] +- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech] +- Restore "for debugging" comment on sprintf() in gzlib.c +- Remove fdopen for MVS from gzguts.h +- Put new README-WIN32.txt in win32 [Rowe] +- Add check for shell to configure and invoke another shell if needed +- Fix big fat stinking bug in gzseek() on uncompressed files +- Remove vestigial F_OPEN64 define in zutil.h +- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE +- Avoid errors on non-LFS systems when applications define LFS macros +- Set EXE to ".exe" in configure for MINGW [Kahle] +- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill] +- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev] +- Add DLL install in win32/makefile.gcc [Bar-Lev] +- Allow Linux* or linux* from uname in configure [Bar-Lev] +- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev] +- Add cross-compilation prefixes to configure [Bar-Lev] +- Match type exactly in gz_load() invocation in gzread.c +- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func +- Provide prototypes for *64 functions when building zlib without LFS +- Don't use -lc when linking shared library on MinGW +- Remove errno.h check in configure and vestigial errno code in zutil.h + +Changes in 1.2.4 (14 Mar 2010) +- Fix VER3 extraction in configure for no fourth subversion +- Update zlib.3, add docs to Makefile.in to make .pdf out of it +- Add zlib.3.pdf to distribution +- Don't set error code in gzerror() if passed pointer is NULL +- Apply destination directory fixes to CMakeLists.txt [Lowman] +- Move #cmakedefine's to a new zconf.in.cmakein +- Restore zconf.h for builds that don't use configure or cmake +- Add distclean to dummy Makefile for convenience +- Update and improve INDEX, README, and FAQ +- Update CMakeLists.txt for the return of zconf.h [Lowman] +- Update contrib/vstudio/vc9 and vc10 [Vollant] +- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc +- Apply license and readme changes to contrib/asm686 [Raiter] +- Check file name lengths and add -c option in minigzip.c [Li] +- Update contrib/amd64 and contrib/masmx86/ [Vollant] +- Avoid use of "eof" parameter in trees.c to not shadow library variable +- Update make_vms.com for removal of zlibdefs.h [Zinser] +- Update assembler code and vstudio projects in contrib [Vollant] +- Remove outdated assembler code contrib/masm686 and contrib/asm586 +- Remove old vc7 and vc8 from contrib/vstudio +- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe] +- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open() +- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant] +- Remove *64 functions from win32/zlib.def (they're not 64-bit yet) +- Fix bug in void-returning vsprintf() case in gzwrite.c +- Fix name change from inflate.h in contrib/inflate86/inffas86.c +- Check if temporary file exists before removing in make_vms.com [Zinser] +- Fix make install and uninstall for --static option +- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta] +- Update readme.txt in contrib/masmx64 and masmx86 to assemble + +Changes in 1.2.3.9 (21 Feb 2010) +- Expunge gzio.c +- Move as400 build information to old +- Fix updates in contrib/minizip and contrib/vstudio +- Add const to vsnprintf test in configure to avoid warnings [Weigelt] +- Delete zconf.h (made by configure) [Weigelt] +- Change zconf.in.h to zconf.h.in per convention [Weigelt] +- Check for NULL buf in gzgets() +- Return empty string for gzgets() with len == 1 (like fgets()) +- Fix description of gzgets() in zlib.h for end-of-file, NULL return +- Update minizip to 1.1 [Vollant] +- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c +- Note in zlib.h that gzerror() should be used to distinguish from EOF +- Remove use of snprintf() from gzlib.c +- Fix bug in gzseek() +- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant] +- Fix zconf.h generation in CMakeLists.txt [Lowman] +- Improve comments in zconf.h where modified by configure + +Changes in 1.2.3.8 (13 Feb 2010) +- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer] +- Use z_off64_t in gz_zero() and gz_skip() to match state->skip +- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t) +- Revert to Makefile.in from 1.2.3.6 (live with the clutter) +- Fix missing error return in gzflush(), add zlib.h note +- Add *64 functions to zlib.map [Levin] +- Fix signed/unsigned comparison in gz_comp() +- Use SFLAGS when testing shared linking in configure +- Add --64 option to ./configure to use -m64 with gcc +- Fix ./configure --help to correctly name options +- Have make fail if a test fails [Levin] +- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson] +- Remove assembler object files from contrib + +Changes in 1.2.3.7 (24 Jan 2010) +- Always gzopen() with O_LARGEFILE if available +- Fix gzdirect() to work immediately after gzopen() or gzdopen() +- Make gzdirect() more precise when the state changes while reading +- Improve zlib.h documentation in many places +- Catch memory allocation failure in gz_open() +- Complete close operation if seek forward in gzclose_w() fails +- Return Z_ERRNO from gzclose_r() if close() fails +- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL +- Return zero for gzwrite() errors to match zlib.h description +- Return -1 on gzputs() error to match zlib.h description +- Add zconf.in.h to allow recovery from configure modification [Weigelt] +- Fix static library permissions in Makefile.in [Weigelt] +- Avoid warnings in configure tests that hide functionality [Weigelt] +- Add *BSD and DragonFly to Linux case in configure [gentoo 123571] +- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212] +- Avoid access of uninitialized data for first inflateReset2 call [Gomes] +- Keep object files in subdirectories to reduce the clutter somewhat +- Remove default Makefile and zlibdefs.h, add dummy Makefile +- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_ +- Remove zlibdefs.h completely -- modify zconf.h instead + +Changes in 1.2.3.6 (17 Jan 2010) +- Avoid void * arithmetic in gzread.c and gzwrite.c +- Make compilers happier with const char * for gz_error message +- Avoid unused parameter warning in inflate.c +- Avoid signed-unsigned comparison warning in inflate.c +- Indent #pragma's for traditional C +- Fix usage of strwinerror() in glib.c, change to gz_strwinerror() +- Correct email address in configure for system options +- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser] +- Update zlib.map [Brown] +- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok] +- Apply various fixes to CMakeLists.txt [Lowman] +- Add checks on len in gzread() and gzwrite() +- Add error message for no more room for gzungetc() +- Remove zlib version check in gzwrite() +- Defer compression of gzprintf() result until need to +- Use snprintf() in gzdopen() if available +- Remove USE_MMAP configuration determination (only used by minigzip) +- Remove examples/pigz.c (available separately) +- Update examples/gun.c to 1.6 + +Changes in 1.2.3.5 (8 Jan 2010) +- Add space after #if in zutil.h for some compilers +- Fix relatively harmless bug in deflate_fast() [Exarevsky] +- Fix same problem in deflate_slow() +- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown] +- Add deflate_rle() for faster Z_RLE strategy run-length encoding +- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding +- Change name of "write" variable in inffast.c to avoid library collisions +- Fix premature EOF from gzread() in gzio.c [Brown] +- Use zlib header window size if windowBits is 0 in inflateInit2() +- Remove compressBound() call in deflate.c to avoid linking compress.o +- Replace use of errno in gz* with functions, support WinCE [Alves] +- Provide alternative to perror() in minigzip.c for WinCE [Alves] +- Don't use _vsnprintf on later versions of MSVC [Lowman] +- Add CMake build script and input file [Lowman] +- Update contrib/minizip to 1.1 [Svensson, Vollant] +- Moved nintendods directory from contrib to . +- Replace gzio.c with a new set of routines with the same functionality +- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above +- Update contrib/minizip to 1.1b +- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h + +Changes in 1.2.3.4 (21 Dec 2009) +- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility +- Update comments in configure and Makefile.in for default --shared +- Fix test -z's in configure [Marquess] +- Build examplesh and minigzipsh when not testing +- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h +- Import LDFLAGS from the environment in configure +- Fix configure to populate SFLAGS with discovered CFLAGS options +- Adapt make_vms.com to the new Makefile.in [Zinser] +- Add zlib2ansi script for C++ compilation [Marquess] +- Add _FILE_OFFSET_BITS=64 test to make test (when applicable) +- Add AMD64 assembler code for longest match to contrib [Teterin] +- Include options from $SFLAGS when doing $LDSHARED +- Simplify 64-bit file support by introducing z_off64_t type +- Make shared object files in objs directory to work around old Sun cc +- Use only three-part version number for Darwin shared compiles +- Add rc option to ar in Makefile.in for when ./configure not run +- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4* +- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile +- Protect against _FILE_OFFSET_BITS being defined when compiling zlib +- Rename Makefile.in targets allstatic to static and allshared to shared +- Fix static and shared Makefile.in targets to be independent +- Correct error return bug in gz_open() by setting state [Brown] +- Put spaces before ;;'s in configure for better sh compatibility +- Add pigz.c (parallel implementation of gzip) to examples/ +- Correct constant in crc32.c to UL [Leventhal] +- Reject negative lengths in crc32_combine() +- Add inflateReset2() function to work like inflateEnd()/inflateInit2() +- Include sys/types.h for _LARGEFILE64_SOURCE [Brown] +- Correct typo in doc/algorithm.txt [Janik] +- Fix bug in adler32_combine() [Zhu] +- Catch missing-end-of-block-code error in all inflates and in puff + Assures that random input to inflate eventually results in an error +- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/ +- Update ENOUGH and its usage to reflect discovered bounds +- Fix gzerror() error report on empty input file [Brown] +- Add ush casts in trees.c to avoid pedantic runtime errors +- Fix typo in zlib.h uncompress() description [Reiss] +- Correct inflate() comments with regard to automatic header detection +- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays) +- Put new version of gzlog (2.0) in examples with interruption recovery +- Add puff compile option to permit invalid distance-too-far streams +- Add puff TEST command options, ability to read piped input +- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but + _LARGEFILE64_SOURCE not defined +- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart +- Fix deflateSetDictionary() to use all 32K for output consistency +- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h) +- Clear bytes after deflate lookahead to avoid use of uninitialized data +- Change a limit in inftrees.c to be more transparent to Coverity Prevent +- Update win32/zlib.def with exported symbols from zlib.h +- Correct spelling errors in zlib.h [Willem, Sobrado] +- Allow Z_BLOCK for deflate() to force a new block +- Allow negative bits in inflatePrime() to delete existing bit buffer +- Add Z_TREES flush option to inflate() to return at end of trees +- Add inflateMark() to return current state information for random access +- Add Makefile for NintendoDS to contrib [Costa] +- Add -w in configure compile tests to avoid spurious warnings [Beucler] +- Fix typos in zlib.h comments for deflateSetDictionary() +- Fix EOF detection in transparent gzread() [Maier] + +Changes in 1.2.3.3 (2 October 2006) +- Make --shared the default for configure, add a --static option +- Add compile option to permit invalid distance-too-far streams +- Add inflateUndermine() function which is required to enable above +- Remove use of "this" variable name for C++ compatibility [Marquess] +- Add testing of shared library in make test, if shared library built +- Use ftello() and fseeko() if available instead of ftell() and fseek() +- Provide two versions of all functions that use the z_off_t type for + binary compatibility -- a normal version and a 64-bit offset version, + per the Large File Support Extension when _LARGEFILE64_SOURCE is + defined; use the 64-bit versions by default when _FILE_OFFSET_BITS + is defined to be 64 +- Add a --uname= option to configure to perhaps help with cross-compiling + +Changes in 1.2.3.2 (3 September 2006) +- Turn off silly Borland warnings [Hay] +- Use off64_t and define _LARGEFILE64_SOURCE when present +- Fix missing dependency on inffixed.h in Makefile.in +- Rig configure --shared to build both shared and static [Teredesai, Truta] +- Remove zconf.in.h and instead create a new zlibdefs.h file +- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant] +- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt] + +Changes in 1.2.3.1 (16 August 2006) +- Add watcom directory with OpenWatcom make files [Daniel] +- Remove #undef of FAR in zconf.in.h for MVS [Fedtke] +- Update make_vms.com [Zinser] +- Use -fPIC for shared build in configure [Teredesai, Nicholson] +- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] +- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck] +- Add some FAQ entries about the contrib directory +- Update the MVS question in the FAQ +- Avoid extraneous reads after EOF in gzio.c [Brown] +- Correct spelling of "successfully" in gzio.c [Randers-Pehrson] +- Add comments to zlib.h about gzerror() usage [Brown] +- Set extra flags in gzip header in gzopen() like deflate() does +- Make configure options more compatible with double-dash conventions + [Weigelt] +- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen] +- Fix uninstall target in Makefile.in [Truta] +- Add pkgconfig support [Weigelt] +- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt] +- Replace set_data_type() with a more accurate detect_data_type() in + trees.c, according to the txtvsbin.txt document [Truta] +- Swap the order of #include and #include "zlib.h" in + gzio.c, example.c and minigzip.c [Truta] +- Shut up annoying VS2005 warnings about standard C deprecation [Rowe, + Truta] (where?) +- Fix target "clean" from win32/Makefile.bor [Truta] +- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe] +- Update zlib www home address in win32/DLL_FAQ.txt [Truta] +- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove] +- Enable browse info in the "Debug" and "ASM Debug" configurations in + the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta] +- Add pkgconfig support [Weigelt] +- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h, + for use in win32/zlib1.rc [Polushin, Rowe, Truta] +- Add a document that explains the new text detection scheme to + doc/txtvsbin.txt [Truta] +- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta] +- Move algorithm.txt into doc/ [Truta] +- Synchronize FAQ with website +- Fix compressBound(), was low for some pathological cases [Fearnley] +- Take into account wrapper variations in deflateBound() +- Set examples/zpipe.c input and output to binary mode for Windows +- Update examples/zlib_how.html with new zpipe.c (also web site) +- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems + that gcc became pickier in 4.0) +- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain + un-versioned, the patch adds versioning only for symbols introduced in + zlib-1.2.0 or later. It also declares as local those symbols which are + not designed to be exported." [Levin] +- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure +- Do not initialize global static by default in trees.c, add a response + NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess] +- Don't use strerror() in gzio.c under WinCE [Yakimov] +- Don't use errno.h in zutil.h under WinCE [Yakimov] +- Move arguments for AR to its usage to allow replacing ar [Marot] +- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson] +- Improve inflateInit() and inflateInit2() documentation +- Fix structure size comment in inflate.h +- Change configure help option from --h* to --help [Santos] + +Changes in 1.2.3 (18 July 2005) +- Apply security vulnerability fixes to contrib/infback9 as well +- Clean up some text files (carriage returns, trailing space) +- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] + +Changes in 1.2.2.4 (11 July 2005) +- Add inflatePrime() function for starting inflation at bit boundary +- Avoid some Visual C warnings in deflate.c +- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit + compile +- Fix some spelling errors in comments [Betts] +- Correct inflateInit2() error return documentation in zlib.h +- Add zran.c example of compressed data random access to examples + directory, shows use of inflatePrime() +- Fix cast for assignments to strm->state in inflate.c and infback.c +- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] +- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] +- Add cast in trees.c t avoid a warning [Oberhumer] +- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] +- Update make_vms.com [Zinser] +- Initialize state->write in inflateReset() since copied in inflate_fast() +- Be more strict on incomplete code sets in inflate_table() and increase + ENOUGH and MAXD -- this repairs a possible security vulnerability for + invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for + discovering the vulnerability and providing test cases. +- Add ia64 support to configure for HP-UX [Smith] +- Add error return to gzread() for format or i/o error [Levin] +- Use malloc.h for OS/2 [Necasek] + +Changes in 1.2.2.3 (27 May 2005) +- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile +- Typecast fread() return values in gzio.c [Vollant] +- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) +- Fix crc check bug in gzread() after gzungetc() [Heiner] +- Add the deflateTune() function to adjust internal compression parameters +- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) +- Remove an incorrect assertion in examples/zpipe.c +- Add C++ wrapper in infback9.h [Donais] +- Fix bug in inflateCopy() when decoding fixed codes +- Note in zlib.h how much deflateSetDictionary() actually uses +- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) +- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] +- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] +- Add gzdirect() function to indicate transparent reads +- Update contrib/minizip [Vollant] +- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] +- Add casts in crc32.c to avoid warnings [Oberhumer] +- Add contrib/masmx64 [Vollant] +- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] + +Changes in 1.2.2.2 (30 December 2004) +- Replace structure assignments in deflate.c and inflate.c with zmemcpy to + avoid implicit memcpy calls (portability for no-library compilation) +- Increase sprintf() buffer size in gzdopen() to allow for large numbers +- Add INFLATE_STRICT to check distances against zlib header +- Improve WinCE errno handling and comments [Chang] +- Remove comment about no gzip header processing in FAQ +- Add Z_FIXED strategy option to deflateInit2() to force fixed trees +- Add updated make_vms.com [Coghlan], update README +- Create a new "examples" directory, move gzappend.c there, add zpipe.c, + fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. +- Add FAQ entry and comments in deflate.c on uninitialized memory access +- Add Solaris 9 make options in configure [Gilbert] +- Allow strerror() usage in gzio.c for STDC +- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] +- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] +- Use z_off_t for adler32_combine() and crc32_combine() lengths +- Make adler32() much faster for small len +- Use OS_CODE in deflate() default gzip header + +Changes in 1.2.2.1 (31 October 2004) +- Allow inflateSetDictionary() call for raw inflate +- Fix inflate header crc check bug for file names and comments +- Add deflateSetHeader() and gz_header structure for custom gzip headers +- Add inflateGetheader() to retrieve gzip headers +- Add crc32_combine() and adler32_combine() functions +- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list +- Use zstreamp consistently in zlib.h (inflate_back functions) +- Remove GUNZIP condition from definition of inflate_mode in inflate.h + and in contrib/inflate86/inffast.S [Truta, Anderson] +- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] +- Update projects/README.projects and projects/visualc6 [Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] +- Deprecate Z_ASCII; use Z_TEXT instead [Truta] +- Use a new algorithm for setting strm->data_type in trees.c [Truta] +- Do not define an exit() prototype in zutil.c unless DEBUG defined +- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] +- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() +- Fix Darwin build version identification [Peterson] + +Changes in 1.2.2 (3 October 2004) +- Update zlib.h comments on gzip in-memory processing +- Set adler to 1 in inflateReset() to support Java test suite [Walles] +- Add contrib/dotzlib [Ravn] +- Update win32/DLL_FAQ.txt [Truta] +- Update contrib/minizip [Vollant] +- Move contrib/visual-basic.txt to old/ [Truta] +- Fix assembler builds in projects/visualc6/ [Truta] + +Changes in 1.2.1.2 (9 September 2004) +- Update INDEX file +- Fix trees.c to update strm->data_type (no one ever noticed!) +- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] +- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) +- Add limited multitasking protection to DYNAMIC_CRC_TABLE +- Add NO_vsnprintf for VMS in zutil.h [Mozilla] +- Don't declare strerror() under VMS [Mozilla] +- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize +- Update contrib/ada [Anisimkov] +- Update contrib/minizip [Vollant] +- Fix configure to not hardcode directories for Darwin [Peterson] +- Fix gzio.c to not return error on empty files [Brown] +- Fix indentation; update version in contrib/delphi/ZLib.pas and + contrib/pascal/zlibpas.pas [Truta] +- Update mkasm.bat in contrib/masmx86 [Truta] +- Update contrib/untgz [Truta] +- Add projects/README.projects [Truta] +- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] +- Remove an unnecessary assignment to curr in inftrees.c [Truta] +- Add OS/2 to exe builds in configure [Poltorak] +- Remove err dummy parameter in zlib.h [Kientzle] + +Changes in 1.2.1.1 (9 January 2004) +- Update email address in README +- Several FAQ updates +- Fix a big fat bug in inftrees.c that prevented decoding valid + dynamic blocks with only literals and no distance codes -- + Thanks to "Hot Emu" for the bug report and sample file +- Add a note to puff.c on no distance codes case. + +Changes in 1.2.1 (17 November 2003) +- Remove a tab in contrib/gzappend/gzappend.c +- Update some interfaces in contrib for new zlib functions +- Update zlib version number in some contrib entries +- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] +- Support shared libraries on Hurd and KFreeBSD [Brown] +- Fix error in NO_DIVIDE option of adler32.c + +Changes in 1.2.0.8 (4 November 2003) +- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas +- Add experimental NO_DIVIDE #define in adler32.c + - Possibly faster on some processors (let me know if it is) +- Correct Z_BLOCK to not return on first inflate call if no wrap +- Fix strm->data_type on inflate() return to correctly indicate EOB +- Add deflatePrime() function for appending in the middle of a byte +- Add contrib/gzappend for an example of appending to a stream +- Update win32/DLL_FAQ.txt [Truta] +- Delete Turbo C comment in README [Truta] +- Improve some indentation in zconf.h [Truta] +- Fix infinite loop on bad input in configure script [Church] +- Fix gzeof() for concatenated gzip files [Johnson] +- Add example to contrib/visual-basic.txt [Michael B.] +- Add -p to mkdir's in Makefile.in [vda] +- Fix configure to properly detect presence or lack of printf functions +- Add AS400 support [Monnerat] +- Add a little Cygwin support [Wilson] + +Changes in 1.2.0.7 (21 September 2003) +- Correct some debug formats in contrib/infback9 +- Cast a type in a debug statement in trees.c +- Change search and replace delimiter in configure from % to # [Beebe] +- Update contrib/untgz to 0.2 with various fixes [Truta] +- Add build support for Amiga [Nikl] +- Remove some directories in old that have been updated to 1.2 +- Add dylib building for Mac OS X in configure and Makefile.in +- Remove old distribution stuff from Makefile +- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X +- Update links in README + +Changes in 1.2.0.6 (13 September 2003) +- Minor FAQ updates +- Update contrib/minizip to 1.00 [Vollant] +- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] +- Update POSTINC comment for 68060 [Nikl] +- Add contrib/infback9 with deflate64 decoding (unsupported) +- For MVS define NO_vsnprintf and undefine FAR [van Burik] +- Add pragma for fdopen on MVS [van Burik] + +Changes in 1.2.0.5 (8 September 2003) +- Add OF to inflateBackEnd() declaration in zlib.h +- Remember start when using gzdopen in the middle of a file +- Use internal off_t counters in gz* functions to properly handle seeks +- Perform more rigorous check for distance-too-far in inffast.c +- Add Z_BLOCK flush option to return from inflate at block boundary +- Set strm->data_type on return from inflate + - Indicate bits unused, if at block boundary, and if in last block +- Replace size_t with ptrdiff_t in crc32.c, and check for correct size +- Add condition so old NO_DEFLATE define still works for compatibility +- FAQ update regarding the Windows DLL [Truta] +- INDEX update: add qnx entry, remove aix entry [Truta] +- Install zlib.3 into mandir [Wilson] +- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] +- Adapt the zlib interface to the new DLL convention guidelines [Truta] +- Introduce ZLIB_WINAPI macro to allow the export of functions using + the WINAPI calling convention, for Visual Basic [Vollant, Truta] +- Update msdos and win32 scripts and makefiles [Truta] +- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] +- Add contrib/ada [Anisimkov] +- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] +- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] +- Add contrib/masm686 [Truta] +- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm + [Truta, Vollant] +- Update contrib/delphi; rename to contrib/pascal; add example [Truta] +- Remove contrib/delphi2; add a new contrib/delphi [Truta] +- Avoid inclusion of the nonstandard in contrib/iostream, + and fix some method prototypes [Truta] +- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip + [Truta] +- Avoid the use of backslash (\) in contrib/minizip [Vollant] +- Fix file time handling in contrib/untgz; update makefiles [Truta] +- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines + [Vollant] +- Remove contrib/vstudio/vc15_16 [Vollant] +- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] +- Update README.contrib [Truta] +- Invert the assignment order of match_head and s->prev[...] in + INSERT_STRING [Truta] +- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings + [Truta] +- Compare function pointers with 0, not with NULL or Z_NULL [Truta] +- Fix prototype of syncsearch in inflate.c [Truta] +- Introduce ASMINF macro to be enabled when using an ASM implementation + of inflate_fast [Truta] +- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] +- Modify test_gzio in example.c to take a single file name as a + parameter [Truta] +- Exit the example.c program if gzopen fails [Truta] +- Add type casts around strlen in example.c [Truta] +- Remove casting to sizeof in minigzip.c; give a proper type + to the variable compared with SUFFIX_LEN [Truta] +- Update definitions of STDC and STDC99 in zconf.h [Truta] +- Synchronize zconf.h with the new Windows DLL interface [Truta] +- Use SYS16BIT instead of __32BIT__ to distinguish between + 16- and 32-bit platforms [Truta] +- Use far memory allocators in small 16-bit memory models for + Turbo C [Truta] +- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in + zlibCompileFlags [Truta] +- Cygwin has vsnprintf [Wilson] +- In Windows16, OS_CODE is 0, as in MSDOS [Truta] +- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] + +Changes in 1.2.0.4 (10 August 2003) +- Minor FAQ updates +- Be more strict when checking inflateInit2's windowBits parameter +- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well +- Add gzip wrapper option to deflateInit2 using windowBits +- Add updated QNX rule in configure and qnx directory [Bonnefoy] +- Make inflate distance-too-far checks more rigorous +- Clean up FAR usage in inflate +- Add casting to sizeof() in gzio.c and minigzip.c + +Changes in 1.2.0.3 (19 July 2003) +- Fix silly error in gzungetc() implementation [Vollant] +- Update contrib/minizip and contrib/vstudio [Vollant] +- Fix printf format in example.c +- Correct cdecl support in zconf.in.h [Anisimkov] +- Minor FAQ updates + +Changes in 1.2.0.2 (13 July 2003) +- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons +- Attempt to avoid warnings in crc32.c for pointer-int conversion +- Add AIX to configure, remove aix directory [Bakker] +- Add some casts to minigzip.c +- Improve checking after insecure sprintf() or vsprintf() calls +- Remove #elif's from crc32.c +- Change leave label to inf_leave in inflate.c and infback.c to avoid + library conflicts +- Remove inflate gzip decoding by default--only enable gzip decoding by + special request for stricter backward compatibility +- Add zlibCompileFlags() function to return compilation information +- More typecasting in deflate.c to avoid warnings +- Remove leading underscore from _Capital #defines [Truta] +- Fix configure to link shared library when testing +- Add some Windows CE target adjustments [Mai] +- Remove #define ZLIB_DLL in zconf.h [Vollant] +- Add zlib.3 [Rodgers] +- Update RFC URL in deflate.c and algorithm.txt [Mai] +- Add zlib_dll_FAQ.txt to contrib [Truta] +- Add UL to some constants [Truta] +- Update minizip and vstudio [Vollant] +- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h +- Expand use of NO_DUMMY_DECL to avoid all dummy structures +- Added iostream3 to contrib [Schwardt] +- Replace rewind() with fseek() for WinCE [Truta] +- Improve setting of zlib format compression level flags + - Report 0 for huffman and rle strategies and for level == 0 or 1 + - Report 2 only for level == 6 +- Only deal with 64K limit when necessary at compile time [Truta] +- Allow TOO_FAR check to be turned off at compile time [Truta] +- Add gzclearerr() function [Souza] +- Add gzungetc() function + +Changes in 1.2.0.1 (17 March 2003) +- Add Z_RLE strategy for run-length encoding [Truta] + - When Z_RLE requested, restrict matches to distance one + - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE +- Correct FASTEST compilation to allow level == 0 +- Clean up what gets compiled for FASTEST +- Incorporate changes to zconf.in.h [Vollant] + - Refine detection of Turbo C need for dummy returns + - Refine ZLIB_DLL compilation + - Include additional header file on VMS for off_t typedef +- Try to use _vsnprintf where it supplants vsprintf [Vollant] +- Add some casts in inffast.c +- Enchance comments in zlib.h on what happens if gzprintf() tries to + write more than 4095 bytes before compression +- Remove unused state from inflateBackEnd() +- Remove exit(0) from minigzip.c, example.c +- Get rid of all those darn tabs +- Add "check" target to Makefile.in that does the same thing as "test" +- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in +- Update contrib/inflate86 [Anderson] +- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] +- Add msdos and win32 directories with makefiles [Truta] +- More additions and improvements to the FAQ + +Changes in 1.2.0 (9 March 2003) +- New and improved inflate code + - About 20% faster + - Does not allocate 32K window unless and until needed + - Automatically detects and decompresses gzip streams + - Raw inflate no longer needs an extra dummy byte at end + - Added inflateBack functions using a callback interface--even faster + than inflate, useful for file utilities (gzip, zip) + - Added inflateCopy() function to record state for random access on + externally generated deflate streams (e.g. in gzip files) + - More readable code (I hope) +- New and improved crc32() + - About 50% faster, thanks to suggestions from Rodney Brown +- Add deflateBound() and compressBound() functions +- Fix memory leak in deflateInit2() +- Permit setting dictionary for raw deflate (for parallel deflate) +- Fix const declaration for gzwrite() +- Check for some malloc() failures in gzio.c +- Fix bug in gzopen() on single-byte file 0x1f +- Fix bug in gzread() on concatenated file with 0x1f at end of buffer + and next buffer doesn't start with 0x8b +- Fix uncompress() to return Z_DATA_ERROR on truncated input +- Free memory at end of example.c +- Remove MAX #define in trees.c (conflicted with some libraries) +- Fix static const's in deflate.c, gzio.c, and zutil.[ch] +- Declare malloc() and free() in gzio.c if STDC not defined +- Use malloc() instead of calloc() in zutil.c if int big enough +- Define STDC for AIX +- Add aix/ with approach for compiling shared library on AIX +- Add HP-UX support for shared libraries in configure +- Add OpenUNIX support for shared libraries in configure +- Use $cc instead of gcc to build shared library +- Make prefix directory if needed when installing +- Correct Macintosh avoidance of typedef Byte in zconf.h +- Correct Turbo C memory allocation when under Linux +- Use libz.a instead of -lz in Makefile (assure use of compiled library) +- Update configure to check for snprintf or vsnprintf functions and their + return value, warn during make if using an insecure function +- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that + is lost when library is used--resolution is to build new zconf.h +- Documentation improvements (in zlib.h): + - Document raw deflate and inflate + - Update RFCs URL + - Point out that zlib and gzip formats are different + - Note that Z_BUF_ERROR is not fatal + - Document string limit for gzprintf() and possible buffer overflow + - Note requirement on avail_out when flushing + - Note permitted values of flush parameter of inflate() +- Add some FAQs (and even answers) to the FAQ +- Add contrib/inflate86/ for x86 faster inflate +- Add contrib/blast/ for PKWare Data Compression Library decompression +- Add contrib/puff/ simple inflate for deflate format description + +Changes in 1.1.4 (11 March 2002) +- ZFREE was repeated on same allocation on some error conditions. + This creates a security problem described in *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Thu Aug 1 14:58:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 531147AD for ; Thu, 1 Aug 2013 14:58:28 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2633F283F for ; Thu, 1 Aug 2013 14:58:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r71EwRkB045612 for ; Thu, 1 Aug 2013 14:58:27 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r71EwRgV045608 for svn-soc-all@FreeBSD.org; Thu, 1 Aug 2013 14:58:27 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 1 Aug 2013 14:58:27 GMT Message-Id: <201308011458.r71EwRgV045608@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255419 - soc2013/dpl/head/lib/libzcap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 01 Aug 2013 14:58:28 -0000 Author: dpl Date: Thu Aug 1 14:58:27 2013 New Revision: 255419 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255419 Log: Everything's ready to change most of the functions! Added: soc2013/dpl/head/lib/libzcap/commands.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/capsicum.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Thu Aug 1 13:18:47 2013 (r255418) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Thu Aug 1 14:58:27 2013 (r255419) @@ -9,10 +9,11 @@ int sv[2]; int startChild(void); -void waitCommand(void); void killChild(void); +nvlist_t * command(int command, int args, ... ); -int startChild() +int +startChild() { if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) perror("socketpair"); @@ -22,14 +23,18 @@ close(STDIN_FILENO); close(STDERR_FILENO); cap_enter(); - waitCommand(); + /* Exec listener */ + exit(0); } else atexit(killChild); return pid; } -/* Wait for commands, and execute them */ +/* + * Wait for commands, and execute them + * This code really pertains to the listener program + void waitCommand() { @@ -38,27 +43,23 @@ while(1) { while(1){ if ((nvl = nvlist_recv(sv[1])) != NULL) - if (nvlist_exists(nvl, "com")) + if (nvlist_exists(nvl, "command")) if (nvlist_exists(nvl, "args")) break; ; } - /* Switch for "command" */ - /* Get args, and call the real lib */ - switch( nvlist_take_number(nvl, "com")){ - case SUM: + // Switch for "command" + // Get args, and call the real lib. + int com = nvlist_take_number(nvl, "command"); + if (com == SUM) { if ((args = nvlist_take_nvlist(nvl, "args")) == NULL) { perror("CHILD: nvlist_take_nvlist(nvl, 'args')"); break; } - nvlist_add_number(nvl, "result", 0 /* sum_(nvlist_take_number(args, "a")) */); - break; - default: - break; + nvlist_add_number(nvl, "result", 0 ); } - while(1){ if( nvlist_send(sv[1], nvl) == 0 ) break; @@ -68,6 +69,112 @@ } } +*/ + +nvlist_t * +command( int command, int args, ... ) +{ + nvlist_t *nvl, *nvlargs; + va_list ap; + + /* If the child is not executing, do it. */ + /* It _should_ only be tested once. + if (pid == 0) + startChild(); + + if( (nvlargs = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", command); + + va_start(ap, args); + // Set up args, and add it to nvl. + if (command == DEFLATEINIT){ + } else if (command == DEFLATE ) { + } else if (command == DEFLATEEND ) { + } else if (command == INFLATEINIT ) { + } else if (command == INFLATE ) { + } else if (command == INFLATEEND ) { + } else if (command == DEFLATEINIT2 ) { + } else if (command == DEFLATESETDICTIONARY ) { + } else if (command == DEFLATECOPY ) { + } else if (command == DEFLATERESET ) { + } else if (command == DEFLATEPARAMS ) { + } else if (command == DEFLATETUNE ) { + } else if (command == DEFLATEBOUND ) { + } else if (command == DEFLATEPENDING ) { + } else if (command == DEFLATEPRIME ) { + } else if (command == DEFLATESETHEADER ) { + } else if (command == INFLATEINIT2 ) { + } else if (command == INFLATESETDICTIONARY ) { + } else if (command == INFLATEGETDICTIONARY ) { + } else if (command == INFLATESYNC ) { + } else if (command == INFLATECOPY ) { + } else if (command == INFLATERESET ) { + } else if (command == INFLATERESET2 ) { + } else if (command == INFLATEPRIME ) { + } else if (command == INFLATEMARK ) { + } else if (command == INFLATEGETHEADER ) { + } else if (command == INFLATEBACKINIT ) { + } else if (command == INFLATEBACK ) { + } else if (command == INFLATEBACKEND ) { + } else if (command == ZLIBCOMPILEFLAGS ) { + } else if (command == COMPRESS ) { + } else if (command == COMPRESS2 ) { + } else if (command == COMPRESSBOUND ) { + } else if (command == UNCOMPRESS ) { + } else if (command == GZOPEN ) { + } else if (command == GZDOPEN ) { + } else if (command == GZBUFFER ) { + } else if (command == GZSETPARAMS ) { + } else if (command == GZREAD ) { + } else if (command == GZWRITE ) { + } else if (command == GZPRINTF ) { + } else if (command == GZPUTS ) { + } else if (command == GZGETS ) { + } else if (command == GZPUTC ) { + } else if (command == GZGETC ) { + } else if (command == GZUNGETC ) { + } else if (command == GZFLUSH ) { + } else if (command == GZSEEK ) { + } else if (command == GZREWIND ) { + } else if (command == GZTELL ) { + } else if (command == GZOFFSET ) { + } else if (command == GZEOF ) { + } else if (command == GZDIRECT ) { + } else if (command == GZCLOSE ) { + } else if (command == GZCLOSE_R ) { + } else if (command == GZCLOSE_W ) { + } else if (command == GZERROR ) { + } else if (command == GZCLEARERR ) { + } else if (command == ADLER32 ) { + } else if (command == ADLER32_COMBINE ) { + } else if (command == CRC32 ) { + } else if (command == CRC32_COMBINE ) { + } else { return NULL; } + + va_end(ap); + + /* send nvlist*/ + /* What about the whiles? */ + while(1){ + if( nvlist_send(sv[0], nvl) == 0 ) + break; + ; + } + + /* recv results */ + while(1){ + if ((nvl = nvlist_recv(sv[0])) != NULL) + if (nvlist_exists(nvl, "result")) + break; + ; + } + return (nvl); +} + void killChild(){ kill(pid, SIGKILL); } Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Thu Aug 1 13:18:47 2013 (r255418) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Thu Aug 1 14:58:27 2013 (r255419) @@ -1,17 +1,15 @@ /* * With Capsicum, we get a compartmentalized, and securer lib. */ -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# include -# include -# include -# include -# include -# include -# include -# endif +#if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# include +# include +# include +# include +# include +# include +# include +# include "commands.h" #endif Added: soc2013/dpl/head/lib/libzcap/commands.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libzcap/commands.h Thu Aug 1 14:58:27 2013 (r255419) @@ -0,0 +1,155 @@ +/* + This is a list of all the capsizumized zlib interfaces. + Every one of the capsicumized functions will have a define. + This list is taken from zlib.h, in this same directory. + + All this defines represent the commands passed to the real + zlib listening through a program, and it will recognize them. + Also, the defines have been checked for not being duplicates. + + // basic functions + zlibVersion // Not capsicumized + deflateInit + deflate + deflateEnd + inflateInit + inflate + inflateEnd + + // Advanced functions + deflateInit2 + deflateSetDictionary + deflateCopy + deflateReset + deflateParams + deflateTune + deflateBound + deflatePending + deflatePrime + deflateSetHeader + inflateInit2 + inflateSetDictionary + inflateGetDictionary + inflateSync + inflateCopy + inflateReset + inflateReset2 + inflatePrime + inflateMark + inflateGetHeader + inflateBackInit + inflateBack + inflateBackEnd + zlibCompileFlags + + // utility functions + compress + compress2 + compressBound + uncompress + + // gzip file access functions + gzopen + gzdopen + gzbuffer + gzsetparams + gzread + gzwrite + gzprintf + gzputs + gzgets + gzputc + gzgetc + gzungetc + gzflush + gzseek + gzrewind + gztell + gzoffset + gzeof + gzdirect + gzclose + gzclose_r + gzclose_w + gzerror + gzclearerr + + // checksum functions + adler32 + adler32_combine + crc32 + crc32_combine +*/ + + +/* basic functions */ +#define DEFLATEINIT 0 +#define DEFLATE 1 +#define DEFLATEEND 2 +#define INFLATEINIT 3 +#define INFLATE 4 +#define INFLATEEND 5 + +/* Advanced functions */ +#define DEFLATEINIT2 +#define DEFLATESETDICTIONARY 6 +#define DEFLATECOPY 7 +#define DEFLATERESET 8 +#define DEFLATEPARAMS 9 +#define DEFLATETUNE 10 +#define DEFLATEBOUND 11 +#define DEFLATEPENDING 12 +#define DEFLATEPRIME 13 +#define DEFLATESETHEADER 14 +#define INFLATEINIT2 15 +#define INFLATESETDICTIONARY 16 +#define INFLATEGETDICTIONARY 17 +#define INFLATESYNC 18 +#define INFLATECOPY 19 +#define INFLATERESET 20 +#define INFLATERESET2 21 +#define INFLATEPRIME 22 +#define INFLATEMARK 23 +#define INFLATEGETHEADER 24 +#define INFLATEBACKINIT 25 +#define INFLATEBACK 26 +#define INFLATEBACKEND 27 +#define ZLIBCOMPILEFLAGS 28 + +/* utility functions */ +#define COMPRESS 29 +#define COMPRESS2 30 +#define COMPRESSBOUND 31 +#define UNCOMPRESS 32 + +/* gzip file access functions */ +#define GZOPEN 33 +#define GZDOPEN 34 +#define GZBUFFER 35 +#define GZSETPARAMS 36 +#define GZREAD 37 +#define GZWRITE 38 +#define GZPRINTF 39 +#define GZPUTS 40 +#define GZGETS 50 +#define GZPUTC 51 +#define GZGETC 52 +#define GZUNGETC 53 +#define GZFLUSH 54 +#define GZSEEK 55 +#define GZREWIND 56 +#define GZTELL 57 +#define GZOFFSET 58 +#define GZEOF 59 +#define GZDIRECT 60 +#define GZCLOSE 61 +#define GZCLOSE_R 62 +#define GZCLOSE_W 63 +#define GZERROR 64 +#define GZCLEARERR 65 + +/* checksum functions */ +#define ADLER32 66 +#define ADLER32_COMBINE 67 +#define CRC32 68 +#define CRC32_COMBINE 69 From owner-svn-soc-all@FreeBSD.ORG Thu Aug 1 19:54:43 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C3EB715B for ; Thu, 1 Aug 2013 19:54:43 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A239627B4 for ; Thu, 1 Aug 2013 19:54:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r71JshRO087153 for ; Thu, 1 Aug 2013 19:54:43 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r71JshGj087137 for svn-soc-all@FreeBSD.org; Thu, 1 Aug 2013 19:54:43 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 1 Aug 2013 19:54:43 GMT Message-Id: <201308011954.r71JshGj087137@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255422 - soc2013/dpl/head/lib/libzcap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 01 Aug 2013 19:54:43 -0000 Author: dpl Date: Thu Aug 1 19:54:43 2013 New Revision: 255422 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255422 Log: Written some first functions to send commands to a secure zlib client. deflateInit, deflate and deflateEnd. Added: soc2013/dpl/head/lib/libzcap/commands.c Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/commands.h soc2013/dpl/head/lib/libzcap/deflate.c Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Thu Aug 1 18:06:58 2013 (r255421) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Thu Aug 1 19:54:43 2013 (r255422) @@ -72,93 +72,8 @@ */ nvlist_t * -command( int command, int args, ... ) +sendCommand( nvlist_t *nvl) { - nvlist_t *nvl, *nvlargs; - va_list ap; - - /* If the child is not executing, do it. */ - /* It _should_ only be tested once. - if (pid == 0) - startChild(); - - if( (nvlargs = nvlist_create(0)) == NULL || - (nvl = nvlist_create(0)) == NULL ) { - perror("nvlist_create"); - return (NULL); - } - nvlist_add_number(nvl, "command", command); - - va_start(ap, args); - // Set up args, and add it to nvl. - if (command == DEFLATEINIT){ - } else if (command == DEFLATE ) { - } else if (command == DEFLATEEND ) { - } else if (command == INFLATEINIT ) { - } else if (command == INFLATE ) { - } else if (command == INFLATEEND ) { - } else if (command == DEFLATEINIT2 ) { - } else if (command == DEFLATESETDICTIONARY ) { - } else if (command == DEFLATECOPY ) { - } else if (command == DEFLATERESET ) { - } else if (command == DEFLATEPARAMS ) { - } else if (command == DEFLATETUNE ) { - } else if (command == DEFLATEBOUND ) { - } else if (command == DEFLATEPENDING ) { - } else if (command == DEFLATEPRIME ) { - } else if (command == DEFLATESETHEADER ) { - } else if (command == INFLATEINIT2 ) { - } else if (command == INFLATESETDICTIONARY ) { - } else if (command == INFLATEGETDICTIONARY ) { - } else if (command == INFLATESYNC ) { - } else if (command == INFLATECOPY ) { - } else if (command == INFLATERESET ) { - } else if (command == INFLATERESET2 ) { - } else if (command == INFLATEPRIME ) { - } else if (command == INFLATEMARK ) { - } else if (command == INFLATEGETHEADER ) { - } else if (command == INFLATEBACKINIT ) { - } else if (command == INFLATEBACK ) { - } else if (command == INFLATEBACKEND ) { - } else if (command == ZLIBCOMPILEFLAGS ) { - } else if (command == COMPRESS ) { - } else if (command == COMPRESS2 ) { - } else if (command == COMPRESSBOUND ) { - } else if (command == UNCOMPRESS ) { - } else if (command == GZOPEN ) { - } else if (command == GZDOPEN ) { - } else if (command == GZBUFFER ) { - } else if (command == GZSETPARAMS ) { - } else if (command == GZREAD ) { - } else if (command == GZWRITE ) { - } else if (command == GZPRINTF ) { - } else if (command == GZPUTS ) { - } else if (command == GZGETS ) { - } else if (command == GZPUTC ) { - } else if (command == GZGETC ) { - } else if (command == GZUNGETC ) { - } else if (command == GZFLUSH ) { - } else if (command == GZSEEK ) { - } else if (command == GZREWIND ) { - } else if (command == GZTELL ) { - } else if (command == GZOFFSET ) { - } else if (command == GZEOF ) { - } else if (command == GZDIRECT ) { - } else if (command == GZCLOSE ) { - } else if (command == GZCLOSE_R ) { - } else if (command == GZCLOSE_W ) { - } else if (command == GZERROR ) { - } else if (command == GZCLEARERR ) { - } else if (command == ADLER32 ) { - } else if (command == ADLER32_COMBINE ) { - } else if (command == CRC32 ) { - } else if (command == CRC32_COMBINE ) { - } else { return NULL; } - - va_end(ap); - - /* send nvlist*/ - /* What about the whiles? */ while(1){ if( nvlist_send(sv[0], nvl) == 0 ) break; Added: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libzcap/commands.c Thu Aug 1 19:54:43 2013 (r255422) @@ -0,0 +1,194 @@ +/* + This is just a template of the capsicumized functions. + +nvlist_t * +zcapcmd_command( args ) +{ + nvlist_t *nvl, *args, *results; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZCAPCMD_); + + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + +} + +*/ + +extern pid; + + +/* basic functions */ +nvlist_t * +zcapcmd_deflateInit( z_streamp strm, int level,int method, int windowBits, + int strategy, const char *version, int stream_size ) +{ + nvlist_t *nvl, *args, *results; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZCAPCMD_DEFLATEINIT); + + nvlist_add_binary(args, "strm", strm, sizeof(z_streamp)); + nvlist_add_number(args, "level", level); + nvlist_add_number(args, "method", method); + nvlist_add_number(args, "windowBits", windowBits); + nvlist_add_string(args, "version", version); + nvlist_add_number(args, "stream_size", stream_size); + nvlist_add_nvlist(nvl, "args", args); + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + int result = nvlist_take_number(nvlresults, "result"); + nvlist_delete(nvlresults); +} + +int +zcapcmd_deflate( z_streamp strm, int flush ) +{ + nvlist_t *nvl, *args, *results; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZCAPCMD_); + + nvlist_add_binary(args, "strm", strm, sizeof(z_streamp)); + nvlist_add_number(args, "flush", flush); + nvlist_add_nvlist(nvl, "args", args); + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + int result = nvlist_take_number(nvlresults, "result"); + nvlist_delete(nvlresults); +} + +nvlist_t * +zcapcmd_deflateEnd(z_streamp strm) +{ + nvlist_t *nvl, *args, *nvlresults; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZLIBCMD_VAR); + + nvlist_add_binary(args, "strm", strm, sizeof(z_streamp)); + nvlist_add_nvlist(nvl, "args", args); + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + int result = nvlist_take_number(nvlresults, "result"); + nvlist_delete(nvlresults); + + return( result); +} + +nvlist_t * +zcapcmd_inflateInit( args ) +{ + nvlist_t *nvl, *args, *results; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZLIBCMD_VAR); + + /* set args */ + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + /* Get result */ +} + +nvlist_t * +zcapcmd_inflate( args ) +{ + nvlist_t *nvl, *args, *results; + + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZLIBCMD_VAR); + + /* set args */ + + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + /* Get result */ +} + +nvlist_t * +zcapcmd_inflateEnd( args ) +{ + nvlist_t *nvl, *args, *results; + + /* If the child is not executing, do it. */ + /* It _should_ only be tested once. + if (pid == 0) + startChild(); + + if( (args = nvlist_create(0)) == NULL || + (nvl = nvlist_create(0)) == NULL ) { + perror("nvlist_create"); + return (NULL); + } + nvlist_add_number(nvl, "command", ZLIBCMD_VAR); + + /* set args */ + + + results = sendCommand(nvl); + nvlist_destroy(args); + nvlist_destroy(nvl); + + /* Get result */ +} + Modified: soc2013/dpl/head/lib/libzcap/commands.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.h Thu Aug 1 18:06:58 2013 (r255421) +++ soc2013/dpl/head/lib/libzcap/commands.h Thu Aug 1 19:54:43 2013 (r255422) @@ -43,9 +43,9 @@ zlibCompileFlags // utility functions - compress - compress2 - compressBound + compress + compress2 + compressBound uncompress // gzip file access functions @@ -83,73 +83,72 @@ /* basic functions */ -#define DEFLATEINIT 0 -#define DEFLATE 1 -#define DEFLATEEND 2 -#define INFLATEINIT 3 -#define INFLATE 4 -#define INFLATEEND 5 +#define ZCAPCMD_DEFLATEINIT 0 +#define ZCAPCMD_DEFLATE 1 +#define ZCAPCMD_DEFLATEEND 2 +#define ZCAPCMD_INFLATEINIT 3 +#define ZCAPCMD_INFLATE 4 +#define ZCAPCMD_INFLATEEND 5 /* Advanced functions */ -#define DEFLATEINIT2 -#define DEFLATESETDICTIONARY 6 -#define DEFLATECOPY 7 -#define DEFLATERESET 8 -#define DEFLATEPARAMS 9 -#define DEFLATETUNE 10 -#define DEFLATEBOUND 11 -#define DEFLATEPENDING 12 -#define DEFLATEPRIME 13 -#define DEFLATESETHEADER 14 -#define INFLATEINIT2 15 -#define INFLATESETDICTIONARY 16 -#define INFLATEGETDICTIONARY 17 -#define INFLATESYNC 18 -#define INFLATECOPY 19 -#define INFLATERESET 20 -#define INFLATERESET2 21 -#define INFLATEPRIME 22 -#define INFLATEMARK 23 -#define INFLATEGETHEADER 24 -#define INFLATEBACKINIT 25 -#define INFLATEBACK 26 -#define INFLATEBACKEND 27 -#define ZLIBCOMPILEFLAGS 28 +#define ZCAPCMD_DEFLATESETDICTIONARY 6 +#define ZCAPCMD_DEFLATECOPY 7 +#define ZCAPCMD_DEFLATERESET 8 +#define ZCAPCMD_DEFLATEPARAMS 9 +#define ZCAPCMD_DEFLATETUNE 10 +#define ZCAPCMD_DEFLATEBOUND 11 +#define ZCAPCMD_DEFLATEPENDING 12 +#define ZCAPCMD_DEFLATEPRIME 13 +#define ZCAPCMD_DEFLATESETHEADER 14 +#define ZCAPCMD_INFLATEINIT2 15 +#define ZCAPCMD_INFLATESETDICTIONARY 16 +#define ZCAPCMD_INFLATEGETDICTIONARY 17 +#define ZCAPCMD_INFLATESYNC 18 +#define ZCAPCMD_INFLATECOPY 19 +#define ZCAPCMD_INFLATERESET 20 +#define ZCAPCMD_INFLATERESET2 21 +#define ZCAPCMD_INFLATEPRIME 22 +#define ZCAPCMD_INFLATEMARK 23 +#define ZCAPCMD_INFLATEGETHEADER 24 +#define ZCAPCMD_INFLATEBACKINIT 25 +#define ZCAPCMD_INFLATEBACK 26 +#define ZCAPCMD_INFLATEBACKEND 27 +#define ZCAPCMD_ZLIBCOMPILEFLAGS 28 /* utility functions */ -#define COMPRESS 29 -#define COMPRESS2 30 -#define COMPRESSBOUND 31 -#define UNCOMPRESS 32 +#define ZCAPCMD_COMPRESS 29 +#define ZCAPCMD_COMPRESS2 30 +#define ZCAPCMD_COMPRESSBOUND 31 +#define ZCAPCMD_UNCOMPRESS 32 /* gzip file access functions */ -#define GZOPEN 33 -#define GZDOPEN 34 -#define GZBUFFER 35 -#define GZSETPARAMS 36 -#define GZREAD 37 -#define GZWRITE 38 -#define GZPRINTF 39 -#define GZPUTS 40 -#define GZGETS 50 -#define GZPUTC 51 -#define GZGETC 52 -#define GZUNGETC 53 -#define GZFLUSH 54 -#define GZSEEK 55 -#define GZREWIND 56 -#define GZTELL 57 -#define GZOFFSET 58 -#define GZEOF 59 -#define GZDIRECT 60 -#define GZCLOSE 61 -#define GZCLOSE_R 62 -#define GZCLOSE_W 63 -#define GZERROR 64 -#define GZCLEARERR 65 +#define ZCAPCMD_GZOPEN 33 +#define ZCAPCMD_GZDOPEN 34 +#define ZCAPCMD_GZBUFFER 35 +#define ZCAPCMD_GZSETPARAMS 36 +#define ZCAPCMD_GZREAD 37 +#define ZCAPCMD_GZWRITE 38 +#define ZCAPCMD_GZPRINTF 39 +#define ZCAPCMD_GZPUTS 40 +#define ZCAPCMD_GZGETS 50 +#define ZCAPCMD_GZPUTC 51 +#define ZCAPCMD_GZGETC 52 +#define ZCAPCMD_GZUNGETC 53 +#define ZCAPCMD_GZFLUSH 54 +#define ZCAPCMD_GZSEEK 55 +#define ZCAPCMD_GZREWIND 56 +#define ZCAPCMD_GZTELL 57 +#define ZCAPCMD_GZOFFSET 58 +#define ZCAPCMD_GZEOF 59 +#define ZCAPCMD_GZDIRECT 60 +#define ZCAPCMD_GZCLOSE 61 +#define ZCAPCMD_GZCLOSE_R 62 +#define ZCAPCMD_GZCLOSE_W 63 +#define ZCAPCMD_GZERROR 64 +#define ZCAPCMD_GZCLEARERR 65 /* checksum functions */ -#define ADLER32 66 -#define ADLER32_COMBINE 67 -#define CRC32 68 -#define CRC32_COMBINE 69 +#define ZCAPCMD_ADLER32 66 +#define ZCAPCMD_ADLER32_COMBINE 67 +#define ZCAPCMD_CRC32 68 +#define ZCAPCMD_CRC32_COMBINE 69 Modified: soc2013/dpl/head/lib/libzcap/deflate.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/deflate.c Thu Aug 1 18:06:58 2013 (r255421) +++ soc2013/dpl/head/lib/libzcap/deflate.c Thu Aug 1 19:54:43 2013 (r255422) @@ -221,102 +221,8 @@ const char *version; int stream_size; { - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->high_water = 0; /* nothing written to s->window yet */ - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); + return zcapcmd_deflateInit(strm, level, method, windowBits, + memLevel, strategy, version, stream_size); } /* ========================================================================= */ @@ -666,344 +572,14 @@ z_streamp strm; int flush; { - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_BLOCK || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - (s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush)); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - if (s->lookahead == 0) { - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; + return zcapcmd_deflate(strm, flush); } /* ========================================================================= */ int ZEXPORT deflateEnd (strm) z_streamp strm; { - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; + return zcapcmd_deflateEnd(strm); } /* ========================================================================= From owner-svn-soc-all@FreeBSD.ORG Thu Aug 1 20:14:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 508A654C for ; Thu, 1 Aug 2013 20:14:57 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3992828A8 for ; Thu, 1 Aug 2013 20:14:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r71KEvpc099731 for ; Thu, 1 Aug 2013 20:14:57 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r71KEv04099717 for svn-soc-all@FreeBSD.org; Thu, 1 Aug 2013 20:14:57 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 1 Aug 2013 20:14:57 GMT Message-Id: <201308012014.r71KEv04099717@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255425 - in soc2013/jmuniz: . KPackageKit/KPackageKit-0.6.3.3/kpackagekit KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files PackageKit-Setter PackageKit-qt4/PackageKit-qt4-0.6.11/pa... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 01 Aug 2013 20:14:57 -0000 Author: jmuniz Date: Thu Aug 1 20:14:56 2013 New Revision: 255425 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255425 Log: Flood of commits Added: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/ soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-AddRmKCM.ui soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-BrowseView.ui soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-Updater-UpdateKCM.ui soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/Makefile.am soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/default-dialog soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_backend.rb soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_prints.rb soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports_pk-backend-ports.c soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-data_pk-upgrade-distro.sh soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-etc_Vendor.conf soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-src_pk-lsof.c soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-src_plugins_pk-lsof.c soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-src_plugins_pk-self-test.c soc2013/jmuniz/Patch_Overlays/ soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/ soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/AddRm/ soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/AddRm/AddRmKCM.ui (contents, props changed) soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/AddRm/BrowseView.ui (contents, props changed) soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/Updater/ soc2013/jmuniz/Patch_Overlays/KPackageKit-0.6.3.3/Updater/UpdateKCM.ui (contents, props changed) soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/Makefile.in soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/Makefile.in soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/pk-backend-pkgng.c soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/pkgngBackend.rb (contents, props changed) soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ruby_packagekit/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ruby_packagekit/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ruby_packagekit/Makefile.in soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ruby_packagekit/enums.rb soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/pkgng/ruby_packagekit/prints.rb soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/ports/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/ports/pk-backend-ports.c soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/backends/ports/portsBackend.rb (contents, props changed) soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/configure (contents, props changed) soc2013/jmuniz/Patch_Overlays/PackageKit-0.6.11/configure.ac soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/.deps/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/.deps/libpk_backend_ports_la-pk-backend-ports.Plo soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/Makefile soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/Makefile.in soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/helpers/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/helpers/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/helpers/default-dialog soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/pk-backend-ports.c soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/portsBackend.rb (contents, props changed) soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/ soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/Makefile soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/Makefile.am soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/Makefile.in soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/backend.rb soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/enums.rb soc2013/jmuniz/Patch_Overlays/PackageKit-0.8.9/backends/ports/ruby_packagekit/prints.rb soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/ soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/data/ soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/data/gpk-application.ui (contents, props changed) soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/data/gpk-update-viewer.ui (contents, props changed) soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/src/ soc2013/jmuniz/Patch_Overlays/gnome-packagekit-2.32.0/src/gpk-application.c soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-data_gpk-application.ui soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/files/patch-data_gpk-update-viewer.ui Modified: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/Makefile soc2013/jmuniz/PackageKit-Setter/pk-setter soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/Makefile soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/pkg-descr soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/pkg-plist soc2013/jmuniz/TODO soc2013/jmuniz/gnome-packagekit/gnome-packagekit-2.32.0/gnome-packagekit/Makefile Modified: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/Makefile ============================================================================== --- soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/Makefile Thu Aug 1 19:37:11 2013 (r255424) +++ soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/Makefile Thu Aug 1 20:14:56 2013 (r255425) @@ -15,7 +15,6 @@ COMMENT= KDE interface for PackageKit LICENSE= GPLv2 -LICENSE_FILE= ${WRKSRC}/COPYING LIB_DEPENDS= packagekit-qt.14:${PORTSDIR}/ports-mgmt/packagekit-qt4 Added: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-AddRmKCM.ui ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-AddRmKCM.ui Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,71 @@ +--- AddRm/AddRmKCM.ui 2011-01-03 12:58:18.000000000 -0500 ++++ AddRM/AddRmKCM.ui 2013-08-01 02:30:03.000000000 -0400 +@@ -6,8 +6,8 @@ + + 0 + 0 +- 411 +- 322 ++ 433 ++ 320 + + + +@@ -29,6 +29,18 @@ + + 0 + ++ ++ ++ ++ false ++ ++ ++ ++ 1 ++ ++ ++ ++ + + + +@@ -56,7 +68,7 @@ + + + +- ++ + Search packages + + +@@ -129,8 +141,11 @@ + + + +- ++ + ++ ++ 2 ++ + + + +@@ -198,6 +213,16 @@ + + + ++ ++ ++ ++ Select Target System(s) ++ ++ ++ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter ++ ++ ++ + + + Added: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-BrowseView.ui ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-AddRm-BrowseView.ui Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,264 @@ +--- AddRm/BrowseView.ui 2011-01-03 12:58:18.000000000 -0500 ++++ AddRM/BrowseView.ui 2013-08-01 02:23:58.000000000 -0400 +@@ -6,8 +6,8 @@ + + 0 + 0 +- 442 +- 328 ++ 580 ++ 326 + + + +@@ -17,7 +17,140 @@ + + 0 + +- ++ ++ ++ ++ Qt::CustomContextMenu ++ ++ ++ QAbstractItemView::NoEditTriggers ++ ++ ++ true ++ ++ ++ ++ 40 ++ 24 ++ ++ ++ ++ QAbstractItemView::ScrollPerPixel ++ ++ ++ false ++ ++ ++ false ++ ++ ++ false ++ ++ ++ false ++ ++ ++ ++ ++ ++ ++ Qt::LeftToRight ++ ++ ++ Select Target System(s) ++ ++ ++ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter ++ ++ ++ ++ ++ ++ ++ ++ 0 ++ ++ ++ 0 ++ ++ ++ ++ ++ false ++ ++ ++ Export Installed Package List... ++ ++ ++ true ++ ++ ++ ++ ++ ++ ++ Install Packages from List... ++ ++ ++ true ++ ++ ++ ++ ++ ++ ++ Qt::Horizontal ++ ++ ++ ++ 20 ++ 20 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ 16777215 ++ 0 ++ ++ ++ ++ ++ ++ ++ ++ Qt::CustomContextMenu ++ ++ ++ QAbstractItemView::NoEditTriggers ++ ++ ++ ++ 20 ++ 20 ++ ++ ++ ++ QAbstractItemView::ScrollPerPixel ++ ++ ++ false ++ ++ ++ true ++ ++ ++ false ++ ++ ++ ++ + + + QFrame::HLine +@@ -111,6 +244,9 @@ + 16777215 + + ++ ++ Qt::LeftToRight ++ + + true + +@@ -122,98 +258,6 @@ + + + +- +- +- +- +- 0 +- +- +- 0 +- +- +- +- +- false +- +- +- Export Installed Package List... +- +- +- true +- +- +- +- +- +- +- Install Packages from List... +- +- +- true +- +- +- +- +- +- +- Qt::Horizontal +- +- +- +- 20 +- 20 +- +- +- +- +- +- +- +- +- +- +- Qt::CustomContextMenu +- +- +- QAbstractItemView::NoEditTriggers +- +- +- true +- +- +- +- 40 +- 24 +- +- +- +- QAbstractItemView::ScrollPerPixel +- +- +- false +- +- +- false +- +- +- false +- +- +- false +- +- +- +- +- +- +- +- 16777215 +- 0 +- +- +- +- + + + Added: soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-Updater-UpdateKCM.ui ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/KPackageKit/KPackageKit-0.6.3.3/kpackagekit/files/patch-Updater-UpdateKCM.ui Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,95 @@ +--- Updater/UpdateKCM.ui 2011-01-03 12:58:18.000000000 -0500 ++++ Updater/UpdateKCM.ui 2013-08-01 02:33:58.000000000 -0400 +@@ -6,8 +6,8 @@ + + 0 + 0 +- 454 +- 449 ++ 469 ++ 447 + + + +@@ -82,8 +82,8 @@ + + 0 + 0 +- 448 +- 94 ++ 227 ++ 96 + + + +@@ -97,16 +97,6 @@ + + + +- +- +- +- +- 16777215 +- 0 +- +- +- +- + + + +@@ -130,6 +120,53 @@ + + + ++ ++ ++ ++ ++ 16777215 ++ 0 ++ ++ ++ ++ ++ ++ ++ ++ ++ 0 ++ 0 ++ ++ ++ ++ ++ 20 ++ 20 ++ ++ ++ ++ false ++ ++ ++ false ++ ++ ++ ++ 1 ++ ++ ++ ++ ++ ++ ++ ++ Select Target Systems(s) ++ ++ ++ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter ++ ++ ++ + + + Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Aug 1 19:37:11 2013 (r255424) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Aug 1 20:14:56 2013 (r255425) @@ -116,7 +116,8 @@ printUsage() { # Print the instructions to the user in an easily readable way echo "pk-setter is used to select the PackageKit backend" - echo "usage: pk-setter list [prefix]" + echo "usage: pk-setter status [prefix]" + echo " pk-setter list [prefix]" echo " pk-setter set [backend] [prefix]" echo "note: prefix is optional and defaults to \"/usr/local/\"," echo " and refers to the installation prefix of PackageKit" @@ -125,13 +126,26 @@ # End printUsage } +# Notify the user of the current default back end, then exit +showStatus() { + if [ "$1" == "status" ]; then + # Load the variables from the configuration file; ignore errors, not a well-formed file + . ${PK_PREFIX}etc/PackageKit/PackageKit.conf 2>/dev/null + # Notify the user of the current default back end by printing the DefaultBackend variable + echo "PackageKit is currently using the $DefaultBackend back end" + fi +# End showStatus +} + # Beginning of execution # Make sure there is an appropriate number of arguments if [ $# -eq 1 -o $# -eq 2 -o $# -eq 3 ]; then - if [ "$1" == "list" -o "$1" == "set" ]; then + if [ "$1" == "list" -o "$1" == "set" -o "$1" == "status" ]; then # Determine if there is a user defined prefix, save the prefix for later setPrefix $* + # List the current default back end if that is the action to do + showStatus $* # If the user wants a list of backends then print it listBackends $* # Change the current backend if the user wants to Modified: soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile Thu Aug 1 19:37:11 2013 (r255424) +++ soc2013/jmuniz/PackageKit-qt4/PackageKit-qt4-0.6.11/packagekit-qt4/Makefile Thu Aug 1 20:14:56 2013 (r255425) @@ -11,6 +11,8 @@ COMMENT= Qt4 bindings to packagekit +LICENSE= GPLv2 + MASTERDIR= ${.CURDIR}/../../ports-mgmt/packagekit BUILD_WRKSRC= ${WRKSRC}/lib/packagekit-qt INSTALL_WRKSRC= ${WRKSRC}/lib/packagekit-qt Modified: soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Thu Aug 1 19:37:11 2013 (r255424) +++ soc2013/jmuniz/PackageKit/PackageKit-0.6.11/packagekit/Makefile Thu Aug 1 20:14:56 2013 (r255425) @@ -11,14 +11,14 @@ MAINTAINER= gnome@FreeBSD.org COMMENT= DBUS packaging abstraction layer +LICENSE= GPLv2 + BUILD_DEPENDS= ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ ${LOCALBASE}/bin/sgmlspl:${PORTSDIR}/textproc/p5-SGMLSpm/pkg-plist LIB_DEPENDS= execinfo:${PORTSDIR}/devel/libexecinfo \ dbus-glib-1:${PORTSDIR}/devel/dbus-glib \ polkit-gobject-1:${PORTSDIR}/sysutils/polkit \ - ck-connector:${PORTSDIR}/sysutils/consolekit \ - libffi:${PORTSDIR}/devel/libffi \ - Expat:${PORTSDIR}/textproc/p5-XML-Parser + ck-connector:${PORTSDIR}/sysutils/consolekit RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof \ ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ ${LOCALBASE}/share/mime/magic:${PORTSDIR}/misc/shared-mime-info @@ -42,13 +42,10 @@ MAKE_ARGS= pkgconfigdir="${PREFIX}/libdata/pkgconfig" -MAKE_JOBS_UNSAFE=yes - - -.if !defined(${SLAVEPORT}) +.if !defined(SLAVEPORT) OPTIONS_DEFINE= DOCS OPTIONS_SINGLE= BACKEND -OPTIONS_SINGLE_BAKCEND= PORTS PKGNG DUMMY +OPTIONS_SINGLE_BACKEND= PORTS PKGNG DUMMY OPTIONS_DEFAULT=PORTS PORTS_DESC= Ruby back end for traditional or new binary packages PKGNG_DESC= C back end for PGN Next Generation, specifically @@ -96,7 +93,7 @@ PLIST_SUB+= GTK="@comment " CONFIGURE_ARGS+=--disable-qt -.elif defined(${SLAVEPORT}) && ${SLAVEPORT}=="qt4" +.elif defined(SLAVEPORT) && ${SLAVEPORT}=="qt4" LIB_DEPENDS+= packagekit-glib2:${PORTSDIR}/ports-mgmt/packagekit CONFIGURE_ARGS+=--enable-qt LIB_DEPENDS+= cppunit-1.12:${PORTSDIR}/devel/cppunit @@ -104,8 +101,8 @@ #.include "${PORTSDIR}/Mk/bsd.qt.mk" .endif -post-fetch: -.if defined(${SLAVEPORT}) && ${SLAVEPORT}=="qt4" +post-extract: +.if defined(SLAVEPORT) && ${SLAVEPORT}=="qt4" (cd ${WRKSRC}/lib/packagekit-qt/src && \ moc-qt4 ./client.h -o ./client.moc && \ moc-qt4 ./clientprivate.h -o ./clientprivate.moc && \ @@ -127,7 +124,7 @@ '/xsltproc/s|.xsl [$$]? &> /dev|.xsl $$? > /dev|g' post-install: -.if !defined(${SLAVEPORT}) +.if !defined(SLAVEPORT) @${INSTALL_DATA} ${WRKSRC}/data/transactions.db \ ${PREFIX}/share/PackageKit/transactions.db @-update-mime-database ${PREFIX}/share/mime > /dev/null Modified: soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/Makefile Thu Aug 1 19:37:11 2013 (r255424) +++ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/Makefile Thu Aug 1 20:14:56 2013 (r255425) @@ -1,69 +1,78 @@ # Created by: Anders F Bjorklund +# $FreeBSD: ports-mgmt/packagekit/Makefile 316683 2013-04-27 18:25:24Z mva $ +# $MCom: ports/trunk/ports-mgmt/packagekit/Makefile 17268 2013-04-01 05:13:11Z marcus $ -# $FreeBSD$ - -PORTNAME= PackageKit +PORTNAME= packagekit PORTVERSION= 0.8.9 -#PORTREVISION= 0 CATEGORIES= ports-mgmt sysutils MASTER_SITES= http://www.packagekit.org/releases/ -EXTRACT_SUFX= .tar.xz +DISTNAME= PackageKit-${PORTVERSION} -MAINTAINER= jmuniz@FreeBSD.org +MAINTAINER= gnome@FreeBSD.org COMMENT= DBUS packaging abstraction layer -BUILD_DEPENDS= intltool>=0.35.0:{PORTSDIR}/textproc/intltool \ - glib>=2.14.0:{PORTSDIR}/devel/glib \ - dbus>=1.1.3:{PORTSDIR}/devel/dbus \ - dbus-glib>=0.74.0:{PORTSDIR}/devel/dbus-glib \ - polkit>=0.9:{PORTSDIR}/sysutils/polkit +LICENSE= GPLv2 + +BUILD_DEPENDS= ${LOCALBASE}/bin/docbook2man:${PORTSDIR}/textproc/docbook-utils \ + g-ir-scanner:${PORTSDIR}/devel/gobject-introspection LIB_DEPENDS= execinfo:${PORTSDIR}/devel/libexecinfo \ - dbus-glib-1:${PORTSDIR}/devel/dbus-glib \ - polkit-gobject-1:${PORTSDIR}/sysutils/polkit \ - ck-connector:${PORTSDIR}/sysutils/consolekit -RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof \ - ${LOCALBASE}/share/gir-1.0/GLib-2.0.gir:${PORTSDIR}/devel/gobject-introspection \ - ${LOCALBASE}/share/mime/magic:${PORTSDIR}/misc/shared-mime-info + polkit-gobject-1.0:${PORTSDIR}/sysutils/polkit +RUN_DEPENDS= lsof:${PORTSDIR}/sysutils/lsof USE_GMAKE= yes -USES= gettext -USE_PYTHON_BUILD= 2.5+ +USE_XZ= yes +USES= gettext iconv pathfix shared-mime-info +USE_GNOME= glib20 intltool +USE_LDCONFIG= yes +USE_SQLITE= 3 +USE_PYTHON= -2.7 GNU_CONFIGURE= yes CPPFLAGS+= -I${LOCALBASE}/include -CONFIGURE_ARGS+= --with-security-framework=polkit \ - --localstatedir=/var \ - --disable-maintainer-mode \ - --disable-gtk-doc \ - --disable-systemd \ - --disable-bash-completion \ - --enable-dummy \ - --with-default-backend=ports \ - --disable-networkmanager \ - --disable-connman \ - --disable-browser-plugin \ - --disable-gstreamer-plugin \ - --disable-man-pages \ - --disable-nls - -MAKE_ARGS= pkgconfigdir="${PREFIX}/libdata/pkgconfig" +LDFLAGS+= -L${LOCALBASE}/lib -lexecinfo +CONFIGURE_ARGS+=--with-security-framework=polkit \ + --localstatedir=/var \ + --disable-gtk-doc \ + --disable-browser-plugin \ + --disable-gstreamer-plugin \ + --disable-networkmanager \ + --disable-systemd \ + --disable-bash-completion \ + --disable-connman \ + +OPTIONS_DEFINE= DOCS + +.include + +.if ${PORT_OPTIONS:MDOCS} || defined(PACKAGE_BUILDING) +BUILD_DEPENDS+= ${LOCALBASE}/share/sgml/docbook/4.1/dtd/catalog:${PORTSDIR}/textproc/docbook-410 \ + ${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl +USE_GNOME+= libxslt:build +MAN1= pkcon.1 pkmon.1 pkgenpack.1 pk-debuginfo-install.1 +.else +CONFIGURE_ARGS+=--disable-man-pages +.endif -post-install: -.if !defined(${SLAVEPORT}) - @${INSTALL_DATA} ${WRKSRC}/data/transactions.db \ - ${PREFIX}/share/PackageKit/transactions.db - @-update-mime-database ${PREFIX}/share/mime > /dev/null +.if ${PORT_OPTIONS:MPORTS_BACKEND} +LIB_DEPENDS+= pkg:${PORTSDIR}/ports-mgmt/pkg +CONFIGURE_ARGS+=--enable-ports --with-default-backend=ports +PLIST_SUB+= PORTS="" +.else +CONFIGURE_ARGS+=--disable-ports --with-default-backend=dummy +PLIST_SUB+= PORTS="@comment " .endif -.include +# gtk+3 module +CONFIGURE_ARGS+=--disable-gtk-module +PLIST_SUB+= GTK="@comment " + +post-patch: + @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ + ${WRKSRC}/src/plugins/pk-lsof.c + (mkdir ${WRKSRC}/backends/ports/helpers && \ + cp ${WRKSRC}/../../files/default-dialog ${WRKDIR}/backends/ports/helpers/ && \ + cp ${WRKSRC}/../../files/Makefile.am ${WRKDIR}/backends/ports/helpers) -#change default backend -#provide option to select a single or multiple backends -#add pk_backend_select script which takes one argument, the name of the backend, and help; responds to bad names or syntax -#patch in pk_backend_select and make sure it is in pkg-plist -#add man page support and option -#preserve modified configuration files - -# --enable-ports \ -# --with-default-backend=ports \ -# --localstatedir=/var +post-install: + @${MKDIR} /var/cache/PackageKit/downloads +.include Added: soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/Makefile.am ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/Makefile.am Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,17 @@ + +helperdir = $(datadir)/PackageKit/helpers/ports + +NULL = + +dist_helper_DATA = \ + default-dialog \ + $(NULL) + +install-data-hook: + chmod a+rx $(DESTDIR)$(helperdir)/default-dialog + +clean-local : + rm -f *~ + + +-include $(top_srcdir)/git.mk Added: soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/default-dialog ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/default-dialog Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,23 @@ +#!/usr/local/bin/ruby + +# This goes instead of dialog(1), it will +# just return the default options selection +# +# Ex: make config DIALOG=default-dialog + +box = ARGV[0] +exit(-1) unless box == "--checklist" + +text, height, width, list_height = ARGV[1, 4] + +i = 5 +while i < ARGV.count do + tag, item, status = ARGV[i, 3] + if status == "on" + $stderr.puts tag + end + i += 3 +end + +# "OK" +exit(0) Added: soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_backend.rb ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_backend.rb Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,158 @@ +--- backends/ports/ruby_packagekit/backend.rb 2013-04-11 07:58:36.000000000 -0400 ++++ backends/ports/ruby_packagekit/backend.rb 2013-07-30 10:11:40.000000000 -0400 +@@ -14,15 +14,44 @@ + # along with this program; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +-# Copyright (C) 2009 Anders F Bjorklund ++# Copyright (C) 2009, 2013 Anders F Bjorklund + # + # This file contain the base classes to implement a PackageKit ruby backend + # + + PACKAGE_IDS_DELIM = '&' + FILENAME_DELIM = '|' ++FLAGS_DELIM = ';' + + class PackageKitBaseBackend ++ @locked = false ++ ++ def do_lock() ++ # Generic locking, override and extend in subclass ++ @locked = true ++ end ++ ++ def un_lock() ++ # Generic locking, override and extend in subclass ++ @locked = false ++ end ++ ++ def locked? ++ return @locked ++ end ++ ++ def error(err, description, exit=true) ++ if exit and locked?: ++ un_lock() ++ end ++ error_description(err, description) ++ if exit ++ # Paradoxically, we don't want to print "finished" to stdout here. ++ # ++ # Leave PackageKit to clean up for us in this case. ++ exit(254) ++ end ++ end + + def dispatch_command(cmd, args) + case +@@ -32,40 +61,40 @@ + download_packages(directory, package_ids) + finished() + when cmd == 'get-packages' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + get_packages(filters) + finished() + when cmd == 'get-repo-list' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + get_repo_list(filters) + finished() + when cmd == 'resolve' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + package_ids = args[1].split(PACKAGE_IDS_DELIM) + resolve(filters, package_ids) + finished() + when cmd == 'search-details' +- options = args[0] +- searchterms = args[1] ++ options = args[0].split(FLAGS_DELIM) ++ searchterms = args[1].split(PACKAGE_IDS_DELIM) + search_details(options, searchterms) + finished() + when cmd == 'search-file' +- options = args[0] +- searchterms = args[1] ++ options = args[0].split(FLAGS_DELIM) ++ searchterms = args[1].split(PACKAGE_IDS_DELIM) + search_file(options, searchterms) + finished() + when cmd == 'search-group' +- options = args[0] +- searchterms = args[1] ++ options = args[0].split(FLAGS_DELIM) ++ searchterms = args[1].split(PACKAGE_IDS_DELIM) + search_group(options, searchterms) + finished() + when cmd == 'search-name' +- options = args[0] +- searchterms = args[1] ++ options = args[0].split(FLAGS_DELIM) ++ searchterms = args[1].split(PACKAGE_IDS_DELIM) + search_name(options, searchterms) + finished() + when cmd == 'get-depends' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + package_ids = args[1].split(PACKAGE_IDS_DELIM) + recursive = to_b(args[2]) + get_depends(filters, package_ids, recursive) +@@ -79,7 +108,7 @@ + get_files(package_ids) + finished() + when cmd == 'get-requires' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + package_ids = args[1].split(PACKAGE_IDS_DELIM) + recursive = to_b(args[2]) + get_requires(filters, package_ids, recursive) +@@ -89,32 +118,34 @@ + get_update_detail(package_ids) + finished() + when cmd == 'get-updates' +- filters = args[0] ++ filters = args[0].split(FLAGS_DELIM) + get_updates(filters) + finished() + when cmd == 'install-files' +- only_trusted = to_b(args[0]) ++ transaction_flags = args[0].split(FLAGS_DELIM) + files_to_inst = args[1].split(FILENAME_DELIM) +- install_files(only_trusted, files_to_inst) ++ install_files(transaction_flags, files_to_inst) + finished() + when cmd == 'install-packages' +- only_trusted = to_b(args[0]) ++ transaction_flags = args[0].split(FLAGS_DELIM) + package_ids = args[1].split(PACKAGE_IDS_DELIM) +- install_packages(only_trusted, package_ids) ++ install_packages(transaction_flags, package_ids) ++ finished() ++ when cmd == 'update-packages' ++ transaction_flags = args[0].split(FLAGS_DELIM) ++ package_ids = args[1].split(PACKAGE_IDS_DELIM) ++ update_packages(transaction_flags, package_ids) + finished() + when cmd == 'refresh-cache' + force = to_b(args[0]) + refresh_cache(force) + finished() + when cmd == 'remove-packages' +- allowdeps = to_b(args[0]) +- autoremove = to_b(args[1]) +- package_ids = args[2].split(PACKAGE_IDS_DELIM) +- remove_packages(allowdeps, autoremove, package_ids) +- finished() +- when cmd == 'update-system' +- only_trusted = to_b(args[0]) +- update_system(only_trusted) ++ transaction_flags = args[0].split(FLAGS_DELIM) ++ package_ids = args[1].split(PACKAGE_IDS_DELIM) ++ allowdeps = to_b(args[2]) ++ autoremove = to_b(args[3]) ++ remove_packages(transaction_flags, package_ids, allowdeps, autoremove) + finished() + else + errmsg = "command '#{cmd}' is not known" Added: soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_prints.rb ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit/PackageKit-0.8.9/packagekit/files/patch-backends-ports-ruby__packagekit_prints.rb Thu Aug 1 20:14:56 2013 (r255425) @@ -0,0 +1,99 @@ +--- backends/ports/ruby_packagekit/prints.rb 2010-02-11 06:13:57.000000000 -0500 ++++ backends/ports/ruby_packagekit/prints.rb 2013-07-30 10:11:40.000000000 -0400 +@@ -8,6 +8,16 @@ + $stdout.flush + end + ++def media_change_required(mtype, id, text) ++ $stdout.printf "media-change-required\t%s\t%s\t%s\n", mtype, id, text ++ $stdout.flush ++end ++ ++def distro_upgrade(repoid, dtype, name, summary) ++ $stdout.printf "distro-upgrade\t%s\t%s\t%s\n", dtype, name, summary ++ $stdout.flush ++end ++ + def repo_detail(repoid, name, state) + $stdout.printf "repo-detail\t%s\t%s\t%s\n", repoid, name, state + $stdout.flush +@@ -18,6 +28,11 @@ + $stdout.flush + end + ++def require_restart(restart_type, details) ++ $stdout.printf "requirerestart\t%s\t%s\n", restart_type, details ++ $stdout.flush ++end ++ + def details(package_id, package_license, group, desc, url, bytes) + $stdout.printf "details\t%s\t%s\t%s\t%s\t%s\t%d\n", package_id, package_license, group, desc, url, bytes + $stdout.flush +@@ -28,23 +43,44 @@ + $stdout.flush + end + ++def category(parent_id, cat_id, name, summary, icon) ++ $stdout.printf "category\t%s\t%s\t%s\t%s\t%s\n", parent_id, cat_id, name, summary, icon ++ $stdout.flush ++end ++ + def status(state) + $stdout.printf "status\t%s\n", state + $stdout.flush + end + +-def error(err, description, exit=true) ++def data(data) ++ $stdout.printf "data\t%s\n", data ++ $stdout.flush ++end ++ ++def allow_cancel(allow) ++ $stdout.printf "allow-cancel\t%s\n", allow ++ $stdout.flush ++end ++ ++def repo_signature_required(package_id, repo_name, key_url, key_userid, key_id, key_fingerprint, key_timestamp, sig_type) ++ $stdout.printf "repo-signature-required\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", package_id, repo_name, key_url, key_userid, key_id, key_fingerprint, key_timestamp, sig_type ++ $stdout.flush ++end ++ ++def eula_required(eula_id, package_id, vendor_name, license_agreement) ++ $stdout.printf "eula-required\t%s\t%s\t%s\t%s\n", eula_id, package_id, vendor_name, license_agreement ++ $stdout.flush ++end ++ ++def error_description(err, description) + $stdout.printf "error\t%s\t%s\n", err, description + $stdout.flush +- if exit +- finished +- exit(1) +- end + end + + def percentage(percent=nil) + if percent==nil +- $stdout.printf "finished\n" ++ $stdout.printf "no-percentage-updates\n" + else percent == 0 or percent > $percentage_old + $stdout.printf "percentage\t%i\n", percent + $percentage_old = percent +@@ -52,6 +88,16 @@ + $stdout.flush + end + ++def item_progress(package_id, status, percent=nil) ++ $stdout.printf "item-progress\t%s\t%s\t%i\n", package_id, status, percent ++ $stdout.flush ++end ++ ++def speed(bps=0) ++ $stdout.printf "speed\t%i\n", bps *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Fri Aug 2 00:31:25 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3D66D89C for ; Fri, 2 Aug 2013 00:31:25 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 10A5022B9 for ; Fri, 2 Aug 2013 00:31:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r720VOj4098030 for ; Fri, 2 Aug 2013 00:31:24 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r720VOAr098028 for svn-soc-all@FreeBSD.org; Fri, 2 Aug 2013 00:31:24 GMT (envelope-from zcore@FreeBSD.org) Date: Fri, 2 Aug 2013 00:31:24 GMT Message-Id: <201308020031.r720VOAr098028@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255437 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 02 Aug 2013 00:31:25 -0000 Author: zcore Date: Fri Aug 2 00:31:24 2013 New Revision: 255437 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255437 Log: add command list and prdt support Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Aug 1 23:51:20 2013 (r255436) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Aug 2 00:31:24 2013 (r255437) @@ -57,7 +57,7 @@ */ static FILE *dbg; #define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) -#define DPRINTF(params) dprintf params +#define DPRINTF(params) printf params #define WPRINTF(params) printf params struct ahci_ioreq { @@ -72,6 +72,7 @@ struct ahci_port { struct blockif_ctxt *bctx; struct pci_ahci_softc *pr_sc; + uint64_t cmd_lst; uint32_t clb; uint32_t clbu; uint32_t fb; @@ -107,6 +108,12 @@ uint32_t reserved[4]; }; +struct ahci_prdt_entry { + uint64_t dba; + uint32_t reserved; + uint32_t dbc; +}; + struct pci_ahci_softc { struct pci_devinst *asc_pi; pthread_mutex_t mtx; @@ -124,6 +131,7 @@ uint32_t bohc; struct ahci_port port[AHCI_MAX_PORTS]; }; +#define ahci_ctx(sc) ((sc)->asc_pi->pi_vmctx) /* * generate HBA intr depending on whether or not ports within @@ -228,17 +236,49 @@ static void handle_slot(struct ahci_port *p, int slot) { - /* TODO */ + uint8_t *cfis; + int cfl, i; + struct ahci_cmd_hdr *hdr; + struct ahci_prdt_entry *prdt; + struct pci_ahci_softc *sc; + + sc = p->pr_sc; + hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + cfl = (hdr->flags & 0x1f) * 4; + dprintf("cfis length:%d prdt entries: %d\n", cfl, hdr->prdtl); + cfis = paddr_guest2host(ahci_ctx(sc), hdr->ctba, cfl); + prdt = paddr_guest2host(ahci_ctx(sc), hdr->ctba + 0x80, hdr->prdtl * 16); + + /* dump cfis, will be removed latter */ + for (i = 0; i < cfl; i++) { + if (i % 10 == 0) + dprintf("\n"); + dprintf("%02x ", cfis[i]); + } + dprintf("\n"); + + /* dump prdt, will be removed latter */ + for (i = 0; i < hdr->prdtl; i++) { + dprintf("%d@%08lx, %d\n", prdt->dbc & 0x3fffff, prdt->dba, (prdt->dbc >> 31) & 0x1); + prdt++; + } } static void handle_cmd(struct ahci_port *p) { int i; + struct pci_ahci_softc *sc; + uint64_t clb; if (!(p->cmd & AHCI_P_CMD_ST) || !p->ci) return; + sc = p->pr_sc; + clb = (uint64_t)p->clbu << 32 | p->clb; + p->cmd_lst = paddr_guest2host(ahci_ctx(sc), clb, + AHCI_CL_SIZE * AHCI_MAX_SLOTS); + for (i = 0; (i < 32) && p->ci; i++) { if (p->ci & (1 << i)) { handle_slot(p, i); From owner-svn-soc-all@FreeBSD.ORG Fri Aug 2 00:49:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id ADC4BA35 for ; Fri, 2 Aug 2013 00:49:48 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 98C082324 for ; Fri, 2 Aug 2013 00:49:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r720nmDK045254 for ; Fri, 2 Aug 2013 00:49:48 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r720nmp9045246 for svn-soc-all@FreeBSD.org; Fri, 2 Aug 2013 00:49:48 GMT (envelope-from def@FreeBSD.org) Date: Fri, 2 Aug 2013 00:49:48 GMT Message-Id: <201308020049.r720nmp9045246@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255438 - soc2013/def/crashdump-head/sys/crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 02 Aug 2013 00:49:48 -0000 Author: def Date: Fri Aug 2 00:49:48 2013 New Revision: 255438 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255438 Log: Add a power of tweak (alpha^j) as a parameter in xts_block_encrypt and xts_block_decrypt. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Fri Aug 2 00:31:24 2013 (r255437) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Fri Aug 2 00:49:48 2013 (r255438) @@ -97,40 +97,46 @@ void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, - const uint8_t *src, uint8_t *dst) + uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_j, + int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + if (alpha_j == NULL) { + xts_start(alg, tweak_ctx, tweak, sector, xtweak); + alpha_j = tweak; + } while (len >= XTS_BLK_BYTES) { - xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); + xts_fullblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst); dst += XTS_BLK_BYTES; src += XTS_BLK_BYTES; len -= XTS_BLK_BYTES; } if (len != 0) - xts_lastblock(alg->pa_encrypt, data_ctx, tweak, src, dst, len); + xts_lastblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst, len); } void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, - const uint8_t *src, uint8_t *dst) + uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_j, + int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; uint64_t prevtweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + if (alpha_j == NULL) { + xts_start(alg, tweak_ctx, tweak, sector, xtweak); + alpha_j = tweak; + } if ((len & XTS_BLK_MASK) != 0) len -= XTS_BLK_BYTES; while (len >= XTS_BLK_BYTES) { - xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst); + xts_fullblock(alg->pa_decrypt, data_ctx, alpha_j, src, dst); dst += XTS_BLK_BYTES; src += XTS_BLK_BYTES; len -= XTS_BLK_BYTES; @@ -138,10 +144,10 @@ if (len != 0) { len += XTS_BLK_BYTES; - prevtweak[0] = tweak[0]; - prevtweak[1] = tweak[1]; - gf_mul128(tweak, tweak); - xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst); + prevtweak[0] = alpha_j[0]; + prevtweak[1] = alpha_j[1]; + gf_mul128(alpha_j, alpha_j); + xts_fullblock(alg->pa_decrypt, data_ctx, alpha_j, src, dst); dst += XTS_BLK_BYTES; src += XTS_BLK_BYTES; len -= XTS_BLK_BYTES; Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Fri Aug 2 00:31:24 2013 (r255437) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Fri Aug 2 00:49:48 2013 (r255438) @@ -111,13 +111,13 @@ void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, - const uint8_t *src, uint8_t *dst); + uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_j, + int len, const uint8_t *src, uint8_t *dst); void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, - const uint8_t *src, uint8_t *dst); + uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_j, + int len, const uint8_t *src, uint8_t *dst); algop_crypt_t xts_aes_encrypt; algop_crypt_t xts_aes_decrypt; From owner-svn-soc-all@FreeBSD.ORG Fri Aug 2 00:52:51 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9BEEFA5C for ; Fri, 2 Aug 2013 00:52:51 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7A841232F for ; Fri, 2 Aug 2013 00:52:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r720qpja017099 for ; Fri, 2 Aug 2013 00:52:51 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r720qpQY017084 for svn-soc-all@FreeBSD.org; Fri, 2 Aug 2013 00:52:51 GMT (envelope-from def@FreeBSD.org) Date: Fri, 2 Aug 2013 00:52:51 GMT Message-Id: <201308020052.r720qpQY017084@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255439 - in soc2013/def/crashdump-head: sbin/savecore sys/kern sys/sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 02 Aug 2013 00:52:51 -0000 Author: def Date: Fri Aug 2 00:52:51 2013 New Revision: 255439 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255439 Log: Store cached alpha^j values. Reduce a number of #ifdef directives. Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Fri Aug 2 00:49:48 2013 (r255438) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Fri Aug 2 00:52:51 2013 (r255439) @@ -20,7 +20,7 @@ fd->buf_used += resid; xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx, - fd->offset, fd->tweak, PEFS_SECTOR_SIZE, + fd->offset, fd->tweak, NULL, PEFS_SECTOR_SIZE, fd->buf, fd->buf); if (fwrite(fd->buf, 1, PEFS_SECTOR_SIZE, fd->fp) != PEFS_SECTOR_SIZE) @@ -106,7 +106,7 @@ if (fd->buf_used > 0) { xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx, - fd->offset, fd->tweak, fd->buf_used, + fd->offset, fd->tweak, NULL, fd->buf_used, fd->buf, fd->buf); if (fwrite(fd->buf, 1, fd->buf_used, fd->fp) != 1) Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Fri Aug 2 00:49:48 2013 (r255438) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Fri Aug 2 00:52:51 2013 (r255439) @@ -146,10 +146,8 @@ int dumping; /* system is dumping */ int rebooting; /* system is rebooting */ static struct dumperinfo dumper; /* our selected dumper */ -#ifdef ENCRYPT_CRASH static struct kerneldumpkey dumperkey; static struct kerneldumpbuffer dumperbuffer; -#endif /* Context information for dump-debuggers. */ static struct pcb dumppcb; /* Registers. */ @@ -854,10 +852,10 @@ if (dumper.dumper != NULL) return (EBUSY); dumper = *di; - -#ifdef ENCRYPT_CRASH dumper.kdk = &dumperkey; dumper.kdb = &dumperbuffer; + +#ifdef ENCRYPT_CRASH kerneldump_crypto_init(&dumper); #endif @@ -869,29 +867,17 @@ return (0); } -/* Call dumper with bounds checking. */ +/* Call dumper with encrypted data. */ int -dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, - off_t offset, size_t length) +dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) { -#ifdef ENCRYPT_CRASH struct kerneldumpkey *kdk; struct kerneldumpbuffer *kdb; - int error, len; - off_t sector_index, devblk_index; - char *ptr; -#endif - - if (length != 0 && (offset < di->mediaoffset || - offset - di->mediaoffset + length > di->mediasize)) { - printf("Attempt to write outside dump device boundaries.\n" - "offset(%jd), mediaoffset(%jd), length(%ju), mediasize(%jd).\n", - (intmax_t)offset, (intmax_t)di->mediaoffset, - (uintmax_t)length, (intmax_t)di->mediasize); - return (ENOSPC); - } + int error, sector_index, devblk_index; + off_t sector_offset; + uint64_t tweak[XTS_BLK_BYTES / 8]; -#ifdef ENCRYPT_CRASH kdk = di->kdk; kdb = di->kdb; @@ -903,22 +889,28 @@ } sector_index = (offset - kdb->kdhoffset)/KERNELDUMP_SECTOR_SIZE; + sector_offset = kdb->kdhoffset + sector_index*KERNELDUMP_SECTOR_SIZE; devblk_index = (offset - kdb->kdhoffset - sector_index*KERNELDUMP_SECTOR_SIZE)/KERNELDUMP_DEVBLK_SIZE; + if (sector_index == kdb->sector_index) { + kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, kdb->devblk_index, devblk_index, + sector_offset, kdk->tweak); + memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak)); + } + while (length > 0) { memcpy(kdb->buf, virtual, KERNELDUMP_DEVBLK_SIZE); - if (devblk_index == 0) - xts_start(&xts_alg_aes, &kdk->tweak_ctx, kdb->tweak, offset, kdk->tweak); - - ptr = kdb->buf; - len = KERNELDUMP_DEVBLK_SIZE; - while (len > 0) { - xts_fullblock(xts_alg_aes.pa_encrypt, &kdk->data_ctx, kdb->tweak, ptr, ptr); - ptr += XTS_BLK_BYTES; - len -= XTS_BLK_BYTES; + if (sector_index != kdb->sector_index) { + kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, 0, devblk_index, + sector_offset, kdk->tweak); + kdb->sector_index = sector_index; + memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak)); } + xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, offset, kdk->tweak, + tweak, KERNELDUMP_DEVBLK_SIZE, kdb->buf, kdb->buf); + error = (di->dumper(di->priv, kdb->buf, physical, offset, KERNELDUMP_DEVBLK_SIZE)); if (error) @@ -927,16 +919,60 @@ virtual = (void *)((char *)virtual + KERNELDUMP_DEVBLK_SIZE); length -= KERNELDUMP_DEVBLK_SIZE; offset += KERNELDUMP_DEVBLK_SIZE; - devblk_index = (devblk_index+1)%(KERNELDUMP_SECTOR_SIZE/KERNELDUMP_DEVBLK_SIZE); + devblk_index = (devblk_index+1)%KERNELDUMP_SECTOR_BLKS; + + if (devblk_index == 0) { + sector_index++; + sector_offset = offset; + } else { + memcpy(kdb->alpha_j[devblk_index], tweak, sizeof(tweak)); + kdb->devblk_index = devblk_index; + } } return (0); -#else /* ENCRYPT_CRASH */ - return (di->dumper(di->priv, virtual, physical, offset, length)); -#endif /* ENCRYPT_CRASH */ } +/* Call dumper with bounds checking. */ +int +dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) +{ + + if (length != 0 && (offset < di->mediaoffset || + offset - di->mediaoffset + length > di->mediasize)) { + printf("Attempt to write outside dump device boundaries.\n" + "offset(%jd), mediaoffset(%jd), length(%ju), mediasize(%jd).\n", + (intmax_t)offset, (intmax_t)di->mediaoffset, + (uintmax_t)length, (intmax_t)di->mediasize); + return (ENOSPC); + } + #ifdef ENCRYPT_CRASH + return (dump_encrypted_write(di, virtual, physical, offset, length)); +#else + return (di->dumper(di->priv, virtual, physical, offset, length)); +#endif +} + +void +kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, + uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j, + uint64_t sector, const uint8_t *xtweak) +{ + int k; + + if (i == 0) + xts_start(alg, tweak_ctx, alpha_j[0], sector, xtweak); + + for (++i ; i <= j ; i++) { + memcpy(alpha_j[i], alpha_j[i-1], XTS_BLK_BYTES); + + for (k = 0 ; k < KERNELDUMP_DEVBLK_SIZE/XTS_BLK_BYTES ; k++) + gf_mul128(alpha_j[i], alpha_j[i]); + } +} + static void kerneldump_hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, int idx, const uint8_t *magic, size_t magicsize) @@ -959,9 +995,6 @@ return; } - /* In the future the tweak will be set via sysctl. */ - arc4rand(kerneldump_tweak, KERNELDUMP_TWEAK_SIZE, 0); - di->kdk = kerneldump_set_key(di->kdk, KERNELDUMP_KEY_SIZE, kerneldump_key, kerneldump_tweak); di->kdb = kerneldump_set_buffer(di->kdb); } @@ -1004,11 +1037,12 @@ return (NULL); } + kdb->sector_index = -1; + kdb->devblk_index = -1; kdb->kdhoffset = 0; return (kdb); } -#endif /* ENCRYPT_CRASH */ void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, @@ -1027,10 +1061,8 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); -#ifdef ENCRYPT_CRASH kdh->keysize = dumper.kdk->keysize; strncpy(kdh->key, dumper.kdk->key, kdh->keysize); strncpy(kdh->tweak, dumper.kdk->tweak, KERNELDUMP_TWEAK_SIZE); -#endif kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Fri Aug 2 00:49:48 2013 (r255438) +++ soc2013/def/crashdump-head/sys/sys/conf.h Fri Aug 2 00:52:51 2013 (r255439) @@ -323,10 +323,8 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* Stuff relating to kernel-dump */ -#ifdef ENCRYPT_CRASH struct kerneldumpkey; struct kerneldumpbuffer; -#endif struct dumperinfo { dumper_t *dumper; /* Dumping function. */ @@ -335,14 +333,13 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ -#ifdef ENCRYPT_CRASH struct kerneldumpkey *kdk; /* Kernel dump key. */ struct kerneldumpbuffer *kdb; /* Kernel dump buffer. */ -#endif }; int set_dumper(struct dumperinfo *, const char *_devname); int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); +int dump_encrypted_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); void dumpsys(struct dumperinfo *); int doadump(boolean_t); extern int dumping; /* system is dumping */ Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Fri Aug 2 00:49:48 2013 (r255438) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Fri Aug 2 00:52:51 2013 (r255439) @@ -109,7 +109,6 @@ } #ifdef _KERNEL -#ifdef ENCRYPT_CRASH /* * Constant key for kernel crash dumps. */ @@ -119,7 +118,9 @@ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }; -static char kerneldump_tweak[KERNELDUMP_TWEAK_SIZE]; +static char kerneldump_tweak[KERNELDUMP_TWEAK_SIZE] = { + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 +}; struct kerneldumpkey { int keysize; @@ -132,16 +133,20 @@ struct kerneldumpbuffer { #define KERNELDUMP_DEVBLK_SIZE 512 #define KERNELDUMP_SECTOR_SIZE 4096 +#define KERNELDUMP_SECTOR_BLKS (KERNELDUMP_SECTOR_SIZE/KERNELDUMP_DEVBLK_SIZE) uint8_t buf[KERNELDUMP_DEVBLK_SIZE]; /* Raw data buffer. */ - uint64_t tweak[XTS_BLK_BYTES / 8]; /* Tweak value used in XTS. */ + uint64_t alpha_j[KERNELDUMP_SECTOR_BLKS][XTS_BLK_BYTES / 8]; + off_t sector_index; + off_t devblk_index; off_t kdhoffset; /* Offset value of the first kdh. */ }; void kerneldump_crypto_init(struct dumperinfo *di); struct kerneldumpkey *kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *key, char *tweak); struct kerneldumpbuffer *kerneldump_set_buffer(struct kerneldumpbuffer *kdb); -#endif /* ENCRYPT_CRASH */ - +void kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, + uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j, + uint64_t sector, const uint8_t *xtweak); void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz); #endif From owner-svn-soc-all@FreeBSD.ORG Fri Aug 2 14:17:25 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B0F085A9 for ; Fri, 2 Aug 2013 14:17:25 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9D2A628BD for ; Fri, 2 Aug 2013 14:17:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r72EHP2D072702 for ; Fri, 2 Aug 2013 14:17:25 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r72EHPQ4072700 for svn-soc-all@FreeBSD.org; Fri, 2 Aug 2013 14:17:25 GMT (envelope-from zcore@FreeBSD.org) Date: Fri, 2 Aug 2013 14:17:25 GMT Message-Id: <201308021417.r72EHPQ4072700@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255450 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 02 Aug 2013 14:17:25 -0000 Author: zcore Date: Fri Aug 2 14:17:25 2013 New Revision: 255450 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255450 Log: only reset necessary port registers during port_reset Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Aug 2 13:06:49 2013 (r255449) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Aug 2 14:17:25 2013 (r255450) @@ -57,7 +57,7 @@ */ static FILE *dbg; #define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) -#define DPRINTF(params) printf params +#define DPRINTF(params) dprintf params #define WPRINTF(params) printf params struct ahci_ioreq { @@ -211,7 +211,13 @@ static void ahci_port_reset(struct ahci_port *pr) { - memset(&pr->clb, 0, 17 * sizeof(uint32_t)); + pr->is = 0; + pr->ie = 0; + pr->ssts = 0; + pr->sctl = 0; + pr->serr = 0; + pr->sact = 0; + /* TODO set signature by the device kind */ pr->sig = 0x00000101; pr->tfd = 0; @@ -269,15 +275,11 @@ { int i; struct pci_ahci_softc *sc; - uint64_t clb; if (!(p->cmd & AHCI_P_CMD_ST) || !p->ci) return; sc = p->pr_sc; - clb = (uint64_t)p->clbu << 32 | p->clb; - p->cmd_lst = paddr_guest2host(ahci_ctx(sc), clb, - AHCI_CL_SIZE * AHCI_MAX_SLOTS); for (i = 0; (i < 32) && p->ci; i++) { if (p->ci & (1 << i)) { @@ -387,6 +389,8 @@ ahci_generate_intr(sc); break; case AHCI_P_CMD: + { + uint64_t clb; p->cmd = value; if (!(value & AHCI_P_CMD_ST)) { @@ -406,8 +410,12 @@ p->cmd &= ~AHCI_P_CMD_CLO; } + clb = (uint64_t)p->clbu << 32 | p->clb; + p->cmd_lst = paddr_guest2host(ahci_ctx(sc), clb, + AHCI_CL_SIZE * AHCI_MAX_SLOTS); handle_cmd(p); break; + } case AHCI_P_TFD: case AHCI_P_SIG: case AHCI_P_SSTS: From owner-svn-soc-all@FreeBSD.ORG Sat Aug 3 10:24:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BC55BB34 for ; Sat, 3 Aug 2013 10:24:59 +0000 (UTC) (envelope-from iori@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8FA6D2E46 for ; Sat, 3 Aug 2013 10:24:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r73AOxgN075296 for ; Sat, 3 Aug 2013 10:24:59 GMT (envelope-from iori@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r73AOxHp075291 for svn-soc-all@FreeBSD.org; Sat, 3 Aug 2013 10:24:59 GMT (envelope-from iori@FreeBSD.org) Date: Sat, 3 Aug 2013 10:24:59 GMT Message-Id: <201308031024.r73AOxHp075291@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iori@FreeBSD.org using -f From: iori@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255477 - in soc2013/iori: . suspendresume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 03 Aug 2013 10:24:59 -0000 Author: iori Date: Sat Aug 3 10:24:59 2013 New Revision: 255477 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255477 Log: New repository to host BHyVe's suspend/resume development. Added: soc2013/iori/ soc2013/iori/suspendresume/ From owner-svn-soc-all@FreeBSD.ORG Sat Aug 3 10:26:56 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5F3BFB53 for ; Sat, 3 Aug 2013 10:26:56 +0000 (UTC) (envelope-from iori@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 32F9C2E50 for ; Sat, 3 Aug 2013 10:26:56 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r73AQuH5084481 for ; Sat, 3 Aug 2013 10:26:56 GMT (envelope-from iori@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r73AQutB084480 for svn-soc-all@FreeBSD.org; Sat, 3 Aug 2013 10:26:56 GMT (envelope-from iori@FreeBSD.org) Date: Sat, 3 Aug 2013 10:26:56 GMT Message-Id: <201308031026.r73AQutB084480@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iori@FreeBSD.org using -f From: iori@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255478 - soc2013/iori/suspendresume/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 03 Aug 2013 10:26:56 -0000 Author: iori Date: Sat Aug 3 10:26:55 2013 New Revision: 255478 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255478 Log: new resitory to host BHyVe's suspend/resume development. Added: soc2013/iori/suspendresume/head/ (props changed) - copied from r255477, mirror/FreeBSD/head/ From owner-svn-soc-all@FreeBSD.ORG Sat Aug 3 13:06:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id AD69A723 for ; Sat, 3 Aug 2013 13:06:28 +0000 (UTC) (envelope-from iori@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 987142242 for ; Sat, 3 Aug 2013 13:06:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r73D6SN5070600 for ; Sat, 3 Aug 2013 13:06:28 GMT (envelope-from iori@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r73D6Sx5070572 for svn-soc-all@FreeBSD.org; Sat, 3 Aug 2013 13:06:28 GMT (envelope-from iori@FreeBSD.org) Date: Sat, 3 Aug 2013 13:06:28 GMT Message-Id: <201308031306.r73D6Sx5070572@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iori@FreeBSD.org using -f From: iori@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255481 - in soc2013/iori/suspendresume/head: lib/libvmmapi sys/amd64/include sys/amd64/vmm sys/amd64/vmm/amd sys/amd64/vmm/intel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 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, 03 Aug 2013 13:06:28 -0000 Author: iori Date: Sat Aug 3 13:06:28 2013 New Revision: 255481 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255481 Log: Added new ioctl to prevent VM from running, kill it, and save emulated integer and contol registers and copy them to userland. If VM killed by suspend request ioctl, vmrun ioctl returns value indicate that save registers request was issued and this is why it returns. TODO: hook vmrun ioctl return in userland tool bhyve, and save registers and transfer to the process requested to suspend. develop new test tool to make sure that it saves. memory save. Modified: soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.c soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.h soc2013/iori/suspendresume/head/sys/amd64/include/vmm.h soc2013/iori/suspendresume/head/sys/amd64/include/vmm_dev.h soc2013/iori/suspendresume/head/sys/amd64/vmm/amd/amdv.c soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.c soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.h soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm.c soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm_dev.c Modified: soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.c ============================================================================== --- soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.c Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.c Sat Aug 3 13:06:28 2013 (r255481) @@ -123,6 +123,39 @@ free(vm); } +unsigned long +vm_get_allvstate(struct vmctx *ctx, struct vmstate *vmstate) +{ + int error; + + error = ioctl(ctx->fd, VM_SAVE_VCPUSTATE, vmstate); + return error; +} + +size_t +vmm_get_mem_total(void) +{ + size_t mem_total = 0; + size_t oldlen = sizeof(mem_total); + int error; + error = sysctlbyname("hw.vmm.mem_total", &mem_total, &oldlen, NULL, 0); + if (error) + return -1; + return mem_total; +} + +size_t +vmm_get_mem_free(void) +{ + size_t mem_free = 0; + size_t oldlen = sizeof(mem_free); + int error; + error = sysctlbyname("hw.vmm.mem_free", &mem_free, &oldlen, NULL, 0); + if (error) + return -1; + return mem_free; +} + int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len) { Modified: soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.h ============================================================================== --- soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.h Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/lib/libvmmapi/vmmapi.h Sat Aug 3 13:06:28 2013 (r255481) @@ -45,6 +45,9 @@ int vm_create(const char *name); struct vmctx *vm_open(const char *name); void vm_destroy(struct vmctx *ctx); +unsigned long vm_get_allvstate(struct vmctx *ctx, struct vmstate *vmstate); +size_t vmm_get_mem_total(void); +size_t vmm_get_mem_free(void); int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len); int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len); Modified: soc2013/iori/suspendresume/head/sys/amd64/include/vmm.h ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/include/vmm.h Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/include/vmm.h Sat Aug 3 13:06:28 2013 (r255481) @@ -33,19 +33,29 @@ #define VM_MAX_NAMELEN 32 +#define VM_SUSPEND 1 +#define VM_USERLAND 0 + +/*- vmrun control -*/ +#define REQ_SUSPEND 0x01 +#define REQ_SNAPSHOT 0x02 +#define REQ_SLEEP 0x04 + struct vm; struct vm_memory_segment; struct seg_desc; struct vm_exit; struct vm_run; struct vlapic; +struct vm_vcpustate; +struct vm_registers; enum x2apic_state; typedef int (*vmm_init_func_t)(void); typedef int (*vmm_cleanup_func_t)(void); typedef void * (*vmi_init_func_t)(struct vm *vm); /* instance specific apis */ -typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip); +typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip, int *control); typedef void (*vmi_cleanup_func_t)(void *vmi); typedef int (*vmi_mmap_set_func_t)(void *vmi, vm_paddr_t gpa, vm_paddr_t hpa, size_t length, @@ -65,11 +75,11 @@ uint32_t code, int code_valid); typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval); typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val); +typedef int (*vmi_reg_copy_t)(void *vmi, int ncpu, struct vm_registers **vmcpu); struct vmm_ops { vmm_init_func_t init; /* module wide initialization */ vmm_cleanup_func_t cleanup; - vmi_init_func_t vminit; /* vm-specific initialization */ vmi_run_func_t vmrun; vmi_cleanup_func_t vmcleanup; @@ -82,6 +92,7 @@ vmi_inject_event_t vminject; vmi_get_cap_t vmgetcap; vmi_set_cap_t vmsetcap; + vmi_reg_copy_t vreg_copy; }; extern struct vmm_ops vmm_ops_intel; @@ -117,6 +128,7 @@ void vm_activate_cpu(struct vm *vm, int vcpu); cpuset_t vm_active_cpus(struct vm *vm); struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); +int vm_save_vcpustate(struct vm *vm, int i, struct vm_vcpustate *vmstate); /* * Return 1 if device indicated by bus/slot/func is supposed to be a @@ -288,4 +300,120 @@ } u; }; +/* Virtual Machine abstract representation for saving its state)*/ + +typedef struct { + uint16_t highreg; + uint64_t otherreg; +} floatreg80_t; + +typedef struct { + uint64_t hireg; + uint64_t loreg; +} floatreg128_t; + +struct vm_x87_registers { + floatreg80_t st[8]; + uint16_t control_reg; + uint16_t status_reg; + uint16_t tag_reg; + uint16_t opcode; //11bit + uint64_t fip; //instruction pointer + uint64_t dpr; //data pointer register +}; + +struct vm_mmx_registers { + uint64_t mm[8]; +}; + +struct vm_sse_registers { + floatreg128_t xmm[16]; + uint32_t mxcsr; +}; + +struct desc_table_register { + uint64_t baseaddr; + uint32_t table_limit; +}; + +struct segment_register { + uint16_t segselect; + uint64_t baseaddr; + uint32_t table_limit; + uint32_t attribute; +}; + +struct vm_registers { +/* memory_registers */ + struct segment_register *tr; + struct seg_desc *gdtr; + struct seg_desc *ldtr; + struct seg_desc *idtr; + +/* control_registers */ + uint32_t cr0; + uint32_t cr1; + uint32_t cr2; + uint32_t cr3; + uint32_t cr4; + uint64_t cr8; + uint64_t xcr0; + +/* vm_gp_registers */ + uint64_t rax; + uint64_t rbx; + uint64_t rcx; + uint64_t rdx; + uint64_t rdi; + uint64_t rsi; + uint64_t rbp; + uint64_t rsp; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + +/* vm_segment_registers */ + struct segment_register *cs; + struct segment_register *ds; + struct segment_register *ss; + struct segment_register *es; + struct segment_register *fs; + struct segment_register *gs; + + uint64_t dr7; //vmcs + uint64_t rflags; + uint64_t rip; + struct savefpu *vfpu; + uint64_t efer; +}; + +struct vm_interrupt_state { +}; + +struct vm_mem_state { +}; + +struct vm_devices { +}; + +struct vm_vcpustate { + struct vm_vcpustate *nextcpu; + struct vm_registers *regs; + struct vm_interrupt_state *intrinfo; +}; + +struct vmstate{ + int bhyve_version; + int host_vendor; + int ncpu; + struct vm_vcpustate *vmcpu; + struct vm_mem_state mem; + struct vm_devices dev; +}; + #endif /* _VMM_H_ */ Modified: soc2013/iori/suspendresume/head/sys/amd64/include/vmm_dev.h ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/include/vmm_dev.h Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/include/vmm_dev.h Sat Aug 3 13:06:28 2013 (r255481) @@ -157,6 +157,7 @@ IOCNUM_VM_STAT_DESC, IOCNUM_SET_X2APIC_STATE, IOCNUM_GET_X2APIC_STATE, + IOCNUM_SAVE_VCPUSTATE, }; #define VM_RUN \ @@ -201,4 +202,6 @@ _IOW('v', IOCNUM_SET_X2APIC_STATE, struct vm_x2apic) #define VM_GET_X2APIC_STATE \ _IOWR('v', IOCNUM_GET_X2APIC_STATE, struct vm_x2apic) +#define VM_SAVE_VCPUSTATE\ + _IOWR('v', IOCNUM_SAVE_VCPUSTATE, struct vmstate) #endif Modified: soc2013/iori/suspendresume/head/sys/amd64/vmm/amd/amdv.c ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/vmm/amd/amdv.c Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/vmm/amd/amdv.c Sat Aug 3 13:06:28 2013 (r255481) @@ -62,7 +62,7 @@ } static int -amdv_vmrun(void *arg, int vcpu, register_t rip) +amdv_vmrun(void *arg, int vcpu, register_t rip, int *control) { printf("amdv_vmrun: not implemented\n"); Modified: soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.c ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.c Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.c Sat Aug 3 13:06:28 2013 (r255481) @@ -1436,7 +1436,7 @@ } static int -vmx_run(void *arg, int vcpu, register_t rip) +vmx_run(void *arg, int vcpu, register_t rip, int *control) { int error, vie, rc, handled, astpending; uint32_t exit_reason; @@ -1539,6 +1539,8 @@ handled = vmx_exit_process(vmx, vcpu, vmexit); vmx_exit_trace(vmx, vcpu, rip, exit_reason, handled); + if ( *control == REQ_SUSPEND ) + break; } while (handled); @@ -1566,7 +1568,13 @@ * Can we avoid doing this? */ VMCLEAR(vmcs); - return (0); + + if ( *control ){ + printf("suspend_request has been issued!(cpu=%d)\n", vcpu); + return (VM_SUSPEND); + } + else + return (VM_USERLAND); err_exit: vmexit->exitcode = VM_EXITCODE_VMX; @@ -1930,6 +1938,102 @@ return (retval); } + +static int +vmx_getseg(void *arg, int vcpu, int reg, struct segment_register *seg) +{ + struct seg_desc tmpsegment; + uint64_t tmpregs; + int error; + + printf("getreg"); + error = vmx_getreg(arg, vcpu, reg, &tmpregs); + if (error) + return error; + + printf("getdesc"); + error = vmx_getdesc(arg, vcpu, reg, &tmpsegment); + if (error) + return error; + + printf("seg"); + seg->segselect = (uint16_t) (0xffff & tmpregs); + printf("limit"); + seg->table_limit = tmpsegment.limit; + printf("base"); + seg->baseaddr = tmpsegment.base; + printf("atri"); + seg->attribute = tmpsegment.access; + + return 0; +} + +static int +vmx_cpu_regcopy(void *arg, int ncpu, struct vm_registers **vmcpu) +{ + struct vmx *vmx = arg; + uint64_t tmpreg; + int vcpu; + int buzy_count = 0; + int hostcpu; + + /*- This is a busy loop and must be fixed -*/ + for (vcpu = 0; vcpu < ncpu; vcpu++) + while (vcpu_is_running(vmx->vm, vcpu, &hostcpu)) + buzy_count++; + + printf("buzy_count waiting for vcpu stop is %d", buzy_count); + + /*- save all register and descriptor -*/ + for (vcpu = 0; vcpu < ncpu; vcpu++) { + vmx_getreg(arg, vcpu, VM_REG_GUEST_RAX, &(vmcpu[vcpu]->rax)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RBX, &(vmcpu[vcpu]->rbx)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RCX, &(vmcpu[vcpu]->rcx)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RDX, &(vmcpu[vcpu]->rdx)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RSI, &(vmcpu[vcpu]->rsi)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RDI, &(vmcpu[vcpu]->rdi)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RBP, &(vmcpu[vcpu]->rbp)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RSP, &(vmcpu[vcpu]->rsp)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R8, &(vmcpu[vcpu]->r8)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R9, &(vmcpu[vcpu]->r9)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R10, &(vmcpu[vcpu]->r10)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R11, &(vmcpu[vcpu]->r11)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R12, &(vmcpu[vcpu]->r12)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R13, &(vmcpu[vcpu]->r13)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R14, &(vmcpu[vcpu]->r14)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_R15, &(vmcpu[vcpu]->r15)); + + vmx_getreg(arg, vcpu, VM_REG_GUEST_CR0, &tmpreg); + vmcpu[vcpu]->cr0 = (uint32_t)tmpreg; + + vmx_getreg(arg, vcpu, VM_REG_GUEST_CR3, &tmpreg); + + vmcpu[vcpu]->cr3 = (uint32_t)tmpreg; + vmx_getreg(arg, vcpu, VM_REG_GUEST_CR4, &tmpreg); + vmcpu[vcpu]->cr4 = (uint32_t)tmpreg; + + vmx_getreg(arg, vcpu, VM_REG_GUEST_DR7, &(vmcpu[vcpu]->dr7)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RIP, &(vmcpu[vcpu]->rip)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_RFLAGS, &(vmcpu[vcpu]->rflags)); + vmx_getreg(arg, vcpu, VM_REG_GUEST_EFER, &(vmcpu[vcpu]->efer)); + + vmx_getseg(arg, vcpu, VM_REG_GUEST_ES, (vmcpu[vcpu]->es)); + vmx_getseg(arg, vcpu, VM_REG_GUEST_CS, (vmcpu[vcpu]->cs)); + vmx_getseg(arg, vcpu, VM_REG_GUEST_SS, (vmcpu[vcpu]->ss)); + vmx_getseg(arg, vcpu, VM_REG_GUEST_DS, (vmcpu[vcpu]->ds)); + vmx_getseg(arg, vcpu, VM_REG_GUEST_FS, (vmcpu[vcpu]->fs)); + vmx_getseg(arg, vcpu, VM_REG_GUEST_GS, (vmcpu[vcpu]->gs)); + + vmx_getseg(arg, vcpu, VM_REG_GUEST_TR, (vmcpu[vcpu]->tr)); + + vmx_getdesc(arg, vcpu, VM_REG_GUEST_LDTR, (vmcpu[vcpu]->ldtr)); + vmx_getdesc(arg, vcpu, VM_REG_GUEST_IDTR, (vmcpu[vcpu]->idtr)); + vmx_getdesc(arg, vcpu, VM_REG_GUEST_GDTR, (vmcpu[vcpu]->gdtr)); + } + + return 1; +} + struct vmm_ops vmm_ops_intel = { vmx_init, vmx_cleanup, @@ -1944,5 +2048,6 @@ vmx_setdesc, vmx_inject, vmx_getcap, - vmx_setcap + vmx_setcap, + vmx_cpu_regcopy }; Modified: soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.h ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.h Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/vmm/intel/vmx.h Sat Aug 3 13:06:28 2013 (r255481) @@ -91,6 +91,7 @@ struct vmxstate state[VM_MAXCPU]; struct vm *vm; }; + CTASSERT((offsetof(struct vmx, pml4ept) & PAGE_MASK) == 0); CTASSERT((offsetof(struct vmx, vmcs) & PAGE_MASK) == 0); CTASSERT((offsetof(struct vmx, msr_bitmap) & PAGE_MASK) == 0); Modified: soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm.c ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm.c Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm.c Sat Aug 3 13:06:28 2013 (r255481) @@ -64,6 +64,8 @@ #include "io/ppt.h" #include "io/iommu.h" +#include "vm_abststate.h" + struct vlapic; struct vcpu { @@ -101,6 +103,7 @@ * explicitly (AP) by sending it a startup ipi. */ cpuset_t active_cpus; + int control; }; static int vmm_initialized; @@ -110,8 +113,8 @@ #define VMM_CLEANUP() (ops != NULL ? (*ops->cleanup)() : 0) #define VMINIT(vm) (ops != NULL ? (*ops->vminit)(vm): NULL) -#define VMRUN(vmi, vcpu, rip) \ - (ops != NULL ? (*ops->vmrun)(vmi, vcpu, rip) : ENXIO) +#define VMRUN(vmi, vcpu, rip, control) \ + (ops != NULL ? (*ops->vmrun)(vmi, vcpu, rip, control) : ENXIO) #define VMCLEANUP(vmi) (ops != NULL ? (*ops->vmcleanup)(vmi) : NULL) #define VMMMAP_SET(vmi, gpa, hpa, len, attr, prot, spm) \ (ops != NULL ? \ @@ -134,10 +137,14 @@ #define VMSETCAP(vmi, vcpu, num, val) \ (ops != NULL ? (*ops->vmsetcap)(vmi, vcpu, num, val) : ENXIO) +#define VREG_COPY(vmi, ncpu, vregs) \ + (ops != NULL ? (*ops->vreg_copy)(vmi, ncpu, vregs) : ENXIO) + #define fpu_start_emulating() load_cr0(rcr0() | CR0_TS) #define fpu_stop_emulating() clts() static MALLOC_DEFINE(M_VM, "vm", "vm"); +static MALLOC_DEFINE(M_VMREGISTERS, "vreg", "snapshot image of virual cpu"); CTASSERT(VMM_MSR_NUM <= 64); /* msr_mask can keep track of up to 64 msrs */ /* statistics */ @@ -632,6 +639,82 @@ static VMM_STAT(VCPU_IDLE_TICKS, "number of ticks vcpu was idle"); + +static struct vm_registers** +construct_vmcpu_snapshot(const int ncpu) +{ + int i = 0; + struct vm_registers **vmcpu = + malloc(ncpu * sizeof(struct vm_registers*), + M_VMREGISTERS, M_ZERO | M_WAITOK); + + for (;i < ncpu; i++){ + vmcpu[i] = + malloc(sizeof(struct vm_registers), M_VMREGISTERS, M_ZERO | M_WAITOK); + + vmcpu[i]->cs = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->ds = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->ss = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->es = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->fs = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->gs = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->tr = + malloc(sizeof(struct segment_register), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->gdtr = + malloc(sizeof(struct seg_desc), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->ldtr = + malloc(sizeof(struct seg_desc), M_VMREGISTERS, + M_ZERO | M_WAITOK); + + vmcpu[i]->idtr = + malloc(sizeof(struct seg_desc), M_VMREGISTERS, + M_ZERO | M_WAITOK); + } + return vmcpu; +} + +static void +destruct_vmcpu_snapshot(struct vm_registers *vmcpu[], int ncpu) +{ + int i = 0; + for (;i < ncpu; i++) { + free(vmcpu[i]->cs, M_VMREGISTERS); + free(vmcpu[i]->ds, M_VMREGISTERS); + free(vmcpu[i]->ss, M_VMREGISTERS); + free(vmcpu[i]->es, M_VMREGISTERS); + free(vmcpu[i]->fs, M_VMREGISTERS); + free(vmcpu[i]->gs, M_VMREGISTERS); + free(vmcpu[i]->tr, M_VMREGISTERS); + free(vmcpu[i]->gdtr, M_VMREGISTERS); + free(vmcpu[i]->ldtr, M_VMREGISTERS); + free(vmcpu[i]->idtr, M_VMREGISTERS); + free(vmcpu[i], M_VMREGISTERS); + } + free(vmcpu, M_VMREGISTERS); +} + int vm_run(struct vm *vm, struct vm_run *vmrun) { @@ -661,7 +744,7 @@ restore_guest_fpustate(vcpu); vcpu->hostcpu = curcpu; - error = VMRUN(vm->cookie, vcpuid, rip); + error = VMRUN(vm->cookie, vcpuid, rip, &(vm->control)); vcpu->hostcpu = NOCPU; save_guest_fpustate(vcpu); @@ -715,6 +798,10 @@ rip = vme->rip + vme->inst_length; goto restart; } + if (error == VM_SUSPEND) { + /*- stab -*/ + printf("hook"); + } return (error); } @@ -997,3 +1084,71 @@ } vcpu_unlock(vcpu); } + +int +vm_save_vcpustate(struct vm *vm, int ncpu, struct vm_vcpustate *vmcpu) +{ + int ret; + int vcpuid; + struct segment_register *cs, *ds, *ss, *es, *fs, *gs; + struct vm_registers **vmregs; + struct vm_vcpustate kvmcpu; + struct vm_registers kvmregs; + struct vcpu *vcpu, *kvcpu; + + vm->control = REQ_SUSPEND; + + for (vcpuid = 0; vcpuid < ncpu; vcpuid++) + vm_interrupt_hostcpu(vm, vcpuid); + + vmregs = construct_vmcpu_snapshot(2); + ret = VREG_COPY(vm->cookie, ncpu, vmregs); + printf("vmcpu is %p", vmcpu); + copyin(vmcpu, &kvmcpu, sizeof(struct vm_vcpuidstate)); + printf("vreg is %p", kvmcpu.regs); + + for (vcpuid = 0; vcpuid < ncpu; vcpuid++) { + vcpu = &vm->vcpu[vcpuid]; + printf("start to copy in\n"); +/* vm_segment_registers */ + printf("1 to copy in\n"); + copyin(kvmcpu.regs, &kvmregs, + sizeof(struct vm_vcpuidstate)); + + printf("rax=%lu\n", kvmregs.rax); + + printf("start to copy out\n"); +/* vm_segment_registers */ + copyout(vmregs[vcpuid]->cs, cs = kvmregs.cs, + sizeof(struct segment_register)); + printf("1 to copy out\n"); + copyout(vmregs[vcpuid]->ds, ds = kvmregs.ds, + sizeof(struct segment_register)); + copyout(vmregs[vcpuid]->ss, ss = kvmregs.ss, + sizeof(struct segment_register)); + copyout(vmregs[vcpuid]->es, es = kvmregs.es, + sizeof(struct segment_register)); + copyout(vmregs[vcpuid]->fs, fs = kvmregs.fs, + sizeof(struct segment_register)); + copyout(vmregs[vcpuid]->gs, gs = kvmregs.gs, + sizeof(struct segment_register)); + copyout(vcpu->guestfpu, kvcpu = kvmregs.vfpu, + sizeof(struct segment_register*)); + + copyout(vmregs[vcpuid], vmcpu->regs, sizeof(struct vm_registers)); + + copyout(&cs, &(kvmregs.cs), sizeof(struct segment_register*)); + copyout(&ds, &(kvmregs.ds), sizeof(struct segment_register*)); + copyout(&ss, &(kvmregs.ss), sizeof(struct segment_register*)); + copyout(&es, &(kvmregs.es), sizeof(struct segment_register*)); + copyout(&fs, &(kvmregs.fs), sizeof(struct segment_register*)); + copyout(&gs, &(kvmregs.gs), sizeof(struct segment_register*)); + + + vmcpu = kvmcpu.nextcpu; + } + + destruct_vmcpu_snapshot(vmregs, ncpu); + return ret; +}; + Modified: soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm_dev.c ============================================================================== --- soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm_dev.c Sat Aug 3 12:45:00 2013 (r255480) +++ soc2013/iori/suspendresume/head/sys/amd64/vmm/vmm_dev.c Sat Aug 3 13:06:28 2013 (r255481) @@ -54,6 +54,7 @@ #include "vmm_mem.h" #include "io/ppt.h" #include +#include "vm_abststate.h" struct vmmdev_softc { struct vm *vm; /* vm instance cookie */ @@ -156,6 +157,7 @@ struct vm_stats *vmstats; struct vm_stat_desc *statdesc; struct vm_x2apic *x2apic; + struct vmstate *vmstate; sc = vmmdev_lookup2(cdev); if (sc == NULL) @@ -219,6 +221,7 @@ if (error) { while (--vcpu >= 0) vcpu_set_state(sc->vm, vcpu, VCPU_IDLE); + printf("vm busy. cmd: %lx\n", cmd); goto done; } @@ -348,6 +351,11 @@ error = vm_get_x2apic_state(sc->vm, x2apic->cpuid, &x2apic->state); break; + case VM_SAVE_VCPUSTATE: + vmstate = (struct vmstate *)data; + vmstate->bhyve_version = 0; + error = vm_save_vcpustate(sc->vm, vmstate->ncpu, vmstate->vmcpu); + break; default: error = ENOTTY; break;