Add the '-b' flag to 'camcontrol devlist'. This prints only the existing
buses and their parent sims, useful for creating a sim->bus->device map. Obtained from: Netflix MFC after: 3 days
This commit is contained in:
parent
e6ebfc7ca9
commit
56dc4e726b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260059
@ -41,6 +41,7 @@
|
|||||||
.Op command args
|
.Op command args
|
||||||
.Nm
|
.Nm
|
||||||
.Ic devlist
|
.Ic devlist
|
||||||
|
.Op Fl b
|
||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Nm
|
.Nm
|
||||||
.Ic periphlist
|
.Ic periphlist
|
||||||
@ -361,6 +362,10 @@ With the
|
|||||||
.Fl v
|
.Fl v
|
||||||
argument, SCSI bus number, adapter name and unit numbers are printed as
|
argument, SCSI bus number, adapter name and unit numbers are printed as
|
||||||
well.
|
well.
|
||||||
|
On the other hand, with the
|
||||||
|
.Fl b
|
||||||
|
argument, only the bus adapter, and unit information will be printed, and
|
||||||
|
device information will be omitted.
|
||||||
.It Ic periphlist
|
.It Ic periphlist
|
||||||
List all peripheral drivers attached to a given physical device (logical
|
List all peripheral drivers attached to a given physical device (logical
|
||||||
unit).
|
unit).
|
||||||
|
@ -202,7 +202,7 @@ static struct camcontrol_opts option_table[] = {
|
|||||||
{"defects", CAM_CMD_READ_DEFECTS, CAM_ARG_NONE, readdefect_opts},
|
{"defects", CAM_CMD_READ_DEFECTS, CAM_ARG_NONE, readdefect_opts},
|
||||||
{"defectlist", CAM_CMD_READ_DEFECTS, CAM_ARG_NONE, readdefect_opts},
|
{"defectlist", CAM_CMD_READ_DEFECTS, CAM_ARG_NONE, readdefect_opts},
|
||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
{"devlist", CAM_CMD_DEVTREE, CAM_ARG_NONE, NULL},
|
{"devlist", CAM_CMD_DEVTREE, CAM_ARG_NONE, "-b"},
|
||||||
#ifndef MINIMALISTIC
|
#ifndef MINIMALISTIC
|
||||||
{"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL},
|
{"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL},
|
||||||
{"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "bdelm:P:"},
|
{"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "bdelm:P:"},
|
||||||
@ -254,7 +254,7 @@ camcontrol_optret getoption(struct camcontrol_opts *table, char *arg,
|
|||||||
#ifndef MINIMALISTIC
|
#ifndef MINIMALISTIC
|
||||||
static int getdevlist(struct cam_device *device);
|
static int getdevlist(struct cam_device *device);
|
||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
static int getdevtree(void);
|
static int getdevtree(int argc, char **argv, char *combinedopt);
|
||||||
#ifndef MINIMALISTIC
|
#ifndef MINIMALISTIC
|
||||||
static int testunitready(struct cam_device *device, int retry_count,
|
static int testunitready(struct cam_device *device, int retry_count,
|
||||||
int timeout, int quiet);
|
int timeout, int quiet);
|
||||||
@ -411,7 +411,7 @@ getdevlist(struct cam_device *device)
|
|||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getdevtree(void)
|
getdevtree(int argc, char **argv, char *combinedopt)
|
||||||
{
|
{
|
||||||
union ccb ccb;
|
union ccb ccb;
|
||||||
int bufsize, fd;
|
int bufsize, fd;
|
||||||
@ -419,6 +419,19 @@ getdevtree(void)
|
|||||||
int need_close = 0;
|
int need_close = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int skip_device = 0;
|
int skip_device = 0;
|
||||||
|
int busonly = 0;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
while ((c = getopt(argc, argv, combinedopt)) != -1) {
|
||||||
|
switch(c) {
|
||||||
|
case 'b':
|
||||||
|
if ((arglist & CAM_ARG_VERBOSE) == 0)
|
||||||
|
busonly = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) {
|
if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) {
|
||||||
warn("couldn't open %s", XPT_DEVICE);
|
warn("couldn't open %s", XPT_DEVICE);
|
||||||
@ -478,7 +491,8 @@ getdevtree(void)
|
|||||||
* Only print the bus information if the
|
* Only print the bus information if the
|
||||||
* user turns on the verbose flag.
|
* user turns on the verbose flag.
|
||||||
*/
|
*/
|
||||||
if ((arglist & CAM_ARG_VERBOSE) == 0)
|
if ((busonly == 0) &&
|
||||||
|
(arglist & CAM_ARG_VERBOSE) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
bus_result =
|
bus_result =
|
||||||
@ -489,11 +503,12 @@ getdevtree(void)
|
|||||||
need_close = 0;
|
need_close = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "scbus%d on %s%d bus %d:\n",
|
fprintf(stdout, "scbus%d on %s%d bus %d%s\n",
|
||||||
bus_result->path_id,
|
bus_result->path_id,
|
||||||
bus_result->dev_name,
|
bus_result->dev_name,
|
||||||
bus_result->unit_number,
|
bus_result->unit_number,
|
||||||
bus_result->bus_id);
|
bus_result->bus_id,
|
||||||
|
(busonly ? "" : ":"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEV_MATCH_DEVICE: {
|
case DEV_MATCH_DEVICE: {
|
||||||
@ -501,6 +516,9 @@ getdevtree(void)
|
|||||||
char vendor[16], product[48], revision[16];
|
char vendor[16], product[48], revision[16];
|
||||||
char fw[5], tmpstr[256];
|
char fw[5], tmpstr[256];
|
||||||
|
|
||||||
|
if (busonly == 1)
|
||||||
|
break;
|
||||||
|
|
||||||
dev_result =
|
dev_result =
|
||||||
&ccb.cdm.matches[i].result.device_result;
|
&ccb.cdm.matches[i].result.device_result;
|
||||||
|
|
||||||
@ -582,7 +600,7 @@ getdevtree(void)
|
|||||||
periph_result =
|
periph_result =
|
||||||
&ccb.cdm.matches[i].result.periph_result;
|
&ccb.cdm.matches[i].result.periph_result;
|
||||||
|
|
||||||
if (skip_device != 0)
|
if (busonly || skip_device != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (need_close > 1)
|
if (need_close > 1)
|
||||||
@ -8178,7 +8196,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
case CAM_CMD_DEVTREE:
|
case CAM_CMD_DEVTREE:
|
||||||
error = getdevtree();
|
error = getdevtree(argc, argv, combinedopt);
|
||||||
break;
|
break;
|
||||||
#ifndef MINIMALISTIC
|
#ifndef MINIMALISTIC
|
||||||
case CAM_CMD_TUR:
|
case CAM_CMD_TUR:
|
||||||
|
Loading…
Reference in New Issue
Block a user