Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/iscsid make the debug level available on the command line.



details:   https://anonhg.NetBSD.org/src/rev/fb823a35490b
branches:  trunk
changeset: 779428:fb823a35490b
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 27 19:52:51 2012 +0000

description:
make the debug level available on the command line.

diffstat:

 sbin/iscsid/Makefile      |   4 +++-
 sbin/iscsid/iscsid.8      |   9 ++++++---
 sbin/iscsid/iscsid_main.c |  28 +++++++++++++++++++++++-----
 3 files changed, 32 insertions(+), 9 deletions(-)

diffs (119 lines):

diff -r ec0fd348cdc2 -r fb823a35490b sbin/iscsid/Makefile
--- a/sbin/iscsid/Makefile      Sun May 27 19:21:26 2012 +0000
+++ b/sbin/iscsid/Makefile      Sun May 27 19:52:51 2012 +0000
@@ -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 @@
 CPPFLAGS+= -I${DESTDIR}/usr/include/dev/iscsi
 CPPFLAGS+= -I${DESTDIR}/usr/include
 CPPFLAGS+= -D_THREAD_SAFE
+CPPFLAGS+= -DISCSI_NOTHREAD
+DBG=-g
 
 MAN=   iscsid.8
 
diff -r ec0fd348cdc2 -r fb823a35490b sbin/iscsid/iscsid.8
--- a/sbin/iscsid/iscsid.8      Sun May 27 19:21:26 2012 +0000
+++ b/sbin/iscsid/iscsid.8      Sun May 27 19:52:51 2012 +0000
@@ -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 <agc%NetBSD.org@localhost>
 .\" 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 @@
 (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
diff -r ec0fd348cdc2 -r fb823a35490b sbin/iscsid/iscsid_main.c
--- a/sbin/iscsid/iscsid_main.c Sun May 27 19:21:26 2012 +0000
+++ b/sbin/iscsid/iscsid_main.c Sun May 27 19:52:51 2012 +0000
@@ -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 @@
 int driver = -1;                               /* the driver's file desc */
 int client_sock;                               /* the client communication socket */
 
-#ifdef ISCSI_DEBUG
+#ifndef ISCSI_DEBUG
+#define ISCSI_DEBUG 0
+#endif
 int debug_level = ISCSI_DEBUG; /* How much info to display */
-#endif
 
 /*
    To avoid memory fragmentation (and speed things up a bit), we use the
@@ -68,6 +69,13 @@
 
 /* -------------------------------------------------------------------------- */
 
+static void __dead
+usage(void) 
+{
+       fprintf(stderr, "Usage: %s [-d]\n", getprogname());
+       exit(EXIT_FAILURE);
+}
+
 
 /*
  * create_node_name:
@@ -501,7 +509,7 @@
 /*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 @@
 
        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);



Home | Main Index | Thread Index | Old Index