From 3e54036862061d8b81fca6cdd3d24bc9ceb53bc0 Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Mon, 22 Dec 2003 19:13:19 -0800 Subject: [PATCH] [PATCH] introduce format char 'k' for kernel-name Attached is a patch that introduces the format char 'k' to be replaced with the kernel name. I like to have it in a callout script. I've moved the build_kernel_name() back to namedev_name_device() since we don't expect it growing cause of 'sdaj' :) --- namedev.c | 27 +++++++++++++++------------ udev.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/namedev.c b/namedev.c index 05553e69..5044870d 100644 --- a/namedev.c +++ b/namedev.c @@ -186,17 +186,6 @@ static mode_t get_default_mode(struct sysfs_class_device *class_dev) return mode; } -static void build_kernel_number(struct sysfs_class_device *class_dev, struct udevice *udev) -{ - char *dig; - - dig = class_dev->name + strlen(class_dev->name); - while (isdigit(*(dig-1))) - dig--; - strfieldcpy(udev->kernel_number, dig); - dbg("kernel_number='%s'", udev->kernel_number); -} - static void apply_format(struct udevice *udev, unsigned char *string) { char name[NAME_SIZE]; @@ -230,6 +219,12 @@ static void apply_format(struct udevice *udev, unsigned char *string) strcat(pos, udev->bus_id); dbg("substitute bus_id '%s'", udev->bus_id); break; + case 'k': + if (strlen(udev->kernel_name) == 0) + break; + strcat(pos, udev->kernel_name); + dbg("substitute kernel name '%s'", udev->kernel_name); + break; case 'n': if (strlen(udev->kernel_number) == 0) break; @@ -728,6 +723,7 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud struct sysfs_class_device *class_dev_parent = NULL; int retval = 0; struct perm_device *perm; + char *pos; udev->mode = 0; @@ -743,7 +739,14 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud dbg("class_dev->name = '%s'", class_dev->name); } - build_kernel_number(class_dev, udev); + strfieldcpy(udev->kernel_name, class_dev->name); + + /* get kernel number */ + pos = class_dev->name + strlen(class_dev->name); + while (isdigit(*(pos-1))) + pos--; + strfieldcpy(udev->kernel_number, pos); + dbg("kernel_number='%s'", udev->kernel_number); /* rules are looked at in priority order */ retval = do_callout(class_dev, udev, sysfs_device); diff --git a/udev.h b/udev.h index 05f6b3c2..656c1b7d 100644 --- a/udev.h +++ b/udev.h @@ -70,6 +70,7 @@ struct udevice { unsigned char bus_id[SYSFS_NAME_LEN]; unsigned char callout_value[NAME_SIZE]; unsigned char kernel_number[NAME_SIZE]; + unsigned char kernel_name[NAME_SIZE]; }; -- 2.39.5