Make saved environment available for remove event rules
PATCH 1/1 Make saved environment available for remove event rules
The patch assures that saved environment is available when processing rules for 'remove' event. It enables mathing on previously set variables. Among others it makes REMOVE_CMD really works (Debian bug 360855).
This is slightly modified version of patch from this thread:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=114416867706787&w=2
---
Patch attached due to kmail customarily mangling long lines :(
-andrey
Subject: [PATCH] Make saved environment available for remove event rules
From: Andrey Borzenkov <[email protected]>
The patch assures that saved environment is available when processing rules for 'remove' event. It enables mathing on previously set variables. Among others it makes REMOVE_CMD really works (Debian bug 360855).
This is slightly modified version of patch from this thread:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=114416867706787&w=2
---
udev_device.c | 7 ++++--- udev_remove.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
udev_device.c +4 -3
@@ -101,6 +101,10 @@ int udev_device_event(struct udev_rulesif (major (udev->devt) !=0 &&strcmp (udev->action,"remove" ) ==0 ) {struct name_entry *name_loop; +udev_db_get_device (udev, udev->dev->devpath); +/* restore stored persistent data */ +list_for_each_entry (name_loop, &udev->env_list, node) +putenv (name_loop->name);udev_rules_get_run (rules, udev);if (udev->ignore_device) {info ("device event will be ignored" );
@@ -109,9 +113,6 @@ int udev_device_event(struct udev_rules/* get data from db, remove db-entry, delete node */ retval =udev_remove_device (udev); -/* restore stored persistent data */ -list_for_each_entry (name_loop, &udev->env_list, node) -putenv (name_loop->name);return retval; }
udev_remove.c +1 -1
@@ -119,7 +119,7 @@ int udev_remove_device(struct udevice *uif (major (udev->devt) ==0 )return 0 ; -if (udev_db_get_device (udev, udev->dev->devpath) ==0 ) { +if (udev->name[0 ] !='\0' ) {if (udev->ignore_remove) {dbg ("remove event for '%s' requested to be ignored by rule" , udev->name);return 0 ;
Quoted 16 lines · Andrey Borzenkov
The patch assures that saved environment is available when processing rules for 'remove' event. It enables mathing on previously set variables. Among others it makes
REMOVE_CMDreally works (Debian bug 360855).This is slightly modified version of patch from this thread:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=114416867706787&w=2Signed-off-by Andrey Borzenkov <[email protected]>---
Patch attached due to kmail customarily mangling long lines :(-andrey
Subject: [PATCH] Make saved environment available for remove event rules
Quoted 8 lines
From: Andrey Borzenkov <[email protected]>
The patch assures that saved environment is available when processing rules for 'remove' event. It enables mathing on previously set variables. Among others it makes
REMOVE_CMDreally works (Debian bug 360855).This is slightly modified version of patch from this thread:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=114416867706787&w=2
This looks fine, but I already played around with merging the node handling code into one file and moving the database calls out of the node functions.
It's a preparation for a future extension to be able to store data for devices that don't create a node.
Attached is the pretty big patch (looks smaller in git) and it's not really tested. I changed the call to the db like your patch is doing. Would be nice if you can have a look if that is correct and would work for you.
Thanks,
Kay
Makefile +1 -2
@@ -69,8 +69,7 @@ HEADERS = \ UDEV_OBJS = \ udev_device.o \ udev_config.o \ - udev_add.o \ - udev_remove.o \ + udev_node.o \ udev_db.o \ udev_sysfs.o \ udev_rules.o \
udev.h +4 -6
@@ -117,12 +117,10 @@ extern struct sysfs_device *sysfs_deviceextern struct sysfs_device *sysfs_device_get_parent_with_subsystem (struct sysfs_device *dev,const char *subsystem);extern char *sysfs_attr_get_value (const char *devpath,const char *attr_name); -/* udev_add.c */ -extern int udev_make_node (struct udevice *udev,const char *file,dev_t devt,mode_t mode,uid_t uid,gid_t gid); -extern int udev_add_device (struct udevice *udev); - -/* udev_remove.c */ -extern int udev_remove_device (struct udevice *udev); +/* udev_node.c */ +extern int udev_node_mknod (struct udevice *udev,const char *file,dev_t devt,mode_t mode,uid_t uid,gid_t gid); +extern int udev_node_add (struct udevice *udev); +extern int udev_node_remove (struct udevice *udev);/* udev_db.c */ extern int udev_db_add_device (struct udevice *dev);
udev_device.c +97 -20
158 lines not on this page · raw message
udev_node.c renamed from udev_add.c +81 -74
227 lines not on this page · raw message
udev_remove.c deleted +0 -135
135 lines not on this page · raw message
udev_rules.c +1 -1
@@ -610,7 +610,7 @@ found:snprintf (udev->tmp_node,sizeof (udev->tmp_node),"%s/.tmp-%u-%u" , udev_root,major (udev->devt),minor (udev->devt)); udev->tmp_node[sizeof (udev->tmp_node)-1 ] ='\0' ; -udev_make_node (udev, udev->tmp_node, udev->devt,0600 ,0 ,0 ); +udev_node_mknod (udev, udev->tmp_node, udev->devt,0600 ,0 ,0 ); }strlcat (string, udev->tmp_node, maxsize);dbg ("substitute temporary device node name '%s'" , udev->tmp_node);
udevstart.c +1 -2
@@ -130,7 +130,6 @@ static int add_device(const char *devpat/* override built-in sysfs device */ udev->dev = dev;strcpy (udev->action,"add" ); - udev->devt =udev_device_get_devt (udev);if (strcmp (udev->dev->subsystem,"net" ) !=0 ) { udev->devt =udev_device_get_devt (udev);
@@ -148,7 +147,7 @@ static int add_device(const char *devpat goto exit; }if (udev->name[0 ] !='\0' ) - retval =udev_add_device (udev); + retval =udev_device_event (&rules, udev);else info ("device node creation supressed" );