Introduction
Introduction Statistics Contact Development Disclaimer Help
smdev: use basename of device for making a path - smdev - suckless mdev
git clone git://git.suckless.org/smdev
Log
Files
Refs
README
LICENSE
---
commit df403c19cc5f4c61dcd10dbc4530051755b56172
parent 23f3fb721b6ad37fff484ffd859596c7f9c77c5b
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 7 Apr 2014 17:36:56 +0200
smdev: use basename of device for making a path
in parsepath() use basename of device (basedevname) to avoid paths like /dev/dr…
Signed-off-by: Hiltjo Posthuma <[email protected]>
Diffstat:
M smdev.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/smdev.c b/smdev.c
@@ -166,11 +166,14 @@ static void
parsepath(struct rule *rule, struct rulepath *rpath,
const char *devname)
{
- char buf[PATH_MAX], *path;
- char *dirc;
+ char buf[PATH_MAX], *path, *dirc;
+ const char *basedevname;
+
+ if(!(basedevname = strrchr(devname, '/')))
+ basedevname = devname;
if (!rule->path) {
- strlcpy(rpath->name, devname, sizeof(rpath->name));
+ strlcpy(rpath->name, basedevname, sizeof(rpath->name));
snprintf(rpath->path, sizeof(rpath->path), "/dev/%s",
rpath->name);
return;
@@ -186,8 +189,8 @@ parsepath(struct rule *rule, struct rulepath *rpath,
/* No need to rename the device node */
if (rule->path[strlen(rule->path) - 1] == '/') {
snprintf(rpath->path, sizeof(rpath->path), "/dev/%s%s",
- path, devname);
- strlcpy(rpath->name, devname, sizeof(rpath->name));
+ path, basedevname);
+ strlcpy(rpath->name, basedevname, sizeof(rpath->name));
free(path);
return;
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.