smdev

suckless mdev
git clone git://git.suckless.org/smdev
Log | Files | Refs | README | LICENSE

commit 9ef2984829ef5c3655296ceed54d270fbff660cc
parent 4493e6f0efa782693f55b062e02d246a257efddf
Author: sin <sin@2f30.org>
Date:   Mon,  2 Sep 2013 10:27:08 +0100

If path[0] is ! then run the command hook for the rule

Diffstat:
Msmdev.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/smdev.c b/smdev.c @@ -214,10 +214,6 @@ removedev(struct event *ev) char buf[PATH_MAX]; rule = ev->rule; - - if (rule->path && rule->path[0] == '!') - return 0; - ocwd = agetcwd(); parsepath(rule, &rpath, ev->devname); @@ -236,6 +232,9 @@ removedev(struct event *ev) free(ocwd); + if (rule->path && rule->path[0] == '!') + return 0; + /* Delete device node */ unlink(rpath.path); /* Delete symlink */ @@ -258,16 +257,15 @@ createdev(struct event *ev) int type; rule = ev->rule; + ocwd = agetcwd(); if (rule->path && rule->path[0] == '!') - return 0; + goto runrule; snprintf(buf, sizeof(buf), "%d:%d", ev->major, ev->minor); if ((type = devtype(buf)) < 0) return -1; - ocwd = agetcwd(); - /* Parse path and create the directory tree */ parsepath(rule, &rpath, ev->devname); if (!(dirc = strdup(rpath.path))) @@ -311,6 +309,7 @@ createdev(struct event *ev) buf, rpath.path); } +runrule: if (chdir("/dev") < 0) eprintf("chdir /dev:");