All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Hoyer <harald@redhat.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev in initrd
Date: Thu, 15 Jul 2004 09:03:15 +0000	[thread overview]
Message-ID: <40F64853.8090601@redhat.com> (raw)

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

Greg KH wrote:
> Care to send that patch upstream?  :)
> 

Ok, here is a patch, which introduces two new config options:

# udev_preserve_owner - preserve the ownership, if the device node is already there
udev_preserve_owner="no"

# udev_remove_devicenodes - remove created device nodes, if the device is removed
#               symlinks will be removed no matter what
udev_remove_devicenodes="yes"

This patch is useful for systems with /dev not beeing a ramfs and for administrators,
who want /dev to be as untouched as possible.

The right fix for udev_remove_devicenodes would be, to add the entry to the udev database,
what files were created by udev, so that only udev generated device nodes and softlinks
would be removed.

[-- Attachment #2: udev-029-preserve.patch --]
[-- Type: text/x-patch, Size: 3589 bytes --]

--- udev-029/udev-add.c.preserve	2004-07-02 20:17:02.000000000 +0200
+++ udev-029/udev-add.c	2004-07-06 15:27:45.839641704 +0200
@@ -117,7 +117,10 @@
 	if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
 	    (stats.st_rdev == makedev(major, minor))) {
 		dbg("preserve file '%s', cause it has correct dev_t", file);
-		goto perms;
+		if (udev_preserve_owner)
+		  goto exit;
+		else
+		  goto perms;
 	}
 
 	if (unlink(file) != 0)
--- udev-029/udev-remove.c.preserve	2004-07-02 20:17:01.000000000 +0200
+++ udev-029/udev-remove.c	2004-07-06 15:28:04.301835024 +0200
@@ -78,29 +78,31 @@
 	strfieldcpy(filename, udev_root);
 	strfieldcat(filename, dev->name);
 
-	info("removing device node '%s'", filename);
-	retval = unlink(filename);
-	if (errno == ENOENT)
-		retval = 0;
-	if (retval) {
-		dbg("unlink(%s) failed with error '%s'",
-			filename, strerror(errno));
-		return retval;
-	}
+	if (udev_remove_devicenodes) {
+		info("removing device node '%s'", filename);
+		retval = unlink(filename);
+		if (errno == ENOENT)
+			retval = 0;
+		if (retval) {
+			dbg("unlink(%s) failed with error '%s'",
+			    filename, strerror(errno));
+			return retval;
+		}
 
-	/* remove partition nodes */
-	if (dev->partitions > 0) {
-		info("removing partitions '%s[1-%i]'", filename, dev->partitions);
-		for (i = 1; i <= dev->partitions; i++) {
-			strfieldcpy(partitionname, filename);
-			strintcat(partitionname, i);
-			unlink(partitionname);
+		/* remove partition nodes */
+		if (dev->partitions > 0) {
+			info("removing partitions '%s[1-%i]'", filename, dev->partitions);
+			for (i = 1; i <= dev->partitions; i++) {
+				strfieldcpy(partitionname, filename);
+				strintcat(partitionname, i);
+				unlink(partitionname);
+			}
 		}
-	}
 
-	/* remove subdirectories */
-	if (strchr(dev->name, '/'))
-		delete_path(filename);
+		/* remove subdirectories */
+		if (strchr(dev->name, '/'))
+			delete_path(filename);
+	}
 
 	foreach_strpart(dev->symlink, " ", pos, len) {
 		strfieldcpymax(linkname, pos, len+1);
--- udev-029/udev_config.c.preserve	2004-07-02 20:17:02.000000000 +0200
+++ udev-029/udev_config.c	2004-07-06 15:27:45.840641552 +0200
@@ -50,6 +50,8 @@
 char default_owner_str[OWNER_SIZE];
 char default_group_str[GROUP_SIZE];
 int udev_log;
+int udev_remove_devicenodes;
+int udev_preserve_owner;
 int udev_sleep;
 int udev_dev_d;
 
@@ -78,6 +80,8 @@
 	strfieldcpy(udev_rules_filename, UDEV_RULES_FILE);
 	strfieldcpy(udev_permissions_filename, UDEV_PERMISSION_FILE);
 	udev_log = string_is_true(UDEV_LOG_DEFAULT);
+	udev_remove_devicenodes = 1;
+	udev_preserve_owner = 0;
 
 	udev_sleep = 1;
 	env = getenv("UDEV_NO_SLEEP");
@@ -224,6 +228,17 @@
 			continue;
 		}
 
+                if (strcasecmp(variable, "udev_remove_devicenodes") == 0) {
+                        udev_remove_devicenodes = string_is_true(value);
+                        continue;
+                }
+
+                if (strcasecmp(variable, "udev_preserve_owner") == 0) {
+                        udev_preserve_owner = string_is_true(value);
+                        continue;
+                }
+
+
 		info("%s:%d:%Zd: unknown key '%s'",
 		     udev_config_filename, lineno, temp-line, temp);
 	}
--- udev-029/udev.h.preserve	2004-07-02 20:17:03.000000000 +0200
+++ udev-029/udev.h	2004-07-06 15:27:45.841641400 +0200
@@ -79,6 +79,8 @@
 extern char default_owner_str[OWNER_SIZE];
 extern char default_group_str[GROUP_SIZE];
 extern int udev_log;
+extern int udev_remove_devicenodes;
+extern int udev_preserve_owner;
 extern int udev_sleep;
 extern int udev_dev_d;
 

                 reply	other threads:[~2004-07-15  9:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=40F64853.8090601@redhat.com \
    --to=harald@redhat.com \
    --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.