chiark / gitweb /
[PATCH] create /block/*/range count of partitons for all_partitions
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Wed, 9 Feb 2005 07:43:18 +0000 (08:43 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:27:41 +0000 (23:27 -0700)
namedev.h
namedev_parse.c
udev.h
udev_add.c
udev_remove.c

index 8a3569ec7cd92cd43d9e2712677c1ecdc69b3fa7..43381bfbd665dc49a27cc7b39cdfc8cffa3fa63f 100644 (file)
--- a/namedev.h
+++ b/namedev.h
@@ -53,7 +53,6 @@ struct sysfs_class_device;
 
 #define ATTR_PARTITIONS                "all_partitions"
 #define ATTR_IGNORE_REMOVE     "ignore_remove"
-#define PARTITIONS_COUNT       15
 
 #define MAX_SYSFS_PAIRS                5
 
@@ -91,6 +90,7 @@ extern struct list_head config_device_list;
 
 extern int namedev_init(void);
 extern int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_dev);
+extern void namedev_close(void);
 
 extern void dump_config_dev(struct config_device *dev);
 extern void dump_config_dev_list(void);
index 5bd59d83f230ea2113bacb48ccf25efbe86c2c06..7b5b963020275eb181c168217044e62593f2cbd5 100644 (file)
@@ -250,7 +250,7 @@ static int namedev_parse(const char *filename, void *data)
                                if (attr != NULL) {
                                        if (strstr(attr, ATTR_PARTITIONS) != NULL) {
                                                dbg_parse("creation of partition nodes requested");
-                                               dev.partitions = PARTITIONS_COUNT;
+                                               dev.partitions = DEFAULT_PARTITIONS_COUNT;
                                        }
                                        if (strstr(attr, ATTR_IGNORE_REMOVE) != NULL) {
                                                dbg_parse("remove event should be ignored");
@@ -338,3 +338,14 @@ int namedev_init(void)
 
        return retval;
 }
+
+void namedev_close(void)
+{
+       struct config_device *dev;
+
+       list_for_each_entry(dev, &config_device_list, node) {
+               list_del(&dev->node);
+               free(dev);
+       }
+}
+
diff --git a/udev.h b/udev.h
index 5beec645572b121ba6f3c2d1a84f343447f581f2..c2f9859c5a38141607f13e3cfc9cfb6c5669171f 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -46,6 +46,8 @@
 #define HOTPLUGD_DIR                   "/etc/hotplug.d"
 #define HOTPLUG_SUFFIX                 ".hotplug"
 
+#define DEFAULT_PARTITIONS_COUNT       15
+
 struct udevice {
        char devpath[DEVPATH_SIZE];
        char subsystem[SUBSYSTEM_SIZE];
index a495902ab2a4154c3b073ed03e21a9f595ff5bc3..c566571c1ca6a688ce8f9d7a0c276a0fdeea3925 100644 (file)
@@ -117,16 +117,16 @@ exit:
        return retval;
 }
 
-static int create_node(struct udevice *udev)
+static int create_node(struct udevice *udev, struct sysfs_class_device *class_dev)
 {
        char filename[NAME_SIZE];
        char partitionname[NAME_SIZE];
        uid_t uid = 0;
        gid_t gid = 0;
-       int i;
        int tail;
        char *pos;
        int len;
+               int i;
 
        snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
        filename[NAME_SIZE-1] = '\0';
@@ -154,6 +154,7 @@ static int create_node(struct udevice *udev)
        if (udev->owner[0] != '\0') {
                char *endptr;
                unsigned long id = strtoul(udev->owner, &endptr, 10);
+
                if (endptr[0] == '\0')
                        uid = (uid_t) id;
                else {
@@ -170,6 +171,7 @@ static int create_node(struct udevice *udev)
        if (udev->group[0] != '\0') {
                char *endptr;
                unsigned long id = strtoul(udev->group, &endptr, 10);
+
                if (endptr[0] == '\0')
                        gid = (gid_t) id;
                else {
@@ -193,6 +195,16 @@ static int create_node(struct udevice *udev)
 
        /* create all_partitions if requested */
        if (udev->partitions > 0) {
+               struct sysfs_attribute *attr;
+               int range;
+
+               /* take the maximum registered minor range */
+               attr = sysfs_get_classdev_attr(class_dev, "range");
+               if (attr) {
+                       range = atoi(attr->value);
+                       if (range > 1)
+                               udev->partitions = range-1;
+               }
                info("creating device partition nodes '%s[1-%i]'", filename, udev->partitions);
                if (!udev->test_run) {
                        for (i = 1; i <= udev->partitions; i++) {
@@ -298,7 +310,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
        selinux_init();
 
        if (udev->type == 'b' || udev->type == 'c') {
-               retval = create_node(udev);
+               retval = create_node(udev, class_dev);
                if (retval != 0)
                        goto exit;
 
index e1af3dbef61cf3a0d34a67af13e972eb31dd5c2a..172ec12690ac993f339444a1c711e8c8986213f3 100644 (file)
@@ -89,7 +89,7 @@ static int delete_node(struct udevice *udev)
        num = udev->partitions;
        if (num > 0) {
                info("removing all_partitions '%s[1-%i]'", filename, num);
-               if (num > PARTITIONS_COUNT) {
+               if (num > 255) {
                        info("garbage from udev database, skip all_partitions removal");
                        return -1;
                }