Long live Binder. Test: yes Bug: 13758960 Change-Id: If6be379b5a873f1b0c66dd1522b87413ad10fc46gugelfrei
parent
5820b51c22
commit
cbe69fc060
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ASEC_H
|
|
||||||
#define _ASEC_H
|
|
||||||
|
|
||||||
struct asec_superblock {
|
|
||||||
#define ASEC_SB_MAGIC 0xc0def00d
|
|
||||||
unsigned int magic;
|
|
||||||
|
|
||||||
#define ASEC_SB_VER 1
|
|
||||||
unsigned char ver;
|
|
||||||
|
|
||||||
#define ASEC_SB_C_CIPHER_NONE 0
|
|
||||||
#define ASEC_SB_C_CIPHER_TWOFISH 1
|
|
||||||
#define ASEC_SB_C_CIPHER_AES 2
|
|
||||||
unsigned char c_cipher;
|
|
||||||
|
|
||||||
#define ASEC_SB_C_CHAIN_NONE 0
|
|
||||||
unsigned char c_chain;
|
|
||||||
|
|
||||||
#define ASEC_SB_C_OPTS_NONE 0
|
|
||||||
#define ASEC_SB_C_OPTS_EXT4 1
|
|
||||||
unsigned char c_opts;
|
|
||||||
|
|
||||||
#define ASEC_SB_C_MODE_NONE 0
|
|
||||||
unsigned char c_mode;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,689 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <fs_mgr.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#define LOG_TAG "VoldCmdListener"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <android-base/stringprintf.h>
|
|
||||||
#include <android-base/unique_fd.h>
|
|
||||||
#include <cutils/fs.h>
|
|
||||||
|
|
||||||
#include <sysutils/SocketClient.h>
|
|
||||||
#include <private/android_filesystem_config.h>
|
|
||||||
|
|
||||||
#include "CommandListener.h"
|
|
||||||
#include "VolumeManager.h"
|
|
||||||
#include "model/VolumeBase.h"
|
|
||||||
#include "ResponseCode.h"
|
|
||||||
#include "Process.h"
|
|
||||||
#include "Loop.h"
|
|
||||||
#include "Devmapper.h"
|
|
||||||
#include "MoveTask.h"
|
|
||||||
#include "TrimTask.h"
|
|
||||||
|
|
||||||
#define DUMP_ARGS 0
|
|
||||||
|
|
||||||
using android::base::unique_fd;
|
|
||||||
|
|
||||||
CommandListener::CommandListener() :
|
|
||||||
FrameworkListener("vold", true) {
|
|
||||||
registerCmd(new DumpCmd());
|
|
||||||
registerCmd(new VolumeCmd());
|
|
||||||
registerCmd(new AsecCmd());
|
|
||||||
registerCmd(new ObbCmd());
|
|
||||||
registerCmd(new StorageCmd());
|
|
||||||
registerCmd(new FstrimCmd());
|
|
||||||
registerCmd(new AppFuseCmd());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DUMP_ARGS
|
|
||||||
void CommandListener::dumpArgs(int argc, char **argv, int argObscure) {
|
|
||||||
char buffer[4096];
|
|
||||||
char *p = buffer;
|
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < argc; i++) {
|
|
||||||
unsigned int len = strlen(argv[i]) + 1; // Account for space
|
|
||||||
if (i == argObscure) {
|
|
||||||
len += 2; // Account for {}
|
|
||||||
}
|
|
||||||
if (((p - buffer) + len) < (sizeof(buffer)-1)) {
|
|
||||||
if (i == argObscure) {
|
|
||||||
*p++ = '{';
|
|
||||||
*p++ = '}';
|
|
||||||
*p++ = ' ';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
strcpy(p, argv[i]);
|
|
||||||
p+= strlen(argv[i]);
|
|
||||||
if (i != (argc -1)) {
|
|
||||||
*p++ = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SLOGD("%s", buffer);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void CommandListener::dumpArgs(int /*argc*/, char ** /*argv*/, int /*argObscure*/) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int CommandListener::sendGenericOkFail(SocketClient *cli, int cond) {
|
|
||||||
if (!cond) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandOkay, "Command succeeded", false);
|
|
||||||
} else {
|
|
||||||
return cli->sendMsg(ResponseCode::OperationFailed, "Command failed", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::DumpCmd::DumpCmd() :
|
|
||||||
VoldCommand("dump") {
|
|
||||||
}
|
|
||||||
|
|
||||||
int CommandListener::DumpCmd::runCommand(SocketClient *cli,
|
|
||||||
int /*argc*/, char ** /*argv*/) {
|
|
||||||
cli->sendMsg(0, "Dumping loop status", false);
|
|
||||||
if (Loop::dumpState(cli)) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "Loop dump failed", true);
|
|
||||||
}
|
|
||||||
cli->sendMsg(0, "Dumping DM status", false);
|
|
||||||
if (Devmapper::dumpState(cli)) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "Devmapper dump failed", true);
|
|
||||||
}
|
|
||||||
cli->sendMsg(0, "Dumping mounted filesystems", false);
|
|
||||||
FILE *fp = fopen("/proc/mounts", "re");
|
|
||||||
if (fp) {
|
|
||||||
char line[1024];
|
|
||||||
while (fgets(line, sizeof(line), fp)) {
|
|
||||||
line[strlen(line)-1] = '\0';
|
|
||||||
cli->sendMsg(0, line, false);;
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "dump complete", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::VolumeCmd::VolumeCmd() :
|
|
||||||
VoldCommand("volume") {
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
std::lock_guard<std::mutex> lock(vm->getLock());
|
|
||||||
|
|
||||||
// TODO: tease out methods not directly related to volumes
|
|
||||||
|
|
||||||
std::string cmd(argv[1]);
|
|
||||||
if (cmd == "reset") {
|
|
||||||
return sendGenericOkFail(cli, vm->reset());
|
|
||||||
|
|
||||||
} else if (cmd == "shutdown") {
|
|
||||||
return sendGenericOkFail(cli, vm->shutdown());
|
|
||||||
|
|
||||||
} else if (cmd == "debug") {
|
|
||||||
return sendGenericOkFail(cli, vm->setDebug(true));
|
|
||||||
|
|
||||||
} else if (cmd == "partition" && argc > 3) {
|
|
||||||
// partition [diskId] [public|private|mixed] [ratio]
|
|
||||||
std::string id(argv[2]);
|
|
||||||
auto disk = vm->findDisk(id);
|
|
||||||
if (disk == nullptr) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown disk", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string type(argv[3]);
|
|
||||||
if (type == "public") {
|
|
||||||
return sendGenericOkFail(cli, disk->partitionPublic());
|
|
||||||
} else if (type == "private") {
|
|
||||||
return sendGenericOkFail(cli, disk->partitionPrivate());
|
|
||||||
} else if (type == "mixed") {
|
|
||||||
if (argc < 4) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false);
|
|
||||||
}
|
|
||||||
int frac = atoi(argv[4]);
|
|
||||||
return sendGenericOkFail(cli, disk->partitionMixed(frac));
|
|
||||||
} else {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (cmd == "mkdirs" && argc > 2) {
|
|
||||||
// mkdirs [path]
|
|
||||||
return sendGenericOkFail(cli, vm->mkdirs(argv[2]));
|
|
||||||
|
|
||||||
} else if (cmd == "user_added" && argc > 3) {
|
|
||||||
// user_added [user] [serial]
|
|
||||||
return sendGenericOkFail(cli, vm->onUserAdded(atoi(argv[2]), atoi(argv[3])));
|
|
||||||
|
|
||||||
} else if (cmd == "user_removed" && argc > 2) {
|
|
||||||
// user_removed [user]
|
|
||||||
return sendGenericOkFail(cli, vm->onUserRemoved(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (cmd == "user_started" && argc > 2) {
|
|
||||||
// user_started [user]
|
|
||||||
return sendGenericOkFail(cli, vm->onUserStarted(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (cmd == "user_stopped" && argc > 2) {
|
|
||||||
// user_stopped [user]
|
|
||||||
return sendGenericOkFail(cli, vm->onUserStopped(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (cmd == "mount" && argc > 2) {
|
|
||||||
// mount [volId] [flags] [user]
|
|
||||||
std::string id(argv[2]);
|
|
||||||
auto vol = vm->findVolume(id);
|
|
||||||
if (vol == nullptr) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mountFlags = (argc > 3) ? atoi(argv[3]) : 0;
|
|
||||||
userid_t mountUserId = (argc > 4) ? atoi(argv[4]) : -1;
|
|
||||||
|
|
||||||
vol->setMountFlags(mountFlags);
|
|
||||||
vol->setMountUserId(mountUserId);
|
|
||||||
|
|
||||||
int res = vol->mount();
|
|
||||||
if (mountFlags & android::vold::VolumeBase::MountFlags::kPrimary) {
|
|
||||||
vm->setPrimary(vol);
|
|
||||||
}
|
|
||||||
return sendGenericOkFail(cli, res);
|
|
||||||
|
|
||||||
} else if (cmd == "unmount" && argc > 2) {
|
|
||||||
// unmount [volId]
|
|
||||||
std::string id(argv[2]);
|
|
||||||
auto vol = vm->findVolume(id);
|
|
||||||
if (vol == nullptr) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendGenericOkFail(cli, vol->unmount());
|
|
||||||
|
|
||||||
} else if (cmd == "format" && argc > 3) {
|
|
||||||
// format [volId] [fsType|auto]
|
|
||||||
std::string id(argv[2]);
|
|
||||||
std::string fsType(argv[3]);
|
|
||||||
auto vol = vm->findVolume(id);
|
|
||||||
if (vol == nullptr) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendGenericOkFail(cli, vol->format(fsType));
|
|
||||||
|
|
||||||
} else if (cmd == "move_storage" && argc > 3) {
|
|
||||||
// move_storage [fromVolId] [toVolId]
|
|
||||||
auto fromVol = vm->findVolume(std::string(argv[2]));
|
|
||||||
auto toVol = vm->findVolume(std::string(argv[3]));
|
|
||||||
if (fromVol == nullptr || toVol == nullptr) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
(new android::vold::MoveTask(fromVol, toVol, nullptr))->start();
|
|
||||||
return sendGenericOkFail(cli, 0);
|
|
||||||
|
|
||||||
} else if (cmd == "benchmark" && argc > 2) {
|
|
||||||
// benchmark [volId]
|
|
||||||
std::string id(argv[2]);
|
|
||||||
LOG(WARNING) << "Benchmarking has moved to Binder interface";
|
|
||||||
nsecs_t res = 0;
|
|
||||||
return cli->sendMsg(ResponseCode::CommandOkay,
|
|
||||||
android::base::StringPrintf("%" PRId64, res).c_str(), false);
|
|
||||||
|
|
||||||
} else if (cmd == "forget_partition" && argc > 2) {
|
|
||||||
// forget_partition [partGuid]
|
|
||||||
std::string partGuid(argv[2]);
|
|
||||||
return sendGenericOkFail(cli, vm->forgetPartition(partGuid));
|
|
||||||
|
|
||||||
} else if (cmd == "remount_uid" && argc > 3) {
|
|
||||||
// remount_uid [uid] [none|default|read|write]
|
|
||||||
uid_t uid = atoi(argv[2]);
|
|
||||||
std::string mode(argv[3]);
|
|
||||||
return sendGenericOkFail(cli, vm->remountUid(uid, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::StorageCmd::StorageCmd() :
|
|
||||||
VoldCommand("storage") {
|
|
||||||
}
|
|
||||||
|
|
||||||
int CommandListener::StorageCmd::runCommand(SocketClient *cli,
|
|
||||||
int argc, char **argv) {
|
|
||||||
/* Guarantied to be initialized by vold's main() before the CommandListener is active */
|
|
||||||
extern struct fstab *fstab;
|
|
||||||
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "mountall")) {
|
|
||||||
if (argc != 2) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: mountall", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fs_mgr_mount_all(fstab, MOUNT_MODE_DEFAULT);
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "Mountall ran successfully", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!strcmp(argv[1], "users")) {
|
|
||||||
DIR *dir;
|
|
||||||
struct dirent *de;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument: user <mountpoint>", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!(dir = opendir("/proc"))) {
|
|
||||||
cli->sendMsg(ResponseCode::OperationFailed, "Failed to open /proc", true);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
|
||||||
int pid = Process::getPid(de->d_name);
|
|
||||||
|
|
||||||
if (pid < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string processName;
|
|
||||||
Process::getProcessName(pid, processName);
|
|
||||||
|
|
||||||
if (Process::checkFileDescriptorSymLinks(pid, argv[2]) ||
|
|
||||||
Process::checkFileMaps(pid, argv[2]) ||
|
|
||||||
Process::checkSymLink(pid, argv[2], "cwd") ||
|
|
||||||
Process::checkSymLink(pid, argv[2], "root") ||
|
|
||||||
Process::checkSymLink(pid, argv[2], "exe")) {
|
|
||||||
|
|
||||||
char msg[1024];
|
|
||||||
snprintf(msg, sizeof(msg), "%d %s", pid, processName.c_str());
|
|
||||||
cli->sendMsg(ResponseCode::StorageUsersListResult, msg, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(dir);
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "Storage user list complete", false);
|
|
||||||
} else {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown storage cmd", false);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::AsecCmd::AsecCmd() :
|
|
||||||
VoldCommand("asec") {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandListener::AsecCmd::listAsecsInDirectory(SocketClient *cli, const char *directory) {
|
|
||||||
DIR *d = opendir(directory);
|
|
||||||
|
|
||||||
if (!d) {
|
|
||||||
cli->sendMsg(ResponseCode::OperationFailed, "Failed to open asec dir", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dirent* dent;
|
|
||||||
while ((dent = readdir(d)) != NULL) {
|
|
||||||
if (dent->d_name[0] == '.')
|
|
||||||
continue;
|
|
||||||
if (dent->d_type != DT_REG)
|
|
||||||
continue;
|
|
||||||
size_t name_len = strlen(dent->d_name);
|
|
||||||
if (name_len > 5 && name_len < 260 &&
|
|
||||||
!strcmp(&dent->d_name[name_len - 5], ".asec")) {
|
|
||||||
char id[255];
|
|
||||||
memset(id, 0, sizeof(id));
|
|
||||||
strlcpy(id, dent->d_name, name_len - 4);
|
|
||||||
cli->sendMsg(ResponseCode::AsecListResult, id, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
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, VolumeManager::SEC_ASECDIR_EXT);
|
|
||||||
listAsecsInDirectory(cli, VolumeManager::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 long 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], "resize")) {
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
if (argc != 5) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec resize <container-id> <size_mb> <key>", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
unsigned long numSectors = (atoi(argv[3]) * (1024 * 1024)) / 512;
|
|
||||||
rc = vm->resizeAsec(argv[2], numSectors, argv[4]);
|
|
||||||
} 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 != 6) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError,
|
|
||||||
"Usage: asec mount <namespace-id> <key> <ownerUid> <ro|rw>", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
bool readOnly = true;
|
|
||||||
if (!strcmp(argv[5], "rw")) {
|
|
||||||
readOnly = false;
|
|
||||||
}
|
|
||||||
rc = vm->mountAsec(argv[2], argv[3], atoi(argv[4]), readOnly);
|
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::ObbCmd::ObbCmd() :
|
|
||||||
VoldCommand("obb") {
|
|
||||||
}
|
|
||||||
|
|
||||||
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> <ownerGid>", 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandListener::FstrimCmd::FstrimCmd() :
|
|
||||||
VoldCommand("fstrim") {
|
|
||||||
}
|
|
||||||
int CommandListener::FstrimCmd::runCommand(SocketClient *cli,
|
|
||||||
int argc, char **argv) {
|
|
||||||
if ((cli->getUid() != 0) && (cli->getUid() != AID_SYSTEM)) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandNoPermission, "No permission to run fstrim commands", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
VolumeManager *vm = VolumeManager::Instance();
|
|
||||||
std::lock_guard<std::mutex> lock(vm->getLock());
|
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
std::string cmd(argv[1]);
|
|
||||||
if (cmd == "dotrim") {
|
|
||||||
flags = 0;
|
|
||||||
} else if (cmd == "dodtrim") {
|
|
||||||
flags = android::vold::TrimTask::Flags::kDeepTrim;
|
|
||||||
} else if (cmd == "dodtrimbench") {
|
|
||||||
flags = android::vold::TrimTask::Flags::kDeepTrim;
|
|
||||||
}
|
|
||||||
|
|
||||||
(new android::vold::TrimTask(flags, nullptr))->start();
|
|
||||||
return sendGenericOkFail(cli, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CommandListener::AppFuseCmd::AppFuseCmd() : VoldCommand("appfuse") {}
|
|
||||||
|
|
||||||
int CommandListener::AppFuseCmd::runCommand(SocketClient *cli, int argc, char **argv) {
|
|
||||||
if (argc < 2) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
VolumeManager *vm = VolumeManager::Instance();
|
|
||||||
std::lock_guard<std::mutex> lock(vm->getLock());
|
|
||||||
|
|
||||||
const std::string command(argv[1]);
|
|
||||||
if (command == "mount" && argc == 5) {
|
|
||||||
const uid_t uid = atoi(argv[2]);
|
|
||||||
const pid_t pid = atoi(argv[3]);
|
|
||||||
const int mountId = atoi(argv[4]);
|
|
||||||
|
|
||||||
unique_fd device_fd;
|
|
||||||
int result = vm->mountAppFuse(uid, pid, mountId, &device_fd);
|
|
||||||
if (result != 0) {
|
|
||||||
return sendGenericOkFail(cli, result);
|
|
||||||
} else {
|
|
||||||
return sendFd(cli, device_fd.get());
|
|
||||||
}
|
|
||||||
} else if (command == "unmount" && argc == 5) {
|
|
||||||
const uid_t uid = atoi(argv[2]);
|
|
||||||
const uid_t pid = atoi(argv[3]);
|
|
||||||
const int mountId = atoi(argv[4]);
|
|
||||||
|
|
||||||
int result = vm->unmountAppFuse(uid, pid, mountId);
|
|
||||||
return sendGenericOkFail(cli, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown appfuse cmd", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
android::status_t CommandListener::AppFuseCmd::sendFd(SocketClient *cli, int fd) {
|
|
||||||
struct iovec data;
|
|
||||||
char dataBuffer[128];
|
|
||||||
char controlBuffer[CMSG_SPACE(sizeof(int))];
|
|
||||||
struct msghdr message;
|
|
||||||
|
|
||||||
// Message.
|
|
||||||
memset(&message, 0, sizeof(struct msghdr));
|
|
||||||
message.msg_iov = &data;
|
|
||||||
message.msg_iovlen = 1;
|
|
||||||
message.msg_control = controlBuffer;
|
|
||||||
message.msg_controllen = CMSG_SPACE(sizeof(int));
|
|
||||||
|
|
||||||
// Data.
|
|
||||||
data.iov_base = dataBuffer;
|
|
||||||
data.iov_len = snprintf(dataBuffer,
|
|
||||||
sizeof(dataBuffer),
|
|
||||||
"200 %d AppFuse command succeeded",
|
|
||||||
cli->getCmdNum()) + 1;
|
|
||||||
|
|
||||||
// Control.
|
|
||||||
struct cmsghdr* const controlMessage = CMSG_FIRSTHDR(&message);
|
|
||||||
memset(controlBuffer, 0, CMSG_SPACE(sizeof(int)));
|
|
||||||
controlMessage->cmsg_level = SOL_SOCKET;
|
|
||||||
controlMessage->cmsg_type = SCM_RIGHTS;
|
|
||||||
controlMessage->cmsg_len = CMSG_LEN(sizeof(int));
|
|
||||||
*((int *) CMSG_DATA(controlMessage)) = fd;
|
|
||||||
|
|
||||||
const int result = TEMP_FAILURE_RETRY(sendmsg(cli->getSocket(), &message, 0));
|
|
||||||
if (result == -1) {
|
|
||||||
PLOG(ERROR) << "Failed to send FD from vold";
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
return android::OK;
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _COMMANDLISTENER_H__
|
|
||||||
#define _COMMANDLISTENER_H__
|
|
||||||
|
|
||||||
#include <sysutils/FrameworkListener.h>
|
|
||||||
#include <utils/Errors.h>
|
|
||||||
#include "VoldCommand.h"
|
|
||||||
|
|
||||||
class CommandListener : public FrameworkListener {
|
|
||||||
public:
|
|
||||||
CommandListener();
|
|
||||||
virtual ~CommandListener() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void dumpArgs(int argc, char **argv, int argObscure);
|
|
||||||
static int sendGenericOkFail(SocketClient *cli, int cond);
|
|
||||||
|
|
||||||
class DumpCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
DumpCmd();
|
|
||||||
virtual ~DumpCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
class VolumeCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
VolumeCmd();
|
|
||||||
virtual ~VolumeCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
class AsecCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
AsecCmd();
|
|
||||||
virtual ~AsecCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
private:
|
|
||||||
void listAsecsInDirectory(SocketClient *c, const char *directory);
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObbCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
ObbCmd();
|
|
||||||
virtual ~ObbCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
class StorageCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
StorageCmd();
|
|
||||||
virtual ~StorageCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
class FstrimCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
FstrimCmd();
|
|
||||||
virtual ~FstrimCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppFuseCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
AppFuseCmd();
|
|
||||||
virtual ~AppFuseCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
private:
|
|
||||||
android::status_t sendFd(SocketClient *c, int fd);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,448 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <fs_mgr.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#define LOG_TAG "VoldCryptCmdListener"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <android-base/stringprintf.h>
|
|
||||||
|
|
||||||
#include <cutils/fs.h>
|
|
||||||
#include <cutils/log.h>
|
|
||||||
#include <cutils/sockets.h>
|
|
||||||
|
|
||||||
#include <sysutils/SocketClient.h>
|
|
||||||
#include <private/android_filesystem_config.h>
|
|
||||||
|
|
||||||
#include "CryptCommandListener.h"
|
|
||||||
#include "Process.h"
|
|
||||||
#include "ResponseCode.h"
|
|
||||||
#include "cryptfs.h"
|
|
||||||
#include "Ext4Crypt.h"
|
|
||||||
#include "MetadataCrypt.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
#define DUMP_ARGS 0
|
|
||||||
|
|
||||||
CryptCommandListener::CryptCommandListener() :
|
|
||||||
FrameworkListener("cryptd", true) {
|
|
||||||
registerCmd(new CryptfsCmd());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DUMP_ARGS
|
|
||||||
void CryptCommandListener::dumpArgs(int argc, char **argv, int argObscure) {
|
|
||||||
char buffer[4096];
|
|
||||||
char *p = buffer;
|
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < argc; i++) {
|
|
||||||
unsigned int len = strlen(argv[i]) + 1; // Account for space
|
|
||||||
if (i == argObscure) {
|
|
||||||
len += 2; // Account for {}
|
|
||||||
}
|
|
||||||
if (((p - buffer) + len) < (sizeof(buffer)-1)) {
|
|
||||||
if (i == argObscure) {
|
|
||||||
*p++ = '{';
|
|
||||||
*p++ = '}';
|
|
||||||
*p++ = ' ';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
strcpy(p, argv[i]);
|
|
||||||
p+= strlen(argv[i]);
|
|
||||||
if (i != (argc -1)) {
|
|
||||||
*p++ = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SLOGD("%s", buffer);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void CryptCommandListener::dumpArgs(int /*argc*/, char ** /*argv*/, int /*argObscure*/) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int CryptCommandListener::sendGenericOkFailOnBool(SocketClient *cli, bool success) {
|
|
||||||
if (success) {
|
|
||||||
return cli->sendMsg(ResponseCode::CommandOkay, "Command succeeded", false);
|
|
||||||
} else {
|
|
||||||
return cli->sendMsg(ResponseCode::OperationFailed, "Command failed", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CryptCommandListener::CryptfsCmd::CryptfsCmd() :
|
|
||||||
VoldCommand("cryptfs") {
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getType(const char* type)
|
|
||||||
{
|
|
||||||
if (!strcmp(type, "default")) {
|
|
||||||
return CRYPT_TYPE_DEFAULT;
|
|
||||||
} else if (!strcmp(type, "password")) {
|
|
||||||
return CRYPT_TYPE_PASSWORD;
|
|
||||||
} else if (!strcmp(type, "pin")) {
|
|
||||||
return CRYPT_TYPE_PIN;
|
|
||||||
} else if (!strcmp(type, "pattern")) {
|
|
||||||
return CRYPT_TYPE_PATTERN;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* parseNull(char* arg) {
|
|
||||||
if (strcmp(arg, "!") == 0) {
|
|
||||||
return nullptr;
|
|
||||||
} else {
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool check_argc(SocketClient *cli, const std::string &subcommand, int argc,
|
|
||||||
int expected, std::string usage) {
|
|
||||||
assert(expected >= 2);
|
|
||||||
if (expected == 2) {
|
|
||||||
assert(usage.empty());
|
|
||||||
} else {
|
|
||||||
assert(!usage.empty());
|
|
||||||
assert(std::count(usage.begin(), usage.end(), ' ') + 3 == expected);
|
|
||||||
}
|
|
||||||
if (argc == expected) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto message = std::string() + "Usage: cryptfs " + subcommand;
|
|
||||||
if (!usage.empty()) {
|
|
||||||
message += " " + usage;
|
|
||||||
}
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, message.c_str(), false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int do_enablecrypto(char* arg2, char* arg4, int type, bool no_ui) {
|
|
||||||
int rc;
|
|
||||||
int tries;
|
|
||||||
for (tries = 0; tries < 2; ++tries) {
|
|
||||||
if (type == CRYPT_TYPE_DEFAULT) {
|
|
||||||
rc = cryptfs_enable_default(arg2, no_ui);
|
|
||||||
} else {
|
|
||||||
rc = cryptfs_enable(arg2, type, arg4, no_ui);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == 0) {
|
|
||||||
free(arg2);
|
|
||||||
free(arg4);
|
|
||||||
return 0;
|
|
||||||
} else if (tries == 0) {
|
|
||||||
Process::killProcessesWithOpenFiles(DATA_MNT_POINT, SIGKILL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(arg2);
|
|
||||||
free(arg4);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CryptCommandListener::CryptfsCmd::runCommand(SocketClient *cli,
|
|
||||||
int argc, char **argv) {
|
|
||||||
if ((cli->getUid() != 0) && (cli->getUid() != AID_SYSTEM)) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandNoPermission, "No permission to run cryptfs commands", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing subcommand", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
std::string subcommand(argv[1]);
|
|
||||||
if (subcommand == "checkpw") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<passwd>")) return 0;
|
|
||||||
dumpArgs(argc, argv, 2);
|
|
||||||
rc = cryptfs_check_passwd(argv[2]);
|
|
||||||
} else if (subcommand == "restart") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
|
|
||||||
// Spawn as thread so init can issue commands back to vold without
|
|
||||||
// causing deadlock, usually as a result of prep_data_fs.
|
|
||||||
std::thread(&cryptfs_restart).detach();
|
|
||||||
} else if (subcommand == "cryptocomplete") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
rc = cryptfs_crypto_complete();
|
|
||||||
} else if (subcommand == "enablecrypto") {
|
|
||||||
if (e4crypt_is_native()) {
|
|
||||||
if (argc != 5 || strcmp(argv[2], "inplace") || strcmp(argv[3], "default")
|
|
||||||
|| strcmp(argv[4], "noui")) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError,
|
|
||||||
"Usage with ext4crypt: cryptfs enablecrypto inplace default noui", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_enable_crypto());
|
|
||||||
}
|
|
||||||
const char* syntax = "Usage: cryptfs enablecrypto <wipe|inplace> "
|
|
||||||
"default|password|pin|pattern [passwd] [noui]";
|
|
||||||
|
|
||||||
// This should be replaced with a command line parser if more options
|
|
||||||
// are added
|
|
||||||
bool valid = true;
|
|
||||||
bool no_ui = false;
|
|
||||||
int type = CRYPT_TYPE_DEFAULT;
|
|
||||||
int options = 4; // Optional parameters are at this offset
|
|
||||||
if (argc < 4) {
|
|
||||||
// Minimum 4 parameters
|
|
||||||
valid = false;
|
|
||||||
} else if (strcmp(argv[2], "wipe") && strcmp(argv[2], "inplace") ) {
|
|
||||||
// Second parameter must be wipe or inplace
|
|
||||||
valid = false;
|
|
||||||
} else {
|
|
||||||
// Third parameter must be valid type
|
|
||||||
type = getType(argv[3]);
|
|
||||||
if (type == -1) {
|
|
||||||
valid = false;
|
|
||||||
} else if (type != CRYPT_TYPE_DEFAULT) {
|
|
||||||
options++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valid) {
|
|
||||||
if(argc < options) {
|
|
||||||
// Too few parameters
|
|
||||||
valid = false;
|
|
||||||
} else if (argc == options) {
|
|
||||||
// No more, done
|
|
||||||
} else if (argc == options + 1) {
|
|
||||||
// One option, must be noui
|
|
||||||
if (!strcmp(argv[options], "noui")) {
|
|
||||||
no_ui = true;
|
|
||||||
} else {
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Too many options
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dumpArgs(argc, argv, 4);
|
|
||||||
|
|
||||||
// Spawn as thread so init can issue commands back to vold without
|
|
||||||
// causing deadlock, usually as a result of prep_data_fs.
|
|
||||||
char* arg2 = argc > 2 ? strdup(argv[2]) : NULL;
|
|
||||||
char* arg4 = argc > 4 ? strdup(argv[4]) : NULL;
|
|
||||||
std::thread(&do_enablecrypto, arg2, arg4, type, no_ui).detach();
|
|
||||||
} else if (subcommand == "enablefilecrypto") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
rc = e4crypt_initialize_global_de();
|
|
||||||
} else if (subcommand == "changepw") {
|
|
||||||
const char* syntax = "Usage: cryptfs changepw "
|
|
||||||
"default|password|pin|pattern [newpasswd]";
|
|
||||||
const char* password;
|
|
||||||
if (argc == 3) {
|
|
||||||
password = "";
|
|
||||||
} else if (argc == 4) {
|
|
||||||
password = argv[3];
|
|
||||||
} else {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int type = getType(argv[2]);
|
|
||||||
if (type == -1) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
SLOGD("cryptfs changepw %s {}", argv[2]);
|
|
||||||
rc = cryptfs_changepw(type, password);
|
|
||||||
} else if (subcommand == "verifypw") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<passwd>")) return 0;
|
|
||||||
SLOGD("cryptfs verifypw {}");
|
|
||||||
rc = cryptfs_verify_passwd(argv[2]);
|
|
||||||
} else if (subcommand == "getfield") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<fieldname>")) return 0;
|
|
||||||
char *valbuf;
|
|
||||||
int valbuf_len = PROPERTY_VALUE_MAX;
|
|
||||||
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
|
|
||||||
// Increase the buffer size until it is big enough for the field value stored.
|
|
||||||
while (1) {
|
|
||||||
valbuf = (char*)malloc(valbuf_len);
|
|
||||||
if (valbuf == NULL) {
|
|
||||||
cli->sendMsg(ResponseCode::OperationFailed, "Failed to allocate memory", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rc = cryptfs_getfield(argv[2], valbuf, valbuf_len);
|
|
||||||
if (rc != CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(valbuf);
|
|
||||||
valbuf_len *= 2;
|
|
||||||
}
|
|
||||||
if (rc == CRYPTO_GETFIELD_OK) {
|
|
||||||
cli->sendMsg(ResponseCode::CryptfsGetfieldResult, valbuf, false);
|
|
||||||
}
|
|
||||||
free(valbuf);
|
|
||||||
} else if (subcommand == "setfield") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 4, "<fieldname> <value>")) return 0;
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
rc = cryptfs_setfield(argv[2], argv[3]);
|
|
||||||
} else if (subcommand == "mountdefaultencrypted") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
SLOGD("cryptfs mountdefaultencrypted");
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
|
|
||||||
if (e4crypt_is_native()) {
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_mount_metadata_encrypted());
|
|
||||||
}
|
|
||||||
// Spawn as thread so init can issue commands back to vold without
|
|
||||||
// causing deadlock, usually as a result of prep_data_fs.
|
|
||||||
std::thread(&cryptfs_mount_default_encrypted).detach();
|
|
||||||
} else if (subcommand == "getpwtype") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
SLOGD("cryptfs getpwtype");
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
switch(cryptfs_get_password_type()) {
|
|
||||||
case CRYPT_TYPE_PASSWORD:
|
|
||||||
cli->sendMsg(ResponseCode::PasswordTypeResult, "password", false);
|
|
||||||
return 0;
|
|
||||||
case CRYPT_TYPE_PATTERN:
|
|
||||||
cli->sendMsg(ResponseCode::PasswordTypeResult, "pattern", false);
|
|
||||||
return 0;
|
|
||||||
case CRYPT_TYPE_PIN:
|
|
||||||
cli->sendMsg(ResponseCode::PasswordTypeResult, "pin", false);
|
|
||||||
return 0;
|
|
||||||
case CRYPT_TYPE_DEFAULT:
|
|
||||||
cli->sendMsg(ResponseCode::PasswordTypeResult, "default", false);
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
/** @TODO better error and make sure handled by callers */
|
|
||||||
cli->sendMsg(ResponseCode::OpFailedStorageNotFound, "Error", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else if (subcommand == "getpw") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
SLOGD("cryptfs getpw");
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
const char* password = cryptfs_get_password();
|
|
||||||
if (password) {
|
|
||||||
char* message = 0;
|
|
||||||
int size = asprintf(&message, "{{sensitive}} %s", password);
|
|
||||||
if (size != -1) {
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, message, false);
|
|
||||||
memset(message, 0, size);
|
|
||||||
free (message);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rc = -1;
|
|
||||||
} else if (subcommand == "clearpw") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
SLOGD("cryptfs clearpw");
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
cryptfs_clear_password();
|
|
||||||
rc = 0;
|
|
||||||
|
|
||||||
} else if (subcommand == "isConvertibleToFBE") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
// ext4enc:TODO: send a CommandSyntaxError if argv[2] not an integer
|
|
||||||
SLOGD("cryptfs isConvertibleToFBE");
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
rc = cryptfs_isConvertibleToFBE();
|
|
||||||
|
|
||||||
} else if (subcommand == "init_user0") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 2, "")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_init_user0());
|
|
||||||
|
|
||||||
} else if (subcommand == "create_user_key") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 5, "<user> <serial> <ephemeral>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_vold_create_user_key(
|
|
||||||
atoi(argv[2]), atoi(argv[3]), atoi(argv[4]) != 0));
|
|
||||||
|
|
||||||
} else if (subcommand == "destroy_user_key") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<user>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_destroy_user_key(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (subcommand == "add_user_key_auth") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 6, "<user> <serial> <token> <secret>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_add_user_key_auth(
|
|
||||||
atoi(argv[2]), atoi(argv[3]), argv[4], argv[5]));
|
|
||||||
|
|
||||||
} else if (subcommand == "fixate_newest_user_key_auth") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<user>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_fixate_newest_user_key_auth(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (subcommand == "unlock_user_key") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 6, "<user> <serial> <token> <secret>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_unlock_user_key(
|
|
||||||
atoi(argv[2]), atoi(argv[3]), argv[4], argv[5]));
|
|
||||||
|
|
||||||
} else if (subcommand == "lock_user_key") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<user>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_lock_user_key(atoi(argv[2])));
|
|
||||||
|
|
||||||
} else if (subcommand == "prepare_user_storage") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 6, "<uuid> <user> <serial> <flags>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli, e4crypt_prepare_user_storage(
|
|
||||||
parseNull(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5])));
|
|
||||||
|
|
||||||
} else if (subcommand == "destroy_user_storage") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 5, "<uuid> <user> <flags>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli,
|
|
||||||
e4crypt_destroy_user_storage(parseNull(argv[2]), atoi(argv[3]), atoi(argv[4])));
|
|
||||||
|
|
||||||
} else if (subcommand == "secdiscard") {
|
|
||||||
if (!check_argc(cli, subcommand, argc, 3, "<path>")) return 0;
|
|
||||||
return sendGenericOkFailOnBool(cli,
|
|
||||||
e4crypt_secdiscard(parseNull(argv[2])));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
dumpArgs(argc, argv, -1);
|
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown cryptfs subcommand", false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always report that the command succeeded and return the error code.
|
|
||||||
// The caller will check the return value to see what the error was.
|
|
||||||
char msg[255];
|
|
||||||
snprintf(msg, sizeof(msg), "%d", rc);
|
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, msg, false);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CRYPTCOMMANDLISTENER_H__
|
|
||||||
#define _CRYPTCOMMANDLISTENER_H__
|
|
||||||
|
|
||||||
#include <sysutils/FrameworkListener.h>
|
|
||||||
#include <utils/Errors.h>
|
|
||||||
#include "VoldCommand.h"
|
|
||||||
|
|
||||||
class CryptCommandListener : public FrameworkListener {
|
|
||||||
public:
|
|
||||||
CryptCommandListener();
|
|
||||||
virtual ~CryptCommandListener() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void dumpArgs(int argc, char **argv, int argObscure);
|
|
||||||
static int sendGenericOkFailOnBool(SocketClient *cli, bool success);
|
|
||||||
|
|
||||||
class CryptfsCmd : public VoldCommand {
|
|
||||||
public:
|
|
||||||
CryptfsCmd();
|
|
||||||
virtual ~CryptfsCmd() {}
|
|
||||||
int runCommand(SocketClient *c, int argc, char ** argv);
|
|
||||||
};
|
|
||||||
int getSocket();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define LOG_TAG "Vold"
|
|
||||||
|
|
||||||
#include <cutils/log.h>
|
|
||||||
|
|
||||||
#include "ResponseCode.h"
|
|
||||||
|
|
||||||
int ResponseCode::convertFromErrno() {
|
|
||||||
if (errno == ENODEV) {
|
|
||||||
return(ResponseCode::OpFailedNoMedia);
|
|
||||||
} else if (errno == ENODATA) {
|
|
||||||
return(ResponseCode::OpFailedMediaBlank);
|
|
||||||
} else if (errno == EIO) {
|
|
||||||
return(ResponseCode::OpFailedMediaCorrupt);
|
|
||||||
} else if (errno == EBUSY) {
|
|
||||||
return(ResponseCode::OpFailedStorageBusy);
|
|
||||||
} else if (errno == ENOENT) {
|
|
||||||
return(ResponseCode::OpFailedStorageNotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
SLOGW("Returning OperationFailed - no handler for errno %d", errno);
|
|
||||||
return(ResponseCode::OperationFailed);
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RESPONSECODE_H
|
|
||||||
#define _RESPONSECODE_H
|
|
||||||
|
|
||||||
class ResponseCode {
|
|
||||||
public:
|
|
||||||
// 100 series - Requestion action was initiated; expect another reply
|
|
||||||
// before proceeding with a new command.
|
|
||||||
static const int ActionInitiated = 100;
|
|
||||||
|
|
||||||
static const int VolumeListResult = 110;
|
|
||||||
static const int AsecListResult = 111;
|
|
||||||
static const int StorageUsersListResult = 112;
|
|
||||||
static const int CryptfsGetfieldResult = 113;
|
|
||||||
|
|
||||||
// 200 series - Requested action has been successfully completed
|
|
||||||
static const int CommandOkay = 200;
|
|
||||||
static const int ShareStatusResult = 210;
|
|
||||||
static const int AsecPathResult = 211;
|
|
||||||
static const int ShareEnabledResult = 212;
|
|
||||||
static const int PasswordTypeResult = 213;
|
|
||||||
|
|
||||||
// 400 series - The command was accepted but the requested action
|
|
||||||
// did not take place.
|
|
||||||
static const int OperationFailed = 400;
|
|
||||||
static const int OpFailedNoMedia = 401;
|
|
||||||
static const int OpFailedMediaBlank = 402;
|
|
||||||
static const int OpFailedMediaCorrupt = 403;
|
|
||||||
static const int OpFailedVolNotMounted = 404;
|
|
||||||
static const int OpFailedStorageBusy = 405;
|
|
||||||
static const int OpFailedStorageNotFound = 406;
|
|
||||||
|
|
||||||
// 500 series - The command was not accepted and the requested
|
|
||||||
// action did not take place.
|
|
||||||
static const int CommandSyntaxError = 500;
|
|
||||||
static const int CommandParameterError = 501;
|
|
||||||
static const int CommandNoPermission = 502;
|
|
||||||
|
|
||||||
// 600 series - Unsolicited broadcasts
|
|
||||||
static const int UnsolicitedInformational = 600;
|
|
||||||
static const int VolumeStateChange = 605;
|
|
||||||
static const int VolumeMountFailedBlank = 610;
|
|
||||||
static const int VolumeMountFailedDamaged = 611;
|
|
||||||
static const int VolumeMountFailedNoMedia = 612;
|
|
||||||
static const int VolumeUuidChange = 613;
|
|
||||||
static const int VolumeUserLabelChange = 614;
|
|
||||||
|
|
||||||
static const int ShareAvailabilityChange = 620;
|
|
||||||
|
|
||||||
static const int VolumeDiskInserted = 630;
|
|
||||||
static const int VolumeDiskRemoved = 631;
|
|
||||||
static const int VolumeBadRemoval = 632;
|
|
||||||
|
|
||||||
static const int DiskCreated = 640;
|
|
||||||
static const int DiskSizeChanged = 641;
|
|
||||||
static const int DiskLabelChanged = 642;
|
|
||||||
static const int DiskScanned = 643;
|
|
||||||
static const int DiskSysPathChanged = 644;
|
|
||||||
static const int DiskDestroyed = 649;
|
|
||||||
|
|
||||||
static const int VolumeCreated = 650;
|
|
||||||
static const int VolumeStateChanged = 651;
|
|
||||||
static const int VolumeFsTypeChanged = 652;
|
|
||||||
static const int VolumeFsUuidChanged = 653;
|
|
||||||
static const int VolumeFsLabelChanged = 654;
|
|
||||||
static const int VolumePathChanged = 655;
|
|
||||||
static const int VolumeInternalPathChanged = 656;
|
|
||||||
static const int VolumeDestroyed = 659;
|
|
||||||
|
|
||||||
static const int MoveStatus = 660;
|
|
||||||
static const int BenchmarkResult = 661;
|
|
||||||
static const int TrimResult = 662;
|
|
||||||
|
|
||||||
static int convertFromErrno();
|
|
||||||
};
|
|
||||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "VoldCommand.h"
|
|
||||||
|
|
||||||
VoldCommand::VoldCommand(const char *cmd) :
|
|
||||||
FrameworkCommand(cmd) {
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VOLD_COMMAND_H
|
|
||||||
#define _VOLD_COMMAND_H
|
|
||||||
|
|
||||||
#include <sysutils/FrameworkCommand.h>
|
|
||||||
|
|
||||||
class VoldCommand : public FrameworkCommand {
|
|
||||||
public:
|
|
||||||
explicit VoldCommand(const char *cmd);
|
|
||||||
virtual ~VoldCommand() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue