how to get iscsi target details(iqn) from device OS name programmatically at initiator side

415 views
Skip to first unread message

lvpriy...@gmail.com

unread,
Nov 10, 2016, 1:03:09 PM11/10/16
to open-iscsi

i need C/C++ library/API at initiator side which can give me the iscsi target details(iqn) when i pass the OS device name or scsi-channel-lun details.

for example input will be "/dev/sdc" or something like "scsi12 Channel 00 Id 0 Lun: 0" and the output should be the corresponding target iqn .



thanks in advance

The Lee-Man

unread,
Nov 10, 2016, 3:01:12 PM11/10/16
to open-iscsi, lvpriy...@gmail.com

Such information is available in the system. Try running "iscsiadm -m session -P3". This prints out the block device for each session. For example:

zsh> iscsiadm -m session -P3 | egrep 'iqn|disk'
iscsiadm -m session -P3 | egrep 'iqn|disk'
Target: iqn.2003-01.org.linux-iscsi.worklaptop.x8664:sn.36fa11d076f4 (non-flash)
                Iface Initiatorname: iqn.2005-03.org.open-iscsi:a02b9e9d4e52
                        Attached scsi disk sdb          State: running

I suspect you could get this information directly from sysfs yourself, if you want to figure out where it all resides.

You can look in usr/iscsi_sysfs.c to see what iscsiadm does to print out this information.

Ulrich Windl

unread,
Nov 11, 2016, 2:10:42 AM11/11/16
to open-...@googlegroups.com
>>> <lvpriy...@gmail.com> schrieb am 10.11.2016 um 11:16 in Nachricht
<4e2f30b5-7c75-47d6...@googlegroups.com>:
Did you try "lsscsi -t"? Look at the source then.

Ulrich


Reply all
Reply to author
Forward
0 new messages