blob: 8725de7097a2c4302cbdc97ceb7aa83ce98c2022 [file] [log] [blame]
# 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")
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 = "minfs"
# 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
}
# Generates a structured config value file for fshost.
#
# Some of the configuration settings are build args, and some are parameters passed in to the
# template by the invoker. A few allow overriding by the invoker but fall back to the global build
# arg.
#
# 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 the defaults and template args but are overridden by global build args.
#
# no_minfs_zxcrypt (optional; default: false)
# [boolean] If set, fshost will look for a data partition that doesn't have zxcrypt set up, and
# instead has minfs directly on the device. This option will cause production builds to fail.
#
# fvm_ramdisk (optional; default: false)
# [boolean] If set, fshost will bind the fvm driver to the first ramdisk it finds that looks
# like an fvm partition, and uses it to back the system blobfs and minfs partitions. It will
# still look for and bind an on-disk fvm, but it doesn't use it for anything.
#
# gpt_all (optional; default: false)
# [boolean] If set, fshost will bind gpt to every block device it finds that looks like gpt,
# instead of just the first one it finds. This option will cause production builds to fail.
#
# minfs_maximum_runtime_bytes_override (optional)
# [string] If set, this option overrides the global build arg for minfs_maximum_runtime_bytes.
# See the related global build arg for more information.
#
# sandbox_decompression (optional; default: true)
# [boolean] Use the sandboxed decompressor for blobfs decompression, instead of doing
# decompression in-process.
#
# apply_limits_to_ramdisk (optional; default: false)
# [boolean] If set, apply the global build args for blobfs_maximum_runtime_bytes and
# minfs_maximum_runtime_bytes to filesystems in ramdisks. By default, these limits only apply
# to on-disk filesystems.
#
# check_filesystems (optional; default: true)
# [boolean] If set, run a filesystem check on minfs before mounting it. fshost never performs
# checks on any other filesystem. If not provided, this check can also be enabled by a kernel
# command line argument (it can't be disabled via one).
#
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
blobfs = true
blobfs_max_bytes = 0
bootpart = true
data = true
data_filesystem_format = ""
data_max_bytes = 0
durable = false
factory = false
format_data_on_corruption = true
fvm = true
gpt = true
mbr = false
nand = false
netboot = false
# Template arguments
allow_legacy_data_partition_names =
defined(invoker.allow_legacy_data_partition_names) &&
invoker.allow_legacy_data_partition_names
apply_limits_to_ramdisk = defined(invoker.apply_limits_to_ramdisk) &&
invoker.apply_limits_to_ramdisk
check_filesystems =
!defined(invoker.check_filesystems) || invoker.check_filesystems
gpt_all = defined(invoker.gpt_all) && invoker.gpt_all
no_zxcrypt = defined(invoker.no_minfs_zxcrypt) && invoker.no_minfs_zxcrypt
fvm_ramdisk = defined(invoker.fvm_ramdisk) && invoker.fvm_ramdisk
sandbox_decompression = !defined(invoker.sandbox_decompression) ||
invoker.sandbox_decompression
zxcrypt_non_ramdisk = fvm_ramdisk
# Final template argument allows setting arbitrary values which need to override
# template arguments but be overridden by build arguments.
if (defined(invoker.options)) {
forward_variables_from(invoker.options, "*")
}
# Build args
if (blobfs_maximum_runtime_bytes != "") {
blobfs_max_bytes = blobfs_maximum_runtime_bytes
}
if (defined(invoker.minfs_maximum_runtime_bytes_override)) {
# This can be overridden by the invoker but defaults to the file one if undefined.
data_max_bytes = invoker.minfs_maximum_runtime_bytes_override
} else if (minfs_maximum_runtime_bytes != "") {
data_max_bytes = minfs_maximum_runtime_bytes
}
if (!format_minfs_on_corruption) {
format_data_on_corruption = false
}
data_filesystem_format = invoker.data_filesystem_format
if (fshost_watch_for_nand) {
nand = true
}
}
# Don't allow these configurations into production.
if (values.no_zxcrypt || values.gpt_all) {
if (!defined(deps)) {
deps = []
}
deps += [ "//build/validate:non_production_tag" ]
}
}
}