Module: xenomai-3
Branch: master
Commit: 24f42351e0192eabe1229099c5dba226cee9d94c
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=24f42351e0192eabe1229099c5dba226cee9d94c

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Jul 23 09:57:18 2015 +0200

copperplate/regd: do command lookup for fusermount/mount

---

 lib/copperplate/regd/regd.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index d86c855..8176c9a 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -268,8 +268,8 @@ fail_nopath:
 
 static void unmount(const char *path)
 {
+       char *cmd, *cmdpath;
        int flags, ret;
-       char *cmd;
 
        /*
         * Silence stderr while we run the shell command - it may complain
@@ -279,7 +279,12 @@ static void unmount(const char *path)
        if (flags >= 0)
                fcntl(2, F_SETFD, flags | FD_CLOEXEC);
 
-       ret = asprintf(&cmd, "/usr/bin/fusermount -uzq %s", path);
+       cmdpath = lookup_command("fusermount");
+       if (cmdpath == NULL)
+               return;
+
+       ret = asprintf(&cmd, "%s -uzq %s", cmdpath, path);
+       free(cmdpath);
        if (ret < 0)
                return;
 
@@ -288,10 +293,12 @@ static void unmount(const char *path)
        if (ret != -1 && WIFEXITED(ret) && WEXITSTATUS(ret) == 0)
                return;
 
-       if (access("/usr/bin/umount", X_OK))
+       cmdpath = lookup_command("umount");
+       if (cmdpath == NULL)
                return;
 
-       ret = asprintf(&cmd, "/usr/bin/umount -l %s", path);
+       ret = asprintf(&cmd, "%s -l %s", cmdpath, path);
+       free(cmdpath);
        if (ret < 0)
                return;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to