From owner-freebsd-scsi Thu Nov 25 7:13:53 1999 Delivered-To: freebsd-scsi@freebsd.org Received: from narnia.plutotech.com (narnia.plutotech.com [206.168.67.130]) by hub.freebsd.org (Postfix) with ESMTP id 65F0614D4D for ; Thu, 25 Nov 1999 07:13:50 -0800 (PST) (envelope-from gibbs@narnia.plutotech.com) Received: (from gibbs@localhost) by narnia.plutotech.com (8.9.3/8.7.3) id IAA99696; Thu, 25 Nov 1999 08:03:37 -0700 (MST) Date: Thu, 25 Nov 1999 08:03:37 -0700 (MST) From: "Justin T. Gibbs" Message-Id: <199911251503.IAA99696@narnia.plutotech.com> To: Nick Hibma Cc: scsi@FreeBSD.org Subject: Re: found device. X-Newsgroups: pluto.freebsd.scsi In-Reply-To: User-Agent: tin/pre-1.4-980818 ("Laura") (UNIX) (FreeBSD/4.0-CURRENT (i386)) Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org In article you wrote: > > How do I make sure the bus is rescanned when a new target has appeared? > > Whenever a new device is attached, I would like the SCSI bus to which it > is connected to be rescanned. The following code however doesn't do the > job it seems (FYI: All USB Zip drives are connected to 1 SCSI bus, bus > 0). > > Nick > > > static int > umass_cam_rescan(umass_softc_t *sc) > { > union ccb *ccb; > struct cam_path *path; > struct cam_periph *periph; > > if (xpt_create_path(&path, NULL, CAM_XPT_PATH_ID, > CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) > != CAM_REQ_CMP) > return(ENOMEM); > > periph = cam_periph_find(path, NULL/*name*/); > if (!periph) > return(EINVAL); The only time you will ever find a peripheral on the wildcard node is if you are using the target mode black hole device. You probably want to use 0 and 0 for the target and lun respectively. (cam_periph_find looks for exact matches, and will not exand wildcards). > if (xpt_create_path(&sc->path, periph, cam_sim_path(umass_sim), > device_get_unit(sc->sc_dev), CAM_LUN_WILDCARD) > != CAM_REQ_CMP) > return(ENOMEM); > > ccb = malloc(sizeof(union ccb), M_DEVBUF, M_WAITOK); > xpt_setup_ccb(&ccb->ccb_h, sc->path, 5/*priority (low)*/); > ccb->ccb_h.func_code = XPT_SCAN_LUN; > ccb->ccb_h.cbfcnp = umass_cam_attach_callback; > ccb->crcn.flags = CAM_FLAG_NONE; > xpt_action(ccb); > > return(0); > } If you simply want to rescan the bus, try XPT_SCAN_BUS. -- Justin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message