Changes of Revision 3
[-] | Changed | vhba-kmp.spec |
x 1
2 -# norootforbuild 3 -%define pname vhba-module 4 -Name: vhba 5 -BuildRequires: kernel-source kernel-syms module-init-tools 6 -Summary: VHBA module provides Virtual (SCSI) Host Bus Adapter, which is the link between userspace daemon and linux kernel. 7 -Version: 1.1.0 8 -Release: 20 9 -Group: Hardware/Other 10 -License: GPL 11 -BuildRoot: %{_tmppath}/%{name}-%{version}-build 12 -URL: http://cdemu.sf.net/ 13 -Source: http://prdownloads.sourceforge.net/cdemu/%{pname}-%{version}.tar.bz2 14 -ExclusiveArch: %ix86 x86_64 15 -%suse_kernel_module_package -n %name kdump um 16 - 17 -%description 18 -VHBA module provides Virtual (SCSI) Host Bus Adapter, which is the link between userspace daemon and linux kernel. 19 - 20 -%package KMP 21 -Group: System/Kernel 22 -License: GPL 23 -Summary: The Virtual (SCSI) Host Bus Adapter kernel module. 24 - 25 -%description KMP 26 -This package contains the cdemu kernel module. 27 - 28 -%prep 29 -%setup -q -n %{pname}-%{version} 30 - 31 - 32 -%build 33 - 34 -cd .. 35 -mkdir -p obj 36 -for flavor in %flavors_to_build; do 37 - rm -rf obj/$flavor 38 - cp -r %{pname}-%{version} obj/$flavor 39 -# an ugly workaround because the makefiles tries to include other makefiles from its directory, 40 -# but during the build process it gets processed from somewhere else -- anyone knows a better way? 41 - export MKINCLUDEDIR=$PWD/obj/$flavor 42 - sed -i "s/PWD/MKINCLUDEDIR/g" $MKINCLUDEDIR/Makefile 43 - make -C /usr/src/linux-obj/%{_target_cpu}/$flavor modules %{?jobs:-j%{jobs}} M=$PWD/obj/$flavor 44 -done 45 - 46 - 47 -%install 48 -export INSTALL_MOD_PATH=$RPM_BUILD_ROOT 49 -export INSTALL_MOD_DIR=updates 50 -cd ../obj 51 -for flavor in %flavors_to_build; do 52 - cd $flavor 53 - make -C /usr/src/linux-obj/%{_target_cpu}/$flavor modules_install M=$PWD 54 - cd .. 55 -done 56 - 57 -%clean 58 -rm -rf $RPM_BUILD_ROOT 59 - 60 -%post KMP 61 -# add an udev rule and run depmod -aq 62 -echo 'KERNEL="cdemu[0-9]*", NAME="cdemu/%n", MODE="0666"' >> /etc/udev/rules.d/55-cdrom.rules 63 -/sbin/depmod -aq 64 - 65 -%postun KMP 66 -# remove the udev rule 67 -# should we search only cdrom.rules or all udev rules? 68 -# this might NOT work! 69 -sed -i "s/`grep cdemu /etc/udev/rules.d/55-cdrom.rules`//g" /etc/udev/rules.d/55-cdrom.rules 70 -#but perhaps this one instead? but what shall we do if the user changed the entry? 71 -#sed -i "s/'KERNEL="cdemu[0-9]*", NAME="cdemu/%n", MODE="0666"'//g" /etc/udev/rules.d/55-cdrom.rules 72 - 73 -%files 74 -%defattr(-,root,root) 75 -%doc AUTHORS ChangeLog COPYING README 76 +# norootforbuild 77 + 78 +Summary: VHBA virtual host bus adapter module 79 +Name: vhba-kmp 80 +Version: 1.1.0 81 +Release: 1 82 +License: GPL 83 +Group: System/Kernel 84 +URL: http://cdemu.sourceforge.net 85 +Packager: Leonardo Chiquitto <lchiquitto@novell.com> 86 +Source: http://downloads.sourceforge.net/cdemu/vhba-module-%{version}.tar.gz 87 +Source1: Kbuild 88 +Source100: preamble 89 +Patch0: vhba-2.6.25.patch 90 +BuildRoot: %{_tmppath}/%{name}-%{version}-build 91 +ExclusiveArch: %ix86 x86_64 92 +BuildRequires: kernel-source kernel-syms module-init-tools 93 + 94 +%suse_kernel_module_package -n vhba -p %_sourcedir/preamble kdump um 95 +%define kernel_version %(echo `rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-source`|sed 's/_/-/g;') 96 + 97 +%description 98 +VHBA kernel module, a virtual SCSI host bus adapter used by CDEmu daemon from 99 +userspace-cdemu suite. 100 + 101 +#%package -n vhba-KMP 102 +#Group: System/Kernel 103 +#License: GPL v2 or later 104 +#Summary: VHBA virtual host bus adapter module 105 + 106 +#%description -n vhba-KMP 107 +#VHBA kernel module, a virtual SCSI host bus adapter used by CDEmu daemon from 108 +#userspace-cdemu suite. 109 + 110 +%prep 111 +%setup -n vhba-module-%{version} 112 +#%patch0 113 +cp %{SOURCE1} vhba-module-%{version} 114 + 115 +%build 116 +for flavor in %{flavors_to_build}; do 117 + make -C /usr/src/linux-obj/%_target_cpu/$flavor modules M=$PWD 118 +done 119 + 120 +%install 121 +export INSTALL_MOD_PATH=%{buildroot} 122 +export INSTALL_MOD_DIR=updates 123 +for flavor in %flavors_to_build; do 124 + make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install M=$PWD 125 +done 126 + 127 +%clean 128 +rm -rf %{buildroot} 129 130 %changelog 131 * Sat Jul 19 2008 Carsten Schoene <cs@linux-administrator.com> 132 |
||
[+] | Added | vhba-2.6.25.patch ^ |
@@ -0,0 +1,186 @@ +--- vhba.c.orig 2008-06-11 15:09:55.000000000 -0300 ++++ vhba.c 2008-06-11 15:09:58.000000000 -0300 +@@ -58,6 +58,8 @@ + #define DATA_TO_DEVICE(dir) ((dir) == DMA_TO_DEVICE || (dir) == DMA_BIDIRECTIONAL) + #define DATA_FROM_DEVICE(dir) ((dir) == DMA_FROM_DEVICE || (dir) == DMA_BIDIRECTIONAL) + ++#define KAT_HAVE_SCSI_MACROS ++ + enum vhba_req_state { + VHBA_REQ_FREE, + VHBA_REQ_PENDING, +@@ -419,17 +421,25 @@ + .sg_tablesize = 256, + }; + +-static ssize_t do_request(const struct scsi_cmnd *cmd, char __user *buf, size_t buf_len) ++static ssize_t do_request(struct scsi_cmnd *cmd, char __user *buf, size_t buf_len) + { + struct vhba_request vreq; + ssize_t ret; + + scmd_dbg(cmd, "request %lu, cdb 0x%x, bufflen %d, use_sg %d\n", +- cmd->serial_number, cmd->cmnd[0], cmd->request_bufflen, cmd->use_sg); ++#ifdef KAT_HAVE_SCSI_MACROS ++ cmd->serial_number, cmd->cmnd[0], scsi_bufflen(cmd), scsi_sg_count(cmd)); ++#else ++ cmd->serial_number, cmd->cmnd[0], cmd->request_bufflen, cmd->use_sg); ++#endif + + ret = sizeof(vreq); + if (DATA_TO_DEVICE(cmd->sc_data_direction)) +- ret += cmd->request_bufflen; ++#ifdef KAT_HAVE_SCSI_MACROS ++ ret += scsi_bufflen(cmd); ++#else ++ ret += cmd->request_bufflen; ++#endif + + if (ret > buf_len) + { +@@ -442,7 +452,11 @@ + vreq.lun = cmd->device->lun; + memcpy(vreq.cdb, cmd->cmnd, MAX_COMMAND_SIZE); + vreq.cdb_len = cmd->cmd_len; ++#ifdef KAT_HAVE_SCSI_MACROS ++ vreq.data_len = scsi_bufflen(cmd); ++#else + vreq.data_len = cmd->request_bufflen; ++#endif + + if (copy_to_user(buf, &vreq, sizeof(vreq))) + return -EFAULT; +@@ -452,7 +466,11 @@ + buf += sizeof(vreq); + + /* XXX use_sg? */ +- if (copy_to_user(buf, cmd->request_buffer, vreq.data_len)) ++#ifdef KAT_HAVE_SCSI_MACROS ++ if (copy_to_user(buf, scsi_sglist(cmd), vreq.data_len)) ++#else ++ if (copy_to_user(buf, cmd->request_buffer, vreq.data_len)) ++#endif + return -EFAULT; + } + +@@ -464,7 +482,11 @@ + ssize_t ret = 0; + + scmd_dbg(cmd, "response %lu, status %x, data len %d, use_sg %d\n", +- cmd->serial_number, res->status, res->data_len, cmd->use_sg); ++#ifdef KAT_HAVE_SCSI_MACROS ++ cmd->serial_number, res->status, res->data_len, scsi_sg_count(cmd)); ++#else ++ cmd->serial_number, res->status, res->data_len, cmd->use_sg); ++#endif + + if (res->status) + { +@@ -481,23 +503,43 @@ + + ret += res->data_len; + } ++#ifdef KAT_HAVE_SCSI_MACROS ++ else if (DATA_FROM_DEVICE(cmd->sc_data_direction) && scsi_bufflen(cmd)) ++#else + else if (DATA_FROM_DEVICE(cmd->sc_data_direction) && cmd->request_bufflen) ++#endif + { + size_t to_read; + +- if (res->data_len > cmd->request_bufflen) ++#ifdef KAT_HAVE_SCSI_MACROS ++ if (res->data_len > scsi_bufflen(cmd)) ++ { ++ scmd_warn(cmd, "truncate data (%d < %d)\n", scsi_bufflen(cmd), res->data_len); ++ res->data_len = scsi_bufflen(cmd); ++ } ++#else ++ if (res->data_len > cmd->request_bufflen) + { + scmd_warn(cmd, "truncate data (%d < %d)\n", cmd->request_bufflen, res->data_len); + res->data_len = cmd->request_bufflen; + } ++#endif + + to_read = res->data_len; + +- if (cmd->use_sg) ++#ifdef KAT_HAVE_SCSI_MACROS ++ if (scsi_sg_count(cmd)) ++#else ++ if (cmd->use_sg) ++#endif + { + unsigned char buf_stack[64]; + unsigned char *kaddr, *uaddr, *kbuf; +- struct scatterlist *sg = cmd->request_buffer; ++#ifdef KAT_HAVE_SCSI_MACROS ++ struct scatterlist *sg = scsi_sglist(cmd); ++#else ++ struct scatterlist *sg = cmd->request_buffer; ++#endif + int i; + + uaddr = (unsigned char *) buf; +@@ -507,7 +549,11 @@ + else + kbuf = buf_stack; + ++#ifdef KAT_HAVE_SCSI_MACROS ++ for (i = 0; i < scsi_sg_count(cmd); i++) ++#else + for (i = 0; i < cmd->use_sg; i++) ++#endif + { + size_t len = (sg[i].length < to_read) ? sg[i].length : to_read; + +@@ -520,7 +566,11 @@ + } + uaddr += len; + ++#ifdef KAT_SCATTERLIST_HAS_PAGE + kaddr = kmap_atomic(sg[i].page, KM_USER0); ++#else ++ kaddr = kmap_atomic(sg_page(&sg[i]), KM_USER0); ++#endif + memcpy(kaddr + sg[i].offset, kbuf, len); + kunmap_atomic(kaddr, KM_USER0); + +@@ -534,13 +584,21 @@ + } + else + { +- if (copy_from_user(cmd->request_buffer, buf, res->data_len)) ++#ifdef KAT_HAVE_SCSI_MACROS ++ if (copy_from_user(scsi_sglist(cmd), buf, res->data_len)) ++#else ++ if (copy_from_user(cmd->request_buffer, buf, res->data_len)) ++#endif + return -EFAULT; + + to_read -= res->data_len; + } + +- cmd->resid = to_read; ++#ifdef KAT_HAVE_SCSI_MACROS ++ scsi_set_resid(cmd, to_read); ++#else ++ cmd->resid = to_read; ++#endif + + ret += res->data_len - to_read; + } +--- Makefile.orig 2008-06-11 15:13:23.000000000 -0300 ++++ Makefile 2008-06-11 15:13:27.000000000 -0300 +@@ -1,7 +1,7 @@ + VHBA_VERSION = 1.0.0 + PACKAGE = vhba-module-$(VHBA_VERSION) + +-CFLAGS += -DVHBA_VERSION=\"$(VHBA_VERSION)\" ++EXTRA_CFLAGS += -DVHBA_VERSION=\"$(VHBA_VERSION)\" + + obj-m += vhba.o + + + | ||
[+] | Added | Kbuild ^ |
@@ -0,0 +1,4 @@ +VHBA_VERSION = 1.0.0 +EXTRA_CFLAGS += -DVHBA_VERSION=\"$(VHBA_VERSION)\" + +obj-m += vhba.o | ||
[+] | Added | preamble ^ |
@@ -0,0 +1,4 @@ +Enhances: kernel-%1 +PreReq: grep coreutils + + | ||
[+] | Added | vhba-kmp.spec.old ^ |
@@ -0,0 +1,79 @@ +# norootforbuild +%define pname vhba-module +Name: vhba +BuildRequires: kernel-source kernel-syms module-init-tools +Summary: VHBA module provides Virtual (SCSI) Host Bus Adapter, which is the link between userspace daemon and linux kernel. +Version: 1.1.0 +Release: 20 +Group: Hardware/Other +License: GPL +BuildRoot: %{_tmppath}/%{name}-%{version}-build +URL: http://cdemu.sf.net/ +Source: http://prdownloads.sourceforge.net/cdemu/%{pname}-%{version}.tar.bz2 +ExclusiveArch: %ix86 x86_64 +%suse_kernel_module_package -n %name kdump um + +%description +VHBA module provides Virtual (SCSI) Host Bus Adapter, which is the link between userspace daemon and linux kernel. + +%package KMP +Group: System/Kernel +License: GPL +Summary: The Virtual (SCSI) Host Bus Adapter kernel module. + +%description KMP +This package contains the cdemu kernel module. + +%prep +%setup -q -n %{pname}-%{version} + + +%build + +cd .. +mkdir -p obj +for flavor in %flavors_to_build; do + rm -rf obj/$flavor + cp -r %{pname}-%{version} obj/$flavor +# an ugly workaround because the makefiles tries to include other makefiles from its directory, +# but during the build process it gets processed from somewhere else -- anyone knows a better way? + export MKINCLUDEDIR=$PWD/obj/$flavor + sed -i "s/PWD/MKINCLUDEDIR/g" $MKINCLUDEDIR/Makefile + make -C /usr/src/linux-obj/%{_target_cpu}/$flavor modules %{?jobs:-j%{jobs}} M=$PWD/obj/$flavor +done + + +%install +export INSTALL_MOD_PATH=$RPM_BUILD_ROOT +export INSTALL_MOD_DIR=updates +cd ../obj +for flavor in %flavors_to_build; do + cd $flavor + make -C /usr/src/linux-obj/%{_target_cpu}/$flavor modules_install M=$PWD + cd .. +done + +%clean +rm -rf $RPM_BUILD_ROOT + +%post KMP +# add an udev rule and run depmod -aq +echo 'KERNEL="cdemu[0-9]*", NAME="cdemu/%n", MODE="0666"' >> /etc/udev/rules.d/55-cdrom.rules +/sbin/depmod -aq + +%postun KMP +# remove the udev rule +# should we search only cdrom.rules or all udev rules? +# this might NOT work! +sed -i "s/`grep cdemu /etc/udev/rules.d/55-cdrom.rules`//g" /etc/udev/rules.d/55-cdrom.rules +#but perhaps this one instead? but what shall we do if the user changed the entry? +#sed -i "s/'KERNEL="cdemu[0-9]*", NAME="cdemu/%n", MODE="0666"'//g" /etc/udev/rules.d/55-cdrom.rules + +%files +%defattr(-,root,root) +%doc AUTHORS ChangeLog COPYING README + +%changelog +* Sat Jul 19 2008 Carsten Schoene <cs@linux-administrator.com> +- initial package import + |