From owner-freebsd-scsi@FreeBSD.ORG Tue Aug 2 16:08:39 2005 Return-Path: X-Original-To: freebsd-scsi@freebsd.org Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0673216A41F; Tue, 2 Aug 2005 16:08:39 +0000 (GMT) (envelope-from ken@nargothrond.kdm.org) Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F03C43D45; Tue, 2 Aug 2005 16:08:38 +0000 (GMT) (envelope-from ken@nargothrond.kdm.org) Received: from nargothrond.kdm.org (localhost [127.0.0.1]) by nargothrond.kdm.org (8.12.11/8.12.11) with ESMTP id j72G8bkS040797; Tue, 2 Aug 2005 10:08:37 -0600 (MDT) (envelope-from ken@nargothrond.kdm.org) Received: (from ken@localhost) by nargothrond.kdm.org (8.12.11/8.12.5/Submit) id j72G8Xan040796; Tue, 2 Aug 2005 10:08:33 -0600 (MDT) (envelope-from ken) Date: Tue, 2 Aug 2005 10:08:33 -0600 From: "Kenneth D. Merry" To: Reinhold Huber Message-ID: <20050802160833.GA40616@nargothrond.kdm.org> References: <20050802143200.GA24341@fs.tum.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050802143200.GA24341@fs.tum.de> User-Agent: Mutt/1.4.2i X-Virus-Scanned: ClamAV 0.86.1/1001/Tue Aug 2 02:22:39 2005 on nargothrond.kdm.org X-Virus-Status: Clean Cc: freebsd-scsi@freebsd.org, freebsd-questions@freebsd.org Subject: Re: CAM SCSI, finding out bus ID, target and LUN X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2005 16:08:39 -0000 On Tue, Aug 02, 2005 at 16:32:00 +0200, Reinhold Huber wrote: > Hello, > > I'm trying to get bus ID, target and LUN to an open fd which is afaik > opened to the device special file, e.g. /dev/cd0 . > > So how do I get the information? Up to now, I didn't find IOCTL calls > (like in NetBSD) which deliver this kind of info, and first tries to > browse in CAM examples didn't help either. > > I tried on FreeBSD 5.3 and currently hope that there are no big > changes to this between 5.3 and 5.4 or even -current. If I'm > wrong with this, please correct me. > > Any pointer to docs or source is welcome. (For this sort of query you might get better answers from the freebsd-scsi list, CCed.) You could try issuing the CAMGETPASSTHRU ioctl. Unfortunately it was broken for the cd(4) driver before 5.4 when there is no media in the drive. It will give you the pass(4) instance associated with that particular cd(4) instance. It doesn't work for the da(4) driver, since the GEOM code has taken over the ioctl routine for that driver. It should work for the cd(4), ch(4), pass(4), pt(4), sa(4) and ses(4) drivers. The CCB header for the XPT_GDEVLIST CCB returned from the CAMGETPASSTHRU ioctl should have the correct path, target and LUN if that's all you want. (The pass driver instance and unit number are in the payload.) If you want something that works consistently across all CAM peripheral drivers, you'll need to know the device name and unit number of the device you're talking to. Then you can open its associated pass(4) device with cam_open_spec_device(3). If you just have the device path name, you can try cam_open_device(3). It will attempt to parse out the path name for you. In either case, the cam_device structure returned will also have the path, target and LUN for the device. One obvious prerequisite for all of this is that you have to know ahead of time that you're talking to a CAM device. These mechanisms don't work otherwise. Ken -- Kenneth Merry ken@FreeBSD.ORG