From ff468dce4c32de86aacbca4afe50a18e4aba43ce Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 23 Mar 2017 16:05:12 -0700 Subject: [PATCH] adb: allow symlinks to directories in directory_exists. Bug: http://b/36516955 Test: python test_device.py Change-Id: Ie81e87aac3b157182bde0955bdba23d48bfea873 --- adb/adb_utils.cpp | 2 +- adb/adb_utils_test.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp index 7058acb38..31d3dc63a 100644 --- a/adb/adb_utils.cpp +++ b/adb/adb_utils.cpp @@ -75,7 +75,7 @@ bool getcwd(std::string* s) { bool directory_exists(const std::string& path) { struct stat sb; - return lstat(path.c_str(), &sb) != -1 && S_ISDIR(sb.st_mode); + return stat(path.c_str(), &sb) != -1 && S_ISDIR(sb.st_mode); } std::string escape_arg(const std::string& s) { diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp index a3bc44560..e1b628707 100644 --- a/adb/adb_utils_test.cpp +++ b/adb/adb_utils_test.cpp @@ -55,7 +55,6 @@ TEST(adb_utils, directory_exists) { ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist"))); #else ASSERT_TRUE(directory_exists("/proc")); - ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link. ASSERT_FALSE(directory_exists("/proc/does-not-exist")); #endif }