You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/01/25 00:59:44 UTC

mesos git commit: Fixed `umountAll` to also clean up mtab.

Repository: mesos
Updated Branches:
  refs/heads/master dd04ce9ee -> 29565a25f


Fixed `umountAll` to also clean up mtab.

- Without this, Mesos tests leave garbage in /etc/mtab.

Review: https://reviews.apache.org/r/55795


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/29565a25
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/29565a25
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/29565a25

Branch: refs/heads/master
Commit: 29565a25f283c5516c4a3ff8b121cef503060eeb
Parents: dd04ce9
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Wed Jan 18 02:18:48 2017 -0800
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Jan 24 16:59:28 2017 -0800

----------------------------------------------------------------------
 src/linux/fs.cpp | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/29565a25/src/linux/fs.cpp
----------------------------------------------------------------------
diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp
index 913e233..feba6ec 100644
--- a/src/linux/fs.cpp
+++ b/src/linux/fs.cpp
@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "linux/fs.hpp"
+
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -39,9 +41,10 @@
 #include <stout/os.hpp>
 
 #include <stout/os/read.hpp>
+#include <stout/os/shell.hpp>
 #include <stout/os/stat.hpp>
 
-#include "linux/fs.hpp"
+#include "common/status_utils.hpp"
 
 using std::list;
 using std::set;
@@ -422,6 +425,24 @@ Try<Nothing> unmountAll(const string& target, int flags)
       if (unmount.isError()) {
         return unmount;
       }
+
+      // This normally should not fail even if the entry is not in
+      // mtab or mtab doesn't exist or is not writable. However we
+      // still catch the error here in case there's an error somewhere
+      // else while running this command.
+      // TODO(xujyan): Consider using `setmntent(3)` to implement this.
+      int status = os::spawn("umount", {"umount", "--fake", entry.dir});
+
+      const string message =
+        "Failed to clean up '" + entry.dir + "' in /etc/mtab";
+
+      if (status == -1) {
+        return ErrnoError(message);
+      }
+
+      if (!WSUCCEEDED(status)) {
+        return Error(message + ": " + WSTRINGIFY(status));
+      }
     }
   }