]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pkgs/multipath-tools/patches/0005-RH-cciss_id.patch
bf616645130a05b7d661420f10e9dfad7e6d6b0a
[people/ms/ipfire-3.x.git] / pkgs / multipath-tools / patches / 0005-RH-cciss_id.patch
1 From a3db7def912c2fd3756cfd99c1165db075281caa Mon Sep 17 00:00:00 2001
2 From: Fabio M. Di Nitto <fdinitto@redhat.com>
3 Date: Tue, 13 Oct 2009 09:26:02 +0200
4 Subject: [PATCH 05/12] RH: cciss_id
5
6 Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
7 ---
8 :100644 100644 54be0a5... 7e4b7b1... M Makefile
9 :000000 100644 0000000... 6db12a4... A cciss_id/Makefile
10 :000000 100644 0000000... 091b5fe... A cciss_id/cciss_id.c
11 Makefile | 3 +-
12 cciss_id/Makefile | 47 +++++++++++++++++++
13 cciss_id/cciss_id.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++
14 3 files changed, 177 insertions(+), 1 deletions(-)
15
16 diff --git a/Makefile b/Makefile
17 index 54be0a5..7e4b7b1 100644
18 --- a/Makefile
19 +++ b/Makefile
20 @@ -25,7 +25,8 @@ BUILDDIRS = \
21 libmultipath/checkers \
22 multipath \
23 multipathd \
24 - kpartx
25 + kpartx \
26 + cciss_id
27
28 ifeq ($(MULTIPATH_VERSION),)
29 VERSION = $(shell basename ${PWD} | cut -d'-' -f3)
30 diff --git a/cciss_id/Makefile b/cciss_id/Makefile
31 new file mode 100644
32 index 0000000..6db12a4
33 --- /dev/null
34 +++ b/cciss_id/Makefile
35 @@ -0,0 +1,47 @@
36 +
37 +# *****************************************************************************
38 +# * *
39 +# * (C) Copyright 2007 Hewlett-Packard Development Company, L.P *
40 +# * *
41 +# * This program is free software; you can redistribute it and/or modify it *
42 +# * under the terms of the GNU General Public License as published by the Free*
43 +# * Software Foundation; either version 2 of the License, or (at your option)*
44 +# * any later version. *
45 +# * *
46 +# * This program is distributed in the hope that it will be useful, but *
47 +# * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY*
48 +# * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
49 +# * for more details. *
50 +# * *
51 +# * You should have received a copy of the GNU General Public License along *
52 +# * with this program; if not, write to the Free Software Foundation, Inc., *
53 +# * 675 Mass Ave, Cambridge, MA 02139, USA. *
54 +# * *
55 +# * *
56 +# * *
57 +# * *
58 +# *****************************************************************************
59 +
60 +include ../Makefile.inc
61 +
62 +OBJS = cciss_id.o
63 +CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes
64 +
65 +LDFLAGS = -ldevmapper
66 +
67 +EXEC = cciss_id
68 +
69 +all: $(EXEC)
70 +
71 +$(EXEC): $(OBJS)
72 + $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
73 +
74 +install:
75 + $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
76 + $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
77 +
78 +uninstall:
79 + rm $(DESTDIR)$(bindir)/$(EXEC)
80 +
81 +clean:
82 + rm -f core.* *.o $(EXEC) *.gz
83 diff --git a/cciss_id/cciss_id.c b/cciss_id/cciss_id.c
84 new file mode 100644
85 index 0000000..091b5fe
86 --- /dev/null
87 +++ b/cciss_id/cciss_id.c
88 @@ -0,0 +1,128 @@
89 +/*
90 + *****************************************************************************
91 + * *
92 + * (C) Copyright 2007 Hewlett-Packard Development Company, L.P *
93 + * *
94 + * This program is free software; you can redistribute it and/or modify it *
95 + * under the terms of the GNU General Public License as published by the Free*
96 + * Software Foundation; either version 2 of the License, or (at your option)*
97 + * any later version. *
98 + * *
99 + * This program is distributed in the hope that it will be useful, but *
100 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY*
101 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
102 + * for more details. *
103 + * *
104 + * You should have received a copy of the GNU General Public License along *
105 + * with this program; if not, write to the Free Software Foundation, Inc., *
106 + * 675 Mass Ave, Cambridge, MA 02139, USA. *
107 + * *
108 + * *
109 + * *
110 + * *
111 + *****************************************************************************
112 +*/
113 +
114 +#include <sys/types.h>
115 +#include <sys/stat.h>
116 +#include <sys/ioctl.h>
117 +#include <fcntl.h>
118 +#include <unistd.h>
119 +#include <stdio.h>
120 +#include <stdlib.h>
121 +#include <errno.h>
122 +#include <string.h>
123 +
124 +#include <linux/cciss_ioctl.h>
125 +
126 +#define LEN_PAGE83_CCISSDEV 0x20 /* Page length of 83h for cciss devices */
127 +#define LEN_DEVICEFILE 255 /* Length of device file name */
128 +#define PATH_CCISSDEV "/dev/cciss/" /* Path of CCISS devices */
129 +int main(int argc, char *argv[])
130 +{
131 + const int resp_len = LEN_PAGE83_CCISSDEV;
132 + unsigned char resp[resp_len+1];
133 + char dev_name[LEN_DEVICEFILE] = "\0" ;
134 + unsigned int lun_id = 0;
135 + int fd, status, i;
136 + struct stat file_stat;
137 +
138 + LogvolInfo_struct lvi; // logical "volume" info
139 + IOCTL_Command_struct cic; // cciss ioctl command
140 +
141 + if(argc < 2) {
142 + fprintf(stderr, "Usage: %s /dev/cciss/cNdN\n", argv[0]);
143 + return -1;
144 + }
145 +
146 + if ( strncmp(PATH_CCISSDEV, argv[1], strlen(PATH_CCISSDEV) ) != 0 ) {
147 + if ( strchr(argv[1], '!') ) {
148 + sprintf(dev_name, "%s%s", PATH_CCISSDEV,
149 + strchr(argv[1], '!')+1);
150 + }
151 + //fprintf(stderr, "dev_name is: -%s-", dev_name);
152 + } else {
153 + sprintf(dev_name, "%s", argv[1]);
154 + }
155 +
156 + if (stat(dev_name, &file_stat) < 0) {
157 + fprintf (stderr, "Stat failed for file %s. Errno=%d\n", dev_name, errno);
158 + return -1;
159 + }
160 + if (!S_ISBLK(file_stat.st_mode)) {
161 + fprintf (stderr, "File %s is not a block device. \n", dev_name);
162 + return -1;
163 + }
164 +
165 +
166 + if((fd = open(dev_name, O_RDWR)) < 0) {
167 + fprintf(stderr, "Open failed for file %s. Errno=%d\n", dev_name, errno);
168 + return -1;
169 + }
170 +
171 + if (ioctl(fd, CCISS_GETLUNINFO, &lvi) < 0) {
172 + fprintf(stderr, "IOCTL failure CCISS_GETLUNINFO for file %s Errno=%d\n", dev_name, errno);
173 + close(fd);
174 + return -1;
175 + } else {
176 + lun_id = lvi.LunID;
177 + }
178 +
179 + memset(&cic, 0, sizeof(IOCTL_Command_struct));
180 + memset(resp, 0, resp_len+1);
181 + cic.LUN_info.LogDev.Mode = 0x01; /* logical volume addressing */
182 + cic.LUN_info.LogDev.VolId = lun_id & 0x3FFFFFFF;
183 + cic.Request.CDBLen = 6;
184 + cic.Request.Type.Type = TYPE_CMD; // It is a command.
185 + cic.Request.Type.Attribute = ATTR_SIMPLE;
186 + cic.Request.Type.Direction = XFER_READ; // Read
187 + cic.Request.Timeout = 0; // Don't time out
188 + cic.Request.CDB[0] = 0x12;
189 + cic.Request.CDB[1] = 0x01; /* EVPD (enable vital product data) */
190 + cic.Request.CDB[2] = 0x83;
191 + cic.Request.CDB[4] = resp_len & 0xFF;
192 + cic.buf_size = resp_len;
193 + cic.buf = resp;
194 + status = ioctl(fd, CCISS_PASSTHRU, &cic);
195 + if(status) {
196 + fprintf(stderr, "IOCTL failure CCISS_PASSTHRU for file %s Errno=%d\n", dev_name, errno);
197 + close(fd);
198 + return -1;
199 + }
200 + else {
201 + if ((cic.error_info.CommandStatus | cic.error_info.ScsiStatus )) {
202 + fprintf(stderr, "CCISS command status error for Inquiry on %s\n",
203 + dev_name);
204 + close(fd);
205 + return -1;
206 + }
207 + printf("3");
208 + for(i=8; i<24; i++)
209 + /* printf("Buff[%d] =%x\n", i, resp[i]); */
210 + printf("%02x", resp[i]);
211 + printf("\n");
212 + }
213 +
214 + close(fd);
215 + return 0;
216 +}
217 --
218 1.6.5.1
219