San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <stdlib.h> |
| 18 | #include <sys/socket.h> |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 19 | #include <sys/types.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 20 | #include <netinet/in.h> |
| 21 | #include <arpa/inet.h> |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 22 | #include <dirent.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 23 | #include <errno.h> |
San Mehat | 2350c44 | 2010-03-02 13:16:50 -0800 | [diff] [blame] | 24 | #include <fcntl.h> |
Mohamad Ayyash | 7929aa7 | 2014-03-10 15:55:33 -0700 | [diff] [blame] | 25 | #include <fs_mgr.h> |
Yabin Cui | d1104f7 | 2015-01-02 13:28:28 -0800 | [diff] [blame] | 26 | #include <stdio.h> |
Olivier Bailly | 37dcda6 | 2010-11-16 10:41:53 -0800 | [diff] [blame] | 27 | #include <string.h> |
Jeff Sharkey | 5a6bfca | 2015-05-14 20:33:55 -0700 | [diff] [blame] | 28 | #include <stdint.h> |
| 29 | #include <inttypes.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 30 | |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 31 | #define LOG_TAG "VoldCmdListener" |
Jeff Sharkey | 5a6bfca | 2015-05-14 20:33:55 -0700 | [diff] [blame] | 32 | |
| 33 | #include <base/stringprintf.h> |
| 34 | #include <cutils/fs.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 35 | #include <cutils/log.h> |
| 36 | |
| 37 | #include <sysutils/SocketClient.h> |
Ken Sumrall | 3ad9072 | 2011-10-04 20:38:29 -0700 | [diff] [blame] | 38 | #include <private/android_filesystem_config.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 39 | |
| 40 | #include "CommandListener.h" |
| 41 | #include "VolumeManager.h" |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 42 | #include "VolumeBase.h" |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 43 | #include "ResponseCode.h" |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 44 | #include "Process.h" |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 45 | #include "Loop.h" |
| 46 | #include "Devmapper.h" |
Ken Sumrall | 8f869aa | 2010-12-03 03:47:09 -0800 | [diff] [blame] | 47 | #include "cryptfs.h" |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 48 | #include "MoveTask.h" |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 49 | #include "TrimTask.h" |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 50 | |
Dianne Hackborn | 3fd60b4 | 2012-11-27 16:00:04 -0800 | [diff] [blame] | 51 | #define DUMP_ARGS 0 |
| 52 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 53 | CommandListener::CommandListener() : |
Robert Greenwalt | 149aa3e | 2012-02-16 14:43:03 -0800 | [diff] [blame] | 54 | FrameworkListener("vold", true) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 55 | registerCmd(new DumpCmd()); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 56 | registerCmd(new VolumeCmd()); |
| 57 | registerCmd(new AsecCmd()); |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 58 | registerCmd(new ObbCmd()); |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 59 | registerCmd(new StorageCmd()); |
Ken Sumrall | b87937c | 2013-03-19 21:46:39 -0700 | [diff] [blame] | 60 | registerCmd(new FstrimCmd()); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Dianne Hackborn | 3fd60b4 | 2012-11-27 16:00:04 -0800 | [diff] [blame] | 63 | #if DUMP_ARGS |
Mark Salyzyn | 3e97127 | 2014-01-21 13:27:04 -0800 | [diff] [blame] | 64 | void CommandListener::dumpArgs(int argc, char **argv, int argObscure) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 65 | char buffer[4096]; |
| 66 | char *p = buffer; |
| 67 | |
| 68 | memset(buffer, 0, sizeof(buffer)); |
| 69 | int i; |
| 70 | for (i = 0; i < argc; i++) { |
Ken Sumrall | 8f869aa | 2010-12-03 03:47:09 -0800 | [diff] [blame] | 71 | unsigned int len = strlen(argv[i]) + 1; // Account for space |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 72 | if (i == argObscure) { |
| 73 | len += 2; // Account for {} |
| 74 | } |
| 75 | if (((p - buffer) + len) < (sizeof(buffer)-1)) { |
| 76 | if (i == argObscure) { |
| 77 | *p++ = '{'; |
| 78 | *p++ = '}'; |
| 79 | *p++ = ' '; |
| 80 | continue; |
| 81 | } |
| 82 | strcpy(p, argv[i]); |
| 83 | p+= strlen(argv[i]); |
| 84 | if (i != (argc -1)) { |
| 85 | *p++ = ' '; |
| 86 | } |
| 87 | } |
| 88 | } |
San Mehat | 97ac40e | 2010-03-24 10:24:19 -0700 | [diff] [blame] | 89 | SLOGD("%s", buffer); |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 90 | } |
Mark Salyzyn | 3e97127 | 2014-01-21 13:27:04 -0800 | [diff] [blame] | 91 | #else |
| 92 | void CommandListener::dumpArgs(int /*argc*/, char ** /*argv*/, int /*argObscure*/) { } |
| 93 | #endif |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 94 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 95 | int CommandListener::sendGenericOkFail(SocketClient *cli, int cond) { |
| 96 | if (!cond) { |
| 97 | return cli->sendMsg(ResponseCode::CommandOkay, "Command succeeded", false); |
| 98 | } else { |
| 99 | return cli->sendMsg(ResponseCode::OperationFailed, "Command failed", false); |
| 100 | } |
| 101 | } |
| 102 | |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 103 | CommandListener::DumpCmd::DumpCmd() : |
| 104 | VoldCommand("dump") { |
| 105 | } |
| 106 | |
| 107 | int CommandListener::DumpCmd::runCommand(SocketClient *cli, |
Mark Salyzyn | 3e97127 | 2014-01-21 13:27:04 -0800 | [diff] [blame] | 108 | int /*argc*/, char ** /*argv*/) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 109 | cli->sendMsg(0, "Dumping loop status", false); |
| 110 | if (Loop::dumpState(cli)) { |
| 111 | cli->sendMsg(ResponseCode::CommandOkay, "Loop dump failed", true); |
| 112 | } |
| 113 | cli->sendMsg(0, "Dumping DM status", false); |
| 114 | if (Devmapper::dumpState(cli)) { |
| 115 | cli->sendMsg(ResponseCode::CommandOkay, "Devmapper dump failed", true); |
| 116 | } |
San Mehat | 96597e8 | 2010-03-17 09:50:54 -0700 | [diff] [blame] | 117 | cli->sendMsg(0, "Dumping mounted filesystems", false); |
| 118 | FILE *fp = fopen("/proc/mounts", "r"); |
| 119 | if (fp) { |
| 120 | char line[1024]; |
| 121 | while (fgets(line, sizeof(line), fp)) { |
| 122 | line[strlen(line)-1] = '\0'; |
| 123 | cli->sendMsg(0, line, false);; |
| 124 | } |
| 125 | fclose(fp); |
| 126 | } |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 127 | |
| 128 | cli->sendMsg(ResponseCode::CommandOkay, "dump complete", false); |
| 129 | return 0; |
| 130 | } |
| 131 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 132 | CommandListener::VolumeCmd::VolumeCmd() : |
| 133 | VoldCommand("volume") { |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 134 | } |
| 135 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 136 | int CommandListener::VolumeCmd::runCommand(SocketClient *cli, |
Mohamad Ayyash | 7929aa7 | 2014-03-10 15:55:33 -0700 | [diff] [blame] | 137 | int argc, char **argv) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 138 | dumpArgs(argc, argv, -1); |
| 139 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 140 | if (argc < 2) { |
| 141 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); |
| 142 | return 0; |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 143 | } |
| 144 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 145 | VolumeManager *vm = VolumeManager::Instance(); |
Jeff Sharkey | c8e04c5 | 2015-04-21 12:14:17 -0700 | [diff] [blame] | 146 | std::lock_guard<std::mutex> lock(vm->getLock()); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 147 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 148 | // TODO: tease out methods not directly related to volumes |
| 149 | |
| 150 | std::string cmd(argv[1]); |
| 151 | if (cmd == "reset") { |
| 152 | return sendGenericOkFail(cli, vm->reset()); |
| 153 | |
| 154 | } else if (cmd == "shutdown") { |
| 155 | return sendGenericOkFail(cli, vm->shutdown()); |
| 156 | |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 157 | } else if (cmd == "debug") { |
| 158 | return sendGenericOkFail(cli, vm->setDebug(true)); |
| 159 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 160 | } else if (cmd == "partition" && argc > 3) { |
| 161 | // partition [diskId] [public|private|mixed] [ratio] |
| 162 | std::string id(argv[2]); |
| 163 | auto disk = vm->findDisk(id); |
| 164 | if (disk == nullptr) { |
| 165 | return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown disk", false); |
San Mehat | 57df7bf | 2010-03-14 13:41:27 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 168 | std::string type(argv[3]); |
| 169 | if (type == "public") { |
| 170 | return sendGenericOkFail(cli, disk->partitionPublic()); |
| 171 | } else if (type == "private") { |
| 172 | return sendGenericOkFail(cli, disk->partitionPrivate()); |
| 173 | } else if (type == "mixed") { |
| 174 | if (argc < 4) { |
| 175 | return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false); |
| 176 | } |
| 177 | int frac = atoi(argv[4]); |
| 178 | return sendGenericOkFail(cli, disk->partitionMixed(frac)); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 179 | } else { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 180 | return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 181 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 182 | |
| 183 | } else if (cmd == "mkdirs" && argc > 2) { |
| 184 | // mkdirs [path] |
| 185 | return sendGenericOkFail(cli, vm->mkdirs(argv[2])); |
| 186 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 187 | } else if (cmd == "user_added" && argc > 3) { |
| 188 | // user_added [user] [serial] |
| 189 | return sendGenericOkFail(cli, vm->onUserAdded(atoi(argv[2]), atoi(argv[3]))); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 190 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 191 | } else if (cmd == "user_removed" && argc > 2) { |
| 192 | // user_removed [user] |
| 193 | return sendGenericOkFail(cli, vm->onUserRemoved(atoi(argv[2]))); |
| 194 | |
| 195 | } else if (cmd == "user_started" && argc > 2) { |
| 196 | // user_started [user] |
| 197 | return sendGenericOkFail(cli, vm->onUserStarted(atoi(argv[2]))); |
| 198 | |
| 199 | } else if (cmd == "user_stopped" && argc > 2) { |
| 200 | // user_stopped [user] |
| 201 | return sendGenericOkFail(cli, vm->onUserStopped(atoi(argv[2]))); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 202 | |
| 203 | } else if (cmd == "mount" && argc > 2) { |
| 204 | // mount [volId] [flags] [user] |
| 205 | std::string id(argv[2]); |
| 206 | auto vol = vm->findVolume(id); |
| 207 | if (vol == nullptr) { |
| 208 | return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false); |
Jeff Sharkey | 71ebe15 | 2013-09-17 17:24:38 -0700 | [diff] [blame] | 209 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 210 | |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 211 | int mountFlags = (argc > 3) ? atoi(argv[3]) : 0; |
| 212 | userid_t mountUserId = (argc > 4) ? atoi(argv[4]) : -1; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 213 | |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 214 | vol->setMountFlags(mountFlags); |
| 215 | vol->setMountUserId(mountUserId); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 216 | |
Jeff Sharkey | 1bfb375 | 2015-04-29 15:22:23 -0700 | [diff] [blame] | 217 | int res = vol->mount(); |
| 218 | if (mountFlags & android::vold::VolumeBase::MountFlags::kPrimary) { |
| 219 | vm->setPrimary(vol); |
| 220 | } |
| 221 | return sendGenericOkFail(cli, res); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 222 | |
| 223 | } else if (cmd == "unmount" && argc > 2) { |
| 224 | // unmount [volId] |
| 225 | std::string id(argv[2]); |
| 226 | auto vol = vm->findVolume(id); |
| 227 | if (vol == nullptr) { |
| 228 | return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false); |
| 229 | } |
| 230 | |
| 231 | return sendGenericOkFail(cli, vol->unmount()); |
| 232 | |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 233 | } else if (cmd == "format" && argc > 3) { |
| 234 | // format [volId] [fsType|auto] |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 235 | std::string id(argv[2]); |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 236 | std::string fsType(argv[3]); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 237 | auto vol = vm->findVolume(id); |
| 238 | if (vol == nullptr) { |
| 239 | return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false); |
| 240 | } |
| 241 | |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 242 | return sendGenericOkFail(cli, vol->format(fsType)); |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 243 | |
| 244 | } else if (cmd == "move_storage" && argc > 3) { |
| 245 | // move_storage [fromVolId] [toVolId] |
| 246 | auto fromVol = vm->findVolume(std::string(argv[2])); |
| 247 | auto toVol = vm->findVolume(std::string(argv[3])); |
| 248 | if (fromVol == nullptr || toVol == nullptr) { |
| 249 | return cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown volume", false); |
| 250 | } |
| 251 | |
| 252 | (new android::vold::MoveTask(fromVol, toVol))->start(); |
| 253 | return sendGenericOkFail(cli, 0); |
Jeff Sharkey | 5a6bfca | 2015-05-14 20:33:55 -0700 | [diff] [blame] | 254 | |
| 255 | } else if (cmd == "benchmark" && argc > 2) { |
| 256 | // benchmark [volId] |
| 257 | std::string id(argv[2]); |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 258 | nsecs_t res = vm->benchmarkPrivate(id); |
Jeff Sharkey | 5a6bfca | 2015-05-14 20:33:55 -0700 | [diff] [blame] | 259 | return cli->sendMsg(ResponseCode::CommandOkay, |
| 260 | android::base::StringPrintf("%" PRId64, res).c_str(), false); |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 261 | |
| 262 | } else if (cmd == "forget_partition" && argc > 2) { |
| 263 | // forget_partition [partGuid] |
| 264 | std::string partGuid(argv[2]); |
| 265 | return sendGenericOkFail(cli, vm->forgetPartition(partGuid)); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 266 | |
| 267 | } else if (cmd == "remount_uid" && argc > 3) { |
| 268 | // remount_uid [uid] [none|default|read|write] |
| 269 | uid_t uid = atoi(argv[2]); |
| 270 | std::string mode(argv[3]); |
| 271 | return sendGenericOkFail(cli, vm->remountUid(uid, mode)); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 274 | return cli->sendMsg(ResponseCode::CommandSyntaxError, nullptr, false); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 275 | } |
| 276 | |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 277 | CommandListener::StorageCmd::StorageCmd() : |
| 278 | VoldCommand("storage") { |
| 279 | } |
| 280 | |
| 281 | int CommandListener::StorageCmd::runCommand(SocketClient *cli, |
| 282 | int argc, char **argv) { |
Mohamad Ayyash | 7929aa7 | 2014-03-10 15:55:33 -0700 | [diff] [blame] | 283 | /* Guarantied to be initialized by vold's main() before the CommandListener is active */ |
| 284 | extern struct fstab *fstab; |
| 285 | |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 286 | dumpArgs(argc, argv, -1); |
| 287 | |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 288 | if (argc < 2) { |
| 289 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); |
| 290 | return 0; |
| 291 | } |
| 292 | |
Mohamad Ayyash | 7929aa7 | 2014-03-10 15:55:33 -0700 | [diff] [blame] | 293 | if (!strcmp(argv[1], "mountall")) { |
| 294 | if (argc != 2) { |
| 295 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: mountall", false); |
| 296 | return 0; |
| 297 | } |
| 298 | fs_mgr_mount_all(fstab); |
| 299 | cli->sendMsg(ResponseCode::CommandOkay, "Mountall ran successfully", false); |
| 300 | return 0; |
| 301 | } |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 302 | if (!strcmp(argv[1], "users")) { |
| 303 | DIR *dir; |
| 304 | struct dirent *de; |
| 305 | |
JP Abgrall | edf7adf | 2014-03-12 10:41:05 -0700 | [diff] [blame] | 306 | if (argc < 3) { |
| 307 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument: user <mountpoint>", false); |
| 308 | return 0; |
| 309 | } |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 310 | if (!(dir = opendir("/proc"))) { |
| 311 | cli->sendMsg(ResponseCode::OperationFailed, "Failed to open /proc", true); |
| 312 | return 0; |
| 313 | } |
| 314 | |
| 315 | while ((de = readdir(dir))) { |
| 316 | int pid = Process::getPid(de->d_name); |
| 317 | |
| 318 | if (pid < 0) { |
| 319 | continue; |
| 320 | } |
| 321 | |
| 322 | char processName[255]; |
| 323 | Process::getProcessName(pid, processName, sizeof(processName)); |
| 324 | |
| 325 | if (Process::checkFileDescriptorSymLinks(pid, argv[2]) || |
| 326 | Process::checkFileMaps(pid, argv[2]) || |
| 327 | Process::checkSymLink(pid, argv[2], "cwd") || |
| 328 | Process::checkSymLink(pid, argv[2], "root") || |
| 329 | Process::checkSymLink(pid, argv[2], "exe")) { |
| 330 | |
| 331 | char msg[1024]; |
| 332 | snprintf(msg, sizeof(msg), "%d %s", pid, processName); |
| 333 | cli->sendMsg(ResponseCode::StorageUsersListResult, msg, false); |
| 334 | } |
| 335 | } |
| 336 | closedir(dir); |
| 337 | cli->sendMsg(ResponseCode::CommandOkay, "Storage user list complete", false); |
| 338 | } else { |
| 339 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown storage cmd", false); |
| 340 | } |
| 341 | return 0; |
| 342 | } |
| 343 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 344 | CommandListener::AsecCmd::AsecCmd() : |
| 345 | VoldCommand("asec") { |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 346 | } |
| 347 | |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 348 | void CommandListener::AsecCmd::listAsecsInDirectory(SocketClient *cli, const char *directory) { |
| 349 | DIR *d = opendir(directory); |
| 350 | |
| 351 | if (!d) { |
| 352 | cli->sendMsg(ResponseCode::OperationFailed, "Failed to open asec dir", true); |
| 353 | return; |
| 354 | } |
| 355 | |
| 356 | size_t dirent_len = offsetof(struct dirent, d_name) + |
Elliott Hughes | 8c480f7 | 2012-10-26 16:57:19 -0700 | [diff] [blame] | 357 | fpathconf(dirfd(d), _PC_NAME_MAX) + 1; |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 358 | |
| 359 | struct dirent *dent = (struct dirent *) malloc(dirent_len); |
| 360 | if (dent == NULL) { |
| 361 | cli->sendMsg(ResponseCode::OperationFailed, "Failed to allocate memory", true); |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | struct dirent *result; |
| 366 | |
| 367 | while (!readdir_r(d, dent, &result) && result != NULL) { |
| 368 | if (dent->d_name[0] == '.') |
| 369 | continue; |
| 370 | if (dent->d_type != DT_REG) |
| 371 | continue; |
| 372 | size_t name_len = strlen(dent->d_name); |
| 373 | if (name_len > 5 && name_len < 260 && |
| 374 | !strcmp(&dent->d_name[name_len - 5], ".asec")) { |
| 375 | char id[255]; |
| 376 | memset(id, 0, sizeof(id)); |
Kenny Root | 7b0bc85 | 2012-04-27 15:33:58 -0700 | [diff] [blame] | 377 | strlcpy(id, dent->d_name, name_len - 4); |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 378 | cli->sendMsg(ResponseCode::AsecListResult, id, false); |
| 379 | } |
| 380 | } |
| 381 | closedir(d); |
| 382 | |
| 383 | free(dent); |
| 384 | } |
| 385 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 386 | int CommandListener::AsecCmd::runCommand(SocketClient *cli, |
| 387 | int argc, char **argv) { |
| 388 | if (argc < 2) { |
| 389 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 390 | return 0; |
| 391 | } |
| 392 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 393 | VolumeManager *vm = VolumeManager::Instance(); |
| 394 | int rc = 0; |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 395 | |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 396 | if (!strcmp(argv[1], "list")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 397 | dumpArgs(argc, argv, -1); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 398 | |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 399 | listAsecsInDirectory(cli, VolumeManager::SEC_ASECDIR_EXT); |
| 400 | listAsecsInDirectory(cli, VolumeManager::SEC_ASECDIR_INT); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 401 | } else if (!strcmp(argv[1], "create")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 402 | dumpArgs(argc, argv, 5); |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 403 | if (argc != 8) { |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 404 | cli->sendMsg(ResponseCode::CommandSyntaxError, |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 405 | "Usage: asec create <container-id> <size_mb> <fstype> <key> <ownerUid> " |
| 406 | "<isExternal>", false); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | unsigned int numSectors = (atoi(argv[3]) * (1024 * 1024)) / 512; |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 411 | const bool isExternal = (atoi(argv[7]) == 1); |
| 412 | rc = vm->createAsec(argv[2], numSectors, argv[4], argv[5], atoi(argv[6]), isExternal); |
Daniel Rosenberg | fcd34a0 | 2014-05-22 11:23:56 -0700 | [diff] [blame] | 413 | } else if (!strcmp(argv[1], "resize")) { |
| 414 | dumpArgs(argc, argv, -1); |
| 415 | if (argc != 5) { |
| 416 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec resize <container-id> <size_mb> <key>", false); |
| 417 | return 0; |
| 418 | } |
| 419 | unsigned int numSectors = (atoi(argv[3]) * (1024 * 1024)) / 512; |
| 420 | rc = vm->resizeAsec(argv[2], numSectors, argv[4]); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 421 | } else if (!strcmp(argv[1], "finalize")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 422 | dumpArgs(argc, argv, -1); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 423 | if (argc != 3) { |
| 424 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec finalize <container-id>", false); |
| 425 | return 0; |
| 426 | } |
San Mehat | 8f2875b | 2010-02-18 11:40:49 -0800 | [diff] [blame] | 427 | rc = vm->finalizeAsec(argv[2]); |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 428 | } else if (!strcmp(argv[1], "fixperms")) { |
| 429 | dumpArgs(argc, argv, -1); |
| 430 | if (argc != 5) { |
| 431 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fixperms <container-id> <gid> <filename>", false); |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | char *endptr; |
| 436 | gid_t gid = (gid_t) strtoul(argv[3], &endptr, 10); |
| 437 | if (*endptr != '\0') { |
| 438 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fixperms <container-id> <gid> <filename>", false); |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | rc = vm->fixupAsecPermissions(argv[2], gid, argv[4]); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 443 | } else if (!strcmp(argv[1], "destroy")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 444 | dumpArgs(argc, argv, -1); |
San Mehat | 4ba8948 | 2010-02-18 09:00:18 -0800 | [diff] [blame] | 445 | if (argc < 3) { |
| 446 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec destroy <container-id> [force]", false); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 447 | return 0; |
| 448 | } |
San Mehat | 4ba8948 | 2010-02-18 09:00:18 -0800 | [diff] [blame] | 449 | bool force = false; |
| 450 | if (argc > 3 && !strcmp(argv[3], "force")) { |
| 451 | force = true; |
| 452 | } |
San Mehat | 8f2875b | 2010-02-18 11:40:49 -0800 | [diff] [blame] | 453 | rc = vm->destroyAsec(argv[2], force); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 454 | } else if (!strcmp(argv[1], "mount")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 455 | dumpArgs(argc, argv, 3); |
Jeff Sharkey | 43ed123 | 2014-08-22 12:29:05 -0700 | [diff] [blame] | 456 | if (argc != 6) { |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 457 | cli->sendMsg(ResponseCode::CommandSyntaxError, |
Jeff Sharkey | 43ed123 | 2014-08-22 12:29:05 -0700 | [diff] [blame] | 458 | "Usage: asec mount <namespace-id> <key> <ownerUid> <ro|rw>", false); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 459 | return 0; |
| 460 | } |
Jeff Sharkey | 43ed123 | 2014-08-22 12:29:05 -0700 | [diff] [blame] | 461 | bool readOnly = true; |
| 462 | if (!strcmp(argv[5], "rw")) { |
| 463 | readOnly = false; |
| 464 | } |
| 465 | rc = vm->mountAsec(argv[2], argv[3], atoi(argv[4]), readOnly); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 466 | } else if (!strcmp(argv[1], "unmount")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 467 | dumpArgs(argc, argv, -1); |
San Mehat | 4ba8948 | 2010-02-18 09:00:18 -0800 | [diff] [blame] | 468 | if (argc < 3) { |
| 469 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec unmount <container-id> [force]", false); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 470 | return 0; |
| 471 | } |
San Mehat | 4ba8948 | 2010-02-18 09:00:18 -0800 | [diff] [blame] | 472 | bool force = false; |
| 473 | if (argc > 3 && !strcmp(argv[3], "force")) { |
| 474 | force = true; |
| 475 | } |
San Mehat | 8f2875b | 2010-02-18 11:40:49 -0800 | [diff] [blame] | 476 | rc = vm->unmountAsec(argv[2], force); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 477 | } else if (!strcmp(argv[1], "rename")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 478 | dumpArgs(argc, argv, -1); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 479 | if (argc != 4) { |
| 480 | cli->sendMsg(ResponseCode::CommandSyntaxError, |
| 481 | "Usage: asec rename <old_id> <new_id>", false); |
| 482 | return 0; |
| 483 | } |
San Mehat | 8f2875b | 2010-02-18 11:40:49 -0800 | [diff] [blame] | 484 | rc = vm->renameAsec(argv[2], argv[3]); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 485 | } else if (!strcmp(argv[1], "path")) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 486 | dumpArgs(argc, argv, -1); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 487 | if (argc != 3) { |
| 488 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec path <container-id>", false); |
| 489 | return 0; |
| 490 | } |
| 491 | char path[255]; |
| 492 | |
San Mehat | 88ac2c0 | 2010-03-23 11:15:58 -0700 | [diff] [blame] | 493 | if (!(rc = vm->getAsecMountPath(argv[2], path, sizeof(path)))) { |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 494 | cli->sendMsg(ResponseCode::AsecPathResult, path, false); |
San Mehat | 88ac2c0 | 2010-03-23 11:15:58 -0700 | [diff] [blame] | 495 | return 0; |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 496 | } |
Dianne Hackborn | 736910c | 2011-06-27 13:37:07 -0700 | [diff] [blame] | 497 | } else if (!strcmp(argv[1], "fspath")) { |
| 498 | dumpArgs(argc, argv, -1); |
| 499 | if (argc != 3) { |
| 500 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: asec fspath <container-id>", false); |
| 501 | return 0; |
| 502 | } |
| 503 | char path[255]; |
| 504 | |
| 505 | if (!(rc = vm->getAsecFilesystemPath(argv[2], path, sizeof(path)))) { |
| 506 | cli->sendMsg(ResponseCode::AsecPathResult, path, false); |
| 507 | return 0; |
| 508 | } |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 509 | } else { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 510 | dumpArgs(argc, argv, -1); |
San Mehat | eba65e9 | 2010-01-29 05:15:16 -0800 | [diff] [blame] | 511 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown asec cmd", false); |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 512 | } |
| 513 | |
San Mehat | 8f2875b | 2010-02-18 11:40:49 -0800 | [diff] [blame] | 514 | if (!rc) { |
| 515 | cli->sendMsg(ResponseCode::CommandOkay, "asec operation succeeded", false); |
| 516 | } else { |
| 517 | rc = ResponseCode::convertFromErrno(); |
| 518 | cli->sendMsg(rc, "asec operation failed", true); |
| 519 | } |
| 520 | |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 521 | return 0; |
| 522 | } |
San Mehat | 2350c44 | 2010-03-02 13:16:50 -0800 | [diff] [blame] | 523 | |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 524 | CommandListener::ObbCmd::ObbCmd() : |
| 525 | VoldCommand("obb") { |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 528 | int CommandListener::ObbCmd::runCommand(SocketClient *cli, |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 529 | int argc, char **argv) { |
| 530 | if (argc < 2) { |
| 531 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | VolumeManager *vm = VolumeManager::Instance(); |
| 536 | int rc = 0; |
| 537 | |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 538 | if (!strcmp(argv[1], "list")) { |
| 539 | dumpArgs(argc, argv, -1); |
| 540 | |
| 541 | rc = vm->listMountedObbs(cli); |
| 542 | } else if (!strcmp(argv[1], "mount")) { |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 543 | dumpArgs(argc, argv, 3); |
| 544 | if (argc != 5) { |
| 545 | cli->sendMsg(ResponseCode::CommandSyntaxError, |
Jeff Sharkey | 6947904 | 2012-09-25 16:14:57 -0700 | [diff] [blame] | 546 | "Usage: obb mount <filename> <key> <ownerGid>", false); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 547 | return 0; |
| 548 | } |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 549 | rc = vm->mountObb(argv[2], argv[3], atoi(argv[4])); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 550 | } else if (!strcmp(argv[1], "unmount")) { |
| 551 | dumpArgs(argc, argv, -1); |
| 552 | if (argc < 3) { |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 553 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: obb unmount <source file> [force]", false); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 554 | return 0; |
| 555 | } |
| 556 | bool force = false; |
| 557 | if (argc > 3 && !strcmp(argv[3], "force")) { |
| 558 | force = true; |
| 559 | } |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 560 | rc = vm->unmountObb(argv[2], force); |
| 561 | } else if (!strcmp(argv[1], "path")) { |
| 562 | dumpArgs(argc, argv, -1); |
| 563 | if (argc != 3) { |
| 564 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: obb path <source file>", false); |
| 565 | return 0; |
| 566 | } |
| 567 | char path[255]; |
| 568 | |
| 569 | if (!(rc = vm->getObbMountPath(argv[2], path, sizeof(path)))) { |
| 570 | cli->sendMsg(ResponseCode::AsecPathResult, path, false); |
| 571 | return 0; |
| 572 | } |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 573 | } else { |
| 574 | dumpArgs(argc, argv, -1); |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 575 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown obb cmd", false); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | if (!rc) { |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 579 | cli->sendMsg(ResponseCode::CommandOkay, "obb operation succeeded", false); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 580 | } else { |
| 581 | rc = ResponseCode::convertFromErrno(); |
Kenny Root | 508c0e1 | 2010-07-12 09:59:49 -0700 | [diff] [blame] | 582 | cli->sendMsg(rc, "obb operation failed", true); |
Kenny Root | fb7c4d5 | 2010-06-30 18:48:41 -0700 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | return 0; |
| 586 | } |
| 587 | |
Ken Sumrall | b87937c | 2013-03-19 21:46:39 -0700 | [diff] [blame] | 588 | CommandListener::FstrimCmd::FstrimCmd() : |
| 589 | VoldCommand("fstrim") { |
| 590 | } |
| 591 | int CommandListener::FstrimCmd::runCommand(SocketClient *cli, |
| 592 | int argc, char **argv) { |
| 593 | if ((cli->getUid() != 0) && (cli->getUid() != AID_SYSTEM)) { |
| 594 | cli->sendMsg(ResponseCode::CommandNoPermission, "No permission to run fstrim commands", false); |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | if (argc < 2) { |
| 599 | cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false); |
| 600 | return 0; |
| 601 | } |
| 602 | |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 603 | VolumeManager *vm = VolumeManager::Instance(); |
| 604 | std::lock_guard<std::mutex> lock(vm->getLock()); |
Ken Sumrall | b87937c | 2013-03-19 21:46:39 -0700 | [diff] [blame] | 605 | |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 606 | int flags = 0; |
| 607 | |
| 608 | std::string cmd(argv[1]); |
| 609 | if (cmd == "dotrim") { |
| 610 | flags = 0; |
| 611 | } else if (cmd == "dotrimbench") { |
| 612 | flags = android::vold::TrimTask::Flags::kBenchmarkAfter; |
| 613 | } else if (cmd == "dodtrim") { |
| 614 | flags = android::vold::TrimTask::Flags::kDeepTrim; |
| 615 | } else if (cmd == "dodtrimbench") { |
| 616 | flags = android::vold::TrimTask::Flags::kDeepTrim |
| 617 | | android::vold::TrimTask::Flags::kBenchmarkAfter; |
Ken Sumrall | b87937c | 2013-03-19 21:46:39 -0700 | [diff] [blame] | 618 | } |
| 619 | |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 620 | (new android::vold::TrimTask(flags))->start(); |
| 621 | return sendGenericOkFail(cli, 0); |
Ken Sumrall | b87937c | 2013-03-19 21:46:39 -0700 | [diff] [blame] | 622 | } |