From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [udev] updated man, subdirs, ownership, namedev enum patches
Date: Sat, 15 Nov 2003 16:09:14 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-106891263429303@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-106860942327356@msgid-missing>
[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]
On Thu, Nov 13, 2003 at 11:49:03AM -0800, Greg KH wrote:
> On Thu, Nov 13, 2003 at 09:30:08AM +0100, Kay Sievers wrote:
> > Yes, it doesn't append the number when a label is specified for a
> > partition. But what when i want my partition labeled "data" not "data1"
> > LABEL, BUS="ide", size="117210177", NAME="data"
>
> Problem is, if you use the LABEL rule to match a device, like a SCSI
> vendor, then all of the partitions, as well as the main block device,
> will end up with the same name. That's why I added the "add the number"
> hack to the LABEL rule.
>
> So yes, your patch is correct in that we shouldn't always be adding the
> number to any match for LABEL (like for char devices), but if we do
> that, then we break partitions. Your '%' patch fixes this, but I'd just
> like to extend it a bit. Let me see what I can come up with...
Oh, I see. Do you mean something like this:
LABEL, BUS="usb", model="Creative Labs WebCam 3", NAME="webcam%n-%M:%m-test"
results in: "webcam0-81:0-test"
Nov 15 16:51:53 pim udev[16193]: get_class_dev: looking at /sys/class/video4linux/video0
Nov 15 16:51:53 pim udev[16193]: get_class_dev: class_dev->name = video0
Nov 15 16:51:53 pim udev[16193]: get_major_minor: dev = 81:0
Nov 15 16:51:53 pim udev[16193]: get_major_minor: found major = 81, minor = 0
Nov 15 16:51:53 pim udev[16193]: udev_add_device: name = webcam0-81:0-test
Nov 15 16:51:53 pim udev[16193]: create_node: mknod(/udev/webcam0-81:0-test, 020666, 81, 0)
thanks,
Kay
04-udev-add.c-minor_before_namedev.diff
move get_major_minor() before namedev_name_device(), so namedev knows
major/minor of device
04-namedev.c-multiple-placeholder-support.diff
implement printf-like placeholder support for NAME
%n-kernel number, %M-major number, %m-minor number
[-- Attachment #2: 04-udev-add.c-minor_before_namedev.diff --]
[-- Type: text/plain, Size: 581 bytes --]
--- /usr/src/udev/udev-add.c 2003-10-30 08:37:11.000000000 +0100
+++ udev-add.c 2003-10-30 15:21:02.000000000 +0100
@@ -183,16 +183,16 @@
if (class_dev == NULL)
goto exit;
- retval = namedev_name_device(class_dev, &dev);
- if (retval)
- return retval;
-
retval = get_major_minor(class_dev, &dev.major, &dev.minor);
if (retval) {
dbg("get_major_minor failed");
goto exit;
}
+ retval = namedev_name_device(class_dev, &dev);
+ if (retval)
+ return retval;
+
// strcpy(dev.name, attr.name);
// strcpy(dev.owner, attr.owner);
// strcpy(dev.group, attr.group);
[-- Attachment #3: 04-namedev.c-multiple-placeholder-support.diff --]
[-- Type: text/plain, Size: 1564 bytes --]
--- ../udev/namedev.c 2003-11-12 13:56:20.000000000 +0100
+++ namedev.c 2003-11-15 17:06:07.000000000 +0100
@@ -540,6 +540,9 @@
static int get_attr(struct sysfs_class_device *class_dev, struct udevice *udev)
{
struct list_head *tmp;
+ char *pos;
+ char *dig;
+ char name[NAME_SIZE];
int retval = 0;
int found;
@@ -623,10 +626,6 @@
}
strcpy(udev->name, dev->name);
- if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
- temp = &class_dev->path[strlen(class_dev->path)-1];
- strcat(udev->name, temp);
- }
if (dev->mode != 0) {
udev->mode = dev->mode;
strcpy(udev->owner, dev->owner);
@@ -756,6 +755,37 @@
strcpy(udev->name, class_dev->name);
done:
+ /* substitute placeholder in NAME */
+ while (1) {
+ pos = strchr(udev->name, '%');
+ if (pos) {
+ strcpy(name, pos+2);
+ *pos = 0x00;
+ switch (pos[1]) {
+ case 'n':
+ dig = class_dev->name + strlen(class_dev->name);
+ while (isdigit(*(dig-1)))
+ dig--;
+ strcat(udev->name, dig);
+ dbg_parse("kernel number appended: %s", dig);
+ break;
+ case 'm':
+ sprintf(pos, "%u", udev->minor);
+ dbg_parse("minor number appended: %u", udev->minor);
+ break;
+ case 'M':
+ sprintf(pos, "%u", udev->major);
+ dbg_parse("major number appended: %u", udev->major);
+ break;
+ default:
+ dbg_parse("unknown substitution type: %%%c", pos[1]);
+ break;
+ }
+ strcat(udev->name, name);
+ } else
+ break;
+ }
+
/* mode was never set above */
if (!udev->mode) {
udev->mode = get_default_mode(class_dev);
next prev parent reply other threads:[~2003-11-15 16:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-12 3:53 [udev] updated man, subdirs, ownership, namedev enum patches Greg KH
2003-11-12 13:23 ` Kay Sievers
2003-11-13 6:23 ` Greg KH
2003-11-13 8:30 ` Kay Sievers
2003-11-13 19:49 ` Greg KH
2003-11-15 16:09 ` Kay Sievers [this message]
2003-11-17 17:33 ` Arnd Bergmann
2003-11-18 1:00 ` Greg KH
2003-11-18 1:14 ` Greg KH
2003-11-18 3:15 ` Kay Sievers
2003-11-18 12:09 ` Arnd Bergmann
2003-11-18 12:17 ` Arnd Bergmann
2003-11-19 0:24 ` Greg KH
2003-11-19 23:40 ` Greg KH
2003-11-19 23:42 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2003-11-05 19:38 Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-106891263429303@msgid-missing \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.