Subject: modstat + gehenna-devsw
To: None <current-users@netbsd.org>
From: Love <lha@stacken.kth.se>
List: current-users
Date: 09/17/2002 18:53:37
modstat can't handle MOD_DEV index number like it used too with the
gehenna-devsw (nice work BTW).

I'ld like to commit this patch tomorrow assuming someone doesn't disagree
how it should be done.

Love

1.6# modstat
Type    Id  Off Loadaddr Size Info     Rev Module Name
DEV       0   - cb7b6000 0038 cb7c2a60   1 nnpfs_mod
1.6# ./modstat
Type    Id   Offset Loadaddr Size Info     Rev Module Name
DEV       0      93 cb7b6000 0038 cb7c2a60   1 nnpfs_mod
1.6# ls -ld /dev/nnpfs0 
crw-r--r--  1 root  wheel  93, 0 Sep 17 18:46 /dev/nnpfs0

1.5# modstat
Type    Id  Off Loadaddr         Size Info             Rev Module Name
DEV       0  17 fffffe000c654000 0048 fffffe000c663d98   1 xfs_mod
1.5# ls -l /dev/xfs0 
crw-r--r--  1 root  wheel  17, 0 Dec 20  2001 /dev/xfs0


Index: modstat.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/basesrc/usr.bin/modstat/modstat.c,v
retrieving revision 1.17
diff -u -u -w -r1.17 modstat.c
--- modstat.c	2002/09/13 17:16:00	1.17
+++ modstat.c	2002/09/17 16:20:47
@@ -113,13 +113,25 @@
 	 * Decode this stat buffer...
 	 */
 	offset = (long)sbuf.offset;
-	if (offset < 0)
+	if (sbuf.type == LM_DEV) {
+		int len = 0;
+		
+		if (block_major(offset) > 0)
+			len = snprintf(offset_string, sizeof(offset_string),
+			    "%3d%s", block_major(offset), 
+			    char_major(offset) > 0 ? "/" : "");
+		if (char_major(offset) > 0 && len < sizeof(offset_string))
+			(void) snprintf(offset_string + len, 
+			    sizeof(offset_string) - len,
+			    "%3d", char_major(offset));
+
+	} else if (offset < 0)
 		(void) strlcpy(offset_string, "-", sizeof (offset_string));
 	else
 		(void) snprintf(offset_string, sizeof (offset_string), "%3ld",
 		    offset);
 
-	printf("%-7s %3d %3s %0*lx %04lx %0*lx %3ld %s\n",
+	printf("%-7s %3d %7s %0*lx %04lx %0*lx %3ld %s\n",
 	    (sbuf.type < tn_nentries) ? type_names[sbuf.type] : "(UNKNOWN)", 
 	    sbuf.id,		/* module id */
 	    offset_string,	/* offset into modtype struct */
@@ -192,7 +204,7 @@
 
 	atexit(cleanup);
 
-	printf("Type    Id  Off %-*s Size %-*s Rev Module Name\n", 
+	printf("Type    Id   Offset %-*s Size %-*s Rev Module Name\n", 
 	    POINTERSIZE, "Loadaddr", 
 	    POINTERSIZE, "Info");