summaryrefslogtreecommitdiff
path: root/udev-remove.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-12-10 00:47:00 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:07 -0700
commit4763256c65859b94ac7a309cbb8f772d5426a08d (patch)
tree60c1857fd2891bb7fde065895ac10bae805b4dc5 /udev-remove.c
parent10a479f5e6df7010a47f1edfab8173de85a34d0d (diff)
[PATCH] allow multiple symlinks
Here is a patch to allow the creation of multiple symlinks. The names must be separated by a space character. REPLACE, KERNEL="ttyUSB0", NAME="visor", SYMLINK="first-%n second-%n third-%n" results in: Dec 9 05:28:51 pim udev[12019]: create_node: mknod(udev-root/visor, 020666, 188, 0) Dec 9 05:28:51 pim udev[12019]: create_node: symlink 'udev-root/first-0' to node 'visor' requested Dec 9 05:28:51 pim udev[12019]: create_node: symlink(./visor, udev-root/first-0) Dec 9 05:28:51 pim udev[12019]: create_node: symlink 'udev-root/second-0' to node 'visor' requested Dec 9 05:28:51 pim udev[12019]: create_node: symlink(./visor, udev-root/second-0) Dec 9 05:28:51 pim udev[12019]: create_node: symlink 'udev-root/third-0' to node 'visor' requested Dec 9 05:28:51 pim udev[12019]: create_node: symlink(./visor, udev-root/third-0)
Diffstat (limited to 'udev-remove.c')
-rw-r--r--udev-remove.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/udev-remove.c b/udev-remove.c
index 02c84371a4..0886c23343 100644
--- a/udev-remove.c
+++ b/udev-remove.c
@@ -66,6 +66,8 @@ static int delete_path(char *path)
static int delete_node(struct udevice *dev)
{
char filename[255];
+ char *symlinks;
+ char *linkname;
int retval;
strncpy(filename, udev_root, sizeof(filename));
@@ -84,17 +86,25 @@ static int delete_node(struct udevice *dev)
delete_path(filename);
if (*dev->symlink) {
- strncpy(filename, udev_root, sizeof(filename));
- strncat(filename, dev->symlink, sizeof(filename));
- dbg("unlinking symlink '%s'", filename);
- retval = unlink(filename);
- if (retval) {
- dbg("unlink(%s) failed with error '%s'",
- filename, strerror(errno));
- return retval;
- }
- if (strchr(dev->symlink, '/')) {
- delete_path(filename);
+ symlinks = dev->symlink;
+ while (1) {
+ linkname = strsep(&symlinks, " ");
+ if (linkname == NULL)
+ break;
+
+ strncpy(filename, udev_root, sizeof(filename));
+ strncat(filename, linkname, sizeof(filename));
+
+ dbg("unlinking symlink '%s'", filename);
+ retval = unlink(filename);
+ if (retval) {
+ dbg("unlink(%s) failed with error '%s'",
+ filename, strerror(errno));
+ return retval;
+ }
+ if (strchr(dev->symlink, '/')) {
+ delete_path(filename);
+ }
}
}