Merge "vold: Support aborting FUSE connections." into rvc-dev am: cbb69e548a

Change-Id: I587b49c9baed58fb87d27e060faf5d3d4ef8d788
gugelfrei
Martijn Coenen 4 years ago committed by Automerger Merge Worker
commit 8714d59e29

@ -1330,6 +1330,21 @@ bool writeStringToFile(const std::string& payload, const std::string& filename)
return true;
}
status_t AbortFuseConnections() {
namespace fs = std::filesystem;
for (const auto& itEntry : fs::directory_iterator("/sys/fs/fuse/connections")) {
std::string abortPath = itEntry.path().string() + "/abort";
LOG(DEBUG) << "Aborting fuse connection entry " << abortPath;
bool ret = writeStringToFile("1", abortPath);
if (!ret) {
LOG(WARNING) << "Failed to write to " << abortPath;
}
}
return OK;
}
status_t EnsureDirExists(const std::string& path, mode_t mode, uid_t uid, gid_t gid) {
if (access(path.c_str(), F_OK) != 0) {
PLOG(WARNING) << "Dir does not exist: " << path;

@ -50,6 +50,8 @@ extern bool sSleepOnUnmount;
status_t CreateDeviceNode(const std::string& path, dev_t dev);
status_t DestroyDeviceNode(const std::string& path);
status_t AbortFuseConnections();
int SetQuotaInherit(const std::string& path);
int SetQuotaProjectId(const std::string& path, long projectId);
/*

@ -175,6 +175,13 @@ binder::Status VoldNativeService::shutdown() {
return translate(VolumeManager::Instance()->shutdown());
}
binder::Status VoldNativeService::abortFuse() {
ENFORCE_SYSTEM_OR_ROOT;
ACQUIRE_LOCK;
return translate(VolumeManager::Instance()->abortFuse());
}
binder::Status VoldNativeService::onUserAdded(int32_t userId, int32_t userSerial) {
ENFORCE_SYSTEM_OR_ROOT;
ACQUIRE_LOCK;

@ -36,6 +36,7 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
binder::Status monitor();
binder::Status reset();
binder::Status shutdown();
binder::Status abortFuse();
binder::Status onUserAdded(int32_t userId, int32_t userSerial);
binder::Status onUserRemoved(int32_t userId);

@ -905,6 +905,10 @@ int VolumeManager::remountAppStorageDirs(int uid, int pid,
return 0;
}
int VolumeManager::abortFuse() {
return android::vold::AbortFuseConnections();
}
int VolumeManager::reset() {
// Tear down all existing disks/volumes and start from a blank slate so
// newly connected framework hears all events.
@ -940,6 +944,7 @@ int VolumeManager::shutdown() {
mDisks.clear();
mPendingDisks.clear();
android::vold::sSleepOnUnmount = true;
return 0;
}

@ -120,6 +120,8 @@ class VolumeManager {
int remountUid(uid_t uid, int32_t remountMode);
int remountAppStorageDirs(int uid, int pid, const std::vector<std::string>& packageNames);
/* Aborts all FUSE filesystems, in case the FUSE daemon is no longer up. */
int abortFuse();
/* Reset all internal state, typically during framework boot */
int reset();
/* Prepare for device shutdown, safely unmounting all devices */

@ -25,6 +25,7 @@ import android.os.IVoldTaskListener;
interface IVold {
void setListener(IVoldListener listener);
void abortFuse();
void monitor();
void reset();
void shutdown();

@ -99,6 +99,8 @@ int main(int argc, char** argv) {
checkStatus(args, vold->fdeEnable(passwordType, "", encryptionFlags));
} else if (args[0] == "cryptfs" && args[1] == "mountdefaultencrypted") {
checkStatus(args, vold->mountDefaultEncrypted());
} else if (args[0] == "volume" && args[1] == "abort_fuse") {
checkStatus(args, vold->abortFuse());
} else if (args[0] == "volume" && args[1] == "shutdown") {
checkStatus(args, vold->shutdown());
} else if (args[0] == "volume" && args[1] == "reset") {

Loading…
Cancel
Save