Undo Utils dependency on VolumeManager
I want to use Utils in another executable, so breaking this link. Bug: 25861755 Test: compiles (and boots, though that doesn't exercise changed code) Change-Id: I6bb447453bb370fefb7f2f3aceb459428bdee6a7
This commit is contained in:
parent
4ddf576ca8
commit
56292ef119
4 changed files with 16 additions and 17 deletions
20
Utils.cpp
20
Utils.cpp
|
@ -14,10 +14,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sehandle.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "VolumeManager.h"
|
#include "sehandle.h"
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
@ -55,6 +55,8 @@ security_context_t sBlkidUntrustedContext = nullptr;
|
||||||
security_context_t sFsckContext = nullptr;
|
security_context_t sFsckContext = nullptr;
|
||||||
security_context_t sFsckUntrustedContext = nullptr;
|
security_context_t sFsckUntrustedContext = nullptr;
|
||||||
|
|
||||||
|
bool sSleepOnUnmount = true;
|
||||||
|
|
||||||
static const char* kBlkidPath = "/system/bin/blkid";
|
static const char* kBlkidPath = "/system/bin/blkid";
|
||||||
static const char* kKeyPath = "/data/misc/vold";
|
static const char* kKeyPath = "/data/misc/vold";
|
||||||
|
|
||||||
|
@ -134,22 +136,22 @@ status_t ForceUnmount(const std::string& path) {
|
||||||
}
|
}
|
||||||
// Apps might still be handling eject request, so wait before
|
// Apps might still be handling eject request, so wait before
|
||||||
// we start sending signals
|
// we start sending signals
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
|
|
||||||
KillProcessesWithOpenFiles(path, SIGINT);
|
KillProcessesWithOpenFiles(path, SIGINT);
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
KillProcessesWithOpenFiles(path, SIGTERM);
|
KillProcessesWithOpenFiles(path, SIGTERM);
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
KillProcessesWithOpenFiles(path, SIGKILL);
|
KillProcessesWithOpenFiles(path, SIGKILL);
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -161,17 +163,17 @@ status_t KillProcessesUsingPath(const std::string& path) {
|
||||||
if (KillProcessesWithOpenFiles(path, SIGINT) == 0) {
|
if (KillProcessesWithOpenFiles(path, SIGINT) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
|
|
||||||
if (KillProcessesWithOpenFiles(path, SIGTERM) == 0) {
|
if (KillProcessesWithOpenFiles(path, SIGTERM) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
|
|
||||||
if (KillProcessesWithOpenFiles(path, SIGKILL) == 0) {
|
if (KillProcessesWithOpenFiles(path, SIGKILL) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
if (!VolumeManager::shutting_down) sleep(5);
|
if (sSleepOnUnmount) sleep(5);
|
||||||
|
|
||||||
// Send SIGKILL a second time to determine if we've
|
// Send SIGKILL a second time to determine if we've
|
||||||
// actually killed everyone with open files
|
// actually killed everyone with open files
|
||||||
|
|
3
Utils.h
3
Utils.h
|
@ -38,6 +38,9 @@ extern security_context_t sBlkidUntrustedContext;
|
||||||
extern security_context_t sFsckContext;
|
extern security_context_t sFsckContext;
|
||||||
extern security_context_t sFsckUntrustedContext;
|
extern security_context_t sFsckUntrustedContext;
|
||||||
|
|
||||||
|
// TODO remove this with better solution, b/64143519
|
||||||
|
extern bool sSleepOnUnmount;
|
||||||
|
|
||||||
status_t CreateDeviceNode(const std::string& path, dev_t dev);
|
status_t CreateDeviceNode(const std::string& path, dev_t dev);
|
||||||
status_t DestroyDeviceNode(const std::string& path);
|
status_t DestroyDeviceNode(const std::string& path);
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
using android::base::StringPrintf;
|
using android::base::StringPrintf;
|
||||||
using android::base::unique_fd;
|
using android::base::unique_fd;
|
||||||
|
|
||||||
bool VolumeManager::shutting_down = false;
|
|
||||||
|
|
||||||
static const char* kPathUserMount = "/mnt/user";
|
static const char* kPathUserMount = "/mnt/user";
|
||||||
static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
|
static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
|
||||||
|
|
||||||
|
@ -535,14 +533,14 @@ int VolumeManager::shutdown() {
|
||||||
if (mInternalEmulated == nullptr) {
|
if (mInternalEmulated == nullptr) {
|
||||||
return 0; // already shutdown
|
return 0; // already shutdown
|
||||||
}
|
}
|
||||||
shutting_down = true;
|
android::vold::sSleepOnUnmount = false;
|
||||||
mInternalEmulated->destroy();
|
mInternalEmulated->destroy();
|
||||||
mInternalEmulated = nullptr;
|
mInternalEmulated = nullptr;
|
||||||
for (const auto& disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->destroy();
|
disk->destroy();
|
||||||
}
|
}
|
||||||
mDisks.clear();
|
mDisks.clear();
|
||||||
shutting_down = false;
|
android::vold::sSleepOnUnmount = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,6 @@
|
||||||
#define DEBUG_APPFUSE 0
|
#define DEBUG_APPFUSE 0
|
||||||
|
|
||||||
class VolumeManager {
|
class VolumeManager {
|
||||||
public:
|
|
||||||
//TODO remove this with better solution, b/64143519
|
|
||||||
static bool shutting_down;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static VolumeManager *sInstance;
|
static VolumeManager *sInstance;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue