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.
This commit is contained in:
Alexander Motin
2015-11-21 10:22:01 +00:00
parent fe50a38eb0
commit 6d2a1fbf23
4 changed files with 70 additions and 3 deletions
+12
View File
@@ -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);