[packages/lin_tape] - added and updated patches to make it build on non-RH anitquated kernels

baggins baggins at pld-linux.org
Sun Jun 19 13:30:40 CEST 2016


commit 6986ddb6276be28b0a82655402970069f8c27b6d
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Jun 19 13:30:07 2016 +0200

    - added and updated patches to make it build on non-RH anitquated kernels

 clean-ifdefs.patch   | 203 +++++++++++++++++++++++++++++++++++++++
 insecure-perms.patch |  27 ++++++
 lin_tape.spec        |  21 ++--
 linux-3.13.patch     | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++
 linux-3.19.patch     | 118 +++++++++++++++++++++--
 linux-4.0.patch      |  71 ++++++++++++++
 linux-4.6.patch      |  94 ++++++++++++++++++
 use-module-dir.patch |  24 +----
 8 files changed, 783 insertions(+), 39 deletions(-)
---
diff --git a/lin_tape.spec b/lin_tape.spec
index 0ca9f76..8821943 100644
--- a/lin_tape.spec
+++ b/lin_tape.spec
@@ -5,7 +5,7 @@
 # nothing to be placed to debuginfo package
 %define		_enable_debug_packages	0
 
-%define		rel	0.1
+%define		rel	1
 %define		pname	lin_tape
 Summary:	IBM Tape SCSI Device Driver for Linux
 Name:		%{pname}%{_alt_kernel}
@@ -17,8 +17,12 @@ Source0:	%{pname}-%{version}.tgz
 # Source0-md5:	11a219f7b32496d9c334bbcd534da349
 Source1:	%{pname}.fixlist
 Patch0:		use-module-dir.patch
-Patch1:		linux-3.19.patch
+Patch1:		clean-ifdefs.patch
 Patch2:		insecure-perms.patch
+Patch3:		linux-3.13.patch
+Patch4:		linux-3.19.patch
+Patch5:		linux-4.0.patch
+Patch6:		linux-4.6.patch
 # System Storage, Tape systems, Tape drivers and software, Tape device drivers (Linux)
 URL:		http://www.ibm.com/support/fixcentral/
 BuildRequires:	rpmbuild(macros) >= 1.701
@@ -52,7 +56,7 @@ compatible platforms.\
 \
 %files -n kernel%{_alt_kernel}-scsi-lin_tape\
 %defattr(644,root,root,755)\
-%doc lin_tape.fixlist lin_tape_Ultrium.ReadMe lin_tape_359X.ReadMe\
+%doc lin_tape.fixlist lin_tape.ReadMe\
 /lib/modules/%{_kernel_ver}/kernel/drivers/scsi/lin_tape.ko*\
 %{nil}
 
@@ -65,9 +69,14 @@ compatible platforms.\
 
 %prep
 %setup -q -n %{pname}-%{version}
+%undos Makefile
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
 %ifarch %{ix86} ia64
 proc="Intel"
 %endif
@@ -81,11 +90,7 @@ proc="pSeries"
 proc="zSeries"
 %endif
 
-%{__cp} -af lin_tape_359X_${proc}.ReadMe lin_tape_359X.ReadMe
-%{__cp} -af lin_tape_Ultrium_${proc}.ReadMe lin_tape_Ultrium.ReadMe
-
-%{__mv} Makefile Makefile.IBM
-%{__cp} -af Makefile.GPL Makefile
+install -p %{SOURCE1} .
 
 %build
 %{expand:%build_kernel_packages}
diff --git a/clean-ifdefs.patch b/clean-ifdefs.patch
new file mode 100644
index 0000000..118296a
--- /dev/null
+++ b/clean-ifdefs.patch
@@ -0,0 +1,203 @@
+diff -ur lin_tape-3.0.8/Makefile lin_tape-3.0.8-norh/Makefile
+--- lin_tape-3.0.8/Makefile	2016-06-19 09:57:15.497134019 +0200
++++ lin_tape-3.0.8-norh/Makefile	2016-06-19 09:53:34.317661494 +0200
+@@ -18,15 +18,6 @@
+ lin_tape-objs := join.o lin_tape_scsi_config.o lin_tape_scsi_tape.o lin_tape_scsi_trace.o \
+              lin_tape_ioctl_tape.o lin_tape_ioctl_changer.o lin_tape_extra_ioctl.o
+ 
+-RHELRELEASE := $(shell [ -f "/etc/redhat-release" ] && echo 1 || echo 0)
+-ifeq ($(RHELRELEASE), 1)
+-KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+-KERNELVER = $(shell cd ${KERNELDIR}; make kernelversion 2>/dev/null|sed "s/[\.-]/_/g"|sed "s/\([0-9]*_[0-9]*_[0-9]*_[0-9]*\).*/\1/")
+-EXTRA_CFLAGS += -DKERNELVERSION_${KERNELVER}
+-else
+-EXTRA_CFLAGS += -DSLESVERSION
+-endif
+-             
+ PROC := $(shell uname -m)
+ 
+ ifeq ($(PROC), ppc64)
+diff -ur lin_tape-3.0.8/pfo.h lin_tape-3.0.8-norh/pfo.h
+--- lin_tape-3.0.8/pfo.h	2016-03-17 03:37:58.000000000 +0100
++++ lin_tape-3.0.8-norh/pfo.h	2016-06-19 09:53:34.000000000 +0200
+@@ -26,82 +26,6 @@
+  * will build for various releases of Linux.  This is how
+  * we track different versions using ifdef in the source.
+  */
+-#ifdef KERNELVERSION_2_6_32_220
+-#define BEFORE_RH_63 1
+-#define BEFORE_RH_64 1
+-#define BEFORE_RH_65 1
+-#define BEFORE_RH_66 1
+-#define BEFORE_RH_67 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_2_6_32_279
+-#define AFTER_RH_62 1
+-#define BEFORE_RH_64 1
+-#define BEFORE_RH_65 1
+-#define BEFORE_RH_66 1
+-#define BEFORE_RH_67 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_2_6_32_358
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define BEFORE_RH_65 1
+-#define BEFORE_RH_66 1
+-#define BEFORE_RH_67 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_2_6_32_431
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define AFTER_RH_64 1
+-#define BEFORE_RH_66 1
+-#define BEFORE_RH_67 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_2_6_32_504
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define AFTER_RH_64 1
+-#define AFTER_RH_65 1
+-#define BEFORE_RH_67 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_2_6_32_573
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define AFTER_RH_64 1
+-#define AFTER_RH_65 1
+-#define AFTER_RH_66 1
+-#define BEFORE_RH_70 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_3_10_0_123
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define AFTER_RH_64 1
+-#define AFTER_RH_65 1
+-#define AFTER_RH_66 1
+-#define AFTER_RH_67 1
+-#define AFTER_RH_6x 1
+-#define BEFORE_RH_71 1
+-#endif
+-#ifdef KERNELVERSION_3_10_0_229
+-#define AFTER_RH_62 1
+-#define AFTER_RH_63 1
+-#define AFTER_RH_64 1
+-#define AFTER_RH_65 1
+-#define AFTER_RH_66 1
+-#define AFTER_RH_67 1
+-#define AFTER_RH_6x 1
+-#define AFTER_RH_70 1
+-#define BEFORE_RH_72 1
+-#endif
+-#ifdef KERNELVERSION_3_10_0_327
+ #define AFTER_RH_62 1
+ #define AFTER_RH_63 1
+ #define AFTER_RH_64 1
+@@ -111,7 +35,6 @@
+ #define AFTER_RH_6x 1
+ #define AFTER_RH_70 1
+ #define AFTER_RH_72 1
+-#endif
+ 
+ /* Misc defines needed so source is same for all versions of Linux */
+ #ifndef SDEV_TRANSPORT_OFFLINE
+diff -ur lin_tape-3.0.8/sgmp.c lin_tape-3.0.8-norh/sgmp.c
+--- lin_tape-3.0.8/sgmp.c	2016-03-17 04:44:07.000000000 +0100
++++ lin_tape-3.0.8-norh/sgmp.c	2016-06-19 09:55:40.075920922 +0200
+@@ -262,31 +262,11 @@
+ {
+ 	struct sg_fd *sfp = (struct sg_fd *)filp->private_data;
+ 
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && (!defined(SLESVERSION))
+-	/* RHEL 7.0 and beyond */
+ 	struct request_queue *q = sfp->parentdp->device->request_queue;
+-#else
+-#ifdef AFTER_RH_63
+-	/* RHEL 6.4+ */
+-	struct request_queue *q = sfp->parentdp->device->request_queue;
+-#endif
+-#endif
+-
+ 	if (sfp->parentdp->device->type == TYPE_SCANNER)
+ 		return 0;
+ 
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && (!defined(SLESVERSION))
+-	/* RHEL 7.0 and beyond */
+-	return blk_verify_command(q, cmd, filp->f_mode & FMODE_WRITE);
+-#else
+-#ifdef AFTER_RH_63
+-	/* RHEL 6.4+ */
+-	return blk_verify_command(q, cmd, filp->f_mode & FMODE_WRITE);
+-#else
+-	/* RHEL6.3- or SLES11SP3 */
+ 	return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);
+-#endif
+-#endif
+ }
+ 
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
+diff -ur lin_tape-3.0.8/upper.c lin_tape-3.0.8-norh/upper.c
+--- lin_tape-3.0.8/upper.c	2016-02-23 20:19:55.000000000 +0100
++++ lin_tape-3.0.8-norh/upper.c	2016-06-19 09:56:18.759745753 +0200
+@@ -266,20 +266,7 @@
+ {
+ 	if (copy_from_user(pfo_cmd->scsi_cmd, hdr->cmdp, hdr->cmd_len))
+ 		return -EFAULT;
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && (!defined(SLESVERSION))
+-	/* RHEL 7.0 and beyond */
+-	if (blk_verify_command(q, pfo_cmd->scsi_cmd, mode & FMODE_WRITE))
+-#else
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+-#ifdef AFTER_RH_63
+-	/* RHEL 6.4+ */
+-	if (blk_verify_command(q, pfo_cmd->scsi_cmd, mode & FMODE_WRITE))
+-#else
+-	/* RHEL 6.3- or SLES11SP3 */
+ 	if (blk_verify_command(pfo_cmd->scsi_cmd, mode & FMODE_WRITE))
+-#endif
+-#endif
+-#endif
+ 		return -EPERM;
+ 
+ 	/*
+--- lin_tape-3.0.8/sgmp.c~	2016-06-19 13:18:16.000000000 +0200
++++ lin_tape-3.0.8/sgmp.c	2016-06-19 13:21:28.375961483 +0200
+@@ -1544,7 +1544,7 @@
+ 		if ((sdp->sgdebug > 0) &&
+ 		    ((CHECK_CONDITION == srp->header.masked_status) ||
+ 		     (COMMAND_TERMINATED == srp->header.masked_status)))
+-#ifdef AFTER_RH_72
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ 			__scsi_print_sense(sdp->device, "sg_cmd_done", sense, SCSI_SENSE_BUFFERSIZE);
+ 
+ #else
+--- lin_tape-3.0.8/stmp.c~	2016-06-19 13:18:16.000000000 +0200
++++ lin_tape-3.0.8/stmp.c	2016-06-19 13:21:10.882407139 +0200
+@@ -467,7 +467,7 @@
+ 		       SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
+ 		       SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
+ 		if (cmdstatp->have_sense)
+-#ifdef AFTER_RH_72
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ 			__scsi_print_sense(STp->device, name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+ 
+ #else
+@@ -488,7 +488,7 @@
+ 			 scode != VOLUME_OVERFLOW &&
+ 			 SRpnt->cmd[0] != MODE_SENSE &&
+ 			 SRpnt->cmd[0] != TEST_UNIT_READY) {
+-#ifdef AFTER_RH_72
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+ 			__scsi_print_sense(STp->device, name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+ 
+ #else
diff --git a/insecure-perms.patch b/insecure-perms.patch
index 60c8ac3..98e574c 100644
--- a/insecure-perms.patch
+++ b/insecure-perms.patch
@@ -63,6 +63,33 @@
  	dynamic_attributes_store);
  
  /*******************************************************************************
+@@ -639,7 +639,7 @@
+ 
+ } /* lin_tape_as_sfmp_store() */
+ 
+-DRIVER_ATTR(lin_tape_as_sfmp, 0666, lin_tape_as_sfmp_show, lin_tape_as_sfmp_store);
++DRIVER_ATTR(lin_tape_as_sfmp, 0664, lin_tape_as_sfmp_show, lin_tape_as_sfmp_store);
+ /*******************************************************************************
+ *                                                                              *
+ *  NAME:  disable_auto_drive_dump_show                                         *
+@@ -693,7 +693,7 @@
+ 
+ } /* disable_auto_drive_dump_store() */
+ 
+-DRIVER_ATTR(disable_auto_drive_dump, 0666, disable_auto_drive_dump_show, disable_auto_drive_dump_store);
++DRIVER_ATTR(disable_auto_drive_dump, 0664, disable_auto_drive_dump_show, disable_auto_drive_dump_store);
+ 
+ /*******************************************************************************
+ *                                                                              *
+@@ -748,7 +748,7 @@
+ 
+ } /* busy_retry_store() */
+ 
+-DRIVER_ATTR(busy_retry, 0666, busy_retry_show, busy_retry_store);
++DRIVER_ATTR(busy_retry, 0664, busy_retry_show, busy_retry_store);
+ /*******************************************************************************
+ *                                                                              *
+ *                           CLASS DEVICE ATTRIBUTES                            *
 @@ -699,7 +699,7 @@
  #else
  static DEVICE_ATTR(sys_encryption_proxy,
diff --git a/linux-3.13.patch b/linux-3.13.patch
new file mode 100644
index 0000000..090c015
--- /dev/null
+++ b/linux-3.13.patch
@@ -0,0 +1,264 @@
+diff -ur lin_tape-3.0.8.orig/stmp.c lin_tape-3.0.8/stmp.c
+--- lin_tape-3.0.8.orig/stmp.c	2016-03-17 03:52:34.000000000 +0100
++++ lin_tape-3.0.8/stmp.c	2016-06-19 13:10:40.664509607 +0200
+@@ -121,7 +121,12 @@
+ 
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
+ static struct class st_sysfs_class;
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static const struct attribute_group *st_dev_groups[];
++static const struct attribute_group *st_drv_groups[];
++#else
+ static struct device_attribute st_dev_attrs[];
++#endif
+ /* Paths are protected by st_index_lock */
+ static struct device *old_active_path;
+ static struct device *new_active_path;
+@@ -245,8 +250,10 @@
+ static int st_probe(struct device *);
+ static int st_remove(struct device *);
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
+ static int do_create_sysfs_files(void);
+ static void do_remove_sysfs_files(void);
++#endif
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ static int do_create_class_files(struct scsi_tape *, int, int);
+ #endif
+@@ -255,6 +262,9 @@
+ 	.owner			= THIS_MODULE,
+ 	.gendrv = {
+ 		.name		= "st",
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
++		.groups         = st_drv_groups,
++#endif
+ 		.probe		= st_probe,
+ 		.remove		= st_remove,
+ 	},
+@@ -4806,7 +4816,11 @@
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
+ static struct class st_sysfs_class = {
+ 	.name = "scsi_tape",
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++	.dev_groups = st_dev_groups,
++#else
+ 	.dev_attrs = st_dev_attrs,
++#endif
+ };
+ #endif
+ 
+@@ -4845,9 +4859,11 @@
+ 	if (err)
+ 		goto err_chrdev;
+ 
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,13,0)
+ 	err = do_create_sysfs_files();
+ 	if (err)
+ 		goto err_scsidrv;
++#endif
+ 
+ 	return 0;
+ 
+@@ -4867,7 +4883,9 @@
+ 
+ static void __exit exit_st(void)
+ {
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,13,0)
+ 	do_remove_sysfs_files();
++#endif
+ 	pfo_unregister_st(&st_template.gendrv);
+ 	unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
+ 				 ST_MAX_TAPE_ENTRIES);
+@@ -4884,6 +4902,7 @@
+ module_exit(exit_st);
+ 
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
+ /* The sysfs driver interface. Read-only at the moment */
+ static ssize_t st_try_direct_io_show(struct device_driver *ddp, char *buf)
+ {
+@@ -4947,10 +4966,48 @@
+ 	driver_remove_file(sysfs, &driver_attr_fixed_buffer_size);
+ 	driver_remove_file(sysfs, &driver_attr_try_direct_io);
+ }
++#else
++/* The sysfs driver interface. Read-only at the moment */
++static ssize_t try_direct_io_show(struct device_driver *ddp, char *buf)
++{
++	return scnprintf(buf, PAGE_SIZE, "%d\n", try_direct_io);
++}
++static DRIVER_ATTR_RO(try_direct_io);
+ 
++static ssize_t fixed_buffer_size_show(struct device_driver *ddp, char *buf)
++{
++	return scnprintf(buf, PAGE_SIZE, "%d\n", st_fixed_buffer_size);
++}
++static DRIVER_ATTR_RO(fixed_buffer_size);
++
++static ssize_t max_sg_segs_show(struct device_driver *ddp, char *buf)
++{
++	return scnprintf(buf, PAGE_SIZE, "%d\n", st_max_sg_segs);
++}
++static DRIVER_ATTR_RO(max_sg_segs);
++
++static ssize_t version_show(struct device_driver *ddd, char *buf)
++{
++	return scnprintf(buf, PAGE_SIZE, "[%s]\n", verstr);
++}
++static DRIVER_ATTR_RO(version);
++
++static struct attribute *st_drv_attrs[] = {
++	&driver_attr_try_direct_io.attr,
++	&driver_attr_fixed_buffer_size.attr,
++	&driver_attr_max_sg_segs.attr,
++	&driver_attr_version.attr,
++	NULL,
++};
++ATTRIBUTE_GROUPS(st_drv);
++#endif
+ 
+ /* The sysfs simple class interface */
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static ssize_t lasterror_show(struct device *dev,
++#else
+ static ssize_t st_lasterror_show(struct device *dev,
++#endif
+ 		struct device_attribute *attr, char *buf)
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+@@ -4981,12 +5038,19 @@
+ 		STp->last_checkcondition[2]);
+ 	return l;
+ }
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(lasterror);
++#endif
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ DEVICE_ATTR(lasterror, S_IRUGO, st_lasterror_show, NULL);
+ #endif
+ 
+ static ssize_t
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++defined_show(struct device *dev, struct device_attribute *attr, char *buf)
++#else
+ st_defined_show(struct device *dev, struct device_attribute *attr, char *buf)
++#endif
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+ 	ssize_t l = 0;
+@@ -4994,13 +5058,20 @@
+ 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined);
+ 	return l;
+ }
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(defined);
++#endif
+ 
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL);
+ #endif
+ 
+ static ssize_t
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++default_blksize_show(struct device *dev, struct device_attribute *attr, char *buf)
++#else
+ st_defblk_show(struct device *dev, struct device_attribute *attr, char *buf)
++#endif
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+ 	ssize_t l = 0;
+@@ -5008,13 +5079,20 @@
+ 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize);
+ 	return l;
+ }
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(default_blksize);
++#endif
+ 
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL);
+ #endif
+ 
+ static ssize_t
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++default_density_show(struct device *dev, struct device_attribute *attr, char *buf)
++#else
+ st_defdensity_show(struct device *dev, struct device_attribute *attr, char *buf)
++#endif
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+ 	ssize_t l = 0;
+@@ -5024,13 +5102,20 @@
+ 	l = snprintf(buf, PAGE_SIZE, fmt, STm->default_density);
+ 	return l;
+ }
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(default_density);
++#endif
+ 
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL);
+ #endif
+ 
+ static ssize_t
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++default_compression_show(struct device *dev, struct device_attribute *attr,
++#else
+ st_defcompression_show(struct device *dev, struct device_attribute *attr,
++#endif
+ 		       char *buf)
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+@@ -5039,13 +5124,20 @@
+ 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1);
+ 	return l;
+ }
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(default_compression);
++#endif
+ 
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
+ DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
+ #endif
+ 
+ static ssize_t
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++options_show(struct device *dev, struct device_attribute *attr, char *buf)
++#else
+ st_options_show(struct device *dev, struct device_attribute *attr, char *buf)
++#endif
+ {
+ 	struct st_modedef *STm = dev_get_drvdata(dev);
+ 	int options;
+@@ -5090,7 +5182,30 @@
+ 	l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options);
+ 	return l;
+ }
+-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static DEVICE_ATTR_RO(options);
++#endif
++
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
++static struct attribute *st_dev_attrs[] = {
++	&dev_attr_defined.attr,
++	&dev_attr_default_blksize.attr,
++	&dev_attr_default_density.attr,
++	&dev_attr_default_compression.attr,
++	&dev_attr_options.attr,
++	&dev_attr_lasterror.attr,
++	NULL,
++};
++
++static struct attribute_group st_group = {
++	.attrs = st_dev_attrs,
++};
++
++static const struct attribute_group *st_dev_groups[] = {
++	&st_group,
++	NULL,
++};
++#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
+ static struct device_attribute st_dev_attrs[] = {
+ 	__ATTR_RO(st_defined),
+ 	__ATTR_RO(st_defblk),
diff --git a/linux-3.19.patch b/linux-3.19.patch
index cb73e92..a983356 100644
--- a/linux-3.19.patch
+++ b/linux-3.19.patch
@@ -1,6 +1,7 @@
---- lin_tape-2.9.4/lin_tape_scsi_config.c~	2015-03-30 20:27:22.000000000 +0200
-+++ lin_tape-2.9.4/lin_tape_scsi_config.c	2015-03-30 20:30:52.012073469 +0200
-@@ -6863,9 +6863,13 @@
+diff -ur lin_tape-3.0.8.orig/lin_tape_scsi_config.c lin_tape-3.0.8/lin_tape_scsi_config.c
+--- lin_tape-3.0.8.orig/lin_tape_scsi_config.c	2016-06-19 13:11:34.000000000 +0200
++++ lin_tape-3.0.8/lin_tape_scsi_config.c	2016-06-19 13:12:01.245509373 +0200
+@@ -7191,9 +7191,13 @@
  {
  	int rc = -EIO;
  	int minor = -1;
@@ -14,7 +15,7 @@
  
  	minor = iminor(inode);
  
-@@ -7129,7 +7133,11 @@
+@@ -7459,7 +7463,11 @@
  	int dev_index = 0;
  	boolean des_locked = False, drv_locked = False;
  
@@ -26,7 +27,7 @@
  	DbgPrint(("lin_tape_read entry: minor %d\n", minor));
  
  	if(minor >= LinTapeChangerOffset) {
-@@ -7236,7 +7244,11 @@
+@@ -7566,7 +7574,11 @@
  	int dev_index = 0;
  	boolean des_locked = False, drv_locked = False;
  
@@ -38,9 +39,10 @@
  	DbgPrint(("lin_tape_write entry: minor %d\n", minor));
  
  	if(minor >= LinTapeChangerOffset) {
---- lin_tape-2.9.4/lin_tape_scsi_config.h~	2014-10-30 15:22:07.000000000 +0100
-+++ lin_tape-2.9.4/lin_tape_scsi_config.h	2015-03-30 20:32:58.852078773 +0200
-@@ -304,7 +304,9 @@
+diff -ur lin_tape-3.0.8.orig/lin_tape_scsi_config.h lin_tape-3.0.8/lin_tape_scsi_config.h
+--- lin_tape-3.0.8.orig/lin_tape_scsi_config.h	2016-03-07 20:19:02.000000000 +0100
++++ lin_tape-3.0.8/lin_tape_scsi_config.h	2016-06-19 13:13:48.613514050 +0200
+@@ -315,9 +315,14 @@
  static int lin_tape_probe(struct device *dev);
  static int lin_tape_remove(struct device *dev);
  static struct scsi_driver lin_tape_driver = {
@@ -49,4 +51,104 @@
 +#endif
  	.gendrv = {
  		   .name = "lin_tape",
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
++		   .owner = THIS_MODULE,
++#endif
  		   .probe = lin_tape_probe,
+ 		   .remove = lin_tape_remove,
+ 		   },
+diff -ur lin_tape-3.0.8.orig/sgmp.c lin_tape-3.0.8/sgmp.c
+--- lin_tape-3.0.8.orig/sgmp.c	2016-06-19 13:11:34.000000000 +0200
++++ lin_tape-3.0.8/sgmp.c	2016-06-19 13:12:08.182262293 +0200
+@@ -1223,6 +1223,7 @@
+ 		if (sdp->detached)
+ 			return -ENODEV;
+ 		return put_user(sdp->device->host->hostt->emulated, ip);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+ 	case SG_SCSI_RESET:
+ 		if (sdp->detached)
+ 			return -ENODEV;
+@@ -1256,6 +1257,7 @@
+ 			return -EACCES;
+ 		return (scsi_reset_provider(sdp->device, val) ==
+ 			SUCCESS) ? 0 : -EIO;
++#endif
+ 	case SCSI_IOCTL_SEND_COMMAND:
+ 		if (sdp->detached)
+ 			return -ENODEV;
+@@ -1281,9 +1283,16 @@
+ 	case SCSI_IOCTL_GET_BUS_NUMBER:
+ 	case SCSI_IOCTL_PROBE_HOST:
+ 	case SG_GET_TRANSFORM:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
++	case SG_SCSI_RESET:
++#endif
+ 		if (sdp->detached)
+ 			return -ENODEV;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+ 		return pfo_scsi_ioctl(sdp->device, cmd_in, p);
++#else
++		break;
++#endif
+ 	case BLKSECTGET:
+ 		return put_user(queue_max_sectors(sdp->device->request_queue) * 512,
+ 				ip);
+@@ -1302,8 +1311,19 @@
+ 	default:
+ 		if (read_only)
+ 			return -EPERM;	/* don't know so take safe approach */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+ 		return pfo_scsi_ioctl(sdp->device, cmd_in, p);
++#else
++		break;
++#endif
+ 	}
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
++	result = scsi_ioctl_block_when_processing_errors(sdp->device,
++			cmd_in, filp->f_flags & O_NDELAY);
++	if (result)
++		return result;
++	return pfo_scsi_ioctl(sdp->device, cmd_in, p);
++#endif
+ }
+ 
+ #ifdef CONFIG_COMPAT
+diff -ur lin_tape-3.0.8.orig/stmp.c lin_tape-3.0.8/stmp.c
+--- lin_tape-3.0.8.orig/stmp.c	2016-06-19 13:11:34.000000000 +0200
++++ lin_tape-3.0.8/stmp.c	2016-06-19 13:12:36.339279356 +0200
+@@ -259,9 +259,14 @@
+ #endif
+ 
+ static struct scsi_driver st_template = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+ 	.owner			= THIS_MODULE,
++#endif
+ 	.gendrv = {
+ 		.name		= "st",
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
++		.owner		= THIS_MODULE,
++#endif
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
+ 		.groups         = st_drv_groups,
+ #endif
+@@ -3514,6 +3519,7 @@
+ 	STm = &(STp->modes[STp->current_mode]);
+ 	STps = &(STp->ps[STp->partition]);
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+ 	/*
+ 	 * If we are in the middle of error recovery, don't let anyone
+ 	 * else try and use this device.  Also, if error recovery fails, it
+@@ -3525,6 +3531,12 @@
+ 	if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV)
+ 		goto out;
+ 	retval = 0;
++#else
++	retval = scsi_ioctl_block_when_processing_errors(STp->device, cmd_in,
++			file->f_flags & O_NDELAY);
++	if (retval)
++ 		goto out;
++#endif
+ 
+ 	cmd_type = _IOC_TYPE(cmd_in);
+ 	cmd_nr = _IOC_NR(cmd_in);
diff --git a/linux-4.0.patch b/linux-4.0.patch
new file mode 100644
index 0000000..5f745be
--- /dev/null
+++ b/linux-4.0.patch
@@ -0,0 +1,71 @@
+diff -ur lin_tape-3.0.8.orig/lower.c lin_tape-3.0.8/lower.c
+--- lin_tape-3.0.8.orig/lower.c	2016-03-15 23:39:12.000000000 +0100
++++ lin_tape-3.0.8/lower.c	2016-06-19 13:16:12.828653141 +0200
+@@ -471,6 +471,21 @@
+ 		} else if (pfo_cmd->source == PFO_SOURCE_SG ||
+ 			   pfo_cmd->source == PFO_SOURCE_IOCTL) {
+ 			if (pfo_cmd->iov_count) {
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,19,0)
++				struct iovec *iov = NULL;
++				struct iov_iter i;
++				err = import_iovec(write, pfo_cmd->buffer, pfo_cmd->iov_count, 0, &iov, &i);
++				if (err < 0)
++					return err;
++				iov_iter_truncate(&i, pfo_cmd->bufflen);
++				
++				err = blk_rq_map_user_iov(sdev->request_queue,
++					rq,
++					pfo_cmd->mdata,
++					&i,
++					GFP_ATOMIC);
++				kfree(iov);
++#else
+ 				err = blk_rq_map_user_iov(sdev->request_queue,
+ 					rq,
+ 					pfo_cmd->mdata,
+@@ -478,6 +493,7 @@
+ 					pfo_cmd->iov_count,
+ 					pfo_cmd->bufflen,
+ 					GFP_KERNEL);
++#endif
+ 			} else {
+ 				err = blk_rq_map_user(sdev->request_queue,
+ 					rq,
+diff -ur lin_tape-3.0.8.orig/sgmp.c lin_tape-3.0.8/sgmp.c
+--- lin_tape-3.0.8.orig/sgmp.c	2016-06-19 13:15:52.000000000 +0200
++++ lin_tape-3.0.8/sgmp.c	2016-06-19 13:16:12.828653141 +0200
+@@ -2029,7 +2029,12 @@
+ 	}
+ 
+ 	if (iov_count) {
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,19,0)
++		int size = sizeof(struct iovec) * iov_count;
++		struct iov_iter i;
++#else
+ 		int len, size = sizeof(struct sg_iovec) * iov_count;
++#endif
+ 		struct iovec *iov;
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
+ 		iov = memdup_user(hp->dxferp, size);
+@@ -2046,6 +2051,13 @@
+ 		}
+ #endif
+ 
++#if LINUX_VERSION_CODE > KERNEL_VERSION(3,19,0)
++		iov_iter_init(&i, rw, iov, iov_count,
++			      min_t(size_t, hp->dxfer_len,
++				    iov_length(iov, iov_count)));
++
++		res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC);
++#else
+ 		len = iov_length(iov, iov_count);
+ 		if (hp->dxfer_len < len) {
+ 			iov_count = iov_shorten(iov, iov_count, hp->dxfer_len);
+@@ -2055,6 +2067,7 @@
+ 		res = blk_rq_map_user_iov(q, rq, md, (struct sg_iovec *)iov,
+ 					  iov_count,
+ 					  len, GFP_ATOMIC);
++#endif
+ 		kfree(iov);
+ 	} else
+ 		res = blk_rq_map_user(q, rq, md, hp->dxferp,
diff --git a/linux-4.6.patch b/linux-4.6.patch
new file mode 100644
index 0000000..9716831
--- /dev/null
+++ b/linux-4.6.patch
@@ -0,0 +1,94 @@
+diff -ur lin_tape-3.0.8.orig/lin_tape_scsi_tape.c lin_tape-3.0.8/lin_tape_scsi_tape.c
+--- lin_tape-3.0.8.orig/lin_tape_scsi_tape.c	2016-02-23 22:16:42.000000000 +0100
++++ lin_tape-3.0.8/lin_tape_scsi_tape.c	2016-06-19 13:17:29.632951394 +0200
+@@ -11480,10 +11480,14 @@
+ 
+ 	memset(pages, '\0', drv->supported_sg_tablesize * sizeof(struct page*));
+ 
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++	mapped_pages = get_user_pages_unlocked((ulong)user_location, number_pages, rw, 0, pages);
++#else
+ 	down_read(&current->mm->mmap_sem);
+ 	mapped_pages = get_user_pages(current, current->mm,
+ 		(ulong)user_location, number_pages, rw, 0, pages, NULL);
+ 	up_read(&current->mm->mmap_sem);
++#endif
+ 
+ 	if(mapped_pages < number_pages) {
+ 		rc = -EFAULT;
+@@ -11532,7 +11536,11 @@
+ EXIT_LABEL:
+ 
+ 	if(rc < STATUS_SUCCESS)
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++		for(i = 0; i < mapped_pages; i++) put_page(pages[i]);
++#else
+ 		for(i = 0; i < mapped_pages; i++) page_cache_release(pages[i]);
++#endif
+ 	if(pages_allocd) kfree(pages);
+ 	return rc;
+ } /* lin_tape_get_user_pages() */
+@@ -11567,7 +11575,11 @@
+ 				&drv->sg_list->gather[i]))) {
+ 				SetPageDirty(sg_page(&drv->sg_list->gather[i]));
+ 			} /* if */
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++			put_page(sg_page(&drv->sg_list->gather[i]));
++#else
+ 			page_cache_release(sg_page(&drv->sg_list->gather[i]));
++#endif
+ 		} /* if */
+ 	} /* for */
+ 
+diff -ur lin_tape-3.0.8.orig/stmp.c lin_tape-3.0.8/stmp.c
+--- lin_tape-3.0.8.orig/stmp.c	2016-06-19 13:17:14.000000000 +0200
++++ lin_tape-3.0.8/stmp.c	2016-06-19 13:17:29.632951394 +0200
+@@ -5329,7 +5329,14 @@
+ 
+ 	if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_KERNEL)) == NULL)
+ 		return -ENOMEM;
+-
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++	 res = get_user_pages_unlocked(
++		uaddr,
++		nr_pages,
++		rw == READ,
++		0, /* don't force */
++		pages);
++#else
+         /* Try to fault in all of the necessary pages */
+ 	down_read(&current->mm->mmap_sem);
+         /* rw==READ means read from drive, write into memory area */
+@@ -5343,6 +5350,7 @@
+ 		pages,
+ 		NULL);
+ 	up_read(&current->mm->mmap_sem);
++#endif
+ 
+ 	/* Errors and no page mapped should return here */
+ 	if (res < nr_pages)
+@@ -5362,7 +5370,11 @@
+  out_unmap:
+ 	if (res > 0) {
+ 		for (j=0; j < res; j++)
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++			put_page(pages[j]);
++#else
+ 			page_cache_release(pages[j]);
++#endif
+ 		res = 0;
+ 	}
+ 	kfree(pages);
+@@ -5384,7 +5396,11 @@
+ 		/* FIXME: cache flush missing for rw==READ
+ 		 * FIXME: call the correct reference counting function
+ 		 */
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4,5,0)
++		put_page(page);
++#else
+ 		page_cache_release(page);
++#endif
+ 	}
+ 	kfree(STbp->mapped_pages);
+ 	STbp->mapped_pages = NULL;
+Only in lin_tape-3.0.8: stmp.c.orig
diff --git a/use-module-dir.patch b/use-module-dir.patch
index 938b18b..9c079d0 100644
--- a/use-module-dir.patch
+++ b/use-module-dir.patch
@@ -8,26 +8,4 @@
 +VERSIONRELEASE := $(shell sed --regexp-extended -e '{/\#define LIN_TAPE_VERSION/ s/.*"([0-9.]*)-?([A-Za-z0-9.]*)"/\1 \2/p;d}' $(M)/lin_tape_tape.h)
  endif
  
- obj-m := lin_tape.o
---- lin_tape-1.74.0/Makefile.GPL~	2012-08-21 19:32:26.000000000 +0200
-+++ lin_tape-1.74.0/Makefile.GPL	2012-09-29 13:26:42.136710913 +0200
-@@ -5,7 +5,7 @@
- #include $(PWD)/Kbuild
- 
- else
--VERSIONRELEASE := $(shell sed --regexp-extended -e '{/\#define LIN_TAPE_VERSION/ s/.*"([0-9.]*)-?([A-Za-z0-9.]*)"/\1 \2/p;d}' lin_tape_tape.h)
-+VERSIONRELEASE := $(shell sed --regexp-extended -e '{/\#define LIN_TAPE_VERSION/ s/.*"([0-9.]*)-?([A-Za-z0-9.]*)"/\1 \2/p;d}' $(M)/lin_tape_tape.h)
- endif
- 
- obj-m := lin_tape.o
---- lin_tape-1.74.0/Makefile.supported~	2012-08-21 19:32:27.000000000 +0200
-+++ lin_tape-1.74.0/Makefile.supported	2012-09-29 13:26:59.573376965 +0200
-@@ -5,7 +5,7 @@
- #include $(PWD)/Kbuild
- 
- else
--VERSIONRELEASE := $(shell sed --regexp-extended -e '{/\#define LIN_TAPE_VERSION/ s/.*"([0-9.]*)-?([A-Za-z0-9.]*)"/\1 \2/p;d}' lin_tape_tape.h)
-+VERSIONRELEASE := $(shell sed --regexp-extended -e '{/\#define LIN_TAPE_VERSION/ s/.*"([0-9.]*)-?([A-Za-z0-9.]*)"/\1 \2/p;d}' $(M)/lin_tape_tape.h)
- endif
- 
- obj-m := lin_tape.o
+ obj-m := stmp.o
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/lin_tape.git/commitdiff/6986ddb6276be28b0a82655402970069f8c27b6d



More information about the pld-cvs-commit mailing list