diff options
Diffstat (limited to 'sanei/sanei_scsi.c')
-rw-r--r-- | sanei/sanei_scsi.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c index 2413d8f..b69f78f 100644 --- a/sanei/sanei_scsi.c +++ b/sanei/sanei_scsi.c @@ -252,11 +252,11 @@ static int unit_ready (int fd); #endif #if USE == SYSVR4_INTERFACE -# define MAX_DATA 56*1024 /* don't increase or kernel will dump - * tested with adsl, adsa and umax backend - * it depends on the lowend scsi - * drivers . But the most restriction - * is in the UNIXWARE KERNEL witch do +# define MAX_DATA 56*1024 /* don't increase or kernel will dump + * tested with adsl, adsa and umax backend + * it depends on the lowend scsi + * drivers . But the most restriction + * is in the UNIXWARE KERNEL witch do * not allow more then 64kB DMA transfers */ static char lastrcmd[16]; /* hold command block of last read command */ #endif @@ -615,7 +615,7 @@ open_aspi (void) DBG (1, "OS/2: unique id is '%s'\n", PSRBlock->u.inq.unique_id); strcpy (tmpAspi, "asXXXXXX"); - mktemp (tmpAspi); + mkstemp (tmpAspi); DBG (2, "open_aspi: open temporary file '%s'\n", tmpAspi); tmp = fopen (tmpAspi, "w"); if (!tmp) @@ -875,7 +875,7 @@ sanei_scsi_open (const char *dev, int *fdp, int fd, i; #if USE == LINUX_INTERFACE static int first_time = 1; -#elif USE == MACOSX_INTERFACE +#elif USE == MACOSX_INTERFACE UInt8 *guid; int len; u_int d; @@ -909,7 +909,7 @@ sanei_scsi_open (const char *dev, int *fdp, With newer versions of the SG driver, check the available buffer size by opening all SG device files belonging to a scanner, issue the ioctl calls for setting and reading the reserved - buffer size, and take the smallest value. + buffer size, and take the smallest value. For older version of the SG driver, which don't support variable buffer size, try to read /proc/sys/kernel/sg-big-biff ; if @@ -958,7 +958,7 @@ sanei_scsi_open (const char *dev, int *fdp, if (sscanf (dev, "b%dt%dl%d", &bus, &target, &lun) != 3) { - DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", + DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1149,7 +1149,7 @@ sanei_scsi_open (const char *dev, int *fdp, } else { - DBG (1, "sanei_scsi_open: can't open device `%s´: %s\n", dev, + DBG (1, "sanei_scsi_open: can't open device `%s´: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1163,7 +1163,7 @@ sanei_scsi_open (const char *dev, int *fdp, if (4 != sscanf (dev, "/dev/passthru0:%d,%d,%d,%d", &bus, &cnt, &id, &lun)) { - DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", + DBG (1, "sanei_scsi_open: device name `%s´ is not valid: %s\n", dev, strerror (errno)); return SANE_STATUS_INVAL; } @@ -1222,21 +1222,21 @@ sanei_scsi_open (const char *dev, int *fdp, { char scsi_hca_name[20]; u_int hca = 0; - + if (sscanf (dev, "h%ub%ut%ul%u", &hca, &bus, &target, &lun) != 4) { DBG (1, "sanei_scsi_open: device name %s is not valid\n", dev); return SANE_STATUS_INVAL; } - + snprintf(scsi_hca_name, 19, "\\\\.\\Scsi%d:", hca); scsi_hca_name[19] = 0; - + fd = CreateFile(scsi_hca_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL ); - + if (fd == INVALID_HANDLE_VALUE) fd = -1; } #else @@ -1420,7 +1420,7 @@ sanei_scsi_open (const char *dev, int *fdp, else { /* we have a really old SG driver version, or we're not opening - an SG device file + an SG device file */ if (ioctl (fd, SG_GET_TIMEOUT, &ioctl_val) < 0) { @@ -2436,8 +2436,8 @@ issue (struct req *req) } #if 0 - /* Sometimes the Linux SCSI system reports bogus resid values. - Observed with lk 2.4.5, 2.4.13, aic7xxx and sym53c8xx drivers, + /* Sometimes the Linux SCSI system reports bogus resid values. + Observed with lk 2.4.5, 2.4.13, aic7xxx and sym53c8xx drivers, if command queueing is used. So we better issue only a warning */ if (status == SANE_STATUS_GOOD) @@ -2601,7 +2601,7 @@ issue (struct req *req) } static int /* Returns 1 if match with 'name' set, else 0 */ - + lx_scan_sg (int exclude_devnum, char *name, size_t name_len, int host, int channel, int id, int lun) { @@ -2636,7 +2636,7 @@ issue (struct req *req) } static int /* Returns 1 if match, else 0 */ - + lx_chk_devicename (int guess_devnum, char *name, size_t name_len, int host, int channel, int id, int lun) { @@ -2945,8 +2945,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, char *me = "sanei_scsi_find_devices"; char path[PATH_MAX]; char dev_name[128]; - struct dirent buf; - struct dirent *de; + struct dirent *buf; DIR *scsidevs; FILE *fp; char *ptr; @@ -2987,8 +2986,9 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, number = -1; for (;;) { - ret = readdir_r(scsidevs, &buf, &de); - if (ret != 0) + errno = 0; + buf = readdir (scsidevs); + if (errno != 0) { DBG (1, "%s: could not read directory %s: %s\n", me, SYSFS_SCSI_DEVICES, strerror(errno)); @@ -2996,14 +2996,14 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, break; } - if (de == NULL) + if (buf == NULL) break; - if (buf.d_name[0] == '.') + if (buf->d_name[0] == '.') continue; /* Extract bus, channel, id, lun from directory name b:c:i:l */ - ptr = buf.d_name; + ptr = buf->d_name; for (i = 0; i < 4; i++) { errno = 0; @@ -3028,7 +3028,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (*end && (*end != ':')) { - DBG (1, "%s: parse error on string %s (%d)\n", me, buf.d_name, i); + DBG (1, "%s: parse error on string %s (%d)\n", me, buf->d_name, i); i = 12; /* Skip */ break; @@ -3036,7 +3036,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (val > INT_MAX) { - DBG (1, "%s: integer value too large (%s)\n", me, buf.d_name); + DBG (1, "%s: integer value too large (%s)\n", me, buf->d_name); i = 12; /* Skip */ break; @@ -3059,11 +3059,11 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, for (i = 0; i < 3; i++) { ret = snprintf (path, PATH_MAX, "%s/%s/%s", - SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); if ((ret < 0) || (ret >= PATH_MAX)) { DBG (1, "%s: skipping %s/%s, PATH_MAX exceeded on %s\n", - me, SYSFS_SCSI_DEVICES, buf.d_name, vmtfiles[i]); + me, SYSFS_SCSI_DEVICES, buf->d_name, vmtfiles[i]); i = 12; /* Skip */ break; @@ -3179,7 +3179,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, scsireq_t hdr; int result; -/* xxx obsolete: +/* xxx obsolete: cdb_size = CDB_SIZE (*(u_char *) src); */ @@ -3201,7 +3201,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, /* The old variant: hdr.databuf = (char *) src + cdb_size; hdr.datalen = src_size; - xxxxxx huh? Shouldn´t the above line have been src_size - cdb_size) + xxxxxx huh? Shouldn´t the above line have been src_size - cdb_size) */ hdr.databuf = (char *) src; hdr.datalen = src_size; @@ -3271,8 +3271,8 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, ccb = cam_getccb (dev); /* Build the CCB */ - bzero (&(&ccb->ccb_h)[1], sizeof (struct ccb_scsiio)); - bcopy (cmd, &ccb->csio.cdb_io.cdb_bytes, cmd_size); + memset (&(&ccb->ccb_h)[1], 0, sizeof (struct ccb_scsiio)); + memcpy (&ccb->csio.cdb_io.cdb_bytes, cmd, cmd_size); /* * Set the data direction flags. @@ -3368,7 +3368,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, int retval = 0; /* build ccb for device match */ - bzero (&cdm, sizeof (cdm)); + memset (&cdm, 0, sizeof (cdm)); cdm.ccb_h.func_code = XPT_DEV_MATCH; /* result buffer */ @@ -3454,7 +3454,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, } /* build ccb for device match */ - bzero (&cdm, sizeof (cdm)); + memset (&cdm, 0, sizeof (cdm)); cdm.ccb_h.func_code = XPT_DEV_MATCH; /* result buffer */ @@ -4449,7 +4449,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, memcpy (databuf, (u_char *) src, src_size); } - bzero (sensebuf, 128); + memset (sensebuf, 0, 128); /* * Do SCSI request... @@ -5013,7 +5013,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, #if USE == WIN32_INTERFACE SANE_Status -sanei_scsi_cmd2 (int fd, +sanei_scsi_cmd2 (int fd, const void *cmd, size_t cmd_size, const void *src, size_t src_size, void *dst, size_t * dst_size) @@ -5049,8 +5049,8 @@ sanei_scsi_cmd2 (int fd, pkt.sptd.DataBuffer = src; } else { - pkt.sptd.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; - } + pkt.sptd.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; + } pkt.sptd.TimeOutValue = sane_scsicmd_timeout; @@ -5081,7 +5081,7 @@ sanei_scsi_cmd2 (int fd, else { return SANE_STATUS_IO_ERROR; } - } + } else if (pkt.sptd.ScsiStatus != 0) { DBG (1, "sanei_scsi_cmd2: ScsiStatus is %d\n", pkt.sptd.ScsiStatus); @@ -5152,14 +5152,14 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, adapter = (PSCSI_ADAPTER_BUS_INFO)buffer; - for(i = 0; i < adapter->NumberOfBuses; i++) { + for(i = 0; i < adapter->NumberOfBuses; i++) { if (adapter->BusData[i].InquiryDataOffset == 0) { /* No device here */ continue; } - inquiry = (PSCSI_INQUIRY_DATA) (buffer + + inquiry = (PSCSI_INQUIRY_DATA) (buffer + adapter->BusData[i].InquiryDataOffset); while(1) { @@ -5358,7 +5358,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, memcpy (&cdb.cdb, cmd, cmd_size); if (dst && dst_size) { - bzero (dst, *dst_size); + memset (dst, 0, *dst_size); range.address = (IOVirtualAddress) dst; range.length = *dst_size; transferCount = *dst_size; @@ -5699,7 +5699,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, DBG (6, "isRead dst_size:%ld\n", *dst_size); /* Zero the buffer. */ - bzero (dst, *dst_size); + memset (dst, 0, *dst_size); /* Configure the virtual range for the buffer. */ range.address = (long) dst; @@ -5722,8 +5722,8 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, /* zero the senseData and CDB */ - bzero (&senseData, sizeof (senseData)); - bzero (cdb, sizeof (cdb)); + memset (&senseData, 0, sizeof (senseData)); + memset (cdb, 0, sizeof (cdb)); /* copy the command data */ memcpy (cdb, cmd, cmd_size); |