svn commit: r288710 - stable/10/usr.sbin/sesutil
Baptiste Daroussin
bapt at FreeBSD.org
Mon Oct 5 08:18:32 UTC 2015
Author: bapt
Date: Mon Oct 5 08:18:31 2015
New Revision: 288710
URL: https://svnweb.freebsd.org/changeset/base/288710
Log:
MFC 287473,287485,287493,287494
Add a new sesutil(8) utility
This is an utility for managing SCSI Enclosure Services (SES) device.
For now only one command is supported "locate" which will change the test of the
external LED associated to a given disk.
Usage if the following:
sesutil locate disk [on|off]
Disk can be a device name: "da12" or a special keyword: "all".
Reviewed by: mav
Relnotes: yes
Sponsored by: gandi.net
Added:
stable/10/usr.sbin/sesutil/
- copied from r287473, head/usr.sbin/sesutil/
Modified:
stable/10/usr.sbin/sesutil/sesutil.c
Modified: stable/10/usr.sbin/sesutil/sesutil.c
==============================================================================
--- head/usr.sbin/sesutil/sesutil.c Sat Sep 5 00:06:01 2015 (r287473)
+++ stable/10/usr.sbin/sesutil/sesutil.c Mon Oct 5 08:18:31 2015 (r288710)
@@ -83,13 +83,13 @@ do_locate(int fd, unsigned int idx, bool
static bool
disk_match(const char *devnames, const char *disk, size_t len)
{
- const char *devname;
+ const char *dname;
- devname = devnames;
- while ((devname = strstr(devname, disk)) != NULL) {
- if (devname[len] == '\0' || devname[len] == ',')
+ dname = devnames;
+ while ((dname = strstr(dname, disk)) != NULL) {
+ if (dname[len] == '\0' || dname[len] == ',')
return (true);
- devname++;
+ dname++;
}
return (false);
}
@@ -104,7 +104,7 @@ locate(int argc, char **argv)
size_t len, i;
int fd, nobj, j;
bool all = false;
- bool locate;
+ bool onoff;
if (argc != 2) {
errx(EXIT_FAILURE, "usage: %s locate [disk] [on|off]",
@@ -114,9 +114,9 @@ locate(int argc, char **argv)
disk = argv[0];
if (strcmp(argv[1], "on") == 0) {
- locate = true;
+ onoff = true;
} else if (strcmp(argv[1], "off") == 0) {
- locate = false;
+ onoff = false;
} else {
errx(EXIT_FAILURE, "usage: %s locate [disk] [on|off]",
getprogname());
@@ -165,17 +165,16 @@ locate(int argc, char **argv)
continue;
if (objdn.elm_names_len > 0) {
if (all) {
- do_locate(fd, objdn.elm_idx, locate);
+ do_locate(fd, objdn.elm_idx, onoff);
continue;
}
if (disk_match(objdn.elm_devnames, disk, len)) {
- do_locate(fd, objdn.elm_idx, locate);
+ do_locate(fd, objdn.elm_idx, onoff);
break;
}
}
}
close(fd);
- i++;
}
globfree(&g);
More information about the svn-src-stable-10
mailing list