]> err.no Git - systemd/commitdiff
[PATCH] add IGNORE rule type
authorchristophe@saout.de <christophe@saout.de>
Sat, 10 Jan 2004 08:55:28 +0000 (00:55 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:14 +0000 (21:13 -0700)
On Wed, Dec 31, 2003 at 11:24:53AM -0800, Greg KH wrote:

> > There should be a possibility to tell udev not to create a device node.
> >
> > device-mapper: Usually set up by libdevmapper (or EVMS tools) which
> > creates the device node on its own under /dev/mapper/<name>.
> >
> > With udev a second device is created named /dev/dm-<minor> which is not
> > really needed.
>
> Good point.  Ok, I'll agree with you.  Care to make up a patch for this
> kind of feature?

Yes, I can try.

There was no way to tell not to do anything so I created one. Errors
are signalled via negative return values, so I thought that a positive,
non-zero one could mean to ignore the device. I don't like it but
perhaps you have a better solution.

etc/udev/udev.rules
etc/udev/udev.rules.devfs
namedev.c
namedev.h
namedev_parse.c
udev.8
udev.c

index b206503e1581c5aeea6c3c20b2890d9f6472e1c3..c2b50eb90d4f4af11b8e51e70996232f612b39cd 100644 (file)
@@ -49,4 +49,5 @@ REPLACE, KERNEL="ttyUSB0", NAME="pl2303"
 # if this is a ide cdrom, name it the default name, and create a symlink to cdrom
 CALLOUT, BUS="ide", PROGRAM="/bin/cat /proc/ide/%k/media", ID="cdrom", NAME="%k", SYMLINK="cdrom" 
 
-
+# device mapper creates its own device nodes
+IGNORE, KERNEL="dm-[0-9]*"
index 0d579a4dd46dffd56317c4e953324254add6e618..537d655a0e7f61e1a02d9d0f690d1438d672553a 100644 (file)
@@ -41,3 +41,6 @@ REPLACE, KERNEL="video[0-9]*", NAME="v4l/video%n"
 REPLACE, KERNEL="radio[0-9]*", NAME="v4l/radio%n"
 REPLACE, KERNEL="vbi[0-9]*",   NAME="v4l/vbi%n"
 REPLACE, KERNEL="vtx[0-9]*",   NAME="v4l/vtx%n"
+
+# dm devices
+IGNORE, KERNEL="dm-[0-9]*"
index e1b57ec3501246a2282c76ebe1339731a00651c6..226c1d313f65ef989ee5c72f58c9615759e329a5 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -298,6 +298,27 @@ exit:
        return; /* here to prevent compiler warning... */
 }
 
+static int do_ignore(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
+{
+       struct config_device *dev;
+       struct list_head *tmp;
+
+       list_for_each(tmp, &config_device_list) {
+               dev = list_entry(tmp, struct config_device, node);
+               if (dev->type != IGNORE)
+                       continue;
+
+               dbg("compare name '%s' with '%s'", dev->kernel_name, class_dev->name);
+               if (strcmp_pattern(dev->kernel_name, class_dev->name) != 0)
+                       continue;
+
+               dbg("found name, '%s' will be ignored", dev->kernel_name);
+
+               return 0;
+       }
+       return -ENODEV;
+}
+
 static int exec_callout(struct config_device *dev, char *value, int len)
 {
        int retval;
@@ -734,6 +755,12 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud
        dbg("kernel_number='%s'", udev->kernel_number);
 
        /* rules are looked at in priority order */
+       retval = do_ignore(class_dev, udev, sysfs_device);
+       if (retval == 0) {
+               dbg("name, '%s' is being ignored", class_dev->name);
+               return 1;
+       }
+
        retval = do_callout(class_dev, udev, sysfs_device);
        if (retval == 0)
                goto found;
index 1ac71069ad219784d8c227610a7e911e1329a826..f1e770277b1640c0b2bf2a72cfe4c1d72e6c26de 100644 (file)
--- a/namedev.h
+++ b/namedev.h
@@ -36,6 +36,7 @@ enum config_type {
        TOPOLOGY        = 3,
        REPLACE         = 4,
        CALLOUT         = 5,
+       IGNORE          = 6,
 };
 
 #define BUS_SIZE       30
@@ -50,6 +51,7 @@ enum config_type {
 #define TYPE_TOPOLOGY  "TOPOLOGY"
 #define TYPE_REPLACE   "REPLACE"
 #define TYPE_CALLOUT   "CALLOUT"
+#define TYPE_IGNORE    "IGNORE"
 
 #define FIELD_BUS      "BUS"
 #define FIELD_ID       "ID"
index 4b1377dc32a43b64f26b4cdee86afebdb055e7eb..5b5a5b3bc10a8b94b357a90ed15bc543c2943ac1 100644 (file)
@@ -110,6 +110,10 @@ void dump_config_dev(struct config_device *dev)
                dbg_parse("CALLOUT name='%s', bus='%s', program='%s', id='%s'",
                          dev->name, dev->bus, dev->exec_program, dev->id);
                break;
+       case IGNORE:
+               dbg_parse("IGNORE name='%s', kernel_name='%s'",
+                         dev->name, dev->kernel_name);
+               break;
        default:
                dbg_parse("unknown type of method");
        }
@@ -209,6 +213,11 @@ int namedev_init_rules(void)
                        goto keys;
                }
 
+               if (strcasecmp(temp2, TYPE_IGNORE) == 0) {
+                       dev.type = IGNORE;
+                       goto keys;
+               }
+
                dbg_parse("unknown type of method '%s'", temp2);
                goto error;
 keys:
@@ -323,6 +332,12 @@ keys:
                            (*dev.exec_program == '\0'))
                                goto error;
                        break;
+               case IGNORE:
+                       dbg_parse(TYPE_IGNORE "name='%s', kernel_name='%s'",
+                                 dev.name, dev.kernel_name);
+                       if ((*dev.kernel_name == '\0'))
+                               goto error;
+                       break;
                default:
                        dbg_parse("unknown type of method");
                        goto error;
diff --git a/udev.8 b/udev.8
index 5f497af92a8d31106f8d8507f58bb54660803d3b..3eb4aecad27b8adbbe3f92f1709d214cb867b10c 100644 (file)
--- a/udev.8
+++ b/udev.8
@@ -161,9 +161,15 @@ device position on bus, like physical port of USB device
 string replacement of the kernel device name
 .br
 .RB "key: " KERNEL
+.TP
+.B IGNORE
+tell udev to not care about creation of this device, e.g. because the
+device is already handled by another program
+.br
+.RB "key: " KERNEL
 .P
 The methods are applied in the following order:
-.BR CALLOUT ", " LABEL ", " NUMBER ", " TOPOLOGY ", " REPLACE "."
+.BR IGNORE ", " CALLOUT ", " LABEL ", " NUMBER ", " TOPOLOGY ", " REPLACE "."
 .P
 .RB "The " NAME " ," SYMLINK " and " PROGRAM
 fields support simple printf-like string substitution:
diff --git a/udev.c b/udev.c
index bbff89bad5165ca1ee50ed98f2c6950d95cf704c..116acf538976a070aadaff0ed30187e9dd506747 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -221,6 +221,9 @@ exit_sysbus:
        sysbus_disconnect();
 
 exit:
+       if (retval > 0)
+               retval = 0;
+
        return -retval;
 }