const char kPreloadManifestDir[] = "/usr/share/packages";
const char kPreloadIcons[] = "/usr/share/icons";
+namespace {
+
+enum RWDirectory {
+ DATA,
+ CACHE,
+ SHARED_CACHE,
+ SHARED_DATA,
+ SHARED_TRUSTED
+};
+
+const char* rwDirectories[] = {
+ "data",
+ "cache",
+ "shared/cache",
+ "shared/data",
+ "shared/trusted"
+};
+
+}
bool TouchFile(const bf::path& path) {
void ValidatePackageRWFS(const std::string& pkgid, uid_t uid) {
bf::path root_path = ci::GetRootAppPath(false, uid);
bf::path package_path = root_path / pkgid;
- bf::path data_path = package_path / "data";
- bf::path cache_path = package_path / "cache";
- bf::path shared_data_path = package_path / "shared" / "data";
+ bf::path data_path = package_path / rwDirectories[DATA];
+ bf::path cache_path = package_path / rwDirectories[CACHE];
+ bf::path shared_data_path = package_path / rwDirectories[SHARED_DATA];
ASSERT_TRUE(bf::exists(data_path));
ASSERT_TRUE(bf::exists(cache_path));
iter != bf::recursive_directory_iterator(); ++iter) {
if (bf::is_symlink(symlink_status(iter->path())))
continue;
- if (iter->path().filename() == "data" ||
- iter->path().filename() == ".mmc")
+ bool is_rw_dir = false;
+ for(const auto rw_dir : rwDirectories) {
+ bf::path rw_dir_path = rw_dir;
+ bf::path relative_path = ci::MakeRelativePath(iter->path(), package_path);
+ is_rw_dir |= (relative_path == rw_dir_path);
+ }
+ if (iter->path().filename() == ".mmc" || is_rw_dir) {
+ iter.no_push();
continue;
+ }
struct stat stats;
stat(iter->path().c_str(), &stats);
ASSERT_EQ(uid, stats.st_uid);