Package init

This commit is contained in:
overweight 2019-09-30 11:17:00 -04:00
commit ecf8da6ebc
11 changed files with 558 additions and 0 deletions

View File

@ -0,0 +1,27 @@
From a0569d83929d98c0a175bc3992352c2c8d09ffa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Fri, 18 Oct 2013 12:38:05 +0200
Subject: [PATCH] don't open /dev/snapshot in sginfo (#920687)
see https://bugzilla.redhat.com/show_bug.cgi?id=920687 for details
---
src/sginfo.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/sginfo.c b/src/sginfo.c
index b27f117..1f2151d 100644
--- a/src/sginfo.c
+++ b/src/sginfo.c
@@ -3408,6 +3408,9 @@ show_devices(int raw)
if ( isdigit(entry->d_name[strlen(entry->d_name)-1]) ) {
continue;
}
+ if ( strncmp("snapshot",entry->d_name,8) == 0 ) {
+ continue;
+ }
snprintf(dev_name, sizeof(dev_name),"/dev/%s",entry->d_name);
--
1.8.1.4

View File

@ -0,0 +1,132 @@
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 76773fa..914570b 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -18,8 +18,11 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h> /* to define 'major' */
+#ifndef major
+#include <sys/types.h>
+#endif
#ifdef HAVE_CONFIG_H
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 97a6f77..7bb5eed 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -44,13 +44,15 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/file.h>
-#include <linux/major.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
#include <linux/fs.h> /* <sys/mount.h> */
+#include <linux/major.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/src/sg_map26.c b/src/sg_map26.c
index 7739592..8e583d2 100644
--- a/src/sg_map26.c
+++ b/src/sg_map26.c
@@ -33,8 +33,11 @@
#include <dirent.h>
#include <libgen.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h> /* new location for major + minor */
+#ifndef major
+#include <sys/types.h>
+#endif
#include <linux/major.h>
#ifdef HAVE_CONFIG_H
diff --git a/src/sg_read.c b/src/sg_read.c
index 2cf8212..1eb0411 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -36,9 +36,11 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
#include <sys/mman.h>
#include <sys/time.h>
#include <linux/major.h>
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index 11206ac..49b4341 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -47,11 +47,13 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/file.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
#include <linux/major.h>
#include <linux/fs.h> /* <sys/mount.h> */
diff --git a/src/sgm_dd.c b/src/sgm_dd.c
index 4e40acc..edf4861 100644
--- a/src/sgm_dd.c
+++ b/src/sgm_dd.c
@@ -48,11 +48,13 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <sys/mman.h>
#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
#include <linux/major.h>
#include <linux/fs.h> /* <sys/mount.h> */
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index 1ebecca..be9547b 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -43,9 +43,11 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
+#ifndef major
+#include <sys/types.h>
+#endif
#include <sys/time.h>
#include <linux/major.h>
#include <linux/fs.h> /* <sys/mount.h> */

View File

@ -0,0 +1,18 @@
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 16041ee..74d5683 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -734,7 +734,12 @@ findremapped()
remapped=0
id_serial=`udevadm info -q all -n $sddev | grep "ID_SERIAL=" | cut -d"=" -f2`
[ -z "$id_serial" ] && id_serial="none"
- if [ "$id_serial_old" != "$id_serial" ] ; then
+ dm_name=`cat /sys/class/scsi_device/$hctl/device/block/$sddev/holders/*/dm/name 2>/dev/null`
+ [ -z "$dm_name" ] && dm_name=$id_serial
+ if [ "$id_serial_old" != "$id_serial" -o "$id_serial_old" != "$dm_name" ] ; then
+ echo "$hctl id_serial_old=$id_serial_old"
+ echo "$hctl id_serial=$id_serial"
+ echo "$hctl dm_name=$dm_name"
remapped=1
fi
# If udev events updated the disks already, but the multipath device isn't update

View File

@ -0,0 +1,29 @@
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 16041ee..e411fd2 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -713,6 +713,7 @@ findremapped()
rm -f $tmpfile
fi
+ echo -n "Triggering udev to update device information... "
# Get all of the ID_SERIAL attributes, after finding their sd node
for hctl in $devs ; do
if [ -d /sys/class/scsi_device/$hctl/device/block ] ; then
@@ -720,12 +721,14 @@ findremapped()
id_serial_old=`udevadm info -q all -n $sddev | grep "ID_SERIAL=" | cut -d"=" -f2`
[ -z "$id_serial_old" ] && id_serial_old="none"
echo "$hctl $sddev $id_serial_old" >> $tmpfile
+ udevadm trigger --name-match=$sddev
+ sleep 0.01
fi
done
# Trigger udev to update the info
- echo -n "Triggering udev to update device information... "
- /sbin/udevadm trigger
+ #echo -n "Triggering udev to update device information... "
+ #/sbin/udevadm trigger
udevadm_settle 2>&1 /dev/null
echo "Done"

View File

@ -0,0 +1,58 @@
From eabadd8e6a20252b8ff2f7fde35fd0976a421be8 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 20 Mar 2019 21:04:34 +0800
Subject: [PATCH] sg3_utils: fix syntax error
reason: when some variable not set, test its value, it will show
"test: =: unary operator expected" error message
---
scripts/rescan-scsi-bus.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 4fa5e6c..9bfd3be 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -85,10 +85,10 @@ findhosts ()
hosts=
for driverdir in /proc/scsi/*; do
driver=${driverdir#/proc/scsi/}
- if test $driver = scsi -o $driver = sg -o $driver = dummy -o $driver = device_info; then continue; fi
+ if test x$driver = xscsi -o x$driver = xsg -o x$driver = xdummy -o x$driver = xdevice_info; then continue; fi
for hostdir in $driverdir/*; do
name=${hostdir#/proc/scsi/*/}
- if test $name = add_map -o $name = map -o $name = mod_parm; then continue; fi
+ if test x$name = xadd_map -o x$name = xmap -o x$name = xmod_parm; then continue; fi
num=$name
driverinfo=$driver
if test -r $hostdir/status; then
@@ -254,7 +254,7 @@ testonline ()
print_and_scroll_back "$host:$channel:$id:$lun $SGDEV ($RMB) "
test $RC = 2 -a "$RMB" = "1" && break
done
- if test $ctr != 0; then white_out; fi
+ if test x$ctr != x0; then white_out; fi
# echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n"
if test $RC = 1; then return $RC; fi
# Reset RC (might be !=0 for passive paths)
@@ -512,7 +512,7 @@ dolunscan()
# Device not present
printf "\r\e[A";
# Optimization: if lun==0, stop here (only if in non-remove mode)
- if test $lun = 0 -a -z "$remove" -a $optscan = 1; then
+ if test x$lun = x0 -a -z "$remove" -a x$optscan = x1; then
break;
fi
else
@@ -1193,7 +1193,7 @@ if [ -d /sys/class/scsi_host -a ! -w /sys/class/scsi_host ]; then
fi
if test "$sync" = 1 -a "$remove" = 1; then sync=2; fi
if test "$sync" = 2; then echo "Syncing file systems"; sync; fi
-if test -w /sys/module/scsi_mod/parameters/default_dev_flags -a $scan_flags != 0; then
+if test -w /sys/module/scsi_mod/parameters/default_dev_flags -a x$scan_flags != x0; then
OLD_SCANFLAGS=`cat /sys/module/scsi_mod/parameters/default_dev_flags`
NEW_SCANFLAGS=$(($OLD_SCANFLAGS|$scan_flags))
if test "$OLD_SCANFLAGS" != "$NEW_SCANFLAGS"; then
--
2.19.1

View File

@ -0,0 +1,62 @@
From 96055f3a30d9643eff5141ed1926468301379c74 Mon Sep 17 00:00:00 2001
From: Douglas Gilbert <dgilbert@interlog.com>
Date: Fri, 8 Apr 2016 02:46:35 +0000
Subject: [PATCH 016/126] sg_inq: fix potential unbounded loop in --export
git-svn-id: svn://localhost/trunk@691 6180dd3e-e324-4e3e-922d-17de1ae2f315
---
src/sg_inq.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 9dc8838..8aa1970 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -43,7 +43,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.57 20160208"; /* SPC-5 rev 08 */
+static const char * version_str = "1.58 20160407"; /* SPC-5 rev 08 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
@@ -1032,17 +1032,18 @@ static int
encode_whitespaces(unsigned char *str, int inlen)
{
int k, res;
- int j = 0;
- int valid = 0;
+ int j;
+ bool valid = false;
int outlen = inlen, zeroes = 0;
/* Skip initial whitespaces */
- while (isblank(str[j]))
- j++;
- /* Skip possible unicode prefix characters */
- while (str[j] < 0x20)
- j++;
-
+ for (j = 0; (j < inlen) && isblank(str[j]); ++j)
+ ;
+ if (j < inlen) {
+ /* Skip possible unicode prefix characters */
+ for ( ; (j < inlen) && (str[j] < 0x20); ++j)
+ ;
+ }
k = j;
/* Strip trailing whitespaces */
while ((outlen > k) &&
@@ -1069,7 +1070,7 @@ encode_whitespaces(unsigned char *str, int inlen)
zeroes = 0;
} else {
str[res++] = str[k];
- valid++;
+ valid = true;
zeroes = 0;
}
}
--
1.8.3.1

View File

@ -0,0 +1,21 @@
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 9bfd3be..417dd1d 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -513,7 +513,7 @@ dolunscan()
printf "\r\e[A";
# Optimization: if lun==0, stop here (only if in non-remove mode)
if test x$lun = x0 -a -z "$remove" -a x$optscan = x1; then
- break;
+ return 1;
fi
else
if test "$remappedlun0" != "2" ; then
@@ -521,6 +521,7 @@ dolunscan()
fi
fi
fi
+ return 0;
}
# Perform report lun scan on $host $channel $id using REPORT_LUNS

28
9005-for-dolunscan.patch Normal file
View File

@ -0,0 +1,28 @@
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 417dd1d..4b23ba4 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -594,6 +594,7 @@ doreportlun()
if test $tmplun -eq $lun ; then
inlist=1
dolunscan $lun0added
+ [ $? -eq 1 ] && break
else
newsearch="$newsearch $tmplun"
fi
@@ -610,6 +611,7 @@ doreportlun()
# Add new ones and check stale ones
for lun in $targetluns $lunremove; do
dolunscan $lun0added
+ [ $? -eq 1 ] && break
done
}
@@ -629,6 +631,7 @@ dosearch ()
else
for lun in $lunsearch; do
dolunscan
+ [ $? -eq 1 ] && break
done
fi
done

View File

@ -0,0 +1,52 @@
From 56fb49584c56afe1f222b3ee9fc12c7cfd079286 Mon Sep 17 00:00:00 2001
From: wubo <wubo40@huawei.com>
Date: Tue, 27 Aug 2019 14:16:48 +0800
Subject: [PATCH] rescan-scsi-bus.sh fix delete lun report error
---
scripts/rescan-scsi-bus.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 4b23ba4..3f18403 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -434,7 +434,7 @@ dolunscan()
# Well known lun transition case. Only for Direct-Access devs (type 0)
# If block directory exists && and PQUAL != 0, we unmapped lun0 and just have a well-known lun
# If block directory doesn't exist && PQUAL == 0, we mapped a real lun0
- if test $lun -eq 0 -a $IPTYPE -eq 0 ; then
+ if test x"$lun" = x0 -a x"$IPTYPE" = x0 ; then
if test $RC = 2 ; then
if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then
if test -d /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/block ; then
@@ -443,7 +443,7 @@ dolunscan()
RC=0 # Set this so the system leaves the existing well known lun alone. This is a lun 0 with no block directory
fi
fi
- elif test $RC = 0 -a $IPTYPE -eq 0; then
+ elif test $RC = 0 -a x"$IPTYPE" = x0; then
if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then
if test ! -d /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/block ; then
remappedlun0=1 # Transition from well-known to real lun 0
@@ -455,7 +455,7 @@ dolunscan()
# Special case: lun 0 just got added (for reportlunscan),
# so make sure we correctly treat it as new
- if test "$lun" = "0" -a "$1" = "1" -a -z "$remappedlun0"; then
+ if test x"$lun" = x"0" -a "$1" = "1" -a -z "$remappedlun0"; then
SCSISTR=""
printf "\r\e[A\e[A\e[A"
fi
@@ -478,7 +478,7 @@ dolunscan()
sleep 0.02
else
echo "scsi remove-single-device $devnr" > /proc/scsi/scsi
- if test $RC -eq 1 -o $lun -eq 0 ; then
+ if test $RC -eq 1 -o x"$lun" = x0 ; then
# Try readding, should fail if device is gone
echo "scsi add-single-device $devnr" > /proc/scsi/scsi
fi
--
1.8.3.1

BIN
sg3_utils-1.42.tar.xz Normal file

Binary file not shown.

131
sg3_utils.spec Normal file
View File

@ -0,0 +1,131 @@
Name: sg3_utils
Version: 1.42
Release: 9
Summary: Utilities that send SCSI commands to devices.
License: GPL-2.0-or-later AND BSD
URL: http://sg.danny.cz/sg/sg3_utils.html
Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tar.xz
Patch0000: 0000-sg3_utils-1.37-dont-open-dev-snapshot.patch
Patch0001: 0001-sg3_utils-1.42-sysmacros.patch
Patch9000: 9000-sg3_utils-1.37-rescan-scsi-findremapped-enhance.patch
Patch9001: 9001-sg3_utils-1.37-rescan-downpress.patch
Patch9002: 9002-bugfix-sg3_utils-fix-syntax-error.patch
Patch9003: 9003-sg_inq-fix-potential-unbounded-loop-in-export.patch
Patch9004: 9004-break-to-return.patch
Patch9005: 9005-for-dolunscan.patch
Patch9006: 9006-sg3_utils-1.42-delete-lun-rescan-scsi-bus-report-error.patch
Provides: %{name}-libs
Obsoletes: %{name}-libs
BuildRequires: gcc, git
%description
The sg3_utils package contains utilities that send SCSI commands to devices. As well as
devices on transports traditionally associated with SCSI (e.g. Fibre Channel (FCP),
Serial Attached SCSI (SAS) and the SCSI Parallel Interface(SPI)) many other devices use
SCSI command sets. ATAPI cd/dvd drives and SATA disks that connect via a translation
layer or a bridge device are examples of devices that use SCSI command sets.
%package devel
Summary: A collection of tools that send SCSI commands to devices
Obsoletes: %{name}-libs
%description devel
This subpackage contains libraries and header files for developing
applications that want to make use of libsgutils.
%package help
Summary: Including man files for pciutils
Requires: man
%description help
This contains man files for the using of pciutils.
%prep
%autosetup -Sgit -n %{name}-%{version}
%build
%configure --disable-static
# Don't use rpath!
%disable_rpath
make %{?_smp_mflags}
%install
%make_install
install -p -m 644 doc/rescan-scsi-bus.sh.8 $RPM_BUILD_ROOT%{_mandir}/man8
install -p -m 755 scripts/rescan-scsi-bus.sh $RPM_BUILD_ROOT%{_bindir}
( cd $RPM_BUILD_ROOT%{_bindir}; ln -sf rescan-scsi-bus.sh scsi-rescan )
rm -rf $RPM_BUILD_ROOT/%{_libdir}/*.la
#Files list
%files
%defattr(-,root,root)
%doc AUTHORS BSD_LICENSE COPYING COVERAGE CREDITS ChangeLog README README.sg_start
%{_bindir}/*
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root)
%{_includedir}/scsi/*.h
%{_libdir}/*.so
%files help
%{_mandir}/man8/*
%changelog
* Tue Sep 24 2019 wubo <wubo40@huawei.com> - 1.42-9
- Type:enhancemnet
- ID:NA
- SUG:restart
- DESCi: delete lun rescan scsi bus report error
* Fri Aug 23 2019 zoujing <zoujing13@huawei.com> - 1.42-8
- Type:enhancemnet
- ID:NA
- SUG:restart
- DESCi:openEuler Debranding
* Wed Aug 21 2019 wubo <wubo40@huawei.com> - 1.42-6.7
- change patch name
* Mon Jul 18 2019 wangye<wangye54@huawei.com> - 1.42-6.6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: huawei for dolunscan
* Mon Jul 8 2019 wangye<wangye54@huawei.com> - 1.42-6.5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: huawei break to return
* Tue Apr 16 2019 zhangyujing<zhangyujing1@huawei.com> - 1.42-6.4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:sg inq fix potential unbounded loop in export
* Tue Apr 2 2019 guyue<guyue7@huawei.com> - 1.42-6.3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:delete useless code
* Wed Mar 20 2019 wangjufeng<wangjufeng@huawei.com> - 1.42-6.2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix syntax error
* Wed Jan 23 2019 huangchangyu<huangchangyu@huawei.com> - 1.42-6.1
- Type:enhanced
- ID:NA
- SUG:NA
- DESC:change patch name according to new rule
* Tue Jan 22 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.42-6
- Package init