Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | /* |
| 18 | * Tool to create a directory with the right SELinux context applied, or |
| 19 | * apply the context if it's absent. Also fixes mode, uid, gid. |
| 20 | */ |
| 21 | |
| 22 | #include <iostream> |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include <dirent.h> |
| 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <sys/stat.h> |
| 30 | #include <sys/types.h> |
| 31 | |
| 32 | #include <android-base/logging.h> |
| 33 | #include <android-base/scopeguard.h> |
| 34 | |
| 35 | #include <cutils/fs.h> |
| 36 | #include <selinux/android.h> |
| 37 | |
| 38 | #include "Utils.h" |
| 39 | #include "android/os/IVold.h" |
| 40 | |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 41 | #include <private/android_filesystem_config.h> |
| 42 | |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 43 | static void usage(const char* progname) { |
| 44 | std::cerr << "Usage: " << progname << " [ prepare | destroy ] <volume_uuid> <user_id> <flags>" |
| 45 | << std::endl; |
| 46 | exit(-1); |
| 47 | } |
| 48 | |
| 49 | static bool small_int(const std::string& s) { |
| 50 | return !s.empty() && s.size() < 7 && s.find_first_not_of("0123456789") == std::string::npos; |
| 51 | } |
| 52 | |
| 53 | static bool valid_uuid(const std::string& s) { |
| 54 | return s.size() < 40 && s.find_first_not_of("0123456789abcdefABCDEF-_") == std::string::npos; |
| 55 | } |
| 56 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 57 | static bool prepare_dir_for_user(struct selabel_handle* sehandle, mode_t mode, uid_t uid, gid_t gid, |
| 58 | const std::string& path, uid_t user_id) { |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 59 | auto clearfscreatecon = android::base::make_scope_guard([] { setfscreatecon(nullptr); }); |
| 60 | auto secontext = std::unique_ptr<char, void (*)(char*)>(nullptr, freecon); |
Eric Biggers | c7c4f5a | 2023-03-01 20:08:59 +0000 | [diff] [blame] | 61 | char* tmp_secontext; |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 62 | |
Eric Biggers | c7c4f5a | 2023-03-01 20:08:59 +0000 | [diff] [blame] | 63 | if (selabel_lookup(sehandle, &tmp_secontext, path.c_str(), S_IFDIR) == 0) { |
| 64 | secontext.reset(tmp_secontext); |
| 65 | if (user_id != (uid_t)-1) { |
| 66 | if (selinux_android_context_with_level(secontext.get(), &tmp_secontext, user_id, |
| 67 | (uid_t)-1) != 0) { |
| 68 | PLOG(ERROR) << "Unable to create context with level for: " << path; |
| 69 | return false; |
Austin Delgado | b0f997d | 2023-02-28 21:58:08 +0000 | [diff] [blame] | 70 | } |
Eric Biggers | c7c4f5a | 2023-03-01 20:08:59 +0000 | [diff] [blame] | 71 | secontext.reset(tmp_secontext); |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 72 | } |
Eric Biggers | c7c4f5a | 2023-03-01 20:08:59 +0000 | [diff] [blame] | 73 | if (setfscreatecon(secontext.get()) != 0) { |
| 74 | LOG(ERROR) << "Failed to setfscreatecon for directory " << path; |
| 75 | return false; |
| 76 | } |
| 77 | } else if (errno == ENOENT) { |
| 78 | LOG(DEBUG) << "No selabel defined for directory " << path; |
| 79 | } else { |
| 80 | PLOG(ERROR) << "Failed to look up selabel for directory " << path; |
| 81 | return false; |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 82 | } |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 83 | |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 84 | LOG(DEBUG) << "Setting up mode " << std::oct << mode << std::dec << " uid " << uid << " gid " |
Austin Delgado | b0f997d | 2023-02-28 21:58:08 +0000 | [diff] [blame] | 85 | << gid << " context " << (secontext ? secontext.get() : "null") |
| 86 | << " on path: " << path; |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 87 | if (fs_prepare_dir(path.c_str(), mode, uid, gid) != 0) { |
| 88 | return false; |
| 89 | } |
Austin Delgado | b0f997d | 2023-02-28 21:58:08 +0000 | [diff] [blame] | 90 | if (secontext) { |
| 91 | char* tmp_oldsecontext = nullptr; |
| 92 | if (lgetfilecon(path.c_str(), &tmp_oldsecontext) < 0) { |
| 93 | PLOG(ERROR) << "Unable to read secontext for: " << path; |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 94 | return false; |
| 95 | } |
Austin Delgado | b0f997d | 2023-02-28 21:58:08 +0000 | [diff] [blame] | 96 | auto oldsecontext = std::unique_ptr<char, void (*)(char*)>(tmp_oldsecontext, freecon); |
| 97 | if (strcmp(secontext.get(), oldsecontext.get()) != 0) { |
| 98 | LOG(INFO) << "Relabelling from " << ((char*)oldsecontext.get()) << " to " |
| 99 | << ((char*)secontext.get()) << ": " << path; |
| 100 | if (lsetfilecon(path.c_str(), secontext.get()) != 0) { |
| 101 | PLOG(ERROR) << "Relabelling failed for: " << path; |
| 102 | return false; |
| 103 | } |
| 104 | } |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 105 | } |
| 106 | return true; |
| 107 | } |
| 108 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 109 | static bool prepare_dir(struct selabel_handle* sehandle, mode_t mode, uid_t uid, gid_t gid, |
| 110 | const std::string& path) { |
| 111 | return prepare_dir_for_user(sehandle, mode, uid, gid, path, (uid_t)-1); |
| 112 | } |
| 113 | |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 114 | static bool rmrf_contents(const std::string& path) { |
| 115 | auto dirp = std::unique_ptr<DIR, int (*)(DIR*)>(opendir(path.c_str()), closedir); |
| 116 | if (!dirp) { |
Eric Biggers | 629c634 | 2023-02-24 17:26:10 +0000 | [diff] [blame] | 117 | if (errno == ENOENT) { |
| 118 | return true; |
| 119 | } |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 120 | PLOG(ERROR) << "Unable to open directory: " << path; |
| 121 | return false; |
| 122 | } |
| 123 | bool res = true; |
| 124 | for (;;) { |
| 125 | errno = 0; |
| 126 | auto const entry = readdir(dirp.get()); |
| 127 | if (!entry) { |
| 128 | if (errno) { |
| 129 | PLOG(ERROR) << "readdir failed on: " << path; |
| 130 | return false; |
| 131 | } |
| 132 | return res; |
| 133 | } |
| 134 | if (entry->d_name[0] == '.') continue; |
| 135 | auto subdir = path + "/" + entry->d_name; |
| 136 | if (0 != |
| 137 | android::vold::ForkExecvp(std::vector<std::string>{"/system/bin/rm", "-rf", subdir})) { |
| 138 | LOG(ERROR) << "rm -rf failed on " << subdir; |
| 139 | res = false; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 144 | static bool prepare_apex_subdirs(struct selabel_handle* sehandle, const std::string& path) { |
Oli Lan | e1b3f5c | 2020-01-17 11:01:38 +0000 | [diff] [blame] | 145 | if (!prepare_dir(sehandle, 0711, 0, 0, path + "/apexdata")) return false; |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 146 | |
Jooyung Han | 6d07925 | 2023-08-11 15:34:35 +0000 | [diff] [blame^] | 147 | auto dirp = std::unique_ptr<DIR, int (*)(DIR*)>(opendir("/apex"), closedir); |
| 148 | if (!dirp) { |
| 149 | PLOG(ERROR) << "Unable to open apex directory"; |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 150 | return false; |
| 151 | } |
Jooyung Han | 6d07925 | 2023-08-11 15:34:35 +0000 | [diff] [blame^] | 152 | struct dirent* entry; |
| 153 | while ((entry = readdir(dirp.get())) != nullptr) { |
| 154 | if (entry->d_type != DT_DIR) continue; |
| 155 | |
| 156 | const char* name = entry->d_name; |
| 157 | // skip any starting with "." |
| 158 | if (name[0] == '.') continue; |
| 159 | |
| 160 | if (strchr(name, '@') != NULL) continue; |
| 161 | |
Oli Lan | e1b3f5c | 2020-01-17 11:01:38 +0000 | [diff] [blame] | 162 | if (!prepare_dir(sehandle, 0771, AID_ROOT, AID_SYSTEM, path + "/apexdata/" + name)) { |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 163 | return false; |
| 164 | } |
| 165 | } |
| 166 | return true; |
| 167 | } |
| 168 | |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 169 | static bool prepare_subdirs(const std::string& volume_uuid, int user_id, int flags) { |
| 170 | struct selabel_handle* sehandle = selinux_android_file_context_handle(); |
Eric Biggers | c7c4f5a | 2023-03-01 20:08:59 +0000 | [diff] [blame] | 171 | if (!sehandle) { |
| 172 | LOG(ERROR) << "Failed to get SELinux file contexts handle"; |
| 173 | return false; |
| 174 | } |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 175 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 176 | if (flags & android::os::IVold::STORAGE_FLAG_DE) { |
| 177 | auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id); |
Alan Stokes | e0b7f30 | 2020-12-22 14:49:18 +0000 | [diff] [blame] | 178 | if (!prepare_dir_for_user(sehandle, 0771, AID_SYSTEM, AID_SYSTEM, user_de_path, user_id)) { |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 179 | return false; |
| 180 | } |
| 181 | |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 182 | auto misc_de_path = android::vold::BuildDataMiscDePath(volume_uuid, user_id); |
Samiul Islam | 0cf90d7 | 2022-02-11 16:17:49 +0000 | [diff] [blame] | 183 | if (!prepare_dir_for_user(sehandle, 0771, AID_SYSTEM, AID_SYSTEM, |
Nikita Ioffe | bad7cd0 | 2022-02-21 19:03:26 +0000 | [diff] [blame] | 184 | misc_de_path + "/sdksandbox", user_id)) { |
Samiul Islam | 0cf90d7 | 2022-02-11 16:17:49 +0000 | [diff] [blame] | 185 | return false; |
| 186 | } |
| 187 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 188 | if (volume_uuid.empty()) { |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 189 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_de_path + "/vold")) return false; |
Jin Qian | f396144 | 2017-10-19 14:44:37 -0700 | [diff] [blame] | 190 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_de_path + "/storaged")) return false; |
Narayan Kamath | a232fd7 | 2019-01-14 10:03:07 +0000 | [diff] [blame] | 191 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_de_path + "/rollback")) return false; |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 192 | // TODO: Return false if this returns false once sure this should succeed. |
Oli Lan | ac003c4 | 2019-12-02 18:27:24 +0000 | [diff] [blame] | 193 | prepare_dir(sehandle, 0700, 0, 0, misc_de_path + "/apexrollback"); |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 194 | prepare_apex_subdirs(sehandle, misc_de_path); |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 195 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 196 | auto profiles_de_path = android::vold::BuildDataProfilesDePath(user_id); |
| 197 | if (!prepare_dir_for_user(sehandle, 0771, AID_SYSTEM, AID_SYSTEM, profiles_de_path, |
Alan Stokes | e0b7f30 | 2020-12-22 14:49:18 +0000 | [diff] [blame] | 198 | user_id)) { |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 199 | return false; |
| 200 | } |
| 201 | |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 202 | auto vendor_de_path = android::vold::BuildDataVendorDePath(user_id); |
| 203 | if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, vendor_de_path + "/fpdata")) { |
| 204 | return false; |
| 205 | } |
Kevin Chyn | cdd4228 | 2018-11-20 19:09:15 +0000 | [diff] [blame] | 206 | auto facedata_path = vendor_de_path + "/facedata"; |
| 207 | if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, facedata_path)) { |
| 208 | return false; |
| 209 | } |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 210 | } |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 211 | } |
| 212 | if (flags & android::os::IVold::STORAGE_FLAG_CE) { |
| 213 | auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id); |
Alan Stokes | e0b7f30 | 2020-12-22 14:49:18 +0000 | [diff] [blame] | 214 | if (!prepare_dir_for_user(sehandle, 0771, AID_SYSTEM, AID_SYSTEM, user_ce_path, user_id)) { |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 215 | return false; |
| 216 | } |
| 217 | |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 218 | auto misc_ce_path = android::vold::BuildDataMiscCePath(volume_uuid, user_id); |
Samiul Islam | 0cf90d7 | 2022-02-11 16:17:49 +0000 | [diff] [blame] | 219 | if (!prepare_dir_for_user(sehandle, 0771, AID_SYSTEM, AID_SYSTEM, |
Nikita Ioffe | bad7cd0 | 2022-02-21 19:03:26 +0000 | [diff] [blame] | 220 | misc_ce_path + "/sdksandbox", user_id)) { |
Samiul Islam | 0cf90d7 | 2022-02-11 16:17:49 +0000 | [diff] [blame] | 221 | return false; |
| 222 | } |
| 223 | |
Alan Stokes | be3db7b | 2020-02-07 09:29:38 +0000 | [diff] [blame] | 224 | if (volume_uuid.empty()) { |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 225 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_ce_path + "/vold")) return false; |
Jin Qian | f396144 | 2017-10-19 14:44:37 -0700 | [diff] [blame] | 226 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_ce_path + "/storaged")) return false; |
Narayan Kamath | a232fd7 | 2019-01-14 10:03:07 +0000 | [diff] [blame] | 227 | if (!prepare_dir(sehandle, 0700, 0, 0, misc_ce_path + "/rollback")) return false; |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 228 | // TODO: Return false if this returns false once sure this should succeed. |
Oli Lan | ac003c4 | 2019-12-02 18:27:24 +0000 | [diff] [blame] | 229 | prepare_dir(sehandle, 0700, 0, 0, misc_ce_path + "/apexrollback"); |
Oli Lan | 9445721 | 2019-11-19 18:09:34 +0000 | [diff] [blame] | 230 | prepare_apex_subdirs(sehandle, misc_ce_path); |
Tianjie | 62487c9 | 2021-10-15 20:32:42 -0700 | [diff] [blame] | 231 | // Give gmscore (who runs in cache group) access to the checkin directory. Also provide |
| 232 | // the user id to set the correct selinux mls_level. |
| 233 | if (!prepare_dir_for_user(sehandle, 0770, AID_SYSTEM, AID_CACHE, |
| 234 | misc_ce_path + "/checkin", user_id)) { |
Tianjie | b2ee9e0 | 2021-10-21 15:16:49 -0700 | [diff] [blame] | 235 | // TODO(b/203742483) the checkin directory was created with the wrong permission & |
| 236 | // context. Delete the directory to get these devices out of the bad state. Revert |
| 237 | // the change once the droidfood population is on newer build. |
| 238 | LOG(INFO) << "Failed to prepare the checkin directory, deleting for recreation"; |
| 239 | android::vold::DeleteDirContentsAndDir(misc_ce_path + "/checkin"); |
| 240 | if (!prepare_dir_for_user(sehandle, 0770, AID_SYSTEM, AID_CACHE, |
| 241 | misc_ce_path + "/checkin", user_id)) { |
| 242 | return false; |
| 243 | } |
Tianjie | 62487c9 | 2021-10-15 20:32:42 -0700 | [diff] [blame] | 244 | } |
Annie Meng | 66176c5 | 2019-01-16 21:32:27 +0000 | [diff] [blame] | 245 | |
| 246 | auto system_ce_path = android::vold::BuildDataSystemCePath(user_id); |
| 247 | if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, system_ce_path + "/backup")) { |
| 248 | return false; |
| 249 | } |
| 250 | if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, |
| 251 | system_ce_path + "/backup_stage")) { |
| 252 | return false; |
| 253 | } |
Paul Crowley | b409ade | 2019-04-23 17:04:35 -0700 | [diff] [blame] | 254 | auto vendor_ce_path = android::vold::BuildDataVendorCePath(user_id); |
| 255 | auto facedata_path = vendor_ce_path + "/facedata"; |
| 256 | if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, facedata_path)) { |
| 257 | return false; |
| 258 | } |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | return true; |
| 262 | } |
| 263 | |
| 264 | static bool destroy_subdirs(const std::string& volume_uuid, int user_id, int flags) { |
| 265 | bool res = true; |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 266 | if (flags & android::os::IVold::STORAGE_FLAG_CE) { |
| 267 | auto misc_ce_path = android::vold::BuildDataMiscCePath(volume_uuid, user_id); |
| 268 | res &= rmrf_contents(misc_ce_path); |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 269 | |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 270 | if (volume_uuid.empty()) { |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 271 | auto vendor_ce_path = android::vold::BuildDataVendorCePath(user_id); |
| 272 | res &= rmrf_contents(vendor_ce_path); |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 273 | } |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 274 | } |
| 275 | if (flags & android::os::IVold::STORAGE_FLAG_DE) { |
| 276 | auto misc_de_path = android::vold::BuildDataMiscDePath(volume_uuid, user_id); |
| 277 | res &= rmrf_contents(misc_de_path); |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 278 | |
Mohammad Samiul Islam | b459591 | 2022-03-07 20:27:06 +0000 | [diff] [blame] | 279 | if (volume_uuid.empty()) { |
Andreas Huber | 71cd43f | 2018-01-22 11:25:29 -0800 | [diff] [blame] | 280 | auto vendor_de_path = android::vold::BuildDataVendorDePath(user_id); |
| 281 | res &= rmrf_contents(vendor_de_path); |
Paul Crowley | 82b41ff | 2017-10-20 08:17:54 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | return res; |
| 285 | } |
| 286 | |
| 287 | int main(int argc, const char* const argv[]) { |
| 288 | android::base::InitLogging(const_cast<char**>(argv)); |
| 289 | std::vector<std::string> args(argv + 1, argv + argc); |
| 290 | |
| 291 | if (args.size() != 4 || !valid_uuid(args[1]) || !small_int(args[2]) || !small_int(args[3])) { |
| 292 | usage(argv[0]); |
| 293 | return -1; |
| 294 | } |
| 295 | |
| 296 | auto volume_uuid = args[1]; |
| 297 | int user_id = stoi(args[2]); |
| 298 | int flags = stoi(args[3]); |
| 299 | if (args[0] == "prepare") { |
| 300 | if (!prepare_subdirs(volume_uuid, user_id, flags)) return -1; |
| 301 | } else if (args[0] == "destroy") { |
| 302 | if (!destroy_subdirs(volume_uuid, user_id, flags)) return -1; |
| 303 | } else { |
| 304 | usage(argv[0]); |
| 305 | return -1; |
| 306 | } |
| 307 | return 0; |
| 308 | } |