From owner-svn-soc-all@FreeBSD.ORG Sun Sep 1 08:10: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 8862D7FE for ; Sun, 1 Sep 2013 08:10:06 +0000 (UTC) (envelope-from oleksandr@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 686ED2CDE for ; Sun, 1 Sep 2013 08:10: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 r818A66o034478 for ; Sun, 1 Sep 2013 08:10:06 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r818A6Ze034458 for svn-soc-all@FreeBSD.org; Sun, 1 Sep 2013 08:10:06 GMT (envelope-from oleksandr@FreeBSD.org) Date: Sun, 1 Sep 2013 08:10:06 GMT Message-Id: <201309010810.r818A6Ze034458@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to oleksandr@FreeBSD.org using -f From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256792 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files 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, 01 Sep 2013 08:10:06 -0000 Author: oleksandr Date: Sun Sep 1 08:10:06 2013 New Revision: 256792 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256792 Log: Correct name of file's and structure's remplace allocating of memory to malloc(9) incstead of RTMemAllocZ() virtualbox internal function Modified: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Modified: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk ============================================================================== --- soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Sun Sep 1 07:57:53 2013 (r256791) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Sun Sep 1 08:10:06 2013 (r256792) @@ -1,43 +1,426 @@ +Index: src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk +=================================================================== +--- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk (revision 4) ++++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk (working copy) +@@ -32,13 +32,14 @@ + . \ + $(vboxvfs_0_OUTDIR) + vboxvfs_SOURCES = \ +- vboxvfs_vfsops.c \ +- vboxvfs_vnops.c ++ vboxfs_vfsops.c \ ++ vboxfs_vnops.c \ ++ vboxfs_prov.c + vboxvfs_LIBS = \ + $(VBOX_LIB_VBGL_R0) \ + $(VBOX_LIB_IPRT_GUEST_R0) + vboxvfs_DEPS = \ +- $$(vboxvfs_0_OUTDIR)/vnode_if.h \ ++# $$(vboxvfs_0_OUTDIR)/vnode_if.h \ + $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \ + $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h + vboxvfs_CLEAN += $(vboxvfs_DEPS) +Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c +=================================================================== +--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (revision 4) ++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (working copy) +@@ -1,241 +0,0 @@ +-/* $Id: vboxvfs_vnops.c $ */ +-/** @file +- * Description. +- */ +- +-/* +- * Copyright (C) 2008-2010 Oracle Corporation +- * +- * This file is part of VirtualBox Open Source Edition (OSE), as +- * available from http://www.virtualbox.org. This file is free software; +- * you can redistribute it and/or modify it under the terms of the GNU +- * General Public License (GPL) as published by the Free Software +- * Foundation, in version 2 as it comes in the "COPYING" file of the +- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the +- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +- */ +- +-#include "vboxvfs.h" +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +-#include +- +-/* +- * Prototypes for VBOXVFS vnode operations +- */ +-static vop_create_t vboxvfs_create; +-static vop_mknod_t vboxvfs_mknod; +-static vop_open_t vboxvfs_open; +-static vop_close_t vboxvfs_close; +-static vop_access_t vboxvfs_access; +-static vop_getattr_t vboxvfs_getattr; +-static vop_setattr_t vboxvfs_setattr; +-static vop_read_t vboxvfs_read; +-static vop_write_t vboxvfs_write; +-static vop_fsync_t vboxvfs_fsync; +-static vop_remove_t vboxvfs_remove; +-static vop_link_t vboxvfs_link; +-static vop_lookup_t vboxvfs_lookup; +-static vop_rename_t vboxvfs_rename; +-static vop_mkdir_t vboxvfs_mkdir; +-static vop_rmdir_t vboxvfs_rmdir; +-static vop_symlink_t vboxvfs_symlink; +-static vop_readdir_t vboxvfs_readdir; +-static vop_strategy_t vboxvfs_strategy; +-static vop_print_t vboxvfs_print; +-static vop_pathconf_t vboxvfs_pathconf; +-static vop_advlock_t vboxvfs_advlock; +-static vop_getextattr_t vboxvfs_getextattr; +-static vop_ioctl_t vboxvfs_ioctl; +-static vop_getpages_t vboxvfs_getpages; +-static vop_inactive_t vboxvfs_inactive; +-static vop_putpages_t vboxvfs_putpages; +-static vop_reclaim_t vboxvfs_reclaim; +- +-struct vop_vector vboxvfs_vnodeops = { +- .vop_default = &default_vnodeops, +- +- .vop_access = vboxvfs_access, +- .vop_advlock = vboxvfs_advlock, +- .vop_close = vboxvfs_close, +- .vop_create = vboxvfs_create, +- .vop_fsync = vboxvfs_fsync, +- .vop_getattr = vboxvfs_getattr, +- .vop_getextattr = vboxvfs_getextattr, +- .vop_getpages = vboxvfs_getpages, +- .vop_inactive = vboxvfs_inactive, +- .vop_ioctl = vboxvfs_ioctl, +- .vop_link = vboxvfs_link, +- .vop_lookup = vboxvfs_lookup, +- .vop_mkdir = vboxvfs_mkdir, +- .vop_mknod = vboxvfs_mknod, +- .vop_open = vboxvfs_open, +- .vop_pathconf = vboxvfs_pathconf, +- .vop_print = vboxvfs_print, +- .vop_putpages = vboxvfs_putpages, +- .vop_read = vboxvfs_read, +- .vop_readdir = vboxvfs_readdir, +- .vop_reclaim = vboxvfs_reclaim, +- .vop_remove = vboxvfs_remove, +- .vop_rename = vboxvfs_rename, +- .vop_rmdir = vboxvfs_rmdir, +- .vop_setattr = vboxvfs_setattr, +- .vop_strategy = vboxvfs_strategy, +- .vop_symlink = vboxvfs_symlink, +- .vop_write = vboxvfs_write, +-}; +- +-static int vboxvfs_access(struct vop_access_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_open(struct vop_open_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_close(struct vop_close_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_getattr(struct vop_getattr_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_setattr(struct vop_setattr_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_read(struct vop_read_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_write(struct vop_write_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_create(struct vop_create_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_remove(struct vop_remove_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_rename(struct vop_rename_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_link(struct vop_link_args *ap) +-{ +- return EOPNOTSUPP; +-} +- +-static int vboxvfs_symlink(struct vop_symlink_args *ap) +-{ +- return EOPNOTSUPP; +-} +- +-static int vboxvfs_mknod(struct vop_mknod_args *ap) +-{ +- return EOPNOTSUPP; +-} +- +-static int vboxvfs_mkdir(struct vop_mkdir_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_rmdir(struct vop_rmdir_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_readdir(struct vop_readdir_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_fsync(struct vop_fsync_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_print (struct vop_print_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_pathconf (struct vop_pathconf_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_strategy (struct vop_strategy_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_ioctl(struct vop_ioctl_args *ap) +-{ +- return ENOTTY; +-} +- +-static int vboxvfs_getextattr(struct vop_getextattr_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_advlock(struct vop_advlock_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_lookup(struct vop_lookup_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_inactive(struct vop_inactive_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_reclaim(struct vop_reclaim_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_getpages(struct vop_getpages_args *ap) +-{ +- return 0; +-} +- +-static int vboxvfs_putpages(struct vop_putpages_args *ap) +-{ +- return 0; +-} +- +Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h +=================================================================== +--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (revision 4) ++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (working copy) +@@ -1,92 +0,0 @@ +-/* $Id: vboxvfs.h $ */ +-/** @file +- * Description. +- */ +- +-/* +- * Copyright (C) 2010 Oracle Corporation +- * +- * This file is part of VirtualBox Open Source Edition (OSE), as +- * available from http://www.virtualbox.org. This file is free software; +- * you can redistribute it and/or modify it under the terms of the GNU +- * General Public License (GPL) as published by the Free Software +- * Foundation, in version 2 as it comes in the "COPYING" file of the +- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the +- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +- */ +- +-#ifndef ___VBOXVFS_H___ +-#define ___VBOXVFS_H___ +- +-#define VBOXVFS_VFSNAME "vboxvfs" +-#define VBOXVFS_VERSION 1 +- +-#define MAX_HOST_NAME 256 +-#define MAX_NLS_NAME 32 +- +-struct vboxvfs_mount_info { +- char name[MAX_HOST_NAME]; +- char nls_name[MAX_NLS_NAME]; +- int uid; +- int gid; +- int ttl; +-}; +- +-#ifdef _KERNEL +- +-#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" +-#include +-#include +- +-struct vboxvfsmount { +- uid_t uid; +- gid_t gid; +- mode_t file_mode; +- mode_t dir_mode; +- struct mount *mp; +- struct ucred *owner; +- u_int flags; +- long nextino; +- int caseopt; +- int didrele; +-}; +- +-/* structs - stolen from the linux shared module code */ +-struct sf_glob_info { +- VBSFMAP map; +-/* struct nls_table *nls;*/ +- int ttl; +- int uid; +- int gid; +- struct vnode *vnode_root; +-}; +- +-struct sf_inode_info { +- SHFLSTRING *path; +- int force_restat; +-}; +- +-#if 0 +-struct sf_dir_info { +- struct list_head info_list; +-}; +-#endif +- +-struct sf_dir_buf { +- size_t nb_entries; +- size_t free_bytes; +- size_t used_bytes; +- void *buf; +-#if 0 +- struct list_head head; +-#endif +-}; +- +-struct sf_reg_info { +- SHFLHANDLE handle; +-}; +- +-#endif /* KERNEL */ +- +-#endif /* !___VBOXVFS_H___ */ +- Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (working copy) -@@ -14,13 +14,13 @@ - * VirtualBox OSE distribution. VirtualBox OSE is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. - */ +@@ -1,258 +0,0 @@ +-/* $Id: vboxvfs_vfsops.c $ */ +-/** @file +- * Description. +- */ +- +-/* +- * Copyright (C) 2008-2010 Oracle Corporation +- * +- * This file is part of VirtualBox Open Source Edition (OSE), as +- * available from http://www.virtualbox.org. This file is free software; +- * you can redistribute it and/or modify it under the terms of the GNU +- * General Public License (GPL) as published by the Free Software +- * Foundation, in version 2 as it comes in the "COPYING" file of the +- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the +- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +- */ - -#include "vboxvfs.h" -+#include - #include - #include - #include - #include - #include -+#include - #include - #include - #include -@@ -29,10 +29,14 @@ - #include - #include - +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- -#include -+#include "vboxvfs.h" - - #define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data) - -+#ifdef MALLOC_DECLARE -+MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS"); -+#endif -+ - static int vboxvfs_version = VBOXVFS_VERSION; - - SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); -@@ -51,15 +55,15 @@ - static vfs_unmount_t vboxvfs_unmount; - - static struct vfsops vboxvfs_vfsops = { +- +-#define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data) +- +-static int vboxvfs_version = VBOXVFS_VERSION; +- +-SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); +-SYSCTL_INT(_vfs_vboxvfs, OID_AUTO, version, CTLFLAG_RD, &vboxvfs_version, 0, ""); +- +-/* global connection to the host service. */ +-static VBSFCLIENT g_vboxSFClient; +- +-static vfs_init_t vboxvfs_init; +-static vfs_uninit_t vboxvfs_uninit; +-static vfs_cmount_t vboxvfs_cmount; +-static vfs_mount_t vboxvfs_mount; +-static vfs_root_t vboxvfs_root; +-static vfs_quotactl_t vboxvfs_quotactl; +-static vfs_statfs_t vboxvfs_statfs; +-static vfs_unmount_t vboxvfs_unmount; +- +-static struct vfsops vboxvfs_vfsops = { - .vfs_init = vboxvfs_init, - .vfs_cmount = vboxvfs_cmount, - .vfs_mount = vboxvfs_mount, @@ -47,66 +430,40 @@ - .vfs_sync = vfs_stdsync, - .vfs_uninit = vboxvfs_uninit, - .vfs_unmount = vboxvfs_unmount, -+ .vfs_init = vboxvfs_init, -+ .vfs_cmount = vboxvfs_cmount, -+ .vfs_mount = vboxvfs_mount, -+ .vfs_quotactl = vboxvfs_quotactl, -+ .vfs_root = vboxvfs_root, -+ .vfs_statfs = vboxvfs_statfs, -+ .vfs_sync = vfs_stdsync, -+ .vfs_uninit = vboxvfs_uninit, -+ .vfs_unmount = vboxvfs_unmount, - }; - - -@@ -66,193 +70,239 @@ - VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK); - MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1); - +-}; +- +- +-VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK); +-MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1); +- -static int vboxvfs_cmount(struct mntarg *ma, void * data, int flags, struct thread *td) -+static int vboxvfs_cmount(struct mntarg *ma, void *data, uint64_t flags) - { +-{ - struct vboxvfs_mount_info args; - int rc = 0; -+ struct vboxvfs_mount_info args; -+ int rc = 0; - +- - printf("%s: Enter\n", __FUNCTION__); -+ printf("%s: Enter\n", __FUNCTION__); - +- - rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info)); - if (rc) - return rc; -+ rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info)); -+ if (rc) -+ return (rc); - +- - ma = mount_argf(ma, "uid", "%d", args.uid); - ma = mount_argf(ma, "gid", "%d", args.gid); - ma = mount_arg(ma, "from", args.name, -1); -+ ma = mount_argf(ma, "uid", "%d", args.uid); -+ ma = mount_argf(ma, "gid", "%d", args.gid); -+ ma = mount_arg(ma, "from", args.name, -1); - +- - rc = kernel_mount(ma, flags); -+ rc = kernel_mount(ma, flags); - +- - printf("%s: Leave rc=%d\n", __FUNCTION__, rc); -+ printf("%s: Leave rc=%d\n", __FUNCTION__, rc); - +- - return rc; -} -+ return (rc); -+}; - - static const char *vboxvfs_opts[] = { +- +-static const char *vboxvfs_opts[] = { - "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL -+ "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL - }; - +-}; +- -static int vboxvfs_mount(struct mount *mp, struct thread *td) -+static int vboxvfs_mount(struct mount *mp) - { +-{ - int rc; - char *pszShare; - int cbShare, cbOption; @@ -114,228 +471,126 @@ - struct sf_glob_info *pShFlGlobalInfo; - SHFLSTRING *pShFlShareName = NULL; - int cbShFlShareName; -+ int rc; -+ char *pszShare; -+ int cbShare, cbOption; -+ int uid = 0, gid = 0; -+ struct sf_glob_info *pShFlGlobalInfo; -+ SHFLSTRING *pShFlShareName = NULL; -+ int cbShFlShareName; - +- - printf("%s: Enter\n", __FUNCTION__); -+ printf("%s: Enter\n", __FUNCTION__); -+ - +- - if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) - return EOPNOTSUPP; -+ if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) -+ return (EOPNOTSUPP); - +- - if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts)) - { - vfs_mount_error(mp, "%s", "Invalid option"); - return EINVAL; - } -+ if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts)) -+ { -+ vfs_mount_error(mp, "%s", "Invalid option"); -+ return (EINVAL); -+ } - +- - rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare); - if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe) - return EINVAL; -+ rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare); -+ if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe) -+ return (EINVAL); - +- - rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption); - if ((rc != ENOENT) && (rc || cbOption != sizeof(gid))) - return EINVAL; -+ rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption); -+ if ((rc != ENOENT) && (rc || cbOption != sizeof(gid))) -+ return EINVAL; - +- - rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption); - if ((rc != ENOENT) && (rc || cbOption != sizeof(uid))) - return EINVAL; -+ rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption); -+ if ((rc != ENOENT) && (rc || cbOption != sizeof(uid))) -+ return EINVAL; - +- - pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); - if (!pShFlGlobalInfo) - return ENOMEM; -+ pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); -+ if (!pShFlGlobalInfo) -+ return ENOMEM; - +- - cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1; - pShFlShareName = RTMemAllocZ(cbShFlShareName); - if (!pShFlShareName) - return VERR_NO_MEMORY; -+ cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1; -+ pShFlShareName = RTMemAllocZ(cbShFlShareName); -+ if (!pShFlShareName) -+ return VERR_NO_MEMORY; - +- - pShFlShareName->u16Length = cbShFlShareName; - pShFlShareName->u16Size = cbShFlShareName + 1; - memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1); -+ pShFlShareName->u16Length = cbShFlShareName; -+ pShFlShareName->u16Size = cbShFlShareName + 1; -+ memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1); - +- - rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); - RTMemFree(pShFlShareName); -+ rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); -+ RTMemFree(pShFlShareName); - +- - if (RT_FAILURE (rc)) - { - RTMemFree(pShFlGlobalInfo); - printf("vboxCallMapFolder failed rc=%d\n", rc); - return EPROTO; - } -+ if (RT_FAILURE (rc)) -+ { -+ RTMemFree(pShFlGlobalInfo); -+ printf("vboxCallMapFolder failed rc=%d\n", rc); -+ return (EPROTO); -+ } - +- - pShFlGlobalInfo->uid = uid; - pShFlGlobalInfo->gid = gid; -+ pShFlGlobalInfo->uid = uid; -+ pShFlGlobalInfo->gid = gid; - +- - mp->mnt_data = pShFlGlobalInfo; -+ mp->mnt_data = pShFlGlobalInfo; - +- - /* @todo root vnode. */ -+ /* @todo root vnode. */ - +- - vfs_getnewfsid(mp); - vfs_mountedfrom(mp, pszShare); -+ vfs_getnewfsid(mp); -+ vfs_mountedfrom(mp, pszShare); - +- - printf("%s: Leave rc=0\n", __FUNCTION__); -+ printf("%s: Leave rc=0\n", __FUNCTION__); - +- - return 0; -} -+ return (0); -+}; - +- -static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td) -+/* -+ * Unmount a shared folder. -+ * -+ * vboxvfs_unmount umounts the mounted file system. It return 0 -+ * on sucess and any relevant errno on failure. -+ */ -+static int vboxvfs_unmount(struct mount *mp, int mntflags) - { +-{ - struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); - int rc; - int flags = 0; -+ struct thread *td = curthread; -+ struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); -+/* struct vboxvfs_mnt *vboxvfsmp; */ -+ int error; -+ int flags = 0; -+ -+/* vboxvfsmp = VFSTOVBOXFS(mp); */ - +- - rc = vboxCallUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map); - if (RT_FAILURE(rc)) - printf("Failed to unmap shared folder\n"); -+ error = vboxCallUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map); -+ if (RT_FAILURE(error)) -+ printf("Failed to unmap shared folder\n"); - +- - if (mntflags & MNT_FORCE) - flags |= FORCECLOSE; -+ if (mntflags & MNT_FORCE) -+ flags |= FORCECLOSE; - +- - /* There is 1 extra root vnode reference (vnode_root). */ - rc = vflush(mp, 1, flags, td); - if (rc) - return rc; -+ /* There is 1 extra root vnode reference (vnode_root). */ -+ error = vflush(mp, 1, flags, td); -+ if (error) -+ return (error); - - +- +- - RTMemFree(pShFlGlobalInfo); - mp->mnt_data = NULL; -+ RTMemFree(pShFlGlobalInfo); -+ mp->mnt_data = NULL; - +- - return 0; -+ return (0); - } - +-} +- -static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) -+static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp) - { +-{ - int rc = 0; - struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); - struct vnode *vp; -+ int rc = 0; -+ struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); -+ struct vnode *vp; - +- - printf("%s: Enter\n", __FUNCTION__); -+ printf("%s: Enter\n", __FUNCTION__); - +- - vp = pShFlGlobalInfo->vnode_root; - VREF(vp); -+ vp = pShFlGlobalInfo->vnode_root; -+ VREF(vp); - +- - vn_lock(vp, flags | LK_RETRY, td); - *vpp = vp; -+// vn_lock(vp, flags | LK_RETRY, td); -+ *vpp = vp; - +- - printf("%s: Leave\n", __FUNCTION__); -+ printf("%s: Leave\n", __FUNCTION__); - +- - return rc; -+ return (rc); - } - +-} +- -static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td) -+/* -+ * Do operation associated with quotas, not supported -+ */ -+static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg) - { +-{ - return EOPNOTSUPP; -+ return (EOPNOTSUPP); - } - - int vboxvfs_init(struct vfsconf *vfsp) - { +-} +- +-int vboxvfs_init(struct vfsconf *vfsp) +-{ - int rc; -+ int rc = -1; - +- - /* Initialize the R0 guest library. */ - rc = vboxInit(); - if (RT_FAILURE(rc)) - return ENXIO; -+ /* Initialize the R0 guest library. */ -+ rc = vboxInit(); -+ if (RT_FAILURE(rc)) -+ { -+ printf("sfprov_connect: vboxConnect() failed rc=%d\n", rc); -+ return ENXIO; -+ } - +- - /* Connect to the host service. */ - rc = vboxConnect(&g_vboxSFClient); - if (RT_FAILURE(rc)) @@ -344,15 +599,7 @@ - vboxUninit(); - return ENXIO; - } -+ /* Connect to the host service. */ -+ rc = vboxConnect(&g_vboxSFClient); -+ if (RT_FAILURE(rc)) -+ { -+ printf("Failed to get connection to host! rc=%d\n", rc); -+ vboxUninit(); -+ return ENXIO; -+ } - +- - rc = vboxCallSetUtf8 (&g_vboxSFClient); - if (RT_FAILURE (rc)) - { @@ -361,95 +608,62 @@ - vboxUninit(); - return EPROTO; - } -+ rc = vboxCallSetUtf8 (&g_vboxSFClient); -+ if (RT_FAILURE (rc)) -+ { -+ printf("vboxCallSetUtf8 failed, rc=%d\n", rc); -+ vboxDisconnect(&g_vboxSFClient); -+ vboxUninit(); -+ return EPROTO; -+ } - +- - printf("Successfully loaded shared folder module\n"); -+ printf("Successfully loaded shared folder module\n"); - +- - return 0; -+ return (0); - } - - int vboxvfs_uninit(struct vfsconf *vfsp) - { +-} +- +-int vboxvfs_uninit(struct vfsconf *vfsp) +-{ - vboxDisconnect(&g_vboxSFClient); - vboxUninit(); -+ vboxDisconnect(&g_vboxSFClient); -+ vboxUninit(); - +- - return 0; -+ return (0); - } - +-} +- -int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) -+/* -+ * Get filesystem statistics. -+ */ -+int vboxvfs_statfs(struct mount *mp, struct statfs *sbp) - { +-{ - return 0; -+ struct vboxvfs_mnt *vboxvfsmp; -+ sffs_fsinfo_t fsinfo; -+// dev32_t d32; -+ int error; -+ -+ vboxvfsmp = VFSTOVBOXFS(mp); -+ -+ bzero(sbp, sizeof(*sbp)); -+ error = sfprov_get_fsinfo(vboxvfsmp->sf_handle, &fsinfo); -+ if (error != 0) -+ return (error); +-} +Index: src/VBox/Additions/freebsd/vboxvfs/vboxfs.h +=================================================================== +--- src/VBox/Additions/freebsd/vboxvfs/vboxfs.h (revision 0) ++++ src/VBox/Additions/freebsd/vboxvfs/vboxfs.h (working copy) +@@ -0,0 +1,326 @@ ++/* $Id: vboxfs.h $ */ ++/** @file ++ * Description. ++ */ + -+ sbp->f_bsize = fsinfo.blksize; ++/* ++ * Copyright (C) 2010 Oracle Corporation ++ * ++ * This file is part of VirtualBox Open Source Edition (OSE), as ++ * available from http://www.virtualbox.org. This file is free software; ++ * you can redistribute it and/or modify it under the terms of the GNU ++ * General Public License (GPL) as published by the Free Software ++ * Foundation, in version 2 as it comes in the "COPYING" file of the ++ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the ++ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ++ */ + -+ sbp->f_bfree = fsinfo.blksavail; -+ sbp->f_bavail = fsinfo.blksavail; -+ sbp->f_files = fsinfo.blksavail / 4; /* some kind of reasonable value */ -+ sbp->f_ffree = fsinfo.blksavail / 4; ++#ifndef ___VBOXVFS_H___ ++#define ___VBOXVFS_H___ + -+ sbp->f_blocks = fsinfo.blksused + sbp->f_bavail; -+#if 0 -+ (void) cmpldev(&d32, vfsp->vfs_dev); -+ sbp->f_fsid = d32; -+#endif -+ sbp->f_namemax = fsinfo.maxnamesize; ++#define VBOXVFS_VFSNAME "vboxfs" ++#define VBOXVFS_VERSION 1 + -+ return (0); - } -Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h -=================================================================== ---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (revision 4) -+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (working copy) -@@ -21,46 +21,200 @@ - #define VBOXVFS_VFSNAME "vboxvfs" - #define VBOXVFS_VERSION 1 - --#define MAX_HOST_NAME 256 --#define MAX_NLS_NAME 32 +#define MAX_HOST_NAME 256 +#define MAX_NLS_NAME 32 +//#define MODEMASK 07777 /* mode bits plus permission bits */ +/** Helper macros */ -+#define VFSTOVBOXFS(mp) ((struct vboxvfs_mnt *)((mp)->mnt_data)) -+#define VTOVBOXFS(vp) ((struct vboxvfs_node *)(vp)->v_data) - --struct vboxvfs_mount_info { -- char name[MAX_HOST_NAME]; -- char nls_name[MAX_NLS_NAME]; -- int uid; -- int gid; -- int ttl; --}; ++#define VFSTOVBOXFS(mp) ((struct vboxfs_mnt *)((mp)->mnt_data)) ++#define VTOVBOXFS(vp) ((struct vboxfs_node *)(vp)->v_data) ++ +MALLOC_DECLARE(M_VBOXVFS); - - #ifdef _KERNEL ++ ++#ifdef _KERNEL +#include "../../../../../include/iprt/nocrt/limits.h" +#include "../../../../../include/iprt/alloc.h" +#include "../../../../../include/iprt/asm.h" @@ -492,33 +706,20 @@ +#include "../../../../../include/iprt/time.h" +#include "../../../../../include/iprt/types.h" +#include "../../../../../include/iprt/uni.h" - ++ +#include "../../common/VBoxGuestLib/SysHlp.h" - #include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" - #include --#include ++#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" ++#include +#include +#include - --struct vboxvfsmount { -- uid_t uid; -- gid_t gid; -- mode_t file_mode; -- mode_t dir_mode; -- struct mount *mp; -- struct ucred *owner; -- u_int flags; -- long nextino; -- int caseopt; -- int didrele; ++ +/* + * representation of an active mount point *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Sun Sep 1 15:47:14 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 DEF42702 for ; Sun, 1 Sep 2013 15:47:14 +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 BBF2D2414 for ; Sun, 1 Sep 2013 15:47:14 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r81FlES9094021 for ; Sun, 1 Sep 2013 15:47:14 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r81FlEAg094015 for svn-soc-all@FreeBSD.org; Sun, 1 Sep 2013 15:47:14 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 1 Sep 2013 15:47:14 GMT Message-Id: <201309011547.r81FlEAg094015@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: r256802 - 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, 01 Sep 2013 15:47:14 -0000 Author: mattbw Date: Sun Sep 1 15:47:14 2013 New Revision: 256802 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256802 Log: Move namever-related jobs/pkgutils functions to namever. namever now depends on PackageKit, but not the packagekit backend. Modified: soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/namever.c soc2013/mattbw/backend/namever.h soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sun Sep 1 14:28:12 2013 (r256801) +++ soc2013/mattbw/backend/jobs.c Sun Sep 1 15:47:14 2013 (r256802) @@ -30,12 +30,11 @@ #include "db.h" /* db_... */ #include "emit.h" /* emit_package */ #include "event.h" /* event_cb */ -#include "utils.h" /* ERR, type_of_repo_name */ #include "jobs.h" /* jobs_... */ #include "jobs/check.h" /* jobs_check_... */ +#include "namever.h" /* namever_* */ #include "pkgutils.h" /* pkgutils_... */ - -static char **namevers_from_package_ids(gchar **package_ids, guint count); +#include "utils.h" /* ERR, type_of_repo_name */ static const char *APPLY_ERRORS[] = { "This shouldn't occur and is a bug.", /* EPKG_OK */ @@ -122,11 +121,11 @@ if (count > 0) { int err; - namevers = namevers_from_package_ids(package_ids, count); + namevers = namever_array_from_package_ids(package_ids, count); err = pkg_jobs_add(jobs, MATCH_EXACT, namevers, (int)count); if (err != EPKG_OK) { - jobs_free_namevers(&namevers, count); + namever_array_free(&namevers, count); } } @@ -151,21 +150,6 @@ } } -void -jobs_free_namevers(char ***namevers_p, guint count) -{ - unsigned int i; - - assert(namevers_p != NULL); - - if (*namevers_p != NULL) { - for (i = 0; i < count; i++) - free(*namevers_p[i]); - free(*namevers_p); - *namevers_p = NULL; - } -} - /* Overly safe wrapper around pkg_jobs_new. */ struct pkg_jobs * jobs_allocate(pkg_jobs_t type, struct pkgdb *db) @@ -196,24 +180,3 @@ pkg_jobs_free(*jobs_p); *jobs_p = NULL; } - -static char ** -namevers_from_package_ids(gchar **package_ids, guint count) -{ - char **namevers; - unsigned int i; - - namevers = calloc(count, sizeof(char *)); - if (namevers != NULL) { - for (i = 0; i < count; i++) { - namevers[i] = pkgutils_package_id_namever( - package_ids[i]); - if (namevers[i] == NULL) { - jobs_free_namevers(&namevers, count); - break; - } - } - } - - return namevers; -} Modified: soc2013/mattbw/backend/namever.c ============================================================================== --- soc2013/mattbw/backend/namever.c Sun Sep 1 14:28:12 2013 (r256801) +++ soc2013/mattbw/backend/namever.c Sun Sep 1 15:47:14 2013 (r256802) @@ -19,15 +19,17 @@ */ #include /* assert */ +#include /* gchar, guint */ #include /* asprintf */ #include "pkg.h" /* pkg_... */ +#include "pk-backend.h" /* pk_* */ #include "namever.h" /* namever_... */ /* * Functions for dealing with "namevers" (name-version strings). * - * This file CANNOT depend on PackageKit. + * This file CANNOT depend on the PackageKit backend. */ /* @@ -64,3 +66,68 @@ (void)pkg_asprintf(&result, "%n-%v", package, package); return result; } + +/* + * 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 * +namever_from_package_id(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 = namever_from_name_and_version(id_splits[PK_PACKAGE_ID_NAME], + id_splits[PK_PACKAGE_ID_VERSION]); + + g_strfreev(id_splits); + return result; +} + +char ** +namever_array_from_package_ids(gchar **package_ids, guint count) +{ + char **namevers; + unsigned int i; + + assert(package_ids != NULL); + + namevers = calloc(count, sizeof(char *)); + if (namevers != NULL) { + for (i = 0; i < count; i++) { + namevers[i] = namever_from_package_id(package_ids[i]); + if (namevers[i] == NULL) { + namever_array_free(&namevers, count); + break; + } + } + } + + return namevers; +} + +/* Frees an array of name-version strings. */ +void +namever_array_free(char ***namevers_p, guint count) +{ + unsigned int i; + + assert(namevers_p != NULL); + + if (*namevers_p != NULL) { + for (i = 0; i < count; i++) { + free(*namevers_p[i]); + } + free(*namevers_p); + *namevers_p = NULL; + } + + assert(*namevers_p == NULL); +} Modified: soc2013/mattbw/backend/namever.h ============================================================================== --- soc2013/mattbw/backend/namever.h Sun Sep 1 14:28:12 2013 (r256801) +++ soc2013/mattbw/backend/namever.h Sun Sep 1 15:47:14 2013 (r256802) @@ -23,5 +23,7 @@ char *namever_from_name_and_version(const char *name, const char *version); char *namever_from_package(struct pkg *package); - +char *namever_from_package_id(gchar *package_id); +char **namever_array_from_package_ids(gchar **package_ids, guint count); +void namever_array_free(char ***namevers_p, guint count); #endif /* !_PKGNG_BACKEND_NAMEVER_H_ */ Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sun Sep 1 14:28:12 2013 (r256801) +++ soc2013/mattbw/backend/pkgutils.c Sun Sep 1 15:47:14 2013 (r256802) @@ -28,10 +28,14 @@ #include "pkgutils.h" /* Prototypes */ #include "utils.h" /* INTENTIONALLY_IGNORE */ +static const char *repo_of_package(struct pkg *pkg); +static const char *repo_of_remote_package(struct pkg *pkg); -static const char *repo_of_remote(struct pkg *pkg); - -/* Package utility functions that do not depend on PackageKit. */ +/* + * Package utility functions. + * + * This file CANNOT depend on the PackageKit backend. + */ /* * Infers the correct PkInfoEnum to emit for this package for its current state. @@ -39,6 +43,8 @@ PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg) { + bool locally_installed; + bool remote_but_already_installed; PkInfoEnum info; assert(pkg != NULL); @@ -47,11 +53,15 @@ * it is installed if it is the same version as an installed package, * and available if it is not. */ - if ((pkg_type(pkg) == PKG_INSTALLED) || - pkgutils_pkg_install_state(pkg) == PK_INFO_ENUM_REINSTALLING) + locally_installed = (pkg_type(pkg) == PKG_INSTALLED); + remote_but_already_installed = (pkgutils_pkg_install_state(pkg) == + PK_INFO_ENUM_REINSTALLING); + + if (locally_installed || remote_but_already_installed) { info = PK_INFO_ENUM_INSTALLED; - else + } else { info = PK_INFO_ENUM_AVAILABLE; + } return info; } @@ -105,61 +115,6 @@ } /* - * 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 = namever_from_name_and_version(id_splits[PK_PACKAGE_ID_NAME], - id_splits[PK_PACKAGE_ID_VERSION]); - - g_strfreev(id_splits); - return result; -} - - - -/* - * Gets the PackageKit repository name for the package. - */ -const char * -pkgutils_pk_repo_of(struct pkg *pkg) -{ - const char *repo; - - assert(pkg != NULL); - - switch (pkg_type(pkg)) { - case PKG_OLD_FILE: - case PKG_FILE: - repo = "local"; - break; - case PKG_INSTALLED: - repo = "installed"; - break; - case PKG_REMOTE: - repo = repo_of_remote(pkg); - break; - case PKG_NONE: - repo = "unknown"; - break; - } - - return repo; -} - -/* * Converts a package to a PackageID. */ gchar * @@ -172,12 +127,9 @@ assert(pkg != NULL); - pkg_get(pkg, - PKG_NAME, &name, - PKG_VERSION, &version, - PKG_ARCH, &arch); + pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version, PKG_ARCH, &arch); - repo = pkgutils_pk_repo_of(pkg); + repo = repo_of_package(pkg); return pk_package_id_build(name, version, arch, repo); } @@ -208,13 +160,13 @@ pkg_get(pkg2, PKG_VERSION, &version); pkg_set(pkg, PKG_OLD_VERSION, version); - } - if (old_p != NULL) + if (old_p != NULL) { *old_p = pkg2; - else + } else { pkg_free(pkg2); + } assert (old_p == NULL || pkg2 == NULL || *old_p != NULL); } @@ -244,6 +196,36 @@ } /* + * Gets the PackageKit repository name for the package. + */ +static const char * +repo_of_package(struct pkg *pkg) +{ + const char *repo; + + assert(pkg != NULL); + + switch (pkg_type(pkg)) { + case PKG_OLD_FILE: + case PKG_FILE: + repo = "local"; + break; + case PKG_INSTALLED: + repo = "installed"; + break; + case PKG_REMOTE: + repo = repo_of_remote_package(pkg); + break; + case PKG_NONE: + repo = "unknown"; + break; + } + + assert(repo != NULL); + return repo; +} + +/* * Gets the PackageKit repository name for the (remote) package. * * Currently this is the pkgng repository name (not the ident as was previously @@ -252,7 +234,7 @@ * This does not need to be freed (possibly, TODO: check). */ static const char * -repo_of_remote(struct pkg *pkg) +repo_of_remote_package(struct pkg *pkg) { const char *repo_name; Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sun Sep 1 14:28:12 2013 (r256801) +++ soc2013/mattbw/backend/pkgutils.h Sun Sep 1 15:47:14 2013 (r256802) @@ -29,8 +29,6 @@ PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); bool pkgutils_pkg_matches_filters(struct pkg *pkg, PkBitfield filters); -char *pkgutils_package_id_namever(gchar *package_id); -const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 1 20:50:13 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 751BBB62 for ; Sun, 1 Sep 2013 20:50:13 +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 47FFE24ED for ; Sun, 1 Sep 2013 20:50:13 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r81KoDiC032412 for ; Sun, 1 Sep 2013 20:50:13 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r81KoDTB032393 for svn-soc-all@FreeBSD.org; Sun, 1 Sep 2013 20:50:13 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 1 Sep 2013 20:50:13 GMT Message-Id: <201309012050.r81KoDTB032393@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: r256808 - 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, 01 Sep 2013 20:50:13 -0000 Author: mattbw Date: Sun Sep 1 20:50:12 2013 New Revision: 256808 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256808 Log: Add namever unit tests. Not much to report here, just some more unit tests. Modified: soc2013/mattbw/backend/Atffile soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/namever.c soc2013/mattbw/backend/namever.h Modified: soc2013/mattbw/backend/Atffile ============================================================================== --- soc2013/mattbw/backend/Atffile Sun Sep 1 19:59:54 2013 (r256807) +++ soc2013/mattbw/backend/Atffile Sun Sep 1 20:50:12 2013 (r256808) @@ -2,4 +2,5 @@ prop: test-suite = "main" +tp: namever_test tp: pkgutils_test Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sun Sep 1 19:59:54 2013 (r256807) +++ soc2013/mattbw/backend/Makefile Sun Sep 1 20:50:12 2013 (r256808) @@ -71,6 +71,7 @@ # ATF test flags TESTPROGS= \ + namever_test \ pkgutils_test \ query/id_test \ query/check_test \ @@ -118,5 +119,10 @@ pkgutils_test.o: pkgutils_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} +namever_test: namever_test.o namever.o + ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} + +namever_test.o: namever_test.c + ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} .include Modified: soc2013/mattbw/backend/namever.c ============================================================================== --- soc2013/mattbw/backend/namever.c Sun Sep 1 19:59:54 2013 (r256807) +++ soc2013/mattbw/backend/namever.c Sun Sep 1 20:50:12 2013 (r256808) @@ -74,7 +74,7 @@ * To be freed using free(3). */ char * -namever_from_package_id(gchar *package_id) +namever_from_package_id(const gchar *package_id) { char *result; gchar **id_splits; Modified: soc2013/mattbw/backend/namever.h ============================================================================== --- soc2013/mattbw/backend/namever.h Sun Sep 1 19:59:54 2013 (r256807) +++ soc2013/mattbw/backend/namever.h Sun Sep 1 20:50:12 2013 (r256808) @@ -21,9 +21,12 @@ #ifndef _PKGNG_BACKEND_NAMEVER_H_ #define _PKGNG_BACKEND_NAMEVER_H_ +#include /* gchar, guint */ +#include "pkg.h" /* struct pkg */ + char *namever_from_name_and_version(const char *name, const char *version); char *namever_from_package(struct pkg *package); -char *namever_from_package_id(gchar *package_id); +char *namever_from_package_id(const gchar *package_id); char **namever_array_from_package_ids(gchar **package_ids, guint count); void namever_array_free(char ***namevers_p, guint count); #endif /* !_PKGNG_BACKEND_NAMEVER_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sun Sep 1 22:45: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 7842CBBB for ; Sun, 1 Sep 2013 22:45:55 +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 63F402A08 for ; Sun, 1 Sep 2013 22:45: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 r81MjtIq010025 for ; Sun, 1 Sep 2013 22:45:55 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r81MjtgC010021 for svn-soc-all@FreeBSD.org; Sun, 1 Sep 2013 22:45:55 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 1 Sep 2013 22:45:55 GMT Message-Id: <201309012245.r81MjtgC010021@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: r256813 - 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, 01 Sep 2013 22:45:55 -0000 Author: mattbw Date: Sun Sep 1 22:45:54 2013 New Revision: 256813 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256813 Log: Actually commit namevers tests. In addition, the C standard has dropped back to C99, mainly so that this can be built with FreeBSD gcc again. Debug flags are currently switched on; this will probably change. Added: soc2013/mattbw/backend/namever_test.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/namever.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sun Sep 1 21:44:43 2013 (r256812) +++ soc2013/mattbw/backend/Makefile Sun Sep 1 22:45:54 2013 (r256813) @@ -91,9 +91,9 @@ #.endif CFLAGS+= `pkg-config --cflags ${PKGS}` -CFLAGS+= -DPK_COMPILATION -LDFLAGS+= `pkg-config --libs ${PKGS}` -CSTD?= c11 +CFLAGS+= -DPK_COMPILATION -g +LDFLAGS+= `pkg-config --libs ${PKGS}` -g +CSTD?= c99 group_map.c: groups group_map.awk sort groups | awk -f group_map.awk > group_map.c Modified: soc2013/mattbw/backend/namever.c ============================================================================== --- soc2013/mattbw/backend/namever.c Sun Sep 1 21:44:43 2013 (r256812) +++ soc2013/mattbw/backend/namever.c Sun Sep 1 22:45:54 2013 (r256813) @@ -123,7 +123,7 @@ if (*namevers_p != NULL) { for (i = 0; i < count; i++) { - free(*namevers_p[i]); + free((*namevers_p)[i]); } free(*namevers_p); *namevers_p = NULL; Added: soc2013/mattbw/backend/namever_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/namever_test.c Sun Sep 1 22:45:54 2013 (r256813) @@ -0,0 +1,162 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include +#include /* ATF_CHECK_STREQ */ +#include /* gchar, g_free */ + +#include "namever.h" /* pkgutils_... */ + +/* ATF/kyua tests for 'pkgutils.c'. */ + +static struct pkg *gen_pkg(pkg_t type); + +static struct pkg * +gen_pkg(pkg_t type) +{ + struct pkg *pkg; + int pkg_new_result; + + pkg = NULL; + pkg_new_result = pkg_new(&pkg, type); + + ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); + + pkg_set(pkg, + PKG_NAME, "pkg", + PKG_VERSION, "1.1.4", + PKG_ARCH, "freebsd:10:x86:32", + PKG_REPONAME, "packagesite"); + + return pkg; +} + +ATF_TC(test_namever_from_name_and_version); +ATF_TC_HEAD(test_namever_from_name_and_version, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'namever_from_name_and_version' on a valid pair."); +} +ATF_TC_BODY(test_namever_from_name_and_version, tc) +{ + char *namever; + + namever = namever_from_name_and_version("foo", "1.2.3"); + ATF_CHECK_STREQ(namever, "foo-1.2.3"); + free(namever); +} + +ATF_TC(test_namever_from_package_id); +ATF_TC_HEAD(test_namever_from_package_id, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'namever_from_package_id' on a valid PackageID."); +} +ATF_TC_BODY(test_namever_from_package_id, tc) +{ + char *namever; + + namever = namever_from_package_id("foo;1.2.3;freebsd:10:x86:32;lohac"); + ATF_CHECK_STREQ(namever, "foo-1.2.3"); + free(namever); +} + +ATF_TC(test_namever_array_from_package_ids); +ATF_TC_HEAD(test_namever_array_from_package_ids, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test 'namever_array_from_package_ids' on valid PackageIDs."); +} +ATF_TC_BODY(test_namever_array_from_package_ids, tc) +{ + char *package_ids[9]; + char **namevers; + unsigned int i; + + /* Full PackageIDs */ + package_ids[0] = strdup("dave;1.2.3;freebsd:10:x86:32;lohac"); + package_ids[1] = strdup("rose;4.5.6;freebsd:10:x86:64;lolar"); + package_ids[2] = strdup("john;7.8;freebsd:9:x86:32;lowas"); + package_ids[3] = strdup("jade;9.0a;freebsd:9:x86:64;lofaf"); + + /* Non-canonical/non-remote PackageIDs should still work */ + package_ids[4] = strdup("dirk;1;freebsd:10:x86:32;installed"); + package_ids[5] = strdup("roxy;wizardy-herbert;;"); + package_ids[6] = strdup("jane;rolling;freebsd:8:x86:32;"); + package_ids[7] = strdup("jake;999;;lomax"); + + /* And one for luck */ + package_ids[8] = strdup("nepeta;3.3;dragonflybsd:3.4:x86:32;lolcat"); + + namevers = namever_array_from_package_ids(package_ids, 9); + + ATF_REQUIRE(namevers != NULL); + + ATF_CHECK_STREQ(namevers[0], "dave-1.2.3"); + ATF_CHECK_STREQ(namevers[1], "rose-4.5.6"); + ATF_CHECK_STREQ(namevers[2], "john-7.8"); + ATF_CHECK_STREQ(namevers[3], "jade-9.0a"); + ATF_CHECK_STREQ(namevers[4], "dirk-1"); + ATF_CHECK_STREQ(namevers[5], "roxy-wizardy-herbert"); + ATF_CHECK_STREQ(namevers[6], "jane-rolling"); + ATF_CHECK_STREQ(namevers[7], "jake-999"); + ATF_CHECK_STREQ(namevers[8], "nepeta-3.3"); + + namever_array_free(&namevers, 9); + ATF_CHECK_EQ(namevers, NULL); + + for (i = 0; i < 4; i++) { + free(package_ids[i]); + } +} + +ATF_TC(test_namever_from_package); +ATF_TC_HEAD(test_namever_from_package, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'namever_from_package_id' on a valid package."); +} +ATF_TC_BODY(test_namever_from_package, tc) +{ + char *namever; + struct pkg *package; + + package = gen_pkg(PKG_FILE); + namever = namever_from_package(package); + ATF_CHECK_STREQ(namever, "pkg-1.1.4"); + pkg_free(package); + free(namever); +} + +/* + * TEST PACK + */ + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, test_namever_from_name_and_version); + ATF_TP_ADD_TC(tp, test_namever_from_package_id); + ATF_TP_ADD_TC(tp, test_namever_array_from_package_ids); + ATF_TP_ADD_TC(tp, test_namever_from_package); + + return atf_no_error(); +} From owner-svn-soc-all@FreeBSD.ORG Sun Sep 1 23:16:50 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 A636BA86 for ; Sun, 1 Sep 2013 23:16:50 +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 790232C08 for ; Sun, 1 Sep 2013 23:16:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r81NGom1076773 for ; Sun, 1 Sep 2013 23:16:50 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r81NGoG2076769 for svn-soc-all@FreeBSD.org; Sun, 1 Sep 2013 23:16:50 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 1 Sep 2013 23:16:50 GMT Message-Id: <201309012316.r81NGoG2076769@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: r256816 - in soc2013/mattbw/backend: . jobs 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, 01 Sep 2013 23:16:50 -0000 Author: mattbw Date: Sun Sep 1 23:16:50 2013 New Revision: 256816 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256816 Log: Fix broken namever free references. This also changes the repo type checking code to use names instead of idents, but jobs are currently broken because they still expect idents. Modified: soc2013/mattbw/backend/jobs/core.h soc2013/mattbw/backend/jobs/do.c soc2013/mattbw/backend/utils.c Modified: soc2013/mattbw/backend/jobs/core.h ============================================================================== --- soc2013/mattbw/backend/jobs/core.h Sun Sep 1 22:30:24 2013 (r256815) +++ soc2013/mattbw/backend/jobs/core.h Sun Sep 1 23:16:50 2013 (r256816) @@ -32,6 +32,5 @@ struct pkg_jobs *jobs_allocate(pkg_jobs_t type, struct pkgdb *db); void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); void jobs_free(struct pkg_jobs **jobs_p); -void jobs_free_namevers(char ***namevers_p, guint count); #endif /* !_PKGNG_BACKEND_JOBS_CORE_H_ */ Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Sun Sep 1 22:30:24 2013 (r256815) +++ soc2013/mattbw/backend/jobs/do.c Sun Sep 1 23:16:50 2013 (r256816) @@ -27,6 +27,7 @@ #include "pkg.h" /* pkg_... */ #include "../db.h" /* db_... */ +#include "../namever.h" /* namever_array_free */ #include "../utils.h" /* get_package_ids */ #include "check.h" /* jobs_check_... */ #include "core.h" /* jobs_... */ @@ -230,7 +231,7 @@ } pkg_jobs_free(jobs); - jobs_free_namevers(&namevers, count); + namever_array_free(&namevers, count); } return success; @@ -275,7 +276,7 @@ ERR(spec->backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "could not solve the job"); - } + } return solved; } Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Sun Sep 1 22:30:24 2013 (r256815) +++ soc2013/mattbw/backend/utils.c Sun Sep 1 23:16:50 2013 (r256816) @@ -42,7 +42,7 @@ rtype = REPO_ANY; } else if (strcmp(name, "installed") == 0) { rtype = REPO_LOCAL; - } else if (pkg_repo_find_ident(name) != NULL) { + } else if (pkg_repo_find_name(name) != NULL) { rtype = REPO_REMOTE; } else { rtype = REPO_INVALID; From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 07:43: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 889B7E94 for ; Mon, 2 Sep 2013 07:43:31 +0000 (UTC) (envelope-from ccqin@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 73A9824AD for ; Mon, 2 Sep 2013 07:43: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 r827hVWB052137 for ; Mon, 2 Sep 2013 07:43:31 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r827hVKi052129 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 07:43:31 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 2 Sep 2013 07:43:31 GMT Message-Id: <201309020743.r827hVKi052129@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256824 - in soc2013/ccqin/head/sys: dev/ath net80211 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, 02 Sep 2013 07:43:31 -0000 Author: ccqin Date: Mon Sep 2 07:43:31 2013 New Revision: 256824 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256824 Log: teach ieee80211_amrr to return multiple rates and modify ath to use net80211_ratectl. * add amrr_rates to teach ieee80211_amrr of multiple rate. * change ieee80211_ratectl_complete(), drop stats, arg1, arg2, add ieee80211_rc_info *. adapt amrr_tx_complete correspondingly. * update ieee80211_ratectl_hascap_* functions to make it more reasonable. * modify ieee80211_ratectl_complete_rcflags() to let it work properly. we just care about rc flags here. ratecode is left for drivers to fill. * add a 48 bytes buf to mbuf(m_hdr) to record rc state. * modify ath to make it use net80211_ratectl api. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h soc2013/ccqin/head/sys/sys/mbuf.h Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Mon Sep 2 07:43:31 2013 (r256824) @@ -1380,6 +1380,15 @@ } ATH_UNLOCK(sc); + uint32_t caps = 0; + if (sc->sc_mrretry) + caps |= IEEE80211_RATECTL_CAP_MRR; + if (sc->sc_mrrprot) + caps |= IEEE80211_RATECTL_CAP_MRRPROT; + if (sc->sc_txchainmask > 1) + caps |= IEEE80211_RATECTL_CAP_MULTXCHAIN; + + ieee80211_ratectl_init(vap, caps); /* complete setup */ ieee80211_vap_attach(vap, ath_media_change, ieee80211_media_status); return vap; @@ -1414,6 +1423,7 @@ ath_stoprecv(sc, 1); /* stop recv side */ } + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); /* @@ -4072,6 +4082,13 @@ bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0 ? 0 : 1)); + + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } ath_tx_default_comp(sc, bf, 0); } else Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Mon Sep 2 07:43:31 2013 (r256824) @@ -1395,7 +1395,7 @@ /* Get rid of any previous state */ bzero(bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc)); - +#if 0 ATH_NODE_LOCK(ATH_NODE(bf->bf_node)); ath_rate_findrate(sc, ATH_NODE(bf->bf_node), bf->bf_state.bfs_shpream, bf->bf_state.bfs_pktlen, &rix, &try0, &rate); @@ -1409,6 +1409,20 @@ ath_rate_getxtxrates(sc, ATH_NODE(bf->bf_node), rix, bf->bf_state.bfs_rc); ATH_NODE_UNLOCK(ATH_NODE(bf->bf_node)); +#endif + /* net80211 ratectl */ + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + struct ieee80211_rc_series *rc = rc_info->iri_rc; + struct ieee80211_node *ni = bf->bf_node; + bzero(rc_info, sizeof(rc_info)); + if (bf->bf_state.bfs_shpream) + rc_info->iri_flags |= IEEE80211_RATECTL_INFO_SP; + + ieee80211_ratectl_rates(ni, rc_info); + + rix = rc[0].rix; + try0 = rc[0].tries; + rate = ni->ni_txrate; sc->sc_txrix = rix; /* for LED blinking */ sc->sc_lastdatarix = rix; /* for fast frames */ @@ -4108,10 +4122,19 @@ * during a hw queue drain and the frame wanted an ACK. */ if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) + { ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0) ? 0 : 1); + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } + ath_tx_default_comp(sc, bf, fail); } @@ -4490,6 +4513,13 @@ bf_first->bf_state.bfs_pktlen, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes); + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + ieee80211_ratectl_rc_info_set(rc_info, + bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes, + bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); ATH_TX_LOCK(sc); tap = ath_tx_get_tx_tid(an, tid->tid); sc->sc_stats.ast_tx_aggr_failall++; @@ -4873,9 +4903,18 @@ * control code. */ if (fail == 0) + { ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes, nbad); + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + ieee80211_ratectl_rc_info_set(rc_info, + nframes, nbad, pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } + /* * send bar if we dropped any frames */ @@ -4962,11 +5001,19 @@ * Do it outside of the TXQ lock. */ if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) + { ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, &bf->bf_status.ds_txstat, bf->bf_state.bfs_pktlen, 1, (ts.ts_status == 0) ? 0 : 1); + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } /* * This is called early so atid->hwq_depth can be tracked. * This unfortunately means that it's released and regrabbed Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Mon Sep 2 07:43:31 2013 (r256824) @@ -221,13 +221,34 @@ void ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf) { - struct ieee80211_node *ni = bf->bf_node; - struct ieee80211com *ic = ni->ni_ic; + // struct ieee80211_node *ni = bf->bf_node; + // struct ieee80211com *ic = ni->ni_ic; const HAL_RATE_TABLE *rt = sc->sc_currates; - struct ath_rc_series *rc = bf->bf_state.bfs_rc; + struct ath_rc_series *ath_rc = bf->bf_state.bfs_rc; + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + struct ieee80211_rc_series *rc = rc_info->iri_rc; uint8_t rate; int i; + for (i = 0; i < IEEE80211_RATECTL_NUM; i++) { + if (rc[i].tries == 0) + continue; + + rate = rt->info[rc[i].rix].rateCode; + if (rc[i].flags & IEEE80211_RATECTL_FLAG_SP) + rate |= rt->info[rc[i].rix].shortPreamble; + + rc[i].ratecode = rate; + + ath_rc[i].rix = rc[i].rix; + ath_rc[i].tries = rc[i].tries; + ath_rc[i].flags = rc[i].flags; + ath_rc[i].ratecode = rc[i].ratecode; + ath_rc[i].tx_power_cap = rc[i].tx_power_cap; + ath_rc[i].max4msframelen = rc[i].max4msframelen; + } + +#if 0 for (i = 0; i < ATH_RC_NUM; i++) { rc[i].flags = 0; if (rc[i].tries == 0) @@ -325,6 +346,7 @@ "%s: i=%d, rate=0x%x, flags=0x%x, max4ms=%d\n", __func__, i, rate, rc[i].flags, rc[i].max4msframelen); } +#endif } /* Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 07:43:31 2013 (r256824) @@ -65,9 +65,9 @@ static int amrr_update(struct ieee80211_amrr *, struct ieee80211_amrr_node *, struct ieee80211_node *); static int amrr_rate(struct ieee80211_node *, void *, uint32_t); +static int amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *); static void amrr_tx_complete(const struct ieee80211vap *, - const struct ieee80211_node *, int, - void *, void *); + const struct ieee80211_node *, struct ieee80211_rc_info *); static void amrr_tx_update(const struct ieee80211vap *vap, const struct ieee80211_node *, void *, void *, void *); static void amrr_sysctlattach(struct ieee80211vap *, @@ -85,6 +85,7 @@ .ir_node_init = amrr_node_init, .ir_node_deinit = amrr_node_deinit, .ir_rate = amrr_rate, + .ir_rates = amrr_rates, .ir_tx_complete = amrr_tx_complete, .ir_tx_update = amrr_tx_update, .ir_setinterval = amrr_setinterval, @@ -303,6 +304,69 @@ return rix; } +static void +amrr_rates(struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) +{ +#define RATE(_ix) (rs->rs_rates[(_ix)] & IEEE80211_RATE_VAL) +#define MCS(_ix) (rs->rs_rates[(_ix)] | IEEE80211_RATE_MCS) + + struct ieee80211_amrr_node *amn = ni->ni_rctls; + struct ieee80211_amrr *amrr = amn->amn_amrr; + struct ieee80211_rc_series *rc = rc_info->iri_rc; + const struct ieee80211_rateset *rs = NULL; + const struct ieee80211_rate_table *rt = NULL; + int rix, code; + + rs = ieee80211_ratectl_get_rateset(ni); + rt = ieee80211_get_ratetable(ni->ni_ic->ic_curchan); + + rix = amrr_rate(ni, NULL, 0); + + rc[0].flags = rc[1].flags = rc[2].flags = rc[3].flags = 0; + + if (rs->rs_nrates > 0) { + code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix); + rc[0].rix = rt->rateCodeToIndex[code]; + + if (IEEE80211_RATECTL_HASCAP_MRR(ni->ni_vap)) { + rc[0].tries = 1; + rc[1].tries = 1; + rc[2].tries = 1; + rc[3].tries = 1; + if (--rix >= 0) { + code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix); + rc[1].rix = rt->rateCodeToIndex[code]; + } else { + rc[1].rix = 0; + } + if (--rix >= 0) { + code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix); + rc[2].rix = rt->rateCodeToIndex[code]; + } else { + rc[2].rix = 0; + } + if (rix > 0) { + /* NB: only do this if we didn't already do it above */ + code = ieee80211_ratectl_node_is11n(ni)? MCS(0) : RATE(0); + rc[3].rix = rt->rateCodeToIndex[code]; + } else { + rc[3].rix = 0; + } + } else { + rc[0].tries = IEEE80211_RATECTL_TXMAXTRY; + + rc[1].tries = 0; + rc[2].tries = 0; + rc[3].tries = 0; + rc[1].rix = 0; + rc[2].rix = 0; + rc[3].rix = 0; + } + } +#undef RATE +#undef MCS +} + /* * Update statistics with tx complete status. Ok is non-zero * if the packet is known to be ACK'd. Retries has the number @@ -310,22 +374,16 @@ */ static void amrr_tx_complete(const struct ieee80211vap *vap, - const struct ieee80211_node *ni, int ok, - void *arg1, void *arg2) + const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { struct ieee80211_amrr_node *amn = ni->ni_rctls; - int retries = *(int *)arg1; - - /* XXX need to change arg2 to pointer of ieee80211_rc_info */ - struct ieee80211_rc_info *rc_info = (struct ieee80211_rc_info*)arg2; /* update per vap statistics */ ieee80211_ratectl_update_stat(vap, rc_info); - amn->amn_txcnt++; - if (ok) - amn->amn_success++; - amn->amn_retrycnt += retries; + amn->amn_txcnt += rc_info->iri_txcnt; + amn->amn_success += (rc_info->iri_txcnt - rc_info->failcnt); + amn->amn_retrycnt += rc_info->retrycnt; } /* Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Sep 2 07:43:31 2013 (r256824) @@ -131,9 +131,8 @@ struct ieee80211_rc_info *rc_info) { struct ieee80211vap *vap = ni->ni_vap; - const struct ieee80211_rate_table * rt = NULL; struct ieee80211_rc_series *rc = rc_info->iri_rc; - /* int shortPreamble = rc_info->ri_shortPreamble; */ + const struct ieee80211_rate_table * rt = NULL; uint8_t rate; int i; @@ -160,30 +159,27 @@ rate = rt->info[rc[i].rix].dot11Rate; - /* - * Only enable short preamble for legacy rates - */ - - /* XXX how we get the non_ht ratecode here? */ - - #if 0 - if ((! IS_HT_RATE(rate)) && shortPreamble) - rate |= rt->info[rc[i].rix].shortPreamble; - #endif + /* Only enable dual-stream, shortgi, 2040 if HT is set */ - /* - * Save this, used by the TX and completion code - */ - rc[i].ratecode = rate; - - /* Only enable shortgi, 2040, dual-stream if HT is set */ if (IS_HT_RATE(rate)) { rc[i].flags |= IEEE80211_RATECTL_FLAG_HT; + if (ieee80211_ratectl_hascap_cw40(vap, ni)) + rc[i].flags |= IEEE80211_RATECTL_FLAG_CW40; + + if (ieee80211_ratectl_hascap_shortgi(vap, ni)) + rc[i].flags |= IEEE80211_RATECTL_FLAG_SGI; /* - * XXX TODO: LDPC + * If we have STBC TX enabled and the receiver + * can receive (at least) 1 stream STBC, AND it's + * MCS 0-7, AND we have at least two chains enabled, + * enable STBC. */ - + if (ieee80211_ratectl_hascap_stbc(vap, ni) && + (rate & IEEE80211_RATE_VAL) < 8 && + HT_RC_2_STREAMS(rate) == 1) + rc[i].flags |= IEEE80211_RATECTL_FLAG_STBC; + /* * Dual / Triple stream rate? */ @@ -191,6 +187,35 @@ rc[i].flags |= IEEE80211_RATECTL_FLAG_DS; else if (HT_RC_2_STREAMS(rate) == 3) rc[i].flags |= IEEE80211_RATECTL_FLAG_TS; + + /* + * Calculate the maximum 4ms frame length based + * on the MCS rate, SGI and channel width flags. + */ + if (HT_RC_2_MCS(rate) < 32) { + int j; + if (rc[i].flags & IEEE80211_RATECTL_FLAG_CW40) { + if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI) + j = MCS_HT40_SGI; + else + j = MCS_HT40; + } else { + if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI) + j = MCS_HT20_SGI; + else + j = MCS_HT20; + } + rc[i].max4msframelen = + max_4ms_framelen[j][HT_RC_2_MCS(rate)]; + } + } else { + rc[i].max4msframelen = 0; + + /* + * Only enable short preamble for legacy rates + */ + if (rc_info->iri_flags & IEEE80211_RATECTL_INFO_SP) + rc[i].flags |= IEEE80211_RATECTL_FLAG_SP; } /* @@ -200,28 +225,6 @@ */ rc[i].tx_power_cap = ieee80211_get_node_txpower(ni); - /* - * Calculate the maximum 4ms frame length based - * on the MCS rate, SGI and channel width flags. - */ - if ((rc[i].flags & IEEE80211_RATECTL_FLAG_HT) && - (HT_RC_2_MCS(rate) < 32)) { - int j; - if (rc[i].flags & IEEE80211_RATECTL_FLAG_CW40) { - if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI) - j = MCS_HT40_SGI; - else - j = MCS_HT40; - } else { - if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI) - j = MCS_HT20_SGI; - else - j = MCS_HT20; - } - rc[i].max4msframelen = - max_4ms_framelen[j][HT_RC_2_MCS(rate)]; - } else - rc[i].max4msframelen = 0; } } Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Mon Sep 2 07:43:31 2013 (r256824) @@ -44,6 +44,7 @@ #define IEEE80211_RATECTL_FALSE 0 #define IEEE80211_RATECTL_NUM 4 +#define IEEE80211_RATECTL_TXMAXTRY 11 #define IEEE80211_RATECTL_FLAG_DS 0x01 /* dual-stream rate */ #define IEEE80211_RATECTL_FLAG_CW40 0x02 /* use HT40 */ @@ -52,6 +53,7 @@ #define IEEE80211_RATECTL_FLAG_RTSCTS 0x10 /* enable RTS/CTS protection */ #define IEEE80211_RATECTL_FLAG_STBC 0x20 /* enable STBC */ #define IEEE80211_RATECTL_FLAG_TS 0x40 /* triple-stream rate */ +#define IEEE80211_RATECTL_FLAG_SP 0x80 /* short preamble */ /* Hardware CAPs offered to rate control algo */ #define IEEE80211_RATECTL_CAP_MRR 0x01 /* support MRR */ @@ -76,23 +78,28 @@ struct ieee80211_rc_info { struct ieee80211_rc_series iri_rc[IEEE80211_RATECTL_NUM]; - int iri_framelen; - int iri_shortPreamble; + uint32_t iri_framelen; + uint16_t iri_flags; /* for now, just records short preamble */ /* TX info */ - int iri_success; /* TX success or not */ - int iri_okcnt; /* TX ok with or without retry */ - int iri_failcnt; /* TX retry-fail count */ - int iri_txcnt; /* TX count */ - int iri_retrycnt; /* TX retry count */ - int iri_shortretry; - int iri_longretry; - int iri_finaltsi; - int iri_txrate; /* hw tx rate */ + uint8_t iri_txcnt; /* TX count */ + uint8_t iri_okcnt; /* TX ok with or without retry */ + uint8_t iri_failcnt; /* TX retry-fail count */ + uint8_t iri_retrycnt; /* TX retry count */ + uint8_t iri_shortretry; + uint8_t iri_longretry; + uint8_t iri_finaltsi; + uint8_t iri_txrate; /* hw tx rate */ }; -/* net80211 ratectl statistics. - * per vap ratectl seeting must start with this common state +/* ieee80211_rc_info flags */ +#define IEEE80211_RATECTL_INFO_SP 0x01 /* short preamble */ + +#define IEEE80211_RATECTL_INFO(_m) ((struct ieee80211_rc_info *)(_m)->m_ccb) + +/* + * net80211 ratectl statistics. + * per vap ratectl seeting must start with this common state. */ struct ieee80211_rc_stat { uint32_t irs_capabilities; /* hardware capabilities offered to rc */ @@ -126,8 +133,7 @@ int (*ir_rate)(struct ieee80211_node *, void *, uint32_t); void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_info *); void (*ir_tx_complete)(const struct ieee80211vap *, - const struct ieee80211_node *, int, - void *, void *); + const struct ieee80211_node *, struct ieee80211_rc_info *); void (*ir_tx_update)(const struct ieee80211vap *, const struct ieee80211_node *, void *, void *, void *); @@ -184,9 +190,9 @@ static void __inline ieee80211_ratectl_tx_complete(const struct ieee80211vap *vap, - const struct ieee80211_node *ni, int status, void *arg1, void *arg2) + const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { - vap->iv_rate->ir_tx_complete(vap, ni, status, arg1, arg2); + vap->iv_rate->ir_tx_complete(vap, ni, rc_info); } static void __inline @@ -207,39 +213,40 @@ } static int __inline -ieee80211_ratectl_hascap_cw40(const struct ieee80211vap *vap, - const struct ieee80211_node *ni) +ieee80211_ratectl_hascap_cw40(const struct ieee80211_node *ni) { - return IS_VAP_HT(vap) && (ni->ni_chw == 40); + return ni->ni_chw == 40; } static int __inline -ieee80211_ratectl_hascap_shortgi(const struct ieee80211vap *vap, - const struct ieee80211_node *ni) +ieee80211_ratectl_hascap_shortgi(const struct ieee80211_node *ni) { - if (IS_VAP_HT(vap)) - { - if (ni->ni_chw == 40 && - vap->iv_htcaps & IEEE80211_HTCAP_SHORTGI40 && - ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) - return IEEE80211_RATECTL_TRUE; - - if (ni->ni_chw == 20 && - vap->iv_htcaps & IEEE80211_HTCAP_SHORTGI20 && - ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) - return IEEE80211_RATECTL_TRUE; - } + struct ieee80211com *ic = ni->ni_ic; + + if (ni->ni_chw == 40 && + ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40 && + ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) + return IEEE80211_RATECTL_TRUE; + + if (ni->ni_chw == 20 && + ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20 && + ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) + return IEEE80211_RATECTL_TRUE; + return IEEE80211_RATECTL_FALSE; } - static int __inline -ieee80211_ratectl_hascap_stbc(const struct ieee80211vap *vap, - const struct ieee80211_node *ni) +ieee80211_ratectl_hascap_stbc(const struct ieee80211_node *ni) { - return IS_VAP_HT(vap) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) && - (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM) && - IEEE80211_RATECTL_HASCAP_MULTXCHAIN(vap); + struct ieee80211com *ic = ni->ni_ic; + + if (ic->ic_htcaps & IEEE80211_HTCAP_TXSTBC && + ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM && + IEEE80211_RATECTL_HASCAP_MULTXCHAIN(ni->ni_vap)) + return IEEE80211_RATECTL_TRUE; + + return IEEE80211_RATECTL_FALSE; } static int __inline @@ -272,4 +279,21 @@ irs->irs_longretry += rc_info->iri_longretry; } +static void __inline +ieee80211_ratectl_rc_info_set(struct ieee80211_rc_info *rc_info, + uint8_t txcnt, uint8_t failcnt, uint32_t framelen, + uint8_t shortretry, uint8_t longretry, + uint8_t finaltsi, uint8_t txrate) +{ + rc_info->iri_txcnt = txcnt; + rc_info->iri_failcnt = failcnt; + rc_info->iri_okcnt = txcnt - failcnt; + rc_info->iri_framelen = framelen; + rc_info->iri_shortretry = shortretry; + rc_info->iri_longretry = longretry; + rc_info->iri_retrycnt = shortretry + longretry; + rc_info->iri_finaltsi = finaltsi; + rc_info->iri_txrate = txrate; +} + #endif Modified: soc2013/ccqin/head/sys/sys/mbuf.h ============================================================================== --- soc2013/ccqin/head/sys/sys/mbuf.h Mon Sep 2 06:41:54 2013 (r256823) +++ soc2013/ccqin/head/sys/sys/mbuf.h Mon Sep 2 07:43:31 2013 (r256824) @@ -95,6 +95,7 @@ caddr_t mh_data; /* location of data */ int mh_len; /* amount of data in this mbuf */ int mh_flags; /* flags; see below */ + uint8_t mh_ccb[48]; /* common control block */ short mh_type; /* type of data in this mbuf */ uint8_t pad[M_HDR_PAD];/* word align */ }; @@ -173,6 +174,7 @@ #define m_type m_hdr.mh_type #define m_flags m_hdr.mh_flags #define m_nextpkt m_hdr.mh_nextpkt +#define m_ccb m_hdr.mh_ccb #define m_act m_nextpkt #define m_pkthdr M_dat.MH.MH_pkthdr #define m_ext M_dat.MH.MH_dat.MH_ext From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 08:00: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 9FACE367 for ; Mon, 2 Sep 2013 08:00:12 +0000 (UTC) (envelope-from ccqin@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 8B7362588 for ; Mon, 2 Sep 2013 08:00:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8280CRv004938 for ; Mon, 2 Sep 2013 08:00:12 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8280Cm7004921 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 08:00:12 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 2 Sep 2013 08:00:12 GMT Message-Id: <201309020800.r8280Cm7004921@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256825 - soc2013/ccqin/head/sys/net80211 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, 02 Sep 2013 08:00:12 -0000 Author: ccqin Date: Mon Sep 2 08:00:12 2013 New Revision: 256825 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256825 Log: minor errors in ieee80211_amrr fixed. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 07:43:31 2013 (r256824) +++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 08:00:12 2013 (r256825) @@ -65,7 +65,7 @@ static int amrr_update(struct ieee80211_amrr *, struct ieee80211_amrr_node *, struct ieee80211_node *); static int amrr_rate(struct ieee80211_node *, void *, uint32_t); -static int amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *); +static void amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *); static void amrr_tx_complete(const struct ieee80211vap *, const struct ieee80211_node *, struct ieee80211_rc_info *); static void amrr_tx_update(const struct ieee80211vap *vap, @@ -382,8 +382,8 @@ ieee80211_ratectl_update_stat(vap, rc_info); amn->amn_txcnt += rc_info->iri_txcnt; - amn->amn_success += (rc_info->iri_txcnt - rc_info->failcnt); - amn->amn_retrycnt += rc_info->retrycnt; + amn->amn_success += (rc_info->iri_txcnt - rc_info->iri_failcnt); + amn->amn_retrycnt += rc_info->iri_retrycnt; } /* From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 08:50:50 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 92F7EEB0 for ; Mon, 2 Sep 2013 08:50:50 +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 8098A28AB for ; Mon, 2 Sep 2013 08:50:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r828ootF009661 for ; Mon, 2 Sep 2013 08:50:50 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r828ooxG009643 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 08:50:50 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 08:50:50 GMT Message-Id: <201309020850.r828ooxG009643@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: r256826 - soc2013/mattbw/backend/jobs 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, 02 Sep 2013 08:50:50 -0000 Author: mattbw Date: Mon Sep 2 08:50:50 2013 New Revision: 256826 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256826 Log: Use ident when setting pkgng job repo. The above case does not work when repository names are given; they must be idents. Modified: soc2013/mattbw/backend/jobs/do.c Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Mon Sep 2 08:00:12 2013 (r256825) +++ soc2013/mattbw/backend/jobs/do.c Mon Sep 2 08:50:50 2013 (r256826) @@ -49,10 +49,8 @@ jobs_do(const struct jobs_spec *spec) { bool success; - struct pkgdb *db; - assert(spec != NULL); assert(spec->backend != NULL); assert(spec->info != NULL); @@ -172,10 +170,11 @@ /* Nastily inefficient */ splits = pk_package_id_split(package_ids[i]); - if (splits == NULL) + if (splits == NULL) { repo = strdup(""); - else + } else { repo = strdup(splits[PK_PACKAGE_ID_DATA]); + } g_strfreev(splits); success = jobs_do_same_repo(db, spec, package_ids + i, @@ -242,12 +241,22 @@ const char *reponame) { bool success; + struct pkg_repo *repo; assert(spec != NULL); assert(jobs != NULL); /* reponame can be NULL */ - success = jobs_set_repo(jobs, reponame); + success = true; + + /* + * We need to convert the repo name to an ident. This is the only + * place an ident works but a name doesn't, it seems. + */ + repo = pkg_repo_find_name(reponame); + if (repo != NULL) { + success = jobs_set_repo(jobs, pkg_repo_ident(repo)); + } if (!success) { char *err_message; From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 08:51:50 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 AEF31EF1 for ; Mon, 2 Sep 2013 08:51:50 +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 9C80528BC for ; Mon, 2 Sep 2013 08:51:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r828poTw028037 for ; Mon, 2 Sep 2013 08:51:50 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r828powK028032 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 08:51:50 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 08:51:50 GMT Message-Id: <201309020851.r828powK028032@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: r256827 - 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: Mon, 02 Sep 2013 08:51:50 -0000 Author: mattbw Date: Mon Sep 2 08:51:50 2013 New Revision: 256827 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256827 Log: Swap idents and names in repo-list. This is because the name is now the identifier used, and the ident is now the description. Modified: soc2013/mattbw/backend/actions/get_repo_list.c Modified: soc2013/mattbw/backend/actions/get_repo_list.c ============================================================================== --- soc2013/mattbw/backend/actions/get_repo_list.c Mon Sep 2 08:50:50 2013 (r256826) +++ soc2013/mattbw/backend/actions/get_repo_list.c Mon Sep 2 08:51:50 2013 (r256827) @@ -43,8 +43,8 @@ while (pkg_repos(&repo) == EPKG_OK) { assert(backend != NULL); (void)pk_backend_repo_detail(backend, - pkg_repo_ident(repo), pkg_repo_name(repo), + pkg_repo_ident(repo), pkg_repo_enabled(repo)); } From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 09:14: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 66211AC9 for ; Mon, 2 Sep 2013 09:14:04 +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 456532AD2 for ; Mon, 2 Sep 2013 09:14: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 r829E4CP006978 for ; Mon, 2 Sep 2013 09:14:04 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r829E4ts006961 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 09:14:04 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 09:14:04 GMT Message-Id: <201309020914.r829E4ts006961@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: r256828 - 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, 02 Sep 2013 09:14:04 -0000 Author: mattbw Date: Mon Sep 2 09:14:03 2013 New Revision: 256828 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256828 Log: Factor out gen_pkg in tests. This now lies in a new file, "testutils.c", so it can be shared amongst all unit tests. Added: soc2013/mattbw/backend/testutils.c soc2013/mattbw/backend/testutils.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/namever.h soc2013/mattbw/backend/namever_test.c soc2013/mattbw/backend/pkgutils_test.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/Makefile Mon Sep 2 09:14:03 2013 (r256828) @@ -101,28 +101,31 @@ tests: ${TESTPROGS} # TODO: Find a more BSD way of doing this -query/id_test: query/id_test.o query/id.o namever.o +query/id_test: query/id_test.o query/id.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} query/id_test.o: query/id_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o +query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} query/check_test.o: query/check_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -pkgutils_test: pkgutils_test.o pkgutils.o namever.o +pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} pkgutils_test.o: pkgutils_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -namever_test: namever_test.o namever.o +namever_test: namever_test.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} namever_test.o: namever_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} +testutils.o: testutils.c + ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} + .include Modified: soc2013/mattbw/backend/namever.h ============================================================================== --- soc2013/mattbw/backend/namever.h Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/namever.h Mon Sep 2 09:14:03 2013 (r256828) @@ -29,4 +29,5 @@ char *namever_from_package_id(const gchar *package_id); char **namever_array_from_package_ids(gchar **package_ids, guint count); void namever_array_free(char ***namevers_p, guint count); + #endif /* !_PKGNG_BACKEND_NAMEVER_H_ */ Modified: soc2013/mattbw/backend/namever_test.c ============================================================================== --- soc2013/mattbw/backend/namever_test.c Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/namever_test.c Mon Sep 2 09:14:03 2013 (r256828) @@ -22,31 +22,10 @@ #include /* gchar, g_free */ #include "namever.h" /* pkgutils_... */ +#include "testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'pkgutils.c'. */ -static struct pkg *gen_pkg(pkg_t type); - -static struct pkg * -gen_pkg(pkg_t type) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, type); - - ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); - - pkg_set(pkg, - PKG_NAME, "pkg", - PKG_VERSION, "1.1.4", - PKG_ARCH, "freebsd:10:x86:32", - PKG_REPONAME, "packagesite"); - - return pkg; -} - ATF_TC(test_namever_from_name_and_version); ATF_TC_HEAD(test_namever_from_name_and_version, tc) { Modified: soc2013/mattbw/backend/pkgutils_test.c ============================================================================== --- soc2013/mattbw/backend/pkgutils_test.c Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/pkgutils_test.c Mon Sep 2 09:14:03 2013 (r256828) @@ -23,31 +23,10 @@ #include "pkg.h" /* pkg... */ #include "pkgutils.h" /* pkgutils_... */ +#include "testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'pkgutils.c'. */ -static struct pkg *gen_pkg(pkg_t type); - -static struct pkg * -gen_pkg(pkg_t type) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, type); - - ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); - - pkg_set(pkg, - PKG_NAME, "pkg", - PKG_VERSION, "1.1.4", - PKG_ARCH, "freebsd:10:x86:32", - PKG_REPONAME, "packagesite"); - - return pkg; -} - ATF_TC(pkg_to_id_valid_local); ATF_TC_HEAD(pkg_to_id_valid_local, tc) { Added: soc2013/mattbw/backend/testutils.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/testutils.c Mon Sep 2 09:14:03 2013 (r256828) @@ -0,0 +1,50 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "pkg.h" /* pkg... */ + +#include "testutils.h" /* Prototypes */ + +/* + * Utility functions for unit tests. These shouldn't be used for anything + * else. + */ + +struct pkg * +gen_pkg(pkg_t type) +{ + struct pkg *pkg; + int pkg_new_result; + + pkg = NULL; + pkg_new_result = pkg_new(&pkg, type); + + ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); + + pkg_set(pkg, + PKG_NAME, "pkg", + PKG_VERSION, "1.1.4", + PKG_ARCH, "freebsd:10:x86:32", + PKG_REPONAME, "packagesite"); + + return pkg; +} + Added: soc2013/mattbw/backend/testutils.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/testutils.h Mon Sep 2 09:14:03 2013 (r256828) @@ -0,0 +1,28 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_TESTUTILS_H_ +#define _PKGNG_BACKEND_TESTUTILS_H_ + +#include "pkg.h" /* struct pkg */ + +struct pkg *gen_pkg(pkg_t type); + +#endif /* !_PKGNG_BACKEND_TESTUTILS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 09:17:58 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 75AFDC1E for ; Mon, 2 Sep 2013 09:17:58 +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 62F912B00 for ; Mon, 2 Sep 2013 09:17:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r829HwIW050909 for ; Mon, 2 Sep 2013 09:17:58 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r829HwHq050907 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 09:17:58 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 09:17:58 GMT Message-Id: <201309020917.r829HwHq050907@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: r256829 - 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: Mon, 02 Sep 2013 09:17:58 -0000 Author: mattbw Date: Mon Sep 2 09:17:58 2013 New Revision: 256829 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256829 Log: Missed out check_test previously. This unit test batch now has a failing test added that might explain why resolve is no longer picking up installed packages. Modified: soc2013/mattbw/backend/query/check_test.c Modified: soc2013/mattbw/backend/query/check_test.c ============================================================================== --- soc2013/mattbw/backend/query/check_test.c Mon Sep 2 09:14:03 2013 (r256828) +++ soc2013/mattbw/backend/query/check_test.c Mon Sep 2 09:17:58 2013 (r256829) @@ -24,31 +24,10 @@ #include "pkg.h" /* pkg... */ #include "check.h" /* query_check... */ +#include "../testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'check.c'. */ -static struct pkg *gen_pkg(void); - -static struct pkg * -gen_pkg(void) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, PKG_FILE); - - ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); - - pkg_set(pkg, - PKG_NAME, "pkg", - PKG_VERSION, "1.1.4", - PKG_ARCH, "freebsd:10:x86:32", - PKG_REPONAME, "packagesite"); - - return pkg; -} - ATF_TC(package_match_name_only); ATF_TC_HEAD(package_match_name_only, tc) { @@ -61,7 +40,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg"); @@ -86,7 +65,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -111,7 +90,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -120,6 +99,14 @@ ATF_CHECK(query_check_package(pkg, &id)); + /* + * This is a remote package, so setting the ID repo to 'installed' + * should cause the match to fail. + */ + free(id.repo); + id.repo = strdup("installed"); + ATF_CHECK(!query_check_package(pkg, &id)); + pkg_free(pkg); free(id.namever); free(id.arch); @@ -138,7 +125,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("wrong-1.1.4"); @@ -165,7 +152,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -192,7 +179,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -207,6 +194,37 @@ free(id.repo); } +ATF_TC(package_match_full_installed); +ATF_TC_HEAD(package_match_full_installed, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Ensure installed packages only match installed query IDs."); +} +ATF_TC_BODY(package_match_full_installed, tc) +{ + struct pkg *pkg; + struct query_id id; + + pkg = gen_pkg(PKG_INSTALLED); + ATF_REQUIRE(pkg != NULL); + + id.namever = strdup("pkg-1.1.4"); + id.arch = strdup("freebsd:10:x86:32"); + id.repo = strdup("packagesite"); + + ATF_CHECK(!query_check_package(pkg, &id)); + + free(id.repo); + id.repo = strdup("installed"); + ATF_CHECK(query_check_package(pkg, &id)); + + pkg_free(pkg); + free(id.namever); + free(id.arch); + free(id.repo); +} + /* * This test condition is commented out because it triggers an assertion * failure instead of failing normally. @@ -223,7 +241,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = NULL; @@ -250,6 +268,7 @@ ATF_TP_ADD_TC(tp, package_match_bad_namever); ATF_TP_ADD_TC(tp, package_match_bad_arch); ATF_TP_ADD_TC(tp, package_match_bad_repo); + ATF_TP_ADD_TC(tp, package_match_full_installed); /*ATF_TP_ADD_TC(tp, package_match_no_namever);*/ return atf_no_error(); From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 09:51:42 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 64114C85 for ; Mon, 2 Sep 2013 09:51:42 +0000 (UTC) (envelope-from ccqin@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 35C4B2D89 for ; Mon, 2 Sep 2013 09:51:42 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r829pg5c060371 for ; Mon, 2 Sep 2013 09:51:42 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r829pfa4060318 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 09:51:41 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 2 Sep 2013 09:51:41 GMT Message-Id: <201309020951.r829pfa4060318@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256830 - in soc2013/ccqin/head/sys: dev/ath dev/bwi dev/bwn dev/iwn dev/ral dev/usb/wlan dev/wpi net80211 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, 02 Sep 2013 09:51:42 -0000 Author: ccqin Date: Mon Sep 2 09:51:41 2013 New Revision: 256830 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256830 Log: fix compile errors. * fix references to ieee80211_ratectl_complete() from drivers. * other minor errors Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c soc2013/ccqin/head/sys/dev/bwi/if_bwi.c soc2013/ccqin/head/sys/dev/bwn/if_bwn.c soc2013/ccqin/head/sys/dev/iwn/if_iwn.c soc2013/ccqin/head/sys/dev/ral/rt2560.c soc2013/ccqin/head/sys/dev/ral/rt2661.c soc2013/ccqin/head/sys/dev/ral/rt2860.c soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c soc2013/ccqin/head/sys/dev/wpi/if_wpi.c soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Mon Sep 2 09:51:41 2013 (r256830) @@ -82,6 +82,8 @@ #include #include + +#include #ifdef IEEE80211_SUPPORT_SUPERG #include #endif Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Mon Sep 2 09:51:41 2013 (r256830) @@ -72,6 +72,8 @@ #include #include + +#include #ifdef IEEE80211_SUPPORT_SUPERG #include #endif @@ -4513,12 +4515,13 @@ bf_first->bf_state.bfs_pktlen, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes); - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); + struct ath_tx_status ts = bf_first->bf_status.ds_txstat; + struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf_first->bf_m); ieee80211_ratectl_rc_info_set(rc_info, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes, - bf->bf_state.bfs_pktlen, - ts->ts_shortretry, ts->ts_longretry, - ts->ts_finaltsi, ts->ts_rate); + bf_first->bf_state.bfs_pktlen, + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); ATH_TX_LOCK(sc); tap = ath_tx_get_tx_tid(an, tid->tid); @@ -4910,8 +4913,8 @@ struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); ieee80211_ratectl_rc_info_set(rc_info, nframes, nbad, pktlen, - ts->ts_shortretry, ts->ts_longretry, - ts->ts_finaltsi, ts->ts_rate); + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } @@ -5009,9 +5012,9 @@ struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); ieee80211_ratectl_rc_info_set(rc_info, - 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, - ts->ts_shortretry, ts->ts_longretry, - ts->ts_finaltsi, ts->ts_rate); + 1, (ts.ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } /* Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Mon Sep 2 09:51:41 2013 (r256830) @@ -64,6 +64,8 @@ #include #include + +#include #ifdef IEEE80211_SUPPORT_SUPERG #include #endif Modified: soc2013/ccqin/head/sys/dev/bwi/if_bwi.c ============================================================================== --- soc2013/ccqin/head/sys/dev/bwi/if_bwi.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/bwi/if_bwi.c Mon Sep 2 09:51:41 2013 (r256830) @@ -3378,9 +3378,12 @@ * well so to avoid over-aggressive downshifting we * treat any number of retries as "1". */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, (data_txcnt > 1) ? IEEE80211_RATECTL_TX_SUCCESS : IEEE80211_RATECTL_TX_FAILURE, &acked, NULL); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ } /* Modified: soc2013/ccqin/head/sys/dev/bwn/if_bwn.c ============================================================================== --- soc2013/ccqin/head/sys/dev/bwn/if_bwn.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/bwn/if_bwn.c Mon Sep 2 09:51:41 2013 (r256830) @@ -9021,11 +9021,14 @@ if (meta->mt_islast) { ni = meta->mt_ni; vap = ni->ni_vap; +#if 0 ieee80211_ratectl_tx_complete(vap, ni, status->ack ? IEEE80211_RATECTL_TX_SUCCESS : IEEE80211_RATECTL_TX_FAILURE, &retrycnt, 0); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ break; } slot = bwn_dma_nextslot(dr, slot); @@ -9042,11 +9045,14 @@ } ni = tp->tp_ni; vap = ni->ni_vap; +#if 0 ieee80211_ratectl_tx_complete(vap, ni, status->ack ? IEEE80211_RATECTL_TX_SUCCESS : IEEE80211_RATECTL_TX_FAILURE, &retrycnt, 0); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ } bwn_pio_handle_txeof(mac, status); } Modified: soc2013/ccqin/head/sys/dev/iwn/if_iwn.c ============================================================================== --- soc2013/ccqin/head/sys/dev/iwn/if_iwn.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/iwn/if_iwn.c Mon Sep 2 09:51:41 2013 (r256830) @@ -2500,7 +2500,8 @@ uint64_t bitmap; uint16_t ssn; uint8_t tid; - int ackfailcnt = 0, i, lastidx, qid, *res, shift; + /* int failcnt = 0; */ + int i, lastidx, qid, *res, shift; bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD); @@ -2564,12 +2565,18 @@ for (i = 0; bitmap; i++) { if ((bitmap & 1) == 0) { ifp->if_oerrors++; +#if 0 ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); +#endif + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, NULL); /* just make it compiled. qcc */ } else { ifp->if_opackets++; +#if 0 ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); +#endif + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, NULL); /* just make it compiled. qcc */ } bitmap >>= 1; } @@ -2808,12 +2815,18 @@ */ if (status & IWN_TX_FAIL) { ifp->if_oerrors++; +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ } else { ifp->if_opackets++; +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ } m_freem(m); ieee80211_free_node(ni); Modified: soc2013/ccqin/head/sys/dev/ral/rt2560.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ral/rt2560.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ral/rt2560.c Mon Sep 2 09:51:41 2013 (r256830) @@ -956,9 +956,13 @@ DPRINTFN(sc, 10, "%s\n", "data frame sent successfully"); if (data->rix != IEEE80211_FIXED_RATE_NONE) + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); +#endif + ifp->if_opackets++; break; @@ -968,9 +972,12 @@ DPRINTFN(sc, 9, "data frame sent after %u retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); +#endif ifp->if_opackets++; break; @@ -980,9 +987,12 @@ DPRINTFN(sc, 9, "data frame failed after %d retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); +#endif ifp->if_oerrors++; break; Modified: soc2013/ccqin/head/sys/dev/ral/rt2661.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ral/rt2661.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ral/rt2661.c Mon Sep 2 09:51:41 2013 (r256830) @@ -906,9 +906,12 @@ DPRINTFN(sc, 10, "data frame sent successfully after " "%d retries\n", retrycnt); if (data->rix != IEEE80211_FIXED_RATE_NONE) + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); +#endif ifp->if_opackets++; break; @@ -918,9 +921,12 @@ DPRINTFN(sc, 9, "%s\n", "sending data frame failed (too much retries)"); if (data->rix != IEEE80211_FIXED_RATE_NONE) + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); +#endif ifp->if_oerrors++; break; Modified: soc2013/ccqin/head/sys/dev/ral/rt2860.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ral/rt2860.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/ral/rt2860.c Mon Sep 2 09:51:41 2013 (r256830) @@ -1122,11 +1122,17 @@ retrycnt = 1; else retrycnt = 0; + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); +#endif } else { + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, NULL); /* just make it compiled. qcc */ +#if 0 ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); +#endif ifp->if_oerrors++; } } Modified: soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c Mon Sep 2 09:51:41 2013 (r256830) @@ -668,9 +668,12 @@ int retrycnt = (int)(le16toh(retry->count) & 0xff); +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ ieee80211_free_node(ni); } if (le16toh(retry->count) & 0x100) Modified: soc2013/ccqin/head/sys/dev/wpi/if_wpi.c ============================================================================== --- soc2013/ccqin/head/sys/dev/wpi/if_wpi.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/dev/wpi/if_wpi.c Mon Sep 2 09:51:41 2013 (r256830) @@ -1597,8 +1597,11 @@ DPRINTFN(WPI_DEBUG_TX, ("%d retries\n", stat->ntries)); retrycnt = 1; } +#if 0 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); +#endif + ieee80211_ratectl_tx_complete(vap, ni, NULL); /* just make it compiled. qcc */ /* XXX oerrors should only count errors !maxtries */ if ((le32toh(stat->status) & 0xff) != 1) Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 2 09:51:41 2013 (r256830) @@ -309,9 +309,6 @@ { #define RATE(_ix) (rs->rs_rates[(_ix)] & IEEE80211_RATE_VAL) #define MCS(_ix) (rs->rs_rates[(_ix)] | IEEE80211_RATE_MCS) - - struct ieee80211_amrr_node *amn = ni->ni_rctls; - struct ieee80211_amrr *amrr = amn->amn_amrr; struct ieee80211_rc_series *rc = rc_info->iri_rc; const struct ieee80211_rateset *rs = NULL; const struct ieee80211_rate_table *rt = NULL; Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Sep 2 09:51:41 2013 (r256830) @@ -164,10 +164,10 @@ if (IS_HT_RATE(rate)) { rc[i].flags |= IEEE80211_RATECTL_FLAG_HT; - if (ieee80211_ratectl_hascap_cw40(vap, ni)) + if (ieee80211_ratectl_hascap_cw40(ni)) rc[i].flags |= IEEE80211_RATECTL_FLAG_CW40; - if (ieee80211_ratectl_hascap_shortgi(vap, ni)) + if (ieee80211_ratectl_hascap_shortgi(ni)) rc[i].flags |= IEEE80211_RATECTL_FLAG_SGI; /* * If we have STBC TX enabled and the receiver @@ -175,7 +175,7 @@ * MCS 0-7, AND we have at least two chains enabled, * enable STBC. */ - if (ieee80211_ratectl_hascap_stbc(vap, ni) && + if (ieee80211_ratectl_hascap_stbc(ni) && (rate & IEEE80211_RATE_VAL) < 8 && HT_RC_2_STREAMS(rate) == 1) rc[i].flags |= IEEE80211_RATECTL_FLAG_STBC; Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Mon Sep 2 09:17:58 2013 (r256829) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Mon Sep 2 09:51:41 2013 (r256830) @@ -113,8 +113,7 @@ static void none_tx_complete(const struct ieee80211vap *vap, - const struct ieee80211_node *ni, int ok, - void *arg1, void *arg2 __unused) + const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { } From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 18:40:53 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 95E9E9AC for ; Mon, 2 Sep 2013 18:40:53 +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 8195C29A0 for ; Mon, 2 Sep 2013 18:40:53 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r82IercE024020 for ; Mon, 2 Sep 2013 18:40:53 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r82IerkZ023988 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 18:40:53 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 18:40:53 GMT Message-Id: <201309021840.r82IerkZ023988@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: r256840 - 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: Mon, 02 Sep 2013 18:40:53 -0000 Author: mattbw Date: Mon Sep 2 18:40:53 2013 New Revision: 256840 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256840 Log: Fix broken installed packages resolution. I was using the pkgng package repo, as opposed to the PackageKit version, which is different when the package is local or installed. The corresponding unit test in query/check.c now passes. Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/check.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Sep 2 17:07:46 2013 (r256839) +++ soc2013/mattbw/backend/Makefile Mon Sep 2 18:40:53 2013 (r256840) @@ -107,7 +107,7 @@ query/id_test.o: query/id_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o +query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o pkgutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} query/check_test.o: query/check_test.c Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Mon Sep 2 17:07:46 2013 (r256839) +++ soc2013/mattbw/backend/pkgutils.c Mon Sep 2 18:40:53 2013 (r256840) @@ -28,7 +28,7 @@ #include "pkgutils.h" /* Prototypes */ #include "utils.h" /* INTENTIONALLY_IGNORE */ -static const char *repo_of_package(struct pkg *pkg); + static const char *repo_of_remote_package(struct pkg *pkg); /* @@ -129,7 +129,7 @@ pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version, PKG_ARCH, &arch); - repo = repo_of_package(pkg); + repo = pkgutils_pkg_to_pk_repo(pkg); return pk_package_id_build(name, version, arch, repo); } @@ -198,8 +198,8 @@ /* * Gets the PackageKit repository name for the package. */ -static const char * -repo_of_package(struct pkg *pkg) +const char * +pkgutils_pkg_to_pk_repo(struct pkg *pkg) { const char *repo; Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Mon Sep 2 17:07:46 2013 (r256839) +++ soc2013/mattbw/backend/pkgutils.h Mon Sep 2 18:40:53 2013 (r256840) @@ -30,6 +30,7 @@ PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); bool pkgutils_pkg_matches_filters(struct pkg *pkg, PkBitfield filters); gchar *pkgutils_pkg_to_id(struct pkg *pkg); +const char *pkgutils_pkg_to_pk_repo(struct pkg *pkg); void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p); #endif /* !_PKGNG_BACKEND_PKGUTILS_H_ */ Modified: soc2013/mattbw/backend/query/check.c ============================================================================== --- soc2013/mattbw/backend/query/check.c Mon Sep 2 17:07:46 2013 (r256839) +++ soc2013/mattbw/backend/query/check.c Mon Sep 2 18:40:53 2013 (r256840) @@ -24,6 +24,7 @@ #include "pkg.h" /* struct pkg... */ #include "../namever.h" /* namever_... */ +#include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* type_of_repo_name, enum repo_type */ #include "check.h" /* query_check... */ #include "find.h" /* query_find_... */ @@ -48,12 +49,9 @@ assert(query_id != NULL); assert(query_id->namever != NULL); - namever = namever_from_package(package); - (void)pkg_get(package, - PKG_ARCH, &arch, - PKG_NAME, &name, - PKG_REPONAME, &repo); + repo = pkgutils_pkg_to_pk_repo(package); + (void)pkg_get(package, PKG_ARCH, &arch, PKG_NAME, &name); /* Be cautious and reject matches if the package fields aren't here. */ if (namever == NULL || arch == NULL || repo == NULL) { From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 19:03: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 D58EFF39 for ; Mon, 2 Sep 2013 19:03:40 +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 B35412AF2 for ; Mon, 2 Sep 2013 19:03: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 r82J3e30078494 for ; Mon, 2 Sep 2013 19:03:40 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r82J3eNa078483 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 19:03:40 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 19:03:40 GMT Message-Id: <201309021903.r82J3eNa078483@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: r256842 - soc2013/mattbw/backend/jobs 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, 02 Sep 2013 19:03:40 -0000 Author: mattbw Date: Mon Sep 2 19:03:40 2013 New Revision: 256842 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256842 Log: Output exact package that failed a suitability check. This is mainly for debugging purposes. Modified: soc2013/mattbw/backend/jobs/check.c soc2013/mattbw/backend/jobs/check.h soc2013/mattbw/backend/jobs/do.c Modified: soc2013/mattbw/backend/jobs/check.c ============================================================================== --- soc2013/mattbw/backend/jobs/check.c Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/check.c Mon Sep 2 19:03:40 2013 (r256842) @@ -34,33 +34,36 @@ #include "check.h" /* jobs_check_... */ static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); -static bool jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); +static struct pkg *jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); /* Checks a solved job against a string vector of PackageIDs to ensure any * packages that match the PackageIDs match them fully. + * + * Returns NULL if the check succeeded, and a struct pkg if that package + * failed the check. */ -bool +struct pkg * jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates) { - bool success; + struct pkg *package; struct query_id *query_ids; assert(jobs != NULL); assert(package_ids != NULL); assert(0 < count); - success = false; + package = NULL; query_ids = query_id_array_from_package_ids(package_ids, count); if (query_ids != NULL) { /* Now do the actual checking, per package. */ - success = jobs_check_query_ids(jobs, query_ids, count, + package = jobs_check_query_ids(jobs, query_ids, count, reject_non_updates); } - return success; + return package; } static bool @@ -86,7 +89,7 @@ } -static bool +static struct pkg * jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates) { @@ -141,5 +144,5 @@ /* Do not free the struct pkg, we actually don't own it. */ } - return success; + return success ? NULL : package; } Modified: soc2013/mattbw/backend/jobs/check.h ============================================================================== --- soc2013/mattbw/backend/jobs/check.h Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/check.h Mon Sep 2 19:03:40 2013 (r256842) @@ -25,6 +25,6 @@ #include /* bool */ #include "../pkg.h" /* pkg_... */ -bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates); +struct pkg *jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates); #endif /* !_PKGNG_BACKEND_JOBS_CHECK_H_ */ Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:03:40 2013 (r256842) @@ -28,6 +28,7 @@ #include "../db.h" /* db_... */ #include "../namever.h" /* namever_array_free */ +#include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* get_package_ids */ #include "check.h" /* jobs_check_... */ #include "core.h" /* jobs_... */ @@ -103,28 +104,39 @@ jobs_do_check(const struct jobs_spec *spec, struct pkg_jobs *jobs, gchar **package_ids, guint count) { - bool success; + struct pkg *failed_package; assert(spec != NULL); assert(jobs != NULL); assert(package_ids != NULL || 0 == count); assert(package_ids == NULL || 0 < count); - success = true; + failed_package = NULL; if (package_ids != NULL) { - success = jobs_check_package_ids(jobs, package_ids, count, - spec->reject_non_updates); + failed_package = jobs_check_package_ids(jobs, package_ids, + count, spec->reject_non_updates); } - if (!success) { + if (failed_package != NULL) { + char *message; + char *package_id; + + package_id = pkgutils_pkg_to_id(failed_package); + message = NULL; + (void)asprintf(&message, + "(internal error) package %s failed suitability check.", + package_id); ERR(spec->backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "packages failed suitability check"); + message); + + g_free(package_id); + free(message); } - assert(0 < count || success); + assert(0 < count || failed_package == NULL); - return success; + return (failed_package == NULL); } static bool From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 19:28: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 60E5D1F4 for ; Mon, 2 Sep 2013 19:28:45 +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 2BEA82CCE for ; Mon, 2 Sep 2013 19:28: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 r82JSjQF064156 for ; Mon, 2 Sep 2013 19:28:45 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r82JSjJM064153 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 19:28:45 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 19:28:45 GMT Message-Id: <201309021928.r82JSjJM064153@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: r256843 - in soc2013/mattbw/backend: . jobs 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, 02 Sep 2013 19:28:45 -0000 Author: mattbw Date: Mon Sep 2 19:28:44 2013 New Revision: 256843 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256843 Log: Make repository validation work- ish. This seems to work better than it did before this commit, but the jobs are still trying to match packages from other repositories. Modified: soc2013/mattbw/backend/jobs/do.c soc2013/mattbw/backend/utils.c Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:03:40 2013 (r256842) +++ soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:28:44 2013 (r256843) @@ -259,15 +259,29 @@ assert(jobs != NULL); /* reponame can be NULL */ - success = true; + success = false; + repo = NULL; /* * We need to convert the repo name to an ident. This is the only * place an ident works but a name doesn't, it seems. */ - repo = pkg_repo_find_name(reponame); - if (repo != NULL) { - success = jobs_set_repo(jobs, pkg_repo_ident(repo)); + switch(type_of_repo_name(reponame)) { + case REPO_REMOTE: + success = jobs_set_repo(jobs, + pkg_repo_ident_from_name(reponame)); + break; + case REPO_LOCAL: + case REPO_ANY: + /* + * No need to set the repository name; we're either dealing + * with a local package or a wildcard-repo one. + */ + success = true; + break; + case REPO_INVALID: + success = false; + break; } if (!success) { char *err_message; Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Mon Sep 2 19:03:40 2013 (r256842) +++ soc2013/mattbw/backend/utils.c Mon Sep 2 19:28:44 2013 (r256843) @@ -42,7 +42,8 @@ rtype = REPO_ANY; } else if (strcmp(name, "installed") == 0) { rtype = REPO_LOCAL; - } else if (pkg_repo_find_name(name) != NULL) { + } else if (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) + != NULL) { rtype = REPO_REMOTE; } else { rtype = REPO_INVALID; From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 19:37:55 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 8FFFB787 for ; Mon, 2 Sep 2013 19:37:55 +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 626162D77 for ; Mon, 2 Sep 2013 19:37: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 r82Jbtb5056612 for ; Mon, 2 Sep 2013 19:37:55 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r82JbtKq056604 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 19:37:55 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 19:37:55 GMT Message-Id: <201309021937.r82JbtKq056604@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: r256844 - in soc2013/mattbw/backend: . jobs 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, 02 Sep 2013 19:37:55 -0000 Author: mattbw Date: Mon Sep 2 19:37:55 2013 New Revision: 256844 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256844 Log: Fix job repo suitability check issue. This was mainly due to forgetting there was another layer between jobs_do_set_repo and the actual repo setter, with most of the checks I was writing being duplicated across do_set_repo and set_repo. As such the checks in the latter failed due to expecting a name instead of an ident, and things broke spectacularly. Modified: soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs/do.c Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Mon Sep 2 19:28:44 2013 (r256843) +++ soc2013/mattbw/backend/jobs.c Mon Sep 2 19:37:55 2013 (r256844) @@ -89,15 +89,20 @@ jobs_set_repo(struct pkg_jobs *jobs, const char *reponame) { bool success; + enum repo_type type; assert(jobs != NULL); success = true; - if (type_of_repo_name(reponame) == REPO_REMOTE) { + type = type_of_repo_name(reponame); + if (type == REPO_INVALID) { + success = false; + } else if (type == REPO_REMOTE) { int err; - err = pkg_jobs_set_repository(jobs, reponame); + err = pkg_jobs_set_repository(jobs, + pkg_repo_ident_from_name(reponame)); success = (err == EPKG_OK); } Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:28:44 2013 (r256843) +++ soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:37:55 2013 (r256844) @@ -253,36 +253,12 @@ const char *reponame) { bool success; - struct pkg_repo *repo; assert(spec != NULL); assert(jobs != NULL); /* reponame can be NULL */ - success = false; - repo = NULL; - - /* - * We need to convert the repo name to an ident. This is the only - * place an ident works but a name doesn't, it seems. - */ - switch(type_of_repo_name(reponame)) { - case REPO_REMOTE: - success = jobs_set_repo(jobs, - pkg_repo_ident_from_name(reponame)); - break; - case REPO_LOCAL: - case REPO_ANY: - /* - * No need to set the repository name; we're either dealing - * with a local package or a wildcard-repo one. - */ - success = true; - break; - case REPO_INVALID: - success = false; - break; - } + success = jobs_set_repo(jobs, reponame); if (!success) { char *err_message; From owner-svn-soc-all@FreeBSD.ORG Tue Sep 3 18:41:30 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 81CB3A2E for ; Tue, 3 Sep 2013 18:41:30 +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 6C4982E30 for ; Tue, 3 Sep 2013 18:41: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 r83IfU0c081760 for ; Tue, 3 Sep 2013 18:41:30 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r83IfUlb081729 for svn-soc-all@FreeBSD.org; Tue, 3 Sep 2013 18:41:30 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 3 Sep 2013 18:41:30 GMT Message-Id: <201309031841.r83IfUlb081729@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: r256878 - in soc2013/dpl/head/lib/libzcap: . test zlibworker 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, 03 Sep 2013 18:41:30 -0000 Author: dpl Date: Tue Sep 3 18:41:30 2013 New Revision: 256878 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256878 Log: Savepoint before an architectural change. Last commit working with a single child process. Added: soc2013/dpl/head/lib/libzcap/test/testlib.sh (contents, props changed) soc2013/dpl/head/lib/libzcap/zlibworker/data.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/capsicum.h soc2013/dpl/head/lib/libzcap/commands.c soc2013/dpl/head/lib/libzcap/commands.h soc2013/dpl/head/lib/libzcap/deflate.c soc2013/dpl/head/lib/libzcap/gzlib.c soc2013/dpl/head/lib/libzcap/inflate.c soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c soc2013/dpl/head/lib/libzcap/zlibworker/commands.c soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Tue Sep 3 18:41:30 2013 (r256878) @@ -12,8 +12,6 @@ #include #include -#define SUM 0 - pid_t pid = 0; int sv[2]; @@ -29,22 +27,20 @@ perror("zcaplib: socketpair()"); if( (pid = fork()) == 0 ){ - cap_rights_limit(STDIN_FILENO, CAP_READ); - cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT|CAP_IOCTL); - cap_rights_limit(STDERR_FILENO, CAP_WRITE); + if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) + err(1, "Couldn't limit rights"); + if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT) < 0) + err(1, "Couldn't limit rights"); + if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0) + err(1, "Couldn't limit rights"); dup2(sv[0], 3); - cap_rights_limit(3, CAP_WRITE|CAP_READ|CAP_POLL_EVENT); + if (cap_rights_limit(3, CAP_WRITE|CAP_READ|CAP_POLL_EVENT) < 0) + err(1, "Couldn't limit rights"); closefrom(4); - /* open and execl() listener */ - if (access("/usr/libexec/zlibworker", X_OK) < 0) { - perror("zcaplib: access():"); - exit (-1); - } - + /* execl() zlibworker */ if ( execl("/usr/libexec/zlibworker", "zlibworker", NULL) < 0) { - perror("zcaplib: execl:"); - exit (-1); + err(1, "Couldn't find zlibworker."); } exit(0); } else { Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Tue Sep 3 18:41:30 2013 (r256878) @@ -2,16 +2,20 @@ * With Capsicum, we get a compartmentalized, and securer lib. */ #define CAPSICUM -#include -#include -#include #include #include #include #include + +#include +#include +#include #include +#include + #include "commands.h" + #define MAXLEN (5*1024) extern int pid; Modified: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/commands.c Tue Sep 3 18:41:30 2013 (r256878) @@ -10,9 +10,8 @@ #include -void checkChild(void); -void initializeCommand(void); -void destroy(void); +static void initializeCommand(void); +static void destroy(void); /* Basic functions */ @@ -61,7 +60,7 @@ uLong zcapcmd_compressBound(uLong sourceLen); /* gzip file functions */ -gzFile zcapcmd_gzopen(const char *path, int fd, const char *mode); +gzFile zcapcmd_gzopen(int fd, const char *mode); int zcapcmd_gzbuffer(gzFile file, unsigned size); int zcapcmd_gzsetparams(gzFile file, int level, int strategy); int zcapcmd_gzread(gzFile file, voidp buf, unsigned len); @@ -74,7 +73,7 @@ int zcapcmd_gzflush(gzFile file, int flush); z_off_t zcapcmd_gzseek(gzFile file, z_off_t offset, int whence); int zcapcmd_simplecommand(gzFile file, int command); -char * zcapcmd_gzerror(gzFile file, int *errnum); +const char * zcapcmd_gzerror(gzFile file, int *errnum); /* Checksum functions */ uLong zcapcmd_adler32(uLong adler, const Bytef *buf, uInt len); @@ -88,26 +87,21 @@ extern void *data; nvlist_t *nvl, *args, *result; -size_t gzfilesize = sizeof(struct gzFile_s); +size_t gzfilesize = sizeof(gzFile); size_t gzheadersize = sizeof(struct gz_header_s); size_t zstreamsize = sizeof(z_stream); -void -checkChild(void) { +static void +initializeCommand() { if (pid == 0) startChild(); -} - -void -initializeCommand() { - checkChild(); if( (args = nvlist_create(0)) == NULL || (nvl = nvlist_create(0)) == NULL ) err(1, "zcaplib: nvlist_create"); } -void +static void destroy(void) { nvlist_destroy(args); nvlist_destroy(nvl); @@ -119,6 +113,7 @@ int memLevel, int strategy, const char * version, int stream_size) { uLong ret; + const z_stream *newstrm; initializeCommand(); @@ -135,18 +130,19 @@ nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - - ret = nvlist_take_number(result, "result"); - /* We take the "good" struct from the worker. - Here we have the good internal_state. - When we work on the data now, we have to pass it in - buffers, and sync: next_in, avail_in, total_in, next_out, - avail_out, total_out. */ - /* Supposing there's already space reserved for z_stream */ - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); - memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); - memcpy(strm->msg, msg, strlen(msg)+1); + ret = dnvlist_get_number(result, "result", NULL); + /* + * We get the "good" struct from the worker. + * Here we have the good internal_state. + * When we work on the data now, we have to pass + * it in buffers, and sync next_in, avail_in, total_in, + * next_out, avail_out and total_out. + */ + newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); + memcpy(strm, newstrm, zstreamsize); + const char *msg = dnvlist_get_string(result, "msg", NULL); + if (msg != NULL) + memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); } @@ -155,7 +151,8 @@ zcapcmd_deflate(z_streamp strm, int flush) { uLong ret; - + const z_stream *newstrm; + initializeCommand(); nvlist_add_number(nvl, "command", ZCAPCMD_DEFLATEINIT); @@ -164,8 +161,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); /* Supposing there's already space reserved for z_stream */ memcpy(strm, newstrm, zstreamsize); destroy(); @@ -177,7 +174,8 @@ zcapcmd_deflateEnd(z_streamp strm) { uLong ret; - + const z_stream *newstrm; + initializeCommand(); nvlist_add_number(nvl, "command", ZCAPCMD_DEFLATEEND); nvlist_add_binary(args, "strm", (void *)strm, zstreamsize); @@ -185,9 +183,12 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); - memcpy(strm, newstrm, zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); + if (newstrm != NULL) + memcpy(strm, newstrm, zstreamsize); + else + err(1, "libzcap: deflateEnd() destroyed z_stream\n"); destroy(); return(ret); } @@ -197,11 +198,12 @@ const char *version, int stream_size) { uLong ret; - + const z_stream *newstrm; + const char *msg; + initializeCommand(); nvlist_add_number(nvl, "command", ZCAPCMD_INFLATEINIT); - /* No worries here */ nvlist_add_binary(args, "strm", (void *)strm, zstreamsize); nvlist_add_number(args, "windowBits", windowBits); nvlist_add_string(args, "version", version); @@ -210,11 +212,13 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); - memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); - memcpy(strm->msg, msg, strlen(msg)+1); + ret = dnvlist_get_number(result, "result", NULL); + newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); + if (newstrm != NULL) + memcpy(strm, newstrm, zstreamsize); + msg = dnvlist_get_string(result, "msg", NULL); + if (msg != NULL) + memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); } @@ -226,14 +230,14 @@ initializeCommand(); - nvlist_add_number(nvl, "command", ZCAPCMD_DEFLATEINIT); + nvlist_add_number(nvl, "command", ZCAPCMD_INFLATE); nvlist_add_binary(args, "strm", (void *)strm, zstreamsize); nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); /* Supposing there's already space reserved for z_stream */ memcpy(strm, newstrm, zstreamsize); destroy(); @@ -244,18 +248,20 @@ zcapcmd_inflateEnd(z_streamp strm) { uLong ret; - + const z_stream *newstrm; + initializeCommand(); - nvlist_add_number(nvl, "command", ZCAPCMD_DEFLATEINIT); + nvlist_add_number(nvl, "command", ZCAPCMD_INFLATEEND); nvlist_add_binary(args, "strm", (void *)strm, zstreamsize); nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); - memcpy(strm, newstrm, zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); + if (newstrm != NULL) + memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); } @@ -277,8 +283,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -299,8 +305,8 @@ /* The two z_streamp are now copied at the worker. */ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(dest, newstrm, zstreamsize); destroy(); return(ret); @@ -319,11 +325,11 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); /* Save the reseted strm. */ - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); + const char *msg = dnvlist_get_string(result, "msg", NULL); memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); @@ -344,9 +350,9 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); /* Overwrite the old streamp */ - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -370,8 +376,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -391,8 +397,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -414,8 +420,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -436,8 +442,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -461,8 +467,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -482,8 +488,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -503,8 +509,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -523,8 +529,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -545,8 +551,8 @@ /* The two z_streamp are now copied at the worker. */ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(dest, newstrm, zstreamsize); destroy(); return(ret); @@ -565,10 +571,10 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); + const char *msg = dnvlist_get_string(result, "msg", NULL); memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); @@ -588,10 +594,10 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); + const char *msg = dnvlist_get_string(result, "msg", NULL); memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); @@ -612,8 +618,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -632,8 +638,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -654,10 +660,10 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); - gz_headerp newhead = nvlist_take_binary(result, "newhead", gzheadersize); + gz_headerp newhead = (gz_headerp)dnvlist_get_binary(result, "newhead", gzheadersize, NULL, sizeof(NULL)); head->done = newhead->done; destroy(); return(ret); @@ -673,17 +679,16 @@ initializeCommand(); nvlist_add_number(nvl, "command", ZCAPCMD_INFLATEBACKINIT); - /* No worries here */ nvlist_add_binary(args, "strm", (void *)strm, zstreamsize); nvlist_add_number(args, "windowBits", windowBits); nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); - char *msg = nvlist_take_string(result, "msg"); + const char *msg = dnvlist_get_string(result, "msg", NULL); memcpy(strm->msg, msg, strlen(msg)+1); destroy(); return(ret); @@ -703,8 +708,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -723,8 +728,8 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); - z_stream *newstrm = nvlist_take_binary(result, "newstrm", &zstreamsize); + ret = dnvlist_get_number(result, "result", NULL); + const z_stream *newstrm = dnvlist_get_binary(result, "newstrm", &zstreamsize, NULL, sizeof(NULL)); memcpy(strm, newstrm, zstreamsize); destroy(); return(ret); @@ -742,7 +747,7 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -760,32 +765,32 @@ nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } /* gzip file functions */ gzFile -zcapcmd_gzopen(const char *path, int fd, const char *mode) +zcapcmd_gzopen(int fd, const char *mode) { - + gzFile *fileptr; + gzFile file; initializeCommand(); nvlist_add_number(nvl, "command", ZCAPCMD_GZOPEN); - nvlist_add_string(args, "path", path); nvlist_move_descriptor(args, "fd", fd); nvlist_add_string(args, "mode", mode); nvlist_add_nvlist(nvl, "args", args); - + result = sendCommand(nvl); - void *mem = malloc(gzfilesize); - memcpy(mem, - nvlist_take_binary(result, "result", &gzfilesize), - gzfilesize); + fileptr = (gzFile *)dnvlist_get_binary(result, "result", &gzfilesize, NULL, sizeof(NULL)); + file = *fileptr; destroy(); - return((gzFile)mem); + fprintf(stderr, "zcaplib: after zcapcmd_gzopen: fileptr: %p *fileprt: %p\n", fileptr, *fileptr); + fprintf(stderr, "zcaplib: after zcapcmd_gzopen: file: %p\n", file); + return((gzFile)file); } int @@ -801,7 +806,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -820,7 +825,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -828,7 +833,7 @@ int zcapcmd_gzread(gzFile file, voidp buf, unsigned len) { - void * data; + const void * data; initializeCommand(); @@ -839,8 +844,8 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); - data = nvlist_take_binary(result, "data", len); + int ret = dnvlist_get_number(result, "result", NULL); + data = dnvlist_get_binary(result, "data", len, NULL, sizeof(NULL)); memcpy(buf, data, (size_t)len); destroy(); return(ret); @@ -859,7 +864,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -876,7 +881,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -894,7 +899,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -912,7 +917,7 @@ result = sendCommand(nvl); - char *ret = nvlist_take_string(result, "result"); + const char *ret = dnvlist_get_string(result, "result", NULL); if (ret == NULL) return NULL; else @@ -934,7 +939,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -952,7 +957,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -970,7 +975,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -989,7 +994,7 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return ((z_off_t)ret); } @@ -1011,12 +1016,12 @@ result = sendCommand(nvl); - int ret = nvlist_take_number(result, "result"); + int ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } -char * +const char * zcapcmd_gzerror(gzFile file, int *errnum) { @@ -1029,8 +1034,8 @@ result = sendCommand(nvl); /* XXX: Should I malloc space for this? */ - char * ret = nvlist_take_string(result, "result"); - *errnum = nvlist_take_number(result, "zerrno"); + const char * ret = dnvlist_get_string(result, "result", NULL); + *errnum = dnvlist_get_number(result, "zerrno", NULL); destroy(); return(ret); } @@ -1051,7 +1056,7 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -1071,7 +1076,7 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -1081,12 +1086,8 @@ { uLong ret; - checkChild(); - if( (args = nvlist_create(0)) == NULL || - (nvl = nvlist_create(0)) == NULL ) { - perror("zcaplib: nvlist_create"); - return(0); - } + initializeCommand(); + nvlist_add_number(nvl, "command", ZCAPCMD_CRC32); nvlist_add_number(args, "crc", crc); nvlist_add_binary(args, "buf", buf, len); @@ -1095,7 +1096,7 @@ result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } @@ -1114,7 +1115,7 @@ nvlist_add_nvlist(nvl, "args", args); result = sendCommand(nvl); - ret = nvlist_take_number(result, "result"); + ret = dnvlist_get_number(result, "result", NULL); destroy(); return(ret); } \ No newline at end of file Modified: soc2013/dpl/head/lib/libzcap/commands.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.h Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/commands.h Tue Sep 3 18:41:30 2013 (r256878) @@ -13,6 +13,7 @@ */ +#define SOCKETFILENO 3 #define ZCAPCMD_DEFLATEINIT 0 #define ZCAPCMD_DEFLATE 1 Modified: soc2013/dpl/head/lib/libzcap/deflate.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/deflate.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/deflate.c Tue Sep 3 18:41:30 2013 (r256878) @@ -174,9 +174,6 @@ int ZEXPORT deflateEnd (strm) z_streamp strm; { - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; return zcapcmd_deflateEnd(strm); } Modified: soc2013/dpl/head/lib/libzcap/gzlib.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/gzlib.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/gzlib.c Tue Sep 3 18:41:30 2013 (r256878) @@ -27,52 +27,55 @@ { int oflag = 0; int fd; + char *loopmode; - while(*mode) { + strncpy(loopmode, mode, strlen(mode)+1); + while(*loopmode) { switch (*mode){ #ifndef NO_GZCOMPRESS - case('w'): - oflag |= O_WRONLY|O_CREAT|O_TRUNC; - break; - case('a'): - oflag |= O_WRONLY|O_CREAT|O_APPEND; - break; -#endif - case('r'): - oflag |= O_RDONLY; - break; + case('w'): + oflag |= O_WRONLY|O_CREAT|O_TRUNC; + break; + case('a'): + oflag |= O_WRONLY|O_CREAT|O_APPEND; + break; +#endif + case('r'): + oflag |= O_RDONLY; + break; #ifdef O_CLOEXEC - case('e'): - oflag |= O_CLOEXEC; - break; + case('e'): + oflag |= O_CLOEXEC; + break; #endif #ifdef O_EXCL - case('x'): - oflag |= O_EXCL; - break; -#endif - case('+'): - /* Not accepted by gzopen */ - oflag |= O_RDONLY; - break; - default: - ; + case('x'): + oflag |= O_EXCL; + break; +#endif + case('+'): + /* Not accepted by gzopen */ + oflag |= O_RDONLY; + break; + default: + ; } - ++mode; + ++loopmode; } -#ifdef O_LARGEFILE - oflag |= O_LARGEFILE; -#endif -#ifdef O_BINARY - oflag |= O_BINARY; -#endif if ((fd = open(path, oflag)) < 0) { - perror("zcaplib: Couldn't open"); + perror("zcaplib: Couldn't create gzip file"); + abort(); + } + + if (cap_rights_limit(fd, CAP_READ|CAP_SEEK|CAP_WRITE|CAP_FSTAT|CAP_FCNTL) < 0) { + perror("zcaplib: Couldn't limit fd"); + abort(); + } + if (cap_fcntls_limit(fd, CAP_FCNTL_GETFL) < 0) { + perror("zcaplib: Couldn't limit fd"); abort(); } - - cap_rights_limit(fd, CAP_READ|CAP_SEEK|CAP_WRITE|CAP_FSTAT); return gzdopen(fd, mode); } @@ -94,16 +97,6 @@ } /* -- see zlib.h -- */ -#ifdef _WIN32 -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ - return gz_open(path, -2, mode); -} -#endif - -/* -- see zlib.h -- */ extern gzFile zcapcmd_gzbuffer(); int ZEXPORT gzbuffer(file, size) gzFile file; Modified: soc2013/dpl/head/lib/libzcap/inflate.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/inflate.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/inflate.c Tue Sep 3 18:41:30 2013 (r256878) @@ -37,9 +37,6 @@ int ZEXPORT inflateEnd(strm) z_streamp strm; { - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; return zcapcmd_inflateEnd(strm); } Added: soc2013/dpl/head/lib/libzcap/test/testlib.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libzcap/test/testlib.sh Tue Sep 3 18:41:30 2013 (r256878) @@ -0,0 +1,16 @@ +#!/bin/sh + +cd /usr/home/athos/gsoc/head/lib/libzcap/ +sudo make clean all install +cd /usr/home/athos/gsoc/head/lib/libzcap/test +cc -o zcaplibtest -g -Wall -fno-color-diagnostics -lnv -lzcap zcaplibtest.c +echo; echo +echo 'Done compiling library and tester.' +echo + +if [ $1 = "-k" ] +then + ktrace -i ./zcaplibtest +else + ./zcaplibtest +fi Modified: soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Tue Sep 3 17:33:29 2013 (r256877) +++ soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Tue Sep 3 18:41:30 2013 (r256878) @@ -1,61 +1,64 @@ -#include - #include #include #include #include +#include /* Basic functions */ -void testzlibVersion(void); -void testdeflateInit(z_streamp strm); -void testdeflate(z_streamp strm); -void testdeflateEnd(z_streamp strm); -void testinflateInit(z_streamp strm); -void testinflate(z_streamp strm); -void testinflateEnd(z_streamp strm); +static void testzlibVersion(void); +static void testdeflateInit(z_streamp strm); +static void testdeflate(z_streamp strm); +static void testdeflateEnd(z_streamp strm); +static void testinflateInit(z_streamp strm); +static void testinflate(z_streamp strm); +static void testinflateEnd(z_streamp strm); /* gzip functions */ /* Test non-IO and saves a compressed file */ -gzFile testgzbasic(void); +static gzFile testgzbasic(void); /* returns a gzFile of the written file */ -gzFile testgzio(gzFile file); +static gzFile testgzio(gzFile file); /* Test error related functions */ -void testgzerr(gzFile file); +static void testgzerr(gzFile file); /* Advanced functions */ -void testzlibCompileFlags(void); +static void testzlibCompileFlags(void); /* Utility functions */ -void testCompressBound(void); +static void testCompressBound(void); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 17:17:33 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 462C48C1 for ; Wed, 4 Sep 2013 17:17:33 +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 326D32505 for ; Wed, 4 Sep 2013 17:17: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 r84HHXQt050982 for ; Wed, 4 Sep 2013 17:17:33 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84HHXa1050980 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 17:17:33 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 4 Sep 2013 17:17:33 GMT Message-Id: <201309041717.r84HHXa1050980@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: r256900 - 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: Wed, 04 Sep 2013 17:17:33 -0000 Author: mattbw Date: Wed Sep 4 17:17:32 2013 New Revision: 256900 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256900 Log: Change the standard to gnu99. C99 causes GCC to become confused at pkg's C11/gnu99 usage of anonymous unions. Modified: soc2013/mattbw/backend/Makefile Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Wed Sep 4 15:02:14 2013 (r256899) +++ soc2013/mattbw/backend/Makefile Wed Sep 4 17:17:32 2013 (r256900) @@ -93,7 +93,7 @@ CFLAGS+= `pkg-config --cflags ${PKGS}` CFLAGS+= -DPK_COMPILATION -g LDFLAGS+= `pkg-config --libs ${PKGS}` -g -CSTD?= c99 +CSTD?= gnu99 group_map.c: groups group_map.awk sort groups | awk -f group_map.awk > group_map.c From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 18:22: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 57DCA896 for ; Wed, 4 Sep 2013 18:22:04 +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 43E2B2A02 for ; Wed, 4 Sep 2013 18:22: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 r84IM4Oi095376 for ; Wed, 4 Sep 2013 18:22:04 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84IM4xA095362 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 18:22:04 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 4 Sep 2013 18:22:04 GMT Message-Id: <201309041822.r84IM4xA095362@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: r256903 - 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: Wed, 04 Sep 2013 18:22:04 -0000 Author: dpl Date: Wed Sep 4 18:22:03 2013 New Revision: 256903 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256903 Log: First draft of the new sandboxing. Take a look at caspicum.[ch]. Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/capsicum.h soc2013/dpl/head/lib/libzcap/commands.c soc2013/dpl/head/lib/libzcap/commands.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 17:48:41 2013 (r256902) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 18:22:03 2013 (r256903) @@ -1,32 +1,61 @@ #include "capsicum.h" #include "zlib.h" -#include +#include #include #include #include +#include #include #include #include #include #include -pid_t pid = 0; -int sv[2]; +external struct sandbox; +external struct slisthead sandboxes; int startChild(void); void killChild(void); void suicide(int signal); nvlist_t * sendCommand(nvlist_t *nvl); -int -startChild(void) +bool slist_initiated = 0; + +nvlist_t * +sendCommand(nvlist_t *nvl, int socket) +{ + nvlist_t *new; + if( nvlist_send(socket, nvl) != 0 ) + err(1, "zcaplib: nvlist_send() Went wrong"); + if ((new = nvlist_recv(socket)) == NULL) + err(1, "nvlist_recv(): nvlist_t is NULL"); + return (new); +} + +void killChild(void) { + kill(pid, SIGKILL); +} +void suicide(int signal) { + kill(getpid(), SIGKILL); +} + +void +startChild(void *data) { + int procd, sv[2]; + struct sandbox *newsandbox; + + if ((newsandbox = malloc(sizeof (struct sandbox)) == NULL) + err(1, "Couldn't allocate memory for sandboxes"); + + sv[0] = sv[1] = 0; if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) perror("zcaplib: socketpair()"); - if( (pid = fork()) == 0 ){ + procd = pdfork(); + if (pid == 0 ){ if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) err(1, "Couldn't limit rights"); if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT) < 0) @@ -43,28 +72,87 @@ err(1, "Couldn't find zlibworker."); } exit(0); + } else if (pid == -1) { + err(1, "Couldn't fork"); } else { + close(sv[1]); signal(SIGCHLD, suicide); atexit(killChild); + sandbox->dataptr = data; + sandbox->pd = procd; + sandbox->socket = sv[0]; } - - return pid; } -nvlist_t * -sendCommand( nvlist_t *nvl ) +/* + * This function should be called only by: + * - gzopen() + * - deflateInit() + * - inflateInit() + */ +struct sandbox * +startSandbox(void *data) { - nvlist_t *new; - if( nvlist_send(sv[1], nvl) != 0 ) - err(1, "zcaplib: nvlist_send() Went wrong"); - if ((new = nvlist_recv(sv[1])) == NULL) - err(1, "nvlist_recv(): nvlist_t is NULL"); - return (new); + struct sandbox *newsandbox; + + if (!slist_initiated) { + SLIST_INIT(&sandboxes); + slist_initiated = 1; + } + + /* Here we add a sandbox used for non-structure related stuff */ + /* This will be the first sandbox always */ + if (SLIST_EMPTY(&sandboxes)) { + newsandbox = startChild(newsandbox, NULL); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + } + + /* Create and add the real sandbox */ + newsandbox = startChild(data); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + + return (newsandbox); } -void killChild(void) { - kill(pid, SIGKILL); +/* + * Kills the sandbox, and deletes + * the associated struct sandbox. + */ +int +stopSandbox(struct sandbox *sandbox) +{ + int sandboxpid; + + if ((sandboxpid = pdgetpid(sandbox->pd)) < 0) + err(1, "Couldn't get child PID"); + + if (kill(SIGKILL, sandboxpid) < 0) + err(1, "Couldn't kill child"); + + SLIST_REMOVE(&sandboxes, sandbox, entry, entries); + free(sandbox); } -void suicide(int signal) { - kill(getpid(), SIGKILL); + +/* + * Finds the struct sandbox for + * a pointer to the data structure + * the sandbox is related to. + * Returns NULL if not found. + */ +struct sandbox * +findsanbox(void *ptr) +{ + struct sandbox *sandbox; + + sandbox = NULL; + + if (ptr == NULL) + return (SLIST_FIRST(&sandboxes)); + + SLIST_FOREACH(sandbox, &sandboxes, entries) + if (sandbox->dataptr == ptr) + return (sandbox); + + /* Not found */ + return (NULL); } \ No newline at end of file Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 17:48:41 2013 (r256902) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 18:22:03 2013 (r256903) @@ -1,5 +1,5 @@ /* - * With Capsicum, we get a compartmentalized, and securer lib. + * We're using Capsicum! */ #define CAPSICUM #include @@ -20,7 +20,22 @@ extern int pid; extern int sv[2]; +extern struct sandbox * sandboxes; extern int startChild(void); extern void killChild(void); extern nvlist_t * sendCommand(nvlist_t *nvl); + +/* head of singly-linked list. */ +SLIST_HEAD(slisthead, sandbox) sandboxes = SLIST_HEAD_INITIALIZER(head); + +/* + * This structure holds a relation of structs of data structs, + * and its related process descriptor (pd). + */ +struct sandbox { + void * dataptr; /* Pointer to the data structure of the lib */ + int pd; /* Process descriptor */ + int socket; /* Socket we have to pass the data through */ + SLIST_ENTRY(entry) entries; /* Singly-linked list. */ +} Modified: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.c Wed Sep 4 17:48:41 2013 (r256902) +++ soc2013/dpl/head/lib/libzcap/commands.c Wed Sep 4 18:22:03 2013 (r256903) @@ -82,7 +82,6 @@ uLong zcapcmd_crc32_combine(uLong crc1, uLong crc2, z_off64_t len2); -extern pid_t pid; extern nvlist_t *sendCommand(nvlist_t *); extern void *data; @@ -92,13 +91,15 @@ size_t zstreamsize = sizeof(z_stream); -static void -initializeCommand() { - if (pid == 0) - startChild(); +static sandbox_s* +initializeCommand(void *ptr) { + sandbox_s *sanbox; + sandbox = findSandbox(ptr); if( (args = nvlist_create(0)) == NULL || (nvl = nvlist_create(0)) == NULL ) err(1, "zcaplib: nvlist_create"); + + return sandbox; } static void Modified: soc2013/dpl/head/lib/libzcap/commands.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.h Wed Sep 4 17:48:41 2013 (r256902) +++ soc2013/dpl/head/lib/libzcap/commands.h Wed Sep 4 18:22:03 2013 (r256903) @@ -13,8 +13,6 @@ */ -#define SOCKETFILENO 3 - #define ZCAPCMD_DEFLATEINIT 0 #define ZCAPCMD_DEFLATE 1 #define ZCAPCMD_DEFLATEEND 2 From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 18:26:31 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 DE74F992 for ; Wed, 4 Sep 2013 18:26:30 +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 BBF842A5E for ; Wed, 4 Sep 2013 18:26: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 r84IQU3q047846 for ; Wed, 4 Sep 2013 18:26:30 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84IQUx5047832 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 18:26:30 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 4 Sep 2013 18:26:30 GMT Message-Id: <201309041826.r84IQUx5047832@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: r256904 - soc2013/mattbw/port 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, 04 Sep 2013 18:26:31 -0000 Author: mattbw Date: Wed Sep 4 18:26:30 2013 New Revision: 256904 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256904 Log: Add (experimental) port. This currently uses a tarball in my university web-space, which is a rather precarious place in which to put it. This will probably change soon. Added: soc2013/mattbw/port/ soc2013/mattbw/port/Makefile soc2013/mattbw/port/distinfo soc2013/mattbw/port/pkg-descr soc2013/mattbw/port/pkg-message soc2013/mattbw/port/pkg-plist Added: soc2013/mattbw/port/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/port/Makefile Wed Sep 4 18:26:30 2013 (r256904) @@ -0,0 +1,19 @@ +# %FREEBSD$ + +PORTNAME= pkgpackagekit +PORTVERSION= 0.1 +CATEGORIES= ports-mgmt +MASTER_SITES= http://www-student.cs.york.ac.uk/~mbw500/ + +MAINTAINER= mattbw@FreeBSD.org +COMMENT= PackageKit backend for pkgng + +LIB_DEPENDS= libpackagekit-glib2.so:${PORTSDIR}/ports-mgmt/packagekit \ + libpkg.so:${PORTSDIR}/ports-mgmt/pkg + +WRKSRC= ${WRKDIR}/backend + +post-install: + cat pkg-message + +.include Added: soc2013/mattbw/port/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/port/distinfo Wed Sep 4 18:26:30 2013 (r256904) @@ -0,0 +1,2 @@ +SHA256 (pkgpackagekit-0.1.tar.gz) = 85562b2fbd783579a97eddd3616fdf1f511618a85dcf89743f7483d8b06823e1 +SIZE (pkgpackagekit-0.1.tar.gz) = 40960 Added: soc2013/mattbw/port/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/port/pkg-descr Wed Sep 4 18:26:30 2013 (r256904) @@ -0,0 +1,6 @@ +This is an experimental PackageKit backend for pkgng, the FreeBSD next +generation package manager. In conjunction with PackageKit frontends such as +Apper and GPackageKit, it allows for maintenance of the pkgng system inside a +graphical user environment. + +WWW: http://wiki.FreeBSD.org/SummerOfCode2013/pkgPackagekit Added: soc2013/mattbw/port/pkg-message ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/port/pkg-message Wed Sep 4 18:26:30 2013 (r256904) @@ -0,0 +1,11 @@ +In order to enable this backend by default, you will need to change the file +/usr/local/etc/PackageKit/PackageKit.conf, replacing the line: + +< DefaultBackend=ports + +with: + +> DefaultBackend=pkgng + +Otherwise, PackageKit will default to using the ports backend unless you +explicitly launch packagekitd with a different backend. Added: soc2013/mattbw/port/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/port/pkg-plist Wed Sep 4 18:26:30 2013 (r256904) @@ -0,0 +1 @@ +lib/packagekit-backend/libpk_backend_pkgng.so From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 18:28:03 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 9EDA7ACE for ; Wed, 4 Sep 2013 18:28:03 +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 716B02A73 for ; Wed, 4 Sep 2013 18:28:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r84IS3V1060613 for ; Wed, 4 Sep 2013 18:28:03 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84IS3G5060611 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 18:28:03 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 4 Sep 2013 18:28:03 GMT Message-Id: <201309041828.r84IS3G5060611@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: r256905 - 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: Wed, 04 Sep 2013 18:28:03 -0000 Author: dpl Date: Wed Sep 4 18:28:03 2013 New Revision: 256905 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256905 Log: Now the creation of sandbox makes more sense. Modified: soc2013/dpl/head/lib/libzcap/capsicum.c Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 18:26:30 2013 (r256904) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 18:28:03 2013 (r256905) @@ -86,26 +86,16 @@ /* * This function should be called only by: - * - gzopen() - * - deflateInit() - * - inflateInit() + * gzopen(), deflateInit(), inflateInit(), + * inflateBackInit(). */ struct sandbox * startSandbox(void *data) { struct sandbox *newsandbox; - if (!slist_initiated) { - SLIST_INIT(&sandboxes); - slist_initiated = 1; - } - - /* Here we add a sandbox used for non-structure related stuff */ - /* This will be the first sandbox always */ - if (SLIST_EMPTY(&sandboxes)) { - newsandbox = startChild(newsandbox, NULL); - SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); - } + if (!slist_initiated) + startNullSandbox(); /* Create and add the real sandbox */ newsandbox = startChild(data); @@ -114,9 +104,26 @@ return (newsandbox); } +void +startNullSandbox(void) +{ + if (!slist_initiated) { + SLIST_INIT(&sandboxes); + + /* Here we add a sandbox used for non-structure related stuff */ + /* This will be the first sandbox always */ + if (SLIST_EMPTY(&sandboxes)) { + newsandbox = startChild(newsandbox, NULL); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + } + } + slist_initiated = 1; +} + /* - * Kills the sandbox, and deletes - * the associated struct sandbox. + * Kills the sandbox, and deletes the associated + * struct sandbox. Should be called by: gzclose, + * deflateEnd, inflateEnd (inflateBackEnd). */ int stopSandbox(struct sandbox *sandbox) @@ -140,7 +147,7 @@ * Returns NULL if not found. */ struct sandbox * -findsanbox(void *ptr) +findsandbox(void *ptr) { struct sandbox *sandbox; From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 18:59: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 29CBF992 for ; Wed, 4 Sep 2013 18:59:40 +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 15C7C2C54 for ; Wed, 4 Sep 2013 18:59: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 r84IxdSO095338 for ; Wed, 4 Sep 2013 18:59:39 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84Ixdxp095335 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 18:59:39 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 4 Sep 2013 18:59:39 GMT Message-Id: <201309041859.r84Ixdxp095335@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: r256906 - 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: Wed, 04 Sep 2013 18:59:40 -0000 Author: dpl Date: Wed Sep 4 18:59:39 2013 New Revision: 256906 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256906 Log: mini-update. 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 Wed Sep 4 18:28:03 2013 (r256905) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 18:59:39 2013 (r256906) @@ -13,76 +13,20 @@ #include #include -external struct sandbox; -external struct slisthead sandboxes; +extern struct sandbox; +extern struct slisthead sandboxes; -int startChild(void); +struct sandbox * startSandbox(void *data); +int stopSandbox(struct sandbox *sandbox); +void startNullSandbox(void); +struct sandbox * findSandbox(void *ptr); +struct sandbox *startChild(void *data); void killChild(void); void suicide(int signal); -nvlist_t * sendCommand(nvlist_t *nvl); +nvlist_t * sendCommand(nvlist_t *nvl, int socket); bool slist_initiated = 0; -nvlist_t * -sendCommand(nvlist_t *nvl, int socket) -{ - nvlist_t *new; - if( nvlist_send(socket, nvl) != 0 ) - err(1, "zcaplib: nvlist_send() Went wrong"); - if ((new = nvlist_recv(socket)) == NULL) - err(1, "nvlist_recv(): nvlist_t is NULL"); - return (new); -} - -void killChild(void) { - kill(pid, SIGKILL); -} -void suicide(int signal) { - kill(getpid(), SIGKILL); -} - -void -startChild(void *data) -{ - int procd, sv[2]; - struct sandbox *newsandbox; - - if ((newsandbox = malloc(sizeof (struct sandbox)) == NULL) - err(1, "Couldn't allocate memory for sandboxes"); - - sv[0] = sv[1] = 0; - if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) - perror("zcaplib: socketpair()"); - - procd = pdfork(); - if (pid == 0 ){ - if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) - err(1, "Couldn't limit rights"); - if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT) < 0) - err(1, "Couldn't limit rights"); - if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0) - err(1, "Couldn't limit rights"); - dup2(sv[0], 3); - if (cap_rights_limit(3, CAP_WRITE|CAP_READ|CAP_POLL_EVENT) < 0) - err(1, "Couldn't limit rights"); - closefrom(4); - - /* execl() zlibworker */ - if ( execl("/usr/libexec/zlibworker", "zlibworker", NULL) < 0) { - err(1, "Couldn't find zlibworker."); - } - exit(0); - } else if (pid == -1) { - err(1, "Couldn't fork"); - } else { - close(sv[1]); - signal(SIGCHLD, suicide); - atexit(killChild); - sandbox->dataptr = data; - sandbox->pd = procd; - sandbox->socket = sv[0]; - } -} /* * This function should be called only by: @@ -104,22 +48,6 @@ return (newsandbox); } -void -startNullSandbox(void) -{ - if (!slist_initiated) { - SLIST_INIT(&sandboxes); - - /* Here we add a sandbox used for non-structure related stuff */ - /* This will be the first sandbox always */ - if (SLIST_EMPTY(&sandboxes)) { - newsandbox = startChild(newsandbox, NULL); - SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); - } - } - slist_initiated = 1; -} - /* * Kills the sandbox, and deletes the associated * struct sandbox. Should be called by: gzclose, @@ -140,19 +68,33 @@ free(sandbox); } +/* Starts the default sandbox. */ +void +startNullSandbox(void) +{ + if (!slist_initiated) { + sandboxes = SLIST_HEAD_INITIALIZER(head); + SLIST_INIT(&sandboxes); + /* Here we add a sandbox used for non-structure related stuff */ + /* This will be the first sandbox always */ + if (SLIST_EMPTY(&sandboxes)) { + newsandbox = startChild(newsandbox, NULL); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + } + } + slist_initiated = 1; +} + /* * Finds the struct sandbox for * a pointer to the data structure * the sandbox is related to. - * Returns NULL if not found. */ struct sandbox * -findsandbox(void *ptr) +findSandbox(void *ptr) { struct sandbox *sandbox; - sandbox = NULL; - if (ptr == NULL) return (SLIST_FIRST(&sandboxes)); @@ -162,4 +104,65 @@ /* Not found */ return (NULL); -} \ No newline at end of file +} + +struct sandbox * +startChild(void *data) +{ + int procd, sv[2]; + struct sandbox *newsandbox; + + if ((newsandbox = malloc(sizeof (struct sandbox)) == NULL) + err(1, "Couldn't allocate memory for sandboxes"); + + sv[0] = sv[1] = 0; + if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) + perror("zcaplib: socketpair()"); + + procd = pdfork(); + if (pid == 0 ){ + if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) + err(1, "Couldn't limit rights"); + if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT) < 0) + err(1, "Couldn't limit rights"); + if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0) + err(1, "Couldn't limit rights"); + dup2(sv[0], 3); + if (cap_rights_limit(3, CAP_WRITE|CAP_READ|CAP_POLL_EVENT) < 0) + err(1, "Couldn't limit rights"); + closefrom(4); + + /* execl() zlibworker */ + if ( execl("/usr/libexec/zlibworker", "zlibworker", NULL) < 0) { + err(1, "Couldn't find zlibworker."); + } + exit(0); + } else if (pid == -1) { + err(1, "Couldn't fork"); + } else { + close(sv[1]); + signal(SIGCHLD, suicide); + atexit(killChild); + sandbox->dataptr = data; + sandbox->pd = procd; + sandbox->socket = sv[0]; + } +} + +void killChild(void) { + kill(pid, SIGKILL); +} +void suicide(int signal) { + kill(getpid(), SIGKILL); +} + +nvlist_t * +sendCommand(nvlist_t *nvl, int socket) +{ + nvlist_t *new; + if( nvlist_send(socket, nvl) != 0 ) + err(1, "zcaplib: nvlist_send() Went wrong"); + if ((new = nvlist_recv(socket)) == NULL) + err(1, "nvlist_recv(): nvlist_t is NULL"); + return (new); +} Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 18:28:03 2013 (r256905) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 18:59:39 2013 (r256906) @@ -18,16 +18,18 @@ #define MAXLEN (5*1024) -extern int pid; -extern int sv[2]; -extern struct sandbox * sandboxes; - -extern int startChild(void); -extern void killChild(void); -extern nvlist_t * sendCommand(nvlist_t *nvl); +struct sandbox * startSandbox(void *data); +int stopSandbox(struct sandbox *sandbox); +void startNullSandbox(void); +struct sandbox * findSandbox(void *ptr); +struct sandbox *startChild(void *data); +void killChild(void); +void suicide(int signal); +nvlist_t * sendCommand(nvlist_t *nvl, int socket); /* head of singly-linked list. */ -SLIST_HEAD(slisthead, sandbox) sandboxes = SLIST_HEAD_INITIALIZER(head); +struct slisthead sandboxes; +SLIST_HEAD(slisthead, sandbox) sandboxes; /* * This structure holds a relation of structs of data structs, @@ -38,4 +40,4 @@ int pd; /* Process descriptor */ int socket; /* Socket we have to pass the data through */ SLIST_ENTRY(entry) entries; /* Singly-linked list. */ -} +}; From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 19:07: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 CE2CEA89 for ; Wed, 4 Sep 2013 19:07:06 +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 B96032CB6 for ; Wed, 4 Sep 2013 19:07: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 r84J76S2019183 for ; Wed, 4 Sep 2013 19:07:06 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84J76oJ019161 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 19:07:06 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 4 Sep 2013 19:07:06 GMT Message-Id: <201309041907.r84J76oJ019161@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: r256909 - soc2013/dpl/head/lib/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: Wed, 04 Sep 2013 19:07:07 -0000 Author: dpl Date: Wed Sep 4 19:07:06 2013 New Revision: 256909 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256909 Log: Added libnv to my branch. Added: soc2013/dpl/head/lib/libnv/ soc2013/dpl/head/lib/libnv/Makefile soc2013/dpl/head/lib/libnv/dnv.h soc2013/dpl/head/lib/libnv/dnvlist.c soc2013/dpl/head/lib/libnv/msgio.c soc2013/dpl/head/lib/libnv/msgio.h soc2013/dpl/head/lib/libnv/nv.h soc2013/dpl/head/lib/libnv/nv_impl.h soc2013/dpl/head/lib/libnv/nvlist.c soc2013/dpl/head/lib/libnv/nvlist_impl.h soc2013/dpl/head/lib/libnv/nvpair.c soc2013/dpl/head/lib/libnv/nvpair_impl.h Added: soc2013/dpl/head/lib/libnv/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/Makefile Wed Sep 4 19:07:06 2013 (r256909) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +LIB= nv +SHLIBDIR?= /lib +SHLIB_MAJOR= 0 + +SRCS= dnvlist.c +SRCS+= msgio.c +SRCS+= nvlist.c +SRCS+= nvpair.c +INCS= nv.h +INCS+= dnv.h + +CFLAGS+=-ggdb + +.include Added: soc2013/dpl/head/lib/libnv/dnv.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/dnv.h Wed Sep 4 19:07:06 2013 (r256909) @@ -0,0 +1,87 @@ +/*- + * 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 _DNV_H_ +#define _DNV_H_ + +#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 + +/* + * The dnvlist_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. + * If no element of the given name and type exists, the function will return + * provided default value. + */ + +const nvpair_t *dnvlist_get_nvpair(const nvlist_t *nvl, const char *name, const nvpair_t *defval); +bool dnvlist_get_bool(const nvlist_t *nvl, const char *name, bool defval); +uint64_t dnvlist_get_number(const nvlist_t *nvl, const char *name, uint64_t defval); +const char *dnvlist_get_string(const nvlist_t *nvl, const char *name, const char *defval); +const nvlist_t *dnvlist_get_nvlist(const nvlist_t *nvl, const char *name, const nvlist_t *defval); +int dnvlist_get_descriptor(const nvlist_t *nvl, const char *name, int defval); +const void *dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep, const void *defval, size_t defsize); + +const nvpair_t *dnvlist_getf_nvpair(const nvlist_t *nvl, const nvpair_t *defval, const char *namefmt, ...) __printflike(3, 4); +bool dnvlist_getf_bool(const nvlist_t *nvl, bool defval, const char *namefmt, ...) __printflike(3, 4); +uint64_t dnvlist_getf_number(const nvlist_t *nvl, uint64_t defval, const char *namefmt, ...) __printflike(3, 4); +const char *dnvlist_getf_string(const nvlist_t *nvl, const char *defval, const char *namefmt, ...) __printflike(3, 4); +const nvlist_t *dnvlist_getf_nvlist(const nvlist_t *nvl, const nvlist_t *defval, const char *namefmt, ...) __printflike(3, 4); +int dnvlist_getf_descriptor(const nvlist_t *nvl, int defval, const char *namefmt, ...) __printflike(3, 4); +const void *dnvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const void *defval, size_t defsize, const char *namefmt, ...) __printflike(5, 6); + +const nvpair_t *dnvlist_getv_nvpair(const nvlist_t *nvl, const nvpair_t *defval, const char *namefmt, va_list nameap) __printflike(3, 0); +bool dnvlist_getv_bool(const nvlist_t *nvl, bool defval, const char *namefmt, va_list nameap) __printflike(3, 0); +uint64_t dnvlist_getv_number(const nvlist_t *nvl, uint64_t defval, const char *namefmt, va_list nameap) __printflike(3, 0); +const char *dnvlist_getv_string(const nvlist_t *nvl, const char *defval, const char *namefmt, va_list nameap) __printflike(3, 0); +const nvlist_t *dnvlist_getv_nvlist(const nvlist_t *nvl, const nvlist_t *defval, const char *namefmt, va_list nameap) __printflike(3, 0); +int dnvlist_getv_descriptor(const nvlist_t *nvl, int defval, const char *namefmt, va_list nameap) __printflike(3, 0); +const void *dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval, size_t defsize, const char *namefmt, va_list nameap) __printflike(5, 0); + +#endif /* !_DNV_H_ */ Added: soc2013/dpl/head/lib/libnv/dnvlist.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/dnvlist.c Wed Sep 4 19:07:06 2013 (r256909) @@ -0,0 +1,163 @@ +/*- + * 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 "nv.h" + +#include "dnv.h" + +#define DNVLIST_GET(ftype, type) \ +ftype \ +dnvlist_get_##type(const nvlist_t *nvl, const char *name, ftype defval) \ +{ \ + \ + return (dnvlist_getf_##type(nvl, defval, "%s", name)); \ +} + +DNVLIST_GET(const nvpair_t *, nvpair) +DNVLIST_GET(bool, bool) +DNVLIST_GET(uint64_t, number) +DNVLIST_GET(const char *, string) +DNVLIST_GET(const nvlist_t *, nvlist) +DNVLIST_GET(int, descriptor) + +#undef DNVLIST_GET + +const void * +dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep, + const void *defval, size_t defsize) +{ + + return (dnvlist_getf_binary(nvl, sizep, defval, defsize, "%s", name)); +} + +#define DNVLIST_GETF(ftype, type) \ +ftype \ +dnvlist_getf_##type(const nvlist_t *nvl, ftype defval, \ + const char *namefmt, ...) \ +{ \ + va_list nameap; \ + ftype value; \ + \ + va_start(nameap, namefmt); \ + value = dnvlist_getv_##type(nvl, defval, namefmt, nameap); \ + va_end(nameap); \ + \ + return (value); \ +} + +DNVLIST_GETF(const nvpair_t *, nvpair) +DNVLIST_GETF(bool, bool) +DNVLIST_GETF(uint64_t, number) +DNVLIST_GETF(const char *, string) +DNVLIST_GETF(const nvlist_t *, nvlist) +DNVLIST_GETF(int, descriptor) + +#undef DNVLIST_GETF + +const void * +dnvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const void *defval, + size_t defsize, const char *namefmt, ...) +{ + va_list nameap; + const void *value; + + va_start(nameap, namefmt); + value = dnvlist_getv_binary(nvl, sizep, defval, defsize, namefmt, + nameap); + va_end(nameap); + + return (value); +} + +const nvpair_t * +dnvlist_getv_nvpair(const nvlist_t *nvl, const nvpair_t *defval, + const char *namefmt, va_list nameap) +{ + va_list cnameap; + const nvpair_t *value; + + va_copy(cnameap, nameap); + if (nvlist_existsv(nvl, namefmt, cnameap)) + value = nvlist_getv_nvpair(nvl, namefmt, nameap); + else + value = defval; + va_end(cnameap); + return (value); +} + +#define DNVLIST_GETV(ftype, type) \ +ftype \ +dnvlist_getv_##type(const nvlist_t *nvl, ftype defval, \ + const char *namefmt, va_list nameap) \ +{ \ + va_list cnameap; \ + ftype value; \ + \ + va_copy(cnameap, nameap); \ + if (nvlist_existsv_##type(nvl, namefmt, cnameap)) \ + value = nvlist_getv_##type(nvl, namefmt, nameap); \ + else \ + value = defval; \ + va_end(cnameap); \ + return (value); \ +} + +DNVLIST_GETV(bool, bool) +DNVLIST_GETV(uint64_t, number) +DNVLIST_GETV(const char *, string) +DNVLIST_GETV(const nvlist_t *, nvlist) +DNVLIST_GETV(int, descriptor) + +#undef DNVLIST_GETV + +const void * +dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval, + size_t defsize, const char *namefmt, va_list nameap) +{ + va_list cnameap; + const void *value; + + va_copy(cnameap, nameap); + if (nvlist_existsv_binary(nvl, namefmt, cnameap)) { + value = nvlist_getv_binary(nvl, sizep, namefmt, nameap); + } else { + if (sizep != NULL) + *sizep = defsize; + value = defval; + } + va_end(cnameap); + return (value); +} Added: soc2013/dpl/head/lib/libnv/msgio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/msgio.c Wed Sep 4 19:07:06 2013 (r256909) @@ -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/head/lib/libnv/msgio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/msgio.h Wed Sep 4 19:07:06 2013 (r256909) @@ -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/head/lib/libnv/nv.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libnv/nv.h Wed Sep 4 19:07:06 2013 (r256909) @@ -0,0 +1,347 @@ +/*- + * 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 + +/* 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 +/* + * Perform case-insensitive lookups of provided names. + */ +#define NV_FLAG_IGNORE_CASE 0x08 + +nvlist_t *nvlist_create(int flags); +void nvlist_destroy(nvlist_t *nvl); +int nvlist_error(const nvlist_t *nvl); +bool nvlist_empty(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_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_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); + +/* + * 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, const 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_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_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); + +/* + * The nvlist_move functions add the given name/value pair. + * The functions consumes provided buffer. + */ + +void nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp); +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_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_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); + +/* + * 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. + */ + +const 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 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 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); + +/* + * 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); + +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); + +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); + +/* 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_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_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); + +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_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); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Sep 4 21:18:22 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 BF62EA37 for ; Wed, 4 Sep 2013 21:18:22 +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 9CD8726A0 for ; Wed, 4 Sep 2013 21:18: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 r84LIMDs081067 for ; Wed, 4 Sep 2013 21:18:22 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r84LIMKB081057 for svn-soc-all@FreeBSD.org; Wed, 4 Sep 2013 21:18:22 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 4 Sep 2013 21:18:22 GMT Message-Id: <201309042118.r84LIMKB081057@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: r256914 - 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: Wed, 04 Sep 2013 21:18:22 -0000 Author: dpl Date: Wed Sep 4 21:18:22 2013 New Revision: 256914 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256914 Log: Simplified capsicum.h. Now it doesn't include other files, except what is needed. Also, it has been guarded. Also, I'm working on the infrastructure of the sandbox. Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/capsicum.h soc2013/dpl/head/lib/libzcap/zconf.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 20:55:56 2013 (r256913) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Wed Sep 4 21:18:22 2013 (r256914) @@ -1,10 +1,12 @@ #include "capsicum.h" #include "zlib.h" +#include +#include +#include #include -#include #include -#include +#include #include #include @@ -13,8 +15,8 @@ #include #include -extern struct sandbox; -extern struct slisthead sandboxes; +struct sandbox; +struct slisthead sandboxes; struct sandbox * startSandbox(void *data); int stopSandbox(struct sandbox *sandbox); @@ -56,12 +58,12 @@ int stopSandbox(struct sandbox *sandbox) { - int sandboxpid; + int pid; - if ((sandboxpid = pdgetpid(sandbox->pd)) < 0) + if (pdgetpid(sandbox->pd, &pid) < 0) err(1, "Couldn't get child PID"); - if (kill(SIGKILL, sandboxpid) < 0) + if (kill(SIGKILL, pid) < 0) err(1, "Couldn't kill child"); SLIST_REMOVE(&sandboxes, sandbox, entry, entries); @@ -72,14 +74,15 @@ void startNullSandbox(void) { + struct sandbox newsandbox; if (!slist_initiated) { sandboxes = SLIST_HEAD_INITIALIZER(head); SLIST_INIT(&sandboxes); /* Here we add a sandbox used for non-structure related stuff */ /* This will be the first sandbox always */ if (SLIST_EMPTY(&sandboxes)) { - newsandbox = startChild(newsandbox, NULL); - SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + newsandbox = startChild(NULL); + SLIST_INSERT_HEAD(sandboxes, newsandbox, entries); } } slist_initiated = 1; @@ -112,7 +115,7 @@ int procd, sv[2]; struct sandbox *newsandbox; - if ((newsandbox = malloc(sizeof (struct sandbox)) == NULL) + if ((newsandbox = malloc(sizeof (struct sandbox))) == NULL) err(1, "Couldn't allocate memory for sandboxes"); sv[0] = sv[1] = 0; @@ -120,7 +123,7 @@ perror("zcaplib: socketpair()"); procd = pdfork(); - if (pid == 0 ){ + if (procd == 0 ){ if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) err(1, "Couldn't limit rights"); if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE|CAP_FSTAT) < 0) @@ -137,20 +140,23 @@ err(1, "Couldn't find zlibworker."); } exit(0); - } else if (pid == -1) { + } else if (procd == -1) { err(1, "Couldn't fork"); } else { close(sv[1]); signal(SIGCHLD, suicide); atexit(killChild); - sandbox->dataptr = data; - sandbox->pd = procd; - sandbox->socket = sv[0]; + newsandbox->dataptr = data; + newsandbox->pd = procd; + newsandbox->socket = sv[0]; } } void killChild(void) { - kill(pid, SIGKILL); + int pid; + SLIST_FOREACH(sandbox, &sandboxes, entries) + if (pdgetpid(sandbox->pd, &pid) > 0) + kill(SIGKILL, pid) } void suicide(int signal) { kill(getpid(), SIGKILL); Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 20:55:56 2013 (r256913) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Wed Sep 4 21:18:22 2013 (r256914) @@ -1,20 +1,12 @@ /* * We're using Capsicum! */ -#define CAPSICUM -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#ifndef CAPSICUM_H +#define CAPSICUM_H -#include "commands.h" +#include +#include #define MAXLEN (5*1024) @@ -41,3 +33,5 @@ int socket; /* Socket we have to pass the data through */ SLIST_ENTRY(entry) entries; /* Singly-linked list. */ }; + +#endif /* CAPSICUM_H */ \ No newline at end of file Modified: soc2013/dpl/head/lib/libzcap/zconf.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/zconf.h Wed Sep 4 20:55:56 2013 (r256913) +++ soc2013/dpl/head/lib/libzcap/zconf.h Wed Sep 4 21:18:22 2013 (r256914) @@ -480,7 +480,6 @@ /* * This is hard-configured for FreeBSD. */ -#include "capsicum.h" #define z_off_t off_t #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 02:56:59 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 1E18E543 for ; Thu, 5 Sep 2013 02:56:59 +0000 (UTC) (envelope-from ccqin@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 0951B2F36 for ; Thu, 5 Sep 2013 02: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 r852uw4W083688 for ; Thu, 5 Sep 2013 02:56:58 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r852uwWA083662 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 02:56:58 GMT (envelope-from ccqin@FreeBSD.org) Date: Thu, 5 Sep 2013 02:56:58 GMT Message-Id: <201309050256.r852uwWA083662@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256929 - in soc2013/ccqin/head/sys: dev/bwn dev/usb/wlan net80211 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: Thu, 05 Sep 2013 02:56:59 -0000 Author: ccqin Date: Thu Sep 5 02:56:58 2013 New Revision: 256929 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256929 Log: rm mh_ccb from mbuf (we need it as a mbug_tag) and fix some "unused variable" compile error. Modified: soc2013/ccqin/head/sys/dev/bwn/if_bwn.c soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c soc2013/ccqin/head/sys/net80211/ieee80211_rssadapt.c soc2013/ccqin/head/sys/sys/mbuf.h Modified: soc2013/ccqin/head/sys/dev/bwn/if_bwn.c ============================================================================== --- soc2013/ccqin/head/sys/dev/bwn/if_bwn.c Thu Sep 5 01:13:26 2013 (r256928) +++ soc2013/ccqin/head/sys/dev/bwn/if_bwn.c Thu Sep 5 02:56:58 2013 (r256929) @@ -8992,8 +8992,9 @@ struct bwn_stats *stats = &mac->mac_stats; struct ieee80211_node *ni; struct ieee80211vap *vap; - int retrycnt = 0, slot; - + /*int retrycnt = 0, slot;*/ + int slot; + BWN_ASSERT_LOCKED(mac->mac_sc); if (status->im) Modified: soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c Thu Sep 5 01:13:26 2013 (r256928) +++ soc2013/ccqin/head/sys/dev/usb/wlan/if_zyd.c Thu Sep 5 02:56:58 2013 (r256929) @@ -665,8 +665,8 @@ */ ni = ieee80211_find_txnode(vap, retry->macaddr); if (ni != NULL) { - int retrycnt = - (int)(le16toh(retry->count) & 0xff); + /*int retrycnt = + (int)(le16toh(retry->count) & 0xff);*/ #if 0 ieee80211_ratectl_tx_complete(vap, ni, Modified: soc2013/ccqin/head/sys/net80211/ieee80211_rssadapt.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_rssadapt.c Thu Sep 5 01:13:26 2013 (r256928) +++ soc2013/ccqin/head/sys/net80211/ieee80211_rssadapt.c Thu Sep 5 02:56:58 2013 (r256929) @@ -84,8 +84,7 @@ static void rssadapt_raise_rate(struct ieee80211_rssadapt_node *, int, int); static void rssadapt_tx_complete(const struct ieee80211vap *, - const struct ieee80211_node *, int, - void *, void *); + const struct ieee80211_node *, struct ieee80211_rc_info *); static void rssadapt_sysctlattach(struct ieee80211vap *, struct sysctl_ctx_list *, struct sysctl_oid *); @@ -311,10 +310,11 @@ static void rssadapt_tx_complete(const struct ieee80211vap *vap, - const struct ieee80211_node *ni, int success, void *arg1, void *arg2) + const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { struct ieee80211_rssadapt_node *ra = ni->ni_rctls; - int pktlen = *(int *)arg1, rssi = *(int *)arg2; + /*int pktlen = *(int *)arg1, rssi = *(int *)arg2;*/ + int pktlen = 0, rssi = 0, success = 0; /* just make it compiled. qcc */ if (success) { ra->ra_nok++; Modified: soc2013/ccqin/head/sys/sys/mbuf.h ============================================================================== --- soc2013/ccqin/head/sys/sys/mbuf.h Thu Sep 5 01:13:26 2013 (r256928) +++ soc2013/ccqin/head/sys/sys/mbuf.h Thu Sep 5 02:56:58 2013 (r256929) @@ -95,7 +95,6 @@ caddr_t mh_data; /* location of data */ int mh_len; /* amount of data in this mbuf */ int mh_flags; /* flags; see below */ - uint8_t mh_ccb[48]; /* common control block */ short mh_type; /* type of data in this mbuf */ uint8_t pad[M_HDR_PAD];/* word align */ }; @@ -174,7 +173,6 @@ #define m_type m_hdr.mh_type #define m_flags m_hdr.mh_flags #define m_nextpkt m_hdr.mh_nextpkt -#define m_ccb m_hdr.mh_ccb #define m_act m_nextpkt #define m_pkthdr M_dat.MH.MH_pkthdr #define m_ext M_dat.MH.MH_dat.MH_ext From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 08:29: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 EA9AF7A6 for ; Thu, 5 Sep 2013 08:29:48 +0000 (UTC) (envelope-from ccqin@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 CAF202AC2 for ; Thu, 5 Sep 2013 08:29: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 r858TmpS072750 for ; Thu, 5 Sep 2013 08:29:48 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r858TmB2072745 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 08:29:48 GMT (envelope-from ccqin@FreeBSD.org) Date: Thu, 5 Sep 2013 08:29:48 GMT Message-Id: <201309050829.r858TmB2072745@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256936 - in soc2013/ccqin/head/sys: dev/ath net80211 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, 05 Sep 2013 08:29:49 -0000 Author: ccqin Date: Thu Sep 5 08:29:48 2013 New Revision: 256936 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256936 Log: add net80211 ratectl state as a mbuf tag. * add NET80211_TAG_RATECTL * modify ath to use the mbuf tag to do rate control. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Thu Sep 5 07:13:08 2013 (r256935) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Thu Sep 5 08:29:48 2013 (r256936) @@ -4054,6 +4054,8 @@ { struct ieee80211_node *ni = bf->bf_node; struct ath_node *an = NULL; + struct ieee80211_rc_info *rc_info = NULL; + struct m_tag *mtag; ATH_TX_UNLOCK_ASSERT(sc); ATH_TXQ_UNLOCK_ASSERT(txq); @@ -4080,17 +4082,23 @@ * XXX assume this isn't an aggregate * frame. */ +#if 0 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0 ? 0 : 1)); - - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - ieee80211_ratectl_rc_info_set(rc_info, - 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, - ts->ts_shortretry, ts->ts_longretry, - ts->ts_finaltsi, ts->ts_rate); - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); +#endif + mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + if (NULL != mtag) { + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts->ts_status == 0 ? 0 : 1), + bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } } ath_tx_default_comp(sc, bf, 0); } else Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Thu Sep 5 07:13:08 2013 (r256935) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Thu Sep 5 08:29:48 2013 (r256936) @@ -1389,6 +1389,10 @@ static void ath_tx_do_ratelookup(struct ath_softc *sc, struct ath_buf *bf) { + struct ieee80211_node *ni = bf->bf_node; + struct ieee80211_rc_info *rc_info = NULL; + struct ieee80211_rc_series *rc = NULL; + struct m_tag *mtag; uint8_t rate, rix; int try0; @@ -1412,16 +1416,29 @@ bf->bf_state.bfs_rc); ATH_NODE_UNLOCK(ATH_NODE(bf->bf_node)); #endif + /* net80211 ratectl */ - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - struct ieee80211_rc_series *rc = rc_info->iri_rc; - struct ieee80211_node *ni = bf->bf_node; + mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + if (NULL == mtag) { + mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_RATECTL, + sizeof(struct ieee80211_rc_info), M_NOWAIT); + if (NULL == mtag) + return; + /* XXX need some msg out here.*/ + } + + rc_info = (struct ieee80211_rc_series*)(mtag + 1); + rc = rc_info->iri_rc; + bzero(rc_info, sizeof(rc_info)); if (bf->bf_state.bfs_shpream) rc_info->iri_flags |= IEEE80211_RATECTL_INFO_SP; ieee80211_ratectl_rates(ni, rc_info); + m_tag_prepend(bf->bf_m, mtag); + rix = rc[0].rix; try0 = rc[0].tries; rate = ni->ni_txrate; @@ -4074,6 +4091,8 @@ int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; + struct ieee80211_rc_info *rc_info = NULL; + struct m_tag *mtag; /* The TID state is protected behind the TXQ lock */ ATH_TX_LOCK(sc); @@ -4125,16 +4144,22 @@ */ if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) { +#if 0 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0) ? 0 : 1); - - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - ieee80211_ratectl_rc_info_set(rc_info, - 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, - ts->ts_shortretry, ts->ts_longretry, - ts->ts_finaltsi, ts->ts_rate); - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); +#endif + mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + if (NULL != mtag) { + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts->ts_status == 0 ? 0 : 1), + bf->bf_state.bfs_pktlen, + ts->ts_shortretry, ts->ts_longretry, + ts->ts_finaltsi, ts->ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } } ath_tx_default_comp(sc, bf, fail); @@ -4500,6 +4525,9 @@ int drops = 0; struct ieee80211_tx_ampdu *tap; ath_bufhead bf_cq; + struct ath_tx_status ts = bf_first->bf_status.ds_txstat; + struct ieee80211_rc_info *rc_info = NULL; + struct m_tag *mtag; TAILQ_INIT(&bf_q); TAILQ_INIT(&bf_cq); @@ -4510,19 +4538,27 @@ * XXX use the length in the first frame in the series; * XXX just so things are consistent for now. */ +#if 0 ath_tx_update_ratectrl(sc, ni, bf_first->bf_state.bfs_rc, &bf_first->bf_status.ds_txstat, bf_first->bf_state.bfs_pktlen, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes); +#endif - struct ath_tx_status ts = bf_first->bf_status.ds_txstat; - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf_first->bf_m); - ieee80211_ratectl_rc_info_set(rc_info, - bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes, - bf_first->bf_state.bfs_pktlen, - ts.ts_shortretry, ts.ts_longretry, - ts.ts_finaltsi, ts.ts_rate); - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + mtag = m_tag_locate(bf_first->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + + if (NULL != mtag) { + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + ieee80211_ratectl_rc_info_set(rc_info, + bf_first->bf_state.bfs_nframes, + bf_first->bf_state.bfs_nframes, + bf_first->bf_state.bfs_pktlen, + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } + ATH_TX_LOCK(sc); tap = ath_tx_get_tx_tid(an, tid->tid); sc->sc_stats.ast_tx_aggr_failall++; @@ -4659,8 +4695,12 @@ int nframes = 0, nbad = 0, nf; int pktlen; /* XXX there's too much on the stack? */ +#if 0 struct ath_rc_series rc[ATH_RC_NUM]; +#endif int txseq; + struct ieee80211_rc_info *rc_info = NULL; + struct m_tag *mtag; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", __func__, atid->hwq_depth); @@ -4781,7 +4821,7 @@ isaggr = bf_first->bf_state.bfs_aggr; ba[0] = ts.ts_ba_low; ba[1] = ts.ts_ba_high; - +#if 0 /* * Copy the TX completion status and the rate control * series from the first descriptor, as it may be freed @@ -4789,7 +4829,14 @@ * into things. */ memcpy(rc, bf_first->bf_state.bfs_rc, sizeof(rc)); - +#endif + /* + * Get the net80211 ratectl mtag here, as bf_first will + * be set to NULL later. + */ + mtag = m_tag_locate(bf_first->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: txa_start=%d, tx_ok=%d, status=%.8x, flags=%.8x, " "isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", @@ -4906,16 +4953,19 @@ * control code. */ if (fail == 0) - { + { +#if 0 ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes, nbad); - - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - ieee80211_ratectl_rc_info_set(rc_info, - nframes, nbad, pktlen, - ts.ts_shortretry, ts.ts_longretry, - ts.ts_finaltsi, ts.ts_rate); - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); +#endif + if (NULL != mtag) { + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + ieee80211_ratectl_rc_info_set(rc_info, + nframes, nbad, pktlen, + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } } /* @@ -4990,6 +5040,8 @@ struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status ts; int drops = 0; + struct ieee80211_rc_info *rc_info = NULL; + struct m_tag *mtag; /* * Take a copy of this; filtering/cloning the frame may free the @@ -5004,18 +5056,25 @@ * Do it outside of the TXQ lock. */ if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) - { + { +#if 0 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, &bf->bf_status.ds_txstat, bf->bf_state.bfs_pktlen, 1, (ts.ts_status == 0) ? 0 : 1); - - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - ieee80211_ratectl_rc_info_set(rc_info, - 1, (ts.ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, - ts.ts_shortretry, ts.ts_longretry, - ts.ts_finaltsi, ts.ts_rate); - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); +#endif + mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + + if (NULL != mtag) { + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + ieee80211_ratectl_rc_info_set(rc_info, + 1, (ts.ts_status == 0 ? 0 : 1), + bf->bf_state.bfs_pktlen, + ts.ts_shortretry, ts.ts_longretry, + ts.ts_finaltsi, ts.ts_rate); + ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); + } } /* * This is called early so atid->hwq_depth can be tracked. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Thu Sep 5 07:13:08 2013 (r256935) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c Thu Sep 5 08:29:48 2013 (r256936) @@ -227,11 +227,20 @@ // struct ieee80211com *ic = ni->ni_ic; const HAL_RATE_TABLE *rt = sc->sc_currates; struct ath_rc_series *ath_rc = bf->bf_state.bfs_rc; - struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m); - struct ieee80211_rc_series *rc = rc_info->iri_rc; + struct ieee80211_rc_info *rc_info = NULL; + struct ieee80211_rc_series *rc = NULL; + struct m_tag *mtag; uint8_t rate; int i; + mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + if (NULL == mtag) + return; + + rc_info = (struct ieee80211_rc_info*)(mtag + 1); + rc = rc_info->iri_rc; + for (i = 0; i < IEEE80211_RATECTL_NUM; i++) { if (rc[i].tries == 0) continue; @@ -248,6 +257,10 @@ ath_rc[i].ratecode = rc[i].ratecode; ath_rc[i].tx_power_cap = rc[i].tx_power_cap; ath_rc[i].max4msframelen = rc[i].max4msframelen; + + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: i=%d, rate=0x%x, flags=0x%x, max4ms=%d\n", + __func__, i, rate, rc[i].flags, rc[i].max4msframelen); } #if 0 Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Thu Sep 5 07:13:08 2013 (r256935) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Thu Sep 5 08:29:48 2013 (r256936) @@ -95,7 +95,7 @@ /* ieee80211_rc_info flags */ #define IEEE80211_RATECTL_INFO_SP 0x01 /* short preamble */ -#define IEEE80211_RATECTL_INFO(_m) ((struct ieee80211_rc_info *)(_m)->m_ccb) +#define NET80211_TAG_RATECTL 1 /* net80211 ratectl state */ /* * net80211 ratectl statistics. From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 11:15:58 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 642551C2 for ; Thu, 5 Sep 2013 11:15:58 +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 429EC250E for ; Thu, 5 Sep 2013 11:15:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r85BFwXn013334 for ; Thu, 5 Sep 2013 11:15:58 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85BFwRw013331 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 11:15:58 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 5 Sep 2013 11:15:58 GMT Message-Id: <201309051115.r85BFwRw013331@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: r256942 - 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, 05 Sep 2013 11:15:58 -0000 Author: dpl Date: Thu Sep 5 11:15:58 2013 New Revision: 256942 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256942 Log: Made capsicum files fully compilable. Also, all the interface with sys/queue.h has been cleared up. 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 Sep 5 10:24:09 2013 (r256941) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Thu Sep 5 11:15:58 2013 (r256942) @@ -15,11 +15,15 @@ #include #include +/* + * The only function allocating space + * for struct sandbox is startChild(). + */ struct sandbox; struct slisthead sandboxes; struct sandbox * startSandbox(void *data); -int stopSandbox(struct sandbox *sandbox); +void stopSandbox(struct sandbox *sandbox); void startNullSandbox(void); struct sandbox * findSandbox(void *ptr); struct sandbox *startChild(void *data); @@ -45,7 +49,7 @@ /* Create and add the real sandbox */ newsandbox = startChild(data); - SLIST_INSERT_HEAD(&sandboxes, newsandbox, entries); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, next); return (newsandbox); } @@ -55,34 +59,33 @@ * struct sandbox. Should be called by: gzclose, * deflateEnd, inflateEnd (inflateBackEnd). */ -int -stopSandbox(struct sandbox *sandbox) +void +stopSandbox(struct sandbox *sandboxToStop) { int pid; - if (pdgetpid(sandbox->pd, &pid) < 0) + if (pdgetpid(sandboxToStop->pd, &pid) < 0) err(1, "Couldn't get child PID"); if (kill(SIGKILL, pid) < 0) err(1, "Couldn't kill child"); - SLIST_REMOVE(&sandboxes, sandbox, entry, entries); - free(sandbox); + SLIST_REMOVE(&sandboxes, sandboxToStop, sandbox, next); + free(sandboxToStop); } /* Starts the default sandbox. */ void startNullSandbox(void) { - struct sandbox newsandbox; + struct sandbox *newsandbox; if (!slist_initiated) { - sandboxes = SLIST_HEAD_INITIALIZER(head); SLIST_INIT(&sandboxes); /* Here we add a sandbox used for non-structure related stuff */ /* This will be the first sandbox always */ if (SLIST_EMPTY(&sandboxes)) { newsandbox = startChild(NULL); - SLIST_INSERT_HEAD(sandboxes, newsandbox, entries); + SLIST_INSERT_HEAD(&sandboxes, newsandbox, next); } } slist_initiated = 1; @@ -101,7 +104,7 @@ if (ptr == NULL) return (SLIST_FIRST(&sandboxes)); - SLIST_FOREACH(sandbox, &sandboxes, entries) + SLIST_FOREACH(sandbox, &sandboxes, next) if (sandbox->dataptr == ptr) return (sandbox); @@ -116,13 +119,13 @@ struct sandbox *newsandbox; if ((newsandbox = malloc(sizeof (struct sandbox))) == NULL) - err(1, "Couldn't allocate memory for sandboxes"); + err(1, "Couldn't allocate memory for sandbox"); sv[0] = sv[1] = 0; if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) perror("zcaplib: socketpair()"); - procd = pdfork(); + procd = pdfork(&procd, 0); if (procd == 0 ){ if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0) err(1, "Couldn't limit rights"); @@ -150,13 +153,15 @@ newsandbox->pd = procd; newsandbox->socket = sv[0]; } + return (newsandbox); } void killChild(void) { int pid; - SLIST_FOREACH(sandbox, &sandboxes, entries) - if (pdgetpid(sandbox->pd, &pid) > 0) - kill(SIGKILL, pid) + struct sandbox *box; + SLIST_FOREACH(box, &sandboxes, next) + if (pdgetpid(box->pd, &pid) > 0) + kill(SIGKILL, pid); } void suicide(int signal) { kill(getpid(), SIGKILL); Modified: soc2013/dpl/head/lib/libzcap/capsicum.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.h Thu Sep 5 10:24:09 2013 (r256941) +++ soc2013/dpl/head/lib/libzcap/capsicum.h Thu Sep 5 11:15:58 2013 (r256942) @@ -11,7 +11,7 @@ #define MAXLEN (5*1024) struct sandbox * startSandbox(void *data); -int stopSandbox(struct sandbox *sandbox); +void stopSandbox(struct sandbox *sandbox); void startNullSandbox(void); struct sandbox * findSandbox(void *ptr); struct sandbox *startChild(void *data); @@ -20,8 +20,7 @@ nvlist_t * sendCommand(nvlist_t *nvl, int socket); /* head of singly-linked list. */ -struct slisthead sandboxes; -SLIST_HEAD(slisthead, sandbox) sandboxes; +SLIST_HEAD(slisthead, sandbox) sandboxes = SLIST_HEAD_INITIALIZER(sandboxes); /* * This structure holds a relation of structs of data structs, @@ -31,7 +30,7 @@ void * dataptr; /* Pointer to the data structure of the lib */ int pd; /* Process descriptor */ int socket; /* Socket we have to pass the data through */ - SLIST_ENTRY(entry) entries; /* Singly-linked list. */ + SLIST_ENTRY(sandbox) next; /* Singly-linked list. */ }; #endif /* CAPSICUM_H */ \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 19:51:00 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 9474182E for ; Thu, 5 Sep 2013 19:51:00 +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 670D72C6D for ; Thu, 5 Sep 2013 19:51:00 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r85Jp0sx026991 for ; Thu, 5 Sep 2013 19:51:00 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85Jp03C026985 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 19:51:00 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 5 Sep 2013 19:51:00 GMT Message-Id: <201309051951.r85Jp03C026985@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: r256964 - soc2013/mattbw/tests 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, 05 Sep 2013 19:51:00 -0000 Author: mattbw Date: Thu Sep 5 19:50:59 2013 New Revision: 256964 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256964 Log: Add basic functional test script for installing and uninstalling a test package. Added: soc2013/mattbw/tests/ftest-install-remove-single.sh (contents, props changed) Added: soc2013/mattbw/tests/ftest-install-remove-single.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/ftest-install-remove-single.sh Thu Sep 5 19:50:59 2013 (r256964) @@ -0,0 +1,79 @@ +#!/bin/sh +# Functional test for installing/removing based on test repositories. + +# Expect testpkg not to be installed initially +if [ -f /usr/local/testpkgs/testfile ] +then + echo "Please remove testpkg and try again." + exit +fi + +# It should come up as available... +RESOLVE=`pkcon resolve --filter "~installed" testpkg | grep "Available.*"` +if [ -z "${RESOLVE}" ] +then + echo "Test failed: testpkg is not showing as available." + exit +fi + +# ...but not installed. +RESOLVE=`pkcon resolve --filter "installed" testpkg | grep "Installed.*"` +if [ -n "${RESOLVE}" ] +then + echo "Test failed: testpkg is showing as installed." + exit +fi + +# ToDo: put more tests here? + +pkcon install testpkg + +# Expect testpkg to now be installed +if [ ! -f /usr/local/testpkgs/testfile ] +then + echo "Test failed: testpkg was not installed." + exit +fi + +# It should come up as available... +RESOLVE=`pkcon resolve --filter "~installed" testpkg | grep "Available.*"` +if [ -n "${RESOLVE}" ] +then + echo "Test failed: testpkg is showing as available post-install." + exit +fi + +# ...but not installed. +RESOLVE=`pkcon resolve --filter "installed" testpkg | grep "Installed.*"` +if [ -z "${RESOLVE}" ] +then + echo "Test failed: testpkg is not showing as installed post-install." + exit +fi + +pkcon remove testpkg + +# Expect testpkg to now be uninstalled again +if [ -f /usr/local/testpkgs/testfile ] +then + echo "Test failed: testpkg was not uninstalled." + exit +fi + +# It should once more come up as available... +RESOLVE=`pkcon resolve --filter "~installed" testpkg | grep "Available.*"` +if [ -z "${RESOLVE}" ] +then + echo "Test failed: testpkg is not showing as available post-remove." + exit +fi + +# ...but not installed. +RESOLVE=`pkcon resolve --filter "installed" testpkg | grep "Installed.*"` +if [ -n "${RESOLVE}" ] +then + echo "Test failed: testpkg is showing as installed post-remove." + exit +fi + +echo "Test succeeded." From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 20:48: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 9E28FBEC for ; Thu, 5 Sep 2013 20:48: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 88D3D2F6C for ; Thu, 5 Sep 2013 20:48: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 r85KmN8L063158 for ; Thu, 5 Sep 2013 20:48:23 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85KmNRJ063153 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 20:48:23 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 5 Sep 2013 20:48:23 GMT Message-Id: <201309052048.r85KmNRJ063153@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: r256967 - soc2013/mattbw/backend/jobs 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, 05 Sep 2013 20:48:23 -0000 Author: mattbw Date: Thu Sep 5 20:48:23 2013 New Revision: 256967 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256967 Log: Split out the jobs checking function a little. Modified: soc2013/mattbw/backend/jobs/check.c Modified: soc2013/mattbw/backend/jobs/check.c ============================================================================== --- soc2013/mattbw/backend/jobs/check.c Thu Sep 5 19:25:36 2013 (r256966) +++ soc2013/mattbw/backend/jobs/check.c Thu Sep 5 20:48:23 2013 (r256967) @@ -33,7 +33,8 @@ #include "../query.h" /* query_... */ #include "check.h" /* jobs_check_... */ -static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); +static bool check_package(struct pkg *pkg, struct query_id *query_ids, guint count, bool reject_non_updates); +static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); static struct pkg *jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); /* Checks a solved job against a string vector of PackageIDs to ensure any @@ -94,55 +95,77 @@ guint count, bool reject_non_updates) { bool success; - guint i; int err; - char *namever; struct pkg *package; assert(jobs != NULL); assert(query_ids != NULL); assert(0 < count); - package = NULL; success = true; while (success) { err = pkg_jobs(jobs, &package); - if (err != EPKG_OK) { - /* Did we reach the end of the job iterator? */ - if (err != EPKG_END) { - success = false; - } + if (err == EPKG_OK) { + success = check_package(package, query_ids, + count, reject_non_updates); + } else if (err == EPKG_END) { + /* + * Only return a package if it failed to match. + * If we've reached this far all of them have + * matched, so don't return one! + */ + package = NULL; break; + } else { + /* Abnormal termination */ + success = false; } + } - assert(package != NULL); + return package; +} - namever = namever_from_package(package); - if (namever == NULL) { - success = false; - } +/* + * Checks a single job target package against a set of candidate + * query IDs to make sure that the originally requested packages in + * the job have been resolved properly. + */ +static bool +check_package(struct pkg *package, struct query_id *query_ids, + guint count, bool reject_non_updates) +{ + bool success; + guint i; + char *namever; + + assert(package != NULL); + + success = true; + + namever = namever_from_package(package); + if (namever == NULL) { + success = false; + } - for (i = 0; i < count; i++) { - if (!success) { - /* Leave the for loop, not the while loop. */ - break; - } - - assert(success); - success = jobs_check_id_on_package(package, - query_ids + i, - namever); - - if (success && reject_non_updates && - pkgutils_pkg_install_state(package) != - PK_INFO_ENUM_UPDATING) { - success = false; - } + for (i = 0; i < count; i++) { + if (!success) { + break; } - /* Do not free the struct pkg, we actually don't own it. */ + assert(success); + success = jobs_check_id_on_package(package, + query_ids + i, + namever); + + if (success && reject_non_updates && + pkgutils_pkg_install_state(package) != + PK_INFO_ENUM_UPDATING) { + success = false; + } } - return success ? NULL : package; + /* Do not free the struct pkg, we actually don't own it. */ + + return success; } From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 20:53:15 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 91BFEEA9 for ; Thu, 5 Sep 2013 20:53:15 +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 7E0CB2FC9 for ; Thu, 5 Sep 2013 20:53:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r85KrF0I057459 for ; Thu, 5 Sep 2013 20:53:15 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85KrFR4057454 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 20:53:15 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 5 Sep 2013 20:53:15 GMT Message-Id: <201309052053.r85KrFR4057454@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: r256968 - 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: Thu, 05 Sep 2013 20:53:15 -0000 Author: mattbw Date: Thu Sep 5 20:53:15 2013 New Revision: 256968 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256968 Log: Don't bother adding redundant licence joiner under clang. Without this conditional there's a catch-22 situation where GCC complains without the join string and clang complains with it. Modified: soc2013/mattbw/backend/licenses.c Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Thu Sep 5 20:48:23 2013 (r256967) +++ soc2013/mattbw/backend/licenses.c Thu Sep 5 20:53:15 2013 (r256968) @@ -42,6 +42,15 @@ struct pkg_license *lic; struct sbuf *sb; + /* + * GCC worries about this being NULL, so initialise it here. + * Clang worries about the lack of enum saturation, so it doesn't + * ever get used as a default though. + */ +#ifndef __clang__ + logic_str = " "; +#endif /* !__clang__ */ + pkg_get(pkg, PKG_LICENSE_LOGIC, &logic); switch (logic) { case LICENSE_OR: From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 21:10: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 151DD9AE for ; Thu, 5 Sep 2013 21:10:18 +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 DD5A920D7 for ; Thu, 5 Sep 2013 21:10: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 r85LAHiP066874 for ; Thu, 5 Sep 2013 21:10:17 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85LAHOw066788 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 21:10:17 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 5 Sep 2013 21:10:17 GMT Message-Id: <201309052110.r85LAHOw066788@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: r256972 - 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: Thu, 05 Sep 2013 21:10:18 -0000 Author: mattbw Date: Thu Sep 5 21:10:17 2013 New Revision: 256972 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256972 Log: Split search body into two functions. Modified: soc2013/mattbw/backend/search.c Modified: soc2013/mattbw/backend/search.c ============================================================================== --- soc2013/mattbw/backend/search.c Thu Sep 5 20:50:52 2013 (r256971) +++ soc2013/mattbw/backend/search.c Thu Sep 5 21:10:17 2013 (r256972) @@ -26,6 +26,8 @@ #include "pkgutils.h" /* pkgutils_... */ #include "search.h" /* search_... */ +static void search_do_with_it(struct search *search, struct pkgdb_it *it); + /* * Performs the search specified by the given "struct search" and emits each * result according to the likewise-specified filter set. @@ -33,12 +35,10 @@ bool search_do(struct search *search) { - bool success; struct pkgdb_it *it; assert(search != NULL); - success = false; it = pkgdb_search(search->db, search->term, search->type, @@ -47,23 +47,31 @@ NULL); if (it != NULL) { - struct pkg *pkg; + search_do_with_it(search, it); + pkgdb_it_free(it); + } + + return (it != NULL); +} - pkg = NULL; - while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { - assert(pkg != NULL); - - pkgutils_add_old_version(search->db, pkg, NULL); - emit_filtered_package(pkg, - search->backend, - search->filters, - pkgutils_pkg_current_state(pkg)); - } +static void +search_do_with_it(struct search *search, struct pkgdb_it *it) +{ + struct pkg *pkg; + + assert(search != NULL); + assert(it != NULL); - success = true; - pkg_free(pkg); + pkg = NULL; + while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { + assert(pkg != NULL); + + pkgutils_add_old_version(search->db, pkg, NULL); + emit_filtered_package(pkg, + search->backend, + search->filters, + pkgutils_pkg_current_state(pkg)); } - pkgdb_it_free(it); - return success; + pkg_free(pkg); } From owner-svn-soc-all@FreeBSD.ORG Thu Sep 5 21:13: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 B47009E5 for ; Thu, 5 Sep 2013 21:13:21 +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 A097D210E for ; Thu, 5 Sep 2013 21:13: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 r85LDLhW065852 for ; Thu, 5 Sep 2013 21:13:21 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r85LDLjR065844 for svn-soc-all@FreeBSD.org; Thu, 5 Sep 2013 21:13:21 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 5 Sep 2013 21:13:21 GMT Message-Id: <201309052113.r85LDLjR065844@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: r256973 - 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: Thu, 05 Sep 2013 21:13:21 -0000 Author: mattbw Date: Thu Sep 5 21:13:21 2013 New Revision: 256973 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256973 Log: Yet another gcc/clang catch-22. Yay. Modified: soc2013/mattbw/backend/pkgutils.c Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Thu Sep 5 21:10:17 2013 (r256972) +++ soc2013/mattbw/backend/pkgutils.c Thu Sep 5 21:13:21 2013 (r256973) @@ -205,6 +205,14 @@ assert(pkg != NULL); + /* + * clang complains about this redundant assignment, but + * gcc complains if it doesn't exist. + */ +#ifndef __clang__ + repo = ""; +#endif /* __clang */ + switch (pkg_type(pkg)) { case PKG_OLD_FILE: case PKG_FILE: From owner-svn-soc-all@FreeBSD.ORG Fri Sep 6 12: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 8D17A368 for ; Fri, 6 Sep 2013 12:08:31 +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 6AD9F25BD for ; Fri, 6 Sep 2013 12: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 r86C8Vaf048077 for ; Fri, 6 Sep 2013 12:08:31 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r86C8Vem048039 for svn-soc-all@FreeBSD.org; Fri, 6 Sep 2013 12:08:31 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 6 Sep 2013 12:08:31 GMT Message-Id: <201309061208.r86C8Vem048039@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: r257007 - 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: Fri, 06 Sep 2013 12:08:31 -0000 Author: mattbw Date: Fri Sep 6 12:08:31 2013 New Revision: 257007 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257007 Log: Split repository functions into another file. This is for consistency and also so the ones that were originally in utils can be unit tested. Added: soc2013/mattbw/backend/repo.c soc2013/mattbw/backend/repo.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query/match.c soc2013/mattbw/backend/utils.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/Makefile Fri Sep 6 12:08:31 2013 (r257007) @@ -32,6 +32,7 @@ licenses.c \ namever.c \ pkgutils.c \ + repo.c \ search.c \ utils.c SRCS+= \ Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/jobs.c Fri Sep 6 12:08:31 2013 (r257007) @@ -34,7 +34,8 @@ #include "jobs/check.h" /* jobs_check_... */ #include "namever.h" /* namever_* */ #include "pkgutils.h" /* pkgutils_... */ -#include "utils.h" /* ERR, type_of_repo_name */ +#include "repo.h" /* repo_... */ +#include "utils.h" /* ERR */ static const char *APPLY_ERRORS[] = { "This shouldn't occur and is a bug.", /* EPKG_OK */ @@ -95,7 +96,7 @@ success = true; - type = type_of_repo_name(reponame); + type = repo_type(reponame); if (type == REPO_INVALID) { success = false; } else if (type == REPO_REMOTE) { Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/pkgutils.c Fri Sep 6 12:08:31 2013 (r257007) @@ -28,9 +28,6 @@ #include "pkgutils.h" /* Prototypes */ #include "utils.h" /* INTENTIONALLY_IGNORE */ - -static const char *repo_of_remote_package(struct pkg *pkg); - /* * Package utility functions. * @@ -195,61 +192,3 @@ return matches_filters; } -/* - * Gets the PackageKit repository name for the package. - */ -const char * -pkgutils_pkg_to_pk_repo(struct pkg *pkg) -{ - const char *repo; - - assert(pkg != NULL); - - /* - * clang complains about this redundant assignment, but - * gcc complains if it doesn't exist. - */ -#ifndef __clang__ - repo = ""; -#endif /* __clang */ - - switch (pkg_type(pkg)) { - case PKG_OLD_FILE: - case PKG_FILE: - repo = "local"; - break; - case PKG_INSTALLED: - repo = "installed"; - break; - case PKG_REMOTE: - repo = repo_of_remote_package(pkg); - break; - case PKG_NONE: - repo = "unknown"; - break; - } - - assert(repo != NULL); - return repo; -} - -/* - * Gets the PackageKit repository name for the (remote) package. - * - * Currently this is the pkgng repository name (not the ident as was previously - * the case). - * - * This does not need to be freed (possibly, TODO: check). - */ -static const char * -repo_of_remote_package(struct pkg *pkg) -{ - const char *repo_name; - - assert(pkg != NULL); - assert(pkg_type(pkg) == PKG_REMOTE); - - repo_name = NULL; - pkg_get(pkg, PKG_REPONAME, &repo_name); - return repo_name; -} Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/query/match.c Fri Sep 6 12:08:31 2013 (r257007) @@ -24,6 +24,7 @@ #include "pkg.h" /* struct pkg... */ #include "../namever.h" /* namever_... */ +#include "../repo.h" /* repo_... */ #include "../utils.h" /* type_of_repo_name, enum repo_type */ #include "check.h" /* query_check... */ #include "find.h" /* query_find_... */ @@ -79,7 +80,7 @@ { bool try_local; bool try_remote; - enum repo_type repo_type; + enum repo_type type; struct pkg *package; assert(query_id != NULL); @@ -90,9 +91,9 @@ * to try searching locally first and then remotely; otherwise which * database we query depends on the repository we have been given. */ - repo_type = type_of_repo_name(query_id->repo); - try_local = (repo_type != REPO_REMOTE); - try_remote = (repo_type != REPO_LOCAL); + type = repo_type(query_id->repo); + try_local = (type != REPO_REMOTE); + try_remote = (type != REPO_LOCAL); package = NULL; if (try_local) { Added: soc2013/mattbw/backend/repo.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/repo.c Fri Sep 6 12:08:31 2013 (r257007) @@ -0,0 +1,111 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Functions for dealing with PackageKit repositories. */ + +#include +#include + +#include "pkg.h" /* pkg_..., struct pkg */ +#include "repo.h" /* repo_... */ + +static const char *repo_of_remote_package(struct pkg *pkg); + +/* + * Finds the type of the given PackageKit repository name. + */ +enum repo_type +repo_type(const char *name) +{ + enum repo_type rtype; + + /* Null or empty implies no specific repository */ + if (name == NULL || name[0] == '\0') { + rtype = REPO_ANY; + } else if (strcmp(name, "installed") == 0) { + rtype = REPO_LOCAL; + } else if (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) + != NULL) { + rtype = REPO_REMOTE; + } else { + rtype = REPO_INVALID; + } + + return rtype; +} + +/* + * Gets the PackageKit repository name for the package. + */ +const char * +repo_of_package(struct pkg *package) +{ + const char *repo; + + assert(package != NULL); + + /* + * clang complains about this redundant assignment, but + * gcc complains if it doesn't exist. + */ +#ifndef __clang__ + repo = ""; +#endif /* __clang */ + + switch (pkg_type(package)) { + case PKG_OLD_FILE: + case PKG_FILE: + repo = "local"; + break; + case PKG_INSTALLED: + repo = "installed"; + break; + case PKG_REMOTE: + repo = repo_of_remote_package(package); + break; + case PKG_NONE: + repo = "unknown"; + break; + } + + assert(repo != NULL); + return repo; +} + +/* + * Gets the PackageKit repository name for the (remote) package. + * + * Currently this is the pkgng repository name (not the ident as was previously + * the case). + * + * This does not need to be freed (possibly, TODO: check). + */ +static const char * +repo_of_remote_package(struct pkg *pkg) +{ + const char *repo_name; + + assert(pkg != NULL); + assert(pkg_type(pkg) == PKG_REMOTE); + + repo_name = NULL; + pkg_get(pkg, PKG_REPONAME, &repo_name); + return repo_name; +} Added: soc2013/mattbw/backend/repo.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/repo.h Fri Sep 6 12:08:31 2013 (r257007) @@ -0,0 +1,36 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_REPO_H_ +#define _PKGNG_BACKEND_REPO_H_ + +#include "pkg.h" + +enum repo_type { + REPO_INVALID, + REPO_ANY, + REPO_LOCAL, + REPO_REMOTE +}; + +enum repo_type repo_type(const char *name); +const char *repo_of_package(struct pkg *package); + +#endif /* !_PKGNG_BACKEND_REPO_H_ */ Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/utils.c Fri Sep 6 12:08:31 2013 (r257007) @@ -30,29 +30,6 @@ #include "utils.h" /* prototypes */ /* - * Finds the type of the given PackageKit repository name. - */ -enum repo_type -type_of_repo_name(const char *name) -{ - enum repo_type rtype; - - /* Null or empty implies no specific repository */ - if (name == NULL || name[0] == '\0') { - rtype = REPO_ANY; - } else if (strcmp(name, "installed") == 0) { - rtype = REPO_LOCAL; - } else if (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) - != NULL) { - rtype = REPO_REMOTE; - } else { - rtype = REPO_INVALID; - } - - return rtype; -} - -/* * Retrieves PackageIDs from the backend, as well as the total number of them. */ gchar ** Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Fri Sep 6 10:40:38 2013 (r257006) +++ soc2013/mattbw/backend/utils.h Fri Sep 6 12:08:31 2013 (r257007) @@ -25,20 +25,12 @@ #include /* gchar, guint */ #include "pk-backend.h" /* PkBackend */ -enum repo_type { - REPO_INVALID, - REPO_ANY, - REPO_LOCAL, - REPO_REMOTE -}; - #define INTENTIONALLY_IGNORE(x) (void)(x) #define STATUS(backend, status) \ (void)pk_backend_set_status((backend), (status)) #define ERR(backend, type, msg) \ (void)pk_backend_error_code((backend), (type), (msg)) -enum repo_type type_of_repo_name(const char *name); gchar **get_package_ids(PkBackend *backend, guint *count_p); gchar **get_strv_and_length(PkBackend *backend, const char *name, guint *count_p); From owner-svn-soc-all@FreeBSD.ORG Fri Sep 6 12:44:14 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 4D3F6B21 for ; Fri, 6 Sep 2013 12:44:14 +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 386E627B2 for ; Fri, 6 Sep 2013 12:44:14 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r86CiE2C071885 for ; Fri, 6 Sep 2013 12:44:14 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r86CiEUw071874 for svn-soc-all@FreeBSD.org; Fri, 6 Sep 2013 12:44:14 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 6 Sep 2013 12:44:14 GMT Message-Id: <201309061244.r86CiEUw071874@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: r257008 - 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: Fri, 06 Sep 2013 12:44:14 -0000 Author: mattbw Date: Fri Sep 6 12:44:13 2013 New Revision: 257008 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257008 Log: Add tests for repo_of_package. This also fixes some broken references to legacy repo functions. Added: soc2013/mattbw/backend/repo_test.c Modified: soc2013/mattbw/backend/Atffile soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query/check.c Modified: soc2013/mattbw/backend/Atffile ============================================================================== --- soc2013/mattbw/backend/Atffile Fri Sep 6 12:08:31 2013 (r257007) +++ soc2013/mattbw/backend/Atffile Fri Sep 6 12:44:13 2013 (r257008) @@ -4,3 +4,4 @@ tp: namever_test tp: pkgutils_test +tp: repo_test Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Sep 6 12:08:31 2013 (r257007) +++ soc2013/mattbw/backend/Makefile Fri Sep 6 12:44:13 2013 (r257008) @@ -74,6 +74,7 @@ TESTPROGS= \ namever_test \ pkgutils_test \ + repo_test \ query/id_test \ query/check_test \ @@ -108,16 +109,16 @@ query/id_test.o: query/id_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o pkgutils.o +query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o pkgutils.o repo.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} query/check_test.o: query/check_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o +pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o repo.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} -pkgutils_test.o: pkgutils_test.c +pkgutils_test.o: pkgutils_test.c repo.o ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} namever_test: namever_test.o namever.o testutils.o @@ -126,6 +127,12 @@ namever_test.o: namever_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} +repo_test: repo_test.o repo.o testutils.o + ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} + +repo_test.o: repo_test.c + ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} + testutils.o: testutils.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Fri Sep 6 12:08:31 2013 (r257007) +++ soc2013/mattbw/backend/pkgutils.c Fri Sep 6 12:44:13 2013 (r257008) @@ -26,6 +26,7 @@ #include "namever.h" /* namever_... */ #include "pkgutils.h" /* Prototypes */ +#include "repo.h" /* repo_... */ #include "utils.h" /* INTENTIONALLY_IGNORE */ /* @@ -126,7 +127,7 @@ pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version, PKG_ARCH, &arch); - repo = pkgutils_pkg_to_pk_repo(pkg); + repo = repo_of_package(pkg); return pk_package_id_build(name, version, arch, repo); } Modified: soc2013/mattbw/backend/query/check.c ============================================================================== --- soc2013/mattbw/backend/query/check.c Fri Sep 6 12:08:31 2013 (r257007) +++ soc2013/mattbw/backend/query/check.c Fri Sep 6 12:44:13 2013 (r257008) @@ -25,6 +25,7 @@ #include "../namever.h" /* namever_... */ #include "../pkgutils.h" /* pkgutils_... */ +#include "../repo.h" /* repo_... */ #include "../utils.h" /* type_of_repo_name, enum repo_type */ #include "check.h" /* query_check... */ #include "find.h" /* query_find_... */ @@ -50,7 +51,7 @@ assert(query_id->namever != NULL); namever = namever_from_package(package); - repo = pkgutils_pkg_to_pk_repo(package); + repo = repo_of_package(package); (void)pkg_get(package, PKG_ARCH, &arch, PKG_NAME, &name); /* Be cautious and reject matches if the package fields aren't here. */ Added: soc2013/mattbw/backend/repo_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/repo_test.c Fri Sep 6 12:44:13 2013 (r257008) @@ -0,0 +1,98 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include +#include /* ATF_CHECK_STREQ */ +#include /* gchar, g_free */ +#include "pkg.h" /* pkg... */ + +#include "repo.h" /* repo_... */ +#include "testutils.h" /* gen_pkg */ + +/* ATF/kyua tests for 'repo.c'. */ + +ATF_TC(repo_of_package_valid_local); +ATF_TC_HEAD(repo_of_package_valid_local, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'repo_of_package' on a local (file) package."); +} +ATF_TC_BODY(repo_of_package_valid_local, tc) +{ + struct pkg *pkg; + + pkg = gen_pkg(PKG_FILE); + ATF_REQUIRE(pkg != NULL); + + ATF_CHECK_STREQ(repo_of_package(pkg), "local"); + + pkg_free(pkg); +} + +ATF_TC(repo_of_package_valid_installed); +ATF_TC_HEAD(repo_of_package_valid_installed, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'repo_of_package' on an installed package."); +} +ATF_TC_BODY(repo_of_package_valid_installed, tc) +{ + struct pkg *pkg; + + pkg = gen_pkg(PKG_INSTALLED); + ATF_REQUIRE(pkg != NULL); + + ATF_CHECK_STREQ(repo_of_package(pkg), "installed"); + + pkg_free(pkg); +} + +ATF_TC(repo_of_package_valid_remote); +ATF_TC_HEAD(repo_of_package_valid_remote, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Test 'repo_of_package' on a remote package."); +} +ATF_TC_BODY(repo_of_package_valid_remote, tc) +{ + struct pkg *pkg; + + pkg = gen_pkg(PKG_REMOTE); + ATF_REQUIRE(pkg != NULL); + + ATF_CHECK_STREQ(repo_of_package(pkg), "packagesite"); + + pkg_free(pkg); +} + +/* + * TEST PACK + */ + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, repo_of_package_valid_local); + ATF_TP_ADD_TC(tp, repo_of_package_valid_installed); + ATF_TP_ADD_TC(tp, repo_of_package_valid_remote); + + return atf_no_error(); +} From owner-svn-soc-all@FreeBSD.ORG Fri Sep 6 13:05:14 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 4341855A for ; Fri, 6 Sep 2013 13:05:14 +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 3071828B6 for ; Fri, 6 Sep 2013 13:05:14 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r86D5DDo021662 for ; Fri, 6 Sep 2013 13:05:13 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r86D5D33021652 for svn-soc-all@FreeBSD.org; Fri, 6 Sep 2013 13:05:13 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 6 Sep 2013 13:05:13 GMT Message-Id: <201309061305.r86D5D33021652@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: r257013 - 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: Fri, 06 Sep 2013 13:05:14 -0000 Author: mattbw Date: Fri Sep 6 13:05:13 2013 New Revision: 257013 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257013 Log: Add test case for checking the type-of-repo functionality. This necessitated a separation of the package database-dependent code in repo.c. Modified: soc2013/mattbw/backend/repo.c soc2013/mattbw/backend/repo.h soc2013/mattbw/backend/repo_test.c Modified: soc2013/mattbw/backend/repo.c ============================================================================== --- soc2013/mattbw/backend/repo.c Fri Sep 6 12:59:48 2013 (r257012) +++ soc2013/mattbw/backend/repo.c Fri Sep 6 13:05:13 2013 (r257013) @@ -30,25 +30,45 @@ /* * Finds the type of the given PackageKit repository name. + * + * This function checks remote repositories to ensure they match actually + * configured repositories, and instead returns 'REPO_INVALID' when they don't. + * A separate function 'repo_type_no_remote_check' does not do this and can + * thus be unit tested. */ enum repo_type repo_type(const char *name) { - enum repo_type rtype; + enum repo_type type; + + /* 'name' may be NULL. This implies REPO_ANY. */ + + type = repo_type_no_remote_check(name); + + if (type == REPO_REMOTE && + (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) != NULL)) { + type = REPO_INVALID; + } + + return type; +} + +/* As repo_type, but without the remote repository check. */ +enum repo_type +repo_type_no_remote_check(const char *name) +{ + enum repo_type type; /* Null or empty implies no specific repository */ if (name == NULL || name[0] == '\0') { - rtype = REPO_ANY; + type = REPO_ANY; } else if (strcmp(name, "installed") == 0) { - rtype = REPO_LOCAL; - } else if (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) - != NULL) { - rtype = REPO_REMOTE; + type = REPO_LOCAL; } else { - rtype = REPO_INVALID; + type = REPO_REMOTE; } - return rtype; + return type; } /* Modified: soc2013/mattbw/backend/repo.h ============================================================================== --- soc2013/mattbw/backend/repo.h Fri Sep 6 12:59:48 2013 (r257012) +++ soc2013/mattbw/backend/repo.h Fri Sep 6 13:05:13 2013 (r257013) @@ -31,6 +31,7 @@ }; enum repo_type repo_type(const char *name); +enum repo_type repo_type_no_remote_check(const char *name); const char *repo_of_package(struct pkg *package); #endif /* !_PKGNG_BACKEND_REPO_H_ */ Modified: soc2013/mattbw/backend/repo_test.c ============================================================================== --- soc2013/mattbw/backend/repo_test.c Fri Sep 6 12:59:48 2013 (r257012) +++ soc2013/mattbw/backend/repo_test.c Fri Sep 6 13:05:13 2013 (r257013) @@ -84,12 +84,29 @@ pkg_free(pkg); } +ATF_TC(repo_type_test); +ATF_TC_HEAD(repo_type_test, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Test repo_type_no_remote_check."); +} +ATF_TC_BODY(repo_type_test, tc) +{ + + ATF_CHECK_EQ(repo_type_no_remote_check("installed"), REPO_LOCAL); + ATF_CHECK_EQ(repo_type_no_remote_check("derp"), REPO_REMOTE); + ATF_CHECK_EQ(repo_type_no_remote_check(""), REPO_ANY); + ATF_CHECK_EQ(repo_type_no_remote_check(NULL), REPO_ANY); +} + + /* * TEST PACK */ ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, repo_type_test); ATF_TP_ADD_TC(tp, repo_of_package_valid_local); ATF_TP_ADD_TC(tp, repo_of_package_valid_installed); ATF_TP_ADD_TC(tp, repo_of_package_valid_remote); From owner-svn-soc-all@FreeBSD.ORG Fri Sep 6 20:46:52 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 8125634B for ; Fri, 6 Sep 2013 20:46:52 +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 54F482354 for ; Fri, 6 Sep 2013 20:46:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r86KkqHc018118 for ; Fri, 6 Sep 2013 20:46:52 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r86Kkqgf018114 for svn-soc-all@FreeBSD.org; Fri, 6 Sep 2013 20:46:52 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 6 Sep 2013 20:46:52 GMT Message-Id: <201309062046.r86Kkqgf018114@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: r257032 - in soc2013/mattbw/backend: . jobs 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, 06 Sep 2013 20:46:52 -0000 Author: mattbw Date: Fri Sep 6 20:46:51 2013 New Revision: 257032 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257032 Log: Move jobs.c to jobs/core.c. This brings it in line with query. Added: soc2013/mattbw/backend/jobs/core.c - copied, changed from r257007, soc2013/mattbw/backend/jobs.c Deleted: soc2013/mattbw/backend/jobs.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/jobs/do.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Sep 6 18:41:57 2013 (r257031) +++ soc2013/mattbw/backend/Makefile Fri Sep 6 20:46:51 2013 (r257032) @@ -28,7 +28,6 @@ event.c \ group.c \ group_map.c \ - jobs.c \ licenses.c \ namever.c \ pkgutils.c \ @@ -63,6 +62,7 @@ query/packages.c SRCS+= \ + jobs/core.c \ jobs/check.c \ jobs/do.c Copied and modified: soc2013/mattbw/backend/jobs/core.c (from r257007, soc2013/mattbw/backend/jobs.c) ============================================================================== --- soc2013/mattbw/backend/jobs.c Fri Sep 6 12:08:31 2013 (r257007, copy source) +++ soc2013/mattbw/backend/jobs/core.c Fri Sep 6 20:46:51 2013 (r257032) @@ -24,18 +24,18 @@ #include /* gchar, g_... */ #include /* bool, true, false */ #include /* strcmp */ -#include "pk-backend.h" /* pk_..., Pk... */ +#include "../pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg_... */ -#include "db.h" /* db_... */ -#include "emit.h" /* emit_package */ -#include "event.h" /* event_cb */ -#include "jobs.h" /* jobs_... */ -#include "jobs/check.h" /* jobs_check_... */ -#include "namever.h" /* namever_* */ -#include "pkgutils.h" /* pkgutils_... */ -#include "repo.h" /* repo_... */ -#include "utils.h" /* ERR */ +#include "../db.h" /* db_... */ +#include "../emit.h" /* emit_package */ +#include "../event.h" /* event_cb */ +#include "../namever.h" /* namever_* */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../repo.h" /* repo_... */ +#include "../utils.h" /* ERR */ +#include "check.h" /* jobs_check_... */ +#include "core.h" /* jobs_... */ static const char *APPLY_ERRORS[] = { "This shouldn't occur and is a bug.", /* EPKG_OK */ Modified: soc2013/mattbw/backend/jobs/do.h ============================================================================== --- soc2013/mattbw/backend/jobs/do.h Fri Sep 6 18:41:57 2013 (r257031) +++ soc2013/mattbw/backend/jobs/do.h Fri Sep 6 20:46:51 2013 (r257032) @@ -23,6 +23,7 @@ #include /* bool */ #include "../pk-backend.h" /* PkBackend */ + #include "core.h" /* pkg_info_ptr */ struct jobs_spec { From owner-svn-soc-all@FreeBSD.ORG Fri Sep 6 21:29:36 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 64169827 for ; Fri, 6 Sep 2013 21:29:36 +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 42C4827B4 for ; Fri, 6 Sep 2013 21:29:36 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r86LTaot083398 for ; Fri, 6 Sep 2013 21:29:36 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r86LTaAc083393 for svn-soc-all@FreeBSD.org; Fri, 6 Sep 2013 21:29:36 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 6 Sep 2013 21:29:36 GMT Message-Id: <201309062129.r86LTaAc083393@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: r257040 - soc2013/mattbw/backend/jobs 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, 06 Sep 2013 21:29:36 -0000 Author: mattbw Date: Fri Sep 6 21:29:35 2013 New Revision: 257040 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257040 Log: Add some tests for job/check.c. Trying to get as close to full coverage of the backend's non-database and non-backend code as possible in the time remaining. Added: soc2013/mattbw/backend/jobs/Atffile soc2013/mattbw/backend/jobs/check_test.c Modified: soc2013/mattbw/backend/jobs/check.c soc2013/mattbw/backend/jobs/check.h Added: soc2013/mattbw/backend/jobs/Atffile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/jobs/Atffile Fri Sep 6 21:29:35 2013 (r257040) @@ -0,0 +1,5 @@ +Content-Type: application/X-atf-atffile; version="1" + +prop: test-suite = "main" + +tp: check_test Modified: soc2013/mattbw/backend/jobs/check.c ============================================================================== --- soc2013/mattbw/backend/jobs/check.c Fri Sep 6 20:51:15 2013 (r257039) +++ soc2013/mattbw/backend/jobs/check.c Fri Sep 6 21:29:35 2013 (r257040) @@ -34,20 +34,20 @@ #include "check.h" /* jobs_check_... */ static bool check_package(struct pkg *pkg, struct query_id *query_ids, guint count, bool reject_non_updates); -static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); static struct pkg *jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); -/* Checks a solved job against a string vector of PackageIDs to ensure any +/* + * Checks a solved job against a string vector of PackageIDs to ensure any * packages that match the PackageIDs match them fully. - * - * Returns NULL if the check succeeded, and a struct pkg if that package - * failed the check. + * + * Returns NULL if the check succeeded, and a struct pkg if that package failed + * the check. */ -struct pkg * +struct pkg * jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates) { - struct pkg *package; + struct pkg *package; struct query_id *query_ids; assert(jobs != NULL); @@ -63,11 +63,17 @@ package = jobs_check_query_ids(jobs, query_ids, count, reject_non_updates); } - return package; } -static bool +/* + * Checks a package and its pre-computed namever against a Query ID to ensure + * that if the ID refers to the same package name and version, the + * architecture and repository also match. + * + * Exposed publicly to allow for unit testing. + */ +bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever) { @@ -85,11 +91,9 @@ /* Does the rest of the PackageID match up? */ success = query_check_package(pkg, query_id); } - return success; } - static struct pkg * jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates) @@ -111,9 +115,9 @@ count, reject_non_updates); } else if (err == EPKG_END) { /* - * Only return a package if it failed to match. - * If we've reached this far all of them have - * matched, so don't return one! + * Only return a package if it failed to match. If + * we've reached this far all of them have matched, + * so don't return one! */ package = NULL; break; @@ -127,17 +131,17 @@ } /* - * Checks a single job target package against a set of candidate - * query IDs to make sure that the originally requested packages in - * the job have been resolved properly. - */ + * Checks a single job target package against a set of candidate query IDs to + * make sure that the originally requested packages in the job have been + * resolved properly. + */ static bool check_package(struct pkg *package, struct query_id *query_ids, guint count, bool reject_non_updates) { bool success; guint i; - char *namever; + char *namever; assert(package != NULL); @@ -147,12 +151,10 @@ if (namever == NULL) { success = false; } - for (i = 0; i < count; i++) { if (!success) { break; } - assert(success); success = jobs_check_id_on_package(package, query_ids + i, Modified: soc2013/mattbw/backend/jobs/check.h ============================================================================== --- soc2013/mattbw/backend/jobs/check.h Fri Sep 6 20:51:15 2013 (r257039) +++ soc2013/mattbw/backend/jobs/check.h Fri Sep 6 21:29:35 2013 (r257040) @@ -25,6 +25,9 @@ #include /* bool */ #include "../pkg.h" /* pkg_... */ +#include "../query/id.h" /* struct query_id */ + +bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); struct pkg *jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates); #endif /* !_PKGNG_BACKEND_JOBS_CHECK_H_ */ Added: soc2013/mattbw/backend/jobs/check_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/jobs/check_test.c Fri Sep 6 21:29:35 2013 (r257040) @@ -0,0 +1,131 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include /* free */ +#include /* strcmp */ +#include "pkg.h" /* pkg... */ + +#include "check.h" /* job_check... */ +#include "../testutils.h" /* gen_pkg */ + +/* ATF/kyua tests for 'check.c'. */ + +ATF_TC(check_id_on_package_no_match); +ATF_TC_HEAD(check_id_on_package_no_match, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Ensure package/ID check succeeds if package and ID don't match."); +} +ATF_TC_BODY(check_id_on_package_no_match, tc) +{ + struct pkg *package; + struct query_id id; + + package = gen_pkg(PKG_REMOTE); + ATF_REQUIRE(package != NULL); + + id.namever = strdup("nonsuch-1.2.3"); + id.arch = strdup("freebsd:10:x86:32"); + id.repo = strdup("packagesite"); + + ATF_CHECK(jobs_check_id_on_package(package, &id, "pkg-1.1.4")); + + pkg_free(package); + free(id.namever); + free(id.arch); + free(id.repo); +} + +ATF_TC(check_id_on_package_partial_match); +ATF_TC_HEAD(check_id_on_package_partial_match, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Ensure package/ID check fails if only the namever matches."); +} +ATF_TC_BODY(check_id_on_package_partial_match, tc) +{ + struct pkg *package; + struct query_id id; + + package = gen_pkg(PKG_REMOTE); + ATF_REQUIRE(package != NULL); + + id.namever = strdup("pkg-1.1.4"); + id.arch = strdup("freebsd:10:x86:32"); + id.repo = strdup("nope"); + + ATF_CHECK(!jobs_check_id_on_package(package, &id, "pkg-1.1.4")); + + free(id.arch); + free(id.repo); + + id.arch = strdup("nope"); + id.repo = strdup("packagesite"); + + ATF_CHECK(!jobs_check_id_on_package(package, &id, "pkg-1.1.4")); + + pkg_free(package); + free(id.namever); + free(id.arch); + free(id.repo); +} + +ATF_TC(check_id_on_package_full_match); +ATF_TC_HEAD(check_id_on_package_full_match, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Ensure package/ID check succeeds if everything matches."); +} +ATF_TC_BODY(check_id_on_package_full_match, tc) +{ + struct pkg *package; + struct query_id id; + + package = gen_pkg(PKG_REMOTE); + ATF_REQUIRE(package != NULL); + + id.namever = strdup("pkg-1.1.4"); + id.arch = strdup("freebsd:10:x86:32"); + id.repo = strdup("packagesite"); + + ATF_CHECK(jobs_check_id_on_package(package, &id, "pkg-1.1.4")); + + pkg_free(package); + free(id.namever); + free(id.arch); + free(id.repo); +} + +/* + * TEST PACK + */ + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, check_id_on_package_no_match); + ATF_TP_ADD_TC(tp, check_id_on_package_partial_match); + ATF_TP_ADD_TC(tp, check_id_on_package_full_match); + + return atf_no_error(); +} From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 09:37: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 BCA90D44 for ; Sat, 7 Sep 2013 09:37:45 +0000 (UTC) (envelope-from ccqin@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 A7A73263B for ; Sat, 7 Sep 2013 09:37: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 r879bjmo009185 for ; Sat, 7 Sep 2013 09:37:45 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r879bjle009162 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 09:37:45 GMT (envelope-from ccqin@FreeBSD.org) Date: Sat, 7 Sep 2013 09:37:45 GMT Message-Id: <201309070937.r879bjle009162@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257067 - in soc2013/ccqin/head/sys: dev/ath net80211 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, 07 Sep 2013 09:37:45 -0000 Author: ccqin Date: Sat Sep 7 09:37:45 2013 New Revision: 257067 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257067 Log: add some debug stuff. * blank call to ath_rate_newassoc(), replace to ieee80211_ratectl_node_init(ni) * add some IEEE80211_NOTE to ieee80211 ratectl. * enable IEEE80211_MSG_RATECTL. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Sat Sep 7 09:37:45 2013 (r257067) @@ -1391,6 +1391,7 @@ caps |= IEEE80211_RATECTL_CAP_MULTXCHAIN; ieee80211_ratectl_init(vap, caps); + /* complete setup */ ieee80211_vap_attach(vap, ath_media_change, ieee80211_media_status); return vap; @@ -5601,8 +5602,10 @@ an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate); an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate); - +#if 0 ath_rate_newassoc(sc, an, isnew); +#endif + ieee80211_ratectl_node_init(ni); if (isnew && (vap->iv_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey && Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sat Sep 7 09:37:45 2013 (r257067) @@ -1428,7 +1428,7 @@ /* XXX need some msg out here.*/ } - rc_info = (struct ieee80211_rc_series*)(mtag + 1); + rc_info = (struct ieee80211_rc_info*)(mtag + 1); rc = rc_info->iri_rc; bzero(rc_info, sizeof(rc_info)); Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Sat Sep 7 09:37:45 2013 (r257067) @@ -191,9 +191,8 @@ amn->amn_ticks = ticks; IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR: nrates=%d, initial rate %d", - rs->rs_nrates, - rate); + "%s: AMRR: nrates=%d, initial rate %d", + __func__, rs->rs_nrates, rate); } static void @@ -215,8 +214,8 @@ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR: current rate %d, txcnt=%d, retrycnt=%d", - rs->rs_rates[rix] & IEEE80211_RATE_VAL, + "%s: AMRR: current rate %d, txcnt=%d, retrycnt=%d", + __func__, rs->rs_rates[rix] & IEEE80211_RATE_VAL, amn->amn_txcnt, amn->amn_retrycnt); @@ -236,8 +235,8 @@ amn->amn_success = 0; rix++; IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR increasing rate %d (txcnt=%d retrycnt=%d)", - rs->rs_rates[rix] & IEEE80211_RATE_VAL, + "%s: AMRR increasing rate %d (txcnt=%d retrycnt=%d)", + __func__, rs->rs_rates[rix] & IEEE80211_RATE_VAL, amn->amn_txcnt, amn->amn_retrycnt); } else { amn->amn_recovery = 0; @@ -257,8 +256,8 @@ } rix--; IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR decreasing rate %d (txcnt=%d retrycnt=%d)", - rs->rs_rates[rix] & IEEE80211_RATE_VAL, + "%s: AMRR decreasing rate %d (txcnt=%d retrycnt=%d)", + __func__, rs->rs_rates[rix] & IEEE80211_RATE_VAL, amn->amn_txcnt, amn->amn_retrycnt); } amn->amn_recovery = 0; @@ -360,6 +359,13 @@ rc[3].rix = 0; } } + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: AMRR rate sets(rix, tries). rc[0]:(%d, %d), rc[1]:(%d, %d), " + "rc[2]:(%d, %d), rc[3]:(%d, %d)", __func__, + rc[0].rix, rc[0].tries, + rc[1].rix, rc[1].tries, + rc[2].rix, rc[2].tries, + rc[3].rix, rc[3].tries); #undef RATE #undef MCS } @@ -381,6 +387,12 @@ amn->amn_txcnt += rc_info->iri_txcnt; amn->amn_success += (rc_info->iri_txcnt - rc_info->iri_failcnt); amn->amn_retrycnt += rc_info->iri_retrycnt; + + IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni, + "%s: AMRR tx complete. txcnt=%d(%d) success=%d(%d) retrycnt=%d(%d)\n", + __func__, amn->amn_txcnt, rc_info->iri_txcnt, + amn->amn_success, (rc_info->iri_txcnt - rc_info->iri_failcnt), + amn->amn_retrycnt, rc_info->iri_retrycnt); } /* @@ -398,6 +410,9 @@ amn->amn_txcnt = txcnt; amn->amn_success = success; amn->amn_retrycnt = retrycnt; + IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni, + "%s: AMRR tx update. txcnt=%d success=%d retrycnt=%d\n", + __func__, txcnt, success, retrycnt); } static int Modified: soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c Sat Sep 7 09:37:45 2013 (r257067) @@ -262,7 +262,9 @@ "driver_caps", CTLFLAG_RW, &vap->iv_caps, 0, "driver capabilities"); #ifdef IEEE80211_DEBUG + ieee80211_debug |= IEEE80211_MSG_RATECTL; vap->iv_debug = ieee80211_debug; + if_printf(ifp, "%s: iv_debug=0x%x\n", __func__, vap->iv_debug); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "debug", CTLFLAG_RW, &vap->iv_debug, 0, "control debugging printfs"); Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Sat Sep 7 09:37:45 2013 (r257067) @@ -106,6 +106,9 @@ if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE]) ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR); vap->iv_rate->ir_init(vap, capabilities); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_RATECTL, + "%s: ratectl initialized. caps=0x%08x\n", + __func__, capabilities); } void Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Sat Sep 7 07:58:29 2013 (r257066) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Sat Sep 7 09:37:45 2013 (r257067) @@ -161,6 +161,8 @@ const struct ieee80211vap *vap = ni->ni_vap; vap->iv_rate->ir_node_init(ni); + IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_RATECTL, + "%s: net80211 ratectl node inited.\n", __func__); } static void __inline @@ -262,9 +264,18 @@ __inline static const struct ieee80211_rateset * ieee80211_ratectl_get_rateset(const struct ieee80211_node *ni) { - return ieee80211_ratectl_node_is11n(ni) ? - (struct ieee80211_rateset *) &ni->ni_htrates : - &ni->ni_rates; + const struct ieee80211_rateset *rs = NULL; + /* 11n or not? Pick the right rateset */ + if (ieee80211_ratectl_node_is11n(ni)) { + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: 11n node", __func__); + rs = (struct ieee80211_rateset *) &ni->ni_htrates; + } else { + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: non-11n node", __func__); + rs = &ni->ni_rates; + } + return rs; } static void __inline From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 10:29:22 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 CDA31647 for ; Sat, 7 Sep 2013 10:29:22 +0000 (UTC) (envelope-from ccqin@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 B9BE8289A for ; Sat, 7 Sep 2013 10:29: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 r87ATMYn047094 for ; Sat, 7 Sep 2013 10:29:22 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87ATMfR047090 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 10:29:22 GMT (envelope-from ccqin@FreeBSD.org) Date: Sat, 7 Sep 2013 10:29:22 GMT Message-Id: <201309071029.r87ATMfR047090@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257070 - in soc2013/ccqin/head/sys: dev/ath net80211 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, 07 Sep 2013 10:29:23 -0000 Author: ccqin Date: Sat Sep 7 10:29:22 2013 New Revision: 257070 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257070 Log: add some debug msgs to funcs relating to rateclt mbuf tag. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Sat Sep 7 09:47:18 2013 (r257069) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Sat Sep 7 10:29:22 2013 (r257070) @@ -4099,7 +4099,9 @@ ts->ts_shortretry, ts->ts_longretry, ts->ts_finaltsi, ts->ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); - } + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't locate mbuf tag for ratectl.\n", __func__); } ath_tx_default_comp(sc, bf, 0); } else Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sat Sep 7 09:47:18 2013 (r257069) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sat Sep 7 10:29:22 2013 (r257070) @@ -1425,8 +1425,11 @@ sizeof(struct ieee80211_rc_info), M_NOWAIT); if (NULL == mtag) return; - /* XXX need some msg out here.*/ - } + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't alloc mbuf tag for ratectl.\n", __func__); + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: nani? find mbuf tag for ratectl directly.\n", __func__); rc_info = (struct ieee80211_rc_info*)(mtag + 1); rc = rc_info->iri_rc; @@ -4159,7 +4162,9 @@ ts->ts_shortretry, ts->ts_longretry, ts->ts_finaltsi, ts->ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); - } + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't locate mbuf tag for ratectl.\n", __func__); } ath_tx_default_comp(sc, bf, fail); @@ -4557,7 +4562,9 @@ ts.ts_shortretry, ts.ts_longretry, ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); - } + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't locate mbuf tag for ratectl.\n", __func__); ATH_TX_LOCK(sc); tap = ath_tx_get_tx_tid(an, tid->tid); @@ -4965,7 +4972,9 @@ ts.ts_shortretry, ts.ts_longretry, ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); - } + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't locate mbuf tag for ratectl.\n", __func__); } /* @@ -5074,7 +5083,9 @@ ts.ts_shortretry, ts.ts_longretry, ts.ts_finaltsi, ts.ts_rate); ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); - } + } else + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't locate mbuf tag for ratectl.\n", __func__); } /* * This is called early so atid->hwq_depth can be tracked. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c Sat Sep 7 09:47:18 2013 (r257069) +++ soc2013/ccqin/head/sys/net80211/ieee80211_freebsd.c Sat Sep 7 10:29:22 2013 (r257070) @@ -264,7 +264,7 @@ #ifdef IEEE80211_DEBUG ieee80211_debug |= IEEE80211_MSG_RATECTL; vap->iv_debug = ieee80211_debug; - if_printf(ifp, "%s: iv_debug=0x%x\n", __func__, vap->iv_debug); + if_printf(ifp, "%s: iv_debug=0x%08x\n", __func__, vap->iv_debug); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "debug", CTLFLAG_RW, &vap->iv_debug, 0, "control debugging printfs"); From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 12:34: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 5CA57E2F for ; Sat, 7 Sep 2013 12:34: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 492D62E2A for ; Sat, 7 Sep 2013 12:34: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 r87CY6Ko059038 for ; Sat, 7 Sep 2013 12:34:06 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87CY6Ol059016 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 12:34:06 GMT (envelope-from def@FreeBSD.org) Date: Sat, 7 Sep 2013 12:34:06 GMT Message-Id: <201309071234.r87CY6Ol059016@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: r257074 - 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: Sat, 07 Sep 2013 12:34:06 -0000 Author: def Date: Sat Sep 7 12:34:06 2013 New Revision: 257074 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257074 Log: Roll back XTS implementation to r255309. 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 Sat Sep 7 11:41:52 2013 (r257073) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Sat Sep 7 12:34:06 2013 (r257074) @@ -32,6 +32,12 @@ #include #include +#ifdef _KERNEL +#include +#else +#include +#endif + void xts_aes_keysetup(struct xts_ctx *ctx, const uint8_t *key, uint32_t keybits) { @@ -57,7 +63,42 @@ .pa_id = XTS_ALG_AES, }; -void +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 xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, uint64_t *tweak, const uint8_t *src, uint8_t *dst) { @@ -67,7 +108,7 @@ gf_mul128(tweak, tweak); } -void +static __inline 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) { @@ -83,7 +124,7 @@ xor128(dst, dst, tweak); } -void +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) { @@ -97,46 +138,40 @@ 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, uint64_t *alpha_j, - int len, const uint8_t *src, uint8_t *dst) + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; - if (alpha_j == NULL) { - xts_start(alg, tweak_ctx, tweak, sector, xtweak); - alpha_j = tweak; - } + xts_start(alg, tweak_ctx, tweak, sector, xtweak); while (len >= XTS_BLK_BYTES) { - xts_fullblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst); + xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); dst += XTS_BLK_BYTES; src += XTS_BLK_BYTES; len -= XTS_BLK_BYTES; } if (len != 0) - xts_lastblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst, len); + xts_lastblock(alg->pa_encrypt, data_ctx, tweak, 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, uint64_t *alpha_j, - int len, const uint8_t *src, uint8_t *dst) + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; uint64_t prevtweak[XTS_BLK_BYTES / 8]; - if (alpha_j == NULL) { - xts_start(alg, tweak_ctx, tweak, sector, xtweak); - alpha_j = tweak; - } + xts_start(alg, tweak_ctx, tweak, sector, xtweak); if ((len & XTS_BLK_MASK) != 0) len -= XTS_BLK_BYTES; while (len >= XTS_BLK_BYTES) { - xts_fullblock(alg->pa_decrypt, data_ctx, alpha_j, src, dst); + xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst); dst += XTS_BLK_BYTES; src += XTS_BLK_BYTES; len -= XTS_BLK_BYTES; @@ -144,10 +179,10 @@ if (len != 0) { len += XTS_BLK_BYTES; - 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); + prevtweak[0] = tweak[0]; + prevtweak[1] = tweak[1]; + gf_mul128(tweak, tweak); + xts_fullblock(alg->pa_decrypt, data_ctx, tweak, 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 Sat Sep 7 11:41:52 2013 (r257073) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Sat Sep 7 12:34:06 2013 (r257074) @@ -32,13 +32,6 @@ #include #include #include -#include - -#ifdef _KERNEL -#include -#else -#include -#endif #define XTS_BLK_BYTES 16 #define XTS_BLK_MASK (XTS_BLK_BYTES - 1) @@ -65,59 +58,15 @@ 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, uint64_t *alpha_j, - int len, const uint8_t *src, uint8_t *dst); + uint64_t sector, const uint8_t *xtweak, 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, uint64_t *alpha_j, - int len, const uint8_t *src, uint8_t *dst); + uint64_t sector, const uint8_t *xtweak, 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 Sat Sep 7 16:04:26 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 9AFA5A66 for ; Sat, 7 Sep 2013 16:04:26 +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 8709D27EC for ; Sat, 7 Sep 2013 16:04: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 r87G4Q7U057577 for ; Sat, 7 Sep 2013 16:04:26 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G4Qe2057568 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:04:26 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:04:26 GMT Message-Id: <201309071604.r87G4Qe2057568@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: r257080 - 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: Sat, 07 Sep 2013 16:04:26 -0000 Author: zcore Date: Sat Sep 7 16:04:26 2013 New Revision: 257080 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257080 Log: support ATA_READ_DMA Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sat Sep 7 15:16:30 2013 (r257079) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sat Sep 7 16:04:26 2013 (r257080) @@ -32,7 +32,9 @@ #include #include -#define BLOCKIF_IOV_MAX 32 /* XXX */ +#include "ahci.h" + +#define BLOCKIF_IOV_MAX AHCI_SG_ENTRIES /* XXX */ struct blockif_req { struct iovec br_iov[BLOCKIF_IOV_MAX]; Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 15:16:30 2013 (r257079) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:04:26 2013 (r257080) @@ -79,10 +79,11 @@ struct ahci_ioreq { struct blockif_req io_req; struct ahci_port *io_pr; - uint32_t io_genid; STAILQ_ENTRY(ahci_ioreq) io_list; - int io_didx; - uint8_t *io_status; + uint8_t *cfis; + int slot; + uint8_t status; + uint8_t error; }; struct ahci_port { @@ -93,6 +94,7 @@ int atapi; int reset; int mult_sectors; + uint32_t unhandled; uint8_t xfermode; uint32_t clb; @@ -212,7 +214,34 @@ } } -static void ahci_write_fis_d2h(struct ahci_port *p) +static void ahci_write_fis_d2h(struct ahci_port *p, struct ahci_ioreq *aior) +{ + uint8_t fis[20]; + uint8_t *cfis = aior->cfis; + + memset(fis, 0, sizeof(fis)); + fis[0] = FIS_TYPE_REGD2H; + fis[1] = (1 << 6); + fis[2] = aior->status; + fis[3] = aior->error; + fis[4] = cfis[4]; + fis[5] = cfis[5]; + fis[6] = cfis[6]; + fis[7] = cfis[7]; + fis[8] = cfis[8]; + fis[9] = cfis[9]; + fis[10] = cfis[10]; + fis[11] = cfis[11]; + fis[12] = cfis[12]; + fis[13] = cfis[13]; + if (aior->error & ATA_S_ERROR) + p->is |= AHCI_P_IX_TFE; + p->tfd = (aior->error << 8) | aior->status; + p->ci &= ~(1 << aior->slot); + ahci_write_fis(p, FIS_TYPE_REGD2H, fis); +} + +static void ahci_write_reset_fis_d2h(struct ahci_port *p) { uint8_t fis[20]; @@ -228,60 +257,6 @@ ahci_write_fis(p, FIS_TYPE_REGD2H, fis); } -/* - * blockif callback routine - this runs in the context of the blockif - * i/o thread, so the mutex needs to be acquired. - */ -static void -pci_ahci_ioreq_cb(struct blockif_req *br, int err) -{ - struct ahci_port *pr; - struct pci_ahci_softc *sc; - struct ahci_ioreq *vio; - - vio = br->br_param; - pr = vio->io_pr; - sc = pr->pr_sc; - - DPRINTF(("ahci_ioreq_cb %d\n", err)); - pthread_mutex_lock(&sc->mtx); - - /* TODO */ - - ahci_generate_intr(sc); - /* - * Move the blockif request back to the free list - */ - STAILQ_INSERT_TAIL(&pr->iofhd, vio, io_list); - pr->iofree++; - - pthread_mutex_unlock(&sc->mtx); - DPRINTF(("%s exit\n", __func__)); -} - -static void -pci_ahci_ioreq_init(struct ahci_port *pr) -{ - struct ahci_ioreq *vr; - int i; - - pr->ioqsz = blockif_queuesz(pr->bctx); - pr->ioreq = calloc(pr->ioqsz, sizeof(struct ahci_ioreq)); - STAILQ_INIT(&pr->iofhd); - - /* - * Add all i/o request entries to the free queue - */ - for (i = 0; i < pr->ioqsz; i++) { - vr = &pr->ioreq[i]; - vr->io_pr = pr; - vr->io_req.br_callback = pci_ahci_ioreq_cb; - vr->io_req.br_param = vr; - STAILQ_INSERT_TAIL(&pr->iofhd, vr, io_list); - pr->iofree++; - } -} - static void ahci_port_reset(struct ahci_port *pr) { @@ -305,7 +280,7 @@ pr->tfd |= ATA_S_READY; } else pr->sig = PxSIG_ATAPI; - ahci_write_fis_d2h(pr); + ahci_write_reset_fis_d2h(pr); } static void @@ -336,8 +311,59 @@ } static void -handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis, - struct ahci_cmd_hdr *hdr) +read_dma(struct ahci_port *p, int slot, uint8_t *cfis) +{ + int i, err; + uint64_t lba; + uint32_t len; + struct ahci_ioreq *aior; + struct blockif_req *breq; + struct pci_ahci_softc *sc = p->pr_sc; + struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); + struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + + lba = ((cfis[7] & 0xf) << 24) | (cfis[6] << 16) | + (cfis[5] << 8) | cfis[4]; + lba *= blockif_sectsz(p->bctx); + + if (!cfis[12]) + len = 256; + else + len = cfis[12]; + len *= blockif_sectsz(p->bctx); + + /* + * Pull request off free list + */ + if (!p->iofree) { + p->unhandled |= (1 << slot); + return; + } + aior = STAILQ_FIRST(&p->iofhd); + assert(aior != NULL); + STAILQ_REMOVE_HEAD(&p->iofhd, io_list); + p->iofree--; + aior->cfis = cfis; + aior->slot = slot; + breq = &aior->io_req; + breq->br_offset = lba; + breq->br_iovcnt = hdr->prdtl; + + /* + * Build up the iovec based on the prdt + */ + for (i = 0; i < hdr->prdtl; i++) { + breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc), + prdt->dba, prdt->dbc + 1); + breq->br_iov[i].iov_len = prdt->dbc + 1; + prdt++; + } + err = blockif_read(p->bctx, breq); + assert(err == 0); +} + +static void +handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { struct pci_ahci_softc *sc = p->pr_sc; struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); @@ -349,6 +375,7 @@ uint64_t sectors; int i, len; void *from; + struct ahci_cmd_hdr *hdr; sectors = blockif_size(p->bctx) / blockif_sectsz(p->bctx); memset(buf, 0, sizeof(buf)); @@ -392,6 +419,7 @@ buf[101] = (sectors >> 16); buf[102] = (sectors >> 32); buf[103] = (sectors >> 48); + hdr = p->cmd_lst + slot * AHCI_CL_SIZE; if (hdr->prdtl == 0) { WPRINTF(("wrong prdtl\n")); return; @@ -409,6 +437,7 @@ hdr->prdbc = sizeof(buf) - len; p->tfd = ATA_S_DSC | ATA_S_READY; p->is |= AHCI_P_IX_DP; + p->ci &= ~(1 << slot); ahci_generate_intr(sc); break; } @@ -441,6 +470,7 @@ break; } p->is |= AHCI_P_IX_DP; + p->ci &= ~(1 << slot); ahci_generate_intr(sc); break; } @@ -454,8 +484,12 @@ p->tfd = ATA_S_DSC | ATA_S_READY; } p->is |= AHCI_P_IX_DP; + p->ci &= ~(1 << slot); ahci_generate_intr(sc); break; + case ATA_READ_DMA: + read_dma(p, slot, cfis); + break; default: break; } @@ -499,7 +533,7 @@ if (cfis[1] & 0x80) { dprintf("command cfis\n"); - handle_cmd(p, slot, cfis, hdr); + handle_cmd(p, slot, cfis); } else { dprintf("control cfis\n"); if (cfis[15] & (1 << 2)) @@ -508,6 +542,7 @@ p->reset = 0; ahci_port_reset(p); } + p->ci &= ~(1 << slot); } } @@ -515,19 +550,86 @@ handle_port(struct ahci_port *p) { int i; - struct pci_ahci_softc *sc; - if (!(p->cmd & AHCI_P_CMD_ST) || !p->ci) + if (!(p->cmd & AHCI_P_CMD_ST)) return; - sc = p->pr_sc; - for (i = 0; (i < 32) && p->ci; i++) { - if (p->ci & (1 << i)) { + if (p->ci & (1 << i)) handle_slot(p, i); - p->ci &= ~(1 << i); + } +} + +/* + * blockif callback routine - this runs in the context of the blockif + * i/o thread, so the mutex needs to be acquired. + */ +static void +pci_ahci_ioreq_cb(struct blockif_req *br, int err) +{ + struct ahci_port *p; + struct pci_ahci_softc *sc; + struct ahci_ioreq *aior; + + aior = br->br_param; + p = aior->io_pr; + sc = p->pr_sc; + + DPRINTF(("ahci_ioreq_cb %d\n", err)); + pthread_mutex_lock(&sc->mtx); + + if (err) { + aior->status = ATA_S_READY | ATA_S_ERROR; + aior->error = ATA_E_ABORT; + } else { + aior->status = ATA_S_READY | ATA_S_DSC; + aior->error = 0; + } + ahci_write_fis_d2h(p, aior); + + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + p->iofree++; + + /* + * If the number of oustanding commands has dropped below the + * threshold, see if more can be queued up + */ + if (p->ioqsz - p->iofree <= 2 && (p->cmd & AHCI_P_CMD_ST)) { + int i; + for (i = 0; (i < 32) && p->unhandled; i++) { + if (p->unhandled & (1 << i)) + handle_slot(p, i); } } + + pthread_mutex_unlock(&sc->mtx); + DPRINTF(("%s exit\n", __func__)); +} + +static void +pci_ahci_ioreq_init(struct ahci_port *pr) +{ + struct ahci_ioreq *vr; + int i; + + pr->ioqsz = blockif_queuesz(pr->bctx); + pr->ioreq = calloc(pr->ioqsz, sizeof(struct ahci_ioreq)); + STAILQ_INIT(&pr->iofhd); + + /* + * Add all i/o request entries to the free queue + */ + for (i = 0; i < pr->ioqsz; i++) { + vr = &pr->ioreq[i]; + vr->io_pr = pr; + vr->io_req.br_callback = pci_ahci_ioreq_cb; + vr->io_req.br_param = vr; + STAILQ_INSERT_TAIL(&pr->iofhd, vr, io_list); + pr->iofree++; + } } static int @@ -563,14 +665,17 @@ pi->pi_arg = sc; sc->asc_pi = pi; - for (i = 0; i < AHCI_MAX_PORTS; i++) - sc->port[i].pr_sc = sc; - /* - * Allocate blockif request structures and add them - * to the free list - */ sc->port[0].bctx = bctxt; - pci_ahci_ioreq_init(&sc->port[0]); + + for (i = 0; i < AHCI_MAX_PORTS; i++) { + sc->port[i].pr_sc = sc; + /* + * Allocate blockif request structures and add them + * to the free list + */ + if (sc->port[i].bctx) + pci_ahci_ioreq_init(&sc->port[i]); + } pthread_mutex_init(&sc->mtx, NULL); From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 16:05:59 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 3B08FA8E for ; Sat, 7 Sep 2013 16:05:59 +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 0E78527FA for ; Sat, 7 Sep 2013 16:05: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 r87G5wgt076237 for ; Sat, 7 Sep 2013 16:05:58 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G5wIG076231 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:05:58 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:05:58 GMT Message-Id: <201309071605.r87G5wIG076231@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: r257081 - 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: Sat, 07 Sep 2013 16:05:59 -0000 Author: zcore Date: Sat Sep 7 16:05:58 2013 New Revision: 257081 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257081 Log: support ATA_WRITE_DMA 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 Sat Sep 7 16:04:26 2013 (r257080) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:05:58 2013 (r257081) @@ -94,7 +94,8 @@ int atapi; int reset; int mult_sectors; - uint32_t unhandled; + uint32_t unhandled_read; + uint32_t unhandled_write; uint8_t xfermode; uint32_t clb; @@ -311,9 +312,9 @@ } static void -read_dma(struct ahci_port *p, int slot, uint8_t *cfis) +handle_dma(struct ahci_port *p, int slot, uint8_t *cfis) { - int i, err; + int i, err, readop = 1; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -322,6 +323,17 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + if (cfis[2] == ATA_WRITE_DMA) + readop = 0; + + if (!p->iofree) { + if (readop) + p->unhandled_read |= (1 << slot); + else + p->unhandled_write |= (1 << slot); + return; + } + lba = ((cfis[7] & 0xf) << 24) | (cfis[6] << 16) | (cfis[5] << 8) | cfis[4]; lba *= blockif_sectsz(p->bctx); @@ -335,10 +347,6 @@ /* * Pull request off free list */ - if (!p->iofree) { - p->unhandled |= (1 << slot); - return; - } aior = STAILQ_FIRST(&p->iofhd); assert(aior != NULL); STAILQ_REMOVE_HEAD(&p->iofhd, io_list); @@ -358,7 +366,10 @@ breq->br_iov[i].iov_len = prdt->dbc + 1; prdt++; } - err = blockif_read(p->bctx, breq); + if (readop) + err = blockif_read(p->bctx, breq); + else + err = blockif_write(p->bctx, breq); assert(err == 0); } @@ -488,7 +499,8 @@ ahci_generate_intr(sc); break; case ATA_READ_DMA: - read_dma(p, slot, cfis); + case ATA_WRITE_DMA: + handle_dma(p, slot, cfis); break; default: break; @@ -599,10 +611,17 @@ */ if (p->ioqsz - p->iofree <= 2 && (p->cmd & AHCI_P_CMD_ST)) { int i; - for (i = 0; (i < 32) && p->unhandled; i++) { - if (p->unhandled & (1 << i)) + uint32_t unhandled = p->unhandled_read | p->unhandled_write; + for (i = 0; (i < 32) && unhandled; i++) { + if (!p->iofree) + break; + if (unhandled & (1 << i)) { handle_slot(p, i); + unhandled &= ~(1 << i); + } } + p->unhandled_read &= unhandled; + p->unhandled_write &= unhandled; } pthread_mutex_unlock(&sc->mtx); From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 16:07:02 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 38669AA9 for ; Sat, 7 Sep 2013 16:07:02 +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 2509D2800 for ; Sat, 7 Sep 2013 16:07:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r87G72Yo088993 for ; Sat, 7 Sep 2013 16:07:02 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G72ql088988 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:07:02 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:07:02 GMT Message-Id: <201309071607.r87G72ql088988@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: r257082 - 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: Sat, 07 Sep 2013 16:07:02 -0000 Author: zcore Date: Sat Sep 7 16:07:01 2013 New Revision: 257082 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257082 Log: support ATA_READ_DMA48 and ATA_WRITE_DMA48 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 Sat Sep 7 16:05:58 2013 (r257081) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:07:01 2013 (r257082) @@ -323,7 +323,7 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; - if (cfis[2] == ATA_WRITE_DMA) + if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48) readop = 0; if (!p->iofree) { @@ -334,14 +334,26 @@ return; } - lba = ((cfis[7] & 0xf) << 24) | (cfis[6] << 16) | - (cfis[5] << 8) | cfis[4]; + if (cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) { + lba = ((uint64_t)cfis[10] << 40) | + ((uint64_t)cfis[9] << 32) | + ((uint64_t)cfis[8] << 24) | + ((uint64_t)cfis[6] << 16) | + ((uint64_t)cfis[5] << 8) | + cfis[4]; + if (!cfis[12] && !cfis[13]) + len = 65536; + else + len = cfis[13] << 8 | cfis[12]; + } else { + lba = ((cfis[7] & 0xf) << 24) | (cfis[6] << 16) | + (cfis[5] << 8) | cfis[4]; + if (!cfis[12]) + len = 256; + else + len = cfis[12]; + } lba *= blockif_sectsz(p->bctx); - - if (!cfis[12]) - len = 256; - else - len = cfis[12]; len *= blockif_sectsz(p->bctx); /* @@ -500,6 +512,8 @@ break; case ATA_READ_DMA: case ATA_WRITE_DMA: + case ATA_READ_DMA48: + case ATA_WRITE_DMA48: handle_dma(p, slot, cfis); break; default: From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 16:08:00 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 CDA31ABE for ; Sat, 7 Sep 2013 16:08:00 +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 BA0512805 for ; Sat, 7 Sep 2013 16:08:00 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r87G80E0000695 for ; Sat, 7 Sep 2013 16:08:00 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G80Nk000689 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:08:00 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:08:00 GMT Message-Id: <201309071608.r87G80Nk000689@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: r257083 - 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: Sat, 07 Sep 2013 16:08:00 -0000 Author: zcore Date: Sat Sep 7 16:08:00 2013 New Revision: 257083 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257083 Log: support ATA_FLUSHCACHE and ATA_FLUSHCACHE48 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 Sat Sep 7 16:07:01 2013 (r257082) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:08:00 2013 (r257083) @@ -54,6 +54,8 @@ #include "ahci.h" #include "block_if.h" +#define MAX_PORTS 6 /* Intel Cougar Point AHCI support 6 ports*/ + #define PxSIG_ATA 0x00000101 /* ATA drive */ #define PxSIG_ATAPI 0xeb140101 /* ATAPI drive */ @@ -82,8 +84,6 @@ STAILQ_ENTRY(ahci_ioreq) io_list; uint8_t *cfis; int slot; - uint8_t status; - uint8_t error; }; struct ahci_port { @@ -94,8 +94,10 @@ int atapi; int reset; int mult_sectors; + int flush_pending; uint32_t unhandled_read; uint32_t unhandled_write; + pthread_cond_t flush_cond; uint8_t xfermode; uint32_t clb; @@ -154,7 +156,7 @@ uint32_t em_ctl; uint32_t cap2; uint32_t bohc; - struct ahci_port port[AHCI_MAX_PORTS]; + struct ahci_port port[MAX_PORTS]; }; #define ahci_ctx(sc) ((sc)->asc_pi->pi_vmctx) @@ -215,16 +217,18 @@ } } -static void ahci_write_fis_d2h(struct ahci_port *p, struct ahci_ioreq *aior) +static void ahci_write_fis_d2h(struct ahci_port *p, int slot, + uint8_t *cfis, uint32_t tfd) { uint8_t fis[20]; - uint8_t *cfis = aior->cfis; + uint8_t error; + error = (tfd >> 8) & 0xff; memset(fis, 0, sizeof(fis)); fis[0] = FIS_TYPE_REGD2H; fis[1] = (1 << 6); - fis[2] = aior->status; - fis[3] = aior->error; + fis[2] = tfd & 0xff; + fis[3] = error; fis[4] = cfis[4]; fis[5] = cfis[5]; fis[6] = cfis[6]; @@ -235,10 +239,10 @@ fis[11] = cfis[11]; fis[12] = cfis[12]; fis[13] = cfis[13]; - if (aior->error & ATA_S_ERROR) + if (error & ATA_S_ERROR) p->is |= AHCI_P_IX_TFE; - p->tfd = (aior->error << 8) | aior->status; - p->ci &= ~(1 << aior->slot); + p->tfd = tfd; + p->ci &= ~(1 << slot); ahci_write_fis(p, FIS_TYPE_REGD2H, fis); } @@ -386,6 +390,19 @@ } static void +handle_flush(struct ahci_port *p, int slot, uint8_t *cfis) +{ + struct pci_ahci_softc *sc = p->pr_sc; + + if (p->unhandled_write) { + p->flush_pending = 1; + pthread_cond_wait(&p->flush_cond, &sc->mtx); + p->flush_pending = 0; + } + ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); +} + +static void handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { struct pci_ahci_softc *sc = p->pr_sc; @@ -516,6 +533,10 @@ case ATA_WRITE_DMA48: handle_dma(p, slot, cfis); break; + case ATA_FLUSHCACHE: + case ATA_FLUSHCACHE48: + handle_flush(p, slot, cfis); + break; default: break; } @@ -596,6 +617,7 @@ struct ahci_port *p; struct pci_ahci_softc *sc; struct ahci_ioreq *aior; + uint32_t tfd; aior = br->br_param; p = aior->io_pr; @@ -604,14 +626,11 @@ DPRINTF(("ahci_ioreq_cb %d\n", err)); pthread_mutex_lock(&sc->mtx); - if (err) { - aior->status = ATA_S_READY | ATA_S_ERROR; - aior->error = ATA_E_ABORT; - } else { - aior->status = ATA_S_READY | ATA_S_DSC; - aior->error = 0; - } - ahci_write_fis_d2h(p, aior); + if (err) + tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; + else + tfd = ATA_S_READY | ATA_S_DSC; + ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); /* * Move the blockif request back to the free list @@ -636,6 +655,8 @@ } p->unhandled_read &= unhandled; p->unhandled_write &= unhandled; + if (!p->unhandled_write && p->flush_pending) + pthread_cond_signal(&p->flush_cond); } pthread_mutex_unlock(&sc->mtx); @@ -700,20 +721,22 @@ sc->port[0].bctx = bctxt; - for (i = 0; i < AHCI_MAX_PORTS; i++) { + sc->ports = MAX_PORTS; + for (i = 0; i < sc->ports; i++) { + if (!sc->port[i].bctx) + continue; sc->port[i].pr_sc = sc; + pthread_cond_init(&sc->port[i].flush_cond, NULL); /* * Allocate blockif request structures and add them * to the free list */ - if (sc->port[i].bctx) - pci_ahci_ioreq_init(&sc->port[i]); + pci_ahci_ioreq_init(&sc->port[i]); } pthread_mutex_init(&sc->mtx, NULL); /* Intel Cougar Point AHCI */ - sc->ports = 6; sc->cap = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 16:08: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 9B9C7AD1 for ; Sat, 7 Sep 2013 16:08:48 +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 883EA2809 for ; Sat, 7 Sep 2013 16:08: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 r87G8mkP011070 for ; Sat, 7 Sep 2013 16:08:48 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G8mV6011065 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:08:48 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:08:48 GMT Message-Id: <201309071608.r87G8mV6011065@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: r257084 - 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: Sat, 07 Sep 2013 16:08:48 -0000 Author: zcore Date: Sat Sep 7 16:08:48 2013 New Revision: 257084 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257084 Log: should set prdbc before send h2d fis 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 Sat Sep 7 16:08:00 2013 (r257083) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:08:48 2013 (r257084) @@ -83,6 +83,7 @@ struct ahci_port *io_pr; STAILQ_ENTRY(ahci_ioreq) io_list; uint8_t *cfis; + uint32_t len; int slot; }; @@ -369,6 +370,7 @@ p->iofree--; aior->cfis = cfis; aior->slot = slot; + aior->len = len; breq = &aior->io_req; breq->br_offset = lba; breq->br_iovcnt = hdr->prdtl; @@ -618,18 +620,23 @@ struct pci_ahci_softc *sc; struct ahci_ioreq *aior; uint32_t tfd; + struct ahci_cmd_hdr *hdr; aior = br->br_param; p = aior->io_pr; sc = p->pr_sc; + hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; DPRINTF(("ahci_ioreq_cb %d\n", err)); pthread_mutex_lock(&sc->mtx); - if (err) - tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; - else + if (!err) { tfd = ATA_S_READY | ATA_S_DSC; + hdr->prdbc = aior->len; + } else { + tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; + hdr->prdbc = 0; + } ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); /* From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 16:09:44 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 8A033AEA for ; Sat, 7 Sep 2013 16:09:44 +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 76B6F2811 for ; Sat, 7 Sep 2013 16:09:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r87G9iCW022504 for ; Sat, 7 Sep 2013 16:09:44 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87G9iXp022496 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 16:09:44 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 7 Sep 2013 16:09:44 GMT Message-Id: <201309071609.r87G9iXp022496@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: r257085 - 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: Sat, 07 Sep 2013 16:09:44 -0000 Author: zcore Date: Sat Sep 7 16:09:44 2013 New Revision: 257085 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257085 Log: support ATA_READ_FPDMA_QUEUED and ATA_WRITE_FPDMA_QUEUED Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sat Sep 7 16:08:48 2013 (r257084) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sat Sep 7 16:09:44 2013 (r257085) @@ -49,7 +49,7 @@ #define BLOCKIF_SIG 0xb109b109 -#define BLOCKIF_MAXREQ 8 +#define BLOCKIF_MAXREQ 32 enum blockop { BOP_READ, Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:08:48 2013 (r257084) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 7 16:09:44 2013 (r257085) @@ -177,7 +177,6 @@ sc->is |= (1 << i); } - dprintf("%x %x\n", sc->port[0].is, sc->port[0].ie); DPRINTF(("%s %x\n", __func__, sc->is)); if (sc->is && (sc->ghc & AHCI_GHC_IE)) pci_generate_msi(sc->asc_pi, 0); @@ -218,6 +217,24 @@ } } +static void ahci_write_fis_sdb(struct ahci_port *p, int slot, + uint32_t tfd) +{ + uint8_t fis[8]; + uint8_t error; + + error = (tfd >> 8) & 0xff; + memset(fis, 0, sizeof(fis)); + fis[0] = error; + fis[2] = tfd & 0x77; + *(uint32_t *)(fis + 4) = (1 << slot); + if (error & ATA_S_ERROR) + p->is |= AHCI_P_IX_TFE; + p->tfd = tfd; + p->ci &= ~(1 << slot); + ahci_write_fis(p, FIS_TYPE_SETDEVBITS, fis); +} + static void ahci_write_fis_d2h(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t tfd) { @@ -328,7 +345,8 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; - if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48) + if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48 || + cfis[2] == ATA_WRITE_FPDMA_QUEUED) readop = 0; if (!p->iofree) { @@ -339,24 +357,33 @@ return; } - if (cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) { + if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || + cfis[2] == ATA_READ_FPDMA_QUEUED) { lba = ((uint64_t)cfis[10] << 40) | ((uint64_t)cfis[9] << 32) | ((uint64_t)cfis[8] << 24) | ((uint64_t)cfis[6] << 16) | ((uint64_t)cfis[5] << 8) | cfis[4]; - if (!cfis[12] && !cfis[13]) + len = cfis[11] << 8 | cfis[3]; + if (!len) + len = 65536; + } else if (cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) { + lba = ((uint64_t)cfis[10] << 40) | + ((uint64_t)cfis[9] << 32) | + ((uint64_t)cfis[8] << 24) | + ((uint64_t)cfis[6] << 16) | + ((uint64_t)cfis[5] << 8) | + cfis[4]; + len = cfis[13] << 8 | cfis[12]; + if (!len) len = 65536; - else - len = cfis[13] << 8 | cfis[12]; } else { lba = ((cfis[7] & 0xf) << 24) | (cfis[6] << 16) | (cfis[5] << 8) | cfis[4]; - if (!cfis[12]) + len = cfis[12]; + if (!len) len = 256; - else - len = cfis[12]; } lba *= blockif_sectsz(p->bctx); len *= blockif_sectsz(p->bctx); @@ -533,6 +560,8 @@ case ATA_WRITE_DMA: case ATA_READ_DMA48: case ATA_WRITE_DMA48: + case ATA_READ_FPDMA_QUEUED: + case ATA_WRITE_FPDMA_QUEUED: handle_dma(p, slot, cfis); break; case ATA_FLUSHCACHE: @@ -621,23 +650,38 @@ struct ahci_ioreq *aior; uint32_t tfd; struct ahci_cmd_hdr *hdr; + int ncq = 0; + + DPRINTF(("ahci_ioreq_cb %d\n", err)); aior = br->br_param; p = aior->io_pr; sc = p->pr_sc; hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; + if (aior->cfis[2] == ATA_WRITE_FPDMA_QUEUED || + aior->cfis[2] == ATA_READ_FPDMA_QUEUED) + ncq = 1; - DPRINTF(("ahci_ioreq_cb %d\n", err)); pthread_mutex_lock(&sc->mtx); if (!err) { tfd = ATA_S_READY | ATA_S_DSC; - hdr->prdbc = aior->len; + if (ncq) + hdr->prdbc = 0; + else + hdr->prdbc = aior->len; } else { tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; hdr->prdbc = 0; + if (ncq) + p->serr |= (1 << aior->slot); } - ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); + + if (ncq) { + p->sact &= ~(1 << aior->slot); + ahci_write_fis_sdb(p, aior->slot, tfd); + } else + ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); /* * Move the blockif request back to the free list From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 19:11:50 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 B1B63436 for ; Sat, 7 Sep 2013 19:11:50 +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 9ECD32F9E for ; Sat, 7 Sep 2013 19:11:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r87JBo2q088498 for ; Sat, 7 Sep 2013 19:11:50 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87JBou2088492 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 19:11:50 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 7 Sep 2013 19:11:50 GMT Message-Id: <201309071911.r87JBou2088492@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: r257094 - soc2013/dpl/head/contrib/bzip2 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, 07 Sep 2013 19:11:50 -0000 Author: dpl Date: Sat Sep 7 19:11:50 2013 New Revision: 257094 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257094 Log: Updated bzip2 to cope with the current Capsicum interface. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Sep 7 18:55:52 2013 (r257093) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Sep 7 19:11:50 2013 (r257094) @@ -670,17 +670,23 @@ { cap_rights_t rights; + cap_rights_init(&rights); if (fd == OUT_FILENO) - rights = CAP_READ|CAP_FSTAT|CAP_WRITE|CAP_FCHMOD|CAP_FCHOWN|CAP_FUTIMES; + cap_rights_set(&rights, CAP_READ|CAP_FSTAT|CAP_WRITE|CAP_FCHMOD|CAP_FCHOWN|CAP_FUTIMES); else if (fd == IN_FILENO) - rights = CAP_WRITE|CAP_READ|CAP_FSTAT; + cap_rights_set(&rights, CAP_WRITE|CAP_READ|CAP_FSTAT); else if (fd == STDERR_FILENO) - rights = CAP_WRITE; - else if ( fd == cwd ) - rights = CAP_UNLINKAT|CAP_LOOKUP; + cap_rights_set(&rights, CAP_WRITE); + else if (fd == cwd) + cap_rights_set(&rights, CAP_UNLINKAT|CAP_LOOKUP); + else { + fprintf (stderr, "%s: Wrong file descriptor.\n", progName); + setExit(1); + exit(exitValue); + } - if (cap_rights_limit(fd, rights) < 0 && errno != ENOSYS){ - fprintf ( stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", + if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS){ + fprintf (stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", progName, fd, strerror(errno)); setExit(1); exit(exitValue); From owner-svn-soc-all@FreeBSD.ORG Sat Sep 7 20:44:42 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 B8230FB0 for ; Sat, 7 Sep 2013 20:44:42 +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 988302496 for ; Sat, 7 Sep 2013 20:44:42 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r87Kigde066000 for ; Sat, 7 Sep 2013 20:44:42 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r87KigCB065996 for svn-soc-all@FreeBSD.org; Sat, 7 Sep 2013 20:44:42 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 7 Sep 2013 20:44:42 GMT Message-Id: <201309072044.r87KigCB065996@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: r257100 - soc2013/dpl/head/contrib/xz/src/xz 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, 07 Sep 2013 20:44:42 -0000 Author: dpl Date: Sat Sep 7 20:44:42 2013 New Revision: 257100 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257100 Log: Updated xz to cope with the new Capsicum interface. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Sat Sep 7 19:43:39 2013 (r257099) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Sat Sep 7 20:44:42 2013 (r257100) @@ -1013,42 +1013,27 @@ if( opt_mode != MODE_TEST ) io_open_dest(pairs[i]); #if defined(CAPSICUM) - limitfd(pairs[i]); + limitpair(pairs[i]); #endif } return pairs; } #if defined(CAPSICUM) +void limitfd(int, unsigned long long); + extern void -limitfd(file_pair *pair) +limitpair(file_pair *pair) { - cap_rights_t rights; + if(pair->dir_fd != -1 ) + limitfd(pair->dir_fd, CAP_FSTATAT|CAP_UNLINKAT|CAP_LOOKUP); - if(pair->dir_fd != -1 ){ - rights = CAP_FSTATAT|CAP_UNLINKAT|CAP_LOOKUP; - if (cap_rights_limit(pair->dir_fd, rights) < 0 && errno != ENOSYS){ - message_error("%s: %s", pair->dest_name, strerror(errno)); - exit(E_ERROR); - } - } + if(pair->src_fd != -1 ) + limitfd(pair->src_fd, CAP_READ|CAP_SEEK); - if(pair->src_fd != -1 ){ - rights = CAP_READ|CAP_SEEK; - if (cap_rights_limit(pair->src_fd, rights) < 0 && errno != ENOSYS){ - message_error("%s: %s", pair->src_name, strerror(errno)); - exit(E_ERROR); - } - } + if(pair->dest_fd != -1 ) + limitfd(pair->dest_fd, CAP_WRITE|CAP_FSTAT|CAP_FCHOWN|CAP_FCHMOD|CAP_FUTIMES); - if(pair->dest_fd != -1 ){ - rights = CAP_WRITE|CAP_FSTAT|CAP_FCHOWN - |CAP_FCHMOD|CAP_FUTIMES; - if (cap_rights_limit(pair->dest_fd, rights) < 0 && errno != ENOSYS){ - message_error("%s: %s", pair->dest_name, strerror(errno)); - exit(E_ERROR); - } - } return; } @@ -1057,36 +1042,35 @@ { cap_rights_t rights; - if( cap_rights_get(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) { - message_error("%d: %s", STDIN_FILENO, strerror(errno)); - exit(E_ERROR); - } else if (rights == 0) { - if (cap_rights_limit(STDIN_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ - message_error("%d: %s", STDIN_FILENO, strerror(errno)); - exit(E_ERROR); - } - } + cap_rights_init(&rights); + limitfd( STDIN_FILENO, CAP_READ); + limitfd( STDOUT_FILENO, CAP_WRITE); + limitfd( STDERR_FILENO, CAP_WRITE); - if( cap_rights_get(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) { - message_error("%d: %s", STDOUT_FILENO, strerror(errno)); + if (cap_enter() < 0 && errno != ENOSYS) { + message_error("cap_enter: %s", strerror(errno)); exit(E_ERROR); - } else if (rights == 0) { - if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ - message_error("%d: %s", STDOUT_FILENO, strerror(errno)); - exit(E_ERROR); - } } - if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ - message_error("%d: %s", STDERR_FILENO, strerror(errno)); - exit(E_ERROR); - } + return; +} - if (cap_enter() < 0 && errno != ENOSYS){ - message_error("cap_enter: %s", strerror(errno)); +void +limitfd(int fd, unsigned long long cap) +{ + cap_rights_t rights; + + cap_rights_init(&rights); + cap_rights_set(&rights, cap); + + if( cap_rights_get(fd, &rights) < 0 && errno != ENOSYS) { + message_error("%d: %s", fd, strerror(errno)); exit(E_ERROR); + } else { + if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDIN_FILENO, strerror(errno)); + exit(E_ERROR); + } } - - return; } -#endif +#endif /* CAPSICUM */ Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Sat Sep 7 19:43:39 2013 (r257099) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Sat Sep 7 20:44:42 2013 (r257100) @@ -106,7 +106,7 @@ /// \brief Limits fd using FreeBSD's Capsicum framework. /// /// \param fd File descriptor to limit. -extern void limitfd(file_pair *pair); +extern void limitpair(file_pair *pair); /// \brief Enters Capability mode, and limit basic fds. extern void capsicum_enter(void); Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Sat Sep 7 19:43:39 2013 (r257099) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Sat Sep 7 20:44:42 2013 (r257100) @@ -144,6 +144,7 @@ int forkpid, i, nfiles=0; //Filenames will be here, and get passed to io_open_files(). // If we get past of 8 elements, realloc 8 more. + // XXX check char **files = malloc( 8*sizeof(char*) ); #if defined(_WIN32) && !defined(__CYGWIN__)