Loading cmds/installd/commands.cpp +7 −3 Original line number Original line Diff line number Diff line Loading @@ -235,7 +235,9 @@ int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int f } } static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { return delete_dir_contents_and_dir(create_data_user_profile_package_path(userid, pkgname)); return delete_dir_contents_and_dir( create_data_user_profile_package_path(userid, pkgname), /*ignore_if_missing*/ true); } } int destroy_app_profiles(const char *pkgname) { int destroy_app_profiles(const char *pkgname) { Loading @@ -244,7 +246,9 @@ int destroy_app_profiles(const char *pkgname) { for (auto user : users) { for (auto user : users) { result |= destroy_app_current_profiles(pkgname, user); result |= destroy_app_current_profiles(pkgname, user); } } result |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); result |= delete_dir_contents_and_dir( create_data_ref_profile_package_path(pkgname), /*ignore_if_missing*/ true); return result; return result; } } Loading @@ -257,8 +261,8 @@ int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int if (flags & FLAG_STORAGE_DE) { if (flags & FLAG_STORAGE_DE) { res |= delete_dir_contents_and_dir( res |= delete_dir_contents_and_dir( create_data_user_de_package_path(uuid, userid, pkgname)); create_data_user_de_package_path(uuid, userid, pkgname)); } destroy_app_current_profiles(pkgname, userid); destroy_app_current_profiles(pkgname, userid); } return res; return res; } } Loading cmds/installd/utils.cpp +9 −5 Original line number Original line Diff line number Diff line Loading @@ -341,23 +341,27 @@ static int _delete_dir_contents(DIR *d, return result; return result; } } int delete_dir_contents(const std::string& pathname) { int delete_dir_contents(const std::string& pathname, bool ignore_if_missing) { return delete_dir_contents(pathname.c_str(), 0, NULL); return delete_dir_contents(pathname.c_str(), 0, NULL, ignore_if_missing); } } int delete_dir_contents_and_dir(const std::string& pathname) { int delete_dir_contents_and_dir(const std::string& pathname, bool ignore_if_missing) { return delete_dir_contents(pathname.c_str(), 1, NULL); return delete_dir_contents(pathname.c_str(), 1, NULL, ignore_if_missing); } } int delete_dir_contents(const char *pathname, int delete_dir_contents(const char *pathname, int also_delete_dir, int also_delete_dir, int (*exclusion_predicate)(const char*, const int)) int (*exclusion_predicate)(const char*, const int), bool ignore_if_missing) { { int res = 0; int res = 0; DIR *d; DIR *d; d = opendir(pathname); d = opendir(pathname); if (d == NULL) { if (d == NULL) { if (ignore_if_missing && (errno == ENOENT)) { return 0; } ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno)); ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno)); return -errno; return -errno; } } Loading cmds/installd/utils.h +4 −3 Original line number Original line Diff line number Diff line Loading @@ -99,12 +99,13 @@ int create_move_path(char path[PKG_PATH_MAX], int is_valid_package_name(const char* pkgname); int is_valid_package_name(const char* pkgname); int delete_dir_contents(const std::string& pathname); int delete_dir_contents(const std::string& pathname, bool ignore_if_missing = false); int delete_dir_contents_and_dir(const std::string& pathname); int delete_dir_contents_and_dir(const std::string& pathname, bool ignore_if_missing = false); int delete_dir_contents(const char *pathname, int delete_dir_contents(const char *pathname, int also_delete_dir, int also_delete_dir, int (*exclusion_predicate)(const char *name, const int is_dir)); int (*exclusion_predicate)(const char *name, const int is_dir), bool ignore_if_missing = false); int delete_dir_contents_fd(int dfd, const char *name); int delete_dir_contents_fd(int dfd, const char *name); Loading Loading
cmds/installd/commands.cpp +7 −3 Original line number Original line Diff line number Diff line Loading @@ -235,7 +235,9 @@ int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int f } } static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { return delete_dir_contents_and_dir(create_data_user_profile_package_path(userid, pkgname)); return delete_dir_contents_and_dir( create_data_user_profile_package_path(userid, pkgname), /*ignore_if_missing*/ true); } } int destroy_app_profiles(const char *pkgname) { int destroy_app_profiles(const char *pkgname) { Loading @@ -244,7 +246,9 @@ int destroy_app_profiles(const char *pkgname) { for (auto user : users) { for (auto user : users) { result |= destroy_app_current_profiles(pkgname, user); result |= destroy_app_current_profiles(pkgname, user); } } result |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); result |= delete_dir_contents_and_dir( create_data_ref_profile_package_path(pkgname), /*ignore_if_missing*/ true); return result; return result; } } Loading @@ -257,8 +261,8 @@ int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int if (flags & FLAG_STORAGE_DE) { if (flags & FLAG_STORAGE_DE) { res |= delete_dir_contents_and_dir( res |= delete_dir_contents_and_dir( create_data_user_de_package_path(uuid, userid, pkgname)); create_data_user_de_package_path(uuid, userid, pkgname)); } destroy_app_current_profiles(pkgname, userid); destroy_app_current_profiles(pkgname, userid); } return res; return res; } } Loading
cmds/installd/utils.cpp +9 −5 Original line number Original line Diff line number Diff line Loading @@ -341,23 +341,27 @@ static int _delete_dir_contents(DIR *d, return result; return result; } } int delete_dir_contents(const std::string& pathname) { int delete_dir_contents(const std::string& pathname, bool ignore_if_missing) { return delete_dir_contents(pathname.c_str(), 0, NULL); return delete_dir_contents(pathname.c_str(), 0, NULL, ignore_if_missing); } } int delete_dir_contents_and_dir(const std::string& pathname) { int delete_dir_contents_and_dir(const std::string& pathname, bool ignore_if_missing) { return delete_dir_contents(pathname.c_str(), 1, NULL); return delete_dir_contents(pathname.c_str(), 1, NULL, ignore_if_missing); } } int delete_dir_contents(const char *pathname, int delete_dir_contents(const char *pathname, int also_delete_dir, int also_delete_dir, int (*exclusion_predicate)(const char*, const int)) int (*exclusion_predicate)(const char*, const int), bool ignore_if_missing) { { int res = 0; int res = 0; DIR *d; DIR *d; d = opendir(pathname); d = opendir(pathname); if (d == NULL) { if (d == NULL) { if (ignore_if_missing && (errno == ENOENT)) { return 0; } ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno)); ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno)); return -errno; return -errno; } } Loading
cmds/installd/utils.h +4 −3 Original line number Original line Diff line number Diff line Loading @@ -99,12 +99,13 @@ int create_move_path(char path[PKG_PATH_MAX], int is_valid_package_name(const char* pkgname); int is_valid_package_name(const char* pkgname); int delete_dir_contents(const std::string& pathname); int delete_dir_contents(const std::string& pathname, bool ignore_if_missing = false); int delete_dir_contents_and_dir(const std::string& pathname); int delete_dir_contents_and_dir(const std::string& pathname, bool ignore_if_missing = false); int delete_dir_contents(const char *pathname, int delete_dir_contents(const char *pathname, int also_delete_dir, int also_delete_dir, int (*exclusion_predicate)(const char *name, const int is_dir)); int (*exclusion_predicate)(const char *name, const int is_dir), bool ignore_if_missing = false); int delete_dir_contents_fd(int dfd, const char *name); int delete_dir_contents_fd(int dfd, const char *name); Loading