From owner-svn-src-all@FreeBSD.ORG Wed Sep 18 08:37:15 2013 Return-Path: Delivered-To: svn-src-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 BC568A4B; Wed, 18 Sep 2013 08:37:15 +0000 (UTC) (envelope-from trasz@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 8F8FF28D2; Wed, 18 Sep 2013 08:37:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8I8bFPg057532; Wed, 18 Sep 2013 08:37:15 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8I8bE1W057529; Wed, 18 Sep 2013 08:37:14 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201309180837.r8I8bE1W057529@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 18 Sep 2013 08:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255665 - in head: usr.bin/iscsictl usr.sbin/ctld usr.sbin/iscsid X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Sep 2013 08:37:15 -0000 Author: trasz Date: Wed Sep 18 08:37:14 2013 New Revision: 255665 URL: http://svnweb.freebsd.org/changeset/base/255665 Log: Make iscsictl(8) automatically try to load the iscsi module. While here, improve module loading in iscsid(8) and ctld(8). Approved by: re (delphij) Modified: head/usr.bin/iscsictl/iscsictl.c head/usr.sbin/ctld/kernel.c head/usr.sbin/iscsid/iscsid.c Modified: head/usr.bin/iscsictl/iscsictl.c ============================================================================== --- head/usr.bin/iscsictl/iscsictl.c Wed Sep 18 06:40:47 2013 (r255664) +++ head/usr.bin/iscsictl/iscsictl.c Wed Sep 18 08:37:14 2013 (r255665) @@ -30,6 +30,8 @@ */ #include +#include +#include #include #include #include @@ -512,7 +514,7 @@ main(int argc, char **argv) const char *conf_path = DEFAULT_CONFIG_PATH; char *nickname = NULL, *discovery_host = NULL, *host = NULL, *target = NULL, *user = NULL, *secret = NULL; - int ch, error, iscsi_fd; + int ch, error, iscsi_fd, retval, saved_errno; int failed = 0; struct conf *conf; struct target *targ; @@ -672,6 +674,14 @@ main(int argc, char **argv) } iscsi_fd = open(ISCSI_PATH, O_RDWR); + if (iscsi_fd < 0 && errno == ENOENT) { + saved_errno = errno; + retval = kldload("iscsi"); + if (retval != -1) + iscsi_fd = open(ISCSI_PATH, O_RDWR); + else + errno = saved_errno; + } if (iscsi_fd < 0) err(1, "failed to open %s", ISCSI_PATH); Modified: head/usr.sbin/ctld/kernel.c ============================================================================== --- head/usr.sbin/ctld/kernel.c Wed Sep 18 06:40:47 2013 (r255664) +++ head/usr.sbin/ctld/kernel.c Wed Sep 18 08:37:14 2013 (r255665) @@ -79,7 +79,7 @@ kernel_init(void) int retval, saved_errno; ctl_fd = open(CTL_DEFAULT_DEV, O_RDWR); - if (ctl_fd < 0) { + if (ctl_fd < 0 && errno == ENOENT) { saved_errno = errno; retval = kldload("ctl"); if (retval != -1) Modified: head/usr.sbin/iscsid/iscsid.c ============================================================================== --- head/usr.sbin/iscsid/iscsid.c Wed Sep 18 06:40:47 2013 (r255664) +++ head/usr.sbin/iscsid/iscsid.c Wed Sep 18 08:37:14 2013 (r255665) @@ -509,7 +509,7 @@ main(int argc, char **argv) } iscsi_fd = open(ISCSI_PATH, O_RDWR); - if (iscsi_fd < 0) { + if (iscsi_fd < 0 && errno == ENOENT) { saved_errno = errno; retval = kldload("iscsi"); if (retval != -1)