summaryrefslogtreecommitdiff
path: root/cmds/installd/CacheItem.cpp
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2017-05-03 11:36:42 -0600
committer Jeff Sharkey <jsharkey@android.com> 2017-05-05 14:57:29 -0600
commitd712f0ccc120357e1267a04ac6de9dd732b27e76 (patch)
tree7c022021ac8547cd4c061772552c5cfe9ca34d88 /cmds/installd/CacheItem.cpp
parent8bba03d323684abb4e209398019c2540b053b827 (diff)
Clear cached files on external storage.
When clearing cached files belonging to an app, include any cached files on external storage. Since we need to keep sdcardfs in the loop about any file deletions, we always mutate by going through the sdcardfs layer instead of behind its back. Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest Bug: 37486230, 37566983, 37913442, 37914374 Change-Id: If174bf7eaf682da83cf0ab1b4938fe9a5956d464
Diffstat (limited to 'cmds/installd/CacheItem.cpp')
-rw-r--r--cmds/installd/CacheItem.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/cmds/installd/CacheItem.cpp b/cmds/installd/CacheItem.cpp
index 17eb7ff0e1..515f915b8b 100644
--- a/cmds/installd/CacheItem.cpp
+++ b/cmds/installd/CacheItem.cpp
@@ -67,6 +67,7 @@ std::string CacheItem::buildPath() {
}
int CacheItem::purge() {
+ int res = 0;
auto path = buildPath();
if (directory) {
FTS *fts;
@@ -88,29 +89,47 @@ int CacheItem::purge() {
break;
case FTS_F:
if (p->fts_parent->fts_number) {
- truncate(p->fts_path, 0);
+ if (truncate(p->fts_path, 0) != 0) {
+ PLOG(WARNING) << "Failed to truncate " << p->fts_path;
+ res = -1;
+ }
} else {
- unlink(p->fts_path);
+ if (unlink(p->fts_path) != 0) {
+ PLOG(WARNING) << "Failed to unlink " << p->fts_path;
+ res = -1;
+ }
}
break;
case FTS_DEFAULT:
case FTS_SL:
case FTS_SLNONE:
- unlink(p->fts_path);
+ if (unlink(p->fts_path) != 0) {
+ PLOG(WARNING) << "Failed to unlink " << p->fts_path;
+ res = -1;
+ }
break;
case FTS_DP:
- rmdir(p->fts_path);
+ if (rmdir(p->fts_path) != 0) {
+ PLOG(WARNING) << "Failed to rmdir " << p->fts_path;
+ res = -1;
+ }
break;
}
}
- return 0;
} else {
if (tombstone) {
- return truncate(path.c_str(), 0);
+ if (truncate(path.c_str(), 0) != 0) {
+ PLOG(WARNING) << "Failed to truncate " << path;
+ res = -1;
+ }
} else {
- return unlink(path.c_str());
+ if (unlink(path.c_str()) != 0) {
+ PLOG(WARNING) << "Failed to unlink " << path;
+ res = -1;
+ }
}
}
+ return res;
}
} // namespace installd