Skip to contentSkip to conversation

udev in initrd

DISCUSSION Harald Hoyer 1 participant 1 message Jul 15, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines · Greg KH

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.

udev-add.c renamed from udev-add.c.preserve +4 -1
@@ -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-remove.c renamed from udev-remove.c.preserve +22 -20

51 lines not on this page · raw message

udev_config.c renamed from udev_config.c.preserve +15 -0
@@ -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.h renamed from udev.h.preserve +2 -0
@@ -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;