From owner-svn-src-all@FreeBSD.ORG Wed Apr 18 16:47:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 35FFA1065676; Wed, 18 Apr 2012 16:47:58 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 159448FC16; Wed, 18 Apr 2012 16:47:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3IGlvbG040767; Wed, 18 Apr 2012 16:47:57 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3IGlvjq040763; Wed, 18 Apr 2012 16:47:57 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201204181647.q3IGlvjq040763@svn.freebsd.org> From: Josh Paetzel Date: Wed, 18 Apr 2012 16:47:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234425 - in head: sbin/iscontrol sys/modules/iscsi/initiator X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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 Apr 2012 16:47:58 -0000 Author: jpaetzel Date: Wed Apr 18 16:47:57 2012 New Revision: 234425 URL: http://svn.freebsd.org/changeset/base/234425 Log: Unbreak tinderbox. Fix FreeBSD paradigms in the upstream code. PR: bin/166933 Submitted by: Garrett Cooper Modified: head/sbin/iscontrol/Makefile head/sbin/iscontrol/iscontrol.c head/sys/modules/iscsi/initiator/Makefile Modified: head/sbin/iscontrol/Makefile ============================================================================== --- head/sbin/iscontrol/Makefile Wed Apr 18 16:29:55 2012 (r234424) +++ head/sbin/iscontrol/Makefile Wed Apr 18 16:47:57 2012 (r234425) @@ -7,8 +7,7 @@ LDADD= -lcam -lmd S= ${.CURDIR}/../../sys WARNS?= 3 -CFLAGS += -I$S -CFLAGS += -g -DDEBUG +CFLAGS+= -I$S MAN= iscsi.conf.5 iscontrol.8 Modified: head/sbin/iscontrol/iscontrol.c ============================================================================== --- head/sbin/iscontrol/iscontrol.c Wed Apr 18 16:29:55 2012 (r234424) +++ head/sbin/iscontrol/iscontrol.c Wed Apr 18 16:47:57 2012 (r234425) @@ -44,13 +44,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include -#include -#include +#include #include #include +#include +#include +#include +#include #include +#include #include #include @@ -111,6 +113,13 @@ isc_opt_t opvals = { .immediateData = TRUE, }; +static void +usage(const char *pname) +{ + fprintf(stderr, "usage: %s " USAGE "\n", pname); + exit(1); +} + int lookup(token_t *tbl, char *m) { @@ -135,8 +144,8 @@ main(int cc, char **vv) iscsidev = "/dev/"ISCSIDEV; fd = NULL; pname = vv[0]; - if((p = strrchr(pname, '/')) != NULL) - pname = p + 1; + if ((pname = basename(pname)) == NULL) + err(1, "basename"); kw = ta = 0; disco = 0; @@ -145,17 +154,21 @@ main(int cc, char **vv) | check for driver & controller version match */ n = 0; - if(sysctlbyname("net.iscsi_initiator.driver_version", 0, &n, 0, 0) != 0) - perror("sysctlbyname"); - v = malloc(n+1); - if(sysctlbyname("net.iscsi_initiator.driver_version", v, &n, 0, 0) != 0) - perror("sysctlbyname"); - - if(strncmp(version, v, 3)) { - fprintf(stderr, "versions missmatch\n"); - exit(1); +#define VERSION_OID_S "net.iscsi_initiator.driver_version" + if (sysctlbyname(VERSION_OID_S, 0, &n, 0, 0) != 0) { + if (errno == ENOENT) + errx(1, "sysctlbyname(\"" VERSION_OID_S "\") " + "failed; is the iscsi driver loaded?"); + err(1, "sysctlbyname(\"" VERSION_OID_S "\")"); } + v = malloc(n+1); + if (v == NULL) + err(1, "malloc"); + if (sysctlbyname(VERSION_OID_S, v, &n, 0, 0) != 0) + err(1, "sysctlbyname"); + if (strncmp(version, v, 3) != 0) + errx(1, "versions mismatch"); while((ch = getopt(cc, vv, OPTIONS)) != -1) { switch(ch) { @@ -164,10 +177,8 @@ main(int cc, char **vv) break; case 'c': fd = fopen(optarg, "r"); - if(fd == NULL) { - perror(optarg); - exit(1); - } + if (fd == NULL) + err(1, "fopen(\"%s\")", optarg); break; case 'd': disco = 1; @@ -182,9 +193,7 @@ main(int cc, char **vv) pidfile = optarg; break; default: - badu: - fprintf(stderr, "Usage: %s %s\n", pname, USAGE); - exit(1); + usage(pname); } } if(fd == NULL) @@ -205,8 +214,8 @@ main(int cc, char **vv) op->targetAddress = ta; if(op->targetAddress == NULL) { - fprintf(stderr, "No target!\n"); - goto badu; + warnx("no target specified!"); + usage(pname); } q = op->targetAddress; if(*q == '[' && (q = strchr(q, ']')) != NULL) { @@ -224,7 +233,7 @@ main(int cc, char **vv) op->targetPortalGroupTag = atoi(p); } if(op->initiatorName == 0) { - char hostname[256]; + char hostname[MAXHOSTNAMELEN]; if(op->iqn) { if(gethostname(hostname, sizeof(hostname)) == 0) Modified: head/sys/modules/iscsi/initiator/Makefile ============================================================================== --- head/sys/modules/iscsi/initiator/Makefile Wed Apr 18 16:29:55 2012 (r234424) +++ head/sys/modules/iscsi/initiator/Makefile Wed Apr 18 16:47:57 2012 (r234425) @@ -10,7 +10,9 @@ SRCS+= iscsi.c isc_cam.c isc_soc.c isc_s SRCS+= opt_cam.h opt_iscsi_initiator.h SRCS+= bus_if.h device_if.h #CFLAGS+= -DNO_USE_MBUF +CFLAGS+= -DISCSI_INITIATOR_DEBUG=2 #CFLAGS+= -DISCSI_INITIATOR_DEBUG=2 +CFLAGS+= -DINVARIANTS CFLAGS+= -I$S CFLAGS+= -DINVARIANTS .include