Merge "Make clean_scratch_files work"
This commit is contained in:
commit
9ac28517a3
4 changed files with 25 additions and 42 deletions
|
@ -246,28 +246,12 @@ cc_binary {
|
|||
"-UALLOW_ADBD_DISABLE_VERITY",
|
||||
"-DALLOW_ADBD_DISABLE_VERITY=1",
|
||||
],
|
||||
},
|
||||
},
|
||||
required: [
|
||||
"clean_scratch_files",
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "clean_scratch_files",
|
||||
defaults: ["fs_mgr_defaults"],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libfs_mgr_binder",
|
||||
],
|
||||
srcs: [
|
||||
"clean_scratch_files.cpp",
|
||||
],
|
||||
product_variables: {
|
||||
debuggable: {
|
||||
init_rc: [
|
||||
"clean_scratch_files.rc",
|
||||
],
|
||||
},
|
||||
},
|
||||
symlinks: [
|
||||
"clean_scratch_files",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2020 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 <fs_mgr_overlayfs.h>
|
||||
|
||||
int main() {
|
||||
android::fs_mgr::CleanupOldScratchFiles();
|
||||
return 0;
|
||||
}
|
|
@ -42,6 +42,8 @@
|
|||
#include <libavb_user/libavb_user.h>
|
||||
#include <libgsi/libgsid.h>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace {
|
||||
|
||||
[[noreturn]] void usage(int exit_status) {
|
||||
|
@ -142,6 +144,7 @@ enum RemountStatus {
|
|||
BINDER_ERROR,
|
||||
CHECKPOINTING,
|
||||
GSID_ERROR,
|
||||
CLEAN_SCRATCH_FILES,
|
||||
};
|
||||
|
||||
static int do_remount(int argc, char* argv[]) {
|
||||
|
@ -163,6 +166,7 @@ static int do_remount(int argc, char* argv[]) {
|
|||
{"help", no_argument, nullptr, 'h'},
|
||||
{"reboot", no_argument, nullptr, 'R'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{"clean_scratch_files", no_argument, nullptr, 'C'},
|
||||
{0, 0, nullptr, 0},
|
||||
};
|
||||
for (int opt; (opt = ::getopt_long(argc, argv, "hRT:v", longopts, nullptr)) != -1;) {
|
||||
|
@ -183,6 +187,8 @@ static int do_remount(int argc, char* argv[]) {
|
|||
case 'v':
|
||||
verbose = true;
|
||||
break;
|
||||
case 'C':
|
||||
return CLEAN_SCRATCH_FILES;
|
||||
default:
|
||||
LOG(ERROR) << "Bad Argument -" << char(opt);
|
||||
usage(BADARG);
|
||||
|
@ -476,14 +482,24 @@ static int do_remount(int argc, char* argv[]) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int do_clean_scratch_files() {
|
||||
android::fs_mgr::CleanupOldScratchFiles();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
android::base::InitLogging(argv, MyLogger);
|
||||
if (argc > 0 && android::base::Basename(argv[0]) == "clean_scratch_files"s) {
|
||||
return do_clean_scratch_files();
|
||||
}
|
||||
int result = do_remount(argc, argv);
|
||||
if (result == MUST_REBOOT) {
|
||||
LOG(INFO) << "Now reboot your device for settings to take effect";
|
||||
result = 0;
|
||||
} else if (result == REMOUNT_SUCCESS) {
|
||||
printf("remount succeeded\n");
|
||||
} else if (result == CLEAN_SCRATCH_FILES) {
|
||||
return do_clean_scratch_files();
|
||||
} else {
|
||||
printf("remount failed\n");
|
||||
}
|
||||
|
|
|
@ -696,7 +696,12 @@ bool ImageManager::RemoveDisabledImages() {
|
|||
bool ok = true;
|
||||
for (const auto& partition : metadata->partitions) {
|
||||
if (partition.attributes & LP_PARTITION_ATTR_DISABLED) {
|
||||
ok &= DeleteBackingImage(GetPartitionName(partition));
|
||||
const auto name = GetPartitionName(partition);
|
||||
if (!DeleteBackingImage(name)) {
|
||||
ok = false;
|
||||
} else {
|
||||
LOG(INFO) << "Removed disabled partition image: " << name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
|
|
Loading…
Reference in a new issue