From 1eb300dca5d7a5430c320fe2acd654f119716961 Mon Sep 17 00:00:00 2001 From: Satoshi Niwa Date: Mon, 20 Jan 2020 18:00:49 +0900 Subject: [PATCH] init: Fix a bug in MountDir mkdir always returns -1 for any types of errors. errno should be checked for actual error type. Test: m Change-Id: I1b56d48ba48992a2f9629dc09d795c277b5b774d --- init/mount_namespace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp index b811622c5..1a474fbf3 100644 --- a/init/mount_namespace.cpp +++ b/init/mount_namespace.cpp @@ -107,7 +107,7 @@ static bool IsApexUpdatable() { } static Result MountDir(const std::string& path, const std::string& mount_path) { - if (int ret = mkdir(mount_path.c_str(), 0755); ret != 0 && ret != EEXIST) { + if (int ret = mkdir(mount_path.c_str(), 0755); ret != 0 && errno != EEXIST) { return ErrnoError() << "Could not create mount point " << mount_path; } if (mount(path.c_str(), mount_path.c_str(), nullptr, MS_BIND, nullptr) != 0) {