1// Copyright (C) 2024 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 fsgen 16 17import ( 18 "android/soong/filesystem" 19 20 "github.com/google/blueprint/proptools" 21) 22 23var ( 24 // Most of the symlinks and directories listed here originate from create_root_structure.mk, 25 // but the handwritten generic system image also recreates them: 26 // https://cs.android.com/android/platform/superproject/main/+/main:build/make/target/product/generic/Android.bp;l=33;drc=db08311f1b6ef6cb0a4fbcc6263b89849360ce04 27 // TODO(b/377734331): only generate the symlinks if the relevant partitions exist 28 commonSymlinksFromRoot = []filesystem.SymlinkDefinition{ 29 { 30 Target: proptools.StringPtr("/system/bin/init"), 31 Name: proptools.StringPtr("init"), 32 }, 33 { 34 Target: proptools.StringPtr("/system/etc"), 35 Name: proptools.StringPtr("etc"), 36 }, 37 { 38 Target: proptools.StringPtr("/system/bin"), 39 Name: proptools.StringPtr("bin"), 40 }, 41 { 42 Target: proptools.StringPtr("/data/user_de/0/com.android.shell/files/bugreports"), 43 Name: proptools.StringPtr("bugreports"), 44 }, 45 { 46 Target: proptools.StringPtr("/sys/kernel/debug"), 47 Name: proptools.StringPtr("d"), 48 }, 49 { 50 Target: proptools.StringPtr("/product/etc/security/adb_keys"), 51 Name: proptools.StringPtr("adb_keys"), 52 }, 53 { 54 Target: proptools.StringPtr("/vendor/odm/app"), 55 Name: proptools.StringPtr("odm/app"), 56 }, 57 { 58 Target: proptools.StringPtr("/vendor/odm/bin"), 59 Name: proptools.StringPtr("odm/bin"), 60 }, 61 { 62 Target: proptools.StringPtr("/vendor/odm/etc"), 63 Name: proptools.StringPtr("odm/etc"), 64 }, 65 { 66 Target: proptools.StringPtr("/vendor/odm/firmware"), 67 Name: proptools.StringPtr("odm/firmware"), 68 }, 69 { 70 Target: proptools.StringPtr("/vendor/odm/framework"), 71 Name: proptools.StringPtr("odm/framework"), 72 }, 73 { 74 Target: proptools.StringPtr("/vendor/odm/lib"), 75 Name: proptools.StringPtr("odm/lib"), 76 }, 77 { 78 Target: proptools.StringPtr("/vendor/odm/lib64"), 79 Name: proptools.StringPtr("odm/lib64"), 80 }, 81 { 82 Target: proptools.StringPtr("/vendor/odm/overlay"), 83 Name: proptools.StringPtr("odm/overlay"), 84 }, 85 { 86 Target: proptools.StringPtr("/vendor/odm/priv-app"), 87 Name: proptools.StringPtr("odm/priv-app"), 88 }, 89 { 90 Target: proptools.StringPtr("/vendor/odm/usr"), 91 Name: proptools.StringPtr("odm/usr"), 92 }, 93 // For Treble Generic System Image (GSI), system-as-root GSI needs to work on 94 // both devices with and without /odm_dlkm partition. Those symlinks are for 95 // devices without /odm_dlkm partition. For devices with /odm_dlkm 96 // partition, mount odm_dlkm.img under /odm_dlkm will hide those symlinks. 97 // Note that /odm_dlkm/lib is omitted because odm DLKMs should be accessed 98 // via /odm/lib/modules directly. All of this also applies to the vendor_dlkm symlink 99 { 100 Target: proptools.StringPtr("/odm/odm_dlkm/etc"), 101 Name: proptools.StringPtr("odm_dlkm/etc"), 102 }, 103 { 104 Target: proptools.StringPtr("/vendor/vendor_dlkm/etc"), 105 Name: proptools.StringPtr("vendor_dlkm/etc"), 106 }, 107 } 108 109 // Common directories between partitions that may be listed as `Dirs` property in the 110 // filesystem module. 111 commonPartitionDirs = []string{ 112 // From generic_rootdirs in build/make/target/product/generic/Android.bp 113 "apex", 114 "bootstrap-apex", 115 "config", 116 "data", 117 "data_mirror", 118 "debug_ramdisk", 119 "dev", 120 "linkerconfig", 121 "metadata", 122 "mnt", 123 "odm", 124 "odm_dlkm", 125 "oem", 126 "postinstall", 127 "proc", 128 "second_stage_resources", 129 "storage", 130 "sys", 131 "system", 132 "system_dlkm", 133 "tmp", 134 "vendor", 135 "vendor_dlkm", 136 137 // from android_rootdirs in build/make/target/product/generic/Android.bp 138 "system_ext", 139 "product", 140 } 141) 142