int main() { VolumeManager *vm; CommandListener *cl; NetlinkManager *nm; SLOGI("Vold 2.1 (the revenge) firing up"); mkdir("/dev/block/vold", 0755); /* Create our singleton managers */ if (!(vm = VolumeManager::Instance())) { SLOGE("Unable to create VolumeManager"); exit(1); }; if (!(nm = NetlinkManager::Instance())) { SLOGE("Unable to create NetlinkManager"); exit(1); }; cl = new CommandListener(); vm->setBroadcaster((SocketListener *) cl); nm->setBroadcaster((SocketListener *) cl); if (vm->start()) { SLOGE("Unable to start VolumeManager (%s)", strerror(errno)); exit(1); } if (process_config(vm)) { SLOGE("Error reading configuration (%s)... continuing anyways", strerror(errno)); } if (nm->start()) { SLOGE("Unable to start NetlinkManager (%s)", strerror(errno)); exit(1); } coldboot("/sys/block"); // coldboot("/sys/class/switch"); /* * Now that we're up, we can respond to commands */ if (cl->startListener()) { SLOGE("Unable to start CommandListener (%s)", strerror(errno)); exit(1); } // Eventually we'll become the monitoring thread while(1) { sleep(1000); } SLOGI("Vold exiting"); exit(0); }
int CommandListener::ObbCmd::runCommand(SocketClient *cli, int argc, char **argv) { if (argc < 2) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); return 0; } VolumeManager *vm = VolumeManager::Instance(); int rc = 0; if (!strcmp(argv[1], "list")) { dumpArgs(argc, argv, -1); rc = vm->listMountedObbs(cli); } else if (!strcmp(argv[1], "mount")) { dumpArgs(argc, argv, 3); if (argc != 5) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: obb mount <filename> <key> <ownerUid>", false); return 0; } rc = vm->mountObb(argv[2], argv[3], atoi(argv[4])); } else if (!strcmp(argv[1], "unmount")) { dumpArgs(argc, argv, -1); if (argc < 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: obb unmount <source file> [force]", false); return 0; } bool force = false; if (argc > 3 && !strcmp(argv[3], "force")) { force = true; } rc = vm->unmountObb(argv[2], force); } else if (!strcmp(argv[1], "path")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: obb path <source file>", false); return 0; } char path[255]; if (!(rc = vm->getObbMountPath(argv[2], path, sizeof(path)))) { cli->sendMsg(ResponseCode::AsecPathResult, path, false); return 0; } } else { dumpArgs(argc, argv, -1); cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown obb cmd", false); } if (!rc) { cli->sendMsg(ResponseCode::CommandOkay, "obb operation succeeded", false); } else { rc = ResponseCode::convertFromErrno(); cli->sendMsg(rc, "obb operation failed", true); } return 0; }
extern "C" int vold_unmountAllAsecs(void) { int rc; VolumeManager *vm = VolumeManager::Instance(); rc = vm->unmountAllAsecsInDir(Volume::SEC_ASECDIR_EXT); if (vm->unmountAllAsecsInDir(Volume::SEC_ASECDIR_INT)) { rc = -1; } return rc; }
TrimTask::TrimTask(int flags) : mFlags(flags) { // Collect both fstab and vold volumes addFromFstab(); VolumeManager* vm = VolumeManager::Instance(); std::list<std::string> privateIds; vm->listVolumes(VolumeBase::Type::kPrivate, privateIds); for (const auto& id : privateIds) { auto vol = vm->findVolume(id); if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) { mPaths.push_back(vol->getPath()); } } }
// netfs_free_query_cookie static int netfs_free_query_cookie(void *ns, void *node, void *cookie) { VolumeManager* volumeManager = (VolumeManager*)ns; QueryIterator* iterator = (QueryIterator*)cookie; PRINT("netfs_free_query_cookie(%p, %p)\n", ns, cookie); status_t error = B_OK; volumeManager->GetQueryManager()->PutIterator(iterator); PRINT("netfs_free_query_cookie() done: (%" B_PRIx32 ")\n", error); return error; }
// GetNode Node* ClientVolume::GetNode(dev_t volumeID, ino_t nodeID) { VolumeManager* volumeManager = VolumeManager::GetDefault(); // get the node Node* node = volumeManager->GetNode(volumeID, nodeID); if (!node) return NULL; // check, if the node is contained by the root dir of the client volume if (volumeManager->DirectoryContains(GetRootDirectory(), node, true)) return node; return NULL; }
// GetEntry Entry* ClientVolume::GetEntry(dev_t volumeID, ino_t dirID, const char* name) { VolumeManager* volumeManager = VolumeManager::GetDefault(); // get the entry Entry* entry = volumeManager->GetEntry(volumeID, dirID, name); if (!entry) return NULL; // check, if the entry is contained by the root dir of the client volume if (volumeManager->DirectoryContains(GetRootDirectory(), entry)) return entry; return NULL; }
// GetDirectory Directory* ClientVolume::GetDirectory(dev_t volumeID, ino_t nodeID) { VolumeManager* volumeManager = VolumeManager::GetDefault(); // get the directory Directory* dir = GetDirectory(volumeID, nodeID); if (!dir) return NULL; // check, if the dir is contained by the root dir of the client volume if (volumeManager->DirectoryContains(GetRootDirectory(), dir, true)) return dir; return NULL; }
// netfs_write_fs_stat static int netfs_write_fs_stat(void *ns, struct fs_info *info, long mask) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetRootVolume(); VolumePutter _(volume); PRINT("netfs_write_fs_stat(%p, %p, %ld)\n", ns, info, mask); status_t error = B_BAD_VALUE; if (volume) error = volume->WriteFSStat(info, mask); PRINT("netfs_write_fs_stat() done: %" B_PRIx32 " \n", error); return error; }
void NetlinkHandler::onEvent(NetlinkEvent *evt) { VolumeManager *vm = VolumeManager::Instance(); const char *subsys = evt->getSubsystem(); if (!subsys) { SLOGW("No subsystem found in netlink event"); return; } if (!strcmp(subsys, "block")) { vm->handleBlockEvent(evt); } #if defined(BOARD_USES_HDMI) || defined(S5P_BOARD_USES_HDMI) else if ((!strcmp(subsys, "misc")) || (!strcmp(subsys, "video4linux"))) { vm->handleMiscEvent(evt); } #endif }
// netfs_read_vnode static int netfs_read_vnode(void *ns, vnode_id vnid, char reenter, void **node) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetVolume(vnid); VolumePutter _(volume); PRINT(("netfs_read_vnode(%p, %Ld, %d, %p)\n", ns, vnid, reenter, node)); status_t error = B_BAD_VALUE; if (volume) error = volume->ReadVNode(vnid, reenter, (Node**)node); PRINT(("netfs_read_vnode() done: (%lx, %p)\n", error, *node)); return error; }
// netfs_read_fs_stat static int netfs_read_fs_stat(void *ns, struct fs_info *info) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetRootVolume(); VolumePutter _(volume); PRINT(("netfs_read_fs_stat(%p, %p)\n", ns, info)); status_t error = B_BAD_VALUE; if (volume) error = volume->ReadFSStat(info); PRINT(("netfs_read_fs_stat() done: %lx \n", error)); return error; }
// netfs_sync static int netfs_sync(void *ns) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetRootVolume(); VolumePutter _(volume); PRINT("netfs_sync(%p)\n", ns); status_t error = B_BAD_VALUE; if (volume) error = volume->Sync(); PRINT("netfs_sync() done: %" B_PRIx32 " \n", error); return error; }
// Mount status_t ClientVolume::Mount(UserSecurityContext* securityContext, Share* share) { if (!securityContext || !share) return B_BAD_VALUE; ObjectDeleter<UserSecurityContext> securityContextDeleter(securityContext); if (IsMounted()) return B_BAD_VALUE; fSecurityContext = securityContext; securityContextDeleter.Detach(); fShare = share; fShare->AcquireReference(); dev_t volumeID = share->GetVolumeID(); ino_t nodeID = share->GetNodeID(); // into root node ref fRootNodeRef.device = volumeID; fRootNodeRef.node = nodeID; // get the share permissions fSharePermissions = securityContext->GetNodePermissions(volumeID, nodeID); // get the root directory VolumeManager* volumeManager = VolumeManager::GetDefault(); Directory* rootDir; status_t error = volumeManager->LoadDirectory(volumeID, nodeID, &rootDir); if (error != B_OK) return error; // register with the volume manager error = volumeManager->AddClientVolume(this); if (error != B_OK) { Unmount(); return error; } fMounted = true; // notify the statistics manager StatisticsManager::GetDefault()->ShareMounted(fShare, fSecurityContext->GetUser()); return B_OK; }
void NetlinkHandler::onEvent(NetlinkEvent *evt) { VolumeManager *vm = VolumeManager::Instance(); const char *subsys = evt->getSubsystem(); if (!subsys) { SLOGW("No subsystem found in netlink event"); return; } if (!strcmp(subsys, "block")) { vm->handleBlockEvent(evt); } else if (!strcmp(subsys, "switch")) { vm->handleSwitchEvent(evt); } else if (!strcmp(subsys, "usb_composite")) { vm->handleUsbCompositeEvent(evt); } else if (!strcmp(subsys, "battery")) { } else if (!strcmp(subsys, "power_supply")) { } }
// netfs_unmount static int netfs_unmount(void *ns) { VolumeManager* volumeManager = (VolumeManager*)ns; PRINT("netfs_unmount()\n"); volumeManager->UnmountRootVolume(); delete volumeManager; #ifdef DEBUG_OBJECT_TRACKING ObjectTracker::ExitDefault(); #endif PRINT("netfs_unmount() done\n"); exit_debugging(); return B_OK; }
// netfs_open_query static int netfs_open_query(void *ns, const char *queryString, ulong flags, port_id port, long token, void **cookie) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetRootVolume(); VolumePutter _(volume); PRINT("netfs_open_query(%p, `%s', %lu, %" B_PRId32 ", %ld, %p)\n", ns, queryString, flags, port, token, cookie); status_t error = B_BAD_VALUE; if (volume) { error = volume->OpenQuery(queryString, flags, port, token, (QueryIterator**)cookie); } PRINT("netfs_open_query() done: (%" B_PRIx32 ", %p)\n", error, *cookie); return error; }
// LoadDirectory status_t ClientVolume::LoadDirectory(dev_t volumeID, ino_t nodeID, Directory** _directory) { if (!_directory) return B_BAD_VALUE; VolumeManager* volumeManager = VolumeManager::GetDefault(); // load the directory Directory* dir; status_t error = volumeManager->LoadDirectory(volumeID, nodeID, &dir); if (error != B_OK) return error; // check, if the dir is contained by the root dir of the client volume if (!volumeManager->DirectoryContains(GetRootDirectory(), dir, true)) return B_ENTRY_NOT_FOUND; *_directory = dir; return B_OK; }
// netfs_read_query static int netfs_read_query(void *ns, void *cookie, long *count, struct dirent *buffer, size_t bufferSize) { VolumeManager* volumeManager = (VolumeManager*)ns; Volume* volume = volumeManager->GetRootVolume(); QueryIterator* iterator = (QueryIterator*)cookie; VolumePutter _(volume); PRINT(("netfs_read_query(%p, %p, %ld, %p, %lu)\n", ns, cookie, *count, buffer, bufferSize)); status_t error = B_BAD_VALUE; if (volume) { error = volume->ReadQuery(iterator, buffer, bufferSize, *count, count); } PRINT(("netfs_read_query() done: (%lx, %ld)\n", error, *count)); return error; }
// netfs_mount static int netfs_mount(nspace_id nsid, const char *device, ulong flags, void *parameters, size_t len, void **data, vnode_id *rootID) { status_t error = B_OK; init_debugging(); #ifdef DEBUG_OBJECT_TRACKING ObjectTracker::InitDefault(); #endif // create and init the volume manager VolumeManager* volumeManager = new(std::nothrow) VolumeManager(nsid, flags); Volume* rootVolume = NULL; if (volumeManager) { error = volumeManager->MountRootVolume(device, (const char*)parameters, len, &rootVolume); if (error != B_OK) { delete volumeManager; volumeManager = NULL; } } else error = B_NO_MEMORY; VolumePutter _(rootVolume); // set results if (error == B_OK) { *data = volumeManager; *rootID = rootVolume->GetRootID(); } else { #ifdef DEBUG_OBJECT_TRACKING ObjectTracker::ExitDefault(); #endif exit_debugging(); } return error; }
// LoadEntry status_t ClientVolume::LoadEntry(dev_t volumeID, ino_t dirID, const char* name, Entry** _entry) { if (!name || !_entry) return B_BAD_VALUE; VolumeManager* volumeManager = VolumeManager::GetDefault(); // get the entry Entry* entry; status_t error = VolumeManager::GetDefault()->LoadEntry(volumeID, dirID, name, true, &entry); if (error != B_OK) return error; // check, if the entry is contained by the root dir of the client volume if (!volumeManager->DirectoryContains(GetRootDirectory(), entry)) return B_ENTRY_NOT_FOUND; *_entry = entry; return B_OK; }
int CommandListener::AsecCmd::runCommand(SocketClient *cli, int argc, char **argv) { if (argc < 2) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); return 0; } VolumeManager *vm = VolumeManager::Instance(); int rc = 0; if (!strcmp(argv[1], "list")) { dumpArgs(argc, argv, -1); DIR *d = opendir(Volume::SEC_ASECDIR); if (!d) { cli->sendMsg(ResponseCode::OperationFailed, "Failed to open asec dir", true); return 0; } struct dirent *dent; while ((dent = readdir(d))) { if (dent->d_name[0] == '.') continue; if (!strcmp(&dent->d_name[strlen(dent->d_name)-5], ".asec")) { char id[255]; memset(id, 0, sizeof(id)); strncpy(id, dent->d_name, strlen(dent->d_name) -5); cli->sendMsg(ResponseCode::AsecListResult, id, false); } } closedir(d); } else if (!strcmp(argv[1], "create")) { dumpArgs(argc, argv, 5); if (argc != 7) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec create <container-id> <size_mb> <fstype> <key> <ownerUid>", false); return 0; } unsigned int numSectors = (atoi(argv[3]) * (1024 * 1024)) / 512; rc = vm->createAsec(argv[2], numSectors, argv[4], argv[5], atoi(argv[6])); } else if (!strcmp(argv[1], "finalize")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec finalize <container-id>", false); return 0; } rc = vm->finalizeAsec(argv[2]); } else if (!strcmp(argv[1], "destroy")) { dumpArgs(argc, argv, -1); if (argc < 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec destroy <container-id> [force]", false); return 0; } bool force = false; if (argc > 3 && !strcmp(argv[3], "force")) { force = true; } rc = vm->destroyAsec(argv[2], force); } else if (!strcmp(argv[1], "mount")) { dumpArgs(argc, argv, 3); if (argc != 5) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec mount <namespace-id> <key> <ownerUid>", false); return 0; } rc = vm->mountAsec(argv[2], argv[3], atoi(argv[4])); } else if (!strcmp(argv[1], "unmount")) { dumpArgs(argc, argv, -1); if (argc < 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec unmount <container-id> [force]", false); return 0; } bool force = false; if (argc > 3 && !strcmp(argv[3], "force")) { force = true; } rc = vm->unmountAsec(argv[2], force); } else if (!strcmp(argv[1], "rename")) { dumpArgs(argc, argv, -1); if (argc != 4) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec rename <old_id> <new_id>", false); return 0; } rc = vm->renameAsec(argv[2], argv[3]); } else if (!strcmp(argv[1], "path")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec path <container-id>", false); return 0; } char path[255]; if (!(rc = vm->getAsecMountPath(argv[2], path, sizeof(path)))) { cli->sendMsg(ResponseCode::AsecPathResult, path, false); return 0; } } else if (!strcmp(argv[1], "fspath")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fspath <container-id>", false); return 0; } char path[255]; if (!(rc = vm->getAsecFilesystemPath(argv[2], path, sizeof(path)))) { cli->sendMsg(ResponseCode::AsecPathResult, path, false); return 0; } } else { dumpArgs(argc, argv, -1); cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown asec cmd", false); } if (!rc) { cli->sendMsg(ResponseCode::CommandOkay, "asec operation succeeded", false); } else { rc = ResponseCode::convertFromErrno(); cli->sendMsg(rc, "asec operation failed", true); } return 0; }
int CommandListener::VolumeCmd::runCommand(SocketClient *cli, int argc, char **argv) { dumpArgs(argc, argv, -1); if (argc < 2) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); return 0; } VolumeManager *vm = VolumeManager::Instance(); int rc = 0; if (!strcmp(argv[1], "list")) { return vm->listVolumes(cli); } else if (!strcmp(argv[1], "debug")) { if (argc != 3 || (argc == 3 && (strcmp(argv[2], "off") && strcmp(argv[2], "on")))) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume debug <off/on>", false); return 0; } vm->setDebug(!strcmp(argv[2], "on") ? true : false); } else if (!strcmp(argv[1], "mount")) { if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume mount <path>", false); return 0; } rc = vm->mountVolume(argv[2]); } else if (!strcmp(argv[1], "unmount")) { if (argc < 3 || argc > 4 || ((argc == 4 && strcmp(argv[3], "force")) && (argc == 4 && strcmp(argv[3], "force_and_revert")))) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume unmount <path> [force|force_and_revert]", false); return 0; } bool force = false; bool revert = false; if (argc >= 4 && !strcmp(argv[3], "force")) { force = true; } else if (argc >= 4 && !strcmp(argv[3], "force_and_revert")) { force = true; revert = true; } rc = vm->unmountVolume(argv[2], force, revert); } else if (!strcmp(argv[1], "format")) { if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume format <path>", false); return 0; } rc = vm->formatVolume(argv[2]); } else if (!strcmp(argv[1], "share")) { if (argc != 4) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume share <path> <method>", false); return 0; } rc = vm->shareVolume(argv[2], argv[3]); } else if (!strcmp(argv[1], "unshare")) { if (argc != 4) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume unshare <path> <method>", false); return 0; } rc = vm->unshareVolume(argv[2], argv[3]); } else if (!strcmp(argv[1], "shared")) { bool enabled = false; if (argc != 4) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume shared <path> <method>", false); return 0; } if (vm->shareEnabled(argv[2], argv[3], &enabled)) { cli->sendMsg( ResponseCode::OperationFailed, "Failed to determine share enable state", true); } else { cli->sendMsg(ResponseCode::ShareEnabledResult, (enabled ? "Share enabled" : "Share disabled"), false); } return 0; } else { cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume cmd", false); } if (!rc) { cli->sendMsg(ResponseCode::CommandOkay, "volume operation succeeded", false); } else { int erno = errno; rc = ResponseCode::convertFromErrno(); cli->sendMsg(rc, "volume operation failed", true); } return 0; }
int CommandListener::AsecCmd::runCommand(SocketClient *cli, int argc, char **argv) { if (argc < 2) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); return 0; } VolumeManager *vm = VolumeManager::Instance(); int rc = 0; if (!strcmp(argv[1], "list")) { dumpArgs(argc, argv, -1); listAsecsInDirectory(cli, Volume::SEC_ASECDIR_EXT); listAsecsInDirectory(cli, Volume::SEC_ASECDIR_INT); } else if (!strcmp(argv[1], "create")) { dumpArgs(argc, argv, 5); if (argc != 8) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec create <container-id> <size_mb> <fstype> <key> <ownerUid> " "<isExternal>", false); return 0; } unsigned int numSectors = (atoi(argv[3]) * (1024 * 1024)) / 512; const bool isExternal = (atoi(argv[7]) == 1); rc = vm->createAsec(argv[2], numSectors, argv[4], argv[5], atoi(argv[6]), isExternal); } else if (!strcmp(argv[1], "finalize")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec finalize <container-id>", false); return 0; } rc = vm->finalizeAsec(argv[2]); } else if (!strcmp(argv[1], "fixperms")) { dumpArgs(argc, argv, -1); if (argc != 5) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fixperms <container-id> <gid> <filename>", false); return 0; } char *endptr; gid_t gid = (gid_t) strtoul(argv[3], &endptr, 10); if (*endptr != '\0') { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fixperms <container-id> <gid> <filename>", false); return 0; } rc = vm->fixupAsecPermissions(argv[2], gid, argv[4]); } else if (!strcmp(argv[1], "destroy")) { dumpArgs(argc, argv, -1); if (argc < 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec destroy <container-id> [force]", false); return 0; } bool force = false; if (argc > 3 && !strcmp(argv[3], "force")) { force = true; } rc = vm->destroyAsec(argv[2], force); } else if (!strcmp(argv[1], "mount")) { dumpArgs(argc, argv, 3); if (argc != 5) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec mount <namespace-id> <key> <ownerUid>", false); return 0; } rc = vm->mountAsec(argv[2], argv[3], atoi(argv[4])); } else if (!strcmp(argv[1], "unmount")) { dumpArgs(argc, argv, -1); if (argc < 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec unmount <container-id> [force]", false); return 0; } bool force = false; if (argc > 3 && !strcmp(argv[3], "force")) { force = true; } rc = vm->unmountAsec(argv[2], force); } else if (!strcmp(argv[1], "rename")) { dumpArgs(argc, argv, -1); if (argc != 4) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec rename <old_id> <new_id>", false); return 0; } rc = vm->renameAsec(argv[2], argv[3]); } else if (!strcmp(argv[1], "path")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec path <container-id>", false); return 0; } char path[255]; if (!(rc = vm->getAsecMountPath(argv[2], path, sizeof(path)))) { cli->sendMsg(ResponseCode::AsecPathResult, path, false); return 0; } } else if (!strcmp(argv[1], "fspath")) { dumpArgs(argc, argv, -1); if (argc != 3) { cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fspath <container-id>", false); return 0; } char path[255]; if (!(rc = vm->getAsecFilesystemPath(argv[2], path, sizeof(path)))) { cli->sendMsg(ResponseCode::AsecPathResult, path, false); return 0; } } else { dumpArgs(argc, argv, -1); cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown asec cmd", false); } if (!rc) { cli->sendMsg(ResponseCode::CommandOkay, "asec operation succeeded", false); } else { rc = ResponseCode::convertFromErrno(); cli->sendMsg(rc, "asec operation failed", true); } return 0; }
extern "C" int vold_getDirectVolumeList(struct volume_info *vol_list) { VolumeManager *vm = VolumeManager::Instance(); return vm->getDirectVolumeList(vol_list); }
extern "C" int vold_getNumDirectVolumes(void) { VolumeManager *vm = VolumeManager::Instance(); return vm->getNumDirectVolumes(); }
extern "C" int vold_disableVol(const char *label) { VolumeManager *vm = VolumeManager::Instance(); vm->disableVolumeManager(); vm->unshareVolume(label, "ums"); return vm->unmountVolume(label, true, false); }