Subject: Re: modstat + gehenna-devsw
To: MAEKAWA Masahide <bishop@rr.iij4u.or.jp>
From: Love <lha@stacken.kth.se>
List: current-users
Date: 09/18/2002 19:06:20
So how about this then.

Love

Index: sys/kern/kern_lkm.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/syssrc/sys/kern/kern_lkm.c,v
retrieving revision 1.59
diff -u -r1.59 kern_lkm.c
--- sys/kern/kern_lkm.c 2002/09/13 13:08:53     1.59
+++ sys/kern/kern_lkm.c 2002/09/18 13:03:36
@@ -747,8 +747,8 @@
                if (error != 0)
                        return (error);
 
-               args->lkm_offset = makemajor(args->lkm_bdevmaj,
-                                            args->lkm_cdevmaj);
+               args->lkm_offset = 
+                       LKM_MAKEMAJOR(args->lkm_bdevmaj, args->lkm_cdevmaj);
                break;
 
        case LKM_E_UNLOAD:
Index: sys/sys/lkm.h
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/syssrc/sys/sys/lkm.h,v
retrieving revision 1.23
diff -u -r1.23 lkm.h
--- sys/sys/lkm.h       2002/09/13 14:51:25     1.23
+++ sys/sys/lkm.h       2002/09/18 13:03:09
@@ -392,8 +392,8 @@
        int     ver;                    /* OUT: lkm compile version */
 };
 
-#define        makemajor(b, c)         ((((b) & 0xffff) << 16) | ((c) & 0xffff))
-#define        block_major(v)          (int)((int16_t)(((v) >> 16) & 0xffff))
-#define        char_major(v)           (int)((int16_t)((v) & 0xffff))
+#define        LKM_MAKEMAJOR(b, c)     ((((b) & 0xffff) << 16) | ((c) & 0xffff))
+#define        LKM_BLOCK_MAJOR(v)      (int)((int16_t)(((v) >> 16) & 0xffff))
+#define        LKM_CHAR_MAJOR(v)       (int)((int16_t)((v) & 0xffff))
 
 #endif /* !_SYS_LKM_H_ */
Index: sbin/modload/modload.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/basesrc/sbin/modload/modload.c,v
retrieving revision 1.31
diff -u -r1.31 modload.c
--- sbin/modload/modload.c      2002/09/13 15:30:36     1.31
+++ sbin/modload/modload.c      2002/09/18 14:54:53
@@ -463,8 +463,8 @@
                (void)snprintf(type, sizeof(type), "0x%x", sbuf.type);
                if (sbuf.type == LM_DEV) {
                        char arg3[16], arg4[16];
-                       int bmajor = block_major(sbuf.offset);
-                       int cmajor = char_major(sbuf.offset);
+                       int bmajor = LKM_BLOCK_MAJOR(sbuf.offset);
+                       int cmajor = LKM_CHAR_MAJOR(sbuf.offset);
                        (void)snprintf(arg3, sizeof(arg3), "%d", cmajor);
                        (void)snprintf(arg4, sizeof(arg4), "%d", bmajor);
                        execl(post, post, id, type, arg3, arg4, 0);
Index: usr.bin/modstat/modstat.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/basesrc/usr.bin/modstat/modstat.c,v
retrieving revision 1.17
diff -u -r1.17 modstat.c
--- usr.bin/modstat/modstat.c   2002/09/13 17:16:00     1.17
+++ usr.bin/modstat/modstat.c   2002/09/18 13:04:35
@@ -113,13 +113,18 @@
         * Decode this stat buffer...
         */
        offset = (long)sbuf.offset;
-       if (offset < 0)
-               (void) strlcpy(offset_string, "-", sizeof (offset_string));
+       if (sbuf.type == LM_DEV)
+               (void) snprintf(offset_string, sizeof(offset_string), 
+                   "%3d/%3d", 
+                   LKM_BLOCK_MAJOR(offset), 
+                   LKM_CHAR_MAJOR(offset));
+       else if (offset < 0)
+               (void) strlcpy(offset_string, " -", sizeof (offset_string));
        else
-               (void) snprintf(offset_string, sizeof (offset_string), "%3ld",
+               (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 +197,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");