public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* bus:id:lun to device name
@ 2003-07-02 15:24 Stefan Voelkel
  2003-07-08 14:50 ` Kurt Garloff
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Voelkel @ 2003-07-02 15:24 UTC (permalink / raw)
  To: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

Hi,

I want to convert a bus:id:lun triple to something like "/dev/sda".

From userspace I can ioctl() /dev/s[d|cd|...]* or parse /proc/scsi/scsi.
I do not like any of those solutions.

Since a kernel module is already involved, I was wondering if it
can/may/should be done from kernelspace. As of 2.4.21 some data
structures from the middle layer are exported, but with a "debug only"
comment.

regards
	Stefan
-- 
--------------------------------------------------------------------
Stefan Völkel                            stefan.voelkel@millenux.com
Millenux GmbH                              mobile: +49.170.79177.17
Lilienthalstraße 2                          phone: +49.711.88770.300
70825 Stuttgart-Korntal                       fax: +49.711.88770.349
     -= linux without limits -=- http://linux.zSeries.org/ =-

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bus:id:lun to device name
  2003-07-02 15:24 bus:id:lun to device name Stefan Voelkel
@ 2003-07-08 14:50 ` Kurt Garloff
  2003-07-15 14:45   ` Stefan Voelkel
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Garloff @ 2003-07-08 14:50 UTC (permalink / raw)
  To: Stefan Voelkel; +Cc: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

Hi Stefan,

On Wed, Jul 02, 2003 at 05:24:08PM +0200, Stefan Voelkel wrote:
> I want to convert a bus:id:lun triple to something like "/dev/sda".
> 
> From userspace I can ioctl() /dev/s[d|cd|...]* or parse /proc/scsi/scsi.

Plain /proc/scsi/scsi does not help you.
You may want to have a lok at the scsi-many patches that export this
information via /proc/scsi/scsi though.
http://www.suse.de/~garloff/linux/scsi-many/

Host: scsi3 Channel: 00 Id: 10 Lun: 00
  Vendor: IBM      Model: DDYS-T18350N     Rev: S84D
  Type:   Direct-Access                    ANSI SCSI revision: 03
  Attached drivers: sde(b:08:40) sg5(c:15:05)

> I do not like any of those solutions.

For non-removable harddisks, the ioctl() just works fine, BTW.
I see no reason to dislike it.

Another option is to use scsidev
http://www.garloff.de/kurt/linux/scsidev/
where the device nodes are dynamically created and (by default) have 
names which contain this information.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers                 SuSE Labs (Head)
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bus:id:lun to device name
  2003-07-08 14:50 ` Kurt Garloff
@ 2003-07-15 14:45   ` Stefan Voelkel
  2003-07-15 17:03     ` Bryan Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Voelkel @ 2003-07-15 14:45 UTC (permalink / raw)
  To: Kurt Garloff; +Cc: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

On Tue, 2003-07-08 at 16:50, Kurt Garloff wrote:
> Hi Stefan,
> 
> On Wed, Jul 02, 2003 at 05:24:08PM +0200, Stefan Voelkel wrote:
> > I want to convert a bus:id:lun triple to something like "/dev/sda".
> > 
> > From userspace I can ioctl() /dev/s[d|cd|...]* or parse /proc/scsi/scsi.
> 
> Plain /proc/scsi/scsi does not help you.
> You may want to have a lok at the scsi-many patches that export this
> information via /proc/scsi/scsi though.
> http://www.suse.de/~garloff/linux/scsi-many/

I can not patch the middle layer.

> Host: scsi3 Channel: 00 Id: 10 Lun: 00
>   Vendor: IBM      Model: DDYS-T18350N     Rev: S84D
>   Type:   Direct-Access                    ANSI SCSI revision: 03
>   Attached drivers: sde(b:08:40) sg5(c:15:05)
> 
> > I do not like any of those solutions.
> 
> For non-removable harddisks, the ioctl() just works fine, BTW.
> I see no reason to dislike it.

Theoretically /dev/foobar might be a scsi device, meaning that I
must/should ioctl() all files under /dev/. Thats what I do not like
about ioctl() :).

> Another option is to use scsidev
> http://www.garloff.de/kurt/linux/scsidev/
> where the device nodes are dynamically created and (by default) have 
> names which contain this information.

AFAIR devfs does this too, depending on devfs would be an option.

regards
	Stefan
-- 
--------------------------------------------------------------------
Stefan Völkel                            stefan.voelkel@millenux.com
Millenux GmbH                              mobile: +49.170.79177.17
Lilienthalstraße 2                          phone: +49.711.88770.300
70825 Stuttgart-Korntal                       fax: +49.711.88770.349
     -= linux without limits -=- http://linux.zSeries.org/ =-

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bus:id:lun to device name
  2003-07-15 14:45   ` Stefan Voelkel
@ 2003-07-15 17:03     ` Bryan Henderson
  2003-07-16  8:29       ` Stefan Voelkel
  0 siblings, 1 reply; 6+ messages in thread
From: Bryan Henderson @ 2003-07-15 17:03 UTC (permalink / raw)
  To: Stefan Voelkel; +Cc: Kurt Garloff, linux-scsi





>Theoretically /dev/foobar might be a scsi device, meaning that I
>must/should ioctl() all files under /dev/. Thats what I do not like
>about ioctl() :).

Even that is an oversimplification of the problem.  /home/bryanh/foo could
be a SCSI device.  It could be the same device as /dev/sda.  The device
could have no device special file at all (maybe a program that accesses the
device creates the device special file on the fly.  Maybe the file has been
deleted since the device was opened).

Once you admit that devices in Linux are not fundamentally associated with
names in the file tree, the problem takes on a whole new perspective.

On the other hand, if you're willing to constrain your world such that
there is such an association (by setting up rules about how you will and
will not use device special files), then there's really nothing wrong with
saying all SCSI devices will be accessed via device special file names in a
certain list, and then doing the ioctl to each file in that list to find
out which SCSI device it is.

>> Another option is to use scsidev
>> http://www.garloff.de/kurt/linux/scsidev/
>> where the device nodes are dynamically created and (by default) have
>> names which contain this information.
>
>AFAIR devfs does this too, depending on devfs would be an option.

Then it isn't clear which specific problem you're trying to solve.  Do you
mean you want _a_ device special file by which you can access the device,
and any will do?  In that case a scsidev/devfs solution would work.  You
could also use sg devices (via permanent device special files, or ones made
up on the fly).  Or do you want the name by which people normally know and
use the device?  E.g. "I have /dev/sda mounted, but what device is that?"


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bus:id:lun to device name
  2003-07-15 17:03     ` Bryan Henderson
@ 2003-07-16  8:29       ` Stefan Voelkel
  2003-07-17 10:29         ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Voelkel @ 2003-07-16  8:29 UTC (permalink / raw)
  To: Bryan Henderson; +Cc: Kurt Garloff, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 2131 bytes --]

On Tue, 2003-07-15 at 19:03, Bryan Henderson wrote:
> 
> 
> >Theoretically /dev/foobar might be a scsi device, meaning that I
> >must/should ioctl() all files under /dev/. Thats what I do not like
> >about ioctl() :).
> 
> Once you admit that devices in Linux are not fundamentally associated with
> names in the file tree, the problem takes on a whole new perspective.

True. What I do not like about a list of devices is the fact that I will
duplicate code, eg (from sd.c)

static void sd_devname(unsigned int disknum, char *buffer)

> >> Another option is to use scsidev
> >> http://www.garloff.de/kurt/linux/scsidev/
> >> where the device nodes are dynamically created and (by default) have
> >> names which contain this information.
> >
> >AFAIR devfs does this too, depending on devfs would be an option.
> 
> [...] Or do you want the name by which people normally know and
> use the device?  E.g. "I have /dev/sda mounted, but what device is that?"

Yes, basically. I have this information: host_id:bus:target:lun, and now
I'd like the "device file name with which one normally access' this
specific lun".

Let me give you some details (hope that will make it clearer). I am
implementing FC-HBA (ftp://ftp.t11.org/t11/pub/fc/hba/03-108v2.pdf). The
problem occures with HBA_GetFcpTargetMapping() on page 73 (7.4.4), the
parameters are describerd on page 31 (6.6.1) and the specific struct is
HBA_ScsiId (6.6.1.5), actually the member OSDeviceName (6.6.2.11).

As it seems, I must use the file-name-list-ioctl() approach without
devfs and something like snprintf("/dev/scsi/host%d/bus%d/...", ...); if
devfs is mounted.

Thank you all for your time

regards
	Stefan
-- 
--------------------------------------------------------------------
Stefan Völkel                            stefan.voelkel@millenux.com
Millenux GmbH                              mobile: +49.170.79177.17
Lilienthalstraße 2                          phone: +49.711.88770.300
70825 Stuttgart-Korntal                       fax: +49.711.88770.349
     -= linux without limits -=- http://linux.zSeries.org/ =-

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bus:id:lun to device name
  2003-07-16  8:29       ` Stefan Voelkel
@ 2003-07-17 10:29         ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2003-07-17 10:29 UTC (permalink / raw)
  To: Stefan Voelkel; +Cc: Bryan Henderson, Kurt Garloff, linux-scsi

On Wed, Jul 16, 2003 at 10:29:52AM +0200, Stefan Voelkel wrote:
> Yes, basically. I have this information: host_id:bus:target:lun, and now
> I'd like the "device file name with which one normally access' this
> specific lun".

This is not possible in Linux as it's a userspace policy decision.
E.g. scsi cdrom devices at least have three commonly used naming schemes.

> Let me give you some details (hope that will make it clearer). I am
> implementing FC-HBA (ftp://ftp.t11.org/t11/pub/fc/hba/03-108v2.pdf). The
> problem occures with HBA_GetFcpTargetMapping() on page 73 (7.4.4), the
> parameters are describerd on page 31 (6.6.1) and the specific struct is
> HBA_ScsiId (6.6.1.5), actually the member OSDeviceName (6.6.2.11).

This doesn't make any sense in a linux enviroment.  I'd rather try to
get that draft fixed before it's ratified instead of working around
it especially as they already mention Linux in some examples.

OTOH it's probably totally irrelevant for real life anyway.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-07-17 10:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-02 15:24 bus:id:lun to device name Stefan Voelkel
2003-07-08 14:50 ` Kurt Garloff
2003-07-15 14:45   ` Stefan Voelkel
2003-07-15 17:03     ` Bryan Henderson
2003-07-16  8:29       ` Stefan Voelkel
2003-07-17 10:29         ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox