devfs
[Top] [All Lists]

Re: PATCH: Re: Strange devices in devfs

To: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
Subject: Re: PATCH: Re: Strange devices in devfs
From: Richard Gooch <rgooch@xxxxxxxxxxxxxxx>
Date: Sun, 20 Jan 2002 14:20:42 -0700
Cc: devfs mailing list <devfs@xxxxxxxxxxx>, Mandrake kernel list <kernel@xxxxxxxxxxxxxxxx>
In-reply-to: <1011469337.2456.5.camel@xxxxxxxxxxxxxxxxxxxxx>
References: <1011389385.2428.1.camel@xxxxxxxxxxxxxxxxxxxxx> <1011469337.2456.5.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: owner-devfs@xxxxxxxxxxx
Borsenkow Andrej writes:
> 
> --=-LF7ErWmLg/hcTmBTogqk
> Content-Type: text/plain; charset=KOI8-R
> Content-Transfer-Encoding: quoted-printable
> 
> On =F3=C2=D4, 2002-01-19 at 00:29, Andrej Borsenkow wrote:
> > lr-xr-xr-x    1 root     root            6 Jan 18  2002 /dev/hdy ->
> > ide/cd/
> > {pts/1}% LC_TIME=3Den LANGUAGE=3Den ll /dev/ide/cd
> > total 0
> > lr-xr-xr-x    1 root     root           29 Jan 18  2002 c0b1t0u0 ->
> > ../host0/bus1/target0/lun0/cd
> > lr-xr-xr-x    1 root     root            5 Jan 18  2002
> > c-1073745722b0t6u134553339 -> ../cd/
> > lr-xr-xr-x    1 root     root            5 Jan 17 22:12
> > c-1073745722b0t6u134621803 -> ../cd/
> >=20
> 
> Attached patch stops devfsd attempts to treat /dev/ide/cd as CD-ROM.=20

I've had a closer look at your patch, and I don't rellay like the
approach. I've come up with a cleaner way to do this. At the same
time, I've finally gotten around to consolidating some of that code,
which makes devfsd a little smaller.

I've appended a patch between devfsd-v1.3.21 and my current
tree. Please try this out and let me know how it goes. If it works
fine, I'll release devfsd-v1.3.22.


                                Regards,

                                        Richard....
Permanent: rgooch@xxxxxxxxxxxxx
Current:   rgooch@xxxxxxxxxxxxxxx

diff -urN /tmp/devfsd-v1.3.21/compat_name.c devfsd/compat_name.c
--- /tmp/devfsd-v1.3.21/compat_name.c   Thu Nov  8 10:42:17 2001
+++ devfsd/compat_name.c        Sun Jan 20 14:05:57 2002
@@ -2,7 +2,7 @@
 
     Compatibility name file for  devfsd  (build compatibility names).
 
-    Copyright (C) 1998-2001  Richard Gooch
+    Copyright (C) 1998-2002  Richard Gooch
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -48,9 +48,16 @@
     Updated by      Richard Gooch   6-NOV-2001: Updated compatibility entry
   support for fixed Computone serial driver names.
 
-    Last updated by Richard Gooch   8-NOV-2001: Updated compatibility entry
+    Updated by      Richard Gooch   8-NOV-2001: Updated compatibility entry
   support for pending Cyclades serial driver names.
 
+    Updated by      Richard Gooch   19-JAN-2002: Fixed <write_old_sd_name> when
+  there are more than 26 SCSI discs.
+
+    Last updated by Richard Gooch   20-JAN-2002: Fixed <get_old_name> to ignore
+  new compatibility names for IDE devices. Consolidated SCSI code. Consolidated
+  IDE code.
+
 
 */
 #include <linux/major.h>
@@ -149,68 +156,59 @@
        sprintf (buffer, "sbpcd%u", minor);
        compat_name = buffer;
     }
-    else if ( (strncmp (devname, "scsi/", 5) == 0) &&
-             (strcmp (devname + namelen - 7, "generic") == 0) )
-    {
-       sprintf (buffer, "sg%u", minor);
-       compat_name = buffer;
-    }
-    else if ( (strncmp (devname, "scsi/", 5) == 0) &&
-             (strncmp (ptr = (strrchr (devname, '/') + 1), "mt", 2)
-              == 0) )
-    {
-       char mode = ptr[2];
+    else if (strncmp (devname, "scsi/", 5) == 0)
+    {   /*  All SCSI devices  */
+       if (strcmp (devname + namelen - 7, "generic") == 0)
+       {
+           sprintf (buffer, "sg%u", minor);
+           compat_name = buffer;
+       }
+       else if (strncmp (ptr = (strrchr (devname, '/') + 1), "mt", 2) == 0)
+       {
+           char mode = ptr[2];
 
-       if (mode == 'n') mode = '\0';
-       sprintf (buffer, "nst%u%c", minor & 0x1f, mode);
-       compat_name = buffer;
-       if (devname[namelen - 1] != 'n') ++compat_name;
-    }
-    else if ( (strncmp (devname, "ide/", 4) == 0) &&
-             (strncmp (ptr = (strrchr (devname, '/') + 1), "mt", 2)
-              == 0) )
-    {
-       sprintf (buffer, "%sht%d", ptr + 2, minor & 0x7f);
-       compat_name = buffer;
-    }
-    else if ( (strncmp (devname, "scsi/", 5) == 0) &&
-             (strcmp (devname + namelen - 2, "cd") == 0) )
-    {
-       sprintf (buffer, "sr%u", minor);
-       compat_name = buffer;
-    }
-    else if ( (strncmp (devname, "scsi/", 5) == 0) &&
-             (strcmp (devname + namelen - 4, "disc") == 0) )
-    {
-       compat_name = write_old_sd_name (buffer, major, minor, "");
-    }
-    else if ( (strncmp (devname, "scsi/", 5) == 0) &&
-             (strncmp (ptr = (strrchr (devname, '/') +1), "part", 4)
-              == 0) )
-    {
-       compat_name = write_old_sd_name (buffer, major, minor, ptr + 4);
-    }
-    else if ( (strncmp (devname, "ide/", 4) == 0) &&
-             (strcmp (devname + namelen - 4, "disc") == 0) )
-    {
-       sprintf ( buffer, "hd%c",
-                 get_old_ide_name (major, minor) );
-       compat_name = buffer;
-    }
-    else if ( (strncmp (devname, "ide/", 4) == 0) &&
-             (strncmp (ptr = (strrchr (devname, '/') +1), "part", 4)
-              == 0) )
-    {
-       sprintf (buffer, "hd%c%s",
-                get_old_ide_name (major, minor), ptr + 4);
-       compat_name = buffer;
-    }
-    else if ( (strncmp (devname, "ide/", 4) == 0) &&
-             (strcmp (devname + namelen - 2, "cd") == 0) )
-    {
-       sprintf ( buffer, "hd%c",
-                 get_old_ide_name (major, minor) );
-       compat_name = buffer;
+           if (mode == 'n') mode = '\0';
+           sprintf (buffer, "nst%u%c", minor & 0x1f, mode);
+           compat_name = buffer;
+           if (devname[namelen - 1] != 'n') ++compat_name;
+       }
+       else if (strcmp (devname + namelen - 2, "cd") == 0)
+       {
+           sprintf (buffer, "sr%u", minor);
+           compat_name = buffer;
+       }
+       else if (strcmp (devname + namelen - 4, "disc") == 0)
+           compat_name = write_old_sd_name (buffer, major, minor, "");
+       else if (strncmp (ptr = (strrchr (devname, '/') + 1), "part", 4) == 0)
+           compat_name = write_old_sd_name (buffer, major, minor, ptr + 4);
+       return (compat_name);
+    }
+    else if (strncmp (devname, "ide/host", 8) == 0)
+    {   /*  All IDE devices  */
+       if (strncmp (ptr = (strrchr (devname, '/') + 1), "mt", 2) == 0)
+       {
+           sprintf (buffer, "%sht%d", ptr + 2, minor & 0x7f);
+           compat_name = buffer;
+       }
+       else if (strcmp (devname + namelen - 4, "disc") == 0)
+       {
+           sprintf ( buffer, "hd%c",
+                     get_old_ide_name (major, minor) );
+           compat_name = buffer;
+       }
+       else if (strncmp (ptr = (strrchr (devname, '/') + 1), "part", 4) == 0)
+       {
+           sprintf (buffer, "hd%c%s",
+                    get_old_ide_name (major, minor), ptr + 4);
+           compat_name = buffer;
+       }
+       else if (strcmp (devname + namelen - 2, "cd") == 0)
+       {
+           sprintf ( buffer, "hd%c",
+                     get_old_ide_name (major, minor) );
+           compat_name = buffer;
+       }
+       return (compat_name);
     }
     else if (strncmp (devname, "vcc/", 4) == 0)
     {
@@ -305,7 +303,7 @@
        if (disc_index < 26)
            sprintf (buffer, "sd%c%s", 'a' + disc_index, part);
        else sprintf (buffer, "sd%c%c%s",
-                     'a' + (disc_index / 26) - 1, 'a' + disc_index, part);
+                     'a' + (disc_index / 26) - 1, 'a' + disc_index % 26,part);
        return (buffer);
     }
     return (NULL);
diff -urN /tmp/devfsd-v1.3.21/devfsd.c devfsd/devfsd.c
--- /tmp/devfsd-v1.3.21/devfsd.c        Mon Jan 14 21:07:15 2002
+++ devfsd/devfsd.c     Sun Jan 20 14:07:31 2002
@@ -236,10 +236,13 @@
     Updated by      Richard Gooch   1-JAN-2002: Changed to extended regular
   expressions.
 
-    Last updated by Richard Gooch   14-JAN-2002: Fixed dummy opens of
+    Updated by      Richard Gooch   14-JAN-2002: Fixed dummy opens of
   /dev/null so that fds [0:2] are open (was only doing fds [0:1]) and prevent
   infinite loop if /dev/null cannot be opened.
 
+    Last updated by Richard Gooch   20-JAN-2002: Fixed <action_compat> to
+  ignore new compatibility names for IDE devices.
+
 
 */
 #define _GNU_SOURCE
@@ -1475,7 +1478,7 @@
                          host, bus, target, lun, atoi (ptr + 4) );
            else compat_name = NULL;
        }
-       else if (strncmp (info->devname, "ide/", 4) == 0)
+       else if (strncmp (info->devname, "ide/host", 8) == 0)
        {
            int host, bus, target, lun;
 
diff -urN /tmp/devfsd-v1.3.21/version.h devfsd/version.h
--- /tmp/devfsd-v1.3.21/version.h       Thu Nov 29 23:49:05 2001
+++ devfsd/version.h    Mon Jan 14 21:14:24 2002
@@ -1 +1 @@
-#define DEVFSD_VERSION "1.3.21"
+#define DEVFSD_VERSION "1.3.22"

<Prev in Thread] Current Thread [Next in Thread>