blob: 0599ea0a92fa6613005cec38ae8a7fe35677ceb6 [file] [log] [blame]
Jiyong Park6f0f6882020-11-12 13:14:30 +09001// Copyright (C) 2020 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package filesystem
16
17import (
Jooyung Han65f402b2022-04-21 14:24:04 +090018 "crypto/sha256"
Jiyong Park6f0f6882020-11-12 13:14:30 +090019 "fmt"
Jooyung Han65f402b2022-04-21 14:24:04 +090020 "io"
Inseob Kim14199b02021-02-09 21:18:31 +090021 "path/filepath"
Cole Faust4a2a7c92024-03-12 12:44:40 -070022 "slices"
Nikita Ioffe2c8cdc62024-03-27 22:19:30 +000023 "strconv"
Inseob Kim14199b02021-02-09 21:18:31 +090024 "strings"
Jiyong Park6f0f6882020-11-12 13:14:30 +090025
26 "android/soong/android"
Jooyung Hane6067592023-03-16 13:11:17 +090027 "android/soong/cc"
Jiyong Park65b62242020-11-25 12:44:59 +090028
29 "github.com/google/blueprint"
Jiyong Park71baa762021-01-18 21:11:03 +090030 "github.com/google/blueprint/proptools"
Jiyong Park6f0f6882020-11-12 13:14:30 +090031)
32
33func init() {
Jooyung Han9706cbc2021-04-15 22:43:48 +090034 registerBuildComponents(android.InitRegistrationContext)
35}
36
37func registerBuildComponents(ctx android.RegistrationContext) {
Cole Faust92ccbe22024-10-03 14:38:37 -070038 ctx.RegisterModuleType("android_filesystem", FilesystemFactory)
Jiyong Parkf46b1af2024-04-05 18:13:33 +090039 ctx.RegisterModuleType("android_filesystem_defaults", filesystemDefaultsFactory)
Jihoon Kang98047cf2024-10-02 17:13:54 +000040 ctx.RegisterModuleType("android_system_image", SystemImageFactory)
Jiyong Parkbc485482022-11-15 22:31:49 +090041 ctx.RegisterModuleType("avb_add_hash_footer", avbAddHashFooterFactory)
Inseob Kim87230e62023-11-22 18:55:07 +090042 ctx.RegisterModuleType("avb_add_hash_footer_defaults", avbAddHashFooterDefaultsFactory)
Alice Wang000e3a32023-01-03 16:11:20 +000043 ctx.RegisterModuleType("avb_gen_vbmeta_image", avbGenVbmetaImageFactory)
Inseob Kim87230e62023-11-22 18:55:07 +090044 ctx.RegisterModuleType("avb_gen_vbmeta_image_defaults", avbGenVbmetaImageDefaultsFactory)
Jiyong Park6f0f6882020-11-12 13:14:30 +090045}
46
47type filesystem struct {
48 android.ModuleBase
49 android.PackagingBase
Jiyong Parkf46b1af2024-04-05 18:13:33 +090050 android.DefaultableModuleBase
Jiyong Park65c49f52020-11-24 14:23:26 +090051
Jihoon Kang98047cf2024-10-02 17:13:54 +000052 properties FilesystemProperties
Jiyong Park71baa762021-01-18 21:11:03 +090053
Jiyong Parkfa616132021-04-20 11:36:40 +090054 // Function that builds extra files under the root directory and returns the files
55 buildExtraFiles func(ctx android.ModuleContext, root android.OutputPath) android.OutputPaths
56
Jeongik Cha54bf8752024-02-08 10:44:37 +090057 // Function that filters PackagingSpec in PackagingBase.GatherPackagingSpecs()
58 filterPackagingSpec func(spec android.PackagingSpec) bool
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090059
Jiyong Park65c49f52020-11-24 14:23:26 +090060 output android.OutputPath
61 installDir android.InstallPath
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090062
Kiyoung Kim99a954d2024-06-21 14:22:20 +090063 fileListFile android.OutputPath
64
65 // Keeps the entries installed from this filesystem
Jooyung Han0fbbc2b2022-03-25 12:35:46 +090066 entries []string
Jiyong Park6f0f6882020-11-12 13:14:30 +090067}
68
Spandan Das69464c32024-10-25 20:08:06 +000069type SymlinkDefinition struct {
Inseob Kim14199b02021-02-09 21:18:31 +090070 Target *string
71 Name *string
72}
73
Jihoon Kang98047cf2024-10-02 17:13:54 +000074type FilesystemProperties struct {
Jiyong Park71baa762021-01-18 21:11:03 +090075 // When set to true, sign the image with avbtool. Default is false.
76 Use_avb *bool
77
78 // Path to the private key that avbtool will use to sign this filesystem image.
79 // TODO(jiyong): allow apex_key to be specified here
80 Avb_private_key *string `android:"path"`
81
Shikha Panwar01403bb2022-12-22 12:22:57 +000082 // Signing algorithm for avbtool. Default is SHA256_RSA4096.
Jiyong Park71baa762021-01-18 21:11:03 +090083 Avb_algorithm *string
Jiyong Park11a65972021-02-01 21:09:38 +090084
Shikha Panwar01403bb2022-12-22 12:22:57 +000085 // Hash algorithm used for avbtool (for descriptors). This is passed as hash_algorithm to
86 // avbtool. Default used by avbtool is sha1.
Shikha Panware6f30632022-12-21 12:54:45 +000087 Avb_hash_algorithm *string
88
Nikita Ioffe2c8cdc62024-03-27 22:19:30 +000089 // The index used to prevent rollback of the image. Only used if use_avb is true.
90 Rollback_index *int64
91
Jiyong Parkac4076d2021-03-15 23:21:30 +090092 // Name of the partition stored in vbmeta desc. Defaults to the name of this module.
93 Partition_name *string
94
Spandan Dasc35d6fb2024-10-10 17:51:14 +000095 // Type of the filesystem. Currently, ext4, erofs, cpio, and compressed_cpio are supported. Default
Jiyong Park837cdb22021-02-05 00:17:14 +090096 // is ext4.
Jiyong Park11a65972021-02-01 21:09:38 +090097 Type *string
Inseob Kimcc8e5362021-02-03 14:05:24 +090098
Cole Faust9a24d902024-03-18 15:38:12 -070099 // Identifies which partition this is for //visibility:any_system_image (and others) visibility
100 // checks, and will be used in the future for API surface checks.
101 Partition_type *string
102
Inseob Kimcc8e5362021-02-03 14:05:24 +0900103 // file_contexts file to make image. Currently, only ext4 is supported.
104 File_contexts *string `android:"path"`
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900105
106 // Base directory relative to root, to which deps are installed, e.g. "system". Default is "."
107 // (root).
108 Base_dir *string
Inseob Kim14199b02021-02-09 21:18:31 +0900109
110 // Directories to be created under root. e.g. /dev, /proc, etc.
Cole Faustd9c6a5b2024-05-21 14:54:00 -0700111 Dirs proptools.Configurable[[]string]
Inseob Kim14199b02021-02-09 21:18:31 +0900112
113 // Symbolic links to be created under root with "ln -sf <target> <name>".
Spandan Das69464c32024-10-25 20:08:06 +0000114 Symlinks []SymlinkDefinition
Jooyung Han65f402b2022-04-21 14:24:04 +0900115
116 // Seconds since unix epoch to override timestamps of file entries
117 Fake_timestamp *string
118
119 // When set, passed to mkuserimg_mke2fs --mke2fs_uuid & --mke2fs_hash_seed.
120 // Otherwise, they'll be set as random which might cause indeterministic build output.
121 Uuid *string
Inseob Kim376d72f2023-11-01 15:40:25 +0900122
123 // Mount point for this image. Default is "/"
124 Mount_point *string
Cole Faust4a2a7c92024-03-12 12:44:40 -0700125
126 // If set to the name of a partition ("system", "vendor", etc), this filesystem module
127 // will also include the contents of the make-built staging directories. If any soong
128 // modules would be installed to the same location as a make module, they will overwrite
129 // the make version.
130 Include_make_built_files string
Inseob Kim53391842024-03-29 17:44:07 +0900131
Inseob Kimb7b84572024-04-30 10:51:47 +0900132 // When set, builds etc/event-log-tags file by merging logtags from all dependencies.
133 // Default is false
134 Build_logtags *bool
135
Justin Yun74f3f302024-05-07 14:32:14 +0900136 // Install aconfig_flags.pb file for the modules installed in this partition.
137 Gen_aconfig_flags_pb *bool
138
Inseob Kim53391842024-03-29 17:44:07 +0900139 Fsverity fsverityProperties
Cole Faust92ccbe22024-10-03 14:38:37 -0700140
141 // If this property is set to true, the filesystem will call ctx.UncheckedModule(), causing
142 // it to not be built on checkbuilds. Used for the automatic migration from make to soong
143 // build modules, where we want to emit some not-yet-working filesystems and we don't want them
144 // to be built.
145 Unchecked_module *bool `blueprint:"mutated"`
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000146
147 Erofs ErofsProperties
Jihoon Kang0d545b82024-10-11 00:21:57 +0000148
149 // Determines if the module is auto-generated from Soong or not. If the module is
150 // auto-generated, its deps are exempted from visibility enforcement.
151 Is_auto_generated *bool
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000152}
153
154// Additional properties required to generate erofs FS partitions.
155type ErofsProperties struct {
156 // Compressor and Compression level passed to mkfs.erofs. e.g. (lz4hc,9)
157 // Please see external/erofs-utils/README for complete documentation.
158 Compressor *string
159
160 // Used as --compress-hints for mkfs.erofs
161 Compress_hints *string `android:"path"`
162
163 Sparse *bool
Jiyong Park71baa762021-01-18 21:11:03 +0900164}
165
Jiyong Park65c49f52020-11-24 14:23:26 +0900166// android_filesystem packages a set of modules and their transitive dependencies into a filesystem
167// image. The filesystem images are expected to be mounted in the target device, which means the
168// modules in the filesystem image are built for the target device (i.e. Android, not Linux host).
169// The modules are placed in the filesystem image just like they are installed to the ordinary
170// partitions like system.img. For example, cc_library modules are placed under ./lib[64] directory.
Cole Faust92ccbe22024-10-03 14:38:37 -0700171func FilesystemFactory() android.Module {
Jiyong Park6f0f6882020-11-12 13:14:30 +0900172 module := &filesystem{}
Jiyong Park7e7d4af2024-05-01 12:36:10 +0000173 module.filterPackagingSpec = module.filterInstallablePackagingSpec
Cole Faust2cfe6962024-09-17 11:31:14 -0700174 initFilesystemModule(module, module)
Jiyong Parkfa616132021-04-20 11:36:40 +0900175 return module
176}
177
Cole Faust2cfe6962024-09-17 11:31:14 -0700178func initFilesystemModule(module android.DefaultableModule, filesystemModule *filesystem) {
179 module.AddProperties(&filesystemModule.properties)
180 android.InitPackageModule(filesystemModule)
181 filesystemModule.PackagingBase.DepsCollectFirstTargetOnly = true
Jihoon Kang79196c52024-10-30 18:49:47 +0000182 filesystemModule.PackagingBase.AllowHighPriorityDeps = true
Jiyong Park6f0f6882020-11-12 13:14:30 +0900183 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900184 android.InitDefaultableModule(module)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900185}
186
Jihoon Kang0d545b82024-10-11 00:21:57 +0000187type depTag struct {
Jiyong Park12a719c2021-01-07 15:31:24 +0900188 blueprint.BaseDependencyTag
Jooyung Han092ef812021-03-10 15:40:34 +0900189 android.PackagingItemAlwaysDepTag
Jihoon Kang0d545b82024-10-11 00:21:57 +0000190}
191
192var dependencyTag = depTag{}
193
194type depTagWithVisibilityEnforcementBypass struct {
195 depTag
196}
197
198var _ android.ExcludeFromVisibilityEnforcementTag = (*depTagWithVisibilityEnforcementBypass)(nil)
199
200func (t depTagWithVisibilityEnforcementBypass) ExcludeFromVisibilityEnforcement() {}
201
202var dependencyTagWithVisibilityEnforcementBypass = depTagWithVisibilityEnforcementBypass{}
Jiyong Park65b62242020-11-25 12:44:59 +0900203
Jiyong Park6f0f6882020-11-12 13:14:30 +0900204func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) {
Jihoon Kang0d545b82024-10-11 00:21:57 +0000205 if proptools.Bool(f.properties.Is_auto_generated) {
206 f.AddDeps(ctx, dependencyTagWithVisibilityEnforcementBypass)
207 } else {
208 f.AddDeps(ctx, dependencyTag)
209 }
Jiyong Park6f0f6882020-11-12 13:14:30 +0900210}
211
Jiyong Park11a65972021-02-01 21:09:38 +0900212type fsType int
213
214const (
215 ext4Type fsType = iota
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000216 erofsType
Jiyong Park11a65972021-02-01 21:09:38 +0900217 compressedCpioType
Jiyong Park837cdb22021-02-05 00:17:14 +0900218 cpioType // uncompressed
Jiyong Park11a65972021-02-01 21:09:38 +0900219 unknown
220)
221
Spandan Das7a46f6c2024-10-14 18:41:18 +0000222func (fs fsType) IsUnknown() bool {
223 return fs == unknown
224}
225
Cole Faust92ccbe22024-10-03 14:38:37 -0700226type FilesystemInfo struct {
227 // A text file containing the list of paths installed on the partition.
228 FileListFile android.Path
229}
230
231var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]()
232
Spandan Das7a46f6c2024-10-14 18:41:18 +0000233func GetFsTypeFromString(ctx android.EarlyModuleContext, typeStr string) fsType {
Jiyong Park11a65972021-02-01 21:09:38 +0900234 switch typeStr {
235 case "ext4":
236 return ext4Type
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000237 case "erofs":
238 return erofsType
Jiyong Park11a65972021-02-01 21:09:38 +0900239 case "compressed_cpio":
240 return compressedCpioType
Jiyong Park837cdb22021-02-05 00:17:14 +0900241 case "cpio":
242 return cpioType
Jiyong Park11a65972021-02-01 21:09:38 +0900243 default:
Jiyong Park11a65972021-02-01 21:09:38 +0900244 return unknown
245 }
246}
247
Spandan Das7a46f6c2024-10-14 18:41:18 +0000248func (f *filesystem) fsType(ctx android.ModuleContext) fsType {
249 typeStr := proptools.StringDefault(f.properties.Type, "ext4")
250 fsType := GetFsTypeFromString(ctx, typeStr)
251 if fsType == unknown {
252 ctx.PropertyErrorf("type", "%q not supported", typeStr)
253 }
254 return fsType
255}
256
Jiyong Park65c49f52020-11-24 14:23:26 +0900257func (f *filesystem) installFileName() string {
258 return f.BaseModuleName() + ".img"
259}
260
Inseob Kim53391842024-03-29 17:44:07 +0900261func (f *filesystem) partitionName() string {
262 return proptools.StringDefault(f.properties.Partition_name, f.Name())
263}
264
Jiyong Park7e7d4af2024-05-01 12:36:10 +0000265func (f *filesystem) filterInstallablePackagingSpec(ps android.PackagingSpec) bool {
266 // Filesystem module respects the installation semantic. A PackagingSpec from a module with
267 // IsSkipInstall() is skipped.
Spandan Das6d056502024-10-21 15:40:32 +0000268 if proptools.Bool(f.properties.Is_auto_generated) { // TODO (spandandas): Remove this.
269 return !ps.SkipInstall() && (ps.Partition() == f.PartitionType())
270 }
271 return !ps.SkipInstall()
Jiyong Park7e7d4af2024-05-01 12:36:10 +0000272}
273
Jiyong Park6f0f6882020-11-12 13:14:30 +0900274var pctx = android.NewPackageContext("android/soong/filesystem")
275
276func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900277 validatePartitionType(ctx, f)
Jiyong Park11a65972021-02-01 21:09:38 +0900278 switch f.fsType(ctx) {
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000279 case ext4Type, erofsType:
Jiyong Park11a65972021-02-01 21:09:38 +0900280 f.output = f.buildImageUsingBuildImage(ctx)
281 case compressedCpioType:
Jiyong Park837cdb22021-02-05 00:17:14 +0900282 f.output = f.buildCpioImage(ctx, true)
283 case cpioType:
284 f.output = f.buildCpioImage(ctx, false)
Jiyong Park11a65972021-02-01 21:09:38 +0900285 default:
286 return
287 }
288
289 f.installDir = android.PathForModuleInstall(ctx, "etc")
290 ctx.InstallFile(f.installDir, f.installFileName(), f.output)
mrziwang555d1332024-06-07 11:15:33 -0700291 ctx.SetOutputFiles([]android.Path{f.output}, "")
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900292
293 f.fileListFile = android.PathForModuleOut(ctx, "fileList").OutputPath
294 android.WriteFileRule(ctx, f.fileListFile, f.installedFilesList())
Cole Faust92ccbe22024-10-03 14:38:37 -0700295
296 android.SetProvider(ctx, FilesystemProvider, FilesystemInfo{
297 FileListFile: f.fileListFile,
298 })
299
300 if proptools.Bool(f.properties.Unchecked_module) {
301 ctx.UncheckedModule()
302 }
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900303}
304
305func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.OutputPath) {
306 partitionBaseDir := android.PathForModuleOut(ctx, "root", f.partitionName()).String() + "/"
307
308 relPath, inTargetPartition := strings.CutPrefix(installedFile.String(), partitionBaseDir)
309 if inTargetPartition {
310 f.entries = append(f.entries, relPath)
311 }
312}
313
314func (f *filesystem) installedFilesList() string {
315 installedFilePaths := android.FirstUniqueStrings(f.entries)
316 slices.Sort(installedFilePaths)
317
318 return strings.Join(installedFilePaths, "\n")
Jiyong Park11a65972021-02-01 21:09:38 +0900319}
320
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900321func validatePartitionType(ctx android.ModuleContext, p partition) {
322 if !android.InList(p.PartitionType(), validPartitions) {
323 ctx.PropertyErrorf("partition_type", "partition_type must be one of %s, found: %s", validPartitions, p.PartitionType())
324 }
325
326 ctx.VisitDirectDepsWithTag(android.DefaultsDepTag, func(m android.Module) {
327 if fdm, ok := m.(*filesystemDefaults); ok {
328 if p.PartitionType() != fdm.PartitionType() {
329 ctx.PropertyErrorf("partition_type",
330 "%s doesn't match with the partition type %s of the filesystem default module %s",
331 p.PartitionType(), fdm.PartitionType(), m.Name())
332 }
333 }
334 })
335}
336
Cole Faust3b806d32024-03-11 15:15:03 -0700337// Copy extra files/dirs that are not from the `deps` property to `rootDir`, checking for conflicts with files
338// already in `rootDir`.
339func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.OutputPath) {
Inseob Kim14199b02021-02-09 21:18:31 +0900340 // create dirs and symlinks
Cole Faustd9c6a5b2024-05-21 14:54:00 -0700341 for _, dir := range f.properties.Dirs.GetOrDefault(ctx, nil) {
Inseob Kim14199b02021-02-09 21:18:31 +0900342 // OutputPath.Join verifies dir
343 builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, dir).String())
344 }
345
346 for _, symlink := range f.properties.Symlinks {
347 name := strings.TrimSpace(proptools.String(symlink.Name))
348 target := strings.TrimSpace(proptools.String(symlink.Target))
349
350 if name == "" {
351 ctx.PropertyErrorf("symlinks", "Name can't be empty")
352 continue
353 }
354
355 if target == "" {
356 ctx.PropertyErrorf("symlinks", "Target can't be empty")
357 continue
358 }
359
360 // OutputPath.Join verifies name. don't need to verify target.
361 dst := rootDir.Join(ctx, name)
Cole Faust3b806d32024-03-11 15:15:03 -0700362 builder.Command().Textf("(! [ -e %s -o -L %s ] || (echo \"%s already exists from an earlier stage of the build\" && exit 1))", dst, dst, dst)
Inseob Kim14199b02021-02-09 21:18:31 +0900363 builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String()))
364 builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String())
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900365 f.appendToEntry(ctx, dst)
Inseob Kim14199b02021-02-09 21:18:31 +0900366 }
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900367
Jiyong Parkfa616132021-04-20 11:36:40 +0900368 // create extra files if there's any
Jiyong Parkfa616132021-04-20 11:36:40 +0900369 if f.buildExtraFiles != nil {
Cole Faust4a2a7c92024-03-12 12:44:40 -0700370 rootForExtraFiles := android.PathForModuleGen(ctx, "root-extra").OutputPath
371 extraFiles := f.buildExtraFiles(ctx, rootForExtraFiles)
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900372 for _, extraFile := range extraFiles {
373 rel, err := filepath.Rel(rootForExtraFiles.String(), extraFile.String())
Cole Faust4a2a7c92024-03-12 12:44:40 -0700374 if err != nil || strings.HasPrefix(rel, "..") {
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900375 ctx.ModuleErrorf("can't make %q relative to %q", extraFile, rootForExtraFiles)
Cole Faust4a2a7c92024-03-12 12:44:40 -0700376 }
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900377 f.appendToEntry(ctx, rootDir.Join(ctx, rel))
Jiyong Parkfa616132021-04-20 11:36:40 +0900378 }
Cole Faust4a2a7c92024-03-12 12:44:40 -0700379 if len(extraFiles) > 0 {
380 builder.Command().BuiltTool("merge_directories").
381 Implicits(extraFiles.Paths()).
382 Text(rootDir.String()).
383 Text(rootForExtraFiles.String())
384 }
Jiyong Parkfa616132021-04-20 11:36:40 +0900385 }
Inseob Kim2ce1b5d2021-02-15 17:01:04 +0900386}
387
Inseob Kim33f95a92024-07-11 15:44:49 +0900388func (f *filesystem) copyPackagingSpecs(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir, rebasedDir android.WritablePath) []string {
389 rootDirSpecs := make(map[string]android.PackagingSpec)
390 rebasedDirSpecs := make(map[string]android.PackagingSpec)
391
392 for rel, spec := range specs {
393 if spec.Partition() == "root" {
394 rootDirSpecs[rel] = spec
395 } else {
396 rebasedDirSpecs[rel] = spec
397 }
398 }
399
400 dirsToSpecs := make(map[android.WritablePath]map[string]android.PackagingSpec)
401 dirsToSpecs[rootDir] = rootDirSpecs
402 dirsToSpecs[rebasedDir] = rebasedDirSpecs
403
404 return f.CopySpecsToDirs(ctx, builder, dirsToSpecs)
405}
406
Justin Yun34baa2e2024-08-30 21:11:33 +0900407func (f *filesystem) copyFilesToProductOut(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
Justin Yun2cc42502024-09-11 14:10:20 +0900408 if f.Name() != ctx.Config().SoongDefinedSystemImage() {
Justin Yun34baa2e2024-08-30 21:11:33 +0900409 return
410 }
411 installPath := android.PathForModuleInPartitionInstall(ctx, f.partitionName())
412 builder.Command().Textf("cp -prf %s/* %s", rebasedDir, installPath)
413}
414
Jiyong Park11a65972021-02-01 21:09:38 +0900415func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath {
Jiyong Park6f0f6882020-11-12 13:14:30 +0900416 rootDir := android.PathForModuleOut(ctx, "root").OutputPath
Cole Faust3b806d32024-03-11 15:15:03 -0700417 rebasedDir := rootDir
418 if f.properties.Base_dir != nil {
419 rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
420 }
421 builder := android.NewRuleBuilder(pctx, ctx)
422 // Wipe the root dir to get rid of leftover files from prior builds
423 builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
Inseob Kim53391842024-03-29 17:44:07 +0900424 specs := f.gatherFilteredPackagingSpecs(ctx)
Inseob Kim33f95a92024-07-11 15:44:49 +0900425 f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
Cole Faust3b806d32024-03-11 15:15:03 -0700426
427 f.buildNonDepsFiles(ctx, builder, rootDir)
Cole Faust4a2a7c92024-03-12 12:44:40 -0700428 f.addMakeBuiltFiles(ctx, builder, rootDir)
Inseob Kim53391842024-03-29 17:44:07 +0900429 f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
Inseob Kimb7b84572024-04-30 10:51:47 +0900430 f.buildEventLogtagsFile(ctx, builder, rebasedDir)
Justin Yun74f3f302024-05-07 14:32:14 +0900431 f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
Justin Yun34baa2e2024-08-30 21:11:33 +0900432 f.copyFilesToProductOut(ctx, builder, rebasedDir)
Jiyong Park6f0f6882020-11-12 13:14:30 +0900433
Nikita Ioffe519015f2022-12-23 15:36:29 +0000434 // run host_init_verifier
435 // Ideally we should have a concept of pluggable linters that verify the generated image.
436 // While such concept is not implement this will do.
437 // TODO(b/263574231): substitute with pluggable linter.
438 builder.Command().
439 BuiltTool("host_init_verifier").
440 FlagWithArg("--out_system=", rootDir.String()+"/system")
441
Jiyong Park72678312021-01-18 17:29:49 +0900442 propFile, toolDeps := f.buildPropFile(ctx)
Jiyong Park11a65972021-02-01 21:09:38 +0900443 output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath
Colin Crossf1a035e2020-11-16 17:32:30 -0800444 builder.Command().BuiltTool("build_image").
Jiyong Park6f0f6882020-11-12 13:14:30 +0900445 Text(rootDir.String()). // input directory
446 Input(propFile).
Jiyong Park72678312021-01-18 17:29:49 +0900447 Implicits(toolDeps).
Jiyong Park11a65972021-02-01 21:09:38 +0900448 Output(output).
Jiyong Park6f0f6882020-11-12 13:14:30 +0900449 Text(rootDir.String()) // directory where to find fs_config_files|dirs
450
451 // rootDir is not deleted. Might be useful for quick inspection.
Colin Crossf1a035e2020-11-16 17:32:30 -0800452 builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
Jiyong Park65c49f52020-11-24 14:23:26 +0900453
Jiyong Park11a65972021-02-01 21:09:38 +0900454 return output
Jiyong Park65c49f52020-11-24 14:23:26 +0900455}
456
Inseob Kimcc8e5362021-02-03 14:05:24 +0900457func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.OutputPath {
458 builder := android.NewRuleBuilder(pctx, ctx)
459 fcBin := android.PathForModuleOut(ctx, "file_contexts.bin")
460 builder.Command().BuiltTool("sefcontext_compile").
461 FlagWithOutput("-o ", fcBin).
462 Input(android.PathForModuleSrc(ctx, proptools.String(f.properties.File_contexts)))
463 builder.Build("build_filesystem_file_contexts", fmt.Sprintf("Creating filesystem file contexts for %s", f.BaseModuleName()))
464 return fcBin.OutputPath
465}
466
Jooyung Han65f402b2022-04-21 14:24:04 +0900467// Calculates avb_salt from entry list (sorted) for deterministic output.
468func (f *filesystem) salt() string {
469 return sha1sum(f.entries)
470}
471
Jiyong Park72678312021-01-18 17:29:49 +0900472func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) {
Jiyong Park72678312021-01-18 17:29:49 +0900473 var deps android.Paths
Cole Faustcec230a2024-03-07 15:51:12 -0800474 var propFileString strings.Builder
Jiyong Park72678312021-01-18 17:29:49 +0900475 addStr := func(name string, value string) {
Cole Faustcec230a2024-03-07 15:51:12 -0800476 propFileString.WriteString(name)
477 propFileString.WriteRune('=')
478 propFileString.WriteString(value)
479 propFileString.WriteRune('\n')
Jiyong Park72678312021-01-18 17:29:49 +0900480 }
481 addPath := func(name string, path android.Path) {
Cole Faustcec230a2024-03-07 15:51:12 -0800482 addStr(name, path.String())
Jiyong Park72678312021-01-18 17:29:49 +0900483 deps = append(deps, path)
484 }
485
Jiyong Park11a65972021-02-01 21:09:38 +0900486 // Type string that build_image.py accepts.
487 fsTypeStr := func(t fsType) string {
488 switch t {
Spandan Das94668822024-10-09 20:51:33 +0000489 // TODO(372522486): add more types like f2fs, erofs, etc.
Jiyong Park11a65972021-02-01 21:09:38 +0900490 case ext4Type:
491 return "ext4"
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000492 case erofsType:
493 return "erofs"
Jiyong Park11a65972021-02-01 21:09:38 +0900494 }
495 panic(fmt.Errorf("unsupported fs type %v", t))
496 }
497
498 addStr("fs_type", fsTypeStr(f.fsType(ctx)))
Inseob Kim376d72f2023-11-01 15:40:25 +0900499 addStr("mount_point", proptools.StringDefault(f.properties.Mount_point, "/"))
Jiyong Park72678312021-01-18 17:29:49 +0900500 addStr("use_dynamic_partition_size", "true")
501 addPath("ext_mkuserimg", ctx.Config().HostToolPath(ctx, "mkuserimg_mke2fs"))
502 // b/177813163 deps of the host tools have to be added. Remove this.
503 for _, t := range []string{"mke2fs", "e2fsdroid", "tune2fs"} {
504 deps = append(deps, ctx.Config().HostToolPath(ctx, t))
505 }
506
Jiyong Park71baa762021-01-18 21:11:03 +0900507 if proptools.Bool(f.properties.Use_avb) {
508 addStr("avb_hashtree_enable", "true")
509 addPath("avb_avbtool", ctx.Config().HostToolPath(ctx, "avbtool"))
510 algorithm := proptools.StringDefault(f.properties.Avb_algorithm, "SHA256_RSA4096")
511 addStr("avb_algorithm", algorithm)
512 key := android.PathForModuleSrc(ctx, proptools.String(f.properties.Avb_private_key))
513 addPath("avb_key_path", key)
Inseob Kim53391842024-03-29 17:44:07 +0900514 addStr("partition_name", f.partitionName())
Shikha Panware6f30632022-12-21 12:54:45 +0000515 avb_add_hashtree_footer_args := "--do_not_generate_fec"
516 if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" {
517 avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
518 }
Nikita Ioffe2c8cdc62024-03-27 22:19:30 +0000519 if f.properties.Rollback_index != nil {
520 rollbackIndex := proptools.Int(f.properties.Rollback_index)
521 if rollbackIndex < 0 {
522 ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
523 }
524 avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex)
525 }
Inseob Kim53391842024-03-29 17:44:07 +0900526 securityPatchKey := "com.android.build." + f.partitionName() + ".security_patch"
Seungjae Yooa30e4502023-11-09 14:55:44 +0900527 securityPatchValue := ctx.Config().PlatformSecurityPatch()
528 avb_add_hashtree_footer_args += " --prop " + securityPatchKey + ":" + securityPatchValue
Shikha Panware6f30632022-12-21 12:54:45 +0000529 addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args)
Jooyung Han65f402b2022-04-21 14:24:04 +0900530 addStr("avb_salt", f.salt())
Jiyong Park71baa762021-01-18 21:11:03 +0900531 }
532
Inseob Kimcc8e5362021-02-03 14:05:24 +0900533 if proptools.String(f.properties.File_contexts) != "" {
534 addPath("selinux_fc", f.buildFileContexts(ctx))
535 }
Jooyung Han65f402b2022-04-21 14:24:04 +0900536 if timestamp := proptools.String(f.properties.Fake_timestamp); timestamp != "" {
537 addStr("timestamp", timestamp)
538 }
539 if uuid := proptools.String(f.properties.Uuid); uuid != "" {
540 addStr("uuid", uuid)
541 addStr("hash_seed", uuid)
542 }
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000543 // Add erofs properties
544 if f.fsType(ctx) == erofsType {
545 if compressor := f.properties.Erofs.Compressor; compressor != nil {
546 addStr("erofs_default_compressor", proptools.String(compressor))
547 }
548 if compressHints := f.properties.Erofs.Compress_hints; compressHints != nil {
Cole Faust7cd4bad2024-10-11 10:31:12 -0700549 addPath("erofs_default_compress_hints", android.PathForModuleSrc(ctx, *compressHints))
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000550 }
551 if proptools.BoolDefault(f.properties.Erofs.Sparse, true) {
552 // https://source.corp.google.com/h/googleplex-android/platform/build/+/88b1c67239ca545b11580237242774b411f2fed9:core/Makefile;l=2292;bpv=1;bpt=0;drc=ea8f34bc1d6e63656b4ec32f2391e9d54b3ebb6b
553 addStr("erofs_sparse_flag", "-s")
554 }
Cole Faust7cd4bad2024-10-11 10:31:12 -0700555 } else if f.properties.Erofs.Compressor != nil || f.properties.Erofs.Compress_hints != nil || f.properties.Erofs.Sparse != nil {
556 // Raise an exception if the propfile contains erofs properties, but the fstype is not erofs
557 fs := fsTypeStr(f.fsType(ctx))
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000558 ctx.PropertyErrorf("erofs", "erofs is non-empty, but FS type is %s\n. Please delete erofs properties if this partition should use %s\n", fs, fs)
559 }
560
Jiyong Park72678312021-01-18 17:29:49 +0900561 propFile = android.PathForModuleOut(ctx, "prop").OutputPath
Cole Faustcec230a2024-03-07 15:51:12 -0800562 android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String())
Jiyong Park72678312021-01-18 17:29:49 +0900563 return propFile, deps
564}
565
Jiyong Park837cdb22021-02-05 00:17:14 +0900566func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) android.OutputPath {
Jiyong Park11a65972021-02-01 21:09:38 +0900567 if proptools.Bool(f.properties.Use_avb) {
568 ctx.PropertyErrorf("use_avb", "signing compresed cpio image using avbtool is not supported."+
569 "Consider adding this to bootimg module and signing the entire boot image.")
570 }
571
Inseob Kimcc8e5362021-02-03 14:05:24 +0900572 if proptools.String(f.properties.File_contexts) != "" {
573 ctx.PropertyErrorf("file_contexts", "file_contexts is not supported for compressed cpio image.")
574 }
575
Cole Faust4a2a7c92024-03-12 12:44:40 -0700576 if f.properties.Include_make_built_files != "" {
577 ctx.PropertyErrorf("include_make_built_files", "include_make_built_files is not supported for compressed cpio image.")
578 }
579
Jiyong Park11a65972021-02-01 21:09:38 +0900580 rootDir := android.PathForModuleOut(ctx, "root").OutputPath
Cole Faust3b806d32024-03-11 15:15:03 -0700581 rebasedDir := rootDir
582 if f.properties.Base_dir != nil {
583 rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
584 }
585 builder := android.NewRuleBuilder(pctx, ctx)
586 // Wipe the root dir to get rid of leftover files from prior builds
587 builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
Inseob Kim53391842024-03-29 17:44:07 +0900588 specs := f.gatherFilteredPackagingSpecs(ctx)
Inseob Kim33f95a92024-07-11 15:44:49 +0900589 f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
Cole Faust3b806d32024-03-11 15:15:03 -0700590
591 f.buildNonDepsFiles(ctx, builder, rootDir)
Inseob Kim53391842024-03-29 17:44:07 +0900592 f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
Inseob Kimb7b84572024-04-30 10:51:47 +0900593 f.buildEventLogtagsFile(ctx, builder, rebasedDir)
Justin Yun74f3f302024-05-07 14:32:14 +0900594 f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
Justin Yun34baa2e2024-08-30 21:11:33 +0900595 f.copyFilesToProductOut(ctx, builder, rebasedDir)
Jiyong Park11a65972021-02-01 21:09:38 +0900596
597 output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath
Jiyong Park837cdb22021-02-05 00:17:14 +0900598 cmd := builder.Command().
Jiyong Park11a65972021-02-01 21:09:38 +0900599 BuiltTool("mkbootfs").
Jiyong Park837cdb22021-02-05 00:17:14 +0900600 Text(rootDir.String()) // input directory
601 if compressed {
602 cmd.Text("|").
603 BuiltTool("lz4").
604 Flag("--favor-decSpeed"). // for faster boot
605 Flag("-12"). // maximum compression level
606 Flag("-l"). // legacy format for kernel
607 Text(">").Output(output)
608 } else {
609 cmd.Text(">").Output(output)
610 }
Jiyong Park11a65972021-02-01 21:09:38 +0900611
612 // rootDir is not deleted. Might be useful for quick inspection.
Jiyong Park837cdb22021-02-05 00:17:14 +0900613 builder.Build("build_cpio_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
Jiyong Park11a65972021-02-01 21:09:38 +0900614
615 return output
616}
617
Cole Faust4a2a7c92024-03-12 12:44:40 -0700618var validPartitions = []string{
619 "system",
620 "userdata",
621 "cache",
622 "system_other",
623 "vendor",
624 "product",
625 "system_ext",
626 "odm",
627 "vendor_dlkm",
628 "odm_dlkm",
629 "system_dlkm",
630}
631
632func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.Path) {
633 partition := f.properties.Include_make_built_files
634 if partition == "" {
635 return
636 }
637 if !slices.Contains(validPartitions, partition) {
638 ctx.PropertyErrorf("include_make_built_files", "Expected one of %#v, found %q", validPartitions, partition)
639 return
640 }
641 stampFile := fmt.Sprintf("target/product/%s/obj/PACKAGING/%s_intermediates/staging_dir.stamp", ctx.Config().DeviceName(), partition)
642 fileListFile := fmt.Sprintf("target/product/%s/obj/PACKAGING/%s_intermediates/file_list.txt", ctx.Config().DeviceName(), partition)
643 stagingDir := fmt.Sprintf("target/product/%s/%s", ctx.Config().DeviceName(), partition)
644
645 builder.Command().BuiltTool("merge_directories").
646 Implicit(android.PathForArbitraryOutput(ctx, stampFile)).
647 Text("--ignore-duplicates").
648 FlagWithInput("--file-list", android.PathForArbitraryOutput(ctx, fileListFile)).
649 Text(rootDir.String()).
650 Text(android.PathForArbitraryOutput(ctx, stagingDir).String())
651}
652
Inseob Kimb7b84572024-04-30 10:51:47 +0900653func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
654 if !proptools.Bool(f.properties.Build_logtags) {
655 return
656 }
657
658 logtagsFilePaths := make(map[string]bool)
659 ctx.WalkDeps(func(child, parent android.Module) bool {
660 if logtagsInfo, ok := android.OtherModuleProvider(ctx, child, android.LogtagsProviderKey); ok {
661 for _, path := range logtagsInfo.Logtags {
662 logtagsFilePaths[path.String()] = true
663 }
664 }
665 return true
666 })
667
668 if len(logtagsFilePaths) == 0 {
669 return
670 }
671
672 etcPath := rebasedDir.Join(ctx, "etc")
673 eventLogtagsPath := etcPath.Join(ctx, "event-log-tags")
674 builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String())
675 cmd := builder.Command().BuiltTool("merge-event-log-tags").
676 FlagWithArg("-o ", eventLogtagsPath.String()).
677 FlagWithInput("-m ", android.MergedLogtagsPath(ctx))
678
679 for _, path := range android.SortedKeys(logtagsFilePaths) {
680 cmd.Text(path)
681 }
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900682
683 f.appendToEntry(ctx, eventLogtagsPath)
Inseob Kimb7b84572024-04-30 10:51:47 +0900684}
685
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900686type partition interface {
687 PartitionType() string
688}
689
Cole Faust9a24d902024-03-18 15:38:12 -0700690func (f *filesystem) PartitionType() string {
691 return proptools.StringDefault(f.properties.Partition_type, "system")
692}
693
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900694var _ partition = (*filesystem)(nil)
695
Jiyong Park65c49f52020-11-24 14:23:26 +0900696var _ android.AndroidMkEntriesProvider = (*filesystem)(nil)
697
698// Implements android.AndroidMkEntriesProvider
699func (f *filesystem) AndroidMkEntries() []android.AndroidMkEntries {
700 return []android.AndroidMkEntries{android.AndroidMkEntries{
701 Class: "ETC",
702 OutputFile: android.OptionalPathForPath(f.output),
703 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700704 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossc68db4b2021-11-11 18:59:15 -0800705 entries.SetString("LOCAL_MODULE_PATH", f.installDir.String())
Jiyong Park65c49f52020-11-24 14:23:26 +0900706 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", f.installFileName())
Kiyoung Kim99a954d2024-06-21 14:22:20 +0900707 entries.SetString("LOCAL_FILESYSTEM_FILELIST", f.fileListFile.String())
Jiyong Park65c49f52020-11-24 14:23:26 +0900708 },
709 },
710 }}
Jiyong Park6f0f6882020-11-12 13:14:30 +0900711}
Jiyong Park12a719c2021-01-07 15:31:24 +0900712
713// Filesystem is the public interface for the filesystem struct. Currently, it's only for the apex
714// package to have access to the output file.
715type Filesystem interface {
716 android.Module
717 OutputPath() android.Path
Jiyong Park972e06c2021-03-15 23:32:49 +0900718
719 // Returns the output file that is signed by avbtool. If this module is not signed, returns
720 // nil.
721 SignedOutputPath() android.Path
Jiyong Park12a719c2021-01-07 15:31:24 +0900722}
723
724var _ Filesystem = (*filesystem)(nil)
725
726func (f *filesystem) OutputPath() android.Path {
727 return f.output
728}
Jiyong Park972e06c2021-03-15 23:32:49 +0900729
730func (f *filesystem) SignedOutputPath() android.Path {
731 if proptools.Bool(f.properties.Use_avb) {
732 return f.OutputPath()
733 }
734 return nil
735}
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900736
737// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" partition.
738// Note that "apex" module installs its contents to "apex"(fake partition) as well
739// for symbol lookup by imitating "activated" paths.
740func (f *filesystem) gatherFilteredPackagingSpecs(ctx android.ModuleContext) map[string]android.PackagingSpec {
Jeongik Cha54bf8752024-02-08 10:44:37 +0900741 specs := f.PackagingBase.GatherPackagingSpecsWithFilter(ctx, f.filterPackagingSpec)
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900742 return specs
743}
Jooyung Han65f402b2022-04-21 14:24:04 +0900744
745func sha1sum(values []string) string {
746 h := sha256.New()
747 for _, value := range values {
748 io.WriteString(h, value)
749 }
750 return fmt.Sprintf("%x", h.Sum(nil))
751}
Jooyung Hane6067592023-03-16 13:11:17 +0900752
753// Base cc.UseCoverage
754
755var _ cc.UseCoverage = (*filesystem)(nil)
756
Colin Crosse1a85552024-06-14 12:17:37 -0700757func (*filesystem) IsNativeCoverageNeeded(ctx cc.IsNativeCoverageNeededContext) bool {
Jooyung Hane6067592023-03-16 13:11:17 +0900758 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
759}
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900760
761// android_filesystem_defaults
762
763type filesystemDefaults struct {
764 android.ModuleBase
765 android.DefaultsModuleBase
766
767 properties filesystemDefaultsProperties
768}
769
770type filesystemDefaultsProperties struct {
771 // Identifies which partition this is for //visibility:any_system_image (and others) visibility
772 // checks, and will be used in the future for API surface checks.
773 Partition_type *string
774}
775
776// android_filesystem_defaults is a default module for android_filesystem and android_system_image
777func filesystemDefaultsFactory() android.Module {
778 module := &filesystemDefaults{}
779 module.AddProperties(&module.properties)
780 module.AddProperties(&android.PackagingProperties{})
781 android.InitDefaultsModule(module)
782 return module
783}
784
785func (f *filesystemDefaults) PartitionType() string {
786 return proptools.StringDefault(f.properties.Partition_type, "system")
787}
788
789var _ partition = (*filesystemDefaults)(nil)
790
791func (f *filesystemDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
792 validatePartitionType(ctx, f)
793}