hal: Branch 'master'

Joe Marcus Clarke marcus at kemper.freedesktop.org
Sun Feb 3 08:29:35 PST 2008


 hald/freebsd/libprobe/hfp-cdrom.c           |   12 ++++++++----
 hald/freebsd/libprobe/hfp-cdrom.h           |    4 ++--
 hald/freebsd/probing/freebsd_dvd_rw_utils.c |    4 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 36227d8abb03188134fbaa274bdfe3788c0c97d0
Author: Joe Marcus Clarke <marcus at FreeBSD.org>
Date:   Sun Feb 3 11:29:47 2008 -0500

    do not assume a SCSI cdb size of 16
    
    Certain SCSI commands require a smaller cdb size than 16 bytes.  Trying
    to read more than the allowed amount can cause certain real SCSI devices to
    lock up (even freezing the entire SCSI bus).
    
    Submitted by:	Alexander Kabaev <kabaev at FreeBSD.org>

diff --git a/hald/freebsd/libprobe/hfp-cdrom.c b/hald/freebsd/libprobe/hfp-cdrom.c
index 11d6fa3..a19689d 100644
--- a/hald/freebsd/libprobe/hfp-cdrom.c
+++ b/hald/freebsd/libprobe/hfp-cdrom.c
@@ -124,13 +124,15 @@ hfp_cdrom_new_from_fd (int fd, const char *path, const char *parent)
 
 boolean
 hfp_cdrom_send_ccb (HFPCDROM *cdrom,
-		    char ccb[16],
-		    int timeout,
+		    const char *ccb,
+		    int ccb_len,
 		    HFPCDROMDirection direction,
 		    void *data,
 		    int len,
 		    char **err)
 {
+  int timeout;
+
   assert(cdrom != NULL);
   assert(ccb != NULL);
   assert(direction == HFP_CDROM_DIRECTION_NONE
@@ -138,6 +140,8 @@ hfp_cdrom_send_ccb (HFPCDROM *cdrom,
 	 || direction == HFP_CDROM_DIRECTION_OUT);
   assert(direction == HFP_CDROM_DIRECTION_NONE || data != NULL);
 
+  timeout = 10;
+
   if (cdrom->fd >= 0)		/* ATAPI transport */
     {
 #ifdef IOCATAREQUEST
@@ -227,7 +231,7 @@ hfp_cdrom_send_ccb (HFPCDROM *cdrom,
 		    data,
 		    len,
 		    sizeof(cam_ccb.csio.sense_data),
-		    16,
+		    ccb_len,
 		    timeout * 1000);
 
       memcpy(cam_ccb.csio.cdb_io.cdb_bytes, ccb, 16);
@@ -255,7 +259,7 @@ hfp_cdrom_test_unit_ready (HFPCDROM *cdrom)
 
   assert(cdrom != NULL);
 
-  return hfp_cdrom_send_ccb(cdrom, ccb, 10, HFP_CDROM_DIRECTION_NONE, NULL, 0, NULL);
+  return hfp_cdrom_send_ccb(cdrom, ccb, 6, HFP_CDROM_DIRECTION_NONE, NULL, 0, NULL);
 }
 
 void
diff --git a/hald/freebsd/libprobe/hfp-cdrom.h b/hald/freebsd/libprobe/hfp-cdrom.h
index 584b98e..5ad7595 100644
--- a/hald/freebsd/libprobe/hfp-cdrom.h
+++ b/hald/freebsd/libprobe/hfp-cdrom.h
@@ -149,8 +149,8 @@ HFPCDROM *hfp_cdrom_new (const char *path, const char *parent);
 HFPCDROM *hfp_cdrom_new_from_fd (int fd, const char *path, const char *parent);
 
 boolean hfp_cdrom_send_ccb (HFPCDROM *cdrom,
-			    char ccb[16],
-			    int timeout,
+			    const char *ccb,
+			    int ccb_len,
 			    HFPCDROMDirection direction,
 			    void *data,
 			    int len,
diff --git a/hald/freebsd/probing/freebsd_dvd_rw_utils.c b/hald/freebsd/probing/freebsd_dvd_rw_utils.c
index 230c829..d602a8e 100644
--- a/hald/freebsd/probing/freebsd_dvd_rw_utils.c
+++ b/hald/freebsd/probing/freebsd_dvd_rw_utils.c
@@ -28,6 +28,7 @@ typedef struct ScsiCommand ScsiCommand;
 struct ScsiCommand {
 	HFPCDROM		*cdrom;
 	char			ccb[16];
+	int			len;
 };
 
 static ScsiCommand *
@@ -51,13 +52,14 @@ static void
 scsi_command_init (ScsiCommand * cmd, size_t i, int arg)
 {
 	cmd->ccb[i] = arg;
+	cmd->len = i + 1;
 }
 
 static int
 scsi_command_transport (ScsiCommand * cmd, Direction dir, void *buf,
 			size_t sz)
 {
-	if (hfp_cdrom_send_ccb(cmd->cdrom, cmd->ccb, 10, dir, buf, sz, NULL))
+	if (hfp_cdrom_send_ccb(cmd->cdrom, cmd->ccb, cmd->len, dir, buf, sz, NULL))
 		return 0;
 	else
 		return -1;


More information about the hal-commit mailing list