4 Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sys/ioctl.h>
27 #include "scsi_ioctls.h"
30 idlun_to_components (Scsi_Idlun *idlun,
32 unsigned char *channel,
36 if (!idlun || !host || !channel || !id || !lun) return 1;
38 *host = (idlun->dev_id >> 24) & 0xFF;
39 *channel = (idlun->dev_id >> 16) & 0xFF;
40 *id = (idlun->dev_id ) & 0xFF;
41 *lun = (idlun->dev_id >> 8) & 0xFF;
47 get_scsi_idlun(int fd, Scsi_Idlun *idlun)
49 return ioctl(fd, SCSI_IOCTL_GET_IDLUN, idlun);
53 get_scsi_pci(int fd, char *slot_name)
55 return ioctl(fd, SCSI_IOCTL_GET_PCI, slot_name);
60 #ifdef SCSI_IOCTLS_EXE
64 printf("Usage: %s /dev/sdX where sdX is a SCSI device node.\n",
68 int main(int argc, char **argv)
74 memset(&idlun, 0, sizeof(idlun));
76 if (argc < 2) {usage(argv); exit(1);}
78 fd = open(argv[1], O_RDONLY);
80 perror("Unable to open file");
84 rc = get_scsi_pci(fd, slot_name);
86 perror("Unable to get_scsi_pci()");
88 rc = get_scsi_idlun(fd, &idlun);
90 perror("Unable to get_scsi_idlun()");
93 printf("Device: %s\n", argv[1]);
94 printf("PCI: %s\n", slot_name);
96 printf("SCSI: host %d channel %d id %d lun %d, unique ID %x\n",
97 (idlun.dev_id >> 24) & 0xFF, // host
98 (idlun.dev_id >> 16) & 0xFF, // channel
99 idlun.dev_id & 0xFF, // id
100 (idlun.dev_id >> 8) & 0xFF, // lun
101 idlun.host_unique_id);