vold: Fix fsck on public volumes

* Fsck was hitting a neverallow on public volumes not formatted in vfat
  because it was always using the trusted context
* Always run trusted fsck for private volumes and untrusted for public

Change-Id: I0a6ee9aea907bae9ed097b920df0559df7b45d7d
gugelfrei
Michael Bestas 9 years ago committed by Aaron Kling
parent 584c493f5e
commit c803d524ea

@ -60,7 +60,7 @@ bool IsSupported() {
IsFilesystemSupported("ext4");
}
status_t Check(const std::string& source, const std::string& target) {
status_t Check(const std::string& source, const std::string& target, bool trusted) {
// The following is shamelessly borrowed from fs_mgr.c, so it should be
// kept in sync with any changes over there.
@ -116,8 +116,7 @@ status_t Check(const std::string& source, const std::string& target) {
cmd.push_back("-y");
cmd.push_back(c_source);
// ext4 devices are currently always trusted
return ForkExecvp(cmd, nullptr, sFsckContext);
return ForkExecvp(cmd, nullptr, trusted ? sFsckContext : sFsckUntrustedContext);
}
return 0;

@ -27,7 +27,7 @@ namespace ext4 {
bool IsSupported();
status_t Check(const std::string& source, const std::string& target);
status_t Check(const std::string& source, const std::string& target, bool trusted);
status_t Mount(const std::string& source, const std::string& target, bool ro, bool remount,
bool executable);
status_t Format(const std::string& source, unsigned long numSectors, const std::string& target);

@ -41,14 +41,13 @@ bool IsSupported() {
IsFilesystemSupported("f2fs");
}
status_t Check(const std::string& source) {
status_t Check(const std::string& source, bool trusted) {
std::vector<std::string> cmd;
cmd.push_back(kFsckPath);
cmd.push_back("-a");
cmd.push_back(source);
// f2fs devices are currently always trusted
return ForkExecvp(cmd, nullptr, sFsckContext);
return ForkExecvp(cmd, nullptr, trusted ? sFsckContext : sFsckUntrustedContext);
}
status_t Mount(const std::string& source, const std::string& target) {

@ -27,7 +27,7 @@ namespace f2fs {
bool IsSupported();
status_t Check(const std::string& source);
status_t Check(const std::string& source, bool trusted);
status_t Mount(const std::string& source, const std::string& target);
status_t Format(const std::string& source);

@ -155,7 +155,7 @@ status_t PrivateVolume::doMount() {
}
if (mFsType == "ext4") {
int res = ext4::Check(mDmDevPath, mPath);
int res = ext4::Check(mDmDevPath, mPath, true);
if (res == 0 || res == 1) {
LOG(DEBUG) << getId() << " passed filesystem check";
} else {
@ -169,7 +169,7 @@ status_t PrivateVolume::doMount() {
}
} else if (mFsType == "f2fs") {
int res = f2fs::Check(mDmDevPath);
int res = f2fs::Check(mDmDevPath, true);
if (res == 0) {
LOG(DEBUG) << getId() << " passed filesystem check";
} else {

@ -137,9 +137,9 @@ status_t PublicVolume::doMount() {
if (mFsType == "exfat") {
ret = exfat::Check(mDevPath);
} else if (mFsType == "ext4") {
ret = ext4::Check(mDevPath, mRawPath);
ret = ext4::Check(mDevPath, mRawPath, false);
} else if (mFsType == "f2fs") {
ret = f2fs::Check(mDevPath);
ret = f2fs::Check(mDevPath, false);
} else if (mFsType == "ntfs") {
ret = ntfs::Check(mDevPath);
} else if (mFsType == "vfat") {

Loading…
Cancel
Save