summaryrefslogtreecommitdiffstats
path: root/share/examples/ses
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-11-21 10:22:01 +0000
committermav <mav@FreeBSD.org>2015-11-21 10:22:01 +0000
commit1ad504c2e11d5d784bf6bae3b6bd824393467f19 (patch)
tree7a2f302dcf81307ff266fb289e272fbed018392b /share/examples/ses
parentf39667d4135a58d530c1a5812f3e35188790475c (diff)
downloadFreeBSD-src-1ad504c2e11d5d784bf6bae3b6bd824393467f19.zip
FreeBSD-src-1ad504c2e11d5d784bf6bae3b6bd824393467f19.tar.gz
Add API to obtain primary enclosure name and ID for /dev/sesX devices.
sesX device number may change between reboots, so to properly identify the instance we need more data. Name and ID reported here may mach ones reported by SCSI device, but that is not really required by specs. MFC after: 1 week Sponsored by: iXsystems, Inc.
Diffstat (limited to 'share/examples/ses')
-rw-r--r--share/examples/ses/srcs/getencstat.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/share/examples/ses/srcs/getencstat.c b/share/examples/ses/srcs/getencstat.c
index 9048f73..7cdde90 100644
--- a/share/examples/ses/srcs/getencstat.c
+++ b/share/examples/ses/srcs/getencstat.c
@@ -48,12 +48,14 @@
int
main(int a, char **v)
{
+ encioc_string_t stri;
encioc_element_t *objp;
encioc_elm_status_t ob;
encioc_elm_desc_t objd;
encioc_elm_devnames_t objdn;
int fd, nobj, f, i, verbose, quiet, errors;
u_char estat;
+ char str[32];
if (a < 2) {
fprintf(stderr, "usage: %s [ -v ] device [ device ... ]\n", *v);
@@ -78,6 +80,16 @@ main(int a, char **v)
perror(*v);
continue;
}
+ if (verbose > 1) {
+ stri.bufsiz = sizeof(str);
+ stri.buf = &str[0];
+ if (ioctl(fd, ENCIOC_GETENCNAME, (caddr_t) &stri) == 0)
+ printf("%s: Enclosure Name: %s\n", *v, stri.buf);
+ stri.bufsiz = sizeof(str);
+ stri.buf = &str[0];
+ if (ioctl(fd, ENCIOC_GETENCID, (caddr_t) &stri) == 0)
+ printf("%s: Enclosure ID: %s\n", *v, stri.buf);
+ }
if (ioctl(fd, ENCIOC_GETNELM, (caddr_t) &nobj) < 0) {
perror("ENCIOC_GETNELM");
(void) close(fd);
OpenPOWER on IntegriCloud