diff options
author | David Anderson <dvander@google.com> | 2018-07-17 15:54:44 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2018-07-17 18:43:35 -0700 |
commit | aca58a4abbfbcac263892c265657ba5b2158fb35 (patch) | |
tree | 0bab0b749b6f58afa7fec2db201d8e781a390920 /partition_tools | |
parent | 24a436a49e6540f466159ea5510356a31ea2cb39 (diff) | |
download | extras-aca58a4abbfbcac263892c265657ba5b2158fb35.tar.gz |
lpmake: Pass a block size to WriteToSparseFile.
Note: The default block size is 4096.
Bug: 79173901
Test: lpmake -S can be flashed to Pixel 2
Change-Id: I44a96126edddbaedf078c3a59be3a74df89c0d74
Diffstat (limited to 'partition_tools')
-rw-r--r-- | partition_tools/README.md | 1 | ||||
-rw-r--r-- | partition_tools/lpmake.cc | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/partition_tools/README.md b/partition_tools/README.md index abd38992..0993ce29 100644 --- a/partition_tools/README.md +++ b/partition_tools/README.md @@ -19,6 +19,7 @@ Optional arguments: * `--alignment=N` - By default, lpmake will align partitions to 1MiB boundaries. However, an alternate alignment can be specified if desired. This is useful for devices with a minimum I/O request size where mis-aligned partition boundaries could be a performance issue. * `--alignment-offset=N` - In some cases, the "super" partition is misaligned within its parent block device. This offset can be used to correct for that. * `--sparse` - If set, the output image will be in sparse format for flashing with fastboot. Otherwise, by default, the image will be a minimal format usable with lpdump and lpflash. +* `-b,--block-size=N` - When writing sparse files, the device may require a specific block size. That block size can be specified here. The alignment must be a multiple of the block size. By default the block size is 4096. Example usage. This specifies a 10GB super partition for an A/B device, with a single 64MiB "cache" partition. diff --git a/partition_tools/lpmake.cc b/partition_tools/lpmake.cc index a484a2c8..25133445 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" "\n" "Optional:\n" + " -b,--block-size=SIZE Physical block size, defaults to 4096.\n" " -a,--alignment=N Optimal partition alignment in bytes.\n" " -O,--alignment-offset=N Alignment offset in bytes to device parent.\n" " -S,--sparse Output a sparse image for fastboot.\n" @@ -67,6 +68,7 @@ int main(int argc, char* argv[]) { { "alignment-offset", required_argument, nullptr, 'O' }, { "alignment", required_argument, nullptr, 'a' }, { "sparse", no_argument, nullptr, 'S' }, + { "block-size", required_argument, nullptr, 'b' }, { nullptr, 0, nullptr, 0 }, }; @@ -75,6 +77,7 @@ int main(int argc, char* argv[]) { uint32_t metadata_slots = 0; uint32_t alignment_offset = 0; uint32_t alignment = kDefaultPartitionAlignment; + uint32_t block_size = 4096; std::string output_path; std::vector<std::string> partitions; bool output_sparse = false; @@ -124,6 +127,12 @@ int main(int argc, char* argv[]) { case 'S': output_sparse = true; break; + case 'b': + if (!android::base::ParseUint(optarg, &block_size) || !block_size) { + fprintf(stderr, "Invalid argument to --block-size.\n"); + return EX_USAGE; + } + break; default: break; } @@ -199,7 +208,7 @@ int main(int argc, char* argv[]) { std::unique_ptr<LpMetadata> metadata = builder->Export(); if (output_sparse) { - if (!WriteToSparseFile(output_path.c_str(), *metadata.get())) { + if (!WriteToSparseFile(output_path.c_str(), *metadata.get(), block_size)) { return EX_CANTCREAT; } } else if (!WriteToImageFile(output_path.c_str(), *metadata.get())) { |