本文整理汇总了C++中VolumeManager类的典型用法代码示例。如果您正苦于以下问题:C++ VolumeManager类的具体用法?C++ VolumeManager怎么用?C++ VolumeManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VolumeManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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);
}
示例2: dumpArgs
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;
}
示例3: vold_unmountAllAsecs
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;
}
示例4: mFlags
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());
}
}
}
示例5: netfs_free_query_cookie
// 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;
}
示例6:
// 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;
}
示例7: GetDirectory
// 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;
}
示例8: netfs_write_fs_stat
// 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;
}
示例9: onEvent
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
}
示例10: netfs_read_vnode
// 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;
}
示例11: netfs_read_fs_stat
// 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;
}
示例12: netfs_sync
// 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;
}
示例13: securityContextDeleter
// 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;
}
示例14: onEvent
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")) {
}
}
示例15: netfs_unmount
// 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;
}