- 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 OBS-URL: https://build.opensuse.org/request/show/230262 OBS-URL: https://build.opensuse.org/package/show/Base:System/sg3_utils?expand=0&rev=35
76 lines
2.3 KiB
Diff
76 lines
2.3 KiB
Diff
From: Shirish Pargaonkar <spargaonkar@suse.com>
|
|
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 <device> 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 <spargaonkar@suse.com>
|
|
---
|
|
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;
|