mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* udev and cdsymlinks
@ 2005-02-14 23:57 J.A. Magallon
  0 siblings, 0 replies; only message in thread
From: J.A. Magallon @ 2005-02-14 23:57 UTC (permalink / raw)
  To: Lista Linux-Kernel; +Cc: Greg KH

[-- Attachment #1: Type: text/plain, Size: 4254 bytes --]

Hi all...

There are some problems with current udev. I wil try to propose an acceptable
solution (ie, patch ;) ).

My problems are with cdsymlinks (the C version, mandrake cooker uses that;
all I say is applicable also to the bash version).

Problems with udev-053:cdymlinks.c:

- Does not obey the NUMBERED_LINKS flag. Just a problem with string lengths.
  Fixed below.
- The nunbered links sould always be present (ie, kill NUMBERED_LINKS).
  Why ?
    - In a box with several optical units, you obviously need numbered links.
      You also need a 'default' unit for each class (cdrom, dvd, cdrw...)
    - In a box with only one unit, you also need the numbered links for
      compatibility (a program can try to open cdrom{i}, i in 0.., ) until
      it fails...)
- In a box with just one DVDRW it fails, typo in the strtok.

Is this patch acceptable ?

TIA

--- cdsymlinks.c.orig	2005-02-14 23:18:16.000000000 +0100
+++ cdsymlinks.c	2005-02-15 00:30:16.000000000 +0100
@@ -55,7 +55,6 @@
 
 /* Configuration variables */
 static struct list_t allowed_output = {0};
-static int numbered_links = 1;
 
 /* Available devices */
 static struct list_t Devices = {0};
@@ -218,7 +217,7 @@
 list_assign_split (struct list_t *list, char *text)
 {
   char *token = strchr (text, ':');
-  token = strtok (token ? token + 1 : text, " \t");
+  token = strtok (token ? token + 1 : text, " \t\n");
   while (token)
   {
     list_prepend (list, token);
@@ -267,8 +266,6 @@
             list_delete (&allowed_output);
             list_assign_split (&allowed_output, p.we_wordv[0] + 7);
           }
-          else if (!strncmp (p.we_wordv[0], "NUMBERED_LINKS=", 14))
-            numbered_links = atoi (p.we_wordv[0] + 14);
           break;
 	}
 	/* fall through */
@@ -325,9 +322,9 @@
       list_assign_split (&cap_CDRW, text);
     else if (!strncasecmp (text, "Can write CD-R", 14))
       list_assign_split (&cap_CDR, text);
-    else if (!strncasecmp (text, "Can read MRW", 14))
+    else if (!strncasecmp (text, "Can read MRW", 12))
       list_assign_split (&cap_CDMRW, text);
-    else if (!strncasecmp (text, "Can write MRW", 14))
+    else if (!strncasecmp (text, "Can write MRW", 13))
       list_assign_split (&cap_CDWMRW, text);
   }
   if (!feof (info))
@@ -408,24 +405,30 @@
        */
       present = 1;
       if (isdev)
-        printf (" %s", list_nth (&devls, li)->data);
+        printf ("%s ", list_nth (&devls, li)->data);
     }
 
     /* If we found no existing symlinks for the target device... */
     if (!present)
     {
       char buf[256];
-      snprintf (buf, sizeof (buf), count ? "%s%d" : "%s", link, count);
-      /* Find the next available (not present) symlink name.
-       * We always need to do this for reasons of output consistency: if a
-       * symlink is created by udev as a result of use of this program, we
-       * DON'T want different output!
-       */
-      while (list_search (&devls, buf))
-        snprintf (buf, sizeof (buf), "%s%d", link, ++count);
-      /* If ISDEV, output it. */
-      if (isdev && (numbered_links || count == 0))
-        printf (" %s", buf);
+      if (!count) 
+	  {
+        snprintf (buf, sizeof (buf), "%s", link);
+        if (isdev && !list_search (&devls, buf))
+          printf ("%s ", buf);
+	  }
+	  /* Find the next available (not present) symlink name.
+	   * We always need to do this for reasons of output consistency: if a
+	   * symlink is created by udev as a result of use of this program, we
+	   * DON'T want different output!
+	   */
+	  snprintf (buf, sizeof (buf), "%s%d", link, count);
+	  while (list_search (&devls, buf))
+		snprintf (buf, sizeof (buf), "%s%d", link, ++count);
+	  /* If ISDEV, output it. */
+	  if (isdev)
+		printf ("%s ", buf);
       /* If the link isn't in our "existing links" list, add it and increment
        * our counter.
        */

--
J.A. Magallon <jamagallon()able!es>     \               Software is like sex:
werewolf!able!es                         \         It's better when it's free
Mandrakelinux release 10.2 (Cooker) for i586
Linux 2.6.10-jam9 (gcc 3.4.3 (Mandrakelinux 10.2 3.4.3-3mdk)) #1


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-02-14 23:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-14 23:57 udev and cdsymlinks J.A. Magallon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®