X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=cciss.cpp;h=f5871dd75786f959bfdf9457cce6644fb0e18c0a;hb=bcade6c14a06cfc842b41df91fdc5b9577cd68f1;hp=f81ab2cee3c0d6d45ab01ac09b7d107caec41137;hpb=81c40dd97143253168d7f4bd17fab2d43811461f;p=mirror_smartmontools-debian.git diff --git a/cciss.cpp b/cciss.cpp index f81ab2c..f5871dd 100644 --- a/cciss.cpp +++ b/cciss.cpp @@ -1,10 +1,11 @@ #include #include #include +#include #include "config.h" -#if defined(linux) +#if defined(linux) || defined(__linux__) # include # ifdef HAVE_LINUX_COMPILER_H # include @@ -14,18 +15,32 @@ # define _HAVE_CCISS # endif # include -# define be32toh __be32_to_cpu -#elif defined(__FreeBSD__) && defined(HAVE_DEV_CISS_CISSIO_H) +# ifndef be32toh +# define be32toh __be32_to_cpu +# endif +#elif defined(__FreeBSD__) # include -# include +# include CISS_LOCATION +# define _HAVE_CCISS +#elif defined(__FreeBSD_kernel__) +# include +# ifdef __GLIBC__ +# include +# include +# endif +# include CISS_LOCATION # define _HAVE_CCISS #endif #ifdef _HAVE_CCISS +#include "cciss.h" #include "int64.h" #include "scsicmds.h" #include "utility.h" +const char * cciss_cpp_cvsid = "$Id: cciss.cpp 4156 2015-10-18 12:20:40Z samm2 $" + CCISS_H_CVSID; + typedef struct _ReportLUNdata_struct { uint32_t LUNListLength; /* always big-endian */ @@ -58,10 +73,9 @@ int cciss_io_interface(int device, int target, struct scsi_cmnd_io * iop, int re unsigned char pBuf[512] = {0}; unsigned char phylun[8] = {0}; int iBufLen = 512; - int status = -1; int len = 0; // used later in the code. - status = cciss_getlun(device, target, phylun, report); + int status = cciss_getlun(device, target, phylun, report); if (report > 0) printf(" cciss_getlun(%d, %d) = 0x%x; scsi3addr: %02x %02x %02x %02x %02x %02x %02x %02x\n", device, target, status, @@ -166,7 +180,7 @@ static int cciss_sendpassthru(unsigned int cmdtype, unsigned char *CDB, if ((err = ioctl(fd, CCISS_PASSTHRU, &iocommand))) { - fprintf(stderr, "CCISS ioctl error %d (fd %d CDBLen %d buf_size %d)\n", + fprintf(stderr, "CCISS ioctl error %d (fd %d CDBLen %u buf_size %u)\n", fd, err, CDBlen, size); } return err; @@ -177,7 +191,6 @@ static int cciss_getlun(int device, int target, unsigned char *physlun, int repo unsigned char CDB[16]= {0}; ReportLunData_struct *luns; int reportlunsize = sizeof(*luns) + CISS_MAX_PHYS_LUN * 8; - int i; int ret; luns = (ReportLunData_struct *)malloc(reportlunsize); @@ -209,27 +222,15 @@ static int cciss_getlun(int device, int target, unsigned char *physlun, int repo pout("%02x ",*stuff++); pout("%02x\n",*stuff++); } - pout("===== [%s] DATA END (%d Bytes) =====\n\n", "LUN DATA", sizeof(_ReportLUNdata_struct)); + pout("===== [%s] DATA END (%u Bytes) =====\n\n", "LUN DATA", (unsigned)sizeof(_ReportLUNdata_struct)); } -#if 0 - for (i=0; iLUN[i][6] == target) - { - memcpy(physlun, luns->LUN[i], 8); - free(luns); - return 0; - } - } -#else if (target >= 0 && target < (int) be32toh(luns->LUNListLength) / 8) { memcpy(physlun, luns->LUN[target], 8); free(luns); return 0; } -#endif free(luns); return 1;