diff --git a/sg3_utils.changes b/sg3_utils.changes index 32adaf1..d8f635c 100644 --- a/sg3_utils.changes +++ b/sg3_utils.changes @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Tue Apr 15 20:11:54 UTC 2014 - spargaonkar@suse.com + +- added patch sginfo-inq-fields-strip-blank.patch + sg3_utils: Strip out trailing info from vendor info products fields in inq + bnc#863357 + +- added patches: + * sginfo-inq-fields-strip-blank.patch +------------------------------------------------------------------- Fri Apr 11 12:12:47 CEST 2014 - hare@suse.de - Split off 59-scsi-sg_utils.rules to properly support diff --git a/sg3_utils.spec b/sg3_utils.spec index 0413424..491a38c 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -27,6 +27,7 @@ Url: http://sg.danny.cz/sg/sg3_utils.html Source: http://sg.danny.cz/sg/p/%name-%{version}.tar.xz Patch1: 0001-Split-59-scsi-sg_utils.rules-for-multipath-support.patch +Patch2: sginfo-inq-fields-strip-blank.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: udev BuildRequires: xz @@ -82,6 +83,7 @@ applications that want to make use of libsgutils. %prep %setup -q -n %{name}-%{version} %patch1 -p1 +%patch2 -p1 %build %configure --disable-static --with-pic diff --git a/sginfo-inq-fields-strip-blank.patch b/sginfo-inq-fields-strip-blank.patch new file mode 100644 index 0000000..bda2e94 --- /dev/null +++ b/sginfo-inq-fields-strip-blank.patch @@ -0,0 +1,75 @@ +From: Shirish Pargaonkar +Subject: sg3_utils: Strip out trailing info from vendor info products fields in inquiry +commit 1756f3b04d4c45d7a0d78e128786b2a1c619565e +Date: Tue Apr 15 10:31:23 2014 -0500 +Reference: bnc#863357 + + +sginfo prints out various fields such as Vendor and Product in +INQUIRY response with spaces (0x20) characters. +This can confuse scripts some users have. +Strip out those trailing spaces (if any). + + +signed-of-by: Shirish Pargaonkar +--- +diff --git a/src/sginfo.c b/src/sginfo.c +index b27f117..b9f3f77 100644 +--- a/src/sginfo.c ++++ b/src/sginfo.c +@@ -155,6 +155,7 @@ static char *device_name; + #define MAX_BUFFER_SIZE MAX_RESP10_SIZE + + #define INQUIRY_RESP_INITIAL_LEN 36 ++#define MAX_INQFIELD_LEN 17 + + #define MAX_HEADS 127 + #define HEAD_SORT_TOKEN 0x55 +@@ -3139,11 +3140,23 @@ do_user_page(struct mpage_info * mpi, int decode_in_hex) + return status; + } + ++static void ++inqfieldname(unsigned char *deststr, const unsigned char *srcbuf, int maxlen) ++{ ++ int i; ++ ++ memset(deststr, '\0', MAX_INQFIELD_LEN); ++ for (i = maxlen - 1; i >= 0 && isspace(srcbuf[i]); --i) ++ ; ++ memcpy(deststr, srcbuf, i + 1); ++} ++ + static int + do_inquiry(int * peri_type, int * resp_byte6, int inquiry_verbosity) + { + int status; + unsigned char cmd[6]; ++ unsigned char fieldname[MAX_INQFIELD_LEN]; + unsigned char *pagestart; + struct scsi_cmnd_io sci; + +@@ -3214,14 +3227,17 @@ do_inquiry(int * peri_type, int * resp_byte6, int inquiry_verbosity) + } + if (x_interface) + printf("\n"); +- printf("%s%.8s\n", (!x_interface ? "Vendor: " : ""), +- pagestart + 8); ++ inqfieldname(fieldname, pagestart + 8, 8); ++ printf("%s%s\n", (!x_interface ? "Vendor: " : ""), ++ fieldname); + +- printf("%s%.16s\n", (!x_interface ? "Product: " : ""), +- pagestart + 16); ++ inqfieldname(fieldname, pagestart + 16, 16); ++ printf("%s%s\n", (!x_interface ? "Product: " : ""), ++ fieldname); + +- printf("%s%.4s\n", (!x_interface ? "Revision level: " : ""), +- pagestart + 32); ++ inqfieldname(fieldname, pagestart + 32, 4); ++ printf("%s%s\n", (!x_interface ? "Revision level: " : ""), ++ fieldname); + + printf("\n"); + return status;