linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@mail.ru>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] symlink only rules support
Date: Sun, 22 Feb 2004 09:50:13 +0000	[thread overview]
Message-ID: <20040222095013.GD4873@localhost.localdomain> (raw)

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

On Tue, Feb 17, 2004 at 09:29:53AM -0800, Greg KH wrote:
> > 
> > What about the second part (allow symlink-only rules)?
> 
> Yes, I think that would be good to have too.  Just split the patches up
> into two pieces, only one patch per feature/fix.
> 

Slightly modified version. It is less aggressive in that it just adds
symlink collection but otherwise behaves exactly like current code.

the patch is relative to previous one (configuration directory support).

regards

-andrey

[-- Attachment #2: udev018_symlink.patch --]
[-- Type: text/plain, Size: 2289 bytes --]

--- udev-018/namedev.c.symlink	2004-02-21 21:57:19.000000000 +0300
+++ udev-018/namedev.c	2004-02-21 22:19:59.747075352 +0300
@@ -805,17 +805,30 @@ int namedev_name_device(struct sysfs_cla
 	list_for_each_entry(dev, &config_device_list, node) {
 		dbg("process rule");
 		if (match_rule(dev, class_dev, udev, sysfs_device) == 0) {
-			if (dev->name[0] == '\0') {
+			if (dev->name[0] == '\0' && dev->symlink[0] == '\0') {
 				info("configured rule in '%s' at line %i applied, '%s' is ignored",
 				     dev->config_file, dev->config_line, udev->kernel_name);
 				return -1;
 			}
 
-			info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
-			     dev->config_file, dev->config_line, udev->kernel_name, dev->name);
-			strfieldcpy(udev->name, dev->name);
-			strfieldcpy(udev->symlink, dev->symlink);
-			goto found;
+			if (dev->symlink[0] != '\0') {
+				char temp[NAME_MAX];
+
+				info("configured rule in '%s' at line %i applied, added symlink '%s'",
+				     dev->config_file, dev->config_line, dev->symlink);
+				/* do not clobber dev */
+				strfieldcpy(temp, dev->symlink);
+				apply_format(udev, temp, class_dev, sysfs_device);
+				strfieldcat(udev->symlink, temp);
+				strfieldcat(udev->symlink, " ");
+			}
+
+			if (dev->name[0] != '\0') {
+				info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
+				     dev->config_file, dev->config_line, udev->kernel_name, dev->name);
+				strfieldcpy(udev->name, dev->name);
+				goto found;
+			}
 		}
 	}
 
@@ -826,7 +839,6 @@ int namedev_name_device(struct sysfs_cla
 found:
 	/* substitute placeholder */
 	apply_format(udev, udev->name, class_dev, sysfs_device);
-	apply_format(udev, udev->symlink, class_dev, sysfs_device);
 	udev->partitions = dev->partitions;
 done:
 	perm = find_perm(udev->name);
--- udev-018/udev.h.symlink	2004-02-19 21:38:37.000000000 +0300
+++ udev-018/udev.h	2004-02-21 22:21:44.431160952 +0300
@@ -61,6 +61,12 @@ do { \
 	strncpy(to, from, sizeof(to)-1); \
 } while (0)
 
+#define strfieldcat(to, from) \
+do { \
+	to[sizeof(to)-1] = '\0'; \
+	strncat(to, from, sizeof(to)-1); \
+} while (0)
+
 extern int udev_add_device(char *path, char *subsystem, int fake);
 extern int udev_remove_device(char *path, char *subsystem);
 extern void udev_init_config(void);

             reply	other threads:[~2004-02-22  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-22  9:50 Andrey Borzenkov [this message]
2004-02-28  1:04 ` [PATCH] symlink only rules support Greg KH
2004-02-28 14:57 ` Andrey Borzenkov
2004-03-01 22:27 ` 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=20040222095013.GD4873@localhost.localdomain \
    --to=arvidjaar@mail.ru \
    --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).