From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harald Hoyer Date: Thu, 15 Jul 2004 09:03:15 +0000 Subject: Re: udev in initrd Message-Id: <40F64853.8090601@redhat.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------040101080500080605020301" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------040101080500080605020301 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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. --------------040101080500080605020301 Content-Type: text/x-patch; name="udev-029-preserve.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="udev-029-preserve.patch" --- 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; --------------040101080500080605020301-- ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel