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 <christophe.varoqui@free.fr>
#include <string.h>
#include <sys/ioctl.h>
#include <errno.h>
+#include <sys/stat.h>
#include "checkers.h"
#include "libsg.h"
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];
extern int
readsector0 (struct checker * c)
{
- unsigned char buf[512];
+ unsigned char buf[4096];
unsigned char sbuf[SENSE_BUFF_LEN];
int ret;