summaryrefslogtreecommitdiff
path: root/partition_tools
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-07-13 17:38:52 -0700
committerDavid Anderson <dvander@google.com>2018-07-13 18:22:12 -0700
commit3aa94b205b1e6eab383ea8216f7a56643073adbb (patch)
tree98cfcb76044745cb93dfbb7e79c34f1f98ef1aab /partition_tools
parent2ce2fa7eed139891406e4a5662a5481c3a376b54 (diff)
downloadextras-3aa94b205b1e6eab383ea8216f7a56643073adbb.tar.gz
lpmake: Add a --sparse option for creating super partition images.
This change allows creating a sparse image of the super partition, which can then be flashed using fastboot. Bug: 79173901 Test: N/A Change-Id: Ic49f843a47d5c222ce35ce1bda90fc8c0be578c8
Diffstat (limited to 'partition_tools')
-rw-r--r--partition_tools/lpmake.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/partition_tools/lpmake.cc b/partition_tools/lpmake.cc
index c056cfb0..d43a16c7 100644
--- a/partition_tools/lpmake.cc
+++ b/partition_tools/lpmake.cc
@@ -45,6 +45,7 @@ static int usage(int /* argc */, char* argv[]) {
" -o,--output=FILE Output file.\n"
" --alignment-offset=N Alignment offset in bytes to device parent.\n"
" --alignment=N Optimal partition alignment in bytes.\n"
+ " --sparse Output a sparse image for fastboot.\n"
"\n"
"Partition format:\n"
" <name>:<guid>:<attributes>:<size>\n"
@@ -63,6 +64,7 @@ int main(int argc, char* argv[]) {
{ "help", no_argument, nullptr, 'h' },
{ "alignment-offset", required_argument, nullptr, 'O' },
{ "alignment", required_argument, nullptr, 'a' },
+ { "sparse", no_argument, nullptr, 'S' },
{ nullptr, 0, nullptr, 0 },
};
@@ -73,6 +75,7 @@ int main(int argc, char* argv[]) {
uint32_t alignment = kDefaultPartitionAlignment;
std::string output_path;
std::vector<std::string> partitions;
+ bool output_sparse = false;
int rv;
int index;
@@ -116,6 +119,9 @@ int main(int argc, char* argv[]) {
return EX_USAGE;
}
break;
+ case 'S':
+ output_sparse = true;
+ break;
default:
break;
}
@@ -190,9 +196,12 @@ int main(int argc, char* argv[]) {
}
std::unique_ptr<LpMetadata> metadata = builder->Export();
- if (!WriteToImageFile(output_path.c_str(), *metadata.get())) {
+ if (output_sparse) {
+ if (!WriteToSparseFile(output_path.c_str(), *metadata.get())) {
+ return EX_CANTCREAT;
+ }
+ } else if (!WriteToImageFile(output_path.c_str(), *metadata.get())) {
return EX_CANTCREAT;
}
-
return EX_OK;
}