pkgsrc-Users archive

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

gkrellm-1.2.13 and NetBSD-current



Hi,

as mail to anthony.mallet at ficus.yi.org as the maintainer of gkrellm-1.2.13
failed with: "Name service error for name=ficus.yi.org type=A: Host not found"
here we go:

To make gkrellm-1.2.13 show the disk statistics again w/ the new io_stats
framework, I made the attached changes to src/disk.c. Perhaps this could
be usefull for others, so replacing paches/patch-ac with something like
what I've hacked together would make sense?
(Caveat: The possibility to use different blocksizes is lost...)

Kurt


--- src/disk.c  2002-07-01 04:19:47.000000000 +0200
+++ src/disk.c  2006-04-15 13:41:56.000000000 +0200
@@ -415,14 +415,26 @@
 #include <kvm.h>
 
 static struct nlist nl[] = {
+#if __NetBSD_Version__ >= 399001800
+#define X_DISK_COUNT    0
+   { "_iostat_count" },      /* number of iostatable devices */
+#define X_DISKLIST      1
+   { "_iostatlist" },        /* TAILQ of iostatable devices */
+   { NULL },
+#else
 #define X_DISK_COUNT    0
    { "_disk_count" },      /* number of disks */
 #define X_DISKLIST      1
    { "_disklist" },        /* TAILQ of disks */
    { NULL },
+#endif
 };
 
+#if __NetBSD_Version__ >= 399001800
+static struct io_stats *dkdisks;    /* kernel iostats list head */
+#else
 static struct disk *dkdisks;   /* kernel disk list head */
+#endif
 
 extern kvm_t   *kvmd;
 
@@ -439,7 +451,11 @@
    static gint data_read_tick = -1;
    GList *list;
    DiskMon *disk;
+#if __NetBSD_Version__ >= 399001800
+   struct io_stats d, *p;
+#else
    struct disk d, *p;
+#endif
    
    if (data_read_tick == GK.timer_ticks)       /* Only one read per tick */
       return;
@@ -464,15 +480,36 @@
          * d.xfer value (number of transfers) but there a scaling problem:
          * d.xfer is usually much more smaller thant d.dk_bytes... */
 
+        /* Separate read/write stats were implemented in NetBSD 1.6K. */
         disk = (DiskMon *) list->data;
-        disk->rblk = d.dk_bytes / 512; /* block size hardcoded :
-                                        * d.dk_byteshift is always 0 ?? */
+#if __NetBSD_Version__ >= 106110000 && __NetBSD_Version__ < 399001800
+        /* d.dk_byteshift is not set in, or used, by the kernel as of
+         * NetBSD 1.6K, but maybe one day... In the meantime, NetBSD
+         * only supports a blocksize of 512 == 2^^9, so assume that. */
+        if (d.dk_byteshift == 0) {
+           disk->rblk = d.dk_rbytes >> 9;
+           disk->wblk = d.dk_wbytes >> 9;
+        } else {
+           disk->rblk = d.dk_rbytes / d.dk_byteshift;
+           disk->wblk = d.dk_wbytes / d.dk_byteshift;
+        }
+#elif __NetBSD_Version__ >= 399001800
+        disk->rblk = d.rbytes >> 9;
+        disk->wblk = d.wbytes >> 9;
+#else
+       /* generic stats introduced */
+        disk->rblk = d.dk_bytes >> 9;
         disk->wblk = 0;
+#endif
 
         composite_disk->rblk += disk->rblk;
         composite_disk->wblk += disk->wblk; /* useless, isn't it ? :-D */
       }
+#if __NetBSD_Version__ >= 399001800
+      p = d.link.tqe_next;
+#else
       p = d.dk_link.tqe_next;
+#endif
    }
 }
 
@@ -481,8 +518,13 @@
 {
    gint        i;
    DiskMon *disk;
+#if __NetBSD_Version__ >= 399001800
+   struct iostatlist_head head;
+   struct io_stats d, *p;
+#else
    struct disklist_head head;
    struct disk d, *p;
+#endif
    char buf[20];
 
    if (re_checking) return;
@@ -509,13 +551,21 @@
       disk_mon_list = g_list_append(disk_mon_list, disk);
 
       if (kvm_read(kvmd, (u_long)p, &d, sizeof(d)) != sizeof(d) ||
+#if __NetBSD_Version__ >= 399001800
+         kvm_read(kvmd, (u_long)d.name, buf, sizeof(buf)) != sizeof(buf))
+#else
          kvm_read(kvmd, (u_long)d.dk_name, buf, sizeof(buf)) != sizeof(buf))
+#endif
         /* fallback to default name if kvm_read failed */
         disk->name = g_strdup_printf("%s%c", _("Disk"), 'A' + i);
       else
         disk->name = strdup(buf);
 
+#if __NetBSD_Version__ >= 399001800
+      p = d.link.tqe_next;
+#else
       p = d.dk_link.tqe_next;
+#endif
    }
 
    using_DiskN_names = TRUE;



Home | Main Index | Thread Index | Old Index