From 629c63414e6aa045458823bc9a6a022185548682 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 24 Feb 2023 17:26:10 +0000 Subject: [PATCH] Fix logspam when user removed before CE storage prepared Due to frameworks/base commit 5c65b1ee1023 ("Don't prepare CE storage on user creation") (http://ag/20241697), removing a user immediately after creating it causes the user's directories to be destroyed before CE storage was prepared. Functionally this works fine; however, it causes some error messages to be spammed to the log because 'vold_prepare_subdirs destroy' doesn't like that /data/misc_ce/$userId and /data/vendor_ce/$userId don't exist. vold_prepare_subdirs logs two error messages itself, but it also exits with a failure status, which bubbles up and causes a Slog.wtf with a stack trace in StorageManagerService. Fix this by making rmrf_contents() simply return true if the directory doesn't exist. Bug: 232452368 Test: 'pm create-user 10 && pm remove-user 10' and check logcat Change-Id: I867a915f4b25e1a5f0603fbd84680b673ff5eb96 --- vold_prepare_subdirs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vold_prepare_subdirs.cpp b/vold_prepare_subdirs.cpp index 94d7f15..6ad3c6f 100644 --- a/vold_prepare_subdirs.cpp +++ b/vold_prepare_subdirs.cpp @@ -114,6 +114,9 @@ static bool prepare_dir(struct selabel_handle* sehandle, mode_t mode, uid_t uid, static bool rmrf_contents(const std::string& path) { auto dirp = std::unique_ptr(opendir(path.c_str()), closedir); if (!dirp) { + if (errno == ENOENT) { + return true; + } PLOG(ERROR) << "Unable to open directory: " << path; return false; }