$NetBSD: patch-9006,v 1.1 2014/11/18 14:38:15 manu Exp $
From 4f97f9e26663f03da1ca675b16943544e39399a3 Mon Sep 17 00:00:00 2001
From: Emmanuel Dreyfus <manu@netbsd.org>
Date: Thu, 30 Oct 2014 09:50:41 +0100
Subject: [PATCH] Lazy umount emulation: deal with stopped volumes

On non Linux systems, lazy umount is emulated using contrib/umountd.
It first check that the path given to unmount exists, but it should
not give up on ENOTCONN as it is what happens when a volume is mounted
but stopped.

This lets NetBSD pass tests/bugs/bug-1049323.t

Backport of: http://review.gluster.org/8991

BUG: 1138897
Change-Id: I39941577021c0b39f545f9777fe75cd39637427b
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
---
 contrib/umountd/umountd.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git contrib/umountd/umountd.c contrib/umountd/umountd.c
index 42f867d..0d2c6f2 100644
--- contrib/umountd/umountd.c
+++ contrib/umountd/umountd.c
@@ -49,14 +49,20 @@ sanity_check (char *path, dev_t *devp)
         if (path == NULL)
                 usage ();
 
-        if (stat (path, &st) != 0) {
-                gf_log ("umountd", GF_LOG_ERROR,
-                        "Cannot access %s\n", path, strerror (errno));
-                goto out;
+        if ((ret = stat (path, &st)) != 0) {
+                switch (errno) {
+                case ENOTCONN:
+                        /* volume is stopped */
+                        break;
+                default:
+                        gf_log ("umountd", GF_LOG_ERROR,
+                                "Cannot access %s\n", path, strerror (errno));
+                        goto out;
+                }
         }
 
         /* If dev was not specified, get it from path */
-        if (*devp == -1)
+        if (*devp == -1 && ret == 0)
                 *devp = st.st_dev;
 
         strncpy (pathtmp, path, PATH_MAX);
-- 
1.8.2.3

