chiark / gitweb /
remove "all_partitions" option
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 13 Apr 2010 06:52:48 +0000 (08:52 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 13 Apr 2010 06:52:48 +0000 (08:52 +0200)
We can not predict the major/minor of non-existing devices:
  $ grep . /sys/class/block/sd*/dev
  /sys/class/block/sda1/dev:259:524288
  /sys/class/block/sda2/dev:259:262144
  /sys/class/block/sda3/dev:259:786432
  /sys/class/block/sda4/dev:259:131072
  /sys/class/block/sda/dev:259:0
  /sys/class/block/sdb/dev:259:655360
  /sys/class/block/sdc/dev:259:393216

If this functionality is still needed for some broken hardware, it needs to be
solved with a tool not part of the udev package. Because such option is unreliable
and unsafe to use.

NEWS
libudev/libudev-device-private.c
libudev/libudev-device.c
libudev/libudev-private.h
test/udev-test.pl
udev/udev-node.c
udev/udev-rules.c
udev/udev.xml
udev/udevadm-info.c

diff --git a/NEWS b/NEWS
index c5fbbe165d47055176f4c5eb239ac10740deb6f0..c422eaa8e349b6ff8ad7279c89f869bdedaf7956 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,9 +2,14 @@ udev 152
 ========
 Bugfixes.
 
-"udevadm trigger" default to "change" events now, instead of "add"
+"udevadm trigger" defaults to "change" events now, instead of "add"
 events.
 
+The option "all_partitons" was removed from udev. This should not be
+needed for usual hardware. Udev can not safely make assumptions
+about non-exixting partition major/minor numbers, and therefore no
+longer provide such an unreliable and unsafe option.
+
 All "add|change" matches are replaced by "!remove" in the rules and
 in the udev logic. All types of events will update possible symlinks
 and permissions, only "remove" is handled special now.
index 1bcf441237868c34296d3e7b4cf778436a62a650..19c20b2cc8a9c6b22e7d55180ccc709a848bfab8 100644 (file)
@@ -41,8 +41,6 @@ int udev_device_update_db(struct udev_device *udev_device)
        udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device))
                if (udev_list_entry_get_flags(list_entry))
                        goto file;
-       if (udev_device_get_num_fake_partitions(udev_device) != 0)
-               goto file;
        if (udev_device_get_ignore_remove(udev_device))
                goto file;
        if (udev_device_get_devlink_priority(udev_device) != 0)
@@ -95,8 +93,6 @@ file:
                fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device));
        if (udev_device_get_event_timeout(udev_device) >= 0)
                fprintf(f, "T:%i\n", udev_device_get_event_timeout(udev_device));
-       if (udev_device_get_num_fake_partitions(udev_device) != 0)
-               fprintf(f, "A:%i\n", udev_device_get_num_fake_partitions(udev_device));
        if (udev_device_get_ignore_remove(udev_device))
                fprintf(f, "R:%i\n", udev_device_get_ignore_remove(udev_device));
        if (udev_device_get_watch_handle(udev_device) >= 0)
index 410f75b3008d7054bc7d053403902ffb548526e2..75cc61c5fc6a56be038c28896bd1e9069ebceaec 100644 (file)
@@ -63,7 +63,6 @@ struct udev_device {
        unsigned long long int seqnum;
        int event_timeout;
        int timeout;
-       int num_fake_partitions;
        int devlink_priority;
        int refcount;
        dev_t devnum;
@@ -284,9 +283,6 @@ int udev_device_read_db(struct udev_device *udev_device)
                case 'T':
                        udev_device_set_event_timeout(udev_device, atoi(val));
                        break;
-               case 'A':
-                       udev_device_set_num_fake_partitions(udev_device, atoi(val));
-                       break;
                case 'R':
                        udev_device_set_ignore_remove(udev_device, atoi(val));
                        break;
@@ -1425,19 +1421,6 @@ int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
        return 0;
 }
 
-int udev_device_get_num_fake_partitions(struct udev_device *udev_device)
-{
-       if (!udev_device->info_loaded)
-               device_load_info(udev_device);
-       return udev_device->num_fake_partitions;
-}
-
-int udev_device_set_num_fake_partitions(struct udev_device *udev_device, int num)
-{
-       udev_device->num_fake_partitions = num;
-       return 0;
-}
-
 int udev_device_get_devlink_priority(struct udev_device *udev_device)
 {
        if (!udev_device->info_loaded)
index 3f2861f519f63d1c1522cfd60586f3b29e031fd8..bf9e923b6d598fd16d6042635619f0362f477617 100644 (file)
@@ -93,8 +93,6 @@ int udev_device_get_event_timeout(struct udev_device *udev_device);
 int udev_device_set_event_timeout(struct udev_device *udev_device, int event_timeout);
 int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum);
 int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum);
-int udev_device_get_num_fake_partitions(struct udev_device *udev_device);
-int udev_device_set_num_fake_partitions(struct udev_device *udev_device, int num);
 int udev_device_get_devlink_priority(struct udev_device *udev_device);
 int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
 int udev_device_get_ignore_remove(struct udev_device *udev_device);
index aeca9486f7c9c2041c3d72b89d060cad1ee14138..4633d6be25a96a28997b7bcd5f4658f5c1e005e4 100755 (executable)
@@ -490,16 +490,6 @@ EOF
 SUBSYSTEMS=="usb", PROGRAM=="/bin/echo -n usb-%b", SYMLINK+="%c"
 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n scsi-%b", SYMLINK+="%c"
 SUBSYSTEMS=="foo", PROGRAM=="/bin/echo -n foo-%b", SYMLINK+="%c"
-EOF
-       },
-       {
-               desc            => "create all possible partitions",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
-               exp_name        => "sda15" ,
-               exp_majorminor  => "8:15",
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", OPTIONS="all_partitions"
 EOF
        },
        {
@@ -985,28 +975,6 @@ EOF
                exp_name        => "link4",
                rules           => <<EOF
 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", SYMLINK+="%c{2+}"
-EOF
-       },
-       {
-               desc            => "all_partitions, option-only rule",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
-               exp_name        => "node6",
-               exp_rem_error   => "yes",
-               rules           => <<EOF
-SUBSYSTEM=="block", OPTIONS="all_partitions"
-SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node"
-EOF
-       },
-       {
-               desc            => "all_partitions, option-only rule (fail on partition)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
-               exp_name        => "node6",
-               exp_add_error   => "yes",
-               rules           => <<EOF
-SUBSYSTEM=="block", OPTIONS="all_partitions"
-SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node"
 EOF
        },
        {
@@ -1017,17 +985,6 @@ EOF
                exp_rem_error   => "yes",
                rules           => <<EOF
 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OPTIONS="ignore_remove"
-EOF
-       },
-       {
-               desc            => "ignore remove event test (with all partitions)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
-               exp_name        => "sda14",
-               exp_rem_error   => "yes",
-               option          => "clean",
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", OPTIONS="ignore_remove, all_partitions"
 EOF
        },
        {
index 3b4eb5f00bfb5ab18c53ca84ee059f3bd54be8f0..4492c2e393d3ec904c12f9c70f86b0c9855a5038 100644 (file)
@@ -365,8 +365,6 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev
 int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
 {
        struct udev *udev = udev_device_get_udev(dev);
-       int i;
-       int num;
        struct udev_list_entry *list_entry;
        int err = 0;
 
@@ -380,23 +378,6 @@ int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
                goto exit;
        }
 
-       /* create all_partitions if requested */
-       num = udev_device_get_num_fake_partitions(dev);
-       if (num > 0) {
-               info(udev, "creating device partition nodes '%s[1-%i]'\n", udev_device_get_devnode(dev), num);
-               for (i = 1; i <= num; i++) {
-                       char partitionname[UTIL_PATH_SIZE];
-                       dev_t part_devnum;
-
-                       snprintf(partitionname, sizeof(partitionname), "%s%d",
-                                udev_device_get_devnode(dev), i);
-                       partitionname[sizeof(partitionname)-1] = '\0';
-                       part_devnum = makedev(major(udev_device_get_devnum(dev)),
-                                           minor(udev_device_get_devnum(dev)) + i);
-                       udev_node_mknod(dev, partitionname, part_devnum, mode, uid, gid);
-               }
-       }
-
        /* create/update symlinks, add symlinks to name index */
        udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev)) {
                if (udev_list_entry_get_flags(list_entry))
@@ -414,10 +395,8 @@ int udev_node_remove(struct udev_device *dev)
        struct udev *udev = udev_device_get_udev(dev);
        struct udev_list_entry *list_entry;
        const char *devnode;
-       char partitionname[UTIL_PATH_SIZE];
        struct stat stats;
        int err = 0;
-       int num;
 
        /* remove/update symlinks, remove symlinks from name index */
        udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev))
@@ -451,20 +430,6 @@ int udev_node_remove(struct udev_device *dev)
                udev_device_unref(dev_check);
        }
 
-       num = udev_device_get_num_fake_partitions(dev);
-       if (num > 0) {
-               int i;
-
-               info(udev, "removing all_partitions '%s[1-%i]'\n", devnode, num);
-               if (num > 255)
-                       return -1;
-               for (i = 1; i <= num; i++) {
-                       snprintf(partitionname, sizeof(partitionname), "%s%d", devnode, i);
-                       partitionname[sizeof(partitionname)-1] = '\0';
-                       util_unlink_secure(udev, partitionname);
-               }
-       }
-
        util_delete_path(udev, devnode);
        return err;
 }
index 0361f689d59efc6d97372cf800b97673c7812c23..a4a86b664a6c770c9c33bf3c3cb4ad7b4533c9b4 100644 (file)
@@ -196,7 +196,6 @@ struct token {
                                mode_t  mode;
                                uid_t uid;
                                gid_t gid;
-                               int num_fake_part;
                                int devlink_prio;
                                int event_timeout;
                                int watch;
@@ -371,9 +370,6 @@ static void dump_token(struct udev_rules *rules, struct token *token)
        case TK_A_INOTIFY_WATCH:
                dbg(rules->udev, "%s %u\n", token_str(type), token->key.watch);
                break;
-       case TK_A_NUM_FAKE_PART:
-               dbg(rules->udev, "%s %u\n", token_str(type), token->key.num_fake_part);
-               break;
        case TK_A_DEVLINK_PRIO:
                dbg(rules->udev, "%s %s %u\n", token_str(type), operation_str(op), token->key.devlink_prio);
                break;
@@ -1469,12 +1465,6 @@ static int add_rule(struct udev_rules *rules, char *line,
                                rule_add_key(&rule_tmp, TK_A_NAME, op, value, NULL);
                                attr = get_key_attribute(rules->udev, key + sizeof("NAME")-1);
                                if (attr != NULL) {
-                                       if (strstr(attr, "all_partitions") != NULL) {
-                                               int num = DEFAULT_FAKE_PARTITIONS_COUNT;
-
-                                               dbg(rules->udev, "creation of partition nodes requested\n");
-                                               rule_add_key(&rule_tmp, TK_A_NUM_FAKE_PART, 0, NULL, &num);
-                                       }
                                        if (strstr(attr, "ignore_remove") != NULL) {
                                                dbg(rules->udev, "remove event should be ignored\n");
                                                rule_add_key(&rule_tmp, TK_A_IGNORE_REMOVE, 0, NULL, NULL);
@@ -1576,12 +1566,6 @@ static int add_rule(struct udev_rules *rules, char *line,
                                else if (strncmp(pos, "replace", strlen("replace")) == 0)
                                        rule_add_key(&rule_tmp, TK_A_STRING_ESCAPE_REPLACE, 0, NULL, NULL);
                        }
-                       if (strstr(value, "all_partitions") != NULL) {
-                               int num = DEFAULT_FAKE_PARTITIONS_COUNT;
-
-                               rule_add_key(&rule_tmp, TK_A_NUM_FAKE_PART, 0, NULL, &num);
-                               dbg(rules->udev, "creation of partition nodes requested\n");
-                       }
                        pos = strstr(value, "nowatch");
                        if (pos != NULL) {
                                const int off = 0;
@@ -2331,13 +2315,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                case TK_A_STRING_ESCAPE_REPLACE:
                        esc = ESCAPE_REPLACE;
                        break;
-               case TK_A_NUM_FAKE_PART:
-                       if (strcmp(udev_device_get_subsystem(event->dev), "block") != 0)
-                               break;
-                       if (udev_device_get_sysnum(event->dev) != NULL)
-                               break;
-                       udev_device_set_num_fake_partitions(event->dev, cur->key.num_fake_part);
-                       break;
                case TK_A_INOTIFY_WATCH:
                        event->inotify_watch = cur->key.watch;
                        break;
index 175cdbec6b4de58b2e37616bb363845fa1939fd5..9275e0f79f7fa2fde677bf91cccea9b6cf64fb61 100644 (file)
                       priorities overwrite existing symlinks of other devices. The default is 0.</para>
                     </listitem>
                   </varlistentry>
-                  <varlistentry>
-                    <term><option>all_partitions</option></term>
-                    <listitem>
-                      <para>Create the device nodes for all available partitions of a block device.
-                      This may be useful for removable media devices where media changes are not
-                      detected.</para>
-                    </listitem>
-                  </varlistentry>
                   <varlistentry>
                     <term><option>event_timeout=</option></term>
                     <listitem>
index 47114092d7ba1a7aaf80acaa4a9633c019557f00..c57620feef63269dad81c15a298976a298bf2907 100644 (file)
@@ -142,10 +142,6 @@ static void print_record(struct udev_device *device)
        if (i != 0)
                printf("L: %i\n", i);
 
-       i = udev_device_get_num_fake_partitions(device);
-       if (i != 0)
-               printf("A: %u\n", i);
-
        i = udev_device_get_ignore_remove(device);
        if (i != 0)
                printf("R: %u\n", i);