Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
sg3_utils.1394
sginfo-inq-fields-strip-blank.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sginfo-inq-fields-strip-blank.patch of Package sg3_utils.1394
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;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor