PATCH: cdrecord: avoiding scsi device numbering for ide devices

From: H.Rosmanith (Kernel Mailing List) (kernel_at_wildsau.enemy.org)
Date: 08/04/04

  • Next message: Dmitry Torokhov: "Re: KVM & mouse wheel"
    To: linux-kernel@vger.kernel.org
    Date:	Wed, 4 Aug 2004 14:33:09 +0200 (MET DST)
    
    

    hi,

    I've written a patch for cdrecord/cdrtools. I've sent it to Joerg Schilling
    already, but got no answer so far. Probably he's on vaccation.

    I'm sending this to LKML too, because I've read about some ... nebulosity
    with respect to scsi device numbering as used by cdrtools.

    To cut a long story short: the patch avoids cdrecord having to use the
    "virtual" scsi device numbering in the form of "ATAPI:x.y.z" and allows
    you to use the name of the device, e.g. /dev/hdc instead.

    By removing the IDE to virtual scsi bus/host/lun mapping, a lot of confusion
    can be avoided especially if you have a lot devices of this kind in one
    system.

    with kind regards,
    Herbert "herp" Rosmanith

    Version: cdrtools-2.01a34

    Solution: when the device specified in dev= starts with "/dev/hd" and
              this device can be found in /proc/ide, then cdrecord (and all
              it's components, such as e.g. cdrdao) is forced to use the
              ATAPI driver.

    The patch is really very short and works at least on our system.

    with kind regards,
    Herbert Rosmanith

    --- snip ---
    diff -ru cdrtools-2.01.orig/libscg/scsi-linux-ata.c cdrtools-2.01/libscg/scsi-linux-ata.c
    --- cdrtools-2.01.orig/libscg/scsi-linux-ata.c Sat Jun 12 12:48:12 2004
    +++ cdrtools-2.01/libscg/scsi-linux-ata.c Wed Aug 4 14:19:31 2004
    @@ -42,6 +42,11 @@
      * You should have received a copy of the GNU General Public License along with
      * this program; see the file COPYING. If not, write to the Free Software
      * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    + *
    + * Sat Jun 12 12:48:12 CEST 2004 herp - Herbert Rosmanith
    + * Force ATAPI driver if dev= starts with /dev/hd and device
    + * is present in /proc/ide/hdX
    + *
      */
     
     #ifdef USE_ATA
    @@ -60,7 +65,7 @@
     LOCAL int scgo_areset __PR((SCSI *scgp, int what));
     LOCAL int scgo_asend __PR((SCSI *scgp));
     
    -LOCAL scg_ops_t ata_ops = {
    +EXPORT scg_ops_t scg_ata_ops = {
             scgo_asend,
             scgo_aversion,
             scgo_ahelp,
    diff -ru cdrtools-2.01.orig/libscg/scsi-linux-sg.c cdrtools-2.01/libscg/scsi-linux-sg.c
    --- cdrtools-2.01.orig/libscg/scsi-linux-sg.c Thu May 20 15:42:12 2004
    +++ cdrtools-2.01/libscg/scsi-linux-sg.c Wed Aug 4 14:20:56 2004
    @@ -40,6 +40,11 @@
      * string is related to a modified source.
      *
      * Copyright (c) 1997 J. Schilling
    + *
    + * Sat Jun 12 12:48:12 CEST 2004 herp - Herbert Rosmanith
    + * Force ATAPI driver if dev= starts with /dev/hd and device
    + * is present in /proc/ide/hdX
    + *
      */
     /*
      * This program is free software; you can redistribute it and/or modify
    @@ -315,7 +320,7 @@
             if (device != NULL && *device != '\0') {
     #ifdef USE_ATA
                     if (strncmp(device, "ATAPI", 5) == 0) {
    - scgp->ops = &ata_ops;
    + scgp->ops = &scg_ata_ops;
                             return (SCGO_OPEN(scgp, device));
                     }
     #endif
    diff -ru cdrtools-2.01.orig/libscg/scsitransp.c cdrtools-2.01/libscg/scsitransp.c
    --- cdrtools-2.01.orig/libscg/scsitransp.c Thu Jun 17 22:20:27 2004
    +++ cdrtools-2.01/libscg/scsitransp.c Wed Aug 4 14:26:07 2004
    @@ -13,6 +13,11 @@
      * string is related to a modified source.
      *
      * Copyright (c) 1988,1995,2000-2004 J. Schilling
    + *
    + * Sat Jun 12 12:48:12 CEST 2004 herp - Herbert Rosmanith
    + * Force ATAPI driver if dev= starts with /dev/hd and device
    + * is present in /proc/ide/hdX
    + *
      */
     /*
      * This program is free software; you can redistribute it and/or modify
    @@ -34,6 +39,7 @@
     #include <stdio.h>
     #include <standard.h>
     #include <stdxlib.h>
    +#include <sys/stat.h>
     #include <unixstd.h>
     #include <errno.h>
     #include <timedefs.h>
    @@ -157,7 +163,7 @@
     {
             int ret;
             scg_ops_t *ops;
    -extern scg_ops_t scg_std_ops;
    +extern scg_ops_t scg_std_ops,scg_ata_ops;
     
             /*
              * Begin restricted code for quality assurance.
    @@ -185,6 +191,16 @@
                             scgp->ops = ops;
             }
     
    + // XXX herp - check if atapi driver neccessary
    + // and load if ide device found
    +
    + if (device && strncmp(device,"/dev/hd",7)==0) {
    + char pdev[]="/proc/ide/XXXX";
    + struct stat st;
    + strncpy(pdev+10,device+5,4); /* hdXY should be enough, eh? */
    + if (stat(pdev,&st)==0)
    + scgp->ops=&scg_ata_ops;
    + }
             ret = SCGO_OPEN(scgp, device);
             if (ret < 0)
                     return (ret);
    --- snip ---

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Dmitry Torokhov: "Re: KVM & mouse wheel"

    Relevant Pages

    • Re: [CFT] updated gcc-3.4.0 fixes patch for 2.4.27-pre1
      ... I propose fixing problems that will appear with gcc 3.5, ... Here is a patch for the few places I got hit at. ... pci_set_drvdata(pci_dev, dev); ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH 02/14] Big kfree NULL check cleanup - drivers/net
      ... This is the drivers/net/ part of the big kfree cleanup patch. ... static void b44_free_consistent ... free_netdev; ... /* Unlink device structure, free pieces */ ...
      (Linux-Kernel)
    • [RFC] /sys/class/mem support
      ... Here's a patch against the latest 2.6.0-test3-bk tree that adds ... Robert Love was thinking of moving some of the /proc/sys/kernel/random/ ... | `-- dev ... Memory devices are never unregistered from the kernel, ...
      (Linux-Kernel)
    • [PATCH] new device support for forcedeth.c second try
      ... patch drew some criticism, so I changed a few bits. ... static int mii_rw(struct net_device *dev, int addr, int miireg, int value) ... static void nv_txrx_reset ...
      (Linux-Kernel)
    • Re: [PATCH]: PCI: GART iommu alignment fixes [v2]
      ... The cpu return address and the DMA bus master address are both ... The v3 patch I have from you doesn't apply to my tree but it looks like a good fix. ... some trivial values for the dev, ... -static unsigned long alloc_iommu(struct device *dev, int size) ...
      (Linux-Kernel)