linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [udev] introduce format char 'k' for kernel-name
Date: Sat, 20 Dec 2003 01:32:01 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-107188408328865@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

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' :)

thanks,
Kay

[-- Attachment #2: 03-format-char-k-for-kernel-name.diff --]
[-- Type: text/plain, Size: 1841 bytes --]

diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c	Sat Dec 20 02:00:30 2003
+++ b/namedev.c	Sat Dec 20 02:00:30 2003
@@ -185,17 +185,6 @@
 	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];
@@ -229,6 +218,12 @@
 				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;
@@ -586,6 +581,7 @@
 	struct sysfs_class_device *class_dev_parent = NULL;
 	int retval = 0;
 	struct perm_device *perm;
+	char *pos;
 
 	udev->mode = 0;
 
@@ -622,7 +618,14 @@
 		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 -Nru a/udev.h b/udev.h
--- a/udev.h	Sat Dec 20 02:00:30 2003
+++ b/udev.h	Sat Dec 20 02:00:30 2003
@@ -70,6 +70,7 @@
 	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];
 
 };
 

             reply	other threads:[~2003-12-20  1:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-20  1:32 Kay Sievers [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-22 19:14 [udev] introduce format char 'k' for kernel-name Greg KH

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-107188408328865@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).