import 1.4.1. Thanks to Pedro Martelleto for adding OpenBSD support to
the plugin itself.
This commit is contained in:
parent
0f2c3343eb
commit
a20d24bec0
9
x11/xfce4/plugins/xfce4-diskperf-plugin/Makefile
Normal file
9
x11/xfce4/plugins/xfce4-diskperf-plugin/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2004/01/31 03:32:03 jolan Exp $
|
||||
|
||||
COMMENT= "displays instant disk performance in the xfce4 panel"
|
||||
DISTNAME= xfce4-diskperf-plugin-1.4.1
|
||||
MASTER_SITES= ${MASTER_SITE_GOODIES}
|
||||
|
||||
HOMEPAGE= ${HOMEPAGE_GOODIES}
|
||||
|
||||
.include <bsd.port.mk>
|
3
x11/xfce4/plugins/xfce4-diskperf-plugin/distinfo
Normal file
3
x11/xfce4/plugins/xfce4-diskperf-plugin/distinfo
Normal file
@ -0,0 +1,3 @@
|
||||
MD5 (xfce4/xfce4-diskperf-plugin-1.4.1.tar.gz) = c1e745b1d25cfd70b21bdb1dcfd6a81e
|
||||
RMD160 (xfce4/xfce4-diskperf-plugin-1.4.1.tar.gz) = 954eddd847e05820b262d4232e0a1ad6389852b0
|
||||
SHA1 (xfce4/xfce4-diskperf-plugin-1.4.1.tar.gz) = 51e2653eda48895b9f6521b7850071f4a03fab87
|
@ -0,0 +1,128 @@
|
||||
$OpenBSD: patch-panel-plugin_devperf_c,v 1.1.1.1 2004/01/31 03:32:03 jolan Exp $
|
||||
--- panel-plugin/devperf.c.orig 2003-11-30 09:01:44.000000000 -0200
|
||||
+++ panel-plugin/devperf.c 2004-01-30 23:37:45.000000000 -0200
|
||||
@@ -310,6 +310,124 @@ int DevGetPerfData (const void *p_pvDevi
|
||||
/* *INDENT-ON* */
|
||||
/************************** NetBSD End ***************/
|
||||
|
||||
+#elif defined(__OpenBSD__)
|
||||
+/*
|
||||
+ * OpenBSD support. As of the moment of this writing OpenBSD didn't separate
|
||||
+ * read and write disk statistics, they were assumed to have the same value.
|
||||
+ */
|
||||
+
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/disk.h>
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+static char **disks = NULL;
|
||||
+static int diskn = 0;
|
||||
+
|
||||
+int DevPerfInit ()
|
||||
+{
|
||||
+ return (0);
|
||||
+}
|
||||
+
|
||||
+int DevCheckStatAvailability(char const **strptr)
|
||||
+{
|
||||
+ return (0);
|
||||
+}
|
||||
+
|
||||
+int DevGetPerfData (const void *p_pvDevice, struct devperf_t *perf)
|
||||
+{
|
||||
+ int mib[3], cur_diskn, x;
|
||||
+ size_t len;
|
||||
+ void *r;
|
||||
+ char **tok, *names, *devname = (char *)p_pvDevice;
|
||||
+ struct diskstats *diskstats;
|
||||
+ struct timeval tv;
|
||||
+
|
||||
+ mib[0] = CTL_HW;
|
||||
+ mib[1] = HW_DISKCOUNT;
|
||||
+ len = sizeof(cur_diskn);
|
||||
+
|
||||
+ if (sysctl(mib, 2, &cur_diskn, &len, NULL, 0) < 0)
|
||||
+ return (-1);
|
||||
+
|
||||
+ if (cur_diskn != diskn) {
|
||||
+ if (disks != NULL)
|
||||
+ free(disks[0]);
|
||||
+ r = realloc(disks, cur_diskn * sizeof(char *));
|
||||
+ if (r == NULL) {
|
||||
+error: free(disks);
|
||||
+ disks = NULL;
|
||||
+ diskn = 0;
|
||||
+ return (-1);
|
||||
+ } else
|
||||
+ disks = (char **)r;
|
||||
+
|
||||
+ mib[0] = CTL_HW;
|
||||
+ mib[1] = HW_DISKNAMES;
|
||||
+ len = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 2, NULL, &len, NULL, 0) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ names = malloc(len);
|
||||
+ if (names == NULL)
|
||||
+ goto error;
|
||||
+
|
||||
+ if (sysctl(mib, 2, names, &len, NULL, 0) < 0) {
|
||||
+ free(names);
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ diskn = cur_diskn;
|
||||
+
|
||||
+ for (tok = disks; tok <= &disks[cur_diskn - 1] &&
|
||||
+ (*tok = strsep(&names, ",")) != NULL;)
|
||||
+ if (**tok != '\0')
|
||||
+ tok++;
|
||||
+ }
|
||||
+
|
||||
+ for (x = 0; x < diskn; x++)
|
||||
+ if (!strcmp(disks[x], devname))
|
||||
+ break;
|
||||
+
|
||||
+ if (x == diskn)
|
||||
+ return (-1);
|
||||
+
|
||||
+ mib[0] = CTL_HW;
|
||||
+ mib[1] = HW_DISKSTATS;
|
||||
+ len = diskn * sizeof(struct diskstats);
|
||||
+
|
||||
+ diskstats = malloc(len);
|
||||
+ if (diskstats == NULL)
|
||||
+ return (-1);
|
||||
+
|
||||
+ if (sysctl(mib, 2, diskstats, &len, NULL, 0) < 0) {
|
||||
+ free(diskstats);
|
||||
+ return (-1);
|
||||
+ }
|
||||
+
|
||||
+ if (gettimeofday(&tv, NULL)) {
|
||||
+ free(diskstats);
|
||||
+ return (-1);
|
||||
+ }
|
||||
+
|
||||
+ perf->timestamp_ns = (uint64_t)1000ull * 1000ull * 1000ull * tv.tv_sec
|
||||
+ + 1000ull * tv.tv_usec;
|
||||
+ perf->rbusy_ns = ((uint64_t)1000ull * 1000ull * 1000ull *
|
||||
+ diskstats[x].ds_time.tv_sec + 1000ull *
|
||||
+ diskstats[x].ds_time.tv_usec) / 2ull;
|
||||
+
|
||||
+ perf->wbusy_ns = perf->rbusy_ns / 2ull;
|
||||
+ perf->rbytes = diskstats[x].ds_bytes;
|
||||
+ perf->wbytes = perf->rbytes;
|
||||
+ perf->qlen = diskstats[x].ds_xfer;
|
||||
+
|
||||
+ free(diskstats);
|
||||
+
|
||||
+ return (0);
|
||||
+}
|
||||
+
|
||||
#else
|
||||
/**************************************************************/
|
||||
/******************** Unsupported platform ***************/
|
@ -0,0 +1,84 @@
|
||||
$OpenBSD: patch-panel-plugin_main_c,v 1.1.1.1 2004/01/31 03:32:03 jolan Exp $
|
||||
--- panel-plugin/main.c.orig 2003-11-11 06:40:34.000000000 -0600
|
||||
+++ panel-plugin/main.c 2004-01-30 20:36:19.000000000 -0600
|
||||
@@ -94,7 +94,7 @@ typedef enum monitor_bar_order_t {
|
||||
typedef struct param_t {
|
||||
/* Configurable parameters */
|
||||
char acDevice[64];
|
||||
-#if !defined(__NetBSD__)
|
||||
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
dev_t st_rdev;
|
||||
#endif
|
||||
int fTitleDisplayed;
|
||||
@@ -162,7 +162,7 @@ static int DisplayPerf (struct plugin_t
|
||||
const double K = 1.0 * 1000 * 1000 * 1000 / 1024 / 1024;
|
||||
/* bytes/ns --> MB/s */
|
||||
double arPerf[NMONITORS], arBusy[NMONITORS], *prData, *pr;
|
||||
- char acToolTips[128];
|
||||
+ char acToolTips[256];
|
||||
int status, i;
|
||||
|
||||
if (!s_poToolTips)
|
||||
@@ -170,7 +170,7 @@ static int DisplayPerf (struct plugin_t
|
||||
|
||||
memset (&oPerf, 0, sizeof (oPerf));
|
||||
oPerf.qlen = -1;
|
||||
-#if defined (__NetBSD__)
|
||||
+#if defined (__NetBSD__) || defined(__OpenBSD__)
|
||||
status = DevGetPerfData (poConf->acDevice, &oPerf);
|
||||
#else
|
||||
status = DevGetPerfData (&(poConf->st_rdev), &oPerf);
|
||||
@@ -210,7 +210,7 @@ static int DisplayPerf (struct plugin_t
|
||||
}
|
||||
}
|
||||
|
||||
- sprintf (acToolTips, "%s\n"
|
||||
+ snprintf (acToolTips, sizeof(acToolTips), "%s\n"
|
||||
"----------------\n"
|
||||
"I/O (MB/s)\n"
|
||||
" Read :%3u\n"
|
||||
@@ -406,7 +406,7 @@ static plugin_t *NewPlugin ()
|
||||
struct plugin_t *poPlugin;
|
||||
struct param_t *poConf;
|
||||
struct monitor_t *poMonitor;
|
||||
-#if !defined(__NetBSD__)
|
||||
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
struct stat oStat;
|
||||
int status;
|
||||
#endif
|
||||
@@ -416,7 +416,7 @@ static plugin_t *NewPlugin ()
|
||||
poConf = &(poPlugin->oConf.oParam);
|
||||
poMonitor = &(poPlugin->oMonitor);
|
||||
|
||||
-#if defined(__NetBSD__)
|
||||
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
strcpy (poConf->acDevice, "wd0");
|
||||
strcpy (poConf->acTitle, "wd0");
|
||||
#else
|
||||
@@ -508,7 +508,7 @@ static void plugin_read_config (Control
|
||||
Widget_t *pw2ndBar = poPlugin->oMonitor.awProgressBar + 1;
|
||||
xmlNodePtr poNode;
|
||||
char *pc;
|
||||
-#if !defined(__NetBSD__)
|
||||
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
struct stat oStat;
|
||||
int status;
|
||||
#endif
|
||||
@@ -524,7 +524,7 @@ static void plugin_read_config (Control
|
||||
memset (poConf->acDevice, 0, sizeof (poConf->acDevice));
|
||||
strncpy (poConf->acDevice, pc, sizeof (poConf->acDevice) - 1);
|
||||
xmlFree (pc);
|
||||
-#if !defined(__NetBSD__)
|
||||
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
status = stat (poConf->acDevice, &oStat);
|
||||
poConf->st_rdev = (status == -1 ? 0 : oStat.st_rdev);
|
||||
#endif
|
||||
@@ -660,7 +660,7 @@ static void SetDevice (Widget_t p_wTF, v
|
||||
struct plugin_t *poPlugin = (plugin_t *) p_pvPlugin;
|
||||
struct param_t *poConf = &(poPlugin->oConf.oParam);
|
||||
const char *pcDevice = gtk_entry_get_text (GTK_ENTRY (p_wTF));
|
||||
-#if !defined(__NetBSD__)
|
||||
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
struct stat oStat;
|
||||
int status;
|
||||
|
2
x11/xfce4/plugins/xfce4-diskperf-plugin/pkg/DESCR
Normal file
2
x11/xfce4/plugins/xfce4-diskperf-plugin/pkg/DESCR
Normal file
@ -0,0 +1,2 @@
|
||||
xfce4-diskperf-plugin displays instant disk/partition performance (bytes
|
||||
transfered per second) in the xfce4 panel.
|
4
x11/xfce4/plugins/xfce4-diskperf-plugin/pkg/PLIST
Normal file
4
x11/xfce4/plugins/xfce4-diskperf-plugin/pkg/PLIST
Normal file
@ -0,0 +1,4 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2004/01/31 03:32:03 jolan Exp $
|
||||
lib/xfce4/panel-plugins/libdiskperf.a
|
||||
lib/xfce4/panel-plugins/libdiskperf.la
|
||||
lib/xfce4/panel-plugins/libdiskperf.so
|
Loading…
Reference in New Issue
Block a user