* Re: udev in initrd
@ 2004-07-15 9:03 Harald Hoyer
0 siblings, 0 replies; only message in thread
From: Harald Hoyer @ 2004-07-15 9:03 UTC (permalink / raw)
To: linux-hotplug
[-- 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-07-15 9:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-15 9:03 udev in initrd Harald Hoyer
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).