Module: xenomai-3
Branch: next
Commit: 50e61ff291d4daf4d48088321aa8ed7f229a7ce1
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50e61ff291d4daf4d48088321aa8ed7f229a7ce1

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Mar  4 10:00:29 2015 +0100

copperplate/regd: be resilient in presence of a stale /system tree

---

 lib/copperplate/regd/regd.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index c8ae0f6..fd5b060 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -159,7 +159,7 @@ static void create_rootdir(void)
 
        if (*rootdir != '/')
                error(1, EINVAL, "absolute root directory path required");
-               
+
        ret = create_directory_recursive(rootdir);
        if (ret)
                error(1, -ret, "create_directory_recursive(\"%s\")", rootdir);
@@ -387,9 +387,24 @@ static void create_system_fs(const char *arg0, const char 
*rootdir)
                error(1, ENOMEM, "malloc");
 
        ret = create_directory_recursive(mountpt);
-       if (ret)
+       if (ret) {
+               /*
+                * Before giving up, try to cleanup a left over, in
+                * case a former sysregd instance died ungracefully.
+                * Receiving ENOTCONN when creating the /system root
+                * is the sign that we may be attempting to walk a
+                * stale tree.
+                */
+               if (ret == -ENOTCONN) {
+                       unmount(mountpt);
+                       ret = create_directory_recursive(mountpt);
+                       if (ret == 0)
+                               goto bootstrap;
+               }
                error(1, -ret, "create_directory_recursive(\"%s\")", mountpt);
+       }
 
+bootstrap:
        atexit(delete_system_fs);
 
        CPU_ZERO(&__node_info.cpu_affinity);


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

Reply via email to