diff --git a/eject-scsi-check-host_status-and-driver_status.patch b/eject-scsi-check-host_status-and-driver_status.patch new file mode 100644 index 0000000..6347102 --- /dev/null +++ b/eject-scsi-check-host_status-and-driver_status.patch @@ -0,0 +1,77 @@ +From 90a0e97c7be9da39fd54600228e006b98667ad56 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 18 Jun 2013 12:24:28 +0200 +Subject: [PATCH 1/2] eject: Check host_status and driver_status when using + SG_IO. + +Based on Suse patch, originally from + Anna Bernathova , May 2008 + + SG_IO completion status is weird but still well defined. You'll need + to check both host_status, driver_status and status to determine that + a command actually succeeded. -- Tejun Heo, May 2008 + +Note that we also need to check driver_status and sense_buffer to +detect situation when there is no medium. It's valid request to call +eject(8) for device with no medium. + +References: https://bugzilla.novell.com/show_bug.cgi?id=358033 +Signed-off-by: Anna Bernathova +Signed-off-by: Karel Zak +--- + sys-utils/eject.c | 24 +++++++++++++++++++++--- + 1 file changed, 21 insertions(+), 3 deletions(-) + +diff --git a/sys-utils/eject.c b/sys-utils/eject.c +index 4ec69e7..f98f227 100644 +--- a/sys-utils/eject.c ++++ b/sys-utils/eject.c +@@ -53,6 +53,14 @@ + #include "pathnames.h" + #include "sysfs.h" + ++/* ++ * sg_io_hdr_t driver_status -- see kernel include/scsi/scsi.h ++ */ ++#ifndef DRIVER_SENSE ++# define DRIVER_SENSE 0x08 ++#endif ++ ++ + #define EJECT_DEFAULT_DEVICE "/dev/cdrom" + + +@@ -604,17 +612,27 @@ static int eject_scsi(int fd) + + io_hdr.cmdp = allowRmBlk; + status = ioctl(fd, SG_IO, (void *)&io_hdr); +- if (status < 0) ++ if (status < 0 || io_hdr.host_status || io_hdr.driver_status) + return 0; + + io_hdr.cmdp = startStop1Blk; + status = ioctl(fd, SG_IO, (void *)&io_hdr); +- if (status < 0) ++ if (status < 0 || io_hdr.host_status) ++ return 0; ++ ++ /* Ignore errors when there is not medium -- in this case driver sense ++ * buffer sets MEDIUM NOT PRESENT (3a) bit. For more details see: ++ * http://www.tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-22.html#sec-sensecodes ++ * -- kzak Jun 2013 ++ */ ++ if (io_hdr.driver_status != 0 && ++ !(io_hdr.driver_status == DRIVER_SENSE && io_hdr.sbp && ++ io_hdr.sbp[12] == 0x3a)) + return 0; + + io_hdr.cmdp = startStop2Blk; + status = ioctl(fd, SG_IO, (void *)&io_hdr); +- if (status < 0) ++ if (status < 0 || io_hdr.host_status || io_hdr.driver_status) + return 0; + + /* force kernel to reread partition table when new disc inserted */ +-- +1.8.1.4 + diff --git a/util-linux.changes b/util-linux.changes index fe6c6cb..5fcc15c 100644 --- a/util-linux.changes +++ b/util-linux.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Fri Jun 28 17:42:14 CEST 2013 - sbrabec@suse.cz + +- Fix Provides and Obsoletes of eject. +- Conflict with old coreutils and sysvinit-tools with conflicting + files to guarantee seamless upgrade. +- Remove Provides and Obsoletes of packages that do not exist since + SuSE Linux 8. +- Include upstreamed patch from SUSE eject package: + Check eject host_status and driver_status when using SG_IO + (eject-scsi-check-host_status-and-driver_status.patch, + bnc#358033). + ------------------------------------------------------------------- Wed Jun 19 10:58:17 UTC 2013 - coolo@suse.com diff --git a/util-linux.spec b/util-linux.spec index ca119b0..4c3a1f3 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -16,12 +16,6 @@ # -# -# Following package should be fixed: -# coreutils ... do not install su and kill -# sysvinit-tools ... do not install sulogin and utmpdump -# eject ... simply drop this package -# %bcond_without sysvinit_tools %bcond_without enable_su %bcond_without enable_eject @@ -95,7 +89,8 @@ Patch2: util-linux-2.23.1-eject-fpie.patch Patch3: fdisk-tinfo.patch # PATCH-EXTEND-UPSTREAM: Let `su' handle /sbin and /usr/sbin in path Patch4: make-sure-sbin-resp-usr-sbin-are-in-PATH.diff - +# PATCH-FIX-UPSTREAM eject-scsi-check-host_status-and-driver_status.patch bnc358033 anicka@suse.cz -- Check eject host_status and driver_status when using SG_IO. +Patch5: eject-scsi-check-host_status-and-driver_status.patch # disable encryption Patch12: util-linux-2.23.1-noenc-suse.diff @@ -115,20 +110,25 @@ Patch61: mkfs.bfs_cleanup_endian.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build PreReq: %insserv_prereq %fillup_prereq /bin/sed # -Provides: base = %{version}-%{release} -Provides: eject = %{version}-%{release} +%if %{with enable_eject} +Provides: eject = 2.1.0-166.8 +%endif Provides: login = 4.0-33.7 -Provides: raw = %{version}-%{release} -Provides: rawio = %{version}-%{release} -Provides: util = %{version}-%{release} -Provides: uuid-runtime = %{version}-%{release} -Obsoletes: base < %{version}-%{release} -Obsoletes: eject < %{version}-%{release} +%if %{with enable_eject} +# File conflict of eject (up to 12.3 and SLE11). +Obsoletes: eject < 2.1.0-166.8 +%endif +# File conflict of login (up to 12.1 and SLE11). Obsoletes: login < 4.0-33.7 -Obsoletes: raw < %{version}-%{release} -Obsoletes: rawio < %{version}-%{release} -Obsoletes: util < %{version}-%{release} -Obsoletes: uuid-runtime < %{version}-%{release} +%if %{with enable_su} +# File conflict of su and kill (up to 12.3 and SLE11). +# It should be coreutils < 8.21-4, but coreutils provide Release-less symbol. +Conflicts: coreutils < 8.21 +%endif +%if %{with enable_su} +# File conflict of sulogin and utmpdump (up to 12.3 and SLE11). +Conflicts: sysvinit-tools < 2.88+-87 +%endif # # Using "Requires" here would lend itself to help upgrading, but since # util-linux is in the initial bootstrap, that is not a good thing to do: @@ -210,6 +210,7 @@ Files to develop applications using the libmount library. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %patch12 -p1 # %patch20 -p1 @@ -795,6 +796,7 @@ fi %dir %{_datadir}/getopt %attr (755,root,root) %{_datadir}/getopt/getopt-parse.bash %attr (755,root,root) %{_datadir}/getopt/getopt-parse.tcsh +# FIXME: Fix directory ownership. %{_datadir}/bash-completion %ifnarch ia64 #XXX: post our patches upstream