From: John Kingman Date: Wed, 4 Jul 2007 21:38:53 +0000 (+0200) Subject: [checkers] handle >512 sector size in readsector0 X-Git-Tag: 0.4.8~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=648833108fc5a95cbe15bd779289e98165c34d25;p=platform%2Fupstream%2Fmultipath-tools.git [checkers] handle >512 sector size in readsector0 I encountered a problem with the sg_read() routine in readsector0.c while testing an InfiniBand target having 4096 byte sectors. The sg_read() routine assumes that sectors are 512 bytes long. A patch for the problem follows. Signed-off-by: Christophe Varoqui --- diff --git a/libcheckers/libsg.c b/libcheckers/libsg.c index f426aaf..9171b10 100644 --- a/libcheckers/libsg.c +++ b/libcheckers/libsg.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "checkers.h" #include "libsg.h" @@ -25,8 +26,12 @@ sg_read (int sg_fd, unsigned char * buff, unsigned char * senseBuff) int res; int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; int sz_ind; + struct stat filestatus; int retry_count = 3; - + + if (fstat(sg_fd, &filestatus) != 0) + return PATH_DOWN; + bs = (filestatus.st_blksize > 4096)? 4096: filestatus.st_blksize; memset(rdCmd, 0, cdbsz); sz_ind = 1; rdCmd[0] = rd_opcode[sz_ind]; diff --git a/libcheckers/readsector0.c b/libcheckers/readsector0.c index 3cddfa8..bef0eb6 100644 --- a/libcheckers/readsector0.c +++ b/libcheckers/readsector0.c @@ -26,7 +26,7 @@ void readsector0_free (struct checker * c) extern int readsector0 (struct checker * c) { - unsigned char buf[512]; + unsigned char buf[4096]; unsigned char sbuf[SENSE_BUFF_LEN]; int ret;