linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: [Patch] Selective removal mode for udev
Date: Fri, 11 Feb 2005 09:18:54 +0000	[thread overview]
Message-ID: <420C787E.7080407@suse.de> (raw)

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

Because we are chicken ...

This patch adds a 'removal' mode for udev, with three possible choices:

- all: default behaviour; remove all nodes and symlinks
- symlink_only: only remove symlinks, but keep device nodes
- none: do not remove nodes nor symlinks.

The latter is equivalent with the existing 'ignore_remove' rule 
statement, but implemented as a global switch.

Properly documented in the man-page etc.

This is basically for those worrying about 'my device node may be 
vanishing and ooh everything will stop working'.

Comments etc welcome.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux AG				S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[-- Attachment #2: udev-052-keep-devicenodes.patch --]
[-- Type: text/x-patch, Size: 3364 bytes --]

===== udev.8.in 1.77 vs edited =====
--- 1.77/udev.8.in	2005-02-10 01:03:54 +01:00
+++ edited/udev.8.in	2005-02-11 09:41:11 +01:00
@@ -59,6 +59,21 @@
 The switch to enable/disable logging of udev information
 The default value is
 .IR yes .
+.TP
+.B udev_remove
+Configure the behaviour for remove events. Possible values are
+.IR all ,
+.IR symlinks_only ,
+.IR none .
+When set to
+.IR all ,
+udev will remove all device information (this is the default). When
+set to
+.IR symlinks_only ,
+udev will remove all symlinks but leave the device node
+intact. When set to
+.IR none ,
+udev will not remove any device information.
 .P
 .RI "A sample " udev.conf " file might look like this:
 .sp
===== udev_config.c 1.31 vs edited =====
--- 1.31/udev_config.c	2005-01-04 21:37:01 +01:00
+++ edited/udev_config.c	2005-02-11 10:04:16 +01:00
@@ -48,6 +48,7 @@
 int udev_log;
 int udev_dev_d;
 int udev_hotplug_d;
+int udev_remove_mode = UDEV_REMOVE_ALL;
 
 
 static int string_is_true(const char *str)
@@ -164,6 +165,17 @@
 
 		if (strcasecmp(variable, "udev_log") == 0) {
 			udev_log = string_is_true(value);
+			continue;
+		}
+
+		if (strcasecmp(variable, "udev_remove") == 0) {
+			if (strcasecmp(value,"all") == 0) {
+				udev_remove_mode=UDEV_REMOVE_ALL;
+			} else if (strcasecmp(value,"symlinks_only") == 0) {
+				udev_remove_mode=UDEV_REMOVE_SYMLINKS;
+			} else if (strcasecmp(value,"none")) {
+				udev_remove_mode=UDEV_REMOVE_NONE;
+			}
 			continue;
 		}
 	}
===== udev_db.c 1.41 vs edited =====
--- 1.41/udev_db.c	2005-02-04 18:38:55 +01:00
+++ edited/udev_db.c	2005-02-11 09:45:54 +01:00
@@ -165,6 +165,11 @@
 	get_db_filename(udev, filename, SYSFS_PATH_MAX);
 	unlink(filename);
 
+	if (udev_remove_mode == UDEV_REMOVE_SYMLINKS) {
+		memset(udev->symlink, 0, NAME_SIZE);
+		udev_db_add_device(udev);
+	}
+
 	return 0;
 }
 
===== udev.h 1.84 vs edited =====
--- 1.84/udev.h	2005-02-09 00:43:18 +01:00
+++ edited/udev.h	2005-02-11 09:32:14 +01:00
@@ -48,6 +48,11 @@
 
 #define DEFAULT_PARTITIONS_COUNT	15
 
+/* Removal modes to keep whiners happy */
+#define UDEV_REMOVE_ALL			0
+#define UDEV_REMOVE_SYMLINKS		1
+#define UDEV_REMOVE_NONE		2
+
 struct udevice {
 	char devpath[DEVPATH_SIZE];
 	char subsystem[SUBSYSTEM_SIZE];
@@ -89,5 +94,6 @@
 extern int udev_log;
 extern int udev_dev_d;
 extern int udev_hotplug_d;
+extern int udev_remove_mode;
 
 #endif
===== udev_remove.c 1.45 vs edited =====
--- 1.45/udev_remove.c	2005-02-09 00:43:18 +01:00
+++ edited/udev_remove.c	2005-02-11 10:07:52 +01:00
@@ -80,6 +80,11 @@
 	snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
 	filename[NAME_SIZE-1] = '\0';
 
+	if (udev_remove_mode == UDEV_REMOVE_SYMLINKS) {
+		dbg("remove device nodes for '%s' requested to be ignored by config", udev->name);
+		goto remove_symlinks;
+	}
+
 	info("removing device node '%s'", filename);
 	retval = unlink_secure(filename);
 	if (retval)
@@ -104,6 +109,7 @@
 	if (strchr(udev->name, '/'))
 		delete_path(filename);
 
+ remove_symlinks:
 	foreach_strpart(udev->symlink, " ", pos, len) {
 		char linkname[NAME_SIZE];
 
@@ -152,6 +158,11 @@
 
 	if (udev->ignore_remove) {
 		dbg("remove event for '%s' requested to be ignored by rule", udev->name);
+		return 0;
+	}
+
+	if (udev_remove_mode == UDEV_REMOVE_NONE) {
+		dbg("remove event for '%s' requested to be ignored by config", udev->name);
 		return 0;
 	}
 

             reply	other threads:[~2005-02-11  9:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11  9:18 Hannes Reinecke [this message]
2005-02-11  9:52 ` [Patch] Selective removal mode for udev Kay Sievers
2005-02-11 10:15 ` Christian Zoz
2005-02-11 11:39 ` Kay Sievers
2005-02-11 13:51 ` Hannes Reinecke
2005-02-13 21:24 ` Kay Sievers
2005-02-18 17:43 ` Hannes Reinecke

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=420C787E.7080407@suse.de \
    --to=hare@suse.de \
    --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).