Module Name: src
Committed By: christos
Date: Sun May 27 19:52:51 UTC 2012
Modified Files:
src/sbin/iscsid: Makefile iscsid.8 iscsid_main.c
Log Message:
make the debug level available on the command line.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/iscsid/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sbin/iscsid/iscsid.8
cvs rdiff -u -r1.3 -r1.4 src/sbin/iscsid/iscsid_main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/iscsid/Makefile
diff -u src/sbin/iscsid/Makefile:1.1 src/sbin/iscsid/Makefile:1.2
--- src/sbin/iscsid/Makefile:1.1 Sun Oct 23 17:11:23 2011
+++ src/sbin/iscsid/Makefile Sun May 27 15:52:51 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2011/10/23 21:11:23 agc Exp $
+# $NetBSD: Makefile,v 1.2 2012/05/27 19:52:51 christos Exp $
PROG= iscsid
@@ -8,6 +8,8 @@ SRCS= iscsid_main.c iscsid_lists.c iscsi
CPPFLAGS+= -I${DESTDIR}/usr/include/dev/iscsi
CPPFLAGS+= -I${DESTDIR}/usr/include
CPPFLAGS+= -D_THREAD_SAFE
+CPPFLAGS+= -DISCSI_NOTHREAD
+DBG=-g
MAN= iscsid.8
Index: src/sbin/iscsid/iscsid.8
diff -u src/sbin/iscsid/iscsid.8:1.2 src/sbin/iscsid/iscsid.8:1.3
--- src/sbin/iscsid/iscsid.8:1.2 Mon Nov 21 03:23:20 2011
+++ src/sbin/iscsid/iscsid.8 Sun May 27 15:52:51 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: iscsid.8,v 1.2 2011/11/21 08:23:20 njoly Exp $
+.\" $NetBSD: iscsid.8,v 1.3 2012/05/27 19:52:51 christos Exp $
.\"
.\" Copyright (c) 2011 Alistair Crooks <[email protected]>
.\" All rights reserved.
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd August 8, 2011
+.Dd May 27, 2012
.Dt ISCSID 8
.Os
.Sh NAME
@@ -31,6 +31,7 @@
.Nd interface to kernel iSCSI driver
.Sh SYNOPSIS
.Nm
+.Op Ar d
.Sh DESCRIPTION
The iSCSI initiator runs as a kernel driver, and provides access
to iSCSI targets running across a network using the iSCSI protocol,
@@ -56,7 +57,9 @@ exits on receiving a terminate message,
(no response to one that is sent to the kernel),
or when an error occurs reading from or writing to the socket.
.Pp
-There are no command line arguments to
+The only command line argument
+.Ar d
+increases the debug level.
.Nm .
.Pp
It is envisaged that user-level communication take place with
Index: src/sbin/iscsid/iscsid_main.c
diff -u src/sbin/iscsid/iscsid_main.c:1.3 src/sbin/iscsid/iscsid_main.c:1.4
--- src/sbin/iscsid/iscsid_main.c:1.3 Sat Nov 19 20:23:57 2011
+++ src/sbin/iscsid/iscsid_main.c Sun May 27 15:52:51 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsid_main.c,v 1.3 2011/11/20 01:23:57 agc Exp $ */
+/* $NetBSD: iscsid_main.c,v 1.4 2012/05/27 19:52:51 christos Exp $ */
/*-
* Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -53,9 +53,10 @@ pthread_t event_thread; /* event threa
int driver = -1; /* the driver's file desc */
int client_sock; /* the client communication socket */
-#ifdef ISCSI_DEBUG
-int debug_level = ISCSI_DEBUG; /* How much info to display */
+#ifndef ISCSI_DEBUG
+#define ISCSI_DEBUG 0
#endif
+int debug_level = ISCSI_DEBUG; /* How much info to display */
/*
To avoid memory fragmentation (and speed things up a bit), we use the
@@ -68,6 +69,13 @@ static uint8_t rsp_buf[RSP_BUFFER_SIZE];
/* -------------------------------------------------------------------------- */
+static void __dead
+usage(void)
+{
+ fprintf(stderr, "Usage: %s [-d]\n", getprogname());
+ exit(EXIT_FAILURE);
+}
+
/*
* create_node_name:
@@ -501,7 +509,7 @@ int
/*ARGSUSED*/
main(int argc, char **argv)
{
- int req_temp, rsp_temp;
+ int req_temp, rsp_temp, c;
ssize_t ret;
size_t len;
struct sockaddr_un from;
@@ -518,7 +526,17 @@ main(int argc, char **argv)
printf("iSCSI Daemon loaded\n");
- daemon(0, 1);
+ while ((c = getopt(argc, argv, "d")) != -1)
+ switch (c) {
+ case 'd':
+ debug_level++;
+ break;
+ default:
+ usage();
+ }
+
+ if (!debug_level)
+ daemon(0, 1);
#ifndef ISCSI_NOTHREAD
ret = pthread_create(&event_thread, NULL, event_handler, NULL);