Ver código fonte

Add ./tarball_archive/symon-2.85.tar.gz

Wictor Lund 3 anos atrás
pai
commit
875d0cbf7b

+ 7 - 0
symon/CHANGELOG

@@ -1,3 +1,10 @@
+18/02/2012 - 2.85
+
+   - lib/diskname rewrite -- return possible disknames for Linux and FreeBSD
+     based on a number of predefined path patterns
+
+   - platform/Linux allow /dev/mapper disknames (Edho Arief)
+
 14/01/2012 - 2.84
 14/01/2012 - 2.84
 
 
    - platform/Linux/disk probes now handles '/' in arguments (Bostjan Skufca)
    - platform/Linux/disk probes now handles '/' in arguments (Bostjan Skufca)

+ 1 - 1
symon/Makefile.inc

@@ -1,4 +1,4 @@
-V=2.84
+V=2.85
 
 
 AR?=	ar
 AR?=	ar
 CC?=	cc
 CC?=	cc

+ 1 - 1
symon/lib/Makefile

@@ -5,7 +5,7 @@ OS!=uname -s
 SRCSsym=   	error.c lex.c xmalloc.c net.c data.c
 SRCSsym=   	error.c lex.c xmalloc.c net.c data.c
 OBJSsym+=	${SRCSsym:R:S/$/.o/g}
 OBJSsym+=	${SRCSsym:R:S/$/.o/g}
 
 
-SRCSprobe=      diskbyname.c percentages.c smart.c
+SRCSprobe=      diskname.c percentages.c smart.c
 OBJSprobe+=     ${SRCSprobe:R:S/$/.o/g}
 OBJSprobe+=     ${SRCSprobe:R:S/$/.o/g}
 
 
 CFLAGS+=-I../platform/${OS} -I.
 CFLAGS+=-I../platform/${OS} -I.

+ 0 - 5
symon/lib/diskbyname.h

@@ -1,5 +0,0 @@
-#ifndef _SYMON_LIB_DISKBYNAME_H
-#define _SYMON_LIB_DISKBYNAME_H
-size_t
-diskbyname(const char *spath, char *dpath, size_t maxlen);
-#endif /* _SYMON_LIB_DISKBYNAME_H */

+ 48 - 61
symon/lib/diskbyname.c → symon/lib/diskname.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2011 Willem Dijkstra
+ * Copyright (c) 2012 Willem Dijkstra
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -39,52 +39,18 @@
 
 
 #include "error.h"
 #include "error.h"
 #include "platform.h"
 #include "platform.h"
+#include "diskname.h"
 
 
-/*
- * checkdisk(spath, dpath, maxlen)
- *
- * Determine that <spath> exists, and return the device name that was referenced
- * (/dev/sdx) when <spath> is a link in <dpath>, observing <dpath>'s <maxlen>.
- */
-static size_t
-checkdisk(const char *spath, char *dpath, size_t maxlen)
+void
+initdisknamectx(struct disknamectx *c, const char *spath, char *dpath, size_t dmaxlen)
 {
 {
-    char diskname[MAX_PATH_LEN];
-    char *r;
-    struct stat buffer;
-    size_t result;
-
-    bzero(diskname, MAX_PATH_LEN);
-    bzero(&buffer, sizeof(struct stat));
-
-    if (lstat(spath, &buffer)) {
-        return 0;
-    }
-
-    /* Walk one link, if it is there */
-    if (S_ISLNK(buffer.st_mode)) {
-        if ((r = realpath(spath, NULL))) {
-            strlcpy(diskname, r, sizeof(diskname));
-            free(r);
-        }
-        bzero(&buffer, sizeof(struct stat));
-        if (lstat(diskname, &buffer)) {
-            fatal("diskbyname: '%.200s' = '%.200s' cannot be examined: %.200s", spath, diskname, strerror(errno));
-        }
-    } else
-        strlcpy(diskname, spath, sizeof(diskname));
+    bzero(c, sizeof(struct disknamectx));
+    c->spath = spath;
+    c->dpath = dpath;
+    c->maxlen = dmaxlen;
 
 
-    /*
-     * No more links from here; also note the lack of further checks on the
-     * stat structure. For linux we should now be looking at a block device,
-     * for FreeBSD this should be a character device.
-     */
-    if (!S_ISLNK(buffer.st_mode)) {
-        result = strlcpy(dpath, diskname, maxlen);
-        return result;
-    }
-
-    return 0;
+    if (c->dpath != NULL)
+        bzero(c->dpath, c->maxlen);
 }
 }
 
 
 /*
 /*
@@ -93,32 +59,53 @@ checkdisk(const char *spath, char *dpath, size_t maxlen)
  * Resolve a logical disk name <spath> to it's block device name
  * Resolve a logical disk name <spath> to it's block device name
  * <dpath>. <dpath> is preallocated and can hold <maxlen> characters. <spath>
  * <dpath>. <dpath> is preallocated and can hold <maxlen> characters. <spath>
  * can refer to a disk via 1) an absolute path or 2) a diskname relative to
  * can refer to a disk via 1) an absolute path or 2) a diskname relative to
- * /dev in various forms defined in platform specific DISK_PATHS.
+ * /dev in various forms.
  */
  */
-size_t
-diskbyname(const char *spath, char *dpath, size_t maxlen)
+char *
+nextdiskname(struct disknamectx *c)
 {
 {
-    char diskname[MAX_PATH_LEN];
-    size_t size;
+    char *r;
+    struct stat buffer;
 #ifdef DISK_PATHS
 #ifdef DISK_PATHS
-    char *l[] =  DISK_PATHS;
+    char *l[] = DISK_PATHS;
 #else
 #else
     char *l[] = { "/dev/%s", NULL };
     char *l[] = { "/dev/%s", NULL };
 #endif
 #endif
-    int i;
 
 
-    if (spath == NULL)
-        return 0;
+    if ((c->spath == NULL) || (c->dpath == NULL) || (l[c->i] == NULL))
+        return NULL;
 
 
-    if (strchr(spath, '/') == spath)
-        return checkdisk(spath, dpath, maxlen);
+    bzero(c->dpath, c->maxlen);
 
 
-    for (i = 0; l[i] != NULL; i++) {
-        bzero(diskname, sizeof(diskname));
-        snprintf(diskname, sizeof(diskname), l[i], spath);
-        if ((size = checkdisk(diskname, dpath, maxlen)))
-            return size;
+    /* do not play with absolute paths, just return it once */
+    if (c->spath[0] == '/') {
+        if (c->i == 0) {
+            strlcpy(c->dpath, c->spath, c->maxlen);
+            c->i++;
+            return c->dpath;
+        }
+        return NULL;
     }
     }
 
 
-    return 0;
+    /* prepare the next pathname */
+    snprintf(c->dpath, c->maxlen, l[c->i], c->spath);
+
+    if ((c->link == 0) &&
+        (lstat(c->dpath, &buffer) == 0)) {
+        /* return the real path of a link, but only dereference once */
+        if (S_ISLNK(buffer.st_mode)) {
+            if ((r = realpath(c->dpath, NULL))) {
+                strlcpy(c->dpath, r, c->maxlen);
+                free(r);
+                c->link = 1;
+
+                return c->dpath;
+            }
+        }
+    }
+
+    c->link = 0;
+    c->i++;
+
+    return c->dpath;
 }
 }

+ 16 - 0
symon/lib/diskname.h

@@ -0,0 +1,16 @@
+#ifndef _SYMON_DISKNAME_H
+#define _SYMON_DISKNAME_H
+
+struct disknamectx
+{
+    const char *spath;
+    char *dpath;
+    size_t maxlen;
+    unsigned int i;
+    unsigned int link;
+};
+
+void initdisknamectx(struct disknamectx *c, const char *spath, char *dpath, size_t dmaxlen);
+char *nextdiskname(struct disknamectx *c);
+
+#endif /* _SYMON_DISKNAME_H */

+ 1 - 1
symon/platform/FreeBSD/platform.h

@@ -19,7 +19,7 @@
 #define SA_LEN(x)       ((x)->sa_len)
 #define SA_LEN(x)       ((x)->sa_len)
 #define SS_LEN(x)       ((x)->ss_len)
 #define SS_LEN(x)       ((x)->ss_len)
 
 
-#define DISK_PATHS { "/dev/%s", "/dev/ufs/%s", "/dev/ufsid/%s", "/dev/gpt/%s", NULL }
+#define DISK_PATHS { "%s", "/dev/%s", "/dev/ufs/%s", "/dev/ufsid/%s", "/dev/gpt/%s", "/dev/label/%s", NULL }
 #define MAX_PATH_LEN MAXPATHLEN
 #define MAX_PATH_LEN MAXPATHLEN
 
 
 union stream_parg {
 union stream_parg {

+ 10 - 8
symon/platform/FreeBSD/sm_df.c

@@ -53,7 +53,7 @@
 
 
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 /* Globals for this module start with df_ */
 /* Globals for this module start with df_ */
 static struct statfs *df_stats = NULL;
 static struct statfs *df_stats = NULL;
@@ -62,22 +62,24 @@ static int df_parts = 0;
 void
 void
 init_df(struct stream *st)
 init_df(struct stream *st)
 {
 {
+    struct disknamectx c;
     int n;
     int n;
     char drivename[SYMON_DFNAMESIZE];
     char drivename[SYMON_DFNAMESIZE];
 
 
     if (st->arg == NULL)
     if (st->arg == NULL)
         fatal("df: need a <disk device|name> argument");
         fatal("df: need a <disk device|name> argument");
 
 
-    if (diskbyname(st->arg, drivename, sizeof(drivename)) == 0)
-        fatal("df: '%.200s' is not a disk device", st->arg);
+    initdisknamectx(&c, st->arg, drivename, sizeof(drivename));
 
 
     gets_df();
     gets_df();
 
 
-    for (n = 0; n < df_parts; n++) {
-        if (!strncmp(df_stats[n].f_mntfromname, drivename, SYMON_DFNAMESIZE)) {
-            strlcpy(st->parg.df.rawdev, drivename, sizeof(st->parg.df.rawdev));
-            info("started module df(%.200s)", st->arg);
-            return;
+    while (nextdiskname(&c)) {
+        for (n = 0; n < df_parts; n++) {
+            if (!strncmp(df_stats[n].f_mntfromname, drivename, SYMON_DFNAMESIZE)) {
+                strlcpy(st->parg.df.rawdev, drivename, sizeof(st->parg.df.rawdev));
+                info("started module df(%.200s)", st->arg);
+                return;
+            }
         }
         }
     }
     }
 
 

+ 18 - 13
symon/platform/FreeBSD/sm_io.c

@@ -54,7 +54,7 @@
 
 
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 static struct statinfo io_stats;
 static struct statinfo io_stats;
 static int io_numdevs = 0;
 static int io_numdevs = 0;
@@ -68,6 +68,7 @@ privinit_io()
 void
 void
 init_io(struct stream *st)
 init_io(struct stream *st)
 {
 {
+    struct disknamectx c;
     unsigned int i;
     unsigned int i;
     struct devstat *ds;
     struct devstat *ds;
     char drivename[MAX_PATH_LEN];
     char drivename[MAX_PATH_LEN];
@@ -75,9 +76,6 @@ init_io(struct stream *st)
     if (st->arg == NULL)
     if (st->arg == NULL)
         fatal("io: need a <device>|<devicename> argument");
         fatal("io: need a <device>|<devicename> argument");
 
 
-    if (diskbyname(st->arg, drivename, MAX_PATH_LEN) == 0)
-        fatal("io: '%.200s' is not a <device>|<devicename>", st->arg);
-
     io_stats.dinfo = malloc(sizeof(struct devinfo));
     io_stats.dinfo = malloc(sizeof(struct devinfo));
     if (io_stats.dinfo == NULL) {
     if (io_stats.dinfo == NULL) {
         fatal("io: could not allocate memory");
         fatal("io: could not allocate memory");
@@ -85,17 +83,24 @@ init_io(struct stream *st)
 
 
     io_stats.dinfo->mem_ptr = NULL;
     io_stats.dinfo->mem_ptr = NULL;
 
 
-    gets_io();
+    initdisknamectx(&c, st->arg, drivename, MAX_PATH_LEN);
 
 
-    for (i = 0; i < io_numdevs; i++) {
-        ds = &io_stats.dinfo->devices[i];
+    gets_io();
 
 
-        if (strncmp(ds->device_name, st->arg, strlen(ds->device_name)) == 0 &&
-            strlen(ds->device_name) < strlen(st->arg) &&
-            isdigit(st->arg[strlen(ds->device_name)]) &&
-            atoi(&st->arg[strlen(ds->device_name)]) == ds->unit_number) {
-            info("started module io(%.200s)", st->arg);
-            return;
+    while (nextdiskname(&c)) {
+        for (i = 0; i < io_numdevs; i++) {
+            ds = &io_stats.dinfo->devices[i];
+
+            if (strncmp(ds->device_name, drivename, strlen(ds->device_name)) == 0 &&
+                strlen(ds->device_name) < strlen(drivename) &&
+                isdigit(st->arg[strlen(ds->device_name)]) &&
+                atoi(&drivename[strlen(ds->device_name)]) == ds->unit_number) {
+                if (strcmp(st->arg, drivename) == 0)
+                    info("started module io(%.200s)", st->arg);
+                else
+                    info("started module io(%.200s = %.200s)", st->arg, drivename);
+                return;
+            }
         }
         }
     }
     }
 
 

+ 14 - 9
symon/platform/FreeBSD/sm_smart.c

@@ -44,7 +44,7 @@
 #include "error.h"
 #include "error.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 #include "smart.h"
 #include "smart.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 #ifdef HAS_IOCATAREQUEST
 #ifdef HAS_IOCATAREQUEST
 #ifndef HAS_ATA_SMART_CMD
 #ifndef HAS_ATA_SMART_CMD
@@ -66,6 +66,8 @@ static int smart_cur = 0;
 void
 void
 init_smart(struct stream *st)
 init_smart(struct stream *st)
 {
 {
+    struct disknamectx c;
+    int fd;
     int i;
     int i;
     char drivename[MAX_PATH_LEN];
     char drivename[MAX_PATH_LEN];
     struct ata_ioc_request *p;
     struct ata_ioc_request *p;
@@ -75,11 +77,18 @@ init_smart(struct stream *st)
     }
     }
 
 
     if (st->arg == NULL) {
     if (st->arg == NULL) {
-        fatal("smart: need a <device> argument");
+        fatal("smart: need a <disk device|name> argument");
     }
     }
 
 
-    if (diskbyname(st->arg, drivename, sizeof(drivename)) == 0)
-        fatal("smart: '%.200s' is not a disk device", st->arg);
+    initdisknamectx(&c, st->arg, drivename, sizeof(drivename));
+    fd = -1;
+
+    while (nextdiskname(&c))
+        if ((fd = open(drivename, O_RDONLY, O_NONBLOCK)) != -1)
+            break;
+
+    if (fd < 0)
+        fatal("smart: cannot open '%.200s'", st->arg);
 
 
     /* look for drive in our global table */
     /* look for drive in our global table */
     for (i = 0; i < smart_cur; i++) {
     for (i = 0; i < smart_cur; i++) {
@@ -117,11 +126,7 @@ init_smart(struct stream *st)
     p->count = DISK_BLOCK_LEN;
     p->count = DISK_BLOCK_LEN;
 
 
     /* store filedescriptor to device */
     /* store filedescriptor to device */
-    smart_devs[smart_cur].fd = open(drivename, O_RDONLY | O_NONBLOCK);
-
-    if (errno) {
-        fatal("smart: could not open '%s' for read; %.200s", drivename, strerror(errno));
-    }
+    smart_devs[smart_cur].fd = fd;
 
 
     /* store smart dev entry in stream to facilitate quick get */
     /* store smart dev entry in stream to facilitate quick get */
     st->parg.smart = smart_cur;
     st->parg.smart = smart_cur;

+ 3 - 1
symon/platform/Linux/platform.h

@@ -42,7 +42,9 @@ union semun {
 #define CP_STEAL     7
 #define CP_STEAL     7
 
 
 #define MAX_PATH_LEN       1024
 #define MAX_PATH_LEN       1024
-#define DISK_PATHS         { "/dev/%s", "/dev/disk/by-id/%s", "/dev/disk/by-label/%s", "/dev/disk/by-uuid/%s", "/dev/disk/by-path/%s", NULL }
+
+#define DISK_PATHS   { "%s", "/dev/%s", "/dev/disk/by-id/%s", "/dev/disk/by-id/%s-part1", "/dev/disk/by-label/%s", "/dev/disk/by-uuid/%s", "/dev/disk/by-path/%s", "/dev/disk/by-path/%s-part1", "/dev/mapper/%s", NULL }
+
 #define DISK_BLOCK_LEN     512
 #define DISK_BLOCK_LEN     512
 
 
 #define SENSOR_FAN       0
 #define SENSOR_FAN       0

+ 20 - 16
symon/platform/Linux/sm_df.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2011 Willem Dijkstra
+ * Copyright (c) 2011-2012 Willem Dijkstra
  * Copyright (c) 2007 Martin van der Werff
  * Copyright (c) 2007 Martin van der Werff
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -47,34 +47,38 @@
 #include "conf.h"
 #include "conf.h"
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 void
 void
 init_df(struct stream *st)
 init_df(struct stream *st)
 {
 {
+    struct disknamectx c;
     char drivename[MAX_PATH_LEN];
     char drivename[MAX_PATH_LEN];
-    FILE * fp = setmntent("/etc/mtab", "r");
+    FILE *fp;
     struct mntent *mount;
     struct mntent *mount;
 
 
-    if (fp == NULL)
-        fatal("df: cannot access /etc/mtab: %.200s", strerror(errno));
-
     if (st->arg == NULL)
     if (st->arg == NULL)
         fatal("df: need a <disk device|name> argument");
         fatal("df: need a <disk device|name> argument");
 
 
-    if (diskbyname(st->arg, drivename, sizeof(drivename)) == 0)
-        fatal("df: '%.200s' is not a disk device", st->arg);
+    initdisknamectx(&c, st->arg, drivename, sizeof(drivename));
+
+    while (nextdiskname(&c)) {
+        fp = setmntent("/etc/mtab", "r");
+
+        if (fp == NULL)
+            fatal("df: cannot access /etc/mtab: %.200s", strerror(errno));
 
 
-    while ((mount = getmntent(fp))) {
-	if (strncmp(mount->mnt_fsname, drivename, sizeof(drivename)) == 0) {
-            strlcpy(st->parg.df.mountpath, mount->mnt_dir, sizeof(st->parg.df.mountpath));
-            info("started module df(%.200s = %.200s)", st->arg, st->parg.df.mountpath);
-            endmntent(fp);
-            return;
+        while ((mount = getmntent(fp))) {
+            if (strncmp(mount->mnt_fsname, drivename, sizeof(drivename)) == 0) {
+                strlcpy(st->parg.df.mountpath, mount->mnt_dir, sizeof(st->parg.df.mountpath));
+                info("started module df(%.200s = %.200s)", st->arg, st->parg.df.mountpath);
+                endmntent(fp);
+                return;
+            }
         }
         }
-    }
 
 
-    endmntent(fp);
+        endmntent(fp);
+    }
 
 
     warning("df(%.200s): not mounted", st->arg);
     warning("df(%.200s): not mounted", st->arg);
 }
 }

+ 21 - 12
symon/platform/Linux/sm_io.c

@@ -49,7 +49,7 @@
 #include "xmalloc.h"
 #include "xmalloc.h"
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 /* Globals for this module start with io_ */
 /* Globals for this module start with io_ */
 static void *io_buf = NULL;
 static void *io_buf = NULL;
@@ -81,7 +81,8 @@ char *io_filename = "/proc/partitions";
 void
 void
 init_io(struct stream *st)
 init_io(struct stream *st)
 {
 {
-    size_t lead;
+    struct disknamectx c;
+    size_t lead = sizeof("/dev/") - 1;
 
 
     if (io_buf == NULL) {
     if (io_buf == NULL) {
         io_maxsize = SYMON_MAX_OBJSIZE;
         io_maxsize = SYMON_MAX_OBJSIZE;
@@ -91,18 +92,26 @@ init_io(struct stream *st)
     if (st->arg == NULL)
     if (st->arg == NULL)
         fatal("io: need a <device>|<devicename> argument");
         fatal("io: need a <device>|<devicename> argument");
 
 
-    if (diskbyname(st->arg, &st->parg.io[0], MAX_PATH_LEN) == 0)
-        fatal("io: '%.200s' is not a <device>|<devicename>", st->arg);
+    /* Retrieve io stats to search for devicename */
+    gets_io();
 
 
-    /* devices are named sdX, not /dev/sdX */
-    lead = sizeof("/dev/") - 1;
-    if (strncmp(st->parg.io, "/dev/", lead) == 0)
-        memmove(&st->parg.io[0], &st->parg.io[0] + lead, sizeof(st->parg.io) - lead);
+    initdisknamectx(&c, st->arg, st->parg.io, sizeof(st->parg.io));
 
 
-    if (strcmp(st->arg, st->parg.io) == 0)
-        info("started module io(%.200s)", st->parg.io);
-    else
-        info("started module io(%.200s = %.200s)", st->arg, st->parg.io);
+    while (nextdiskname(&c) != NULL) {
+        /* devices are named sdX, not /dev/sdX */
+        if (strncmp(st->parg.io, "/dev/", lead) == 0)
+            memmove(&st->parg.io[0], &st->parg.io[0] + lead, sizeof(st->parg.io) - lead);
+
+        if (strstr(io_buf, st->parg.io)) {
+            if (strcmp(st->arg, st->parg.io) == 0)
+                info("started module io(%.200s)", st->parg.io);
+            else
+                info("started module io(%.200s = %.200s)", st->arg, st->parg.io);
+            return;
+        }
+    }
+
+    warning("io(%.200s): not mounted", st->arg);
 }
 }
 
 
 void
 void

+ 16 - 7
symon/platform/Linux/sm_smart.c

@@ -44,7 +44,7 @@
 #include "error.h"
 #include "error.h"
 #include "xmalloc.h"
 #include "xmalloc.h"
 #include "smart.h"
 #include "smart.h"
-#include "diskbyname.h"
+#include "diskname.h"
 
 
 #ifndef HAS_HDDRIVECMDHDR
 #ifndef HAS_HDDRIVECMDHDR
 typedef unsigned char task_ioreg_t;
 typedef unsigned char task_ioreg_t;
@@ -86,6 +86,8 @@ static int smart_cur = 0;
 void
 void
 init_smart(struct stream *st)
 init_smart(struct stream *st)
 {
 {
+    struct disknamectx c;
+    int fd;
     int i;
     int i;
     char drivename[MAX_PATH_LEN];
     char drivename[MAX_PATH_LEN];
 
 
@@ -96,8 +98,16 @@ init_smart(struct stream *st)
     if (st->arg == NULL)
     if (st->arg == NULL)
         fatal("smart: need a <disk device|name> argument");
         fatal("smart: need a <disk device|name> argument");
 
 
-    if (diskbyname(st->arg, drivename, sizeof(drivename)) == 0)
-        fatal("smart: '%.200s' is not a disk device", st->arg);
+    initdisknamectx(&c, st->arg, drivename, sizeof(drivename));
+
+    fd = -1;
+    while (nextdiskname(&c))
+        if ((fd = open(drivename, O_RDONLY | O_NONBLOCK)) != -1)
+            break;
+
+
+    if (fd < 0)
+        fatal("smart: cannot open '%.200s'", st->arg);
 
 
     /* look for drive in our global table */
     /* look for drive in our global table */
     for (i = 0; i < smart_cur; i++) {
     for (i = 0; i < smart_cur; i++) {
@@ -121,8 +131,7 @@ init_smart(struct stream *st)
     strlcpy(smart_devs[smart_cur].name, drivename, sizeof(smart_devs[0].name));
     strlcpy(smart_devs[smart_cur].name, drivename, sizeof(smart_devs[0].name));
 
 
     /* store filedescriptor to device */
     /* store filedescriptor to device */
-    if ((smart_devs[smart_cur].fd = open(drivename, O_RDONLY | O_NONBLOCK)) < 0)
-        fatal("smart: could not open '%.200s' for read: %.200s", drivename, strerror(errno));
+    smart_devs[smart_cur].fd = fd;
 
 
     /* store smart dev entry in stream to facilitate quick get */
     /* store smart dev entry in stream to facilitate quick get */
     st->parg.smart = smart_cur;
     st->parg.smart = smart_cur;
@@ -141,8 +150,8 @@ gets_smart()
         /* populate ata command header */
         /* populate ata command header */
         memcpy(&smart_devs[i].cmd, (void *) &smart_cmd, sizeof(struct hd_drive_cmd_hdr));
         memcpy(&smart_devs[i].cmd, (void *) &smart_cmd, sizeof(struct hd_drive_cmd_hdr));
         if (ioctl(smart_devs[i].fd, HDIO_DRIVE_CMD, &smart_devs[i].cmd)) {
         if (ioctl(smart_devs[i].fd, HDIO_DRIVE_CMD, &smart_devs[i].cmd)) {
-            warning("smart: ioctl for drive '%s' failed: %d",
-                    &smart_devs[i].name, errno);
+            warning("smart: ioctl for drive '%.200s' failed: %.200s",
+                    &smart_devs[i].name, strerror(errno));
             smart_devs[i].failed = 1;
             smart_devs[i].failed = 1;
         }
         }
 
 

+ 2 - 10
symon/platform/NetBSD/sm_df.c

@@ -51,7 +51,6 @@
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-#include "diskbyname.h"
 #include "error.h"
 #include "error.h"
 #include "symon.h"
 #include "symon.h"
 
 
@@ -62,15 +61,8 @@ static int df_parts = 0;
 void
 void
 init_df(struct stream *st)
 init_df(struct stream *st)
 {
 {
-    char drivename[MAX_PATH_LEN];
-
-    if (st->arg == NULL)
-        fatal("io: need a <disk device|name> argument");
-
-    if (diskbyname(st->arg, drivename, sizeof(drivename)) == 0)
-        fatal("io: '%.200s' is not a disk device", st->arg);
-
-    strlcpy(st->parg.df.rawdev, drivename, sizeof(st->parg.df.rawdev));
+    strlcpy(st->parg.df.rawdev, "/dev/", sizeof(st->parg.df.rawdev));
+    strlcat(st->parg.df.rawdev, st->arg, sizeof(st->parg.df.rawdev));
 
 
     info("started module df(%.200s)", st->arg);
     info("started module df(%.200s)", st->arg);
 }
 }

+ 2 - 1
symon/symon/Makefile

@@ -12,7 +12,7 @@ MODS!=	( for s in ../platform/stub/sm_*.c; do \
 		fi; fi; \
 		fi; fi; \
 	  done )
 	  done )
 
 
-SRCS=	symon.c readconf.c symonnet.c ${MODS}
+SRCS=	symon.c readconf.c symonnet.c ${MODS} ${EXTRA_SRC}
 OBJS+=	${SRCS:R:S/$/.o/g}
 OBJS+=	${SRCS:R:S/$/.o/g}
 CFLAGS+=-I../lib -I../platform/${OS} -I.
 CFLAGS+=-I../lib -I../platform/${OS} -I.
 
 
@@ -30,6 +30,7 @@ clean:
 	rm -f conf.h symon symon.cat8 symon.core ${OBJS}
 	rm -f conf.h symon symon.cat8 symon.core ${OBJS}
 
 
 install: symon symon.8 symon.conf
 install: symon symon.8 symon.conf
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${BINDIR}
 	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon      ${PREFIX}/${BINDIR}/
 	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon      ${PREFIX}/${BINDIR}/
 	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
 	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
 	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon.8 ${PREFIX}/${MANDIR}/man8/symon.8
 	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symon.8 ${PREFIX}/${MANDIR}/man8/symon.8

+ 4 - 2
symon/symon/symon.8

@@ -1,6 +1,6 @@
 .\"  -*- nroff -*-
 .\"  -*- nroff -*-
 .\"
 .\"
-.\" Copyright (c) 2001-2010 Willem Dijkstra
+.\" Copyright (c) 2001-2012 Willem Dijkstra
 .\" All rights reserved.
 .\" All rights reserved.
 .\"
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd October 20, 2010
+.Dd April 4, 2012
 .Dt SYMON 8
 .Dt SYMON 8
 .Os
 .Os
 .Sh NAME
 .Sh NAME
@@ -128,6 +128,8 @@ set in /etc/pf.conf(5).
 .Pp
 .Pp
 The Linux io, df, and smart probes support device names via id, label, path and uuid.
 The Linux io, df, and smart probes support device names via id, label, path and uuid.
 .Pp
 .Pp
+The FreeBSD io, df, and smart probes support gpt names, ufs names, ufs ids and paths.
+.Pp
 The OpenBSD io probe supports device uuids.
 The OpenBSD io probe supports device uuids.
 .Pp
 .Pp
 .Sh EXAMPLE
 .Sh EXAMPLE

+ 1 - 0
symon/symux/Makefile

@@ -19,6 +19,7 @@ clean:
 	rm -f conf.h symux symux.cat8 symux.core ${OBJS}
 	rm -f conf.h symux symux.cat8 symux.core ${OBJS}
 
 
 install: symux symux.8 c_smrrds.sh symux.conf
 install: symux symux.8 c_smrrds.sh symux.conf
+	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${BINDIR}
 	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux	   ${PREFIX}/${BINDIR}/
 	${INSTALL} -c -m 555 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux	   ${PREFIX}/${BINDIR}/
 	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
 	${INSTALL} -d -m 555 -g ${INSTALLGROUPDIR} -o ${INSTALLUSER} ${PREFIX}/${MANDIR}/man8
 	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux.8	   ${PREFIX}/${MANDIR}/man8/symux.8
 	${INSTALL} -c -m 444 -g ${INSTALLGROUPFILE} -o ${INSTALLUSER} symux.8	   ${PREFIX}/${MANDIR}/man8/symux.8

+ 2 - 2
symon/symux/symux.8

@@ -1,6 +1,6 @@
 .\"  -*- nroff -*-
 .\"  -*- nroff -*-
 .\"
 .\"
-.\" Copyright (c) 2001-2010 Willem Dijkstra
+.\" Copyright (c) 2001-2012 Willem Dijkstra
 .\" All rights reserved.
 .\" All rights reserved.
 .\"
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd October 20, 2010
+.Dd April 4, 2012
 .Dt SYMUX 8
 .Dt SYMUX 8
 .Os
 .Os
 .Sh NAME
 .Sh NAME