| # Copyright 2021 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| import("//build/components.gni") | |
| import("//build/images/args.gni") | |
| import("//build/images/fvm.gni") | |
| declare_args() { | |
| # blobfs_maximum_runtime_bytes is an upper bound on the partition size on the device. Partitions | |
| # can grow as needed if there are extra slices available in FVM. This limit prevents the blobfs | |
| # partition from taking too much space away from other uses. | |
| # | |
| # Pass the empty string for no limit. | |
| blobfs_maximum_runtime_bytes = "" | |
| # minfs_maximum_runtime_bytes is an upper bound on the partition size on the device. Partitions | |
| # can grow as needed if there are extra slices available in FVM. This limit prevents the minfs | |
| # partition from taking too much space away from other uses. | |
| # | |
| # Pass the empty string for no limit. | |
| minfs_maximum_runtime_bytes = "" | |
| # If format_minfs_on_corruption is true (the default), fshost formats minfs partition on finding | |
| # it corrupted. Set to false to keep the devices in a corrupted state which might be of help to | |
| # debug issues. | |
| format_minfs_on_corruption = true | |
| # If extract_minfs_metadata_on_corruption is true, fshost extracts minfs metadata on finding it | |
| # corrupted. Setting this flag to true helps debugging corruptions. | |
| extract_minfs_metadata_on_corruption = false | |
| # Set to one of "minfs", "fxfs", "f2fs" (unstable). | |
| # If set to anything other than "minfs", any existing minfs partition will be | |
| # migrated in-place to the specified format when fshost mounts it. | |
| data_filesystem_format = "fxfs" | |
| # Set to true to enable legacy data partition names. | |
| allow_legacy_data_partition_names = false | |
| # Make fshost watch for NAND devices. | |
| fshost_watch_for_nand = false | |
| # If true, will attempt to copy the data partition to a new partition and then delete the old one | |
| # to migrate from minfs to fxfs. | |
| use_disk_based_minfs_migration = false | |
| # Enables the use of Fxfs' native encryption scheme, using a hardware key source when | |
| # available. | |
| # If set, devices not already using this scheme will be forcibly migrated, losing data. | |
| use_native_fxfs_crypto = true | |
| } | |
| # Generates a structured config value file for fshost. | |
| # | |
| # Parameters: | |
| # | |
| # component_name (optional) | |
| # [string] The name of the component for which to produce config, defaults to "fshost". | |
| # | |
| # options (optional) | |
| # [scope] A block of fshost configuration options to include in the config file. | |
| # Unrecognized options cause errors. Later options override earlier options. The provided | |
| # values override all other values, including defaults and build args. | |
| # | |
| template("generated_fshost_config") { | |
| _manifest_target = "${target_name}_manifest" | |
| _component_name = "fshost" | |
| if (defined(invoker.component_name)) { | |
| _component_name = invoker.component_name | |
| } | |
| fuchsia_component_manifest(_manifest_target) { | |
| component_name = _component_name | |
| manifest = "//src/storage/fshost/meta/config.cml" | |
| metadata = { | |
| # we don't want this in the packaged output, it's just to give cmc something to work with | |
| distribution_entries_barrier = [] | |
| } | |
| } | |
| fuchsia_structured_config_values(target_name) { | |
| cm_label = ":$_manifest_target" | |
| values = { | |
| # Defaults | |
| apply_limits_to_ramdisk = false | |
| blobfs = true | |
| blobfs_max_bytes = 0 | |
| bootpart = true | |
| check_filesystems = true | |
| data = true | |
| data_max_bytes = 0 | |
| disable_block_watcher = false | |
| factory = false | |
| fvm = true | |
| fvm_ramdisk = false | |
| gpt = true | |
| gpt_all = false | |
| mbr = false | |
| netboot = false | |
| no_zxcrypt = false | |
| ramdisk_prefix = "/dev/sys/platform/00:00:2d/ramctl/" | |
| sandbox_decompression = true | |
| # Parameters from //build/images/fvm.gni | |
| fvm_slice_size = fvm_slice_size | |
| # Parameters from //build/images/args.gni | |
| if (blobfs_product_minimum_inodes != false) { | |
| # Product-level overrides take precedence over board-level overrides. | |
| blobfs_initial_inodes = blobfs_product_minimum_inodes | |
| } else if (blobfs_board_minimum_inodes != false) { | |
| blobfs_initial_inodes = blobfs_board_minimum_inodes | |
| } else { | |
| blobfs_initial_inodes = 0 | |
| } | |
| assert(blob_layout_format == "compact" || | |
| blob_layout_format == "deprecated_padded", | |
| "Unrecognized format for blob layout.") | |
| if (blob_layout_format == "deprecated_padded") { | |
| blobfs_use_deprecated_padded_format = true | |
| } else { | |
| blobfs_use_deprecated_padded_format = false | |
| } | |
| # Build args | |
| allow_legacy_data_partition_names = allow_legacy_data_partition_names | |
| data_filesystem_format = data_filesystem_format | |
| format_data_on_corruption = format_minfs_on_corruption | |
| nand = fshost_watch_for_nand | |
| use_disk_based_minfs_migration = use_disk_based_minfs_migration | |
| use_native_fxfs_crypto = use_native_fxfs_crypto | |
| if (minfs_maximum_runtime_bytes != "") { | |
| data_max_bytes = minfs_maximum_runtime_bytes | |
| } | |
| if (blobfs_maximum_runtime_bytes != "") { | |
| blobfs_max_bytes = blobfs_maximum_runtime_bytes | |
| } | |
| if (defined(invoker.options)) { | |
| forward_variables_from(invoker.options, "*") | |
| } | |
| } | |
| # Don't allow these configurations into production. | |
| # Partition limits should always be set on production builds. | |
| if (values.no_zxcrypt || values.gpt_all || values.blobfs_max_bytes == 0 || | |
| values.data_max_bytes == 0) { | |
| if (!defined(deps)) { | |
| deps = [] | |
| } | |
| deps += [ "//build/validate:non_production_tag" ] | |
| } | |
| } | |
| } |