mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: Lista Linux-Kernel <linux-kernel@vger.kernel.org>
Cc: Greg KH <gregkh@suse.de>
Subject: udev and cdsymlinks
Date: Mon, 14 Feb 2005 23:57:07 +0000	[thread overview]
Message-ID: <1108425427l.23313l.1l@werewolf.able.es> (raw)

[-- 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 --]

                 reply	other threads:[~2005-02-14 23:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1108425427l.23313l.1l@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®