diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-09 08:43:18 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:27:41 -0700 |
commit | 6d56416665863dc2b4fb107dbdc779e4791bdf9e (patch) | |
tree | 906017c79653eda2bfa421733c4901fa9e51b440 /udev_add.c | |
parent | c1ab046124ebef3c82950b91ccfd1678d9f7fe5b (diff) |
[PATCH] create /block/*/range count of partitons for all_partitions
Diffstat (limited to 'udev_add.c')
-rw-r--r-- | udev_add.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/udev_add.c b/udev_add.c index a495902ab2..c566571c1c 100644 --- a/udev_add.c +++ b/udev_add.c @@ -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; |