From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darren Salt Date: Thu, 19 May 2005 21:24:38 +0000 Subject: Re: new release of udev? Message-Id: <4D6DAF02EA%linux@youmustbejoking.demon.co.uk> MIME-Version: 1 Content-Type: multipart/mixed; boundary="1986479973--548905899--1314312519" List-Id: References: <20050519065848.GA25640@kroah.com> In-Reply-To: <20050519065848.GA25640@kroah.com> To: linux-hotplug@vger.kernel.org This message is in MIME format which your mailer apparently does not support. You either require a newer version of your software which supports MIME, or a separate MIME decoding utility. Alternatively, ask the sender of this message to resend it in a different format. --1986479973--548905899--1314312519 Content-Type: text/plain; charset=us-ascii I demand that Greg KH may or may not have written... > On Thu, May 19, 2005 at 06:49:45PM +0100, Darren Salt wrote: >> I demand that Greg KH may or may not have written... >>> Anyone have anything they want to see fixed before I release a 058 >>> version? >> Application of the cdsymlinks patch which I posted here a while ago, if >> you've not already done so. (The patch is present in the Debian package of >> version 056.) (Or at least the shell script part of it is there...) > Care to resend it? There have been a lot of different patches for that > file floating around :) Attached. -- | Darren Salt | d youmustbejoking,demon,co,uk | nr. Ashington, | Debian, | s zap,tartarus,org | Northumberland | RISC OS | @ | Toon Army | (PGP 2.6, GPG keys) Forget the people. There are valuable computers at stake. --1986479973--548905899--1314312519 Content-Type: text/plain; charset=iso-8859-1; name="udev-057_cdsymlinks.diff" Content-Disposition: attachment; filename="udev-057_cdsymlinks.diff" Content-Transfer-Encoding: quoted-printable diff -ur udev-057.orig/extras/cdsymlinks.c udev-057/extras/cdsymlinks.c --- udev-057.orig/extras/cdsymlinks.c 2005-04-14 22:39:34.000000000 +0100= +++ udev-057/extras/cdsymlinks.c 2005-02-15 02:23:03.000000000 +0000 @@ -11,7 +11,12 @@ * BUS=3D"scsi", KERNEL=3D"scd[0-9]*", PROGRAM=3D"/etc/udev/cdsymlinks.s= h %k", SYMLINK=3D"%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}" * (this last one is "just in case") * - * (c) 2004 Darren Salt + * (c) 2004, 2005 Darren Salt + * + * Contributors: + * - J A Magallon (bug fixes) + * + * Last modified: 2005-02-15 */ =20 #define _GNU_SOURCE @@ -56,6 +61,7 @@ /* Configuration variables */ static struct list_t allowed_output =3D {0}; static int numbered_links =3D 1; +static int link_zero =3D 0; =20 /* Available devices */ static struct list_t Devices =3D {0}; @@ -65,14 +71,40 @@ */ static struct list_t cap_DVDRAM =3D {0}, cap_DVDRW =3D {0}, cap_DVD =3D = {0}, cap_CDRW =3D {0}, cap_CDR =3D {0}, cap_CDWMRW =3D {0}, - cap_CDMRW =3D {0}; + cap_CDMRW =3D {0}, cap_CDRAM =3D {0}; =20 /* Device capabilities by name */ static struct list_t dev_DVDRAM =3D {0}, dev_DVDRW =3D {0}, dev_DVD =3D = {0}, dev_CDRW =3D {0}, dev_CDR =3D {0}, dev_CDWMRW =3D {0}, - dev_CDMRW =3D {0}; + dev_CDMRW =3D {0}, dev_CDRAM =3D {0}; #define dev_CD Devices =20 +typedef struct { + struct list_t *cap, *dev; + const char label[8], symlink[8]; + const char *captext; + int captextlen; +} cap_dev_t; + +#define CAPDEV(X) &cap_##X, &dev_##X + +static const cap_dev_t cap_dev_info[] =3D { + { NULL, &dev_CD, "CD", "cdrom", NULL, 0 }, + { CAPDEV(CDR), "CDR", "cd-r", "Can write CD-R:", 15 }, + { CAPDEV(CDRW), "CDRW", "cdrw", "Can write CD-RW:", 16 }, + { CAPDEV(DVD), "DVD", "dvd", "Can read DVD:", 13 }, + { CAPDEV(DVDRW), "DVDRW", "dvdrw", "Can write DVD-R:", 16 }, + { CAPDEV(DVDRAM), "DVDRAM", "dvdram", "Can write DVD-RAM:", 18 }, + { CAPDEV(CDMRW), "CDMRW", "cdm", "Can read MRW:", 13 }, /* CDC-M= RW R */ + { CAPDEV(CDWMRW), "CDWMRW", "cdmrw", "Can write MRW:", 14 }, /* CDC-M= RW W */ + { CAPDEV(CDRAM), "CDRAM", "cdram", "Can write RAM:", 14 }, /* CDC-R= AM W */ + { NULL } +}; + +#define foreach_cap_dev(loop) \ + for ((loop) =3D cap_dev_info; (loop)->label[0]; ++(loop)) +#define foreach_cap_dev_noCD(loop) \ + for ((loop) =3D cap_dev_info + 1; (loop)->label[0]; ++(loop)) =20 /* * Some library-like bits first... @@ -218,7 +250,7 @@ list_assign_split (struct list_t *list, char *text) { char *token =3D strchr (text, ':'); - token =3D strtok (token ? token + 1 : text, " \t"); + token =3D strtok (token ? token + 1 : text, " \t\n"); while (token) { list_prepend (list, token); @@ -267,8 +299,10 @@ list_delete (&allowed_output); list_assign_split (&allowed_output, p.we_wordv[0] + 7); } - else if (!strncmp (p.we_wordv[0], "NUMBERED_LINKS=3D", 14)) - numbered_links =3D atoi (p.we_wordv[0] + 14); + else if (!strncmp (p.we_wordv[0], "NUMBERED_LINKS=3D", 15)) + numbered_links =3D atoi (p.we_wordv[0] + 15); + else if (!strncmp (p.we_wordv[0], "LINK_ZERO=3D", 15)) + link_zero =3D atoi (p.we_wordv[0] + 15); break; } /* fall through */ @@ -315,20 +349,16 @@ { if (!strncasecmp (text, "drive name", 10)) list_assign_split (&Devices, text); - else if (!strncasecmp (text, "Can write DVD-RAM", 17)) - list_assign_split (&cap_DVDRAM, text); - else if (!strncasecmp (text, "Can write DVD-R", 15)) - list_assign_split (&cap_DVDRW, text); - else if (!strncasecmp (text, "Can read DVD", 12)) - list_assign_split (&cap_DVD, text); - else if (!strncasecmp (text, "Can write CD-RW", 15)) - 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)) - list_assign_split (&cap_CDMRW, text); - else if (!strncasecmp (text, "Can write MRW", 14)) - list_assign_split (&cap_CDWMRW, text); + else + { + const cap_dev_t *cap; + foreach_cap_dev_noCD (cap) + if (!strncasecmp (text, cap->captext, cap->captextlen)) + { + list_assign_split (cap->cap, text); + break; + } + } } if (!feof (info)) errexit ("error accessing CD/DVD info"); @@ -341,7 +371,8 @@ * taking into account existing links and the capability list for type L= INK. */ static void -do_output (const char *name, const char *link, const struct list_t *dev)= +do_output (const char *name, const char *link, const struct list_t *dev,= + int do_link_zero) { const struct list_item_t *i =3D (const struct list_item_t *)dev; if (!i->next) @@ -406,6 +437,8 @@ /* Existing symlink found - don't output a new one. * If ISDEV, we output the name of the existing symlink. */ + if (do_link_zero) + return; present =3D 1; if (isdev) printf (" %s", list_nth (&devls, li)->data); @@ -415,14 +448,19 @@ if (!present) { char buf[256]; - snprintf (buf, sizeof (buf), count ? "%s%d" : "%s", link, count); + snprintf (buf, sizeof (buf), count || do_link_zero ? "%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)) + { + if (do_link_zero) + return; snprintf (buf, sizeof (buf), "%s%d", link, ++count); + } /* If ISDEV, output it. */ if (isdev && (numbered_links || count =3D=3D 0)) printf (" %s", buf); @@ -431,6 +469,8 @@ */ if (!list_search (&devls, buf)) { + if (do_link_zero) + return; list_append (&devls, buf); ++count; } @@ -458,6 +498,8 @@ int main (int argc, char *argv[]) { + const cap_dev_t *capdev; + progname =3D argv[0]; debug =3D argc > 2 && !strcmp (argv[2], "-d"); =20 @@ -470,62 +512,43 @@ read_defaults (); populate_capability_lists (); =20 - /* Construct the device lists from the capability lists. */ - populate_device_list (&dev_DVDRAM, &cap_DVDRAM); - populate_device_list (&dev_DVDRW, &cap_DVDRW); - populate_device_list (&dev_DVD, &cap_DVD); - populate_device_list (&dev_CDRW, &cap_CDRW); - populate_device_list (&dev_CDR, &cap_CDR); - populate_device_list (&dev_CDWMRW, &cap_CDWMRW); - populate_device_list (&dev_CDMRW, &cap_CDMRW); - /* (All devices can read CDs.) */ + /* Construct the device lists from the capability lists. + * (We assume that all relevant devices can read CDs.) + */ + foreach_cap_dev_noCD (capdev) + populate_device_list (capdev->dev, capdev->cap); =20 if (debug) { -#define printdev(DEV) \ - printf ("%-7s:", #DEV); \ - list_print (&cap_##DEV, stdout); \ - list_print (&dev_##DEV, stdout); \ - puts (""); - printf ("Devices:"); const struct list_item_t *item =3D (const struct list_item_t *)&Devi= ces; while ((item =3D item->next) !=3D NULL) printf (" %s", item->data); - puts (""); =20 - printdev (DVDRAM); - printdev (DVDRW); - printdev (DVD); - printdev (CDRW); - printdev (CDR); - printdev (CDWMRW); - printdev (CDMRW); - - printf ("CDROM : (all)"); + printf ("\nCDROM : (all)"); item =3D (const struct list_item_t *)&dev_CD; while ((item =3D item->next) !=3D NULL) printf (" %s", item->data); puts (""); + + foreach_cap_dev_noCD (capdev) + { + printf ("%-10s:", capdev->label); + list_print (capdev->cap, stdout); + list_print (capdev->dev, stdout); + puts (""); + } + } =20 /* Write the symlink names. */ - if (list_search (&allowed_output, "CD")) - do_output (argv[1], "cdrom", &dev_CD); - if (list_search (&allowed_output, "CDR")) - do_output (argv[1], "cd-r", &dev_CDR); - if (list_search (&allowed_output, "CDRW")) - do_output (argv[1], "cdrw", &dev_CDRW); - if (list_search (&allowed_output, "DVD")) - do_output (argv[1], "dvd", &dev_DVD); - if (list_search (&allowed_output, "DVDRW")) - do_output (argv[1], "dvdrw", &dev_DVDRW); - if (list_search (&allowed_output, "DVDRAM")) - do_output (argv[1], "dvdram", &dev_DVDRAM); - if (list_search (&allowed_output, "CDMRW")) - do_output (argv[1], "cdmrw", &dev_CDMRW); - if (list_search (&allowed_output, "CDWMRW")) - do_output (argv[1], "cdwmrw", &dev_CDWMRW); + foreach_cap_dev (capdev) + if (list_search (&allowed_output, capdev->label)) + { + do_output (argv[1], capdev->symlink, capdev->dev, 0); + if (link_zero) + do_output (argv[1], capdev->symlink, capdev->dev, 1); + } puts (""); =20 return 0; diff -ur udev-057.orig/extras/cdsymlinks.conf udev-057/extras/cdsymlinks.= conf --- udev-057.orig/extras/cdsymlinks.conf 2005-04-14 22:39:39.000000000 +0= 100 +++ udev-057/extras/cdsymlinks.conf 2005-02-15 02:30:11.000000000 +0000 @@ -1,8 +1,13 @@ # Configuration file for cdsymlinks =20 # Output links for these types of devices. -# Allowed keywords are CD, CDR, CDRW, DVD, DVDRW, DVDRAM, CDMRW, CDWMRW.= +# Allowed keywords are: corresponding to device names: +# CD CDR CDRW cdrom cd-r cdrw +# DVD DVDRW DVDRAM dvd dvdrw dvdram +# CDMRW CDWMRW cdm cdmrw +# CDRAM cdram # Other words are accepted but ignored. +# Devices with multiple recognised capabilities WILL get multiple links.= #OUTPUT=3D"CD CDRW DVD DVDRW DVDRAM" =20 # Whether to output numbered links. @@ -10,3 +15,7 @@ # 0 =3D don't output 'cdrom1', 'dvd1' etc. # We always output 'cdrom', 'dvd' etc. for the best-match devices. #NUMBERED_LINKS=3D1 + +# Whether to output link 0 along with each unnumbered link. +# (No effect if NUMBERED_LINKS=3D0.) +#LINK_ZERO=3D0 diff -ur udev-057.orig/extras/cdsymlinks.sh udev-057/extras/cdsymlinks.sh= --- udev-057.orig/extras/cdsymlinks.sh 2005-04-14 22:39:34.000000000 +010= 0 +++ udev-057/extras/cdsymlinks.sh 2005-02-15 02:22:52.000000000 +0000 @@ -1,6 +1,7 @@ #! /bin/sh -e # -# Map cdrom, cdm, cdmrw, cd-r, cdrw, dvd, dvdrw, dvdram to suitable devi= ces. +# Map cdrom, cd-r, cdrw, dvd, dvdrw, dvdram, cdm, cdmrw, cdram +# to suitable devices. # Prefers cd* for DVD-incapable and cdrom and dvd for read-only devices.= # First parameter is the kernel device name. # Second parameter, if present, must be "-d" =3D> output the full mappin= g. @@ -11,13 +12,16 @@ # BUS=3D"scsi", KERNEL=3D"scd[0-9]*", PROGRAM=3D"/etc/udev/cdsymlinks.sh= %k", SYMLINK=3D"%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}" # (this last one is "just in case") # -# (c) 2004 Darren Salt +# (c) 2004, 2005 Darren Salt +# +# Last modified: 2005-02-15 =20 test -e /proc/sys/dev/cdrom/info || exit 0 =20 # Defaults; it's better that you alter them in /etc/udev/cdsymlinks.conf= OUTPUT=3D'CD CDRW DVD DVDRW DVDRAM' NUMBERED_LINKS=3D1 +LINK_ZERO=3D0 =20 test -e /etc/udev/cdsymlinks.conf && . /etc/udev/cdsymlinks.conf =20 @@ -61,6 +65,7 @@ setArray CDRs `sed -re '/^Can write CD-R:/I! d; s/.*://' /proc/sys= /dev/cdrom/info` setArray CDMRWs `sed -re '/^Can write MRW:/I! d; s/.*://' /proc/sys= /dev/cdrom/info` setArray CDMs `sed -re '/^Can read MRW:/I! d; s/.*://' /proc/sys= /dev/cdrom/info` +setArray CDRAMs `sed -re '/^Can write RAM:/I! d; s/.*://' /proc/sys= /dev/cdrom/info` =20 # How many devices do we have? NumDevs=3D$(($DEVICES-1)) @@ -80,6 +85,7 @@ test "`ix CDRs $i`" !=3D '' || ixs CDRs $i 0 test "`ix CDMRWs $i`" !=3D '' || ixs CDMRWs $i 0 test "`ix CDMs $i`" !=3D '' || ixs CDMs $i 0 + test "`ix CDRAMs $i`" !=3D '' || ixs CDRAMs $i 0 done =20 DVDRAM=3D'' @@ -89,6 +95,7 @@ CDR=3D'' CDMRW=3D'' CDM=3D'' +CDRAM=3D'' CD=3D'' =20 # Calculate symlink->device mappings. @@ -117,27 +124,31 @@ test "`ix CDMs $i`" =3D 1 && CDM=3D"$CDM `ix DEVICES $i`" done for i in $Count; do + test "`ix CDRAMs $i`" =3D 1 && CDRAM=3D"$CDRAM `ix DEVICES $i`" +done +for i in $Count; do CD=3D"$CD `ix DEVICES $i`" done =20 # Debug output if test "$DEBUG" =3D 1; then echo 'Devices:' `for i in $Count; do ix DEVICES $i; echo -n \ ; done` - echo 'DVDRAM :' `for i in $Count; do ix DVDRAMs $i; echo -n \ ; done` = $DVDRAM - echo 'DVDRW :' `for i in $Count; do ix DVDRWs $i; echo -n \ ; done` = $DVDRW - echo 'DVD :' `for i in $Count; do ix DVDs $i; echo -n \ ; done` = $DVD - echo 'CDRW :' `for i in $Count; do ix CDRWs $i; echo -n \ ; done` = $CDRW + echo 'CDROM : (all)' $CD echo 'CD-R :' `for i in $Count; do ix CDRs $i; echo -n \ ; done` = $CDR + echo 'CDRW :' `for i in $Count; do ix CDRWs $i; echo -n \ ; done` = $CDRW + echo 'DVD :' `for i in $Count; do ix DVDs $i; echo -n \ ; done` = $DVD + echo 'DVDRW :' `for i in $Count; do ix DVDRWs $i; echo -n \ ; done` = $DVDRW + echo 'DVDRAM :' `for i in $Count; do ix DVDRAMs $i; echo -n \ ; done` = $DVDRAM echo 'CDMRW :' `for i in $Count; do ix CDMRWs $i; echo -n \ ; done` = $CDMRW - echo 'CDM :' `for i in $Count; do ix CDMs $i; echo -n \ ; done` = $CDM - echo 'CDROM : (all)' $CD + echo 'CDWMRW :' `for i in $Count; do ix CDMs $i; echo -n \ ; done` = $CDM + echo 'CDRAM :' `for i in $Count; do ix CDRAMs $i; echo -n \ ; done` = $CDRAM fi =20 # Prepare symlink names output -output () { +do_output () { test "`eval echo '$'$3`" =3D '' && return local i - local COUNT=3D'' + local COUNT=3D$4 local DEVLS=3D"`ls -dl \"/dev/$2\" \"/dev/$2\"[0-9]* 2>/dev/null`" local PRESENT=3D"`echo "$DEVLS" | sed -re 's!^.* /dev/('$2'[[:digit:]]*) -> [^[:space:]]+$!\1!'`" @@ -148,6 +159,7 @@ if test "$DEVPRESENT" !=3D ""; then # Existing symlinks found - don't output a new one. # If the target dev ($1) is the current dev ($i), we output their = names. + test -z "$4" || return; test "$1" =3D "$i" && echo " $DEVPRESENT" | sed -e 'N; $ s/\n/ /' else # If we found no existing symlinks for the target device... @@ -156,15 +168,17 @@ # symlink is created by udev as a result of use of this program, w= e # DON'T want different output! until notin PRESENT "$2$COUNT"; do + test -z "$4" || return; COUNT=3D$(($COUNT+1)) done # If the target dev ($1) is the current dev ($i), we output its na= me. - if test $(($NUMBERED_LINKS)) -ne 0 || test "$COUNT" =3D ''; then - test "$i" =3D "$1" && echo -n " $2$COUNT" + if test $(($NUMBERED_LINKS)) -ne 0 || test -z "$COUNT"; then + test "$i" !=3D "$1" || echo -n " $2$COUNT" fi # If the link isn't in our "existing links" list, add it and incre= ment # our counter. - if test ! -e "/dev/$2$COUNT"; then + if notin PRESENT "$2$COUNT"; then + test -z "$4" || return; PRESENT=3D"$PRESENT\n$2$COUNT" COUNT=3D$(($COUNT+1)) fi @@ -172,13 +186,19 @@ done } =20 +output () { + do_output "$@" + test $(($LINK_ZERO)) -eq 0 || do_output "$@" 0 +} + # And output it notin OUTPUT CD || echo -n "`output "$1" cdrom CD`" -notin OUTPUT CDMRW || echo -n "`output "$1" cdmrw CDM`" -notin OUTPUT CDWMRW || echo -n "`output "$1" cdwmrw CDMRW`" notin OUTPUT CDR || echo -n "`output "$1" cd-r CDR`" notin OUTPUT CDRW || echo -n "`output "$1" cdrw CDRW`" notin OUTPUT DVD || echo -n "`output "$1" dvd DVD`" notin OUTPUT DVDRW || echo -n "`output "$1" dvdrw DVDRW`" notin OUTPUT DVDRAM || echo -n "`output "$1" dvdram DVDRAM`" +notin OUTPUT CDMRW || echo -n "`output "$1" cdmrw CDM`" +notin OUTPUT CDWMRW || echo -n "`output "$1" cdwmrw CDMRW`" +notin OUTPUT CDRAM || echo -n "`output "$1" cdram CDRAM`" echo --1986479973--548905899--1314312519-- ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel