summaryrefslogtreecommitdiffstats
path: root/sbin/camcontrol
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2004-03-03 01:51:24 +0000
committerken <ken@FreeBSD.org>2004-03-03 01:51:24 +0000
commitad706f7e3df834c44510a7b48d6fcd7ca096448c (patch)
treeac0008c512b35b81b718ad3733a16c980ada1b4c /sbin/camcontrol
parent206b5dcf52404648c53b71b3cd1ab0cd84426bbb (diff)
downloadFreeBSD-src-ad706f7e3df834c44510a7b48d6fcd7ca096448c.zip
FreeBSD-src-ad706f7e3df834c44510a7b48d6fcd7ca096448c.tar.gz
Fix a couple of camcontrol issues that popped up on sparc64:
- bzero the CCB header in getdevtree() and set the path properly, to avoid having random garbage in the CCB header. - if the lun isn't specified in a device specifier, it should default to 0, not whatever random data happens to be in the lun variable. - move the prototype for getdevtree() out from under #ifndef MINIMALISTIC, since it is used in both cases. Submitted by: Marius Strobl <marius@alchemy.franken.de> (mostly) MFC After: 2 weeks
Diffstat (limited to 'sbin/camcontrol')
-rw-r--r--sbin/camcontrol/camcontrol.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index 3b4889e..acf9ae1 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -166,7 +166,9 @@ camcontrol_optret getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
const char **subopt);
#ifndef MINIMALISTIC
static int getdevlist(struct cam_device *device);
+#endif /* MINIMALISTIC */
static int getdevtree(void);
+#ifndef MINIMALISTIC
static int testunitready(struct cam_device *device, int retry_count,
int timeout, int quiet);
static int scsistart(struct cam_device *device, int startstop, int loadeject,
@@ -303,8 +305,11 @@ getdevtree(void)
return(1);
}
- bzero(&(&ccb.ccb_h)[1],
- sizeof(struct ccb_dev_match) - sizeof(struct ccb_hdr));
+ bzero(&ccb, sizeof(union ccb));
+
+ ccb.ccb_h.path_id = CAM_XPT_PATH_ID;
+ ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
+ ccb.ccb_h.target_lun = CAM_LUN_WILDCARD;
ccb.ccb_h.func_code = XPT_DEV_MATCH;
bufsize = sizeof(struct dev_match_result) * 100;
@@ -3380,6 +3385,11 @@ main(int argc, char **argv)
errx(1, "numeric device specification must "
"be either bus:target, or "
"bus:target:lun");
+ /* default to 0 if lun was not specified */
+ if ((arglist & CAM_ARG_LUN) == 0) {
+ lun = 0;
+ arglist |= CAM_ARG_LUN;
+ }
optstart++;
} else {
if (cam_get_device(argv[2], name, sizeof name, &unit)
OpenPOWER on IntegriCloud