1 diff -ur lin_tape-3.0.18/Makefile lin_tape-3.0.18-ifdefs/Makefile
2 --- lin_tape-3.0.18/Makefile 2017-05-09 21:11:32.977092391 +0200
3 +++ lin_tape-3.0.18-ifdefs/Makefile 2017-05-09 21:05:59.610307494 +0200
5 lin_tape-objs := join.o lin_tape_scsi_config.o lin_tape_scsi_tape.o lin_tape_scsi_trace.o \
6 lin_tape_ioctl_tape.o lin_tape_ioctl_changer.o lin_tape_extra_ioctl.o
8 -RHELRELEASE := $(shell [ -f "/etc/redhat-release" ] && echo 1 || echo 0)
9 -ifeq ($(RHELRELEASE), 1)
10 -KERNELDIR ?= /lib/modules/$(shell uname -r)/build
11 -KERNELVER = $(shell uname -r 2>/dev/null|sed "s/[\.-]/_/g"|sed "s/\([0-9]*_[0-9]*_[0-9]*_[0-9]*\).*/\1/")
12 -EXTRA_CFLAGS += -DKERNELVERSION_${KERNELVER}
14 -EXTRA_CFLAGS += -DSLESVERSION
18 EXTRA_CFLAGS += -DSFMPENABLED
20 diff -ur lin_tape-3.0.18/pfo.h lin_tape-3.0.18-ifdefs/pfo.h
21 --- lin_tape-3.0.18/pfo.h 2017-02-23 19:14:41.000000000 +0100
22 +++ lin_tape-3.0.18-ifdefs/pfo.h 2017-05-09 21:06:34.117699008 +0200
24 * will build for various releases of Linux. This is how
25 * we track different versions using ifdef in the source.
27 -#ifdef KERNELVERSION_2_6_32_220
28 -#define BEFORE_RH_63 1
29 -#define BEFORE_RH_64 1
30 -#define BEFORE_RH_65 1
31 -#define BEFORE_RH_66 1
32 -#define BEFORE_RH_67 1
33 -#define BEFORE_RH_70 1
34 -#define BEFORE_RH_71 1
35 -#define BEFORE_RH_72 1
37 -#ifdef KERNELVERSION_2_6_32_279
38 -#define AFTER_RH_62 1
39 -#define BEFORE_RH_64 1
40 -#define BEFORE_RH_65 1
41 -#define BEFORE_RH_66 1
42 -#define BEFORE_RH_67 1
43 -#define BEFORE_RH_70 1
44 -#define BEFORE_RH_71 1
45 -#define BEFORE_RH_72 1
47 -#ifdef KERNELVERSION_2_6_32_358
48 -#define AFTER_RH_62 1
49 -#define AFTER_RH_63 1
50 -#define BEFORE_RH_65 1
51 -#define BEFORE_RH_66 1
52 -#define BEFORE_RH_67 1
53 -#define BEFORE_RH_70 1
54 -#define BEFORE_RH_72 1
56 -#ifdef KERNELVERSION_2_6_32_431
57 -#define AFTER_RH_62 1
58 -#define AFTER_RH_63 1
59 -#define AFTER_RH_64 1
60 -#define BEFORE_RH_66 1
61 -#define BEFORE_RH_67 1
62 -#define BEFORE_RH_70 1
63 -#define BEFORE_RH_71 1
64 -#define BEFORE_RH_72 1
66 -#ifdef KERNELVERSION_2_6_32_504
67 -#define AFTER_RH_62 1
68 -#define AFTER_RH_63 1
69 -#define AFTER_RH_64 1
70 -#define AFTER_RH_65 1
71 -#define BEFORE_RH_67 1
72 -#define BEFORE_RH_70 1
73 -#define BEFORE_RH_71 1
74 -#define BEFORE_RH_72 1
76 -#ifdef KERNELVERSION_2_6_32_573
77 -#define AFTER_RH_62 1
78 -#define AFTER_RH_63 1
79 -#define AFTER_RH_64 1
80 -#define AFTER_RH_65 1
81 -#define AFTER_RH_66 1
82 -#define BEFORE_RH_70 1
83 -#define BEFORE_RH_71 1
84 -#define BEFORE_RH_72 1
86 -#ifdef KERNELVERSION_2_6_32_642
87 -#define AFTER_RH_62 1
88 -#define AFTER_RH_63 1
89 -#define AFTER_RH_64 1
90 -#define AFTER_RH_65 1
91 -#define AFTER_RH_66 1
92 -#define AFTER_RH_67 1
93 -#define BEFORE_RH_70 1
94 -#define BEFORE_RH_71 1
95 -#define BEFORE_RH_72 1
97 -#ifdef KERNELVERSION_3_10_0_123
98 -#define AFTER_RH_62 1
99 -#define AFTER_RH_63 1
100 -#define AFTER_RH_64 1
101 -#define AFTER_RH_65 1
102 -#define AFTER_RH_66 1
103 -#define AFTER_RH_67 1
104 -#define AFTER_RH_6x 1
105 -#define BEFORE_RH_71 1
107 -#ifdef KERNELVERSION_3_10_0_229
108 -#define AFTER_RH_62 1
109 -#define AFTER_RH_63 1
110 -#define AFTER_RH_64 1
111 -#define AFTER_RH_65 1
112 -#define AFTER_RH_66 1
113 -#define AFTER_RH_67 1
114 -#define AFTER_RH_6x 1
115 -#define AFTER_RH_70 1
116 -#define BEFORE_RH_72 1
118 -#ifdef KERNELVERSION_3_10_0_327
119 -#define AFTER_RH_62 1
120 -#define AFTER_RH_63 1
121 -#define AFTER_RH_64 1
122 -#define AFTER_RH_65 1
123 -#define AFTER_RH_66 1
124 -#define AFTER_RH_67 1
125 -#define AFTER_RH_6x 1
126 -#define AFTER_RH_70 1
127 -#define AFTER_RH_71 1
129 -#ifdef KERNELVERSION_3_10_0_514
130 #define AFTER_RH_62 1
131 #define AFTER_RH_63 1
132 #define AFTER_RH_64 1
134 #define AFTER_RH_70 1
135 #define AFTER_RH_71 1
136 #define AFTER_RH_72 1
139 /* Misc defines needed so source is same for all versions of Linux */
140 #ifndef SDEV_TRANSPORT_OFFLINE
141 diff -ur lin_tape-3.0.18/sgmp.c lin_tape-3.0.18-ifdefs/sgmp.c
142 --- lin_tape-3.0.18/sgmp.c 2017-02-23 19:14:41.000000000 +0100
143 +++ lin_tape-3.0.18-ifdefs/sgmp.c 2017-05-09 21:10:20.295643954 +0200
144 @@ -262,27 +262,12 @@
146 struct sg_fd *sfp = (struct sg_fd *)filp->private_data;
148 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && (!defined(SLESVERSION))
149 - /* RHEL 7.0 and beyond */
150 struct request_queue *q = sfp->parentdp->device->request_queue;
154 - struct request_queue *q = sfp->parentdp->device->request_queue;
158 if (sfp->parentdp->device->type == TYPE_SCANNER)
161 -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,12,0) || defined(SLESVERSION)
162 return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);
164 - /* RHEL 6.4 and beyond */
165 - return blk_verify_command(q, cmd, filp->f_mode & FMODE_WRITE);
167 -//6.3 blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);
171 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
175 q = sdp->device->request_queue;
176 -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32) && (defined(SLESVERSION))
177 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
178 sdp->sg_tablesize = min(queue_max_hw_segments(q),
179 queue_max_phys_segments(q));
181 @@ -1546,7 +1531,7 @@
182 if ((sdp->sgdebug > 0) &&
183 ((CHECK_CONDITION == srp->header.masked_status) ||
184 (COMMAND_TERMINATED == srp->header.masked_status)))
185 -#if defined(AFTER_RH_71) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
186 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
187 __scsi_print_sense(sdp->device, "sg_cmd_done", sense, SCSI_SENSE_BUFFERSIZE);
190 @@ -1677,7 +1662,7 @@
191 INIT_LIST_HEAD(&sdp->sfds);
192 init_waitqueue_head(&sdp->o_excl_wait);
194 -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32) && (defined(SLESVERSION))
195 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
196 sdp->sg_tablesize = min(queue_max_hw_segments(q),
197 queue_max_phys_segments(q));
199 @@ -3069,7 +3054,7 @@
200 scsidp->id, scsidp->lun, (int) scsidp->type,
202 (int) scsidp->queue_depth,
204 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
205 (int) atomic_read(&scsidp->device_busy),
207 (int) scsidp->device_busy,
208 diff -ur lin_tape-3.0.18/stmp.c lin_tape-3.0.18-ifdefs/stmp.c
209 --- lin_tape-3.0.18/stmp.c 2017-02-23 19:14:41.000000000 +0100
210 +++ lin_tape-3.0.18-ifdefs/stmp.c 2017-05-09 21:11:01.113125428 +0200
212 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
213 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
214 if (cmdstatp->have_sense)
215 -#if defined(AFTER_RH_70) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
216 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
217 __scsi_print_sense(STp->device, name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
221 SRpnt->cmd[0] != MODE_SENSE &&
222 SRpnt->cmd[0] != TEST_UNIT_READY) {
224 -#if defined(AFTER_RH_71) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
225 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,21)
226 __scsi_print_sense(STp->device, name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
229 diff -ur lin_tape-3.0.18/upper.c lin_tape-3.0.18-ifdefs/upper.c
230 --- lin_tape-3.0.18/upper.c 2017-02-23 19:14:41.000000000 +0100
231 +++ lin_tape-3.0.18-ifdefs/upper.c 2017-05-09 21:09:37.868126006 +0200
233 if (copy_from_user(pfo_cmd->scsi_cmd, hdr->cmdp, hdr->cmd_len))
236 -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,12,0) || defined(SLESVERSION)
237 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,12,0)
238 if (blk_verify_command(pfo_cmd->scsi_cmd, mode & FMODE_WRITE))
240 /* RHEL 6.4 and beyond */
242 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
245 -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,12,0) || defined(SLESVERSION)
246 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,12,0)
247 err = blk_verify_command(scsi_cmd, mode & FMODE_WRITE);
249 /* RHEL 6.4 and beyond */