[size_checker] Introduce blob/capacity variable

Currently, we have a blob/contents_size variable that is used by
size_checker to determine the space available for allocation. However,
that variable indicates space for blobs for a single slot. Our new size
budgeting UX looks at total blobfs capacity because not all blobs are
duplicated across system slots. In particular, the Update Package is
downloaded after assembly. As such, we would like to track total blobfs
capacity as a separate product configuration variable. This CL
introduces the machinery to plumb that variable from {product}.gni to
filesystem_sizes.json at build time. Two more patches are necessary to
use this variable in size_checker

Bug: 81554
Change-Id: I608a5e95fa07331b0c862f3d217a9684bda615f3
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/559462
Reviewed-by: Aaron Wood <aaronwood@google.com>
Reviewed-by: Aidan Wolter <awolter@google.com>
Commit-Queue: Fady Samuel <fsamuel@google.com>
diff --git a/build/images/BUILD.gn b/build/images/BUILD.gn
index 28d887f..40f33bf 100644
--- a/build/images/BUILD.gn
+++ b/build/images/BUILD.gn
@@ -1241,6 +1241,8 @@
   rebase_path(minfs_tool_path, root_build_dir),
   "--max-fvm-contents-size",
   "$fvm_max_disk_size_default_zero",
+  "--blobfs-capacity",
+  blobfs_capacity,
   "--max-blob-contents-size",
   max_blob_contents_size,
   "--max-blob-image-size",
diff --git a/build/images/filesystem_limits.gni b/build/images/filesystem_limits.gni
index 16a26d9..603bde3 100644
--- a/build/images/filesystem_limits.gni
+++ b/build/images/filesystem_limits.gni
@@ -9,6 +9,11 @@
   # of how they are stored).
   max_blob_contents_size = "0"
 
+  # Maximum allowable contents for the /blob in a release mode build for
+  # both slot A and slot B of the system.
+  # Zero means no limit.
+  blobfs_capacity = "0"
+
   # Maximum allowable image_size for /blob in a release mode build.
   # Zero means no limit.
   # image_size refers to the total image size, including both contents and
diff --git a/build/images/format_filesystem_sizes.py b/build/images/format_filesystem_sizes.py
index 450a081..40a4b3b 100755
--- a/build/images/format_filesystem_sizes.py
+++ b/build/images/format_filesystem_sizes.py
@@ -11,6 +11,14 @@
 import sys
 
 
+class Capacity(object):
+
+    def __init__(self, name, capacity, debug=None):
+        self.name = name
+        self.size = capacity
+        self.limit = capacity
+        self.debug = debug
+
 class CmdSize(object):
 
     def __init__(self, name, cmd, limit, debug=None):
@@ -43,9 +51,13 @@
     parser.add_argument(
         '--max-fvm-contents-size', help='Total size limit for FVM')
     parser.add_argument(
+        '--blobfs-capacity',
+        default='0',
+        help='Maximum size for blobfs contents in both slot A and B')
+    parser.add_argument(
         '--max-blob-contents-size',
         default='0',
-        help='Maximum size for blob contents')
+        help='Maximum size for blobfs contents')
     parser.add_argument(
         '--max-blob-image-size',
         default='0',
@@ -79,6 +91,8 @@
         blob_tool_prefix = [args.blobfs_tool, args.blob_blk]
         data_points.extend(
             [
+                Capacity(
+                    'blob/capacity', args.blobfs_capacity),
                 CmdSize(
                     'blob/contents_size',
                     blob_tool_prefix + ['used-data-size'],
diff --git a/docs/gen/build_arguments.md b/docs/gen/build_arguments.md
index 90d4d5c..c22665d 100644
--- a/docs/gen/build_arguments.md
+++ b/docs/gen/build_arguments.md
@@ -2089,6 +2089,12 @@
 
 From //src/graphics/lib/magma/gnbuild/magma.gni:20
 
+### blobfs_capacity
+Maximum allowable contents for the /blob in a release mode build for
+both slot A and B of the system.
+Zero means no limit.
+
+**Current value (from the default):** `"0"`
 ### max_blob_contents_size
 Maximum allowable contents for the /blob in a release mode build.
 Zero means no limit.