From 7c2f90e37a292a6cb6d4d0efa2dacd5db7cc3fd8 Mon Sep 17 00:00:00 2001 From: mav Date: Sat, 28 Nov 2015 17:26:46 +0000 Subject: MFC r291126: 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. Sponsored by: iXsystems, Inc. --- share/examples/ses/srcs/getencstat.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'share/examples/ses/srcs/getencstat.c') 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); -- cgit v1.1