From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Reinecke Date: Fri, 11 Feb 2005 09:18:54 +0000 Subject: [Patch] Selective removal mode for udev Message-Id: <420C787E.7080407@suse.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------070804000300020002080402" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------070804000300020002080402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable 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=20 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=20 vanishing and ooh everything will stop working'. Comments etc welcome. Cheers, Hannes --=20 Dr. Hannes Reinecke hare@suse.de SuSE Linux AG S390 & zSeries Maxfeldstra=DFe 5 +49 911 74053 688 90409 N=FCrnberg http://www.suse.de --------------070804000300020002080402 Content-Type: text/x-patch; name="udev-052-keep-devicenodes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="udev-052-keep-devicenodes.patch" ===== 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; } --------------070804000300020002080402-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&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