Merge "Replacing fs_mgr_dir_is_writable(work) with fs_mgr_rw_access(work) to check whether the scratch partition is writable."
This commit is contained in:
commit
cf10e2097d
1 changed files with 4 additions and 13 deletions
|
|
@ -120,13 +120,9 @@ bool fs_mgr_is_dir(const std::string& path) {
|
||||||
return !stat(path.c_str(), &st) && S_ISDIR(st.st_mode);
|
return !stat(path.c_str(), &st) && S_ISDIR(st.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar test as overlayfs workdir= validation in the kernel for read-write
|
bool fs_mgr_rw_access(const std::string& path) {
|
||||||
// validation, except we use fs_mgr_work. Covers space and storage issues.
|
if (path.empty()) return false;
|
||||||
bool fs_mgr_dir_is_writable(const std::string& path) {
|
return access(path.c_str(), R_OK | W_OK) == 0;
|
||||||
auto test_directory = path + "/fs_mgr_work";
|
|
||||||
rmdir(test_directory.c_str());
|
|
||||||
auto ret = !mkdir(test_directory.c_str(), 0700);
|
|
||||||
return ret | !rmdir(test_directory.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// At less than 1% or 8MB of free space return value of false,
|
// At less than 1% or 8MB of free space return value of false,
|
||||||
|
|
@ -280,7 +276,7 @@ std::string fs_mgr_get_overlayfs_candidate(const std::string& mount_point) {
|
||||||
if (!fs_mgr_is_dir(upper)) continue;
|
if (!fs_mgr_is_dir(upper)) continue;
|
||||||
auto work = dir + kWorkName;
|
auto work = dir + kWorkName;
|
||||||
if (!fs_mgr_is_dir(work)) continue;
|
if (!fs_mgr_is_dir(work)) continue;
|
||||||
if (!fs_mgr_dir_is_writable(work)) continue;
|
if (!fs_mgr_rw_access(work)) continue;
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -317,11 +313,6 @@ const std::string fs_mgr_mount_point(const std::string& mount_point) {
|
||||||
return "/system";
|
return "/system";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fs_mgr_rw_access(const std::string& path) {
|
|
||||||
if (path.empty()) return false;
|
|
||||||
return access(path.c_str(), R_OK | W_OK) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr char kOverlayfsFileContext[] = "u:object_r:overlayfs_file:s0";
|
constexpr char kOverlayfsFileContext[] = "u:object_r:overlayfs_file:s0";
|
||||||
|
|
||||||
class AutoSetFsCreateCon final {
|
class AutoSetFsCreateCon final {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue