From owner-svn-src-projects@FreeBSD.ORG Fri Oct 11 22:19:47 2013 Return-Path: Delivered-To: svn-src-projects@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 7FAF5A4D; Fri, 11 Oct 2013 22:19:47 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5C677281E; Fri, 11 Oct 2013 22:19:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9BMJlCi051579; Fri, 11 Oct 2013 22:19:47 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9BMJksP051570; Fri, 11 Oct 2013 22:19:46 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201310112219.r9BMJksP051570@svn.freebsd.org> From: Alan Somers Date: Fri, 11 Oct 2013 22:19:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256356 - projects/zfsd/head/cddl/sbin/zfsd X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Oct 2013 22:19:47 -0000 Author: asomers Date: Fri Oct 11 22:19:45 2013 New Revision: 256356 URL: http://svnweb.freebsd.org/changeset/base/256356 Log: General cleanup to facilitate unit testing. The unit tests will be committed separately. cddl/sbin/zfsd/zfsd.cc cddl/sbin/zfsd/zfsd_main.cc cddl/sbin/zfsd/Makefile Split main() into a separate file. cddl/sbin/zfsd/callout.cc cddl/sbin/zfsd/zfsd_exception.h cddl/sbin/zfsd/zfsd_exception.cc Removed dead code and de-inlined functions. Submitted by: alans Approved by: ken (mentor) Sponsored by: Spectra Logic Corporation Added: projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc Modified: projects/zfsd/head/cddl/sbin/zfsd/Makefile projects/zfsd/head/cddl/sbin/zfsd/callout.cc projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h Modified: projects/zfsd/head/cddl/sbin/zfsd/Makefile ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/Makefile Fri Oct 11 22:00:54 2013 (r256355) +++ projects/zfsd/head/cddl/sbin/zfsd/Makefile Fri Oct 11 22:19:45 2013 (r256356) @@ -8,7 +8,8 @@ SRCS= callout.cc \ vdev_iterator.cc \ zfsd.cc \ zfsd_exception.cc \ - zpool_list.cc + zpool_list.cc \ + zfsd_main.cc NO_MAN= YES Modified: projects/zfsd/head/cddl/sbin/zfsd/callout.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/callout.cc Fri Oct 11 22:00:54 2013 (r256355) +++ projects/zfsd/head/cddl/sbin/zfsd/callout.cc Fri Oct 11 22:19:45 2013 (r256356) @@ -53,7 +53,7 @@ Callout::Init() signal(SIGALRM, Callout::AlarmSignalHandler); } -inline bool +bool Callout::Stop() { if (!IsPending()) Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 22:00:54 2013 (r256355) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 22:19:45 2013 (r256356) @@ -61,7 +61,6 @@ #include #include #include -#include #include #include @@ -683,33 +682,4 @@ ZfsDaemon::EventLoop() } } -/*=============================== Program Main ===============================*/ -static void -usage() -{ - fprintf(stderr, "usage: %s [-d]\n", getprogname()); - exit(1); -} - -/** - * Program entry point. - */ -int -main(int argc, char **argv) -{ - int ch; - while ((ch = getopt(argc, argv, "d")) != -1) { - switch (ch) { - case 'd': - g_debug++; - break; - default: - usage(); - } - } - - ZfsDaemon::Run(); - - return (0); -} Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc Fri Oct 11 22:00:54 2013 (r256355) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc Fri Oct 11 22:19:45 2013 (r256356) @@ -93,32 +93,6 @@ ZfsdException::ZfsdException(nvlist_t *p va_end(ap); } -inline -ZfsdException::ZfsdException(zpool_handle_t *pool, nvlist_t *vdevConfig, - const char *fmt, ...) - : m_poolConfig(zpool_get_config(pool, NULL)), - m_vdevConfig(vdevConfig) -{ - va_list ap; - - va_start(ap, fmt); - FormatLog(fmt, ap); - va_end(ap); -} - -inline -ZfsdException::ZfsdException(nvlist_t *poolConfig, nvlist_t *vdevConfig, - const char *fmt, ...) - : m_poolConfig(poolConfig), - m_vdevConfig(vdevConfig) -{ - va_list ap; - - va_start(ap, fmt); - FormatLog(fmt, ap); - va_end(ap); -} - void ZfsdException::Log() const { Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h Fri Oct 11 22:00:54 2013 (r256355) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h Fri Oct 11 22:19:45 2013 (r256356) @@ -93,42 +93,6 @@ public: ZfsdException(nvlist_t *poolConfig, const char *, ...); /** - * \brief ZfsdException constructor allowing arbitrary string - * data to be reported and associated with the configuration - * data for a single vdev and its parent pool. - * - * \param pool Pool handle describing the pool to which this - * exception is associated. - * \param vdevConfig A name/value list describing the vdev - * to which this exception is associated. - * \param fmt Printf-like string format specifier. - * - * Instantiation with this method is used to report errors - * associated with a vdev when both the vdev's config and - * its pool membership are available. - */ - ZfsdException(zpool_handle_t *pool, nvlist_t *vdevConfig, - const char *fmt, ...); - - /** - * \brief ZfsdException constructor allowing arbitrary string - * data to be reported and associated with the configuration - * data for a single vdev and its parent pool. - * - * \param poolConfig Pool configuration describing the pool to - * which this exception is associated. - * \param vdevConfig A name/value list describing the vdev - * to which this exception is associated. - * \param fmt Printf-like string format specifier. - * - * Instantiation with this method is used to report errors - * associated with a vdev when both the vdev's config and - * its pool membership are available. - */ - ZfsdException(nvlist_t *poolConfig, nvlist_t *vdevConfig, - const char *fmt, ...); - - /** * \brief Augment/Modify a ZfsdException's string data. */ std::string& GetString(); Added: projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc Fri Oct 11 22:19:45 2013 (r256356) @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 2011 Spectra Logic Corporation + * 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, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + * + * Authors: Alan Somers (Spectra Logic Corporation) + */ + +/** + * \file zfsd_main.cc + * + * main function for the ZFS Daemon. Separated to facilitate testing. + * + */ + +#include +#include +#include + +#include "zfsd.h" + + +/*=============================== Program Main ===============================*/ +static void +usage() +{ + fprintf(stderr, "usage: %s [-d]\n", getprogname()); + exit(1); +} + +/** + * Program entry point. + */ +int +main(int argc, char **argv) +{ + int ch; + + while ((ch = getopt(argc, argv, "d")) != -1) { + switch (ch) { + case 'd': + g_debug++; + break; + default: + usage(); + } + } + + ZfsDaemon::Run(); + + return (0); +}