Merge changes I8d2bd67d,I704522b2 am: 27f3ab89d0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1484498 Change-Id: I28ef08b0fe9b3c94b02769f43e21f574e524da57
This commit is contained in:
commit
5a9feb48fa
4 changed files with 13 additions and 11 deletions
|
@ -67,6 +67,7 @@ using android::base::StartsWith;
|
||||||
using android::base::StringPrintf;
|
using android::base::StringPrintf;
|
||||||
using android::fs_mgr::GetEntryForMountPoint;
|
using android::fs_mgr::GetEntryForMountPoint;
|
||||||
using android::vold::BuildDataPath;
|
using android::vold::BuildDataPath;
|
||||||
|
using android::vold::IsDotOrDotDot;
|
||||||
using android::vold::IsFilesystemSupported;
|
using android::vold::IsFilesystemSupported;
|
||||||
using android::vold::kEmptyAuthentication;
|
using android::vold::kEmptyAuthentication;
|
||||||
using android::vold::KeyBuffer;
|
using android::vold::KeyBuffer;
|
||||||
|
@ -140,6 +141,7 @@ static std::vector<std::string> get_ce_key_paths(const std::string& directory_pa
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (IsDotOrDotDot(*entry)) continue;
|
||||||
if (entry->d_type != DT_DIR || entry->d_name[0] != 'c') {
|
if (entry->d_type != DT_DIR || entry->d_name[0] != 'c') {
|
||||||
LOG(DEBUG) << "Skipping non-key " << entry->d_name;
|
LOG(DEBUG) << "Skipping non-key " << entry->d_name;
|
||||||
continue;
|
continue;
|
||||||
|
@ -391,6 +393,7 @@ static bool load_all_de_keys() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (IsDotOrDotDot(*entry)) continue;
|
||||||
if (entry->d_type != DT_DIR || !is_numeric(entry->d_name)) {
|
if (entry->d_type != DT_DIR || !is_numeric(entry->d_name)) {
|
||||||
LOG(DEBUG) << "Skipping non-de-key " << entry->d_name;
|
LOG(DEBUG) << "Skipping non-de-key " << entry->d_name;
|
||||||
continue;
|
continue;
|
||||||
|
@ -973,6 +976,7 @@ static bool destroy_volume_keys(const std::string& directory_path, const std::st
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (IsDotOrDotDot(*entry)) continue;
|
||||||
if (entry->d_type != DT_DIR || entry->d_name[0] == '.') {
|
if (entry->d_type != DT_DIR || entry->d_name[0] == '.') {
|
||||||
LOG(DEBUG) << "Skipping non-user " << entry->d_name;
|
LOG(DEBUG) << "Skipping non-user " << entry->d_name;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -70,9 +70,7 @@ static bool pushBackContents(const std::string& path, std::vector<std::string>&
|
||||||
bool found = false;
|
bool found = false;
|
||||||
struct dirent* ent;
|
struct dirent* ent;
|
||||||
while ((ent = readdir(dirp.get())) != NULL) {
|
while ((ent = readdir(dirp.get())) != NULL) {
|
||||||
if ((!strcmp(ent->d_name, ".")) || (!strcmp(ent->d_name, ".."))) {
|
if (IsDotOrDotDot(*ent)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto subdir = path + "/" + ent->d_name;
|
auto subdir = path + "/" + ent->d_name;
|
||||||
found |= pushBackContents(subdir, cmd, searchLevels - 1);
|
found |= pushBackContents(subdir, cmd, searchLevels - 1);
|
||||||
}
|
}
|
||||||
|
|
14
Utils.cpp
14
Utils.cpp
|
@ -956,10 +956,7 @@ int64_t calculate_dir_size(int dfd) {
|
||||||
int subfd;
|
int subfd;
|
||||||
|
|
||||||
/* always skip "." and ".." */
|
/* always skip "." and ".." */
|
||||||
if (name[0] == '.') {
|
if (IsDotOrDotDot(*de)) continue;
|
||||||
if (name[1] == 0) continue;
|
|
||||||
if ((name[1] == '.') && (name[2] == 0)) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||||
if (subfd >= 0) {
|
if (subfd >= 0) {
|
||||||
|
@ -1256,6 +1253,10 @@ status_t UnmountTree(const std::string& mountPoint) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsDotOrDotDot(const struct dirent& ent) {
|
||||||
|
return strcmp(ent.d_name, ".") == 0 || strcmp(ent.d_name, "..") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static status_t delete_dir_contents(DIR* dir) {
|
static status_t delete_dir_contents(DIR* dir) {
|
||||||
// Shamelessly borrowed from android::installd
|
// Shamelessly borrowed from android::installd
|
||||||
int dfd = dirfd(dir);
|
int dfd = dirfd(dir);
|
||||||
|
@ -1269,10 +1270,7 @@ static status_t delete_dir_contents(DIR* dir) {
|
||||||
const char* name = de->d_name;
|
const char* name = de->d_name;
|
||||||
if (de->d_type == DT_DIR) {
|
if (de->d_type == DT_DIR) {
|
||||||
/* always skip "." and ".." */
|
/* always skip "." and ".." */
|
||||||
if (name[0] == '.') {
|
if (IsDotOrDotDot(*de)) continue;
|
||||||
if (name[1] == 0) continue;
|
|
||||||
if ((name[1] == '.') && (name[2] == 0)) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
android::base::unique_fd subfd(
|
android::base::unique_fd subfd(
|
||||||
openat(dfd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC));
|
openat(dfd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC));
|
||||||
|
|
2
Utils.h
2
Utils.h
|
@ -168,6 +168,8 @@ bool IsVirtioBlkDevice(unsigned int major);
|
||||||
status_t UnmountTreeWithPrefix(const std::string& prefix);
|
status_t UnmountTreeWithPrefix(const std::string& prefix);
|
||||||
status_t UnmountTree(const std::string& mountPoint);
|
status_t UnmountTree(const std::string& mountPoint);
|
||||||
|
|
||||||
|
bool IsDotOrDotDot(const struct dirent& ent);
|
||||||
|
|
||||||
status_t DeleteDirContentsAndDir(const std::string& pathname);
|
status_t DeleteDirContentsAndDir(const std::string& pathname);
|
||||||
status_t DeleteDirContents(const std::string& pathname);
|
status_t DeleteDirContents(const std::string& pathname);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue