From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 10:49:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E9DF4F39 for ; Sun, 21 Jul 2013 10:49:37 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id DA8691E6 for ; Sun, 21 Jul 2013 10:49:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6LAnb0S066600 for ; Sun, 21 Jul 2013 10:49:37 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LAnbt7066587 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 10:49:37 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 21 Jul 2013 10:49:37 GMT Message-Id: <201307211049.r6LAnbt7066587@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: r254994 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 10:49:38 -0000 Author: mattbw Date: Sun Jul 21 10:49:37 2013 New Revision: 254994 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254994 Log: add stub for get_update_detail Added: soc2013/mattbw/backend/actions/get_update_detail.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sun Jul 21 07:24:25 2013 (r254993) +++ soc2013/mattbw/backend/Makefile Sun Jul 21 10:49:37 2013 (r254994) @@ -16,6 +16,7 @@ actions/get_details.c \ actions/get_files.c \ actions/get_repo_list.c \ + actions/get_update_detail.c \ actions/install_files.c \ actions/install_packages.c \ actions/refresh_cache.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Sun Jul 21 07:24:25 2013 (r254993) +++ soc2013/mattbw/backend/actions.h Sun Jul 21 10:49:37 2013 (r254994) @@ -31,6 +31,7 @@ gboolean get_details_thread(PkBackend *backend); gboolean get_files_thread(PkBackend *backend); gboolean get_repo_list_thread(PkBackend *backend); +gboolean get_update_detail_thread(PkBackend *backend); gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); gboolean refresh_cache_thread(PkBackend *backend); Added: soc2013/mattbw/backend/actions/get_update_detail.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/get_update_detail.c Sun Jul 21 10:49:37 2013 (r254994) @@ -0,0 +1,33 @@ +/*- + * 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 /* gboolean */ + +#include "../actions.h" /* Prototype */ +#include "../utils.h" /* ERR */ + +gboolean +get_update_detail_thread(PkBackend *backend) +{ + + ERR(backend, PK_ERROR_ENUM_NOT_SUPPORTED, "todo"); + (void)pk_backend_finished(backend); + return FALSE; +} Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 21 07:24:25 2013 (r254993) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 21 10:49:37 2013 (r254994) @@ -146,6 +146,14 @@ } void +pk_backend_get_update_detail(PkBackend *backend, gchar **package_ids) +{ + + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + THREAD(backend, get_update_detail_thread); +} + +void pk_backend_install_files(PkBackend *backend, gboolean only_trusted, gchar **full_paths) { From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 12:06:05 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E0E64E9C for ; Sun, 21 Jul 2013 12:06:05 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C29F17D1 for ; Sun, 21 Jul 2013 12:06:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6LC65A2039115 for ; Sun, 21 Jul 2013 12:06:05 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LC653Y039096 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 12:06:05 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 21 Jul 2013 12:06:05 GMT Message-Id: <201307211206.r6LC653Y039096@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: r254997 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 12:06:05 -0000 Author: mattbw Date: Sun Jul 21 12:06:05 2013 New Revision: 254997 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254997 Log: (untested) implement barebones and possibly broken GetUpdateDetail; need a good repo to test this on Modified: soc2013/mattbw/backend/actions/get_update_detail.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/search.c Modified: soc2013/mattbw/backend/actions/get_update_detail.c ============================================================================== --- soc2013/mattbw/backend/actions/get_update_detail.c Sun Jul 21 11:59:41 2013 (r254996) +++ soc2013/mattbw/backend/actions/get_update_detail.c Sun Jul 21 12:06:05 2013 (r254997) @@ -18,16 +18,71 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include /* gboolean */ +#include /* assert */ +#include /* gboolean */ +#include "pkg.h" /* pkg... */ +#include "../pk-backend.h" /* pk_..., Pk... */ -#include "../actions.h" /* Prototype */ -#include "../utils.h" /* ERR */ +#include "../actions.h" /* Prototype */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query.h" /* query_..., struct query */ +#include "../utils.h" /* ERR */ + +static bool emit(struct pkg *pkg, const gchar *id, struct query *q); gboolean get_update_detail_thread(PkBackend *backend) { + bool success; - ERR(backend, PK_ERROR_ENUM_NOT_SUPPORTED, "todo"); + success = query_match_id_to_emitter(backend, PKG_LOAD_BASIC, emit); (void)pk_backend_finished(backend); - return FALSE; + return success ? TRUE : FALSE; +} + +static bool +emit(struct pkg *pkg, const gchar *id, struct query *q) +{ + bool success; + const char *origin; + PkBackend *backend; + struct pkg *old; + struct pkgdb *db; + + assert(pkg != NULL); + assert(id != NULL); + assert(q != NULL); + + db = query_db(q); + backend = query_backend(q); + success = FALSE; + + /* See if there's a version of this package already installed */ + origin = NULL; + pkg_get(pkg, PKG_ORIGIN, &origin); + + old = NULL; + pkgutils_add_old_version(db, pkg, &old); + if (old != NULL && pkg_version_change(old) == PKG_UPGRADE) { + const char *update_text; + gchar *old_id; + + old_id = pkgutils_pkg_to_id(pkg); + + /* TODO: elaborate on this */ + update_text = "new version"; + + (void)pk_backend_update_detail(backend, id, old_id, NULL, NULL, + NULL, NULL, PK_RESTART_ENUM_NONE, update_text, NULL, + PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL); + /* Phew */ + + g_free(old_id); + + success = TRUE; + } + + pkg_free(old); + + return success; } Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sun Jul 21 11:59:41 2013 (r254996) +++ soc2013/mattbw/backend/pkgutils.c Sun Jul 21 12:06:05 2013 (r254997) @@ -171,9 +171,12 @@ /* * Adds any old version of the given package to itself as PKG_OLD_VERSION. + * + * If old_p is given, the package representing the old version is retained and + * pointed to through old_p; else it is freed. */ void -pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg) +pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p) { const char *origin; struct pkg *pkg2; @@ -190,8 +193,12 @@ pkg_get(pkg2, PKG_VERSION, &version); pkg_set(pkg, PKG_OLD_VERSION, version); - pkg_free(pkg2); } + + if (old_p != NULL) + *old_p = pkg2; + else + pkg_free(pkg2); } /* Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sun Jul 21 11:59:41 2013 (r254996) +++ soc2013/mattbw/backend/pkgutils.h Sun Jul 21 12:06:05 2013 (r254997) @@ -31,7 +31,7 @@ const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); -void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg); +void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p); void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info); void pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info); Modified: soc2013/mattbw/backend/search.c ============================================================================== --- soc2013/mattbw/backend/search.c Sun Jul 21 11:59:41 2013 (r254996) +++ soc2013/mattbw/backend/search.c Sun Jul 21 12:06:05 2013 (r254997) @@ -47,7 +47,7 @@ pkg = NULL; while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { - pkgutils_add_old_version(search->db, pkg); + pkgutils_add_old_version(search->db, pkg, NULL); pkgutils_emit_filtered(pkg, search->backend, search->filters, From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 13:15:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1FFCE1000 for ; Sun, 21 Jul 2013 13:15:06 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 11E8EB6C for ; Sun, 21 Jul 2013 13:15: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 r6LDF5ra069963 for ; Sun, 21 Jul 2013 13:15:05 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LDF5pC069961 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 13:15:05 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 21 Jul 2013 13:15:05 GMT Message-Id: <201307211315.r6LDF5pC069961@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: r254999 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 13:15:06 -0000 Author: mattbw Date: Sun Jul 21 13:15:05 2013 New Revision: 254999 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254999 Log: accidentally transposed old and pkg in get_update_detail; fixed Modified: soc2013/mattbw/backend/actions/get_update_detail.c Modified: soc2013/mattbw/backend/actions/get_update_detail.c ============================================================================== --- soc2013/mattbw/backend/actions/get_update_detail.c Sun Jul 21 12:47:33 2013 (r254998) +++ soc2013/mattbw/backend/actions/get_update_detail.c Sun Jul 21 13:15:05 2013 (r254999) @@ -63,11 +63,11 @@ old = NULL; pkgutils_add_old_version(db, pkg, &old); - if (old != NULL && pkg_version_change(old) == PKG_UPGRADE) { + if (old != NULL && pkg_version_change(pkg) == PKG_UPGRADE) { const char *update_text; gchar *old_id; - old_id = pkgutils_pkg_to_id(pkg); + old_id = pkgutils_pkg_to_id(old); /* TODO: elaborate on this */ update_text = "new version"; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 14:15:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 21EB13FF for ; Sun, 21 Jul 2013 14:15:26 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 1356EF4D for ; Sun, 21 Jul 2013 14:15: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 r6LEFPjP072454 for ; Sun, 21 Jul 2013 14:15:25 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LEFPMS072450 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 14:15:25 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 21 Jul 2013 14:15:25 GMT Message-Id: <201307211415.r6LEFPMS072450@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: r255000 - in soc2013/mattbw/backend: . query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 14:15:26 -0000 Author: mattbw Date: Sun Jul 21 14:15:25 2013 New Revision: 255000 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255000 Log: use name-version for jobs instead of name only Modified: soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/jobs.c Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sun Jul 21 13:15:05 2013 (r254999) +++ soc2013/mattbw/backend/pkgutils.c Sun Jul 21 14:15:25 2013 (r255000) @@ -97,6 +97,22 @@ } /* + * Allocates and returns a string of the form "name-version" that identifies + * the given package's name and version. + * + * To be freed using free(3). + */ +char * +pkgutils_pkg_namever(struct pkg *pkg) +{ + char *result; + + result = NULL; + (void)pkg_asprintf(&result, "%n-%v", pkg, pkg); + return result; +} + +/* * Gets the PackageKit repository name for the package. */ const char * Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sun Jul 21 13:15:05 2013 (r254999) +++ soc2013/mattbw/backend/pkgutils.h Sun Jul 21 14:15:25 2013 (r255000) @@ -28,6 +28,7 @@ PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); +char *pkgutils_pkg_namever(struct pkg *pkg); const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Sun Jul 21 13:15:05 2013 (r254999) +++ soc2013/mattbw/backend/query/jobs.c Sun Jul 21 14:15:25 2013 (r255000) @@ -29,7 +29,6 @@ #include "core.h" /* query_... */ #include "jobs.h" /* query_jobs_... */ -static int add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static int repo_from_query(struct pkg_jobs *jobs, struct query *q); /* @@ -71,6 +70,7 @@ job_emit_ptr f) { bool success; + char *namever; struct pkg_jobs *jobs; PkBackend *backend; @@ -80,6 +80,7 @@ success = false; jobs = NULL; + namever = NULL; backend = query_backend(q); @@ -95,7 +96,13 @@ "could not set repo"); goto cleanup; } - if (add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { + namever = pkgutils_pkg_namever(pkg); + if (namever == NULL) { + ERR(backend, + PK_ERROR_ENUM_OOM, + "could not allocate a namever"); + } + if (pkg_jobs_add(jobs, MATCH_EXACT, &namever, 1) != EPKG_OK) { ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not add to job"); @@ -111,6 +118,7 @@ success = f(jobs, q); cleanup: + free(namever); pkg_jobs_free(jobs); return success; } @@ -138,17 +146,6 @@ return true; } -/* Adds a single package to a jobs structure. */ -static int -add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) -{ - char *name; - - name = NULL; - pkg_get(pkg, PKG_NAME, &name); - return pkg_jobs_add(jobs, type, &name, 1); -} - /* Sets a jobset to target the repository the given query is looking in. */ static int repo_from_query(struct pkg_jobs *jobs, struct query *q) From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 17:15:15 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CECC88D2 for ; Sun, 21 Jul 2013 17:15:15 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BDE38A54 for ; Sun, 21 Jul 2013 17:15: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 r6LHFFm4054288 for ; Sun, 21 Jul 2013 17:15:15 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LHFFMc054286 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 17:15:15 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 21 Jul 2013 17:15:15 GMT Message-Id: <201307211715.r6LHFFMc054286@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255004 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 17:15:15 -0000 Author: bguan Date: Sun Jul 21 17:15:15 2013 New Revision: 255004 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255004 Log: move usb_bus_methods to .c file Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Added: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 21 17:15:15 2013 (r255004) @@ -0,0 +1,257 @@ +/* $FreeBSD$ */ +/*- + * Xen Host Controller Interface + * + * Copyright (c) 2013 Bei Guan. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * USB eXtensible Host Controller Interface, a.k.a. USB 3.0 controller. + * + * The XHCI 1.0 spec can be found at + * http://www.intel.com/technology/usb/download/xHCI_Specification_for_USB.pdf + * and the USB 3.0 spec at + * http://www.usb.org/developers/docs/usb_30_spec_060910.zip + */ + +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define USB_DEBUG_VAR xhcidebug + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + +#include + +extern struct usb_bus_methods xenhci_bus_methods; + + +static void +xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) +{ + + printf("[gbtest-xenhci.c]xenhci_iterate_hw_softc()\n"); + //TODO +} + +usb_error_t +xenhci_init(struct xenhci_softc *sc, device_t dev) +{ + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + + /* set up the bus struct */ + sc->sc_bus.methods = &xenhci_bus_methods; + + /* setup devices array */ + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + + return (0); +} + + +static void +xenhci_do_poll(struct usb_bus *bus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_do_poll()\n"); + //TODO +} + +/*------------------------------------------------------------------------* + * xenhci root HUB support + *------------------------------------------------------------------------* + * Simulate a HUB by handling all the necessary requests. + *------------------------------------------------------------------------*/ + +static usb_error_t +xenhci_roothub_exec(struct usb_device *udev, + struct usb_device_request *req, const void **pptr, uint16_t *plength) +{ + printf("[gbtest-pv]xenhci.c: xenhci_roothub_exec()\n"); + //usb_error_t err; + + //return (err); + //TODO + return (0); +} + +static void +xenhci_xfer_setup(struct usb_setup_params *parm) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_xfer_unsetup(struct usb_xfer *xfer) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + return; +} + +static void +xenhci_start_dma_delay(struct usb_xfer *xfer) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, + struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static void +xenhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); +} + +static void +xenhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) +{ + printf("[gbtest-pv]xenhci.c: ()\n"); + //TODO +} + +static usb_error_t +xenhci_device_init(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_init()\n"); + //usb_error_t err; + //uint8_t temp; + + //return (err); + //TODO + return (0); +} + +static void +xenhci_device_uninit(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_uninit()\n"); + //TODO +} + +static void +xenhci_get_dma_delay(struct usb_device *udev, uint32_t *pus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_get_dma_delay()\n"); + //TODO +} + +static void +xenhci_device_resume(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_resume()\n"); + //TODO +} + +static void +xenhci_device_suspend(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_suspend()\n"); + //TODO +} + +static void +xenhci_set_hw_power(struct usb_bus *bus) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power()\n"); + DPRINTF("\n"); +} + +static void +xenhci_device_state_change(struct usb_device *udev) +{ + printf("[gbtest-pv]xenhci.c: xenhci_device_state_change()\n"); + //TODO +} + +static usb_error_t +xenhci_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, + uint8_t ep_mode) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_endpoint_mode()\n"); + //TODO + return (0); +} + +struct usb_bus_methods xenhci_bus_methods = { + .endpoint_init = xenhci_ep_init, + .endpoint_uninit = xenhci_ep_uninit, + .xfer_setup = xenhci_xfer_setup, + .xfer_unsetup = xenhci_xfer_unsetup, + .get_dma_delay = xenhci_get_dma_delay, + .device_init = xenhci_device_init, + .device_uninit = xenhci_device_uninit, + .device_resume = xenhci_device_resume, + .device_suspend = xenhci_device_suspend, + .set_hw_power = xenhci_set_hw_power, + .roothub_exec = xenhci_roothub_exec, + .xfer_poll = xenhci_do_poll, + .start_dma_delay = xenhci_start_dma_delay, + .set_address = xenhci_set_address, + .clear_stall = xenhci_ep_clear_stall, + .device_state_change = xenhci_device_state_change, + .set_hw_power_sleep = xenhci_set_hw_power_sleep, + .set_endpoint_mode = xenhci_set_endpoint_mode, +}; From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 17:15:35 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]) by hub.freebsd.org (Postfix) with ESMTP id A569D8E6 for ; Sun, 21 Jul 2013 17:15:35 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 96AE6A57 for ; Sun, 21 Jul 2013 17:15:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6LHFZM4054446 for ; Sun, 21 Jul 2013 17:15:35 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LHFZs9054444 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 17:15:35 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 21 Jul 2013 17:15:35 GMT Message-Id: <201307211715.r6LHFZs9054444@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255005 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 17:15:35 -0000 Author: bguan Date: Sun Jul 21 17:15:35 2013 New Revision: 255005 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255005 Log: move usb_bus_methods to .c file Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Sun Jul 21 17:15:15 2013 (r255004) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Sun Jul 21 17:15:35 2013 (r255005) @@ -30,22 +30,17 @@ #define _USBFRONT_H_ #define XENHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) -#define PCI_CBMEM 0x10 /* USB ports. This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. - * FIXME ?? + * FIXME ?? */ #define USB_MAXCHILDREN 31 #define USB_URB_RING_SIZE __RING_SIZE((usbif_urb_sring_t *)0, PAGE_SIZE) - -//FIXME:? -struct list_head { - struct list_head *next, *prev; -}; +LIST_HEAD(list_head, list_head); /* ring request shadow */ struct usb_shadow { @@ -68,9 +63,6 @@ enum usb_dev_speed speed; }; -///////////////////////////////////////////////// -// Moved to xenhci.h -///////////////////////////////////////////////// struct xenhci_softc { /* base device */ struct usb_bus sc_bus; @@ -80,19 +72,12 @@ struct usb_callout sc_callout; struct usb_device *sc_devices[XENHCI_MAX_DEVICES]; - struct resource *sc_io_res; - struct resource *sc_irq_res; - - void *sc_intr_hdl; - bus_size_t sc_io_size; - bus_space_tag_t sc_io_tag; - bus_space_handle_t sc_io_hdl; /* Virtual Host Controller has 4 urb queues */ - struct list_head pending_submit_list; //?? - struct list_head pending_unlink_list; //?? - struct list_head in_progress_list; //?? - struct list_head giveback_waiting_list; //?? + LIST_ENTRY(list_head) pending_submit_list; //?? + LIST_ENTRY(list_head) pending_unlink_list; //?? + LIST_ENTRY(list_head) in_progress_list; //?? + LIST_ENTRY(list_head) giveback_waiting_list; //?? //spinlock_t lock; @@ -105,7 +90,6 @@ struct rhport_status ports[USB_MAXCHILDREN]; struct vdevice_status devices[USB_MAXCHILDREN]; - /* Xen related staff */ /* shared ring */ device_t xb_dev; @@ -121,41 +105,11 @@ /* ring response thread */ struct task *ringthread;//struct task_struct *kthread; - struct list_head *wait_list; //wait_queue_head_t wq;???????? + LIST_ENTRY(list_head) *wait_list; //wait_queue_head_t wq;?? unsigned int waiting_resp;// }; -/* - * all bus methods are defined here -*/ - - - -extern struct usb_bus_methods xenhci_bus_methods; - -struct usb_bus_methods xenhci_bus_methods = { - .endpoint_init = NULL, //xhci_ep_init, - .endpoint_uninit = NULL, //xhci_ep_uninit, - .xfer_setup = NULL, //xhci_xfer_setup, - .xfer_unsetup = NULL, //xhci_xfer_unsetup, - .get_dma_delay = NULL, //xhci_get_dma_delay, - .device_init = NULL, //xhci_device_init, - .device_uninit = NULL, //xhci_device_uninit, - .device_resume = NULL, //xhci_device_resume, - .device_suspend = NULL, //xhci_device_suspend, - .set_hw_power = NULL, //xhci_set_hw_power, - .roothub_exec = NULL, //xhci_roothub_exec, - .xfer_poll = NULL, //xhci_do_poll, - .start_dma_delay = NULL, //xhci_start_dma_delay, - .set_address = NULL, //xhci_set_address, - .clear_stall = NULL, //xhci_ep_clear_stall, - .device_state_change = NULL, //xhci_device_state_change, - .set_hw_power_sleep = NULL, //xhci_set_hw_power_sleep, - .set_endpoint_mode = NULL, //xhci_set_endpoint_mode, -}; - - /* prototypes */ -//usb_error_t xenhci_init(struct xenhci_softc *, device_t); +usb_error_t xenhci_init(struct xenhci_softc *, device_t); #endif /* _USBFRONT_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sun Jul 21 17:16:23 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]) by hub.freebsd.org (Postfix) with ESMTP id D195D9BA for ; Sun, 21 Jul 2013 17:16:23 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C1986A5C for ; Sun, 21 Jul 2013 17:16: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 r6LHGNjq054585 for ; Sun, 21 Jul 2013 17:16:23 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6LHGN7J054583 for svn-soc-all@FreeBSD.org; Sun, 21 Jul 2013 17:16:23 GMT (envelope-from bguan@FreeBSD.org) Date: Sun, 21 Jul 2013 17:16:23 GMT Message-Id: <201307211716.r6LHGN7J054583@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255006 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 17:16:24 -0000 Author: bguan Date: Sun Jul 21 17:16:23 2013 New Revision: 255006 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255006 Log: get rid of the pci stuff Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Sun Jul 21 17:15:35 2013 (r255005) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Sun Jul 21 17:16:23 2013 (r255006) @@ -26,6 +26,8 @@ //__FBSDID("$FreeBSD: release/9.1.0/sys/dev/xen/usbfront/usbfront.c 237873 2013-07-01 05:13:50Z ken $"); __FBSDID("$FreeBSD$"); +#include +#include #include #include #include @@ -74,8 +76,8 @@ #include #include -#include #include +#include #include "xenbus_if.h" @@ -86,13 +88,18 @@ #define DPRINTK(fmt, args...) #endif +static int usbfront_probe(device_t dev); +static int usbfront_attach(device_t dev); static int usbfront_detach(device_t dev); +static int usbfront_suspend(device_t dev); +static int usbfront_resume(device_t dev); + /** * Entry point to this code when a new device is created. Allocate the basic * structures and the ring buffers for communication with the backend, and * inform the backend of the appropriate details for those. Switch to - * Connected state. + * Connected state. */ static int usbfront_probe(device_t dev) @@ -119,7 +126,7 @@ { struct xenhci_softc *sc; int err; - int rid; + //int rid; int i; int num_ports; @@ -130,15 +137,11 @@ sc = device_get_softc(dev); - /* initialise some bus fields */ - sc->sc_bus.parent = dev; - - /* set up the bus struct */ - sc->sc_bus.methods = &xenhci_bus_methods; - - /* setup devices array */ - sc->sc_bus.devices = sc->sc_devices; - sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + /* initialise some bus fields */ + if (xenhci_init(sc, dev)) { + device_printf(dev, "Could not initialize xen usb hc softc\n"); + goto error; + } /* set the bus revision, read the revision from xenstore */ backend_path = xenbus_get_otherend_path(dev); @@ -162,38 +165,15 @@ return (err); } - /* allocate resource for usb host controller (copy from xhci_pci.c) */ - pci_enable_busmaster(dev); - - rid = PCI_CBMEM; - sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (!sc->sc_io_res) { - device_printf(dev, "Could not map memory\n"); - goto error; - } - sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); - sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); - sc->sc_io_size = rman_get_size(sc->sc_io_res); - - usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); - - rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); - if (sc->sc_irq_res == NULL) { - device_printf(dev, "Could not allocate IRQ\n"); - } - sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); if (sc->sc_bus.bdev == NULL) { device_printf(dev, "Could not add USB device\n"); goto error; } + printf("[gbdebug-pvusb]device_add_child() done!\n"); device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); - - /* xen related stuff*/ + /* xen shared ring related stuff*/ err = xs_scanf(XST_NIL, backend_path, "num-ports", NULL, "%d", &num_ports); if (err) { xenbus_dev_fatal(dev, err, "reading num-ports"); @@ -216,7 +196,7 @@ sc->shadow[USB_URB_RING_SIZE-1].req.id = 0x0fff; - /* attach the xen host controller */ + /* attach the xen host controller */ //TODO?? err = device_probe_and_attach(sc->sc_bus.bdev); if (err) { device_printf(dev, "XENHCI halt/start/probe failed err=%d\n", err); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 02:11:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 22D79FC9 for ; Mon, 22 Jul 2013 02:11:34 +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 120231CCF for ; Mon, 22 Jul 2013 02:11:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6M2BXkP055156 for ; Mon, 22 Jul 2013 02:11:33 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M2BX1o055142 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 02:11:33 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 22 Jul 2013 02:11:33 GMT Message-Id: <201307220211.r6M2BX1o055142@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: r255023 - 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, 22 Jul 2013 02:11:34 -0000 Author: ccqin Date: Mon Jul 22 02:11:33 2013 New Revision: 255023 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255023 Log: Add rate control options and some 11n features to net80211 rate control code. 1) Add some rc options chip can provide to rc code when it init. 2) Implement some 11n features. rc code can get the corresponding feature capability and decide whether to use it. If some 11n features are choosen to be used, rc code must fill corresponding flags. Other flags that rc code may not be interested by now are filled by ieee80211_ratectl_complete_rcflags. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Jul 22 00:44:37 2013 (r255022) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Jul 22 02:11:33 2013 (r255023) @@ -66,10 +66,11 @@ } void -ieee80211_ratectl_init(struct ieee80211vap *vap) +ieee80211_ratectl_init(struct ieee80211vap *vap, uint32_t options) { if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE]) ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR); + vap->iv_rate.options = options; vap->iv_rate->ir_init(vap); } Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Mon Jul 22 00:44:37 2013 (r255022) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Mon Jul 22 02:11:33 2013 (r255023) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 Rui Paulo + * Copyright (c) 2013 Chenchong Qin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,6 +38,9 @@ #define IEEE80211_RATECTL_TX_SUCCESS 1 #define IEEE80211_RATECTL_TX_FAILURE 0 +#define IEEE80211_RATECTL_TRUE 1 +#define IEEE80211_RATECTL_FALSE 0 + #define IEEE80211_RATECTL_NUM 4 #define IEEE80211_RATECTL_DS_FLAG 0x01 /* dual-stream rate */ @@ -47,17 +51,28 @@ #define IEEE80211_RATECTL_STBC_FLAG 0x20 /* enable STBC */ #define IEEE80211_RATECTL_TS_FLAG 0x40 /* triple-stream rate */ +/* Hardware options chip offered to rate control code */ +#define IEEE80211_RATECTL_OPT_MRR 0x01 /* support MRR */ +#define IEEE80211_RATECTL_OPT_MRRPROT 0x02 /* support MRR + protect */ +#define IEEE80211_RATECTL_OPT_MULTXCHAIN 0x04 /* has more than 1 txchain */ + +#define IS_VAP_HT(vap) ((vap)->iv_htcaps & IEEE80211_HTC_HT) + +#define IS_HT_RATE(_rate) ((_rate) & 0x80) +#define HT_RC_2_MCS(_rc) ((_rc) & 0x7f) +#define HT_RC_2_STREAMS(_rc) ((((_rc) & 0x78) >> 3) + 1) + struct ieee80211_rc_series { uint8_t rix; /* ratetable index, not rate code */ uint8_t ratecode; /* hardware rate code */ uint8_t tries; uint8_t tx_power_cap; uint16_t flags; - uint16_t max4msframelen; }; struct ieee80211_ratectl { const char *ir_name; + uint32_t options; /* IEEE80211_RATECTL_OPTs */ int (*ir_attach)(const struct ieee80211vap *); void (*ir_detach)(const struct ieee80211vap *); void (*ir_init)(struct ieee80211vap *); @@ -77,7 +92,7 @@ void ieee80211_ratectl_register(int, const struct ieee80211_ratectl *); void ieee80211_ratectl_unregister(int); -void ieee80211_ratectl_init(struct ieee80211vap *); +void ieee80211_ratectl_init(struct ieee80211vap *, uint32_t); void ieee80211_ratectl_set(struct ieee80211vap *, int); MALLOC_DECLARE(M_80211_RATECTL); @@ -89,11 +104,11 @@ } static void __inline -ieee80211_ratectl_node_init(struct ieee80211_node *ni) +ieee80211_ratectl_node_init(struct ieee80211_node *ni, uint32_t options) { const struct ieee80211vap *vap = ni->ni_vap; - vap->iv_rate->ir_node_init(ni); + vap->iv_rate->ir_node_init(ni, options); } static void __inline @@ -117,19 +132,10 @@ int shortPreamble, size_t frameLen) { const struct ieee80211vap *vap = ni->ni_vap; - struct ieee80211com *ic = vap->iv_ic; vap->iv_rate->ir_rates(ni, rc, shortPreamble, frameLen); - - /* if enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 */ - if (!(ic->ic_htcaps & IEEE80211_HTC_HT)) - { - if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) - rc[1].tries = rc[2].tries = rc[3].tries = 0; - rc[1].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - rc[2].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - rc[3].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - } + + ieee80211_ratectl_complete_rcflags(ni, rc, shortPreamble); } static void __inline @@ -155,3 +161,106 @@ return; vap->iv_rate->ir_setinterval(vap, msecs); } + +static int __inline +ieee80211_ratectl_hascap_cw40(const struct ieee80211vap *vap, + const struct ieee80211_node *ni) +{ + return IS_VAP_HT(vap) && (ni->ni_chw == 40); +} + +static int __inline +ieee80211_ratectl_hascap_shortgi(const struct ieee80211vap *vap, + const struct ieee80211_node *ni) +{ + if (! IS_VAP_HT(vap)) + return IEEE80211_RATECTL_FALSE; + + 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; +} + + +static int __inline +ieee80211_ratectl_hascap_stbc(const struct ieee80211vap *vap, + const struct ieee80211_node *ni) +{ + return IS_VAP_HT(vap) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) && + (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM) && + (vap->iv_rate->options & IEEE80211_RATECTL_OPT_MULTXCHAIN); +} + +static void +ieee80211_ratectl_complete_rcflags(struct ieee80211_node *ni, + struct ieee80211_rc_series *rc, int shortPreamble) +{ + struct ieee80211com *ic = ni->ni_ic; + const struct ieee80211_rate_table * rt = ic->ic_rt; + uint8_t rate0, rate; + int i; + + rate0 = rt->info[rc[0].rix].rateCode; + + /* Make sure that rate control code doesn't mess it up. + * If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 + */ + + if (! IS_HT_RATE(rate0)) + { + if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) + rc[1].tries = rc[2].tries = rc[3].tries = 0; + rc[1].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + rc[2].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + rc[3].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + } + + for (i = 0; i < IEEE80211_RATECTL_NUM; i++) { + + if (rc[i].tries == 0) + continue; + + rate = rt->info[rc[i].rix].rateCode; + + /* + * Only enable short preamble for legacy rates + */ + if ((! IS_HT_RATE(rate)) && shortPreamble) + rate |= rt->info[rc[i].rix].shortPreamble; + + /* + * 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_HT_FLAG; + + /* + * XXX TODO: LDPC + */ + + /* + * Dual / Triple stream rate? + */ + if (HT_RC_2_STREAMS(rate) == 2) + rc[i].flags |= IEEE80211_RATECTL_DS_FLAG; + else if (HT_RC_2_STREAMS(rate) == 3) + rc[i].flags |= IEEE80211_RATECTL_TS_FLAG; + } + + /* + * Calculate the maximum TX power cap for the current + * node. + * Rate control algo can't control TX power by now. + */ + rc[i].tx_power_cap = ieee80211_get_node_txpower(ni); + } +} From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 02:21:13 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 32EE311A for ; Mon, 22 Jul 2013 02:21:13 +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 242A41D0F for ; Mon, 22 Jul 2013 02:21: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 r6M2LDbc047152 for ; Mon, 22 Jul 2013 02:21:13 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M2LDGv047141 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 02:21:13 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 22 Jul 2013 02:21:13 GMT Message-Id: <201307220221.r6M2LDGv047141@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: r255024 - 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, 22 Jul 2013 02:21:13 -0000 Author: ccqin Date: Mon Jul 22 02:21:12 2013 New Revision: 255024 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255024 Log: Add my copyright tag. Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Jul 22 02:11:33 2013 (r255023) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Mon Jul 22 02:21:12 2013 (r255024) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 Rui Paulo + * Copyright (c) 2013 Chenchong Qin * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 07:52:34 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]) by hub.freebsd.org (Postfix) with ESMTP id 5814CF24 for ; Mon, 22 Jul 2013 07:52:34 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 48AE42786 for ; Mon, 22 Jul 2013 07:52:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6M7qYPp020078 for ; Mon, 22 Jul 2013 07:52:34 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M7qYd7020072 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 07:52:34 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 22 Jul 2013 07:52:34 GMT Message-Id: <201307220752.r6M7qYd7020072@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255028 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jul 2013 07:52:34 -0000 Author: bguan Date: Mon Jul 22 07:52:33 2013 New Revision: 255028 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255028 Log: debug method device_add_child() in usbfront Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Mon Jul 22 05:45:54 2013 (r255027) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Mon Jul 22 07:52:33 2013 (r255028) @@ -81,12 +81,7 @@ #include "xenbus_if.h" -#ifdef DEBUG -#define DPRINTK(fmt, args...) \ - printf("[XEN] %s: " fmt, __func__, ##args) -#else -#define DPRINTK(fmt, args...) -#endif + static int usbfront_probe(device_t dev); static int usbfront_attach(device_t dev); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 07:52:47 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]) by hub.freebsd.org (Postfix) with ESMTP id 85A95F3E for ; Mon, 22 Jul 2013 07:52:47 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 74748278B for ; Mon, 22 Jul 2013 07:52:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6M7qlX7022725 for ; Mon, 22 Jul 2013 07:52:47 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M7qlpK022719 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 07:52:47 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 22 Jul 2013 07:52:47 GMT Message-Id: <201307220752.r6M7qlpK022719@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255029 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jul 2013 07:52:47 -0000 Author: bguan Date: Mon Jul 22 07:52:47 2013 New Revision: 255029 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255029 Log: move usb_bus_methods to .c file Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Mon Jul 22 07:52:33 2013 (r255028) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.h Mon Jul 22 07:52:47 2013 (r255029) @@ -29,6 +29,10 @@ #ifndef _USBFRONT_H_ #define _USBFRONT_H_ +#include +#include +#include + #define XENHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) /* USB ports. This is arbitrary. @@ -38,6 +42,13 @@ */ #define USB_MAXCHILDREN 31 +#ifdef DEBUG +#define DPRINTK(fmt, args...) \ + printf("[XEN] %s: " fmt, __func__, ##args) +#else +#define DPRINTK(fmt, args...) +#endif + #define USB_URB_RING_SIZE __RING_SIZE((usbif_urb_sring_t *)0, PAGE_SIZE) LIST_HEAD(list_head, list_head); @@ -109,6 +120,7 @@ unsigned int waiting_resp;// }; + /* prototypes */ usb_error_t xenhci_init(struct xenhci_softc *, device_t); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 07:53: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]) by hub.freebsd.org (Postfix) with ESMTP id 88A25F51 for ; Mon, 22 Jul 2013 07:53:00 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5FE1C278E for ; Mon, 22 Jul 2013 07:53: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 r6M7r0Ol025371 for ; Mon, 22 Jul 2013 07:53:00 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M7r0j8025365 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 07:53:00 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 22 Jul 2013 07:53:00 GMT Message-Id: <201307220753.r6M7r0j8025365@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255030 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jul 2013 07:53:00 -0000 Author: bguan Date: Mon Jul 22 07:53:00 2013 New Revision: 255030 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255030 Log: move usb_bus_methods to .c file Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Jul 22 07:52:47 2013 (r255029) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Jul 22 07:53:00 2013 (r255030) @@ -26,15 +26,6 @@ * SUCH DAMAGE. */ -/* - * USB eXtensible Host Controller Interface, a.k.a. USB 3.0 controller. - * - * The XHCI 1.0 spec can be found at - * http://www.intel.com/technology/usb/download/xHCI_Specification_for_USB.pdf - * and the USB 3.0 spec at - * http://www.usb.org/developers/docs/usb_30_spec_060910.zip - */ - #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else @@ -60,7 +51,7 @@ #include #include -#define USB_DEBUG_VAR xhcidebug +//#define USB_DEBUG_VAR xhcidebug #include #include @@ -79,15 +70,6 @@ extern struct usb_bus_methods xenhci_bus_methods; - -static void -xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) -{ - - printf("[gbtest-xenhci.c]xenhci_iterate_hw_softc()\n"); - //TODO -} - usb_error_t xenhci_init(struct xenhci_softc *sc, device_t dev) { @@ -112,6 +94,23 @@ //TODO } +static void +xenhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power_sleep()\n"); + //TODO +} + +static usb_error_t +xenhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address) +{ + printf("[gbtest-pv]xenhci.c: xenhci_set_address()\n"); + //usb_error_t err; + + //return (err); + //TODO + return (0); +} /*------------------------------------------------------------------------* * xenhci root HUB support *------------------------------------------------------------------------* @@ -216,7 +215,8 @@ xenhci_set_hw_power(struct usb_bus *bus) { printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power()\n"); - DPRINTF("\n"); + //DPRINTF("\n"); + //TODO?? } static void From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 07:53: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]) by hub.freebsd.org (Postfix) with ESMTP id 7FD7BF62 for ; Mon, 22 Jul 2013 07:53:13 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 717C32790 for ; Mon, 22 Jul 2013 07:53: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 r6M7rDMc028059 for ; Mon, 22 Jul 2013 07:53:13 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6M7rDIV028053 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 07:53:13 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 22 Jul 2013 07:53:13 GMT Message-Id: <201307220753.r6M7rDIV028053@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255031 - soc2013/bguan/head/sys/conf 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, 22 Jul 2013 07:53:13 -0000 Author: bguan Date: Mon Jul 22 07:53:13 2013 New Revision: 255031 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255031 Log: add usbfront code files into the conf file Modified: soc2013/bguan/head/sys/conf/files Modified: soc2013/bguan/head/sys/conf/files ============================================================================== --- soc2013/bguan/head/sys/conf/files Mon Jul 22 07:53:00 2013 (r255030) +++ soc2013/bguan/head/sys/conf/files Mon Jul 22 07:53:13 2013 (r255031) @@ -2478,6 +2478,8 @@ dev/xen/control/control.c optional xen | xenhvm dev/xen/netback/netback.c optional xen | xenhvm dev/xen/netfront/netfront.c optional xen | xenhvm +dev/xen/usbfront/usbfront.c optional xen | xenhvm +dev/xen/usbfront/xenhci.c optional xen | xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/xenpci/evtchn.c optional xenpci dev/xl/if_xl.c optional xl pci From owner-svn-soc-all@FreeBSD.ORG Mon Jul 22 16:33:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 013609A9 for ; Mon, 22 Jul 2013 16:33:43 +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 E5B1627DD for ; Mon, 22 Jul 2013 16:33:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6MGXhhk043955 for ; Mon, 22 Jul 2013 16:33:43 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6MGXhan043952 for svn-soc-all@FreeBSD.org; Mon, 22 Jul 2013 16:33:43 GMT (envelope-from def@FreeBSD.org) Date: Mon, 22 Jul 2013 16:33:43 GMT Message-Id: <201307221633.r6MGXhan043952@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: r255039 - soc2013/def/crashdump-head/sbin/savecore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jul 2013 16:33:44 -0000 Author: def Date: Mon Jul 22 16:33:43 2013 New Revision: 255039 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255039 Log: Decrypt a crash dump with savecore using xts.h. Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile soc2013/def/crashdump-head/sbin/savecore/savecore.c Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/Makefile Mon Jul 22 15:02:55 2013 (r255038) +++ soc2013/def/crashdump-head/sbin/savecore/Makefile Mon Jul 22 16:33:43 2013 (r255039) @@ -1,8 +1,17 @@ # $FreeBSD$ +SYS= ${.CURDIR}/../../sys +.PATH: ${SYS}/crypto/camellia ${SYS}/crypto/rijndael ${SYS}/crypto + PROG= savecore +SRCS= ${PROG}.c +SRCS+= rijndael-api.c rijndael-api-fst.c rijndael-alg-fst.c +SRCS+= camellia.c +SRCS+= xts.c DPADD= ${LIBZ} LDADD= -lz +CFLAGS+=-I${SYS} +WARNS?= 2 MAN= savecore.8 .include Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Jul 22 15:02:55 2013 (r255038) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Mon Jul 22 16:33:43 2013 (r255039) @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -291,16 +292,22 @@ static int DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device, - const char *filename, FILE *fp) + const char *filename, FILE *fp, FILE *fp_enc, struct kerneldumpheader *kdh, + off_t offset) { int he, hs, nr, nw, wl; off_t dmpcnt, origsize; + rijndael_ctx tweak_ctx, data_ctx; + + rijndael_set_key(&tweak_ctx, kdh->key, kdh->keysize << 3); + rijndael_set_key(&data_ctx, kdh->key, kdh->keysize << 3); dmpcnt = 0; origsize = dumpsize; he = 0; while (dumpsize > 0) { - wl = BUFFERSIZE; + // wl = BUFFERSIZE; + wl = 512; if (wl > dumpsize) wl = dumpsize; nr = read(fd, buf, wl); @@ -345,10 +352,18 @@ * If hs > nw, buf[nw..hs] contains non-zero data. * If he > hs, buf[hs..he] is all zeroes. */ - if (hs > nw) + if (hs > nw) { + if (fwrite(buf + nw, hs - nw, 1, fp_enc) + != 1) + break; + xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&tweak_ctx, (struct xts_ctx *)&data_ctx, + offset, kdh->tweak, hs - nw, + buf + nw, buf + nw); + offset += hs - nw; if (fwrite(buf + nw, hs - nw, 1, fp) != 1) break; + } if (he > hs) if (fseeko(fp, he - hs, SEEK_CUR) == -1) break; @@ -432,11 +447,12 @@ static void DoFile(const char *savedir, const char *device) { - static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX]; + static char infoname[PATH_MAX], corename[PATH_MAX], + corename_enc[PATH_MAX], linkname[PATH_MAX]; static char *buf = NULL; struct kerneldumpheader kdhf, kdhl; off_t mediasize, dumpsize, firsthd, lasthd; - FILE *info, *fp; + FILE *info, *fp, *fp_enc; mode_t oumask; int fd, fdinfo, error; int bounds, status; @@ -632,9 +648,12 @@ } else { snprintf(corename, sizeof(corename), "%s.%d", istextdump ? "textdump.tar" : "vmcore", bounds); + snprintf(corename_enc, sizeof(corename_enc), "%s_encrypted.%d", + istextdump ? "textdump.tar" : "vmcore", bounds); fp = fopen(corename, "w"); + fp_enc = fopen(corename_enc, "w"); } - if (fp == NULL) { + if (fp == NULL || fp_enc == NULL) { syslog(LOG_ERR, "%s: %m", corename); close(fdinfo); nerr++; @@ -664,7 +683,8 @@ corename, fp) < 0) goto closeall; } else { - if (DoRegularFile(fd, dumpsize, buf, device, corename, fp) + if (DoRegularFile(fd, dumpsize, buf, device, corename, + fp, fp_enc, &kdhl, firsthd + sizeof(kdhf)) < 0) goto closeall; } @@ -677,6 +697,12 @@ goto closeall; } + if (fp_enc != NULL && fclose(fp_enc) < 0) { + syslog(LOG_ERR, "error on %s: %m", corename_enc); + nerr++; + goto closeall; + } + symlinks_remove(); if (symlink(infoname, "info.last") == -1) { syslog(LOG_WARNING, "unable to create symlink %s/%s: %m", @@ -715,6 +741,7 @@ closeall: fclose(fp); + fclose(fp_enc); closefd: close(fd); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 08:56:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 255261A4 for ; Tue, 23 Jul 2013 08:56:28 +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 169C6218B for ; Tue, 23 Jul 2013 08:56:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6N8uRdM066570 for ; Tue, 23 Jul 2013 08:56:27 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6N8uRtX066559 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 08:56:27 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 23 Jul 2013 08:56:27 GMT Message-Id: <201307230856.r6N8uRtX066559@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: r255055 - 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: Tue, 23 Jul 2013 08:56:28 -0000 Author: mattbw Date: Tue Jul 23 08:56:27 2013 New Revision: 255055 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255055 Log: added assertions for pkgutils and query/jobs. Modified: soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query/jobs.c Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Tue Jul 23 05:11:22 2013 (r255054) +++ soc2013/mattbw/backend/pkgutils.c Tue Jul 23 08:56:27 2013 (r255055) @@ -37,6 +37,8 @@ { PkInfoEnum info; + assert(pkg != NULL); + /* If the package is local, then it's installed. If it is remote, then * it is installed if it is the same version as an installed package, * and available if it is not. @@ -60,6 +62,8 @@ PkInfoEnum info; const char *old; + assert(pkg != NULL); + /* Sane default */ info = PK_INFO_ENUM_INSTALLING; @@ -107,6 +111,8 @@ { char *result; + assert(pkg != NULL); + result = NULL; (void)pkg_asprintf(&result, "%n-%v", pkg, pkg); return result; @@ -120,6 +126,8 @@ { const char *repo; + assert(pkg != NULL); + switch (pkg_type(pkg)) { case PKG_OLD_FILE: case PKG_FILE: @@ -172,6 +180,9 @@ pkgutils_pkg_to_id_through(struct pkg *pkg, const char **strv) { + assert(pkg != NULL); + assert(strv != NULL); + pkg_get(pkg, PKG_NAME, strv + PK_PACKAGE_ID_NAME, PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, @@ -197,6 +208,9 @@ const char *origin; struct pkg *pkg2; + assert(db != NULL); + assert(pkg != NULL); + origin = NULL; pkg_get(pkg, PKG_ORIGIN, &origin); @@ -215,6 +229,7 @@ *old_p = pkg2; else pkg_free(pkg2); + assert (old_p == NULL || pkg2 == NULL || *old_p != NULL); } /* @@ -226,6 +241,9 @@ char *comment; gchar *id; + assert(pkg != NULL); + assert(backend != NULL); + comment = id = NULL; pkg_get(pkg, PKG_COMMENT, &comment); @@ -241,7 +259,10 @@ pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info) { - gboolean should_emit; + gboolean should_emit; + + assert(pkg != NULL); + assert(backend != NULL); should_emit = TRUE; @@ -272,6 +293,9 @@ const char *repo_name; struct pkg_repo *repo_struct; + assert(pkg != NULL); + assert(pkg_type(pkg) == PKG_REMOTE); + repo = repo_name = NULL; repo_struct = NULL; Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Tue Jul 23 05:11:22 2013 (r255054) +++ soc2013/mattbw/backend/query/jobs.c Tue Jul 23 08:56:27 2013 (r255055) @@ -42,8 +42,14 @@ bool success; PkBackend *backend; + assert(jobs != NULL); + assert(q != NULL); + success = false; + backend = query_backend(q); + assert(backend != NULL); + query_set_percentage(q, 0); pkg_event_register(event_cb, backend); @@ -74,15 +80,16 @@ struct pkg_jobs *jobs; PkBackend *backend; - assert (q != NULL); - assert (pkg != NULL); assert (f != NULL); + assert (pkg != NULL); + assert (q != NULL); success = false; jobs = NULL; namever = NULL; backend = query_backend(q); + assert(backend != NULL); if (pkg_jobs_new(&jobs, type, query_db(q)) != EPKG_OK) { ERR(backend, @@ -134,7 +141,11 @@ PkBackend *backend; struct pkg *pkg; + assert(jobs != NULL); + assert(q != NULL); + backend = query_backend(q); + assert (backend != NULL); query_set_percentage(q, 0); (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); @@ -152,6 +163,9 @@ { const char *repo; + assert(jobs != NULL); + assert(q != NULL); + repo = query_repo(q); return (repo == NULL ? EPKG_OK : pkg_jobs_set_repository(jobs, repo)); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 09:10:45 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]) by hub.freebsd.org (Postfix) with ESMTP id 03B084D3 for ; Tue, 23 Jul 2013 09:10: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 E87CE2207 for ; Tue, 23 Jul 2013 09:10: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 r6N9Ai84001198 for ; Tue, 23 Jul 2013 09:10:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6N9Aim8001135 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 09:10:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 23 Jul 2013 09:10:44 GMT Message-Id: <201307230910.r6N9Aim8001135@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: r255056 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jul 2013 09:10:45 -0000 Author: mattbw Date: Tue Jul 23 09:10:44 2013 New Revision: 255056 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255056 Log: more null assertions; use 'search' instead of 'values' in searching actions so we don't need to store the search in the backend twice. Modified: soc2013/mattbw/backend/actions/search_files.c soc2013/mattbw/backend/actions/search_groups.c soc2013/mattbw/backend/actions/search_names.c soc2013/mattbw/backend/event.c soc2013/mattbw/backend/group.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/search.c Modified: soc2013/mattbw/backend/actions/search_files.c ============================================================================== --- soc2013/mattbw/backend/actions/search_files.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/actions/search_files.c Tue Jul 23 09:10:44 2013 (r255056) @@ -74,6 +74,8 @@ if (it != NULL) { while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { + assert(pkg != NULL); + pkgutils_emit(pkg, backend, pkgutils_pkg_current_state(pkg)); at_least_one = true; Modified: soc2013/mattbw/backend/actions/search_groups.c ============================================================================== --- soc2013/mattbw/backend/actions/search_groups.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/actions/search_groups.c Tue Jul 23 09:10:44 2013 (r255056) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include "../pk-backend.h" #include "pkg.h" @@ -41,6 +42,8 @@ gchar **values; struct search search; + assert(backend != NULL); + search.db = NULL; groupv = NULL; it = NULL; @@ -55,7 +58,12 @@ if (search.db == NULL) goto cleanup; - values = pk_backend_get_strv(backend, "values"); + values = pk_backend_get_strv(backend, "search"); + if (values == NULL) { + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "search was NULL"); + goto cleanup; + } + groupc = g_strv_length(values); if (groupc == 0) { ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no values"); Modified: soc2013/mattbw/backend/actions/search_names.c ============================================================================== --- soc2013/mattbw/backend/actions/search_names.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/actions/search_names.c Tue Jul 23 09:10:44 2013 (r255056) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include "../pk-backend.h" #include "pkg.h" @@ -35,6 +36,8 @@ gboolean success; struct search search; + assert(backend != NULL); + success = FALSE; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); (void)pk_backend_set_percentage(backend, 0); @@ -54,7 +57,8 @@ guint len; gchar **values; - values = pk_backend_get_strv(backend, "values"); + values = pk_backend_get_strv(backend, "search"); + assert(values != NULL); len = g_strv_length(values); success = TRUE; Modified: soc2013/mattbw/backend/event.c ============================================================================== --- soc2013/mattbw/backend/event.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/event.c Tue Jul 23 09:10:44 2013 (r255056) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include "pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg... */ @@ -34,6 +35,9 @@ { PkBackend *backend; + assert(backend_v != NULL); + assert(event != NULL); + backend = (PkBackend *)backend_v; switch (event->type) { Modified: soc2013/mattbw/backend/group.c ============================================================================== --- soc2013/mattbw/backend/group.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/group.c Tue Jul 23 09:10:44 2013 (r255056) @@ -125,6 +125,8 @@ char *regex; struct sbuf *sb; + assert(groupv != NULL); + regex = NULL; sb = sbuf_new_auto(); if (sb != NULL) { @@ -171,6 +173,10 @@ static int map_compare(const void *key, const void *mapping) { + + assert(key != NULL); + assert(mapping != NULL); + return strcmp((const char *)key, ((const struct group_mapping *)mapping)->key); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 23 09:10:44 2013 (r255056) @@ -211,20 +211,20 @@ } void -pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values) +pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **search) { INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ - (void)pk_backend_set_strv(backend, "values", values); + INTENTIONALLY_IGNORE(search); /* retrieved from backend */ THREAD(backend, search_groups_thread); } void -pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) +pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **search) { INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ - (void)pk_backend_set_strv(backend, "values", values); + INTENTIONALLY_IGNORE(search); /* retrieved from backend */ THREAD(backend, search_names_thread); } Modified: soc2013/mattbw/backend/search.c ============================================================================== --- soc2013/mattbw/backend/search.c Tue Jul 23 08:56:27 2013 (r255055) +++ soc2013/mattbw/backend/search.c Tue Jul 23 09:10:44 2013 (r255056) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include /* bool */ #include "pkg.h" /* pkg_... */ @@ -34,6 +35,8 @@ bool success; struct pkgdb_it *it; + assert(search != NULL); + success = false; it = pkgdb_search(search->db, search->term, @@ -47,6 +50,8 @@ pkg = NULL; while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { + assert(pkg != NULL); + pkgutils_add_old_version(search->db, pkg, NULL); pkgutils_emit_filtered(pkg, search->backend, From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 14:26: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]) by hub.freebsd.org (Postfix) with ESMTP id 6B35597C for ; Tue, 23 Jul 2013 14:26:14 +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 5B37E216F for ; Tue, 23 Jul 2013 14:26: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 r6NEQEOj059882 for ; Tue, 23 Jul 2013 14:26:14 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6NEQDdm059876 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 14:26:13 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 23 Jul 2013 14:26:13 GMT Message-Id: <201307231426.r6NEQDdm059876@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: r255064 - soc2013/dpl/head/lib/libz 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, 23 Jul 2013 14:26:14 -0000 Author: dpl Date: Tue Jul 23 14:26:13 2013 New Revision: 255064 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255064 Log: Compartmentalize crc32. Modified: soc2013/dpl/head/lib/libz/Makefile soc2013/dpl/head/lib/libz/crc32.c soc2013/dpl/head/lib/libz/gzlib.c soc2013/dpl/head/lib/libz/zconf.h soc2013/dpl/head/lib/libz/zutil.h Modified: soc2013/dpl/head/lib/libz/Makefile ============================================================================== --- soc2013/dpl/head/lib/libz/Makefile Tue Jul 23 13:56:38 2013 (r255063) +++ soc2013/dpl/head/lib/libz/Makefile Tue Jul 23 14:26:13 2013 (r255064) @@ -2,6 +2,9 @@ # $FreeBSD: head/lib/libz/Makefile 232263 2012-02-28 18:30:18Z dim $ # +#TODEL +CFLAGS+= -Wall -g -fno-color-diagnostics + LIB= z SHLIBDIR?= /lib SHLIB_MAJOR= 6 @@ -13,8 +16,6 @@ # -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -DHAS_snprintf -DHAS_vsnprintf -I${.CURDIR} -#TODEL -CFLAGS+= -Wall -g -fno-color-output WARNS?= 3 CLEANFILES+= example.o example foo.gz minigzip.o minigzip Modified: soc2013/dpl/head/lib/libz/crc32.c ============================================================================== --- soc2013/dpl/head/lib/libz/crc32.c Tue Jul 23 13:56:38 2013 (r255063) +++ soc2013/dpl/head/lib/libz/crc32.c Tue Jul 23 14:26:13 2013 (r255064) @@ -37,6 +37,8 @@ # define BYFOUR #endif #ifdef BYFOUR + unsigned long crc32_ OF((unsigned long, + const unsigned char FAR *, uInt)); local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -206,6 +208,27 @@ const unsigned char FAR *buf; uInt len; { + long ret; + #ifdef CAPSICUM + int forkpid; + if ( (forkpid = fork()) == 0 ){ + cap_enter(); + #endif + ret = crc32_(crc, buf, len); + #ifdef CAPSICUM + return ret; + } else if ( forkpid != 0) { + wait(NULL); + } + #endif + return ret; +} + +unsigned long ZEXPORT crc32_(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + uInt len; +{ if (buf == Z_NULL) return 0UL; #ifdef DYNAMIC_CRC_TABLE Modified: soc2013/dpl/head/lib/libz/gzlib.c ============================================================================== --- soc2013/dpl/head/lib/libz/gzlib.c Tue Jul 23 13:56:38 2013 (r255063) +++ soc2013/dpl/head/lib/libz/gzlib.c Tue Jul 23 14:26:13 2013 (r255064) @@ -18,14 +18,6 @@ #endif #endif -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# endif -#endif - /* Local functions */ local void gz_reset OF((gz_statep)); local gzFile gz_open OF((const void *, int, const char *)); Modified: soc2013/dpl/head/lib/libz/zconf.h ============================================================================== --- soc2013/dpl/head/lib/libz/zconf.h Tue Jul 23 13:56:38 2013 (r255063) +++ soc2013/dpl/head/lib/libz/zconf.h Tue Jul 23 14:26:13 2013 (r255064) @@ -480,11 +480,25 @@ /* * This is hard-configured for FreeBSD. */ -#define z_off_t off_t +#define z_off_t off_t #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif +/* + * With Capsicum, we get a compartmentalized, and securer lib. + */ +#if defined(__FreeBSD__) +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# include +# include +# include +# endif +#endif + #ifndef z_off_t # define z_off_t long #endif Modified: soc2013/dpl/head/lib/libz/zutil.h ============================================================================== --- soc2013/dpl/head/lib/libz/zutil.h Tue Jul 23 13:56:38 2013 (r255063) +++ soc2013/dpl/head/lib/libz/zutil.h Tue Jul 23 14:26:13 2013 (r255064) @@ -4,8 +4,8 @@ */ /* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ @@ -14,35 +14,35 @@ #define ZUTIL_H #ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else -# define ZLIB_INTERNAL +# define ZLIB_INTERNAL #endif #include "zlib.h" #if defined(STDC) && !defined(Z_SOLO) -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include #endif #ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ #endif #ifndef local -# define local static +# define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ -typedef unsigned char uch; +typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; -typedef unsigned long ulg; +typedef unsigned long ulg; extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ @@ -50,204 +50,218 @@ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ - return (strm->msg = ERR_MSG(err), (err)) + return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ - /* common constants */ + /* common constants */ #ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS +# define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 +# define DEF_MEM_LEVEL 8 #else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 -#define DYN_TREES 2 +#define DYN_TREES 2 /* The three kinds of block type */ -#define MIN_MATCH 3 -#define MAX_MATCH 258 +#define MIN_MATCH 3 +#define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - /* target dependencies */ + /* target dependencies */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# ifndef Z_SOLO -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include +# define OS_CODE 0x00 +# ifndef Z_SOLO +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif # endif -# endif #endif #ifdef AMIGA -# define OS_CODE 0x01 +# define OS_CODE 0x01 #endif #if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 +# define OS_CODE 0x05 #endif #ifdef OS2 -# define OS_CODE 0x06 -# if defined(M_I86) && !defined(Z_SOLO) -# include -# endif +# define OS_CODE 0x06 +# if defined(M_I86) && !defined(Z_SOLO) +# include +# endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif +# define OS_CODE 0x07 +# ifndef Z_SOLO +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif # endif -# endif #endif #ifdef TOPS20 -# define OS_CODE 0x0a +# define OS_CODE 0x0a #endif #ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif #endif #ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f +# define OS_CODE 0x0f #endif #if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ +# define fdopen(fd,mode) NULL /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif #endif #if defined(__BORLANDC__) && !defined(MSDOS) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* + * With Capsicum, we get a compartmentalized, and securer lib. + */ +#if defined(__FreeBSD__) +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# include +# include +# include +# endif #endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ - (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); + (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); #endif - /* common defaults */ + /* common defaults */ #ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ +# define OS_CODE 0x03 /* assume Unix */ #endif #ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) +# define F_OPEN(name, mode) fopen((name), (mode)) #endif - /* functions */ + /* functions */ #if defined(pyr) || defined(Z_SOLO) -# define NO_MEMCPY +# define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY +# define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif #else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) #endif #ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); + void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); #endif #define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} /* Reverse the bytes in a 32-bit value */ #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) #endif /* ZUTIL_H */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 17:36:27 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7C238D58 for ; Tue, 23 Jul 2013 17:36:27 +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 6A9EE2B5A for ; Tue, 23 Jul 2013 17:36:27 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6NHaRqt030643 for ; Tue, 23 Jul 2013 17:36:27 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6NHaRLS030636 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 17:36:27 GMT (envelope-from oleksandr@FreeBSD.org) Date: Tue, 23 Jul 2013 17:36:27 GMT Message-Id: <201307231736.r6NHaRLS030636@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: r255075 - 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: Tue, 23 Jul 2013 17:36:27 -0000 Author: oleksandr Date: Tue Jul 23 17:36:27 2013 New Revision: 255075 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255075 Log: Add vboxvfs_proc functionality from Solaris port of virtualbox guest additions Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Deleted: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Tue Jul 23 17:36:27 2013 (r255075) @@ -0,0 +1,2584 @@ +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) +@@ -14,8 +14,7 @@ + * 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" ++#if 0 + #include + #include + #include +@@ -33,7 +32,28 @@ + + #include + #include ++#endif ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + ++#include ++ ++#include "vboxvfs.h" ++ + /* + * Prototypes for VBOXVFS vnode operations + */ +@@ -56,6 +76,7 @@ + static vop_symlink_t vboxvfs_symlink; + static vop_readdir_t vboxvfs_readdir; + static vop_strategy_t vboxvfs_strategy; ++static vop_bmap_t vboxvfs_bmap; + static vop_print_t vboxvfs_print; + static vop_pathconf_t vboxvfs_pathconf; + static vop_advlock_t vboxvfs_advlock; +@@ -65,177 +86,633 @@ + static vop_inactive_t vboxvfs_inactive; + static vop_putpages_t vboxvfs_putpages; + static vop_reclaim_t vboxvfs_reclaim; ++static vop_vptofh_t vboxvfs_vptofh; + + struct vop_vector vboxvfs_vnodeops = { +- .vop_default = &default_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, ++ .vop_access = vboxvfs_access, ++ .vop_bmap = vboxvfs_bmap, ++ .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_vptofh = vboxvfs_vptofh, ++ .vop_symlink = vboxvfs_symlink, ++ .vop_write = vboxvfs_write, + }; + + static int vboxvfs_access(struct vop_access_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp; ++ accmode_t accmode; ++ ++ vp = ap->a_vp; ++ accmode = ap->a_accmode; ++ ++ if (accmode & VWRITE) { ++ switch (vp->v_type) { ++ case VDIR: ++ case VLNK: ++ case VREG: ++ return (EROFS); ++ /* NOT REACHED */ ++ default: ++ break; ++ } ++ } ++ ++ return (vaccess(vp->v_type, 0444, 0, 0, ++ accmode, ap->a_cred, NULL)); ++#endif ++ return (0); + } + + static int vboxvfs_open(struct vop_open_args *ap) + { +- return 0; ++#if 0 ++ struct vboxvfs_node *np = VTON(ap->a_vp); ++ off_t fsize; ++ ++ fsize = np->vboxvfsmp->size; ++ vnode_create_vobject(ap->a_vp, fsize, ap->a_td); ++#endif ++ return (0); + } + + static int vboxvfs_close(struct vop_close_args *ap) + { +- return 0; ++#if 0 ++ int rc; ++ ++ rc = vboxCallClose(&vbox_client, &fp->map, fp->handle); ++ kmem_free(fp, sizeof(sfp_file_t)); ++#endif ++ return (0); + } + + static int vboxvfs_getattr(struct vop_getattr_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp; ++ struct vboxvfs_node *node; ++ struct vattr *vap; ++ struct timespec ts; ++ ++ ts.tv_sec = 0; ++ ++ vp = ap->a_vp; ++ vap = ap->a_vap; ++ node = VTON(vp); ++ ++ vap->va_fsid = dev2udev(nodevgmp->im_dev); ++ vap->va_fileid = node->hash_id; ++ vap->va_uid = 0; ++ vap->va_gid = 0; ++ vap->va_atime.tv_sec = VNOVAL; ++ vap->va_atime.tv_nsec = VNOVAL; ++ vap->va_mtime.tv_sec = VNOVAL; ++ vap->va_mtime.tv_nsec = VNOVAL; ++ vap->va_ctime.tv_sec = VNOVAL; ++ vap->va_ctime.tv_nsec = VNOVAL; ++ vap->va_rdev = NODEV; ++ if (vp->v_type & VDIR) { ++ vap->va_size = 40; /*XXX*/ ++ vap->va_nlink = 2; ++ vap->va_mode = 0555; ++ } else { ++ vap->va_size = node->vboxvfsmp->size; ++ vap->va_nlink = 1; ++ vap->va_mode = 0444; ++ } ++ vap->va_flags = 0; ++ vap->va_gen = 1; ++ vap->va_blocksize = node->vboxvfsmp->bsize; ++ vap->va_bytes = vap->va_size; ++ vap->va_type = vp->v_type; ++ vap->va_filerev = 0; ++#endif ++ return (0); + } + + static int vboxvfs_setattr(struct vop_setattr_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp; ++ struct vattr *vap; ++ ++ vp = ap->a_vp; ++ vap = ap->a_vap; ++ if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || ++ vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || ++ vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) ++ return (EROFS); ++ if (vap->va_size != (u_quad_t)VNOVAL) { ++ switch (vp->v_type) { ++ case VDIR: ++ return (EISDIR); ++ case VLNK: ++ case VREG: ++ return (EROFS); ++ case VCHR: ++ case VBLK: ++ case VSOCK: ++ case VFIFO: ++ case VNON: ++ case VBAD: ++ case VMARKER: ++ return (0); ++ } ++ } ++#endif ++ return (0); + } + + static int vboxvfs_read(struct vop_read_args *ap) + { +- return 0; ++#if 0 ++ static const int clustersize = MAXBSIZE; ++ ++ struct vnode *vp = ap->a_vp; ++ struct uio *uio = ap->a_uio; ++ struct vboxvfs_node *node = VTON(vp); ++ struct vboxvfs_mnt *vboxvfsmp; ++ struct buf *bp; ++ daddr_t lbn; ++ off_t diff, fsize; ++ int error = 0; ++ long size, n, on; ++ ++ if (uio->uio_resid == 0) ++ return (0); ++ if (uio->uio_offset < 0) ++ return (EINVAL); ++ ++ if (vp->v_type == VCHR || vp->v_type == VBLK) ++ return (EOPNOTSUPP); ++ if (vp->v_type != VREG) ++ return (EINVAL); ++ ++ vboxvfsmp = node->vboxvfsmp; ++ fsize = vboxvfsmp->size; ++ ++ do { ++ lbn = lblkno(vboxvfsmp, uio->uio_offset); ++ on = blkoff(vboxvfsmp, uio->uio_offset); ++ n = min((u_int)(clustersize - on), uio->uio_resid); ++ diff = fsize - uio->uio_offset; ++ if (diff <= 0) ++ return (0); ++ if (diff < n) ++ n = diff; ++ ++ size = (n + vboxvfsmp->bmask) & ~vboxvfsmp->bmask; ++ if (vboxvfsmp->use_devvp) ++ error = bread(vboxvfsmp->im_devvp, ++ lbn << (vboxvfsmp->bshift - DEV_BSHIFT), ++ size, NOCRED, &bp); ++ else ++ error = bread(vp, lbn, size, NOCRED, &bp); ++ ++ n = min(n, size - bp->b_resid); ++ if (error) { ++ brelse(bp); ++ return (error); ++ } ++ error = uiomove(bp->b_data + on, (int)n, uio); ++ brelse(bp); ++ } while (error == 0 && uio->uio_resid > 0 && n != 0); ++ return (error); ++#endif ++ return (0); + } + + static int vboxvfs_write(struct vop_write_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_create(struct vop_create_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_remove(struct vop_remove_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_rename(struct vop_rename_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_link(struct vop_link_args *ap) + { +- return EOPNOTSUPP; ++ return (EOPNOTSUPP); + } + + static int vboxvfs_symlink(struct vop_symlink_args *ap) + { +- return EOPNOTSUPP; ++ return (EOPNOTSUPP); + } + + static int vboxvfs_mknod(struct vop_mknod_args *ap) + { +- return EOPNOTSUPP; ++ return (EOPNOTSUPP); + } + + static int vboxvfs_mkdir(struct vop_mkdir_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_rmdir(struct vop_rmdir_args *ap) + { +- return 0; ++ return (0); + } ++#if 0 ++struct vboxvfs_uiodir { ++ struct dirent *dirent; ++ u_long *cookies; ++ int ncookies; ++ int acookies; ++ int eofflag; ++}; + ++static int ++vboxvfs_uiodir(struct vboxvfs_uiodir *uiodir, int de_size, struct uio *uio, long cookie) ++{ ++ if (uiodir->cookies != NULL) { ++ if (++uiodir->acookies > uiodir->ncookies) { ++ uiodir->eofflag = 0; ++ return (-1); ++ } ++ *uiodir->cookies++ = cookie; ++ } ++ ++ if (uio->uio_resid < de_size) { ++ uiodir->eofflag = 0; ++ return (-1); ++ } ++ ++ return (uiomove(uiodir->dirent, de_size, uio)); ++} ++#endif + static int vboxvfs_readdir(struct vop_readdir_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp; ++ struct uio *uio; ++ struct dirent dir; ++ struct vboxvfs_node *node; ++ struct vboxvfs_mnt *vboxvfsmp; ++ struct vboxvfs_uiodir uiodir; ++ u_long *cookies = NULL; ++ int ncookies; ++ int error = 0; ++ ++ vp = ap->a_vp; ++ uio = ap->a_uio; ++ node = VTON(vp); ++ vboxvfsmp = node->vboxvfsmp; ++ uiodir.eofflag = 1; ++ ++ if (a->a_ncookies != NULL) { ++ /* ++ * Guess how many entries are needed. If we run out, this ++ * function will be called again and thing will pick up were ++ * it left off. ++ */ ++ ncookies = uio->uio_resid / 8; ++ cookies = malloc(sizeof(u_long) * ncookies, ++ M_TEMP, M_WAITOK); ++ if (cookies == NULL) ++ return (ENOMEM); ++ uiodir.ncookies = ncookies; ++ uiodir.cookies = cookies; ++ uiodir.acookies = 0; ++ } else { ++ uiodir.cookies = NULL; ++ } ++ ++ /* Do up the '.' and '..' entries. Dummy values are ++ * used for the cookies since the offset here is ++ * usually zero, and NFS doesn't like that value ++ */ ++ if (uio->uio_offset == 0) { ++ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ ++ dir.d_type = DT_DIR; ++ dir.d_name[0] = '.'; ++ dir.d_name[1] = '\0'; ++ dir.d_namlen = 1; ++ dir.d_reclen = GENERIC_DIRSIZ(&dir); ++ uiodir.dirent = &dir; ++ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 1); ++ if (error) ++ goto finished; ++ ++ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ ++ dir.d_type = DT_DIR; ++ dir.d_name[0] = '.'; ++ dir.d_name[1] = '.'; ++ dir.d_name[2] = '\0'; ++ dir.d_namlen = 2; ++ dir.d_reclen = GENERIC_DIRSIZ(&dir); ++ uiodir.dirent = &dir; ++ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 2); ++ if (error) ++ goto finished; ++ ++ strcpy(&dir.d_name[0], AVG_THEFILE_NAME); ++ dir.d_namlen = strlen(AVG_THEFILE_NAME); ++ dir.d_fileno = AVG_THEFILE_INO; ++ dir.d_type = DT_REG; ++ dir.d_reclen = GENERIC_DIRSIZ(&dir); ++ uiodir.dirent = &dir; ++ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 3); ++ if (error) ++ goto finished; ++ } ++ ++finished: ++ ++ /* tell the calling layer whether we need to be called again */ ++ *ap->a_eofflag = uiodir.eofflag; ++ ++ if (error < 0) ++ error = 0; ++ ++ if (ap-g>a_ncookies != NULL) { ++ if (error) ++ free(cookies, M_TEMP); ++ else { ++ *ap->a_ncookies = uiodir.acookies; ++ *ap->a_cookies = cookies; ++ } ++ } ++ ++ return (error); ++#endif ++ return (0); + } + + static int vboxvfs_fsync(struct vop_fsync_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_print (struct vop_print_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp = ap->a_vp; ++ struct vboxvfs_node *node; ++ ++ node = VTON(vp); ++ printf(" ino %lu, on dev %s", (u_long)node->hash_id, ++ devtoname(node->vboxvfsmp->im_dev)); ++ printf("\n"); ++#endif ++ return (0); + } + + static int vboxvfs_pathconf (struct vop_pathconf_args *ap) + { +- return 0; ++#if 0 ++ switch (ap->a_name) { ++ case _PC_LINK_MAX: ++ *ap->a_retval = 65535; ++ return (0); ++ case _PC_NAME_MAX: ++ i *ap->a_retval = NAME_MAX; ++ return (0); ++ case _PC_PATH_MAX: ++ *ap->a_retval = PATH_MAX; ++ return (0); ++ case _PC_NO_TRUNC: ++ *ap->a_retval = 1; ++ return (0); ++ default: ++ return (EINVAL); ++ } ++#endif ++ return (0); + } + + static int vboxvfs_strategy (struct vop_strategy_args *ap) + { +- return 0; ++#if 0 ++ struct buf *bp; ++ struct vnode *vp; ++ struct vboxvfs_node *node; ++ struct bufobj *bo; ++ ++ bp = ap->a_bp; ++ vp = ap->a_vp; ++ node = VTON(vp); ++ ++ if (bp->b_blkno == bp->b_lblkno) { ++ bp->b_blkno = bp->b_lblkno << (node->vboxvfsmp->bshift - DEV_BSHIFT); ++ } ++ bo = node->vboxfsmp->im_bo; ++ bp->b_iooffset = dbtob(bp->b_blkno); ++ BO_STRATEGY(bo, bp); ++#endif ++ return (0); + } + ++static int ++vboxvfs_bmap(struct vop_bmap_args *ap) ++{ ++#if 0 ++ struct vboxvfs_node *node; ++ ++ node = VTON(ap->a_vp); ++ ++ if (ap->a_bop != NULL) ++ *ap->a_bop = &node->vboxvfsmp->im_devvp->v_bufobj; ++ if (ap->a_bnp == NULL) ++ return (0); ++ if (ap->a_runb) ++ *ap->a_runb = 0; ++ ++ /* Translate logical to physical sector number */ ++ *ap->a_bnp = ap->a_bn << (node->vboxvfsmp->bshift - DEV_BSHIFT); ++ ++ if (ap->a_runp) ++ *ap->a_runp = 0; ++ if (ap->a_runb) ++ *ap->a_runb = 0; ++#endif ++ return (0); ++} ++ ++/* ++ * File specific ioctls. ++ */ + static int vboxvfs_ioctl(struct vop_ioctl_args *ap) + { +- return ENOTTY; ++ printf("%s called\n", __func__); ++ return (ENOTTY); + } + + static int vboxvfs_getextattr(struct vop_getextattr_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_advlock(struct vop_advlock_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_lookup(struct vop_lookup_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *dvp; ++ struct vnode *tdp = NULL; ++ struct vnode **vpp = ap->a_vpp; ++ struct vboxvfs_node *node; ++ struct vboxvfs_mnt *vboxvfsmp; ++ u_long nameiop; ++ u_long flags; ++ char *nameptr; ++ long namelen; ++ ino_t id = 0; ++ int offset, error = 0; ++ int lkflags, ltype; ++ ++ dvp = ap->a_dvp; ++ node = VTON(dvp); ++ vboxvfsmp = node->vboxvfsmp; ++ nameiop = ap->a_cnp->cn_nameiop; ++ flags = ap->a_cnp->cn_flags; ++ lkflags = ap->a_cnp->cn_lkflags; ++ nameptr = ap->a_cnp->cn_nameptr; ++ namelen = ap->a_cnp->cn_namelen; ++ ++ offset = 0; ++ ++ if (strcmp(nameptr, AVG_THEFILE_NAME) == 0) ++ id = AVG_THEFILE_INO; ++ else if (flags & ISDOTDOT) ++ id = AVG_ROOTDIR_INO; ++ ++ /* Did we have a match? */ ++ if (id) { ++ if (flags & ISDOTDOT) { ++ error = vn_vget_ino(dvp, id, lkflags, &tdp); ++ } else if (node->hash_id == id) { ++ VREF(dvp); /* we want ourself, ie "." */ ++ /* ++ * When we lookup "." we still can be asked to lock it ++ * differently. ++ */ ++ ltype = lkflags & LK_TYPE_MASK; ++ if (ltype != VOP_ISLOCKED(dvp)) { ++ if (ltype == LK_EXCLUSIVE) ++ vn_lock(dvp, LK_UPGRADE | LK_RETRY); ++ else /* if (ltype == LK_SHARED) */ ++ vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); ++ } ++ tdp = dvp; ++ } else ++ error = vboxvfs_vget(vboxvfsmp->im_mountp, id, lkflags, &tdp); ++ if (!error) { ++ *vpp = tdp; ++ /* Put this entry in the cache */ ++ if (flags & MAKEENTRY) ++ cache_enter(dvp, *vpp, ap->a_cnp); ++ } ++ } else { ++ /* Enter name into cache as non-existant */ ++ if (flags & MAKEENTRY) ++ cache_enter(dvp, *vpp, ap->a_cnp); ++ ++ if ((flags & ISLASTCN) && ++ (nameiop == CREATE || nameiop == RENAME)) { ++ error = EROFS; ++ } else { ++ error = ENOENT; ++ } ++ } ++ ++ return (error); ++#endif ++ return (0); + } + + static int vboxvfs_inactive(struct vop_inactive_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_reclaim(struct vop_reclaim_args *ap) + { +- return 0; ++#if 0 ++ struct vnode *vp; ++ struct vboxvfs_node *unode; ++ ++ vp = ap->a_vp; ++ unode = VTON(vp); ++ ++ /* ++ * Destroy the vm object and flush associated pages. ++ */ ++ vnode_destroy_vobject(vp); ++ ++ if (unode != NULL) { ++ vfs_hash_remove(vp); ++ free(unode, M_AVGFS); ++ vp->v_data = NULL; ++ } ++#endif ++ return (0); + } + ++static int vboxvfs_vptofh(struct vop_vptofh_args *ap) ++{ ++#if 0 ++ struct vboxvfs_node *node; ++ struct ifid *ifhp; ++ ++ node = VTON(ap->a_vp); ++ ifhp = (struct ifid *)ap->a_fhp; ++ ifhp->ifid_len = sizeof(struct ifid); ++ ifhp->ifid_ino = node->hash_id; ++#endif ++ return (0); ++} ++ + static int vboxvfs_getpages(struct vop_getpages_args *ap) + { +- return 0; ++ return (0); + } + + static int vboxvfs_putpages(struct vop_putpages_args *ap) + { +- return 0; ++ 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,24 +21,130 @@ + #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 + +-struct vboxvfs_mount_info { +- char name[MAX_HOST_NAME]; +- char nls_name[MAX_NLS_NAME]; +- int uid; +- int gid; +- int ttl; +-}; ++/** Helper macros */ ++#define VFSTOVBOXFS(mp) ((vboxvfs_mnt_t *)((mp)->mnt_data)) ++#define VTON(vp) ((vboxvfs_node *)((vp)->v_data)) + ++MALLOC_DECLARE(M_VBOXVFS); ++ + #ifdef _KERNEL ++#include "../../../../../include/iprt/nocrt/limits.h" ++#include "../../../../../include/iprt/alloc.h" ++#include "../../../../../include/iprt/asm.h" ++#include "../../../../../include/iprt/asm-amd64-x86.h" ++#include "../../../../../include/iprt/asm-math.h" ++#include "../../../../../include/iprt/assert.h" ++#include "../../../../../include/iprt/cdefs.h" ++#include "../../../../../include/iprt/err.h" ++#include "../../../../../include/iprt/fs.h" ++#include "../../../../../include/iprt/log.h" ++#include "../../../../../include/iprt/mangling.h" ++#include "../../../../../include/iprt/mem.h" ++#include "../../../../../include/iprt/param.h" ++#include "../../../../../include/iprt/path.h" ++#include "../../../../../include/iprt/semaphore.h" ++#include "../../../../../include/iprt/stdarg.h" ++#include "../../../../../include/iprt/stdint.h" ++#include "../../../../../include/iprt/string.h" ++#include "../../../../../include/iprt/time.h" ++#include "../../../../../include/iprt/types.h" ++#include "../../../../../include/iprt/uni.h" ++#include "../../common/VBoxGuestLib/SysHlp.h" ++#include "../../../../../include/iprt/nocrt/limits.h" ++#include "../../../../../include/iprt/alloc.h" ++#include "../../../../../include/iprt/asm.h" ++#include "../../../../../include/iprt/asm-amd64-x86.h" ++#include "../../../../../include/iprt/asm-math.h" ++#include "../../../../../include/iprt/assert.h" ++#include "../../../../../include/iprt/cdefs.h" ++#include "../../../../../include/iprt/err.h" ++#include "../../../../../include/iprt/fs.h" ++#include "../../../../../include/iprt/log.h" ++#include "../../../../../include/iprt/mangling.h" ++#include "../../../../../include/iprt/mem.h" ++#include "../../../../../include/iprt/param.h" ++#include "../../../../../include/iprt/path.h" ++#include "../../../../../include/iprt/semaphore.h" ++#include "../../../../../include/iprt/stdarg.h" ++#include "../../../../../include/iprt/stdint.h" ++#include "../../../../../include/iprt/string.h" ++#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 + +-struct vboxvfsmount { ++/* ++ * representation of an active mount point ++ */ ++struct sfp_mount { ++ VBSFMAP map; ++}; ++ ++typedef struct sfp_mount sfp_mount_t; ++ ++ ++/* ++ * Shared Folders filesystem per-mount data structure. ++ */ ++typedef struct vboxvfs_mnt { ++ struct mount *sf_vfsp; /* filesystem's vfs struct */ ++ struct vnode *sf_rootnode; /* of vnode of the root directory */ ++ uid_t sf_uid; /* owner of all shared folders */ ++ gid_t sf_gid; /* group of all shared folders */ ++ mode_t sf_dmode; /* mode of all directories */ ++ mode_t sf_fmode; /* mode of all files */ ++ mode_t sf_dmask; /* mask of all directories */ ++ mode_t sf_fmask; /* mask of all files */ ++ int sf_stat_ttl; /* ttl for stat caches (in ms) */ ++ int sf_fsync; /* whether to honor fsync or not */ ++ char *sf_share_name; ++ char *sf_mntpath; /* name of mount point */ ++ sfp_mount_t *sf_handle; ++ uint64_t sf_ino; /* per FS ino generator */ ++} vboxvfs_mnt_t; ++ ++struct vboxvfs_mount_info { ++ char name[MAX_HOST_NAME]; ++ char nls_name[MAX_NLS_NAME]; ++ int uid; ++ int gid; ++ int ttl; ++}; ++ ++#if 0 ++struct vboxvfs_mnt ++{ ++ VBSFMAP map; ++ int im_flags; ++ struct mount *im_mountp; ++ struct g_consumer *im_cp; ++ struct bufobj *im_bo; ++ struct cdev *im_dev; ++ struct vnode *im_devvp; ++ off_t size; ++ int bsize; ++ int bshift; ++ int bmask; ++ int use_devvp; ++}; ++#endif ++ ++/** VNode for VBoxVFS */ ++typedef struct vboxvfs_node ++{ ++ struct vnode *i_vnode; ++ struct vboxvfs_mnt *vboxvfsmp; ++ ino_t hash_id; ++} vboxvfs_vnode_t; ++#if 0 ++struct vboxvfs_mount { + uid_t uid; + gid_t gid; + mode_t file_mode; +@@ -50,17 +156,27 @@ + int caseopt; + int didrele; + }; +- +-/* structs - stolen from the linux shared module code */ ++#endif + struct sf_glob_info { +- VBSFMAP map; ++ VBSFMAP map; + /* struct nls_table *nls;*/ +- int ttl; +- int uid; +- int gid; +- struct vnode *vnode_root; ++ int ttl; ++ int uid; ++ int gid; ++ struct vnode *vnode_root; + }; + ++/** Per-file system mount instance data. */ ++typedef struct vboxvfs_globinfo ++{ ++ VBSFMAP Map; ++ int Ttl; ++ int Uid; ++ int Gid; ++ struct mount *pVFS; ++ vboxvfs_vnode_t *pVNodeRoot; ++} vboxvfs_globinfo_t; ++ + struct sf_inode_info { + SHFLSTRING *path; + int force_restat; +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) +@@ -33,12 +33,13 @@ + $(vboxvfs_0_OUTDIR) + vboxvfs_SOURCES = \ + vboxvfs_vfsops.c \ +- vboxvfs_vnops.c ++ vboxvfs_vnops.c \ ++ vboxvfs_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_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. + */ +- +-#include "vboxvfs.h" ++#include + #include + #include + #include + #include + #include ++#include + #include + #include + #include +@@ -29,8 +29,35 @@ + #include + #include + +-#include ++#include "vboxvfs.h" ++#include "vboxvfs_prov.h" ++#if 0 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + ++#include ++#include ++ ++#include ++#endif ++ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 21:24:25 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]) by hub.freebsd.org (Postfix) with ESMTP id 522AE4E2 for ; Tue, 23 Jul 2013 21:24:25 +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 41B3D261C for ; Tue, 23 Jul 2013 21:24:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6NLOP7n070783 for ; Tue, 23 Jul 2013 21:24:25 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6NLOPVh070776 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 21:24:25 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 23 Jul 2013 21:24:25 GMT Message-Id: <201307232124.r6NLOPVh070776@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: r255077 - 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: Tue, 23 Jul 2013 21:24:25 -0000 Author: mattbw Date: Tue Jul 23 21:24:24 2013 New Revision: 255077 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255077 Log: asserts on remove_packages Modified: soc2013/mattbw/backend/actions/remove_packages.c Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Tue Jul 23 19:34:09 2013 (r255076) +++ soc2013/mattbw/backend/actions/remove_packages.c Tue Jul 23 21:24:24 2013 (r255077) @@ -39,6 +39,8 @@ { bool success; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, job); @@ -55,6 +57,8 @@ { bool success; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, sim_job); @@ -69,6 +73,9 @@ job(struct pkg_jobs *jobs, struct query *q) { + assert(jobs != NULL); + assert(q != NULL); + return query_jobs_apply_emitter(jobs, q, PK_STATUS_ENUM_REMOVE, @@ -83,6 +90,9 @@ sim_job(struct pkg_jobs *jobs, struct query *q) { + assert(jobs != NULL); + assert(q != NULL); + return query_jobs_simulate_emitter(jobs, q, pkgutils_pkg_remove_state); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 23 21:55:19 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 77C32C00 for ; Tue, 23 Jul 2013 21:55:19 +0000 (UTC) (envelope-from syuu@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 67D112744 for ; Tue, 23 Jul 2013 21:55:19 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6NLtJmJ046637 for ; Tue, 23 Jul 2013 21:55:19 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6NLtJAo046633 for svn-soc-all@FreeBSD.org; Tue, 23 Jul 2013 21:55:19 GMT (envelope-from syuu@FreeBSD.org) Date: Tue, 23 Jul 2013 21:55:19 GMT Message-Id: <201307232155.r6NLtJAo046633@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255078 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve: . usb usb/include/hw 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, 23 Jul 2013 21:55:19 -0000 Author: syuu Date: Tue Jul 23 21:55:19 2013 New Revision: 255078 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255078 Log: porting host-libusb.c Added: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/host-libusb.c Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Tue Jul 23 21:24:24 2013 (r255077) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Tue Jul 23 21:55:19 2013 (r255078) @@ -17,12 +17,12 @@ .PATH: ${.CURDIR}/usb CFLAGS+=-I${.CURDIR}/usb/include -I${.CURDIR} -SRCS+= core.c hcd-uhci.c +SRCS+= core.c hcd-uhci.c host-libusb.c NO_MAN= DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} -LDADD= -lvmmapi -lmd -lpthread -lrt +LDADD= -lvmmapi -lmd -lpthread -lrt -lusb WARNS?= 2 Added: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/host-libusb.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/host-libusb.c Tue Jul 23 21:55:19 2013 (r255078) @@ -0,0 +1,1586 @@ +/* + * Linux host USB redirector + * + * Copyright (c) 2005 Fabrice Bellard + * + * Copyright (c) 2008 Max Krasnyansky + * Support for host device auto connect & disconnect + * Major rewrite to support fully async operation + * + * Copyright 2008 TJ + * Added flexible support for /dev/bus/usb /sys/bus/usb/devices in addition + * to the legacy /proc/bus/usb USB device discovery and handling + * + * (c) 2012 Gerd Hoffmann + * Completely rewritten to use libusb instead of usbfs ioctls. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +//#include "qemu-common.h" +//#include "monitor/monitor.h" +//#include "sysemu/sysemu.h" +//#include "trace.h" + +#include "hw/usb.h" + +/* ------------------------------------------------------------------------ */ + +#define TYPE_USB_HOST_DEVICE "usb-host" +#if 0 +#define USB_HOST_DEVICE(obj) \ + OBJECT_CHECK(USBHostDevice, (obj), TYPE_USB_HOST_DEVICE) +#endif +#define USB_HOST_DEVICE(obj) ((struct USBHostDevice *)obj) +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +#define trace_usb_host_req_complete(a,b,c,d,e) +#define trace_usb_host_iso_start(a,b,c) +#define trace_usb_host_iso_stop(a,b,c) +#define trace_usb_host_iso_out_of_bufs(a,b,c) +#define trace_usb_host_parse_config(a,b,c,d) +#define trace_usb_host_parse_interface(a,b,c,d,e) +#define trace_usb_host_parse_error(a,b,c) +#define trace_usb_host_parse_endpoint(a,b,c,d,e,f) +#define trace_usb_host_open_started(a,b) +#define trace_usb_host_open_success(a,b) +#define trace_usb_host_open_failure(a,b) +#define trace_usb_host_close(a,b) +#define trace_usb_host_req_canceled(a,b,c) +#define trace_usb_host_attach_kernel(a,b,c) +#define trace_usb_host_detach_kernel(a,b,c) +#define trace_usb_host_claim_interface(a,b,c,d) +#define trace_usb_host_release_interface(a,b,c) +#define trace_usb_host_set_address(a,b,c) +#define trace_usb_host_set_config(a,b,c) +#define trace_usb_host_set_interface(a,b,c,d) +#define trace_usb_host_req_control(a,b,c,d,e,f) +#define trace_usb_host_req_emulated(a,b,c,d) +#define trace_usb_host_req_complete(a,b,c,d,e) +#define trace_usb_host_req_data(a,b,c,d,e,f) +#define trace_usb_host_reset(a,b) +#define trace_usb_host_auto_scan_enabled() + +typedef struct USBHostDevice USBHostDevice; +typedef struct USBHostRequest USBHostRequest; +typedef struct USBHostIsoXfer USBHostIsoXfer; +typedef struct USBHostIsoRing USBHostIsoRing; + +struct USBAutoFilter { + uint32_t bus_num; + uint32_t addr; + char *port; + uint32_t vendor_id; + uint32_t product_id; +}; + +enum USBHostDeviceOptions { + USB_HOST_OPT_PIPELINE, +}; + +#define USB_DEVICE(s) (&(s)->parent_obj) + +struct USBHostDevice { + USBDevice parent_obj; + + /* properties */ + struct USBAutoFilter match; + int32_t bootindex; + uint32_t iso_urb_count; + uint32_t iso_urb_frames; + uint32_t options; + uint32_t loglevel; + + /* state */ + QTAILQ_ENTRY(USBHostDevice) next; + int seen, errcount; + int bus_num; + int addr; + char port[16]; + + libusb_device *dev; + libusb_device_handle *dh; + struct libusb_device_descriptor ddesc; + + struct { + bool detached; + bool claimed; + } ifs[USB_MAX_INTERFACES]; + + /* callbacks & friends */ +// QEMUBH *bh_nodev; +// QEMUBH *bh_postld; +// Notifier exit; + + /* request queues */ + QTAILQ_HEAD(, USBHostRequest) requests; + QTAILQ_HEAD(, USBHostIsoRing) isorings; +}; + +struct USBHostRequest { + USBHostDevice *host; + USBPacket *p; + bool in; + struct libusb_transfer *xfer; + unsigned char *buffer; + unsigned char *cbuf; + unsigned int clen; + QTAILQ_ENTRY(USBHostRequest) next; +}; + +struct USBHostIsoXfer { + USBHostIsoRing *ring; + struct libusb_transfer *xfer; + bool copy_complete; + unsigned int packet; + QTAILQ_ENTRY(USBHostIsoXfer) next; +}; + +struct USBHostIsoRing { + USBHostDevice *host; + USBEndpoint *ep; + QTAILQ_HEAD(, USBHostIsoXfer) unused; + QTAILQ_HEAD(, USBHostIsoXfer) inflight; + QTAILQ_HEAD(, USBHostIsoXfer) copy; + QTAILQ_ENTRY(USBHostIsoRing) next; +}; + +static QTAILQ_HEAD(, USBHostDevice) hostdevs = + QTAILQ_HEAD_INITIALIZER(hostdevs); + +static void usb_host_auto_check(void *unused); +static void usb_host_release_interfaces(USBHostDevice *s); +static void usb_host_nodev(USBHostDevice *s); +static void usb_host_attach_kernel(USBHostDevice *s); + +/* ------------------------------------------------------------------------ */ + +#define CONTROL_TIMEOUT 10000 /* 10 sec */ +#define BULK_TIMEOUT 0 /* unlimited */ +#define INTR_TIMEOUT 0 /* unlimited */ + +#if 0 +static const char *speed_name[] = { + [LIBUSB_SPEED_UNKNOWN] = "?", + [LIBUSB_SPEED_LOW] = "1.5", + [LIBUSB_SPEED_FULL] = "12", + [LIBUSB_SPEED_HIGH] = "480", + [LIBUSB_SPEED_SUPER] = "5000", +}; +#endif + +static const unsigned int speed_map[] = { + [LIBUSB_SPEED_LOW] = USB_SPEED_LOW, + [LIBUSB_SPEED_FULL] = USB_SPEED_FULL, + [LIBUSB_SPEED_HIGH] = USB_SPEED_HIGH, + [LIBUSB_SPEED_SUPER] = USB_SPEED_SUPER, +}; + +static const unsigned int status_map[] = { + [LIBUSB_TRANSFER_COMPLETED] = USB_RET_SUCCESS, + [LIBUSB_TRANSFER_ERROR] = USB_RET_IOERROR, + [LIBUSB_TRANSFER_TIMED_OUT] = USB_RET_IOERROR, + [LIBUSB_TRANSFER_CANCELLED] = USB_RET_IOERROR, + [LIBUSB_TRANSFER_STALL] = USB_RET_STALL, + [LIBUSB_TRANSFER_NO_DEVICE] = USB_RET_NODEV, + [LIBUSB_TRANSFER_OVERFLOW] = USB_RET_BABBLE, +}; + +static const char *err_names[] = { + [-LIBUSB_ERROR_IO] = "IO", + [-LIBUSB_ERROR_INVALID_PARAM] = "INVALID_PARAM", + [-LIBUSB_ERROR_ACCESS] = "ACCESS", + [-LIBUSB_ERROR_NO_DEVICE] = "NO_DEVICE", + [-LIBUSB_ERROR_NOT_FOUND] = "NOT_FOUND", + [-LIBUSB_ERROR_BUSY] = "BUSY", + [-LIBUSB_ERROR_TIMEOUT] = "TIMEOUT", + [-LIBUSB_ERROR_OVERFLOW] = "OVERFLOW", + [-LIBUSB_ERROR_PIPE] = "PIPE", + [-LIBUSB_ERROR_INTERRUPTED] = "INTERRUPTED", + [-LIBUSB_ERROR_NO_MEM] = "NO_MEM", + [-LIBUSB_ERROR_NOT_SUPPORTED] = "NOT_SUPPORTED", + [-LIBUSB_ERROR_OTHER] = "OTHER", +}; + +static libusb_context *ctx; +static uint32_t loglevel; + +static void usb_host_handle_fd(void *opaque) +{ + struct timeval tv = { 0, 0 }; + libusb_handle_events_timeout(ctx, &tv); +} + +static void usb_host_add_fd(int fd, short events, void *user_data) +{ +/* + qemu_set_fd_handler(fd, + (events & POLLIN) ? usb_host_handle_fd : NULL, + (events & POLLOUT) ? usb_host_handle_fd : NULL, + ctx); +*/ +} + +static void usb_host_del_fd(int fd, void *user_data) +{ +/* + qemu_set_fd_handler(fd, NULL, NULL, NULL); +*/ +} + +static int usb_host_init(void) +{ + const struct libusb_pollfd **poll; + int i, rc; + + if (ctx) { + return 0; + } + rc = libusb_init(&ctx); + if (rc != 0) { + return -1; + } + libusb_set_debug(ctx, loglevel); + + libusb_set_pollfd_notifiers(ctx, usb_host_add_fd, + usb_host_del_fd, + ctx); + poll = libusb_get_pollfds(ctx); + if (poll) { + for (i = 0; poll[i] != NULL; i++) { + usb_host_add_fd(poll[i]->fd, poll[i]->events, ctx); + } + } + free(poll); + return 0; +} + +static int usb_host_get_port(libusb_device *dev, char *port, size_t len) +{ + uint8_t path[7]; + size_t off; + int rc, i; + +//#if LIBUSBX_API_VERSION >= 0x01000102 + rc = libusb_get_port_numbers(dev, path, 7); +//#else +// rc = libusb_get_port_path(ctx, dev, path, 7); +//#endif + if (rc < 0) { + return 0; + } + off = snprintf(port, len, "%d", path[0]); + for (i = 1; i < rc; i++) { + off += snprintf(port+off, len-off, ".%d", path[i]); + } + return off; +} + +static void usb_host_libusb_error(const char *func, int rc) +{ + const char *errname; + + if (rc >= 0) { + return; + } + + if (-rc < ARRAY_SIZE(err_names) && err_names[-rc]) { + errname = err_names[-rc]; + } else { + errname = "?"; + } + fprintf(stderr, "%s: %d [%s]\n", func, rc, errname); +} + +/* ------------------------------------------------------------------------ */ + +static bool usb_host_use_combining(USBEndpoint *ep) +{ + int type; + + if (!ep->pipeline) { + return false; + } + if (ep->pid != USB_TOKEN_IN) { + return false; + } + type = usb_ep_get_type(ep->dev, ep->pid, ep->nr); + if (type != USB_ENDPOINT_XFER_BULK) { + return false; + } + return true; +} + +/* ------------------------------------------------------------------------ */ + +static USBHostRequest *usb_host_req_alloc(USBHostDevice *s, USBPacket *p, + bool in, size_t bufsize) +{ + USBHostRequest *r = (USBHostRequest *)calloc(1, sizeof(*r)); + + r->host = s; + r->p = p; + r->in = in; + r->xfer = libusb_alloc_transfer(0); + if (bufsize) { + r->buffer = malloc(bufsize); + } + QTAILQ_INSERT_TAIL(&s->requests, r, next); + return r; +} + +static void usb_host_req_free(USBHostRequest *r) +{ + if (r->host) { + QTAILQ_REMOVE(&r->host->requests, r, next); + } + libusb_free_transfer(r->xfer); + free(r->buffer); + free(r); +} + +static USBHostRequest *usb_host_req_find(USBHostDevice *s, USBPacket *p) +{ + USBHostRequest *r; + + QTAILQ_FOREACH(r, &s->requests, next) { + if (r->p == p) { + return r; + } + } + return NULL; +} + +static void usb_host_req_complete_ctrl(struct libusb_transfer *xfer) +{ + USBHostRequest *r = xfer->user_data; + USBHostDevice *s = r->host; + bool disconnect = (xfer->status == LIBUSB_TRANSFER_NO_DEVICE); + + if (r->p == NULL) { + goto out; /* request was canceled */ + } + + r->p->status = status_map[xfer->status]; + r->p->actual_length = xfer->actual_length; + if (r->in && xfer->actual_length) { + memcpy(r->cbuf, r->buffer + 8, xfer->actual_length); + } + trace_usb_host_req_complete(s->bus_num, s->addr, r->p, + r->p->status, r->p->actual_length); + usb_generic_async_ctrl_complete(USB_DEVICE(s), r->p); + +out: + usb_host_req_free(r); + if (disconnect) { + usb_host_nodev(s); + } +} + +static void usb_host_req_complete_data(struct libusb_transfer *xfer) +{ + USBHostRequest *r = xfer->user_data; + USBHostDevice *s = r->host; + bool disconnect = (xfer->status == LIBUSB_TRANSFER_NO_DEVICE); + + if (r->p == NULL) { + goto out; /* request was canceled */ + } + + r->p->status = status_map[xfer->status]; + if (r->in && xfer->actual_length) { + usb_packet_copy(r->p, r->buffer, xfer->actual_length); + } + trace_usb_host_req_complete(s->bus_num, s->addr, r->p, + r->p->status, r->p->actual_length); + if (usb_host_use_combining(r->p->ep)) { + usb_combined_input_packet_complete(USB_DEVICE(s), r->p); + } else { + usb_packet_complete(USB_DEVICE(s), r->p); + } + +out: + usb_host_req_free(r); + if (disconnect) { + usb_host_nodev(s); + } +} + +static void usb_host_req_abort(USBHostRequest *r) +{ + USBHostDevice *s = r->host; + bool inflight = (r->p && r->p->state == USB_PACKET_ASYNC); + + if (inflight) { + r->p->status = USB_RET_NODEV; + trace_usb_host_req_complete(s->bus_num, s->addr, r->p, + r->p->status, r->p->actual_length); + if (r->p->ep->nr == 0) { + usb_generic_async_ctrl_complete(USB_DEVICE(s), r->p); + } else { + usb_packet_complete(USB_DEVICE(s), r->p); + } + r->p = NULL; + } + + QTAILQ_REMOVE(&r->host->requests, r, next); + r->host = NULL; + + if (inflight) { + libusb_cancel_transfer(r->xfer); + } +} + +/* ------------------------------------------------------------------------ */ + +static void usb_host_req_complete_iso(struct libusb_transfer *transfer) +{ + USBHostIsoXfer *xfer = transfer->user_data; + + if (!xfer) { + /* USBHostIsoXfer released while inflight */ + free(transfer->buffer); + libusb_free_transfer(transfer); + return; + } + + QTAILQ_REMOVE(&xfer->ring->inflight, xfer, next); + if (QTAILQ_EMPTY(&xfer->ring->inflight)) { +// USBHostDevice *s = xfer->ring->host; + trace_usb_host_iso_stop(s->bus_num, s->addr, xfer->ring->ep->nr); + } + if (xfer->ring->ep->pid == USB_TOKEN_IN) { + QTAILQ_INSERT_TAIL(&xfer->ring->copy, xfer, next); + } else { + QTAILQ_INSERT_TAIL(&xfer->ring->unused, xfer, next); + } +} + +static USBHostIsoRing *usb_host_iso_alloc(USBHostDevice *s, USBEndpoint *ep) +{ + USBHostIsoRing *ring = (USBHostIsoRing *)calloc(1, sizeof(*ring)); + USBHostIsoXfer *xfer; + /* FIXME: check interval (for now assume one xfer per frame) */ + int packets = s->iso_urb_frames; + int i; + + ring->host = s; + ring->ep = ep; + QTAILQ_INIT(&ring->unused); + QTAILQ_INIT(&ring->inflight); + QTAILQ_INIT(&ring->copy); + QTAILQ_INSERT_TAIL(&s->isorings, ring, next); + + for (i = 0; i < s->iso_urb_count; i++) { + xfer = calloc(1, sizeof(*xfer)); + xfer->ring = ring; + xfer->xfer = libusb_alloc_transfer(packets); + xfer->xfer->dev_handle = s->dh; + xfer->xfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS; + + xfer->xfer->endpoint = ring->ep->nr; + if (ring->ep->pid == USB_TOKEN_IN) { + xfer->xfer->endpoint |= USB_DIR_IN; + } + xfer->xfer->callback = usb_host_req_complete_iso; + xfer->xfer->user_data = xfer; + + xfer->xfer->num_iso_packets = packets; + xfer->xfer->length = ring->ep->max_packet_size * packets; + xfer->xfer->buffer = calloc(1, xfer->xfer->length); + + QTAILQ_INSERT_TAIL(&ring->unused, xfer, next); + } + + return ring; +} + +static USBHostIsoRing *usb_host_iso_find(USBHostDevice *s, USBEndpoint *ep) +{ + USBHostIsoRing *ring; + + QTAILQ_FOREACH(ring, &s->isorings, next) { + if (ring->ep == ep) { + return ring; + } + } + return NULL; +} + +static void usb_host_iso_reset_xfer(USBHostIsoXfer *xfer) +{ + libusb_set_iso_packet_lengths(xfer->xfer, + xfer->ring->ep->max_packet_size); + xfer->packet = 0; + xfer->copy_complete = false; +} + +static void usb_host_iso_free_xfer(USBHostIsoXfer *xfer, bool inflight) +{ + if (inflight) { + xfer->xfer->user_data = NULL; + } else { + free(xfer->xfer->buffer); + libusb_free_transfer(xfer->xfer); + } + free(xfer); +} + +static void usb_host_iso_free(USBHostIsoRing *ring) +{ + USBHostIsoXfer *xfer; + + while ((xfer = QTAILQ_FIRST(&ring->inflight)) != NULL) { + QTAILQ_REMOVE(&ring->inflight, xfer, next); + usb_host_iso_free_xfer(xfer, true); + } + while ((xfer = QTAILQ_FIRST(&ring->unused)) != NULL) { + QTAILQ_REMOVE(&ring->unused, xfer, next); + usb_host_iso_free_xfer(xfer, false); + } + while ((xfer = QTAILQ_FIRST(&ring->copy)) != NULL) { + QTAILQ_REMOVE(&ring->copy, xfer, next); + usb_host_iso_free_xfer(xfer, false); + } + + QTAILQ_REMOVE(&ring->host->isorings, ring, next); + free(ring); +} + +static void usb_host_iso_free_all(USBHostDevice *s) +{ + USBHostIsoRing *ring; + + while ((ring = QTAILQ_FIRST(&s->isorings)) != NULL) { + usb_host_iso_free(ring); + } +} + +static bool usb_host_iso_data_copy(USBHostIsoXfer *xfer, USBPacket *p) +{ + unsigned int psize; + unsigned char *buf; + + buf = libusb_get_iso_packet_buffer_simple(xfer->xfer, xfer->packet); + if (p->pid == USB_TOKEN_OUT) { + psize = p->iov.size; + if (psize > xfer->ring->ep->max_packet_size) { + /* should not happen (guest bug) */ + psize = xfer->ring->ep->max_packet_size; + } + xfer->xfer->iso_packet_desc[xfer->packet].length = psize; + } else { + psize = xfer->xfer->iso_packet_desc[xfer->packet].actual_length; + if (psize > p->iov.size) { + /* should not happen (guest bug) */ + psize = p->iov.size; + } + } + usb_packet_copy(p, buf, psize); + xfer->packet++; + xfer->copy_complete = (xfer->packet == xfer->xfer->num_iso_packets); + return xfer->copy_complete; +} + +static void usb_host_iso_data_in(USBHostDevice *s, USBPacket *p) +{ + USBHostIsoRing *ring; + USBHostIsoXfer *xfer; + bool disconnect = false; + int rc; + + ring = usb_host_iso_find(s, p->ep); + if (ring == NULL) { + ring = usb_host_iso_alloc(s, p->ep); + } + + /* copy data to guest */ + xfer = QTAILQ_FIRST(&ring->copy); + if (xfer != NULL) { + if (usb_host_iso_data_copy(xfer, p)) { + QTAILQ_REMOVE(&ring->copy, xfer, next); + QTAILQ_INSERT_TAIL(&ring->unused, xfer, next); + } + } + + /* submit empty bufs to host */ + while ((xfer = QTAILQ_FIRST(&ring->unused)) != NULL) { + QTAILQ_REMOVE(&ring->unused, xfer, next); + usb_host_iso_reset_xfer(xfer); + rc = libusb_submit_transfer(xfer->xfer); + if (rc != 0) { + usb_host_libusb_error("libusb_submit_transfer [iso]", rc); + QTAILQ_INSERT_TAIL(&ring->unused, xfer, next); + if (rc == LIBUSB_ERROR_NO_DEVICE) { + disconnect = true; + } + break; + } + if (QTAILQ_EMPTY(&ring->inflight)) { + trace_usb_host_iso_start(s->bus_num, s->addr, p->ep->nr); + } + QTAILQ_INSERT_TAIL(&ring->inflight, xfer, next); + } + + if (disconnect) { + usb_host_nodev(s); + } +} + +static void usb_host_iso_data_out(USBHostDevice *s, USBPacket *p) +{ + USBHostIsoRing *ring; + USBHostIsoXfer *xfer; + bool disconnect = false; + int rc, filled = 0; + + ring = usb_host_iso_find(s, p->ep); + if (ring == NULL) { + ring = usb_host_iso_alloc(s, p->ep); + } + + /* copy data from guest */ + xfer = QTAILQ_FIRST(&ring->copy); + while (xfer != NULL && xfer->copy_complete) { + filled++; + xfer = QTAILQ_NEXT(xfer, next); + } + if (xfer == NULL) { + xfer = QTAILQ_FIRST(&ring->unused); + if (xfer == NULL) { + trace_usb_host_iso_out_of_bufs(s->bus_num, s->addr, p->ep->nr); + return; + } + QTAILQ_REMOVE(&ring->unused, xfer, next); + usb_host_iso_reset_xfer(xfer); + QTAILQ_INSERT_TAIL(&ring->copy, xfer, next); + } + usb_host_iso_data_copy(xfer, p); + + if (QTAILQ_EMPTY(&ring->inflight)) { + /* wait until half of our buffers are filled + before kicking the iso out stream */ + if (filled*2 < s->iso_urb_count) { + return; + } + } + + /* submit filled bufs to host */ + while ((xfer = QTAILQ_FIRST(&ring->copy)) != NULL && + xfer->copy_complete) { + QTAILQ_REMOVE(&ring->copy, xfer, next); + rc = libusb_submit_transfer(xfer->xfer); + if (rc != 0) { + usb_host_libusb_error("libusb_submit_transfer [iso]", rc); + QTAILQ_INSERT_TAIL(&ring->unused, xfer, next); + if (rc == LIBUSB_ERROR_NO_DEVICE) { + disconnect = true; + } + break; + } + if (QTAILQ_EMPTY(&ring->inflight)) { + trace_usb_host_iso_start(s->bus_num, s->addr, p->ep->nr); + } + QTAILQ_INSERT_TAIL(&ring->inflight, xfer, next); + } + + if (disconnect) { + usb_host_nodev(s); + } +} + +/* ------------------------------------------------------------------------ */ + +static bool usb_host_full_speed_compat(USBHostDevice *s) +{ + struct libusb_config_descriptor *conf; + const struct libusb_interface_descriptor *intf; + const struct libusb_endpoint_descriptor *endp; + uint8_t type; + int rc, c, i, a, e; + + for (c = 0;; c++) { + rc = libusb_get_config_descriptor(s->dev, c, &conf); + if (rc != 0) { + break; + } + for (i = 0; i < conf->bNumInterfaces; i++) { + for (a = 0; a < conf->interface[i].num_altsetting; a++) { + intf = &conf->interface[i].altsetting[a]; + for (e = 0; e < intf->bNumEndpoints; e++) { + endp = &intf->endpoint[e]; + type = endp->bmAttributes & 0x3; + switch (type) { + case 0x01: /* ISO */ + return false; + case 0x03: /* INTERRUPT */ + if (endp->wMaxPacketSize > 64) { + return false; + } + break; + } + } + } + } + libusb_free_config_descriptor(conf); + } + return true; +} + +static void usb_host_ep_update(USBHostDevice *s) +{ +#if 0 + static const char *tname[] = { + [USB_ENDPOINT_XFER_CONTROL] = "control", + [USB_ENDPOINT_XFER_ISOC] = "isoc", + [USB_ENDPOINT_XFER_BULK] = "bulk", + [USB_ENDPOINT_XFER_INT] = "int", + }; +#endif + USBDevice *udev = USB_DEVICE(s); + struct libusb_config_descriptor *conf; + const struct libusb_interface_descriptor *intf; + const struct libusb_endpoint_descriptor *endp; + uint8_t devep, type; + int pid, ep; + int rc, i, e; + + usb_ep_reset(udev); + rc = libusb_get_active_config_descriptor(s->dev, &conf); + if (rc != 0) { + return; + } + trace_usb_host_parse_config(s->bus_num, s->addr, + conf->bConfigurationValue, true); + + for (i = 0; i < conf->bNumInterfaces; i++) { + assert(udev->altsetting[i] < conf->interface[i].num_altsetting); + intf = &conf->interface[i].altsetting[udev->altsetting[i]]; + trace_usb_host_parse_interface(s->bus_num, s->addr, + intf->bInterfaceNumber, + intf->bAlternateSetting, true); + for (e = 0; e < intf->bNumEndpoints; e++) { + endp = &intf->endpoint[e]; + + devep = endp->bEndpointAddress; + pid = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT; + ep = devep & 0xf; + type = endp->bmAttributes & 0x3; + + if (ep == 0) { + trace_usb_host_parse_error(s->bus_num, s->addr, + "invalid endpoint address"); + return; + } + if (usb_ep_get_type(udev, pid, ep) != USB_ENDPOINT_XFER_INVALID) { + trace_usb_host_parse_error(s->bus_num, s->addr, + "duplicate endpoint address"); + return; + } + + trace_usb_host_parse_endpoint(s->bus_num, s->addr, ep, + (devep & USB_DIR_IN) ? "in" : "out", + tname[type], true); + usb_ep_set_max_packet_size(udev, pid, ep, + endp->wMaxPacketSize); + usb_ep_set_type(udev, pid, ep, type); + usb_ep_set_ifnum(udev, pid, ep, i); + usb_ep_set_halted(udev, pid, ep, 0); + } + } + + libusb_free_config_descriptor(conf); +} + +static int usb_host_open(USBHostDevice *s, libusb_device *dev) +{ + USBDevice *udev = USB_DEVICE(s); + int bus_num = libusb_get_bus_number(dev); + int addr = libusb_get_device_address(dev); + int rc; + + trace_usb_host_open_started(bus_num, addr); + + if (s->dh != NULL) { + goto fail; + } + rc = libusb_open(dev, &s->dh); + if (rc != 0) { + goto fail; + } + + libusb_get_device_descriptor(dev, &s->ddesc); + s->dev = dev; + s->bus_num = bus_num; + s->addr = addr; + usb_host_get_port(s->dev, s->port, sizeof(s->port)); + + usb_ep_init(udev); + usb_host_ep_update(s); + + udev->speed = speed_map[libusb_get_device_speed(dev)]; + udev->speedmask = (1 << udev->speed); + if (udev->speed == USB_SPEED_HIGH && usb_host_full_speed_compat(s)) { + udev->speedmask |= USB_SPEED_MASK_FULL; + } + + if (s->ddesc.iProduct) { + libusb_get_string_descriptor_ascii(s->dh, s->ddesc.iProduct, + (unsigned char *)udev->product_desc, + sizeof(udev->product_desc)); + } else { + snprintf(udev->product_desc, sizeof(udev->product_desc), + "host:%d.%d", bus_num, addr); + } + + rc = usb_device_attach(udev); + if (rc) { + goto fail; + } + + trace_usb_host_open_success(bus_num, addr); + return 0; + +fail: + trace_usb_host_open_failure(bus_num, addr); + if (s->dh != NULL) { + libusb_close(s->dh); + s->dh = NULL; + s->dev = NULL; + } + return -1; +} + +static void usb_host_abort_xfers(USBHostDevice *s) +{ + USBHostRequest *r, *rtmp; + + QTAILQ_FOREACH_SAFE(r, &s->requests, next, rtmp) { + usb_host_req_abort(r); + } +} + +static int usb_host_close(USBHostDevice *s) +{ + USBDevice *udev = USB_DEVICE(s); + + if (s->dh == NULL) { + return -1; + } + + trace_usb_host_close(s->bus_num, s->addr); + + usb_host_abort_xfers(s); + usb_host_iso_free_all(s); + + if (udev->attached) { + usb_device_detach(udev); + } + + usb_host_release_interfaces(s); + libusb_reset_device(s->dh); + usb_host_attach_kernel(s); + libusb_close(s->dh); + s->dh = NULL; + s->dev = NULL; + + usb_host_auto_check(NULL); + return 0; +} + +static void usb_host_nodev_bh(void *opaque) +{ + USBHostDevice *s = opaque; + usb_host_close(s); +} + +static void usb_host_nodev(USBHostDevice *s) +{ +/* + if (!s->bh_nodev) { + s->bh_nodev = qemu_bh_new(usb_host_nodev_bh, s); + } + qemu_bh_schedule(s->bh_nodev); +*/ +} + +/* +static void usb_host_exit_notifier(struct Notifier *n, void *data) +{ + USBHostDevice *s = container_of(n, USBHostDevice, exit); + + if (s->dh) { + usb_host_release_interfaces(s); + usb_host_attach_kernel(s); + } +} +*/ + +static int usb_host_initfn(USBDevice *udev) +{ + USBHostDevice *s = USB_HOST_DEVICE(udev); + + loglevel = s->loglevel; + udev->flags |= (1 << USB_DEV_FLAG_IS_HOST); + udev->auto_attach = 0; + QTAILQ_INIT(&s->requests); + QTAILQ_INIT(&s->isorings); + +/* + s->exit.notify = usb_host_exit_notifier; + qemu_add_exit_notifier(&s->exit); +*/ + + QTAILQ_INSERT_TAIL(&hostdevs, s, next); +// add_boot_device_path(s->bootindex, &udev->qdev, NULL); + usb_host_auto_check(NULL); + return 0; +} + +static void usb_host_handle_destroy(USBDevice *udev) +{ + USBHostDevice *s = USB_HOST_DEVICE(udev); + +// qemu_remove_exit_notifier(&s->exit); + QTAILQ_REMOVE(&hostdevs, s, next); + usb_host_close(s); +} + +static void usb_host_cancel_packet(USBDevice *udev, USBPacket *p) +{ + USBHostDevice *s = USB_HOST_DEVICE(udev); + USBHostRequest *r; + + if (p->combined) { + usb_combined_packet_cancel(udev, p); + return; + } + + trace_usb_host_req_canceled(s->bus_num, s->addr, p); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 09:12:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2CEAC5B7 for ; Wed, 24 Jul 2013 09:12:47 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0EB2623E6 for ; Wed, 24 Jul 2013 09:12:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6O9Ckc3073050 for ; Wed, 24 Jul 2013 09:12:46 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6O9Ckkm073021 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 09:12:46 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 24 Jul 2013 09:12:46 GMT Message-Id: <201307240912.r6O9Ckkm073021@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: r255099 - in soc2013/mattbw/backend: . actions 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: Wed, 24 Jul 2013 09:12:47 -0000 Author: mattbw Date: Wed Jul 24 09:12:46 2013 New Revision: 255099 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255099 Log: add some more null-assertions Modified: soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/get_files.c soc2013/mattbw/backend/actions/get_repo_list.c soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/event.h soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/jobs.c Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/actions/get_details.c Wed Jul 24 09:12:46 2013 (r255099) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include #include #include @@ -42,6 +43,8 @@ { bool success; + assert(backend != NULL); + success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); (void)pk_backend_finished(backend); return success ? TRUE : FALSE; @@ -50,7 +53,7 @@ /* * Emits the given package's details. To be used as an iterating function. */ -static bool +static bool emit(struct pkg *pkg, const gchar *id, struct query *q) { bool success; @@ -59,6 +62,10 @@ int64_t flatsize; guint flatsize_u; + assert(pkg != NULL); + assert(id != NULL); + assert(q != NULL); + query_set_percentage(q, 0); /* Information not already part of the PackageID */ Modified: soc2013/mattbw/backend/actions/get_files.c ============================================================================== --- soc2013/mattbw/backend/actions/get_files.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/actions/get_files.c Wed Jul 24 09:12:46 2013 (r255099) @@ -18,16 +18,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include /* assert */ #include +#include #include - #include "../pk-backend.h" #include "pkg.h" -#include "../query.h" /* query_... */ - #include "../actions.h" /* get_files_thread prototype */ +#include "../query.h" /* query_... */ static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; @@ -42,6 +41,8 @@ { gboolean success; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); @@ -59,6 +60,10 @@ struct pkg_file *file; struct sbuf *sb; + assert(pkg != NULL); + assert(id != NULL); + assert(q != NULL); + query_set_percentage(q, 0); success = false; @@ -69,6 +74,8 @@ * rid of the initial ; later. */ sb = sbuf_new_auto(); + assert(sb != NULL); + while (pkg_files(pkg, &file) == EPKG_OK) sbuf_printf(sb, ";%s", pkg_file_path(file)); Modified: soc2013/mattbw/backend/actions/get_repo_list.c ============================================================================== --- soc2013/mattbw/backend/actions/get_repo_list.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/actions/get_repo_list.c Wed Jul 24 09:12:46 2013 (r255099) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include #include "../pk-backend.h" #include "pkg.h" @@ -33,15 +34,19 @@ { struct pkg_repo *repo; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); (void)pk_backend_set_percentage(backend, 0); repo = NULL; - while (pkg_repos(&repo) == EPKG_OK) + 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_enabled(repo)); + } (void)pk_backend_set_percentage(backend, 100); (void)pk_backend_finished(backend); Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/actions/install_packages.c Wed Jul 24 09:12:46 2013 (r255099) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include /* gboolean */ #include /* bool, true, false */ #include "../pk-backend.h" /* pk..., Pk... */ @@ -39,6 +40,8 @@ { bool success; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); @@ -55,6 +58,8 @@ { bool success; + assert(backend != NULL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); @@ -69,6 +74,9 @@ job(struct pkg_jobs *jobs, struct query *q) { + assert(jobs != NULL); + assert(q != NULL); + return query_jobs_apply_emitter(jobs, q, PK_STATUS_ENUM_INSTALL, @@ -83,6 +91,9 @@ sim_job(struct pkg_jobs *jobs, struct query *q) { + assert(jobs != NULL); + assert(q != NULL); + return query_jobs_simulate_emitter(jobs, q, pkgutils_pkg_install_state); Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/actions/remove_packages.c Wed Jul 24 09:12:46 2013 (r255099) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include /* gboolean */ #include /* bool, true, false */ #include "../pk-backend.h" /* pk..., Pk... */ Modified: soc2013/mattbw/backend/event.h ============================================================================== --- soc2013/mattbw/backend/event.h Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/event.h Wed Jul 24 09:12:46 2013 (r255099) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2013 Matt Windsor * * Licensed under the GNU General Public License Version 2 Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 24 09:12:46 2013 (r255099) @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include /* assert */ #include #include #include @@ -38,11 +38,12 @@ { int err; + assert(backend != NULL); err = EPKG_OK; if (!pkg_initialized()) err = pkg_init(NULL); - if (err) + if (err != EPKG_OK) ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "couldn't init pkg"); } @@ -90,6 +91,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, get_details_thread); } @@ -98,6 +100,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, get_files_thread); } @@ -142,6 +145,7 @@ { INTENTIONALLY_IGNORE(filters); /* not yet supported */ + assert(backend != NULL); THREAD(backend, get_repo_list_thread); } @@ -150,6 +154,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, get_update_detail_thread); } @@ -160,6 +165,7 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, install_files_thread); } @@ -170,6 +176,7 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, install_packages_thread); } @@ -177,7 +184,8 @@ pk_backend_refresh_cache(PkBackend *backend, gboolean force) { - (void)pk_backend_set_bool(backend, "force", force); + INTENTIONALLY_IGNORE(force); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, refresh_cache_thread); } @@ -189,6 +197,7 @@ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ INTENTIONALLY_IGNORE(allow_deps); /* not yet supported */ INTENTIONALLY_IGNORE(autoremove); /* not yet supported */ + assert(backend != NULL); THREAD(backend, remove_packages_thread); } @@ -198,6 +207,7 @@ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, resolve_thread); } @@ -207,6 +217,7 @@ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(search); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, search_files_thread); } @@ -216,6 +227,7 @@ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(search); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, search_groups_thread); } @@ -225,6 +237,7 @@ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(search); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, search_names_thread); } @@ -233,6 +246,7 @@ { INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, simulate_install_files_thread); } Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/query/core.c Wed Jul 24 09:12:46 2013 (r255099) @@ -150,6 +150,7 @@ const char * query_repo(struct query *q) { + assert(q != NULL); return (q->rtype == REPO_REMOTE ? @@ -426,6 +427,9 @@ { gchar **id_strv; + assert(backend != NULL); + assert(s != NULL); + id_strv = NULL; if (s->type == QUERY_SINGLE_NAME) { /* Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Wed Jul 24 08:56:59 2013 (r255098) +++ soc2013/mattbw/backend/query/jobs.c Wed Jul 24 09:12:46 2013 (r255099) @@ -150,8 +150,10 @@ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) + while (pkg_jobs(jobs, &pkg) == EPKG_OK) { + assert(pkg != NULL); pkgutils_emit(pkg, backend, info(pkg)); + } query_set_percentage(q, 100); return true; @@ -165,7 +167,7 @@ assert(jobs != NULL); assert(q != NULL); - + repo = query_repo(q); return (repo == NULL ? EPKG_OK : pkg_jobs_set_repository(jobs, repo)); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 09:35:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F0B934B6 for ; Wed, 24 Jul 2013 09:35:44 +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 E0ECB2566 for ; Wed, 24 Jul 2013 09:35: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 r6O9ZiJ8049612 for ; Wed, 24 Jul 2013 09:35:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6O9Zi6R049597 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 09:35:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 24 Jul 2013 09:35:44 GMT Message-Id: <201307240935.r6O9Zi6R049597@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: r255100 - in soc2013/mattbw/tests: . get-details-output search-files-output 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, 24 Jul 2013 09:35:45 -0000 Author: mattbw Date: Wed Jul 24 09:35:44 2013 New Revision: 255100 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255100 Log: add basic test for SearchFile Added: soc2013/mattbw/tests/search-files-output/ soc2013/mattbw/tests/search-files-output/test-file.sh (contents, props changed) soc2013/mattbw/tests/strip_messages.awk - copied unchanged from r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk soc2013/mattbw/tests/test-diff.sh (contents, props changed) Deleted: soc2013/mattbw/tests/get-details-output/strip_messages.awk Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh ============================================================================== --- soc2013/mattbw/tests/get-details-output/test-pkg.sh Wed Jul 24 09:12:46 2013 (r255099) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -134,20 +134,7 @@ eval ${PKGCMD} \""${FMT}"\" > "${PKG_FILE}" ${CMD_PKCON} get-details "${PK_ID}" | - awk -f "strip_messages.awk" > "${PKCON_FILE}" + awk -f "../strip_messages.awk" > "${PKCON_FILE}" -################################################################################ -# Diff the results. - -DIFF="`diff -rupN \"${PACKAGE}-pkg\" \"${PACKAGE}-pkcon\"`" -if [ -n "${DIFF}" ] -then - echo "test failed with diff:" - echo "${DIFF}" - RETURN=1 -else - echo "test succeeded" - RETURN=0 -fi - -return $RETURN +../test-diff.sh "${PACKAGE}-pkg" "${PACKAGE}-pkcon" +return $? Added: soc2013/mattbw/tests/search-files-output/test-file.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/search-files-output/test-file.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -0,0 +1,22 @@ +#!/bin/sh + +################################################################################ +# Test the output of `pkcon search file` to see if it agrees with `pkg which.` +# Expects one argument, the file which shall be passed to both. + +# Output files +PKG_OUT=out.pkg +PKCON_OUT=out.pkcon + +# Get the expected ABI through some invasive inspection of the pkg config dump +ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" + +echo "Looking for provider of $1..." +pkg which -q "$1" | + sed "s/^/Installed /; s/$/.${ARCH}/" > ${PKG_OUT} + +pkcon search file "$1" | + awk -f "../strip_messages.awk" > ${PKCON_OUT} + +../test-diff.sh ${PKG_OUT} ${PKCON_OUT} +return $? Copied: soc2013/mattbw/tests/strip_messages.awk (from r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/strip_messages.awk Wed Jul 24 09:35:44 2013 (r255100, copy of r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk) @@ -0,0 +1,4 @@ +# Strips in-band auxiliary messages from a `pkcon` run, leaving only the results +BEGIN { in_description=0 } +!/Message:.*/ && in_description { print } +/Results:/ { in_description=1 } Added: soc2013/mattbw/tests/test-diff.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/test-diff.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Performs a diff between two files that represent the PkgNG and PackageKit +# outputs after performing analogous commands, modified to follow the format +# of one or the other. The two files should be identical for the test to +# succeed; if it fails then usually the PackageKit backend is reporting +# incorrect data. +# +# Usage: test-diff.sh pkg-file pkcon-file + +DIFF="`diff -rupN \"$1\" \"$2\"`" +if [ -n "${DIFF}" ] +then + echo "test failed with diff:" + echo "${DIFF}" + RETURN=1 +else + echo "test succeeded" + RETURN=0 +fi + From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 09:48:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0297F977 for ; Wed, 24 Jul 2013 09:48:57 +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 DA1F7261A for ; Wed, 24 Jul 2013 09:48:56 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6O9muR9044952 for ; Wed, 24 Jul 2013 09:48:56 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6O9musc044943 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 09:48:56 GMT (envelope-from ccqin@FreeBSD.org) Date: Wed, 24 Jul 2013 09:48:56 GMT Message-Id: <201307240948.r6O9musc044943@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: r255101 - 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: Wed, 24 Jul 2013 09:48:57 -0000 Author: ccqin Date: Wed Jul 24 09:48:56 2013 New Revision: 255101 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255101 Log: Change of naming conversion and field max_4ms_framelen. * change "IEEE80211_RATECTL_OPT_*" to "IEEE80211_RATECTL_CAP_*". change field "options" of ieee80211_ratectl to "ir_capabilities". update the references. * fix error on initialization of ir_capabilities. * re-add max4msframelen to ieee80211_rc_series. port max_4ms_framelen[4][32] to ieee80211_ratectl. also add setup of max4msframelen to ieee80211_ratectl_complete_rcflags(). * move ieee80211_ratectl_complete_rcflags() to ieee80211_ratectl.c, also put max_4ms_framelen[4][32] there. * add pre-compile declaration to ieee80211_ratectl.h. (strange it not appeared) Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Wed Jul 24 09:35:44 2013 (r255100) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c Wed Jul 24 09:48:56 2013 (r255101) @@ -50,6 +50,33 @@ MALLOC_DEFINE(M_80211_RATECTL, "80211ratectl", "802.11 rate control"); +int max_4ms_framelen[4][32] = { + [MCS_HT20] = { + 3212, 6432, 9648, 12864, 19300, 25736, 28952, 32172, + 6424, 12852, 19280, 25708, 38568, 51424, 57852, 64280, + 9628, 19260, 28896, 38528, 57792, 65532, 65532, 65532, + 12828, 25656, 38488, 51320, 65532, 65532, 65532, 65532, + }, + [MCS_HT20_SGI] = { + 3572, 7144, 10720, 14296, 21444, 28596, 32172, 35744, + 7140, 14284, 21428, 28568, 42856, 57144, 64288, 65532, + 10700, 21408, 32112, 42816, 64228, 65532, 65532, 65532, + 14256, 28516, 42780, 57040, 65532, 65532, 65532, 65532, + }, + [MCS_HT40] = { + 6680, 13360, 20044, 26724, 40092, 53456, 60140, 65532, + 13348, 26700, 40052, 53400, 65532, 65532, 65532, 65532, + 20004, 40008, 60016, 65532, 65532, 65532, 65532, 65532, + 26644, 53292, 65532, 65532, 65532, 65532, 65532, 65532, + }, + [MCS_HT40_SGI] = { + 7420, 14844, 22272, 29696, 44544, 59396, 65532, 65532, + 14832, 29668, 44504, 59340, 65532, 65532, 65532, 65532, + 22232, 44464, 65532, 65532, 65532, 65532, 65532, 65532, + 29616, 59232, 65532, 65532, 65532, 65532, 65532, 65532, + } +}; + void ieee80211_ratectl_register(int type, const struct ieee80211_ratectl *ratectl) { @@ -67,11 +94,11 @@ } void -ieee80211_ratectl_init(struct ieee80211vap *vap, uint32_t options) +ieee80211_ratectl_init(struct ieee80211vap *vap, uint32_t capabilities) { if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE]) ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR); - vap->iv_rate.options = options; + vap->iv_rate.ir_capabilities = capabilities; vap->iv_rate->ir_init(vap); } @@ -92,3 +119,95 @@ } vap->iv_rate = ratectls[type]; } + +void +ieee80211_ratectl_complete_rcflags(const struct ieee80211_node *ni, + struct ieee80211_rc_series *rc, int shortPreamble) +{ + const struct ieee80211com *ic = ni->ni_ic; + const struct ieee80211vap *vap = ni->ni_vap; + const struct ieee80211_rate_table * rt = ic->ic_rt; + uint8_t rate; + int i; + + /* Make sure that rate control code doesn't mess it up. + * If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 + */ + + if (! (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRRPROT)) + { + for (i = 1; i < IEEE80211_RATECTL_NUM; i++) + { + if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) + rc[i].tries = 0; + rc[i].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; + } + } + + for (i = 0; i < IEEE80211_RATECTL_NUM; i++) { + + if (rc[i].tries == 0) + continue; + + rate = rt->info[rc[i].rix].rateCode; + + /* + * Only enable short preamble for legacy rates + */ + if ((! IS_HT_RATE(rate)) && shortPreamble) + rate |= rt->info[rc[i].rix].shortPreamble; + + /* + * 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_HT_FLAG; + + /* + * XXX TODO: LDPC + */ + + /* + * Dual / Triple stream rate? + */ + if (HT_RC_2_STREAMS(rate) == 2) + rc[i].flags |= IEEE80211_RATECTL_DS_FLAG; + else if (HT_RC_2_STREAMS(rate) == 3) + rc[i].flags |= IEEE80211_RATECTL_TS_FLAG; + } + + /* + * Calculate the maximum TX power cap for the current + * node. + * Rate control algo can't control TX power by now. + */ + 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_HT_FLAG) && + (HT_RC_2_MCS(rate) < 32)) { + int j; + if (rc[i].flags & IEEE80211_RATECTL_CW40_FLAG) { + if (rc[i].flags & IEEE80211_RATECTL_SGI_FLAG) + j = MCS_HT40_SGI; + else + j = MCS_HT40; + } else { + if (rc[i].flags & IEEE80211_RATECTL_SGI_FLAG) + 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 Wed Jul 24 09:35:44 2013 (r255100) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Wed Jul 24 09:48:56 2013 (r255101) @@ -25,6 +25,8 @@ * * $FreeBSD$ */ +#ifndef _NET80211_IEEE80211_RATECTL_H_ +#define _NET80211_IEEE80211_RATECTL_H_ enum ieee80211_ratealgs { IEEE80211_RATECTL_AMRR = 0, @@ -35,6 +37,13 @@ IEEE80211_RATECTL_MAX }; +enum { + MCS_HT20, + MCS_HT20_SGI, + MCS_HT40, + MCS_HT40_SGI, +}; + #define IEEE80211_RATECTL_TX_SUCCESS 1 #define IEEE80211_RATECTL_TX_FAILURE 0 @@ -51,10 +60,10 @@ #define IEEE80211_RATECTL_STBC_FLAG 0x20 /* enable STBC */ #define IEEE80211_RATECTL_TS_FLAG 0x40 /* triple-stream rate */ -/* Hardware options chip offered to rate control code */ -#define IEEE80211_RATECTL_OPT_MRR 0x01 /* support MRR */ -#define IEEE80211_RATECTL_OPT_MRRPROT 0x02 /* support MRR + protect */ -#define IEEE80211_RATECTL_OPT_MULTXCHAIN 0x04 /* has more than 1 txchain */ +/* Hardware CAPs chip offered to rate control code */ +#define IEEE80211_RATECTL_CAP_MRR 0x01 /* support MRR */ +#define IEEE80211_RATECTL_CAP_MRRPROT 0x02 /* support MRR + protect */ +#define IEEE80211_RATECTL_CAP_MULTXCHAIN 0x04 /* has more than 1 txchain */ #define IS_VAP_HT(vap) ((vap)->iv_htcaps & IEEE80211_HTC_HT) @@ -62,17 +71,22 @@ #define HT_RC_2_MCS(_rc) ((_rc) & 0x7f) #define HT_RC_2_STREAMS(_rc) ((((_rc) & 0x78) >> 3) + 1) + +extern int max_4ms_framelen[4][32]; + struct ieee80211_rc_series { uint8_t rix; /* ratetable index, not rate code */ uint8_t ratecode; /* hardware rate code */ uint8_t tries; uint8_t tx_power_cap; uint16_t flags; + uint16_t max4msframelen; }; struct ieee80211_ratectl { const char *ir_name; - uint32_t options; /* IEEE80211_RATECTL_OPTs */ + uint32_t ir_capabilities; /* hardware capabilities offered to rc */ + int (*ir_attach)(const struct ieee80211vap *); void (*ir_detach)(const struct ieee80211vap *); void (*ir_init)(struct ieee80211vap *); @@ -80,7 +94,8 @@ void (*ir_node_init)(struct ieee80211_node *); void (*ir_node_deinit)(struct ieee80211_node *); int (*ir_rate)(struct ieee80211_node *, void *, uint32_t); - void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_series *, int, size_t); + void (*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_series *, + int, size_t); void (*ir_tx_complete)(const struct ieee80211vap *, const struct ieee80211_node *, int, void *, void *); @@ -94,6 +109,8 @@ void ieee80211_ratectl_unregister(int); void ieee80211_ratectl_init(struct ieee80211vap *, uint32_t); void ieee80211_ratectl_set(struct ieee80211vap *, int); +void ieee80211_ratectl_complete_rcflags(const struct ieee80211_node *, + struct ieee80211_rc_series *, int) MALLOC_DECLARE(M_80211_RATECTL); @@ -104,11 +121,11 @@ } static void __inline -ieee80211_ratectl_node_init(struct ieee80211_node *ni, uint32_t options) +ieee80211_ratectl_node_init(struct ieee80211_node *ni) { const struct ieee80211vap *vap = ni->ni_vap; - vap->iv_rate->ir_node_init(ni, options); + vap->iv_rate->ir_node_init(ni); } static void __inline @@ -194,73 +211,7 @@ { return IS_VAP_HT(vap) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) && (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM) && - (vap->iv_rate->options & IEEE80211_RATECTL_OPT_MULTXCHAIN); + (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MULTXCHAIN); } -static void -ieee80211_ratectl_complete_rcflags(struct ieee80211_node *ni, - struct ieee80211_rc_series *rc, int shortPreamble) -{ - struct ieee80211com *ic = ni->ni_ic; - const struct ieee80211_rate_table * rt = ic->ic_rt; - uint8_t rate0, rate; - int i; - - rate0 = rt->info[rc[0].rix].rateCode; - - /* Make sure that rate control code doesn't mess it up. - * If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 - */ - - if (! IS_HT_RATE(rate0)) - { - if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG) - rc[1].tries = rc[2].tries = rc[3].tries = 0; - rc[1].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - rc[2].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - rc[3].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; - } - - for (i = 0; i < IEEE80211_RATECTL_NUM; i++) { - - if (rc[i].tries == 0) - continue; - - rate = rt->info[rc[i].rix].rateCode; - - /* - * Only enable short preamble for legacy rates - */ - if ((! IS_HT_RATE(rate)) && shortPreamble) - rate |= rt->info[rc[i].rix].shortPreamble; - - /* - * 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_HT_FLAG; - - /* - * XXX TODO: LDPC - */ - - /* - * Dual / Triple stream rate? - */ - if (HT_RC_2_STREAMS(rate) == 2) - rc[i].flags |= IEEE80211_RATECTL_DS_FLAG; - else if (HT_RC_2_STREAMS(rate) == 3) - rc[i].flags |= IEEE80211_RATECTL_TS_FLAG; - } - - /* - * Calculate the maximum TX power cap for the current - * node. - * Rate control algo can't control TX power by now. - */ - rc[i].tx_power_cap = ieee80211_get_node_txpower(ni); - } -} +#endif From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 13:01:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D7865E3C for ; Wed, 24 Jul 2013 13:01:54 +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 BA82C2E89 for ; Wed, 24 Jul 2013 13:01:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6OD1sYn088945 for ; Wed, 24 Jul 2013 13:01:54 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6OD1stR088941 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 13:01:54 GMT (envelope-from oleksandr@FreeBSD.org) Date: Wed, 24 Jul 2013 13:01:54 GMT Message-Id: <201307241301.r6OD1stR088941@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: r255111 - 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: Wed, 24 Jul 2013 13:01:54 -0000 Author: oleksandr Date: Wed Jul 24 13:01:54 2013 New Revision: 255111 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255111 Log: Implemented access, open and close function for vboxvfs_vnops 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 Wed Jul 24 11:32:58 2013 (r255110) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Wed Jul 24 13:01:54 2013 (r255111) @@ -12,7 +12,7 @@ #include #include #include -@@ -33,7 +32,28 @@ +@@ -33,7 +32,29 @@ #include #include @@ -21,6 +21,7 @@ +#include +#include +#include ++#include +#include +#include +#include @@ -41,7 +42,7 @@ /* * Prototypes for VBOXVFS vnode operations */ -@@ -56,6 +76,7 @@ +@@ -56,6 +77,7 @@ static vop_symlink_t vboxvfs_symlink; static vop_readdir_t vboxvfs_readdir; static vop_strategy_t vboxvfs_strategy; @@ -49,7 +50,7 @@ static vop_print_t vboxvfs_print; static vop_pathconf_t vboxvfs_pathconf; static vop_advlock_t vboxvfs_advlock; -@@ -65,177 +86,633 @@ +@@ -65,177 +87,755 @@ static vop_inactive_t vboxvfs_inactive; static vop_putpages_t vboxvfs_putpages; static vop_reclaim_t vboxvfs_reclaim; @@ -118,19 +119,68 @@ + .vop_symlink = vboxvfs_symlink, + .vop_write = vboxvfs_write, }; ++/* ++ * uid and gid in sffs determine owner and group for all files. ++ */ ++#if 0 ++static int ++sfnode_access(sfnode_t *node, mode_t mode, cred_t *cr) ++{ ++ sffs_data_t *sffs = node->sf_sffs; ++ mode_t m; ++ int shift = 0; ++ int error; ++ vnode_t *vp; ++ ASSERT(MUTEX_HELD(&sffs_lock)); ++ ++ /* ++ * get the mode from the cache or provider ++ */ ++ if (sfnode_stat_cached(node)) ++ error = 0; ++ else ++ error = sfnode_update_stat_cache(node); ++ m = (error == 0) ? node->sf_stat.sf_mode : 0; ++ ++ /* ++ * mask off the permissions based on uid/gid ++ */ ++ if (crgetuid(cr) != sffs->sf_uid) { ++ shift += 3; ++ if (groupmember(sffs->sf_gid, cr) == 0) ++ shift += 3; ++ } ++ mode &= ~(m << shift); ++ ++ if (mode == 0) { ++ error = 0; ++ } else { ++ vp = sfnode_get_vnode(node); ++ error = secpolicy_vnode_access(cr, vp, sffs->sf_uid, mode); ++ VN_RELE(vp); ++ } ++ return (error); ++} ++#endif static int vboxvfs_access(struct vop_access_args *ap) { - return 0; +#if 0 -+ struct vnode *vp; -+ accmode_t accmode; ++ sfnode_t *node = VN2SFN(vp->a_vp); ++ int error; + -+ vp = ap->a_vp; -+ accmode = ap->a_accmode; ++ mutex_enter(&sffs_lock); ++ error = sfnode_access(node, mode, cr); ++ mutex_exit(&sffs_lock); + -+ if (accmode & VWRITE) { -+ switch (vp->v_type) { ++ return (error); ++#endif ++ struct vnode *vp = ap->a_vp; ++ accmode_t accmode = ap->a_accmode; ++ ++ if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) { ++ switch (vp->v_type) { + case VDIR: + case VLNK: + case VREG: @@ -139,36 +189,109 @@ + default: + break; + } -+ } -+ ++ } + return (vaccess(vp->v_type, 0444, 0, 0, + accmode, ap->a_cred, NULL)); -+#endif -+ return (0); } ++/* ++ * Clears the (cached) directory listing for the node. ++ */ ++static void ++vfsnode_clear_dir_list(struct vboxvfs_node *np) ++{ ++ while (np->sf_dir_list != NULL) { ++ sffs_dirents_t *next = np->sf_dir_list->sf_next; ++ free(np->sf_dir_list, M_VBOXVFS); ++ np->sf_dir_list = next; ++ } ++} ++ ++/* ++ * Open the provider file associated with a vnode. Holding the file open is ++ * the only way we have of trying to have a vnode continue to refer to the ++ * same host file in the host in light of the possibility of host side renames. ++ */ ++static void ++vfsnode_open(struct vboxvfs_node *np) ++{ ++ int error; ++ sfp_file_t *fp; ++ ++ if (np->sf_file != NULL) ++ return; ++ error = sfprov_open(np->vboxvfsmp->sf_handle, np->sf_path, &fp); ++ if (error == 0) ++ np->sf_file = fp; ++} ++ static int vboxvfs_open(struct vop_open_args *ap) { - return 0; -+#if 0 -+ struct vboxvfs_node *np = VTON(ap->a_vp); ++ struct vnode *vp = ap->a_vp; ++ struct vboxvfs_node *np; ++ int error = 0; + off_t fsize; + ++ np = VTOVBOXFS(vp); ++ vfsnode_open(np); ++ if (np->sf_file == NULL) ++ error = EINVAL; ++ + fsize = np->vboxvfsmp->size; + vnode_create_vobject(ap->a_vp, fsize, ap->a_td); -+#endif -+ return (0); ++ ++ return (error); } ++#if 0 ++static uint64_t ++sfnode_cur_time_usec(void) ++{ ++ clock_t now = drv_hztousec(ddi_get_lbolt()); ++ return now; ++} ++static int ++sfnode_stat_cached(sfnode_t *node) ++{ ++ return (sfnode_cur_time_usec() - node->sf_stat_time) < ++ node->sf_sffs->sf_stat_ttl * 1000L; ++} ++#endif ++static void ++vfsnode_invalidate_stat_cache(struct vboxvfs_node *np) ++{ ++ np->sf_stat_time = 0; ++} ++ static int vboxvfs_close(struct vop_close_args *ap) { - return 0; -+#if 0 -+ int rc; -+ -+ rc = vboxCallClose(&vbox_client, &fp->map, fp->handle); -+ kmem_free(fp, sizeof(sfp_file_t)); -+#endif ++ ++ struct vnode *vp = ap->a_vp; ++ struct vboxvfs_node *np; ++ ++ np = VTOVBOXFS(vp); ++ ++ /* ++ * Free the directory entries for the node. We do this on this call ++ * here because the directory node may not become inactive for a long ++ * time after the readdir is over. Case in point, if somebody cd's into ++ * the directory then it won't become inactive until they cd away again. ++ * In such a case we would end up with the directory listing not getting ++ * updated (i.e. the result of 'ls' always being the same) until they ++ * change the working directory. ++ */ ++ vfsnode_clear_dir_list(np); ++ ++ vfsnode_invalidate_stat_cache(np); ++ ++ if (np->sf_file != NULL) ++ { ++ (void)sfprov_close(np->sf_file); ++ np->sf_file = NULL; ++ } ++ + return (0); } @@ -744,7 +867,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (working copy) -@@ -21,24 +21,130 @@ +@@ -21,46 +21,193 @@ #define VBOXVFS_VFSNAME "vboxvfs" #define VBOXVFS_VERSION 1 @@ -761,8 +884,8 @@ - int ttl; -}; +/** Helper macros */ -+#define VFSTOVBOXFS(mp) ((vboxvfs_mnt_t *)((mp)->mnt_data)) -+#define VTON(vp) ((vboxvfs_node *)((vp)->v_data)) ++#define VFSTOVBOXFS(mp) ((struct vboxvfs_mnt *)((mp)->mnt_data)) ++#define VTOVBOXFS(vp) ((struct vboxvfs_node *)(vp)->v_data) +MALLOC_DECLARE(M_VBOXVFS); + @@ -788,7 +911,6 @@ +#include "../../../../../include/iprt/time.h" +#include "../../../../../include/iprt/types.h" +#include "../../../../../include/iprt/uni.h" -+#include "../../common/VBoxGuestLib/SysHlp.h" +#include "../../../../../include/iprt/nocrt/limits.h" +#include "../../../../../include/iprt/alloc.h" +#include "../../../../../include/iprt/asm.h" @@ -816,22 +938,81 @@ #include -#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 + */ +struct sfp_mount { + VBSFMAP map; + }; + +-/* structs - stolen from the linux shared module code */ ++/* ++ * Mount / Unmount a shared folder. ++ * ++ * sfprov_mount() takes as input the connection pointer and the name of ++ * the shared folder. On success, it returns zero and supplies an ++ * sfp_mount_t handle. On failure it returns any relevant errno value. ++ * ++ * sfprov_unmount() unmounts the mounted file system. It returns 0 on ++ * success and any relevant errno on failure. ++ */ ++typedef struct sfp_mount sfp_mount_t; ++ ++struct sfp_file { ++ SHFLHANDLE handle; ++ VBSFMAP map; /* need this again for the close operation */ +}; + -+typedef struct sfp_mount sfp_mount_t; ++typedef struct sfp_file sfp_file_t; ++ ++/* ++ * File operations: open/close/read/write/etc. ++ * ++ * open/create can return any relevant errno, however ENOENT ++ * generally means that the host file didn't exist. ++ */ ++typedef struct sffs_stat { ++ mode_t sf_mode; ++ off_t sf_size; ++ off_t sf_alloc; ++ struct timespec sf_atime; ++ struct timespec sf_mtime; ++ struct timespec sf_ctime; ++} sffs_stat_t; + ++/* ++ * Read directory entries. ++ */ ++/* ++ * a singly linked list of buffers, each containing an array of stat's+dirent's. ++ * sf_len is length of the sf_entries array, in bytes. ++ */ ++typedef struct sffs_dirents { ++ struct sffs_dirents *sf_next; ++ unsigned long long int sf_len; ++ struct sffs_dirent { ++ sffs_stat_t sf_stat; ++ struct dirent sf_entry; /* this is variable length */ ++ } sf_entries[1]; ++} sffs_dirents_t; + +/* + * Shared Folders filesystem per-mount data structure. + */ -+typedef struct vboxvfs_mnt { ++struct vboxvfs_mnt { + struct mount *sf_vfsp; /* filesystem's vfs struct */ + struct vnode *sf_rootnode; /* of vnode of the root directory */ + uid_t sf_uid; /* owner of all shared folders */ @@ -846,7 +1027,30 @@ + char *sf_mntpath; /* name of mount point */ + sfp_mount_t *sf_handle; + uint64_t sf_ino; /* per FS ino generator */ -+} vboxvfs_mnt_t; ++ off_t size; ++}; ++ ++/* ++ * vboxvfs_node is the file system dependent vnode data for vboxsf. ++ * vboxvfs_node's also track all files ever accessed, both open and closed. ++ * It duplicates some of the information in vnode, since it holds ++ * information for files that may have been completely closed. ++ * ++ */ ++struct vboxvfs_node { ++ struct vboxvfs_mnt *vboxvfsmp; /* containing mounted file system */ ++ char *sf_path; /* full pathname to file or dir */ ++ uint64_t sf_ino; /* assigned unique ID number */ ++ struct vnode *sf_vnode; /* vnode if active */ ++ sfp_file_t *sf_file; /* non NULL if open */ ++ struct vboxvfs_node *sf_parent; /* parent sfnode of this one */ ++ uint16_t sf_children; /* number of children sfnodes */ ++ uint8_t sf_type; /* VDIR or VREG */ ++ uint8_t sf_is_stale; /* this is stale and should be purged */ ++ sffs_stat_t sf_stat; /* cached file attrs for this node */ ++ uint64_t sf_stat_time; /* last-modified time of sf_stat */ ++ sffs_dirents_t *sf_dir_list; /* list of entries for this directory */ ++}; + +struct vboxvfs_mount_info { + char name[MAX_HOST_NAME]; @@ -856,43 +1060,6 @@ + int ttl; +}; + -+#if 0 -+struct vboxvfs_mnt -+{ -+ VBSFMAP map; -+ int im_flags; -+ struct mount *im_mountp; -+ struct g_consumer *im_cp; -+ struct bufobj *im_bo; -+ struct cdev *im_dev; -+ struct vnode *im_devvp; -+ off_t size; -+ int bsize; -+ int bshift; -+ int bmask; -+ int use_devvp; -+}; -+#endif -+ -+/** VNode for VBoxVFS */ -+typedef struct vboxvfs_node -+{ -+ struct vnode *i_vnode; -+ struct vboxvfs_mnt *vboxvfsmp; -+ ino_t hash_id; -+} vboxvfs_vnode_t; -+#if 0 -+struct vboxvfs_mount { - uid_t uid; - gid_t gid; - mode_t file_mode; -@@ -50,17 +156,27 @@ - int caseopt; - int didrele; - }; -- --/* structs - stolen from the linux shared module code */ -+#endif struct sf_glob_info { - VBSFMAP map; + VBSFMAP map; @@ -910,17 +1077,104 @@ +/** Per-file system mount instance data. */ +typedef struct vboxvfs_globinfo +{ -+ VBSFMAP Map; -+ int Ttl; -+ int Uid; -+ int Gid; -+ struct mount *pVFS; -+ vboxvfs_vnode_t *pVNodeRoot; ++ VBSFMAP Map; ++ int Ttl; ++ int Uid; ++ int Gid; ++ struct mount *pVFS; ++ struct vboxvfs_node *pVNodeRoot; +} vboxvfs_globinfo_t; + struct sf_inode_info { SHFLSTRING *path; int force_restat; +@@ -86,6 +233,86 @@ + SHFLHANDLE handle; + }; + ++/* ++ * Initialization and termination. ++ * sfprov_connect() is called once before any other interfaces and returns ++ * a handle used in further calls. The argument should be SFPROV_VERSION ++ * from above. On failure it returns a NULL pointer. ++ * ++ * sfprov_disconnect() must only be called after all sf file systems have been ++ * unmounted. ++ */ ++typedef struct sfp_connection sfp_connection_t; ++ ++extern sfp_connection_t *sfprov_connect(int); ++extern void sfprov_disconnect(sfp_connection_t *); ++extern int sfprov_mount(sfp_connection_t *, char *, sfp_mount_t **); ++extern int sfprov_unmount(sfp_mount_t *); ++ ++/* ++ * query information about a mounted file system ++ */ ++typedef struct sffs_fsinfo { ++ uint64_t blksize; ++ uint64_t blksused; ++ uint64_t blksavail; ++ uint32_t maxnamesize; ++ uint32_t readonly; ++} sffs_fsinfo_t; ++ ++extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *); ++ ++extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode, ++ sfp_file_t **fp, sffs_stat_t *stat); ++extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp); ++extern int sfprov_close(sfp_file_t *fp); ++extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset, ++ uint32_t *numbytes); ++extern int sfprov_write(sfp_file_t *, char * buffer, uint64_t offset, ++ uint32_t *numbytes); ++extern int sfprov_fsync(sfp_file_t *fp); ++ ++ ++/* ++ * get/set information about a file (or directory) using pathname ++ */ ++extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *); ++extern int sfprov_get_size(sfp_mount_t *, char *, uint64_t *); ++extern int sfprov_get_atime(sfp_mount_t *, char *, struct timespec *); ++extern int sfprov_get_mtime(sfp_mount_t *, char *, struct timespec *); ++extern int sfprov_get_ctime(sfp_mount_t *, char *, struct timespec *); ++extern int sfprov_get_attr(sfp_mount_t *, char *, sffs_stat_t *); ++extern int sfprov_set_attr(sfp_mount_t *, char *, u_int, mode_t, ++ struct timespec, struct timespec, struct timespec); ++extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t); ++ ++ ++/* ++ * File/Directory operations ++ */ ++extern int sfprov_trunc(sfp_mount_t *, char *); ++extern int sfprov_remove(sfp_mount_t *, char *path, u_int is_link); ++extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode, ++ sfp_file_t **fp, sffs_stat_t *stat); ++extern int sfprov_rmdir(sfp_mount_t *, char *path); ++extern int sfprov_rename(sfp_mount_t *, char *from, char *to, u_int is_dir); ++ ++ ++/* ++ * Symbolic link operations ++ */ ++extern int sfprov_set_show_symlinks(void); ++extern int sfprov_readlink(sfp_mount_t *, char *path, char *target, ++ size_t tgt_size); ++extern int sfprov_symlink(sfp_mount_t *, char *linkname, char *target, ++ sffs_stat_t *stat); ++ ++#define SFFS_DIRENTS_SIZE 8192 ++#define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0])) ++ ++/*extern int sfprov_readdir(sfp_mount_t *mnt, char *path, ++ sffs_dirents_t **dirents); */ ++ + #endif /* KERNEL */ + + #endif /* !___VBOXVFS_H___ */ Index: src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk (revision 4) @@ -961,13 +1215,12 @@ #include #include #include -@@ -29,8 +29,35 @@ +@@ -29,10 +29,40 @@ #include #include -#include +#include "vboxvfs.h" -+#include "vboxvfs_prov.h" +#if 0 +#include +#include @@ -997,8 +1250,14 @@ + #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; -@@ -51,15 +78,15 @@ + + SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); +@@ -51,15 +81,15 @@ static vfs_unmount_t vboxvfs_unmount; static struct vfsops vboxvfs_vfsops = { @@ -1023,7 +1282,7 @@ }; -@@ -66,193 +93,238 @@ +@@ -66,193 +96,238 @@ VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK); MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1); @@ -1358,7 +1617,7 @@ +int vboxvfs_statfs(struct mount *mp, struct statfs *sbp) { - return 0; -+ vboxvfs_mnt_t *vboxvfsmp; ++ struct vboxvfs_mnt *vboxvfsmp; + sffs_fsinfo_t fsinfo; +// dev32_t d32; + int error; @@ -1390,7 +1649,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c (revision 0) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c (working copy) -@@ -0,0 +1,1021 @@ +@@ -0,0 +1,1011 @@ +/** @file + * VirtualBox File System for FreeBSD Guests, provider implementation. + * Portions contributed by: Ronald. @@ -1429,15 +1688,10 @@ +#include +#include +#include -+#include -+#include "vboxvfs_prov.h" ++#include "vboxvfs.h" + +#define SFPROV_VERSION 1 + -+#ifdef MALLOC_DECLARE -+MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS"); -+#endif -+ +static VBSFCLIENT vbox_client; + +static int sfprov_vbox2errno(int rc) @@ -1689,11 +1943,6 @@ + * open/create can return any relevant errno, however ENOENT + * generally means that the host file didn't exist. + */ -+struct sfp_file { -+ SHFLHANDLE handle; -+ VBSFMAP map; /* need this again for the close operation */ -+}; -+ +int +sfprov_create( + sfp_mount_t *mnt, @@ -2416,7 +2665,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.h (revision 0) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.h (working copy) -@@ -0,0 +1,152 @@ +@@ -0,0 +1,154 @@ +/* $Id: vboxfs_prov.h $ */ +/** @file + * VirtualBox File System for FreeBSD Guests, provider header. @@ -2469,6 +2718,7 @@ +extern sfp_connection_t *sfprov_connect(int); +extern void sfprov_disconnect(sfp_connection_t *); +extern int sfprov_mount(sfp_connection_t *, char *, sfp_mount_t **); ++ +extern int sfprov_unmount(sfp_mount_t *); + +/* @@ -2498,6 +2748,7 @@ + struct timespec sf_mtime; + struct timespec sf_ctime; +} sffs_stat_t; ++ +typedef struct sfp_file sfp_file_t; + +extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode, From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 16:27: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 8551B919 for ; Wed, 24 Jul 2013 16:27: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 636B12BF9 for ; Wed, 24 Jul 2013 16:27: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 r6OGR5a5075094 for ; Wed, 24 Jul 2013 16:27:05 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6OGR5c0075091 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 16:27:05 GMT (envelope-from oleksandr@FreeBSD.org) Date: Wed, 24 Jul 2013 16:27:05 GMT Message-Id: <201307241627.r6OGR5c0075091@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: r255117 - 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: Wed, 24 Jul 2013 16:27:06 -0000 Author: oleksandr Date: Wed Jul 24 16:27:05 2013 New Revision: 255117 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255117 Log: Implemented getattr, setattr and pathconf functions for vboxvfs_vnops 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 Wed Jul 24 15:46:49 2013 (r255116) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Wed Jul 24 16:27:05 2013 (r255117) @@ -1,868 +1,453 @@ -Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c +Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c =================================================================== ---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (revision 4) -+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (working copy) -@@ -14,8 +14,7 @@ +--- 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. */ - -#include "vboxvfs.h" -+#if 0 ++#include #include #include - #include -@@ -33,7 +32,29 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -29,10 +29,40 @@ + #include + #include - #include - #include -+#endif +-#include ++#include "vboxvfs.h" ++#if 0 ++#include +#include +#include -+#include -+#include -+#include -+#include -+#include ++#include +#include -+#include +#include ++#include ++#include ++#include +#include ++#include ++#include +#include -+#include -+#include ++#include ++#include ++#include +#include -+#include ++#include +#include ++#include ++#include ++ +#include ++#endif + -+#include "vboxvfs.h" + #define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data) + ++#ifdef MALLOC_DECLARE ++MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS"); ++#endif + - /* - * Prototypes for VBOXVFS vnode operations - */ -@@ -56,6 +77,7 @@ - static vop_symlink_t vboxvfs_symlink; - static vop_readdir_t vboxvfs_readdir; - static vop_strategy_t vboxvfs_strategy; -+static vop_bmap_t vboxvfs_bmap; - static vop_print_t vboxvfs_print; - static vop_pathconf_t vboxvfs_pathconf; - static vop_advlock_t vboxvfs_advlock; -@@ -65,177 +87,755 @@ - static vop_inactive_t vboxvfs_inactive; - static vop_putpages_t vboxvfs_putpages; - static vop_reclaim_t vboxvfs_reclaim; -+static vop_vptofh_t vboxvfs_vptofh; + static int vboxvfs_version = VBOXVFS_VERSION; - struct vop_vector vboxvfs_vnodeops = { -- .vop_default = &default_vnodeops, -+ .vop_default = &default_vnodeops, + SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); +@@ -51,15 +81,15 @@ + static vfs_unmount_t vboxvfs_unmount; -- .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, -+ .vop_access = vboxvfs_access, -+ .vop_bmap = vboxvfs_bmap, -+ .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_vptofh = vboxvfs_vptofh, -+ .vop_symlink = vboxvfs_symlink, -+ .vop_write = vboxvfs_write, + static struct vfsops vboxvfs_vfsops = { +- .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, ++ .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, }; -+/* -+ * uid and gid in sffs determine owner and group for all files. -+ */ -+#if 0 -+static int -+sfnode_access(sfnode_t *node, mode_t mode, cred_t *cr) -+{ -+ sffs_data_t *sffs = node->sf_sffs; -+ mode_t m; -+ int shift = 0; -+ int error; -+ vnode_t *vp; -+ ASSERT(MUTEX_HELD(&sffs_lock)); -+ -+ /* -+ * get the mode from the cache or provider -+ */ -+ if (sfnode_stat_cached(node)) -+ error = 0; -+ else -+ error = sfnode_update_stat_cache(node); -+ m = (error == 0) ? node->sf_stat.sf_mode : 0; -+ -+ /* -+ * mask off the permissions based on uid/gid -+ */ -+ if (crgetuid(cr) != sffs->sf_uid) { -+ shift += 3; -+ if (groupmember(sffs->sf_gid, cr) == 0) -+ shift += 3; -+ } -+ mode &= ~(m << shift); -+ -+ if (mode == 0) { -+ error = 0; -+ } else { -+ vp = sfnode_get_vnode(node); -+ error = secpolicy_vnode_access(cr, vp, sffs->sf_uid, mode); -+ VN_RELE(vp); -+ } -+ return (error); -+} -+#endif - static int vboxvfs_access(struct vop_access_args *ap) + +@@ -66,193 +96,238 @@ + 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) { -- return 0; -+#if 0 -+ sfnode_t *node = VN2SFN(vp->a_vp); -+ int error; -+ -+ mutex_enter(&sffs_lock); -+ error = sfnode_access(node, mode, cr); -+ mutex_exit(&sffs_lock); -+ -+ return (error); -+#endif -+ struct vnode *vp = ap->a_vp; -+ accmode_t accmode = ap->a_accmode; -+ -+ if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) { -+ switch (vp->v_type) { -+ case VDIR: -+ case VLNK: -+ case VREG: -+ return (EROFS); -+ /* NOT REACHED */ -+ default: -+ break; -+ } -+ } -+ return (vaccess(vp->v_type, 0444, 0, 0, -+ accmode, ap->a_cred, NULL)); - } +- struct vboxvfs_mount_info args; +- int rc = 0; ++ struct vboxvfs_mount_info args; ++ int rc = 0; -+/* -+ * Clears the (cached) directory listing for the node. -+ */ -+static void -+vfsnode_clear_dir_list(struct vboxvfs_node *np) -+{ -+ while (np->sf_dir_list != NULL) { -+ sffs_dirents_t *next = np->sf_dir_list->sf_next; -+ free(np->sf_dir_list, M_VBOXVFS); -+ np->sf_dir_list = next; -+ } -+} -+ -+/* -+ * Open the provider file associated with a vnode. Holding the file open is -+ * the only way we have of trying to have a vnode continue to refer to the -+ * same host file in the host in light of the possibility of host side renames. -+ */ -+static void -+vfsnode_open(struct vboxvfs_node *np) -+{ -+ int error; -+ sfp_file_t *fp; -+ -+ if (np->sf_file != NULL) -+ return; -+ error = sfprov_open(np->vboxvfsmp->sf_handle, np->sf_path, &fp); -+ if (error == 0) -+ np->sf_file = fp; -+} -+ - static int vboxvfs_open(struct vop_open_args *ap) - { -- return 0; -+ struct vnode *vp = ap->a_vp; -+ struct vboxvfs_node *np; -+ int error = 0; -+ off_t fsize; -+ -+ np = VTOVBOXFS(vp); -+ vfsnode_open(np); -+ if (np->sf_file == NULL) -+ error = EINVAL; -+ -+ fsize = np->vboxvfsmp->size; -+ vnode_create_vobject(ap->a_vp, fsize, ap->a_td); -+ -+ return (error); - } -+#if 0 -+static uint64_t -+sfnode_cur_time_usec(void) -+{ -+ clock_t now = drv_hztousec(ddi_get_lbolt()); -+ return now; -+} +- printf("%s: Enter\n", __FUNCTION__); ++ printf("%s: Enter\n", __FUNCTION__); -+static int -+sfnode_stat_cached(sfnode_t *node) -+{ -+ return (sfnode_cur_time_usec() - node->sf_stat_time) < -+ node->sf_sffs->sf_stat_ttl * 1000L; -+} -+#endif -+static void -+vfsnode_invalidate_stat_cache(struct vboxvfs_node *np) -+{ -+ np->sf_stat_time = 0; -+} -+ - static int vboxvfs_close(struct vop_close_args *ap) - { -- return 0; -+ -+ struct vnode *vp = ap->a_vp; -+ struct vboxvfs_node *np; -+ -+ np = VTOVBOXFS(vp); -+ -+ /* -+ * Free the directory entries for the node. We do this on this call -+ * here because the directory node may not become inactive for a long -+ * time after the readdir is over. Case in point, if somebody cd's into -+ * the directory then it won't become inactive until they cd away again. -+ * In such a case we would end up with the directory listing not getting -+ * updated (i.e. the result of 'ls' always being the same) until they -+ * change the working directory. -+ */ -+ vfsnode_clear_dir_list(np); -+ -+ vfsnode_invalidate_stat_cache(np); -+ -+ if (np->sf_file != NULL) -+ { -+ (void)sfprov_close(np->sf_file); -+ np->sf_file = NULL; -+ } -+ -+ return (0); - } +- 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); - static int vboxvfs_getattr(struct vop_getattr_args *ap) - { -- return 0; -+#if 0 -+ struct vnode *vp; -+ struct vboxvfs_node *node; -+ struct vattr *vap; -+ struct timespec ts; -+ -+ ts.tv_sec = 0; -+ -+ vp = ap->a_vp; -+ vap = ap->a_vap; -+ node = VTON(vp); -+ -+ vap->va_fsid = dev2udev(nodevgmp->im_dev); -+ vap->va_fileid = node->hash_id; -+ vap->va_uid = 0; -+ vap->va_gid = 0; -+ vap->va_atime.tv_sec = VNOVAL; -+ vap->va_atime.tv_nsec = VNOVAL; -+ vap->va_mtime.tv_sec = VNOVAL; -+ vap->va_mtime.tv_nsec = VNOVAL; -+ vap->va_ctime.tv_sec = VNOVAL; -+ vap->va_ctime.tv_nsec = VNOVAL; -+ vap->va_rdev = NODEV; -+ if (vp->v_type & VDIR) { -+ vap->va_size = 40; /*XXX*/ -+ vap->va_nlink = 2; -+ vap->va_mode = 0555; -+ } else { -+ vap->va_size = node->vboxvfsmp->size; -+ vap->va_nlink = 1; -+ vap->va_mode = 0444; -+ } -+ vap->va_flags = 0; -+ vap->va_gen = 1; -+ vap->va_blocksize = node->vboxvfsmp->bsize; -+ vap->va_bytes = vap->va_size; -+ vap->va_type = vp->v_type; -+ vap->va_filerev = 0; -+#endif -+ return (0); - } +- 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); - static int vboxvfs_setattr(struct vop_setattr_args *ap) - { -- return 0; -+#if 0 -+ struct vnode *vp; -+ struct vattr *vap; -+ -+ vp = ap->a_vp; -+ vap = ap->a_vap; -+ if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || -+ vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || -+ vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) -+ return (EROFS); -+ if (vap->va_size != (u_quad_t)VNOVAL) { -+ switch (vp->v_type) { -+ case VDIR: -+ return (EISDIR); -+ case VLNK: -+ case VREG: -+ return (EROFS); -+ case VCHR: -+ case VBLK: -+ case VSOCK: -+ case VFIFO: -+ case VNON: -+ case VBAD: -+ case VMARKER: -+ return (0); -+ } -+ } -+#endif -+ return (0); - } +- rc = kernel_mount(ma, flags); ++ rc = kernel_mount(ma, flags); - static int vboxvfs_read(struct vop_read_args *ap) - { -- return 0; -+#if 0 -+ static const int clustersize = MAXBSIZE; -+ -+ struct vnode *vp = ap->a_vp; -+ struct uio *uio = ap->a_uio; -+ struct vboxvfs_node *node = VTON(vp); -+ struct vboxvfs_mnt *vboxvfsmp; -+ struct buf *bp; -+ daddr_t lbn; -+ off_t diff, fsize; -+ int error = 0; -+ long size, n, on; -+ -+ if (uio->uio_resid == 0) -+ return (0); -+ if (uio->uio_offset < 0) -+ return (EINVAL); -+ -+ if (vp->v_type == VCHR || vp->v_type == VBLK) -+ return (EOPNOTSUPP); -+ if (vp->v_type != VREG) -+ return (EINVAL); -+ -+ vboxvfsmp = node->vboxvfsmp; -+ fsize = vboxvfsmp->size; -+ -+ do { -+ lbn = lblkno(vboxvfsmp, uio->uio_offset); -+ on = blkoff(vboxvfsmp, uio->uio_offset); -+ n = min((u_int)(clustersize - on), uio->uio_resid); -+ diff = fsize - uio->uio_offset; -+ if (diff <= 0) -+ return (0); -+ if (diff < n) -+ n = diff; -+ -+ size = (n + vboxvfsmp->bmask) & ~vboxvfsmp->bmask; -+ if (vboxvfsmp->use_devvp) -+ error = bread(vboxvfsmp->im_devvp, -+ lbn << (vboxvfsmp->bshift - DEV_BSHIFT), -+ size, NOCRED, &bp); -+ else -+ error = bread(vp, lbn, size, NOCRED, &bp); -+ -+ n = min(n, size - bp->b_resid); -+ if (error) { -+ brelse(bp); -+ return (error); -+ } -+ error = uiomove(bp->b_data + on, (int)n, uio); -+ brelse(bp); -+ } while (error == 0 && uio->uio_resid > 0 && n != 0); -+ return (error); -+#endif -+ return (0); - } +- printf("%s: Leave rc=%d\n", __FUNCTION__, rc); ++ printf("%s: Leave rc=%d\n", __FUNCTION__, rc); - static int vboxvfs_write(struct vop_write_args *ap) - { -- return 0; -+ return (0); - } +- return rc; +-} ++ return (rc); ++}; - static int vboxvfs_create(struct vop_create_args *ap) - { -- return 0; -+ return (0); - } + static const char *vboxvfs_opts[] = { +- "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL ++ "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL + }; - static int vboxvfs_remove(struct vop_remove_args *ap) +-static int vboxvfs_mount(struct mount *mp, struct thread *td) ++static int vboxvfs_mount(struct mount *mp) { -- return 0; -+ return (0); - } +- int rc; +- char *pszShare; +- int cbShare, cbOption; +- int uid = 0, gid = 0; +- 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; - static int vboxvfs_rename(struct vop_rename_args *ap) - { -- return 0; -+ return (0); - } +- printf("%s: Enter\n", __FUNCTION__); ++ printf("%s: Enter\n", __FUNCTION__); - static int vboxvfs_link(struct vop_link_args *ap) - { -- return EOPNOTSUPP; -+ return (EOPNOTSUPP); - } +- if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) +- return EOPNOTSUPP; ++ if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) ++ return (EOPNOTSUPP); - static int vboxvfs_symlink(struct vop_symlink_args *ap) - { -- return EOPNOTSUPP; -+ 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); ++ } - static int vboxvfs_mknod(struct vop_mknod_args *ap) - { -- return EOPNOTSUPP; -+ return (EOPNOTSUPP); - } +- 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); - static int vboxvfs_mkdir(struct vop_mkdir_args *ap) - { -- return 0; -+ return (0); - } +- 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; - static int vboxvfs_rmdir(struct vop_rmdir_args *ap) - { -- return 0; -+ return (0); - } -+#if 0 -+struct vboxvfs_uiodir { -+ struct dirent *dirent; -+ u_long *cookies; -+ int ncookies; -+ int acookies; -+ int eofflag; -+}; +- 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; -+static int -+vboxvfs_uiodir(struct vboxvfs_uiodir *uiodir, int de_size, struct uio *uio, long cookie) -+{ -+ if (uiodir->cookies != NULL) { -+ if (++uiodir->acookies > uiodir->ncookies) { -+ uiodir->eofflag = 0; -+ return (-1); -+ } -+ *uiodir->cookies++ = cookie; -+ } -+ -+ if (uio->uio_resid < de_size) { -+ uiodir->eofflag = 0; -+ return (-1); -+ } -+ -+ return (uiomove(uiodir->dirent, de_size, uio)); -+} -+#endif - static int vboxvfs_readdir(struct vop_readdir_args *ap) - { -- return 0; -+#if 0 -+ struct vnode *vp; -+ struct uio *uio; -+ struct dirent dir; -+ struct vboxvfs_node *node; -+ struct vboxvfs_mnt *vboxvfsmp; -+ struct vboxvfs_uiodir uiodir; -+ u_long *cookies = NULL; -+ int ncookies; -+ int error = 0; -+ -+ vp = ap->a_vp; -+ uio = ap->a_uio; -+ node = VTON(vp); -+ vboxvfsmp = node->vboxvfsmp; -+ uiodir.eofflag = 1; -+ -+ if (a->a_ncookies != NULL) { -+ /* -+ * Guess how many entries are needed. If we run out, this -+ * function will be called again and thing will pick up were -+ * it left off. -+ */ -+ ncookies = uio->uio_resid / 8; -+ cookies = malloc(sizeof(u_long) * ncookies, -+ M_TEMP, M_WAITOK); -+ if (cookies == NULL) -+ return (ENOMEM); -+ uiodir.ncookies = ncookies; -+ uiodir.cookies = cookies; -+ uiodir.acookies = 0; -+ } else { -+ uiodir.cookies = NULL; -+ } -+ -+ /* Do up the '.' and '..' entries. Dummy values are -+ * used for the cookies since the offset here is -+ * usually zero, and NFS doesn't like that value -+ */ -+ if (uio->uio_offset == 0) { -+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ -+ dir.d_type = DT_DIR; -+ dir.d_name[0] = '.'; -+ dir.d_name[1] = '\0'; -+ dir.d_namlen = 1; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 1); -+ if (error) -+ goto finished; -+ -+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ -+ dir.d_type = DT_DIR; -+ dir.d_name[0] = '.'; -+ dir.d_name[1] = '.'; -+ dir.d_name[2] = '\0'; -+ dir.d_namlen = 2; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 2); -+ if (error) -+ goto finished; -+ -+ strcpy(&dir.d_name[0], AVG_THEFILE_NAME); -+ dir.d_namlen = strlen(AVG_THEFILE_NAME); -+ dir.d_fileno = AVG_THEFILE_INO; -+ dir.d_type = DT_REG; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 3); -+ if (error) -+ goto finished; -+ } -+ -+finished: -+ -+ /* tell the calling layer whether we need to be called again */ -+ *ap->a_eofflag = uiodir.eofflag; -+ -+ if (error < 0) -+ error = 0; -+ -+ if (ap-g>a_ncookies != NULL) { -+ if (error) -+ free(cookies, M_TEMP); -+ else { -+ *ap->a_ncookies = uiodir.acookies; -+ *ap->a_cookies = cookies; -+ } -+ } -+ -+ return (error); -+#endif -+ return (0); - } +- pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); +- if (!pShFlGlobalInfo) +- return ENOMEM; ++ pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); ++ if (!pShFlGlobalInfo) ++ return ENOMEM; - static int vboxvfs_fsync(struct vop_fsync_args *ap) - { -- return 0; -+ return (0); - } +- 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; - static int vboxvfs_print (struct vop_print_args *ap) - { -- return 0; -+#if 0 -+ struct vnode *vp = ap->a_vp; -+ struct vboxvfs_node *node; -+ -+ node = VTON(vp); -+ printf(" ino %lu, on dev %s", (u_long)node->hash_id, -+ devtoname(node->vboxvfsmp->im_dev)); -+ printf("\n"); -+#endif -+ return (0); - } +- 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); - static int vboxvfs_pathconf (struct vop_pathconf_args *ap) - { -- return 0; -+#if 0 -+ switch (ap->a_name) { -+ case _PC_LINK_MAX: -+ *ap->a_retval = 65535; -+ return (0); -+ case _PC_NAME_MAX: -+ i *ap->a_retval = NAME_MAX; -+ return (0); -+ case _PC_PATH_MAX: -+ *ap->a_retval = PATH_MAX; -+ return (0); -+ case _PC_NO_TRUNC: -+ *ap->a_retval = 1; -+ return (0); -+ default: -+ return (EINVAL); -+ } -+#endif -+ return (0); - } +- rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); +- RTMemFree(pShFlShareName); ++ rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); ++ RTMemFree(pShFlShareName); - static int vboxvfs_strategy (struct vop_strategy_args *ap) - { -- return 0; -+#if 0 -+ struct buf *bp; -+ struct vnode *vp; -+ struct vboxvfs_node *node; -+ struct bufobj *bo; -+ -+ bp = ap->a_bp; -+ vp = ap->a_vp; -+ node = VTON(vp); -+ -+ if (bp->b_blkno == bp->b_lblkno) { -+ bp->b_blkno = bp->b_lblkno << (node->vboxvfsmp->bshift - DEV_BSHIFT); -+ } -+ bo = node->vboxfsmp->im_bo; -+ bp->b_iooffset = dbtob(bp->b_blkno); -+ BO_STRATEGY(bo, bp); -+#endif -+ return (0); - } +- 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); ++ } -+static int -+vboxvfs_bmap(struct vop_bmap_args *ap) -+{ -+#if 0 -+ struct vboxvfs_node *node; -+ -+ node = VTON(ap->a_vp); -+ -+ if (ap->a_bop != NULL) -+ *ap->a_bop = &node->vboxvfsmp->im_devvp->v_bufobj; -+ if (ap->a_bnp == NULL) -+ return (0); -+ if (ap->a_runb) -+ *ap->a_runb = 0; -+ -+ /* Translate logical to physical sector number */ -+ *ap->a_bnp = ap->a_bn << (node->vboxvfsmp->bshift - DEV_BSHIFT); -+ -+ if (ap->a_runp) -+ *ap->a_runp = 0; -+ if (ap->a_runb) -+ *ap->a_runb = 0; -+#endif -+ return (0); -+} -+ -+/* -+ * File specific ioctls. -+ */ - static int vboxvfs_ioctl(struct vop_ioctl_args *ap) - { -- return ENOTTY; -+ printf("%s called\n", __func__); -+ return (ENOTTY); - } +- 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__); - static int vboxvfs_getextattr(struct vop_getextattr_args *ap) - { - return 0; +-} + return (0); - } ++}; - static int vboxvfs_advlock(struct vop_advlock_args *ap) +-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_lookup(struct vop_lookup_args *ap) +-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) { -- return 0; -+#if 0 -+ struct vnode *dvp; -+ struct vnode *tdp = NULL; -+ struct vnode **vpp = ap->a_vpp; -+ struct vboxvfs_node *node; -+ struct vboxvfs_mnt *vboxvfsmp; -+ u_long nameiop; -+ u_long flags; -+ char *nameptr; -+ long namelen; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 18:15:35 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 63217CE8 for ; Wed, 24 Jul 2013 18:15:35 +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 419422359 for ; Wed, 24 Jul 2013 18:15:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6OIFZpQ008018 for ; Wed, 24 Jul 2013 18:15:35 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6OIFZ8O007997 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 18:15:35 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 24 Jul 2013 18:15:35 GMT Message-Id: <201307241815.r6OIFZ8O007997@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: r255120 - soc2013/dpl/head/lib/libz 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, 24 Jul 2013 18:15:35 -0000 Author: dpl Date: Wed Jul 24 18:15:34 2013 New Revision: 255120 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255120 Log: We're heading towards a new design here. We will create a persistent process that will wait for commands passed from the parent, and execute the zlib functions from capability mode there. Added: soc2013/dpl/head/lib/libz/capsicum.c soc2013/dpl/head/lib/libz/capsicum.h Modified: soc2013/dpl/head/lib/libz/crc32.c soc2013/dpl/head/lib/libz/zconf.h soc2013/dpl/head/lib/libz/zutil.h Added: soc2013/dpl/head/lib/libz/capsicum.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libz/capsicum.c Wed Jul 24 18:15:34 2013 (r255120) @@ -0,0 +1,48 @@ +#include "capsicum.h" + +int childpid = 0; +int sv[2]; +int buf[1024]; + +void listenAndServe(); +void setChildSignals(); +void getCommand(); +void sendCommand(int, int *); +int startChild(); + + +int startChild() +{ + if ( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) + return -1; + + if( (childpid = fork()) == -1 ) { + return -1; + } else if (childpid == 0){ + close(STDIN_FILENO); + close(STDERR_FILENO); + listenAndServe(); + } + return 0; +} + +void setChildSignals() +{ + +} + +/* Wait for commands, and execute them */ +void listenAndServe() +{ + setChildSignals(); + while(true) + ; +} + +void sendCommand(int c, int *buf){ + +} + +void getCommand(){ + +} Added: soc2013/dpl/head/lib/libz/capsicum.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libz/capsicum.h Wed Jul 24 18:15:34 2013 (r255120) @@ -0,0 +1,15 @@ +/* + * With Capsicum, we get a compartmentalized, and securer lib. + */ +#if defined(__FreeBSD__) +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# include +# include +# include +# include +# include +# endif +#endif Modified: soc2013/dpl/head/lib/libz/crc32.c ============================================================================== --- soc2013/dpl/head/lib/libz/crc32.c Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/crc32.c Wed Jul 24 18:15:34 2013 (r255120) @@ -37,8 +37,6 @@ # define BYFOUR #endif #ifdef BYFOUR - unsigned long crc32_ OF((unsigned long, - const unsigned char FAR *, uInt)); local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -208,27 +206,6 @@ const unsigned char FAR *buf; uInt len; { - long ret; - #ifdef CAPSICUM - int forkpid; - if ( (forkpid = fork()) == 0 ){ - cap_enter(); - #endif - ret = crc32_(crc, buf, len); - #ifdef CAPSICUM - return ret; - } else if ( forkpid != 0) { - wait(NULL); - } - #endif - return ret; -} - -unsigned long ZEXPORT crc32_(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ if (buf == Z_NULL) return 0UL; #ifdef DYNAMIC_CRC_TABLE Modified: soc2013/dpl/head/lib/libz/zconf.h ============================================================================== --- soc2013/dpl/head/lib/libz/zconf.h Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/zconf.h Wed Jul 24 18:15:34 2013 (r255120) @@ -480,24 +480,12 @@ /* * This is hard-configured for FreeBSD. */ +#include "capsicum.h" #define z_off_t off_t #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif -/* - * With Capsicum, we get a compartmentalized, and securer lib. - */ -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# include -# include -# include -# endif -#endif #ifndef z_off_t # define z_off_t long Modified: soc2013/dpl/head/lib/libz/zutil.h ============================================================================== --- soc2013/dpl/head/lib/libz/zutil.h Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/zutil.h Wed Jul 24 18:15:34 2013 (r255120) @@ -167,19 +167,6 @@ #pragma warn -8066 #endif -/* - * With Capsicum, we get a compartmentalized, and securer lib. - */ -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# include -# include -# include -# endif -#endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 18:16:48 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 2FCD9D24 for ; Wed, 24 Jul 2013 18:16:48 +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 0E1402366 for ; Wed, 24 Jul 2013 18:16: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 r6OIGliq027484 for ; Wed, 24 Jul 2013 18:16:47 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6OIGlCr027474 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 18:16:47 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 24 Jul 2013 18:16:47 GMT Message-Id: <201307241816.r6OIGlCr027474@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: r255121 - soc2013/dpl 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, 24 Jul 2013 18:16:48 -0000 Author: dpl Date: Wed Jul 24 18:16:47 2013 New Revision: 255121 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255121 Log: Here I'm doing a original design. I'm doing it in another file since it's my first time doing something like this. Added: soc2013/dpl/caller.c Modified: soc2013/dpl/functions.c Added: soc2013/dpl/caller.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/caller.c Wed Jul 24 18:16:47 2013 (r255121) @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +int childpid = 0; +int sv[2], buf[1024], i; +int buf[1024]; + +void listenAndServe(); +void setChildSignals(); +void getCommand(); +void sendCommand(int, int *); +void gotIO(int); +int startChild(); + +int +main() +{ + int sv; + if(childpid == 0) + sv = startChild(); + sendCommand(0, buf); + return 0; +} + +int startChild() +{ + int buf[10] = { 0,1, 2, 3, 4, 5, 6, 7, 8, 9 }; + if( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) + return -1; + + if( (childpid = fork()) == -1 ) { + return -1; + } else if (childpid == 0){ + struct pollfd fds[1]; + int buf[1], p; + + cap_rights_limit(STDIN_FILENO, CAP_WRITE); + close(STDIN_FILENO); + close(STDERR_FILENO); + + setChildSignals(); + + fds[0].fd = sv[1]; + fds[0].events = POLLIN; + fds[0].revents = 0; + while( (p = poll(fds, 1, -1)) > 0 ) + printf("Received: %d\n", read(sv[1], buf, sizeof(int))); + printf("Poll has returned: %d\n", p); + } else { + for( i=0; i<10; i++){ + printf("sending: %d\n", buf[i]); + write(sv[0], (void *)buf[i], sizeof(int)); + } + } + return sv[0]; +} + +void setChildSignals() +{ + +} + +/* Wait for commands, and execute them */ +void listenAndServe() +{ + +} + +void sendCommand(int c, int *buf){ + +} + +void getCommand(){ + +} \ No newline at end of file Modified: soc2013/dpl/functions.c ============================================================================== --- soc2013/dpl/functions.c Wed Jul 24 18:15:34 2013 (r255120) +++ soc2013/dpl/functions.c Wed Jul 24 18:16:47 2013 (r255121) @@ -1,23 +1,23 @@ void limitfd(int fd) { - cap_rights_t rights; + cap_rights_t rights; - if (fd == OUT_FILENO) - 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; - else if (fd == STDERR_FILENO) - rights = CAP_WRITE; - else if ( fd == cwd ) - rights = CAP_UNLINKAT|CAP_LOOKUP; - - 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); - } + if (fd == OUT_FILENO) + 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; + else if (fd == STDERR_FILENO) + rights = CAP_WRITE; + else if ( fd == cwd ) + rights = CAP_UNLINKAT|CAP_LOOKUP; + + 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); + } } extern void @@ -49,61 +49,60 @@ int sendfd(int s, int fd) -{ - printf("sendfd sending: %d\n", fd); - struct msghdr msg; - struct cmsghdr *cmsg; - struct iovec io[1]; - char buf[1] = { "!" }; - int ret; - - io[0].iov_base = buf; - io[0].iov_len = 1; - - if( (cmsg = malloc(DATALEN)) == NULL ) - return -1; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = io; - msg.msg_iovlen = 1; - msg.msg_control =cmsg; - msg.msg_controllen = DATALEN; - - cmsg->cmsg_len = DATALEN; - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - *(int *)CMSG_DATA(cmsg) = fd; - if( (ret = sendmsg(s, &msg, 0)) <= 0) - return -1; - free(cmsg); - return 0; +{ + struct msghdr msg; + struct cmsghdr *cmsg; + struct iovec io[1]; + char buf[1] = { "!" }; + int ret; + + io[0].iov_base = buf; + io[0].iov_len = 1; + + if( (cmsg = malloc(DATALEN)) == NULL ) + return -1; + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = io; + msg.msg_iovlen = 1; + msg.msg_control =cmsg; + msg.msg_controllen = DATALEN; + + cmsg->cmsg_len = DATALEN; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + *(int *)CMSG_DATA(cmsg) = fd; + if( (ret = sendmsg(s, &msg, 0)) <= 0) + return -1; + free(cmsg); + return 0; } int recvfd(int s) { - int fd; - struct msghdr msg; - struct cmsghdr cmsg; - char buf[1] = { "!" }; - struct iovec io[1]; - - io[0].iov_base = buf; - io[0].iov_len = 1; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = io; - msg.msg_iovlen = 1; - msg.msg_control = &cmsg; - msg.msg_controllen = DATALEN; - - cmsg.cmsg_len = DATALEN; - cmsg.cmsg_level = SOL_SOCKET; - cmsg.cmsg_type = SCM_RIGHTS; - if(recvmsg(s, &msg, 0) < 0) - return -1; - fd = *(int *)CMSG_DATA(&cmsg); - return 0; + int fd; + struct msghdr msg; + struct cmsghdr cmsg; + char buf[1] = { "!" }; + struct iovec io[1]; + + io[0].iov_base = buf; + io[0].iov_len = 1; + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = io; + msg.msg_iovlen = 1; + msg.msg_control = &cmsg; + msg.msg_controllen = DATALEN; + + cmsg.cmsg_len = DATALEN; + cmsg.cmsg_level = SOL_SOCKET; + cmsg.cmsg_type = SCM_RIGHTS; + if(recvmsg(s, &msg, 0) < 0) + return -1; + fd = *(int *)CMSG_DATA(&cmsg); + return 0; } \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 10:01:20 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 B6F50444 for ; Thu, 25 Jul 2013 10:01:20 +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 A3CF02D12 for ; Thu, 25 Jul 2013 10:01:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PA1KBw055675 for ; Thu, 25 Jul 2013 10:01:20 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PA1KLw055659 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 10:01:20 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 25 Jul 2013 10:01:20 GMT Message-Id: <201307251001.r6PA1KLw055659@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: r255152 - 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: Thu, 25 Jul 2013 10:01:20 -0000 Author: mattbw Date: Thu Jul 25 10:01:20 2013 New Revision: 255152 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255152 Log: (untested) quick runoff of UpdatePackages as a copypaste of InstallPackages Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query/jobs.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Thu Jul 25 09:30:00 2013 (r255151) +++ soc2013/mattbw/backend/Makefile Thu Jul 25 10:01:20 2013 (r255152) @@ -1,3 +1,22 @@ +#- +# 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. + # $FreeBSD$ LIB= pk_backend_pkgng @@ -24,7 +43,8 @@ actions/resolve.c \ actions/search_files.c \ actions/search_groups.c \ - actions/search_names.c + actions/search_names.c \ + actions/update_packages.c SRCS+= \ query/core.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Thu Jul 25 09:30:00 2013 (r255151) +++ soc2013/mattbw/backend/actions.h Thu Jul 25 10:01:20 2013 (r255152) @@ -43,5 +43,7 @@ gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); gboolean simulate_remove_packages_thread(PkBackend *backend); +gboolean simulate_update_packages_thread(PkBackend *backend); +gboolean update_packages_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 25 09:30:00 2013 (r255151) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 25 10:01:20 2013 (r255152) @@ -255,6 +255,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); THREAD(backend, simulate_install_packages_thread); } @@ -265,5 +266,26 @@ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ INTENTIONALLY_IGNORE(autoremove); /* not yet supported */ + assert(backend != NULL); THREAD(backend, simulate_remove_packages_thread); } + +void +pk_backend_simulate_update_packages(PkBackend *backend, gchar **package_ids) +{ + + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); + THREAD(backend, simulate_update_packages_thread); +} + +void +pk_backend_update_packages(PkBackend *backend, gboolean only_trusted, + gchar **package_ids) +{ + + INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + assert(backend != NULL); + THREAD(backend, update_packages_thread); +} Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Thu Jul 25 09:30:00 2013 (r255151) +++ soc2013/mattbw/backend/query/jobs.c Thu Jul 25 10:01:20 2013 (r255152) @@ -155,6 +155,7 @@ pkgutils_emit(pkg, backend, info(pkg)); } + pkg_jobs_free(jobs); query_set_percentage(q, 100); return true; } From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 10:02: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 DBECE46E for ; Thu, 25 Jul 2013 10:02:02 +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 C8B152D1C for ; Thu, 25 Jul 2013 10:02: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 r6PA2281063823 for ; Thu, 25 Jul 2013 10:02:02 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PA22Xs063815 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 10:02:02 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 25 Jul 2013 10:02:02 GMT Message-Id: <201307251002.r6PA22Xs063815@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: r255153 - 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: Thu, 25 Jul 2013 10:02:03 -0000 Author: mattbw Date: Thu Jul 25 10:02:02 2013 New Revision: 255153 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255153 Log: (untested) actually add the update_packages unit Added: soc2013/mattbw/backend/actions/update_packages.c Added: soc2013/mattbw/backend/actions/update_packages.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/update_packages.c Thu Jul 25 10:02:02 2013 (r255153) @@ -0,0 +1,100 @@ +/*- + * 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 /* assert */ +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "../actions.h" /* update_packages_thread prototype */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query.h" /* query_... */ + +static bool job(struct pkg_jobs *jobs, struct query *q); +static bool sim_job(struct pkg_jobs *jobs, struct query *q); + +/* + * The thread that performs an UpdatePackages operation. Should be invoked + * by the pk_backend_update_packages hook. + */ +gboolean +update_packages_thread(PkBackend *backend) +{ + bool success; + + assert(backend != NULL); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * The thread that performs a SimulateUpdatePackages operation. Should be + * invoked by the pk_backend_simulate_update_packages hook. + */ +gboolean +simulate_update_packages_thread(PkBackend *backend) +{ + bool success; + + assert(backend != NULL); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_UPGRADE, sim_job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * Tries to process the given solved installation jobs. + */ +static bool +job(struct pkg_jobs *jobs, struct query *q) +{ + + assert(jobs != NULL); + assert(q != NULL); + + return query_jobs_apply_emitter(jobs, + q, + PK_STATUS_ENUM_UPDATE, + PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); +} + +/* + * Tries to simulate processing the given installation jobs. + */ +static bool +sim_job(struct pkg_jobs *jobs, struct query *q) +{ + + assert(jobs != NULL); + assert(q != NULL); + + return query_jobs_simulate_emitter(jobs, + q, + pkgutils_pkg_install_state); +} From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 11:02: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 296FD151 for ; Thu, 25 Jul 2013 11:02:18 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 08A9220C8 for ; Thu, 25 Jul 2013 11:02:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PB2H2c057951 for ; Thu, 25 Jul 2013 11:02:17 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PB2HvU057947 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 11:02:17 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 25 Jul 2013 11:02:17 GMT Message-Id: <201307251102.r6PB2HvU057947@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: r255155 - soc2013/dpl 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, 25 Jul 2013 11:02:18 -0000 Author: dpl Date: Thu Jul 25 11:02:17 2013 New Revision: 255155 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255155 Log: We now have a working child process that is ready to get commands and send the results. We still have to design the basic protocol, but it will be done reading and writing from/to buf. Modified: soc2013/dpl/caller.c Modified: soc2013/dpl/caller.c ============================================================================== --- soc2013/dpl/caller.c Thu Jul 25 10:29:40 2013 (r255154) +++ soc2013/dpl/caller.c Thu Jul 25 11:02:17 2013 (r255155) @@ -7,76 +7,94 @@ #include #include +#include +#include -int childpid = 0; -int sv[2], buf[1024], i; -int buf[1024]; - -void listenAndServe(); -void setChildSignals(); -void getCommand(); -void sendCommand(int, int *); -void gotIO(int); -int startChild(); +pid_t child = 0; +int sv[2], i; +int buf[32]; + +pid_t startChild(); +void worker(); +void setSignals(); +void waitCommand(); +void * command(); +void killChild(); int main() { - int sv; - if(childpid == 0) - sv = startChild(); - sendCommand(0, buf); + if(child == 0) + child = startChild(); + if(child < 0){ + perror("error"); + exit(1); + } + + atexit(killChild); + printf("buf:\n"); + for( i=0; i<32; ++i){ + printf("%d\t", buf[i]); + if( (i+1) % 8 == 0 ) + printf("\n"); + } return 0; } int startChild() { - int buf[10] = { 0,1, 2, 3, 4, 5, 6, 7, 8, 9 }; + bzero(&buf, sizeof(buf)); if( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) return -1; - if( (childpid = fork()) == -1 ) { + if( (child = fork()) == -1 ) { return -1; - } else if (childpid == 0){ - struct pollfd fds[1]; - int buf[1], p; - - cap_rights_limit(STDIN_FILENO, CAP_WRITE); - close(STDIN_FILENO); - close(STDERR_FILENO); - - setChildSignals(); - - fds[0].fd = sv[1]; - fds[0].events = POLLIN; - fds[0].revents = 0; - while( (p = poll(fds, 1, -1)) > 0 ) - printf("Received: %d\n", read(sv[1], buf, sizeof(int))); - printf("Poll has returned: %d\n", p); - } else { - for( i=0; i<10; i++){ - printf("sending: %d\n", buf[i]); - write(sv[0], (void *)buf[i], sizeof(int)); - } + } else if (child == 0){ + worker(); } - return sv[0]; + return child; } -void setChildSignals() -{ - +void worker(){ + cap_rights_limit(STDIN_FILENO, CAP_WRITE); + close(STDIN_FILENO); + close(STDERR_FILENO); + + waitCommand(); } + /* Wait for commands, and execute them */ -void listenAndServe() +void +waitCommand() { - + int p; + pid_t pid; + struct pollfd fds[1]; + fds[0].fd = sv[1]; + fds[0].events = POLLIN|POLLPRI|POLLOUT; + fds[0].revents = 0; + + while(1) { + if ((p = poll(fds, 1, 0)) > 0){ + if( fds[0].revents & POLLIN || fds[0].revents & POLLPRI){ + read(sv[1], buf, sizeof(buf)); + } else if( fds[0].revents & POLLOUT) { + } + } + } + printf("Child's out of while.\n"); } -void sendCommand(int c, int *buf){ +void * +command(){ + return NULL; } -void getCommand(){ - +void +killChild() +{ + printf("About to kill %d\n", child); + kill(child, SIGINT); } \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 12:07:49 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 4EDBB5CD for ; Thu, 25 Jul 2013 12:07:49 +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 3BBC924C4 for ; Thu, 25 Jul 2013 12:07:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PC7nEX028390 for ; Thu, 25 Jul 2013 12:07:49 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PC7nrG028377 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 12:07:49 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 25 Jul 2013 12:07:49 GMT Message-Id: <201307251207.r6PC7nrG028377@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: r255156 - soc2013/dpl 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, 25 Jul 2013 12:07:49 -0000 Author: dpl Date: Thu Jul 25 12:07:48 2013 New Revision: 255156 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255156 Log: Made some little updates to code to be more explainable. Modified: soc2013/dpl/caller.c Modified: soc2013/dpl/caller.c ============================================================================== --- soc2013/dpl/caller.c Thu Jul 25 11:02:17 2013 (r255155) +++ soc2013/dpl/caller.c Thu Jul 25 12:07:48 2013 (r255156) @@ -12,6 +12,9 @@ pid_t child = 0; int sv[2], i; + +/* commands will live here */ +/* I will malloc it this afternoon */ int buf[32]; pid_t startChild(); @@ -32,12 +35,6 @@ } atexit(killChild); - printf("buf:\n"); - for( i=0; i<32; ++i){ - printf("%d\t", buf[i]); - if( (i+1) % 8 == 0 ) - printf("\n"); - } return 0; } @@ -61,6 +58,8 @@ close(STDERR_FILENO); waitCommand(); + signal( + /* Should we call signal() to exit more cleanly? */ } @@ -76,14 +75,16 @@ fds[0].revents = 0; while(1) { - if ((p = poll(fds, 1, 0)) > 0){ + p = poll(fds, 1, 0); + if (p > 0){ if( fds[0].revents & POLLIN || fds[0].revents & POLLPRI){ + /* Read command */ read(sv[1], buf, sizeof(buf)); } else if( fds[0].revents & POLLOUT) { + /* Write answer */ } } } - printf("Child's out of while.\n"); } @@ -95,6 +96,5 @@ void killChild() { - printf("About to kill %d\n", child); kill(child, SIGINT); } \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 12:51:35 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 33F8EE4E for ; Thu, 25 Jul 2013 12:51:35 +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 1F8FB2709 for ; Thu, 25 Jul 2013 12:51:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PCpYen008759 for ; Thu, 25 Jul 2013 12:51:34 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PCpYps008733 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 12:51:34 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 25 Jul 2013 12:51:34 GMT Message-Id: <201307251251.r6PCpYps008733@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: r255157 - in soc2013/mattbw/backend: . actions 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: Thu, 25 Jul 2013 12:51:35 -0000 Author: mattbw Date: Thu Jul 25 12:51:34 2013 New Revision: 255157 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255157 Log: last two commits accidentally implemented UpdateSystem; moving to rectify; moving out some jobs code that isn't dependent on query in preparation Added: soc2013/mattbw/backend/actions/update_system.c soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/query/jobs.c soc2013/mattbw/backend/query/jobs.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Thu Jul 25 12:07:48 2013 (r255156) +++ soc2013/mattbw/backend/Makefile Thu Jul 25 12:51:34 2013 (r255157) @@ -27,6 +27,7 @@ event.c \ group.c \ group_map.c \ + jobs.c \ licenses.c \ pkgutils.c \ search.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Thu Jul 25 12:07:48 2013 (r255156) +++ soc2013/mattbw/backend/actions.h Thu Jul 25 12:51:34 2013 (r255157) @@ -43,7 +43,7 @@ gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); gboolean simulate_remove_packages_thread(PkBackend *backend); -gboolean simulate_update_packages_thread(PkBackend *backend); -gboolean update_packages_thread(PkBackend *backend); +gboolean simulate_update_system_thread(PkBackend *backend); +gboolean update_system_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Added: soc2013/mattbw/backend/actions/update_system.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/update_system.c Thu Jul 25 12:51:34 2013 (r255157) @@ -0,0 +1,100 @@ +/*- + * 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 /* assert */ +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "../actions.h" /* update_packages_thread prototype */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query.h" /* query_... */ + +static bool job(struct pkg_jobs *jobs, struct query *q); +static bool sim_job(struct pkg_jobs *jobs, struct query *q); + +/* + * The thread that performs an UpdatePackages operation. Should be invoked + * by the pk_backend_update_packages hook. + */ +gboolean +update_packages_thread(PkBackend *backend) +{ + bool success; + + assert(backend != NULL); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * The thread that performs a SimulateUpdatePackages operation. Should be + * invoked by the pk_backend_simulate_update_packages hook. + */ +gboolean +simulate_update_packages_thread(PkBackend *backend) +{ + bool success; + + assert(backend != NULL); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_UPGRADE, sim_job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * Tries to process the given solved installation jobs. + */ +static bool +job(struct pkg_jobs *jobs, struct query *q) +{ + + assert(jobs != NULL); + assert(q != NULL); + + return query_jobs_apply_emitter(jobs, + q, + PK_STATUS_ENUM_UPDATE, + PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); +} + +/* + * Tries to simulate processing the given installation jobs. + */ +static bool +sim_job(struct pkg_jobs *jobs, struct query *q) +{ + + assert(jobs != NULL); + assert(q != NULL); + + return query_jobs_simulate_emitter(jobs, + q, + pkgutils_pkg_install_state); +} Added: soc2013/mattbw/backend/jobs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/jobs.c Thu Jul 25 12:51:34 2013 (r255157) @@ -0,0 +1,46 @@ +/*- + * 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. + */ + +/* Helpers for jobs that don't rely on the query system. */ + +#include /* assert */ +#include "pk-backend.h" /* pk_..., Pk... */ +#include "pkg.h" /* pkg_... */ + +#include "pkgutils.h" /* pkgutils_... */ +#include "jobs.h" /* jobs_... */ + +/* Emits each package queued up in a (solved) job. */ +void +jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, + pkg_info_ptr info) +{ + struct pkg *pkg; + + assert(jobs != NULL); + assert(backend != NULL); + assert(info != NULL); + + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) { + assert(pkg != NULL); + pkgutils_emit(pkg, backend, info(pkg)); + } +} Added: soc2013/mattbw/backend/jobs.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/jobs.h Thu Jul 25 12:51:34 2013 (r255157) @@ -0,0 +1,31 @@ +/*- + * 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_JOBS_H_ +#define _PKGNG_BACKEND_JOBS_H_ + +#include /* gboolean */ +#include "pk-backend.h" /* PkBackend */ + +typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); + +void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); + +#endif /* !_PKGNG_BACKEND_JOBS_H_ */ Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Thu Jul 25 12:07:48 2013 (r255156) +++ soc2013/mattbw/backend/query/jobs.c Thu Jul 25 12:51:34 2013 (r255157) @@ -24,6 +24,7 @@ #include "pkg.h" /* pkg... */ #include "../event.h" /* event_... */ +#include "../jobs.h" /* jobs_... */ #include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* ERR */ #include "core.h" /* query_... */ @@ -139,24 +140,20 @@ pkg_info_ptr info) { PkBackend *backend; - struct pkg *pkg; assert(jobs != NULL); assert(q != NULL); + assert(info != NULL); backend = query_backend(q); assert (backend != NULL); - query_set_percentage(q, 0); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); - pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) { - assert(pkg != NULL); - pkgutils_emit(pkg, backend, info(pkg)); - } + query_set_percentage(q, 0); + STATUS(backend, PK_STATUS_ENUM_RUNNING); + jobs_emit_packages(jobs, backend, info); + query_set_percentage(q, 100); pkg_jobs_free(jobs); - query_set_percentage(q, 100); return true; } Modified: soc2013/mattbw/backend/query/jobs.h ============================================================================== --- soc2013/mattbw/backend/query/jobs.h Thu Jul 25 12:07:48 2013 (r255156) +++ soc2013/mattbw/backend/query/jobs.h Thu Jul 25 12:51:34 2013 (r255157) @@ -23,10 +23,9 @@ #include "pkg.h" /* struct pkg */ +#include "../jobs.h" /* pk_info_ptr */ #include "core.h" /* struct query */ -typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); - bool query_jobs_apply_emitter(struct pkg_jobs *jobs, struct query *q, PkStatusEnum status, PkErrorEnum no_jobs, PkErrorEnum job_failed); bool query_jobs_run(struct query *q, struct pkg *pkg, pkg_jobs_t type, job_emit_ptr f); bool query_jobs_simulate_emitter(struct pkg_jobs *jobs, struct query *q, pkg_info_ptr info); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 13:49:49 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 804E7B3C for ; Thu, 25 Jul 2013 13:49:49 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6CF4E29E4 for ; Thu, 25 Jul 2013 13:49:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PDnmod075413 for ; Thu, 25 Jul 2013 13:49:48 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PDnm24075406 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 13:49:48 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 25 Jul 2013 13:49:48 GMT Message-Id: <201307251349.r6PDnm24075406@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255159 - soc2013/bguan/head/sys/dev/xen/usbfront MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jul 2013 13:49:49 -0000 Author: bguan Date: Thu Jul 25 13:49:48 2013 New Revision: 255159 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255159 Log: debug method device_add_child() in usbfront Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Thu Jul 25 12:43:22 2013 (r255158) +++ soc2013/bguan/head/sys/dev/xen/usbfront/usbfront.c Thu Jul 25 13:49:48 2013 (r255159) @@ -197,6 +197,7 @@ device_printf(dev, "XENHCI halt/start/probe failed err=%d\n", err); goto error; } + printf("[gbdebug-pvusb]device_probe_and_attach successfully.\n"); return (0); error: @@ -315,4 +316,5 @@ devclass_t usbfront_devclass; -DRIVER_MODULE(xusb, xenbusb_front, usbfront_driver, usbfront_devclass, 0, 0); +DRIVER_MODULE(xusb, xenbusb_front, usbfront_driver, usbfront_devclass, 0, 0); +MODULE_DEPEND(xusb, usb, 1, 1, 1); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 13:50:02 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 A2D3DB50 for ; Thu, 25 Jul 2013 13:50:02 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8BC6E29E9 for ; Thu, 25 Jul 2013 13:50: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 r6PDo2Hq078259 for ; Thu, 25 Jul 2013 13:50:02 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PDo221078254 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 13:50:02 GMT (envelope-from bguan@FreeBSD.org) Date: Thu, 25 Jul 2013 13:50:02 GMT Message-Id: <201307251350.r6PDo221078254@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255160 - soc2013/bguan/head/sys/dev/usb/controller 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, 25 Jul 2013 13:50:02 -0000 Author: bguan Date: Thu Jul 25 13:50:02 2013 New Revision: 255160 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255160 Log: add usbus driver to usbfront driver devclass 'xu' in usb_controller.c Modified: soc2013/bguan/head/sys/dev/usb/controller/usb_controller.c Modified: soc2013/bguan/head/sys/dev/usb/controller/usb_controller.c ============================================================================== --- soc2013/bguan/head/sys/dev/usb/controller/usb_controller.c Thu Jul 25 13:49:48 2013 (r255159) +++ soc2013/bguan/head/sys/dev/usb/controller/usb_controller.c Thu Jul 25 13:50:02 2013 (r255160) @@ -129,6 +129,7 @@ DRIVER_MODULE(usbus, uhci, usb_driver, usb_devclass, 0, 0); DRIVER_MODULE(usbus, ehci, usb_driver, usb_devclass, 0, 0); DRIVER_MODULE(usbus, xhci, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, xu, usb_driver, usb_devclass, 0, 0); /* Device Only Drivers */ DRIVER_MODULE(usbus, at91_udp, usb_driver, usb_devclass, 0, 0); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 21:22:46 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 F1797946 for ; Thu, 25 Jul 2013 21:22:45 +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 CF04320E1 for ; Thu, 25 Jul 2013 21:22: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 r6PLMj7R036816 for ; Thu, 25 Jul 2013 21:22:45 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PLMj6Y036807 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 21:22:45 GMT (envelope-from oleksandr@FreeBSD.org) Date: Thu, 25 Jul 2013 21:22:45 GMT Message-Id: <201307252122.r6PLMj6Y036807@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: r255173 - 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: Thu, 25 Jul 2013 21:22:46 -0000 Author: oleksandr Date: Thu Jul 25 21:22:45 2013 New Revision: 255173 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255173 Log: Implemented initial version of vboxvfs_read and vboxvfs_readdir, now correctly working yet 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 Thu Jul 25 20:53:15 2013 (r255172) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Thu Jul 25 21:22:45 2013 (r255173) @@ -452,7 +452,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (working copy) -@@ -21,46 +21,193 @@ +@@ -21,46 +21,200 @@ #define VBOXVFS_VFSNAME "vboxvfs" #define VBOXVFS_VERSION 1 @@ -536,6 +536,10 @@ - long nextino; - int caseopt; - int didrele; ++#define DIRENT_RECLEN(namelen) \ ++ ((offsetof(dirent, d_name[0]) + 1 + (namelen) + 7) & ~ 7) ++#define DIRENT_NAMELEN(reclen) \ ++ ((reclen) - (offsetof(dirent, d_name[0]))) +/* + * representation of an active mount point + */ @@ -587,7 +591,7 @@ + */ +typedef struct sffs_dirents { + struct sffs_dirents *sf_next; -+ unsigned long long int sf_len; ++ long long sf_len; + struct sffs_dirent { + sffs_stat_t sf_stat; + struct dirent sf_entry; /* this is variable length */ @@ -599,7 +603,7 @@ + */ +struct vboxvfs_mnt { + struct mount *sf_vfsp; /* filesystem's vfs struct */ -+ struct vnode *sf_rootnode; /* of vnode of the root directory */ ++ struct vnode *sf_devvp; /* of vnode of the root directory */ + uid_t sf_uid; /* owner of all shared folders */ + gid_t sf_gid; /* group of all shared folders */ + mode_t sf_dmode; /* mode of all directories */ @@ -613,6 +617,9 @@ + sfp_mount_t *sf_handle; + uint64_t sf_ino; /* per FS ino generator */ + off_t size; ++ int bshift; ++ int bmask; ++ struct bufobj *sf_bo; +}; + +/* @@ -673,7 +680,7 @@ struct sf_inode_info { SHFLSTRING *path; int force_restat; -@@ -86,6 +233,86 @@ +@@ -86,6 +240,86 @@ SHFLHANDLE handle; }; @@ -754,8 +761,8 @@ +#define SFFS_DIRENTS_SIZE 8192 +#define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0])) + -+/*extern int sfprov_readdir(sfp_mount_t *mnt, char *path, -+ sffs_dirents_t **dirents); */ ++extern int sfprov_readdir(sfp_mount_t *mnt, char *path, ++ sffs_dirents_t **dirents); + #endif /* KERNEL */ @@ -764,7 +771,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (working copy) -@@ -14,26 +14,28 @@ +@@ -14,27 +14,35 @@ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ @@ -801,9 +808,16 @@ +#include "vboxvfs.h" + /* ++ * For now we'll use an I/O buffer that doesn't page fault for VirtualBox ++ * to transfer data into. ++ */ ++char *vboxvfs_buffer; ++ ++/* * Prototypes for VBOXVFS vnode operations */ -@@ -56,6 +58,7 @@ + static vop_create_t vboxvfs_create; +@@ -56,6 +64,7 @@ static vop_symlink_t vboxvfs_symlink; static vop_readdir_t vboxvfs_readdir; static vop_strategy_t vboxvfs_strategy; @@ -811,10 +825,12 @@ static vop_print_t vboxvfs_print; static vop_pathconf_t vboxvfs_pathconf; static vop_advlock_t vboxvfs_advlock; -@@ -65,177 +68,894 @@ +@@ -64,178 +73,1040 @@ + static vop_getpages_t vboxvfs_getpages; static vop_inactive_t vboxvfs_inactive; static vop_putpages_t vboxvfs_putpages; - static vop_reclaim_t vboxvfs_reclaim; +-static vop_reclaim_t vboxvfs_reclaim; ++static vop_reclaim_t vboxvfs_reclaim; +static vop_vptofh_t vboxvfs_vptofh; struct vop_vector vboxvfs_vnodeops = { @@ -984,6 +1000,34 @@ + np->sf_file = fp; +} + ++/* ++ * get a new vnode reference for an sfnode ++ */ ++#if 0 ++struct vnode * ++vfsnode_get_vnode(struct vboxvfs_node *node) ++{ ++ struct vnode *vp; ++ ++ if (node->sf_vnode != NULL) { ++ vref(node->sf_vnode); ++ } else { ++ vp = vn_alloc(KM_SLEEP); ++ printf(" %s gets vnode 0x%p\n", node->sf_path, vp); ++ vp->v_type = node->sf_type; ++ vp->v_vfsp = node->sf_sffs->sf_vfsp; ++ vn_setops(vp, sffs_ops); ++ vp->v_flag = VNOSWAP; ++#ifndef VBOXVFS_WITH_MMAP ++ vp->v_flag |= VNOMAP; ++#endif ++ vn_exists(vp); ++ vp->v_data = node; ++ node->sf_vnode = vp; ++ } ++ return (node->sf_vnode); ++} ++#endif static int vboxvfs_open(struct vop_open_args *ap) { - return 0; @@ -1275,64 +1319,63 @@ + return (error); } ++#define blkoff(vboxvfsmp, loc) ((loc) & (vboxvfsmp)->bmask) ++ static int vboxvfs_read(struct vop_read_args *ap) { - return 0; -+#if 0 -+ static const int clustersize = MAXBSIZE; -+ -+ struct vnode *vp = ap->a_vp; -+ struct uio *uio = ap->a_uio; -+ struct vboxvfs_node *node = VTON(vp); -+ struct vboxvfs_mnt *vboxvfsmp; -+ struct buf *bp; -+ daddr_t lbn; -+ off_t diff, fsize; -+ int error = 0; -+ long size, n, on; -+ -+ if (uio->uio_resid == 0) -+ return (0); -+ if (uio->uio_offset < 0) -+ return (EINVAL); ++ static const int clustersize = MAXBSIZE; + -+ if (vp->v_type == VCHR || vp->v_type == VBLK) -+ return (EOPNOTSUPP); -+ if (vp->v_type != VREG) -+ return (EINVAL); ++ struct vnode *vp = ap->a_vp; ++ struct uio *uio = ap->a_uio; ++ struct vboxvfs_node *np = VTOVBOXFS(vp); ++ int error = 0; ++ uint32_t bytes; ++ uint32_t done; ++ unsigned long offset; ++ ssize_t total; ++ long on; ++ ++ if (vp->v_type == VDIR) ++ return (EISDIR); ++ if (vp->v_type != VREG) ++ return (EINVAL); ++#if 0 ++ if (uio->uio_loffset >= MAXOFFSET_T) ++ { ++ proc_t *p = ttoproc(curthread); ++ (void) rctl_action(rctlproc_legacy[RLIMIT_FSIZE], p->p_rctls, ++ p, RCA_UNSAFE_SIGINFO); ++ return (EFBIG); ++ } ++ if (uio->uio_loffset < 0) ++ return (EINVAL); ++#endif ++ total = uio->uio_resid; ++ if (total == 0) ++ return (0); + -+ vboxvfsmp = node->vboxvfsmp; -+ fsize = vboxvfsmp->size; ++ vfsnode_open(np); ++ if (np->sf_file == NULL) { ++ return (EINVAL); ++ } + -+ do { -+ lbn = lblkno(vboxvfsmp, uio->uio_offset); -+ on = blkoff(vboxvfsmp, uio->uio_offset); -+ n = min((u_int)(clustersize - on), uio->uio_resid); -+ diff = fsize - uio->uio_offset; -+ if (diff <= 0) -+ return (0); -+ if (diff < n) -+ n = diff; ++ do { ++ offset = uio->uio_offset; ++ on = blkoff(np->vboxvfsmp, uio->uio_offset); ++ done = bytes = min((u_int)(clustersize - on), uio->uio_resid); ++ error = sfprov_read(np->sf_file, vboxvfs_buffer, offset, &done); ++ if (error == 0 && done > 0) ++ error = uiomove(vboxvfs_buffer, done, uio); ++ } while (error == 0 && uio->uio_resid > 0 && done > 0); + -+ size = (n + vboxvfsmp->bmask) & ~vboxvfsmp->bmask; -+ if (vboxvfsmp->use_devvp) -+ error = bread(vboxvfsmp->im_devvp, -+ lbn << (vboxvfsmp->bshift - DEV_BSHIFT), -+ size, NOCRED, &bp); -+ else -+ error = bread(vp, lbn, size, NOCRED, &bp); + -+ n = min(n, size - bp->b_resid); -+ if (error) { -+ brelse(bp); -+ return (error); -+ } -+ error = uiomove(bp->b_data + on, (int)n, uio); -+ brelse(bp); -+ } while (error == 0 && uio->uio_resid > 0 && n != 0); -+ return (error); -+#endif -+ return (0); ++ /* ++ * a partial read is never an error ++ */ ++ if (total != uio->uio_resid) ++ error = 0; ++ return (error); } static int vboxvfs_write(struct vop_write_args *ap) @@ -1419,100 +1462,123 @@ static int vboxvfs_readdir(struct vop_readdir_args *ap) { - return 0; ++ struct vnode *vp = ap->a_vp; ++ struct uio *uio = ap->a_uio; ++ struct vboxvfs_node *dir = VTOVBOXFS(vp); ++ struct vboxvfs_node *node; ++ struct sffs_dirent *dirent = NULL; ++ sffs_dirents_t *cur_buf; ++ off_t offset = 0; ++ off_t orig_off = uio->uio_offset; ++ int error = 0; +#if 0 -+ struct vnode *vp; -+ struct uio *uio; -+ struct dirent dir; -+ struct vboxvfs_node *node; -+ struct vboxvfs_mnt *vboxvfsmp; -+ struct vboxvfs_uiodir uiodir; -+ u_long *cookies = NULL; -+ int ncookies; -+ int error = 0; ++ if (uio->uio_iovcnt != 1) ++ return (EINVAL); + -+ vp = ap->a_vp; -+ uio = ap->a_uio; -+ node = VTON(vp); -+ vboxvfsmp = node->vboxvfsmp; -+ uiodir.eofflag = 1; ++ if (vp->v_type != VDIR) ++ return (ENOTDIR); + -+ if (a->a_ncookies != NULL) { -+ /* -+ * Guess how many entries are needed. If we run out, this -+ * function will be called again and thing will pick up were -+ * it left off. -+ */ -+ ncookies = uio->uio_resid / 8; -+ cookies = malloc(sizeof(u_long) * ncookies, -+ M_TEMP, M_WAITOK); -+ if (cookies == NULL) -+ return (ENOMEM); -+ uiodir.ncookies = ncookies; -+ uiodir.cookies = cookies; -+ uiodir.acookies = 0; -+ } else { -+ uiodir.cookies = NULL; -+ } ++ if (eofp == NULL) ++ eofp = &dummy_eof; ++ *eofp = 0; ++ ++ if (uio->uio_loffset >= MAXOFFSET_T) { ++ *eofp = 1; ++ return (0); ++ } ++#endif ++ /* ++ * Get the directory entry names from the host. This gets all ++ * entries. These are stored in a linked list of sffs_dirents_t ++ * buffers, each of which contains a list of dirent64_t's. ++ */ + -+ /* Do up the '.' and '..' entries. Dummy values are -+ * used for the cookies since the offset here is -+ * usually zero, and NFS doesn't like that value -+ */ -+ if (uio->uio_offset == 0) { -+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ -+ dir.d_type = DT_DIR; -+ dir.d_name[0] = '.'; -+ dir.d_name[1] = '\0'; -+ dir.d_namlen = 1; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 1); -+ if (error) -+ goto finished; -+ -+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */ -+ dir.d_type = DT_DIR; -+ dir.d_name[0] = '.'; -+ dir.d_name[1] = '.'; -+ dir.d_name[2] = '\0'; -+ dir.d_namlen = 2; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 2); -+ if (error) -+ goto finished; -+ -+ strcpy(&dir.d_name[0], AVG_THEFILE_NAME); -+ dir.d_namlen = strlen(AVG_THEFILE_NAME); -+ dir.d_fileno = AVG_THEFILE_INO; -+ dir.d_type = DT_REG; -+ dir.d_reclen = GENERIC_DIRSIZ(&dir); -+ uiodir.dirent = &dir; -+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 3); -+ if (error) -+ goto finished; -+ } -+ -+finished: -+ -+ /* tell the calling layer whether we need to be called again */ -+ *ap->a_eofflag = uiodir.eofflag; -+ -+ if (error < 0) -+ error = 0; -+ -+ if (ap-g>a_ncookies != NULL) { -+ if (error) -+ free(cookies, M_TEMP); -+ else { -+ *ap->a_ncookies = uiodir.acookies; -+ *ap->a_cookies = cookies; -+ } -+ } ++ if (dir->sf_dir_list == NULL) { ++ error = sfprov_readdir(dir->vboxvfsmp->sf_handle, dir->sf_path, ++ &dir->sf_dir_list); ++ if (error != 0) ++ goto done; ++ } + -+ return (error); ++ /* ++ * Validate and skip to the desired offset. ++ */ ++ cur_buf = dir->sf_dir_list; ++ offset = 0; ++ ++ while (cur_buf != NULL && ++ offset + cur_buf->sf_len <= uio->uio_offset) { ++ offset += cur_buf->sf_len; ++ cur_buf = cur_buf->sf_next; ++ } ++ ++ if (cur_buf == NULL && offset != uio->uio_offset) { ++ error = EINVAL; ++ goto done; ++ } ++ if (cur_buf != NULL && offset != uio->uio_offset) { ++ off_t off = offset; ++ int step; ++ dirent = &cur_buf->sf_entries[0]; ++ ++ while (off < uio->uio_offset) { ++ step = sizeof(sffs_stat_t) + dirent->sf_entry.d_reclen; ++ dirent = (struct sffs_dirent *) (((char *) dirent) + step); ++ off += step; ++ } ++ ++ if (off >= uio->uio_offset) { ++ error = EINVAL; ++ goto done; ++ } ++ } ++ ++ offset = uio->uio_offset - offset; ++ ++ /* ++ * Lookup each of the names, so that we have ino's, and copy to ++ * result buffer. ++ */ ++ while (cur_buf != NULL) { ++ if (offset >= cur_buf->sf_len) { ++ cur_buf = cur_buf->sf_next; ++ offset = 0; ++ continue; ++ } ++ ++ dirent = (struct sffs_dirent *) ++ (((char *) &cur_buf->sf_entries[0]) + offset); ++ if (dirent->sf_entry.d_reclen > uio->uio_resid) ++ break; ++ ++ if (strcmp(dirent->sf_entry.d_name, ".") == 0) { ++ node = dir; ++ } else if (strcmp(dirent->sf_entry.d_name, "..") == 0) { ++ node = dir->sf_parent; ++ if (node == NULL) ++ node = dir; ++ } else { ++#if 0 ++ node = sfnode_lookup(dir, dirent->sf_entry.d_name, VNON, ++ 0, &dirent->sf_stat, sfnode_cur_time_usec(), NULL); ++ if (node == NULL) ++ panic("sffs_readdir() lookup failed"); +#endif -+ return (0); ++ } ++ ++ error = uiomove(&dirent->sf_entry, dirent->sf_entry.d_reclen, uio); ++ if (error != 0) ++ break; ++ ++ uio->uio_offset= dirent->sf_entry.d_fileno; ++ offset += sizeof(sffs_stat_t) + dirent->sf_entry.d_reclen; ++ } ++done: ++#if 0 ++ if (error != 0) ++ uio->uio_offset = orig_off; ++#endif ++ return (error); } static int vboxvfs_fsync(struct vop_fsync_args *ap) @@ -1524,15 +1590,19 @@ static int vboxvfs_print (struct vop_print_args *ap) { - return 0; -+#if 0 + struct vnode *vp = ap->a_vp; -+ struct vboxvfs_node *node; ++ struct vboxvfs_node *np; ++ ++ np = VTOVBOXFS(vp); + -+ node = VTON(vp); -+ printf(" ino %lu, on dev %s", (u_long)node->hash_id, -+ devtoname(node->vboxvfsmp->im_dev)); ++ if (np == NULL) { ++ printf("No vboxvfs_node data\n"); ++ return (0); ++ } ++ ++ printf("\tpath = %s, parent = %p", np->sf_path, ++ np->sf_parent ? np->sf_parent : NULL); + printf("\n"); -+#endif + return (0); } @@ -1562,49 +1632,47 @@ static int vboxvfs_strategy (struct vop_strategy_args *ap) { - return 0; -+#if 0 + struct buf *bp; + struct vnode *vp; -+ struct vboxvfs_node *node; ++ struct vboxvfs_node *np; + struct bufobj *bo; + + bp = ap->a_bp; + vp = ap->a_vp; -+ node = VTON(vp); ++ np = VTOVBOXFS(vp); + + if (bp->b_blkno == bp->b_lblkno) { -+ bp->b_blkno = bp->b_lblkno << (node->vboxvfsmp->bshift - DEV_BSHIFT); ++ bp->b_blkno = bp->b_lblkno << (np->vboxvfsmp->bshift - DEV_BSHIFT); + } -+ bo = node->vboxfsmp->im_bo; ++ bo = np->vboxvfsmp->sf_bo; + bp->b_iooffset = dbtob(bp->b_blkno); + BO_STRATEGY(bo, bp); -+#endif + return (0); } +static int +vboxvfs_bmap(struct vop_bmap_args *ap) +{ -+#if 0 -+ struct vboxvfs_node *node; -+ -+ node = VTON(ap->a_vp); ++ struct vnode *vp; ++ struct vboxvfs_node *np; ++ ++ vp = ap->a_vp; ++ np = VTOVBOXFS(vp); + + if (ap->a_bop != NULL) -+ *ap->a_bop = &node->vboxvfsmp->im_devvp->v_bufobj; ++ *ap->a_bop = &np->vboxvfsmp->sf_devvp->v_bufobj; + if (ap->a_bnp == NULL) + return (0); + if (ap->a_runb) + *ap->a_runb = 0; + + /* Translate logical to physical sector number */ -+ *ap->a_bnp = ap->a_bn << (node->vboxvfsmp->bshift - DEV_BSHIFT); ++ *ap->a_bnp = ap->a_bn << (np->vboxvfsmp->bshift - DEV_BSHIFT); + + if (ap->a_runp) + *ap->a_runp = 0; + if (ap->a_runb) + *ap->a_runb = 0; -+#endif + return (0); +} + @@ -1630,83 +1698,179 @@ + return (0); } - static int vboxvfs_lookup(struct vop_lookup_args *ap) - { -- return 0; +-static int vboxvfs_lookup(struct vop_lookup_args *ap) ++/* ++ * Look for a cached node, if not found either handle ".." or try looking ++ * via the provider. Create an entry in sfnodes if found but not cached yet. ++ * If the create flag is set, a file or directory is created. If the file ++ * already existed, an error is returned. ++ * Nodes returned from this routine always have a vnode with its ref count ++ * bumped by 1. ++ */ +#if 0 -+ struct vnode *dvp; -+ struct vnode *tdp = NULL; -+ struct vnode **vpp = ap->a_vpp; -+ struct vboxvfs_node *node; -+ struct vboxvfs_mnt *vboxvfsmp; -+ u_long nameiop; -+ u_long flags; -+ char *nameptr; -+ long namelen; -+ ino_t id = 0; -+ int offset, error = 0; -+ int lkflags, ltype; ++static struct vboxvfs_node * ++vfsnode_lookup( ++ struct vboxvfs_node *dir, ++ char *name, ++ vtype_t create, ++ mode_t c_mode, ++ sffs_stat_t *stat, ++ uint64_t stat_time, ++ int *err) + { +- return 0; ++ avl_index_t where; ++ vboxvfs_node template; ++ vboxvfs_node *node; ++ int error = 0; ++ int type; ++ char *fullpath; ++ sfp_file_t *fp; ++ sffs_stat_t tmp_stat; ++ ++ if (err) ++ *err = error; ++ ++ /* ++ * handle referencing myself ++ */ ++ if (strcmp(name, "") == 0 || strcmp(name, ".") == 0) ++ return (dir); ++ ++ /* ++ * deal with parent ++ */ ++ if (strcmp(name, "..") == 0) ++ return (dir->sf_parent); ++ ++ /* ++ * Look for an existing node. ++ */ ++ fullpath = sfnode_construct_path(dir, name); ++ template.sf_sffs = dir->sf_sffs; ++ template.sf_path = fullpath; ++ template.sf_is_stale = 0; ++ node = avl_find(&sfnodes, &template, &where); ++ if (node != NULL) { ++ free(fullpath, M_VBOXVFS); ++ if (create != VNON) ++ return (NULL); ++ return (node); ++ } + ++ /* ++ * No entry for this path currently. ++ * Check if the file exists with the provider and get the type from ++ * there. ++ */ ++ if (create == VREG) { ++ type = VREG; ++ stat = &tmp_stat; ++ error = sfprov_create(dir->sf_sffs->sf_handle, fullpath, c_mode, ++ &fp, stat); ++ stat_time = sfnode_cur_time_usec(); ++ } else if (create == VDIR) { ++ type = VDIR; ++ stat = &tmp_stat; ++ error = sfprov_mkdir(dir->sf_sffs->sf_handle, fullpath, c_mode, ++ &fp, stat); ++ stat_time = sfnode_cur_time_usec(); ++ } else { ++ mode_t m; ++ fp = NULL; ++ type = VNON; ++ if (stat == NULL) { ++ stat = &tmp_stat; ++ error = sfprov_get_attr(dir->sf_sffs->sf_handle, ++ fullpath, stat); ++ stat_time = sfnode_cur_time_usec(); ++ } else { ++ error = 0; ++ } ++ m = stat->sf_mode; ++ if (error != 0) ++ error = ENOENT; ++ else if (S_ISDIR(m)) ++ type = VDIR; ++ else if (S_ISREG(m)) ++ type = VREG; ++ else if (S_ISLNK(m)) ++ type = VLNK; ++ } ++ ++ if (err) ++ *err = error; ++ ++ /* ++ * If no errors, make a new node and return it. ++ */ ++ if (error) { ++ kmem_free(fullpath, strlen(fullpath) + 1); ++ return (NULL); ++ } ++ node = sfnode_make(dir->sf_sffs, fullpath, type, fp, dir, stat, ++ stat_time); ++ return (node); + } ++#endif ++ ++static int vboxvfs_lookup(struct vop_lookup_args /* { ++ struct vnodeop_desc *a_desc; ++ struct vnode *a_dvp; ++ struct vnode **a_vpp; ++ struct componentname *a_cnp; ++ } */ *ap) ++{ ++#if 0 ++ struct componentname *cnp = ap->a_cnp; ++ struct vnode *dvp; ++ struct vnode *vpp; ++ struct vboxvfs_node *np; ++ char *name = cnp->cn_nameptr; ++ int error; + + dvp = ap->a_dvp; -+ node = VTON(dvp); -+ vboxvfsmp = node->vboxvfsmp; -+ nameiop = ap->a_cnp->cn_nameiop; -+ flags = ap->a_cnp->cn_flags; -+ lkflags = ap->a_cnp->cn_lkflags; -+ nameptr = ap->a_cnp->cn_nameptr; -+ namelen = ap->a_cnp->cn_namelen; ++ vpp = ap->a_vvp; + -+ offset = 0; ++ /* ++ * dvp must be a directory ++ */ ++ if (dvp->v_type != VDIR) ++ return (ENOTDIR); + -+ if (strcmp(nameptr, AVG_THEFILE_NAME) == 0) -+ id = AVG_THEFILE_INO; -+ else if (flags & ISDOTDOT) -+ id = AVG_ROOTDIR_INO; -+ -+ /* Did we have a match? */ -+ if (id) { -+ if (flags & ISDOTDOT) { -+ error = vn_vget_ino(dvp, id, lkflags, &tdp); -+ } else if (node->hash_id == id) { -+ VREF(dvp); /* we want ourself, ie "." */ -+ /* -+ * When we lookup "." we still can be asked to lock it -+ * differently. -+ */ -+ ltype = lkflags & LK_TYPE_MASK; -+ if (ltype != VOP_ISLOCKED(dvp)) { -+ if (ltype == LK_EXCLUSIVE) -+ vn_lock(dvp, LK_UPGRADE | LK_RETRY); -+ else /* if (ltype == LK_SHARED) */ -+ vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); -+ } -+ tdp = dvp; -+ } else -+ error = vboxvfs_vget(vboxvfsmp->im_mountp, id, lkflags, &tdp); -+ if (!error) { -+ *vpp = tdp; -+ /* Put this entry in the cache */ -+ if (flags & MAKEENTRY) -+ cache_enter(dvp, *vpp, ap->a_cnp); -+ } -+ } else { -+ /* Enter name into cache as non-existant */ -+ if (flags & MAKEENTRY) -+ cache_enter(dvp, *vpp, ap->a_cnp); -+ -+ if ((flags & ISLASTCN) && -+ (nameiop == CREATE || nameiop == RENAME)) { -+ error = EROFS; -+ } else { -+ error = ENOENT; -+ } -+ } ++ /* ++ * An empty component name or just "." means the directory itself. ++ * Don't do any further lookup or checking. ++ */ ++ if (strcmp(name, "") == 0 || strcmp(name, ".") == 0) { ++ vref(dvp); ++ *vpp = dvp; ++ return (0); ++ } ++ ++ /* ++ * Check permission to look at this directory. We always allow "..". ++ */ ++ ++ if (strcmp(nameiop, "..") != 0) { ++ error = vfsnode_access(VN2SFN(dvp), VEXEC, cred); ++ if (error) { ++ return (error); ++ } ++ } ++ ++ /* ++ * Lookup the node. ++ */ ++ np = vfsnode_lookup(VTOVBOXFS(dvp), name, VNON, 0, NULL, 0, NULL); ++ if (node != NULL) ++ *vpp = vfsnode_get_vnode(np); ++ return ((np == NULL) ? ENOENT : 0); + -+ return (error); +#endif + return (0); - } - ++} ++ static int vboxvfs_inactive(struct vop_inactive_args *ap) { - return 0; @@ -1716,24 +1880,22 @@ static int vboxvfs_reclaim(struct vop_reclaim_args *ap) { - return 0; -+#if 0 + struct vnode *vp; -+ struct vboxvfs_node *unode; ++ struct vboxvfs_node *np; + + vp = ap->a_vp; -+ unode = VTON(vp); ++ np = VTOVBOXFS(vp); + + /* + * Destroy the vm object and flush associated pages. + */ + vnode_destroy_vobject(vp); + -+ if (unode != NULL) { ++ if (np != NULL) { + vfs_hash_remove(vp); -+ free(unode, M_AVGFS); ++ free(np, M_VBOXVFS); + vp->v_data = NULL; + } -+#endif + return (0); } @@ -1787,7 +1949,7 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c (revision 0) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c (working copy) -@@ -0,0 +1,1010 @@ +@@ -0,0 +1,1009 @@ +/** @file + * VirtualBox File System for FreeBSD Guests, provider implementation. + * Portions contributed by: Ronald. @@ -1821,6 +1983,7 @@ +#include +#include +#include ++#include +#include +#include +#include @@ -2653,7 +2816,6 @@ + * for each dirent, all fields except the d_ino will be set appropriately. + * The caller is responsible for freeing the dirents buffer. + */ -+#if 0 +int +sfprov_readdir( + sfp_mount_t *mnt, @@ -2745,7 +2907,7 @@ + */ + for (info = infobuff; (char *) info < (char *) infobuff + numbytes; nents--) { + /* expand buffers if we need more space */ -+ reclen = DIRENT64_RECLEN(strlen(info->name.String.utf8)); ++ reclen = DIRENT_RECLEN(strlen(info->name.String.utf8)); + entlen = sizeof(sffs_stat_t) + reclen; + if (SFFS_DIRENTS_OFF + cur_buf->sf_len + entlen > SFFS_DIRENTS_SIZE) { + cur_buf->sf_next = malloc(SFFS_DIRENTS_SIZE, M_VBOXVFS, M_WAITOK | M_ZERO); @@ -2761,7 +2923,7 @@ + /* create the dirent with the name, offset, and len */ + dirent = (struct sffs_dirent *) + (((char *) &cur_buf->sf_entries[0]) + cur_buf->sf_len); -+ strncpy(&dirent->sf_entry.d_name[0], info->name.String.utf8, DIRENT64_NAMELEN(reclen)); ++ strncpy(&dirent->sf_entry.d_name[0], info->name.String.utf8, DIRENT_NAMELEN(reclen)); + dirent->sf_entry.d_reclen = reclen; + offset += entlen; + dirent->sf_entry.d_off = offset; @@ -2774,8 +2936,8 @@ + size = offsetof (SHFLDIRINFO, name.String) + info->name.u16Size; + info = (SHFLDIRINFO *) ((uintptr_t) info + size); + } -+ ASSERT(nents == 0); -+ ASSERT((char *) info == (char *) infobuff + numbytes); ++ CTASSERT(nents == 0); ++ CTASSERT((char *) info == (char *) infobuff + numbytes); + + if (error == VERR_NO_MORE_FILES) + break; @@ -2797,7 +2959,6 @@ + sfprov_close(fp); + return (error); +} -+#endif Index: src/VBox/Additions/freebsd/Makefile.kmk =================================================================== --- src/VBox/Additions/freebsd/Makefile.kmk (revision 4) @@ -2811,3 +2972,16 @@ include $(PATH_SUB_CURRENT)/drm/Makefile.kmk # +Index: src/VBox/Additions/solaris/SharedFolders/vboxfs_vnode.c +=================================================================== +--- src/VBox/Additions/solaris/SharedFolders/vboxfs_vnode.c (revision 4) ++++ src/VBox/Additions/solaris/SharedFolders/vboxfs_vnode.c (working copy) +@@ -2367,7 +2367,7 @@ + VOPNAME_LOOKUP, { .vop_lookup = sffs_lookup }, + VOPNAME_MKDIR, { .vop_mkdir = sffs_mkdir }, + VOPNAME_OPEN, { .vop_open = sffs_open }, +- VOPNAME_PATHCONF, { .vop_pathconf = sffs_pathconf }, ++ VOPNAME_PATHCONF, { .vop_pathconf = sffs_athconf }, + VOPNAME_READ, { .vop_read = sffs_read }, + VOPNAME_READDIR, { .vop_readdir = sffs_readdir }, + VOPNAME_READLINK, { .vop_readlink = sffs_readlink }, From owner-svn-soc-all@FreeBSD.ORG Sat Jul 27 20:11:11 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 33CF77E1 for ; Sat, 27 Jul 2013 20:11:11 +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 1F42B2321 for ; Sat, 27 Jul 2013 20:11:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6RKBAv3073159 for ; Sat, 27 Jul 2013 20:11:10 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6RKBA3W073134 for svn-soc-all@FreeBSD.org; Sat, 27 Jul 2013 20:11:10 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 27 Jul 2013 20:11:10 GMT Message-Id: <201307272011.r6RKBA3W073134@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: r255231 - in soc2013/mattbw/backend: . actions 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: Sat, 27 Jul 2013 20:11:11 -0000 Author: mattbw Date: Sat Jul 27 20:11:10 2013 New Revision: 255231 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255231 Log: Move jobs and do more work on UpdateSystem. Applying and emitting jobs is now part of the jobs.h file, with the query functions merely wrapping this in PackageKit status updates. This is in preparation for UpdateSystem which does not need to use query, and possibly for the rest of the jobs-based actions if a way of doing jobs without them arises. UpdateSystem needs to be renamed at the C source level to upgrade_system before PackageKit will find it (weird!) so this remains unfinished and untested. Modified: soc2013/mattbw/backend/actions/update_system.c soc2013/mattbw/backend/jobs.c soc2013/mattbw/backend/jobs.h soc2013/mattbw/backend/query/jobs.c Modified: soc2013/mattbw/backend/actions/update_system.c ============================================================================== --- soc2013/mattbw/backend/actions/update_system.c Sat Jul 27 19:57:20 2013 (r255230) +++ soc2013/mattbw/backend/actions/update_system.c Sat Jul 27 20:11:10 2013 (r255231) @@ -24,77 +24,72 @@ #include "../pk-backend.h" /* pk..., Pk... */ #include "pkg.h" /* pkg... */ -#include "../actions.h" /* update_packages_thread prototype */ +#include "../actions.h" /* update_system_thread prototype */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query.h" /* query_... */ +#include "../jobs.h" /* jobs_... */ -static bool job(struct pkg_jobs *jobs, struct query *q); -static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static gboolean update_system(PkBackend *backend, bool simulate); /* - * The thread that performs an UpdatePackages operation. Should be invoked - * by the pk_backend_update_packages hook. + * The thread that performs an UpdateSystem operation. Should be invoked + * by the pk_backend_update_system hook. */ gboolean -update_packages_thread(PkBackend *backend) +update_system_thread(PkBackend *backend) { - bool success; - assert(backend != NULL); + return update_system(backend, false); +} - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); +gboolean +simulate_update_system_thread(PkBackend *backend) +{ - (void)pk_backend_finished(backend); - return success ? TRUE : FALSE; + return update_system(backend, true); } -/* - * The thread that performs a SimulateUpdatePackages operation. Should be - * invoked by the pk_backend_simulate_update_packages hook. - */ -gboolean -simulate_update_packages_thread(PkBackend *backend) +static gboolean +update_system(PkBackend *backend, bool simulate) { bool success; + struct pkgdb *db; + struct pkg_jobs *jobs; assert(backend != NULL); - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_UPGRADE, sim_job); + db = db_open_remote(backend); + if (db == NULL) + goto cleanup; + + /* UpdateSystem is a job with no packages, so there's no need to use + * the full query approach. + */ + jobs = NULL; + if (pkg_jobs_new(&jobs, type, db) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (pkg_jobs_solve(jobs) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + goto cleanup; + } + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); + + if (simulate) { + success = true; + jobs_emit_packages(jobs, backend, + pkgutils_pkg_install_state); + } else + success = jobs_apply(jobs, backend, + PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); +cleanup: (void)pk_backend_finished(backend); return success ? TRUE : FALSE; } - -/* - * Tries to process the given solved installation jobs. - */ -static bool -job(struct pkg_jobs *jobs, struct query *q) -{ - - assert(jobs != NULL); - assert(q != NULL); - - return query_jobs_apply_emitter(jobs, - q, - PK_STATUS_ENUM_UPDATE, - PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); -} - -/* - * Tries to simulate processing the given installation jobs. - */ -static bool -sim_job(struct pkg_jobs *jobs, struct query *q) -{ - - assert(jobs != NULL); - assert(q != NULL); - - return query_jobs_simulate_emitter(jobs, - q, - pkgutils_pkg_install_state); -} Modified: soc2013/mattbw/backend/jobs.c ============================================================================== --- soc2013/mattbw/backend/jobs.c Sat Jul 27 19:57:20 2013 (r255230) +++ soc2013/mattbw/backend/jobs.c Sat Jul 27 20:11:10 2013 (r255231) @@ -21,9 +21,12 @@ /* Helpers for jobs that don't rely on the query system. */ #include /* assert */ +#include /* bool, true, false */ #include "pk-backend.h" /* pk_..., Pk... */ #include "pkg.h" /* pkg_... */ +#include "event.h" /* event_cb */ +#include "utils.h" /* ERR */ #include "pkgutils.h" /* pkgutils_... */ #include "jobs.h" /* jobs_... */ @@ -44,3 +47,27 @@ pkgutils_emit(pkg, backend, info(pkg)); } } + +/* Applies a job with the given error enums and the standard event callback. */ +bool +jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, + PkErrorEnum no_jobs, PkErrorEnum job_failed) +{ + bool success; + + success = false; + assert(backend != NULL); + + pkg_event_register(event_cb, backend); + + if (pkg_jobs_count(jobs) == 0) + ERR(backend, no_jobs, "nothing to do"); + else if (pkg_jobs_apply(jobs) != EPKG_OK) + ERR(backend, job_failed, "job failed"); + else + success = true; + + pkg_event_register(NULL, NULL); + + return success; +} Modified: soc2013/mattbw/backend/jobs.h ============================================================================== --- soc2013/mattbw/backend/jobs.h Sat Jul 27 19:57:20 2013 (r255230) +++ soc2013/mattbw/backend/jobs.h Sat Jul 27 20:11:10 2013 (r255231) @@ -21,11 +21,12 @@ #ifndef _PKGNG_BACKEND_JOBS_H_ #define _PKGNG_BACKEND_JOBS_H_ -#include /* gboolean */ +#include /* bool */ #include "pk-backend.h" /* PkBackend */ typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info); +bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum no_jobs, PkErrorEnum job_failed); #endif /* !_PKGNG_BACKEND_JOBS_H_ */ Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Sat Jul 27 19:57:20 2013 (r255230) +++ soc2013/mattbw/backend/query/jobs.c Sat Jul 27 20:11:10 2013 (r255231) @@ -46,25 +46,14 @@ assert(jobs != NULL); assert(q != NULL); - success = false; - backend = query_backend(q); - assert(backend != NULL); - - query_set_percentage(q, 0); - - pkg_event_register(event_cb, backend); - (void)pk_backend_set_status(backend, status); - if (pkg_jobs_count(jobs) == 0) - ERR(backend, no_jobs, "nothing to do"); - else if (pkg_jobs_apply(jobs) != EPKG_OK) - ERR(backend, job_failed, "job failed"); - else - success = true; + STATUS(backend, status); - pkg_event_register(NULL, NULL); + query_set_percentage(q, 0); + success = jobs_apply(jobs, backend, no_jobs, job_failed); query_set_percentage(q, 100); + return success; } From owner-svn-soc-all@FreeBSD.ORG Sat Jul 27 21:10: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 AE71DEA5 for ; Sat, 27 Jul 2013 21:10:31 +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 957EE256C for ; Sat, 27 Jul 2013 21:10: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 r6RLAVvV010049 for ; Sat, 27 Jul 2013 21:10:31 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6RLAVQs010037 for svn-soc-all@FreeBSD.org; Sat, 27 Jul 2013 21:10:31 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 27 Jul 2013 21:10:31 GMT Message-Id: <201307272110.r6RLAVQs010037@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: r255234 - soc2013/dpl 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, 27 Jul 2013 21:10:31 -0000 Author: dpl Date: Sat Jul 27 21:10:31 2013 New Revision: 255234 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255234 Log: This toy implementation it's almost working. There's only a problem when reading back from buf[] the return value of sum_(). Modified: soc2013/dpl/caller.c Modified: soc2013/dpl/caller.c ============================================================================== --- soc2013/dpl/caller.c Sat Jul 27 20:47:01 2013 (r255233) +++ soc2013/dpl/caller.c Sat Jul 27 21:10:31 2013 (r255234) @@ -10,87 +10,127 @@ #include #include + +struct pollfd fdread[1], fdwrite[1]; pid_t child = 0; int sv[2], i; -/* commands will live here */ -/* I will malloc it this afternoon */ -int buf[32]; +int *buf[32]; pid_t startChild(); -void worker(); -void setSignals(); void waitCommand(); -void * command(); void killChild(); +/* Toy lib */ +int sum(int a); +int sum_(int a); + int main() { - if(child == 0) - child = startChild(); - if(child < 0){ - perror("error"); - exit(1); - } - + int ret, a = 1; + ret = sum(a); + fflush(stdout); + printf("ret: %d (should be 2)\n", ret); + fflush(stdout); + atexit(killChild); return 0; } -int startChild() +int sum(int a) { - bzero(&buf, sizeof(buf)); - if( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) - return -1; - - if( (child = fork()) == -1 ) { - return -1; - } else if (child == 0){ - worker(); + /* Caller overhead */ + /* Much better if we do this in a function */ + int ptr = (int)sum_; + fdwrite[0].fd = sv[0]; + fdwrite[0].events = POLLOUT; + fdwrite[0].revents = 0; + fdread[0].fd = sv[0]; + fdread[0].events = POLLIN|POLLPRI; + fdread[0].revents = 0; + if( child == 0) + startChild(); + + /* Real stuff */ + buf[0] = &ptr; + buf[1] = &a; + + /* Should be in a function as well */ + /* sendAndWait() (?) */ + while(1){ + if(poll(fdwrite, 1, 0) > 0 ){ + write(sv[0], buf, sizeof(buf)); + break; + } } - return child; + /* Here, the stuff gets done in child. */ + while(1){ + if(poll(fdread, 1, 0) > 0 ){ + read(sv[0], buf, sizeof(buf)); + break; + } + } + printf("done: %d\n", *buf[0]); + + return *buf[0]; } -void worker(){ - cap_rights_limit(STDIN_FILENO, CAP_WRITE); - close(STDIN_FILENO); - close(STDERR_FILENO); - - waitCommand(); - signal( - /* Should we call signal() to exit more cleanly? */ +int sum_(int a) +{ + return ++a; } +int startChild() +{ + socketpair(PF_LOCAL, SOCK_STREAM, 0, sv); + if( (child = fork()) == 0 ){ + cap_rights_limit(STDOUT_FILENO, CAP_WRITE); + close(STDIN_FILENO); + close(STDERR_FILENO); + cap_enter(); + waitCommand(); + } + + return child; +} /* Wait for commands, and execute them */ void waitCommand() { - int p; - pid_t pid; - struct pollfd fds[1]; - fds[0].fd = sv[1]; - fds[0].events = POLLIN|POLLPRI|POLLOUT; - fds[0].revents = 0; - + struct pollfd fdread[1], fdwrite[1]; + fdread[0].fd = sv[1]; + fdread[0].events = POLLIN|POLLPRI; + fdread[0].revents = 0; + fdwrite[0].fd = sv[1]; + fdwrite[0].events = POLLOUT; + fdwrite[0].revents = 0; while(1) { - p = poll(fds, 1, 0); - if (p > 0){ - if( fds[0].revents & POLLIN || fds[0].revents & POLLPRI){ - /* Read command */ - read(sv[1], buf, sizeof(buf)); - } else if( fds[0].revents & POLLOUT) { - /* Write answer */ + while(1){ + if( poll(fdread, 1, 0) > 0){ + read(sv[1], buf, sizeof(buf)); + break; } } - } -} + if( (void *)*buf[0] == (void *) sum_ ){ + /* This is a C exercise }:-) */ + int ret = ((int (*) (int)) *buf[0])(*buf[1]); + /* int ret = sum_(*buf[1]); */ + printf("ret:%d\n", ret); + fflush(stdout); + bzero(&buf, sizeof(buf)); + buf[0] = &ret; + } -void * -command(){ - return NULL; + while(1) { + if (poll(fdwrite, 1, 0) > 0){ + write(sv[1], buf, sizeof(buf)); + break; + } + } + } } void From owner-svn-soc-all@FreeBSD.ORG Sat Jul 27 23:47:35 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 B267F808 for ; Sat, 27 Jul 2013 23:47:35 +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 9CA32295A for ; Sat, 27 Jul 2013 23:47:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6RNlZHx087649 for ; Sat, 27 Jul 2013 23:47:35 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6RNlZYk087639 for svn-soc-all@FreeBSD.org; Sat, 27 Jul 2013 23:47:35 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 27 Jul 2013 23:47:35 GMT Message-Id: <201307272347.r6RNlZYk087639@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: r255240 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2013 23:47:35 -0000 Author: mattbw Date: Sat Jul 27 23:47:35 2013 New Revision: 255240 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255240 Log: (Untested) Implement UpdateSystem. UpdateSystem can't yet be said to do anything other than proceed to install at the moment, as the lack of decent error reporting means that it is just failing with a flat "couldn't install packages". It is, however, now properly plumbed in and available through `pkcon update`. Next: UpdatePackages, hopefully. Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/actions/update_system.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 27 22:44:55 2013 (r255239) +++ soc2013/mattbw/backend/Makefile Sat Jul 27 23:47:35 2013 (r255240) @@ -45,7 +45,7 @@ actions/search_files.c \ actions/search_groups.c \ actions/search_names.c \ - actions/update_packages.c + actions/update_system.c SRCS+= \ query/core.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Sat Jul 27 22:44:55 2013 (r255239) +++ soc2013/mattbw/backend/actions.h Sat Jul 27 23:47:35 2013 (r255240) @@ -43,7 +43,6 @@ gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); gboolean simulate_remove_packages_thread(PkBackend *backend); -gboolean simulate_update_system_thread(PkBackend *backend); gboolean update_system_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/update_system.c ============================================================================== --- soc2013/mattbw/backend/actions/update_system.c Sat Jul 27 22:44:55 2013 (r255239) +++ soc2013/mattbw/backend/actions/update_system.c Sat Jul 27 23:47:35 2013 (r255240) @@ -25,11 +25,11 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* update_system_thread prototype */ +#include "../db.h" /* db_open_remote */ +#include "../utils.h" /* ERR */ #include "../pkgutils.h" /* pkgutils_... */ #include "../jobs.h" /* jobs_... */ -static gboolean update_system(PkBackend *backend, bool simulate); - /* * The thread that performs an UpdateSystem operation. Should be invoked * by the pk_backend_update_system hook. @@ -37,26 +37,14 @@ gboolean update_system_thread(PkBackend *backend) { - - return update_system(backend, false); -} - -gboolean -simulate_update_system_thread(PkBackend *backend) -{ - - return update_system(backend, true); -} - -static gboolean -update_system(PkBackend *backend, bool simulate) -{ bool success; struct pkgdb *db; struct pkg_jobs *jobs; assert(backend != NULL); + success = false; + db = db_open_remote(backend); if (db == NULL) goto cleanup; @@ -65,7 +53,7 @@ * the full query approach. */ jobs = NULL; - if (pkg_jobs_new(&jobs, type, db) != EPKG_OK) { + if (pkg_jobs_new(&jobs, PKG_JOBS_UPGRADE, db) != EPKG_OK) { ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not init pkg_jobs"); @@ -80,14 +68,9 @@ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); - if (simulate) { - success = true; - jobs_emit_packages(jobs, backend, - pkgutils_pkg_install_state); - } else - success = jobs_apply(jobs, backend, - PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); + success = jobs_apply(jobs, backend, + PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); cleanup: (void)pk_backend_finished(backend); Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 27 22:44:55 2013 (r255239) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 27 23:47:35 2013 (r255240) @@ -270,6 +270,8 @@ THREAD(backend, simulate_remove_packages_thread); } +#if 0 + void pk_backend_simulate_update_packages(PkBackend *backend, gchar **package_ids) { @@ -289,3 +291,14 @@ assert(backend != NULL); THREAD(backend, update_packages_thread); } + +#endif + +void +pk_backend_update_system(PkBackend *backend, gboolean only_trusted) +{ + + INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ + assert(backend != NULL); + THREAD(backend, update_system_thread); +}