1//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package {
18    default_applicable_licenses: [
19        "Android-Apache-2.0",
20        "system_core_fs_mgr_license",
21    ],
22}
23
24// Added automatically by a large-scale-change that took the approach of
25// 'apply every license found to every target'. While this makes sure we respect
26// every license restriction, it may not be entirely correct.
27//
28// e.g. GPL in an MIT project might only apply to the contrib/ directory.
29//
30// Please consider splitting the single license below into multiple licenses,
31// taking care not to lose any license_kind information, and overriding the
32// default license using the 'licenses: [...]' property on targets as needed.
33//
34// For unused files, consider creating a 'fileGroup' with "//visibility:private"
35// to attach the license to, and including a comment whether the files may be
36// used in the current project.
37// See: http://go/android-license-faq
38license {
39    name: "system_core_fs_mgr_license",
40    visibility: [":__subpackages__"],
41    license_kinds: [
42        "SPDX-license-identifier-MIT",
43    ],
44    license_text: ["NOTICE"],
45}
46
47cc_defaults {
48    name: "fs_mgr_defaults",
49    sanitize: {
50        misc_undefined: ["integer"],
51    },
52    local_include_dirs: ["include/"],
53    cflags: [
54        "-Wall",
55        "-Werror",
56    ],
57}
58
59cc_defaults {
60    name: "libfs_mgr_defaults",
61    defaults: ["fs_mgr_defaults"],
62    export_include_dirs: ["include"],
63    include_dirs: ["system/vold"],
64    cflags: [
65        "-D_FILE_OFFSET_BITS=64",
66    ],
67    srcs: [
68        "blockdev.cpp",
69        "file_wait.cpp",
70        "fs_mgr.cpp",
71        "fs_mgr_format.cpp",
72        "fs_mgr_dm_linear.cpp",
73        "fs_mgr_overlayfs.cpp",
74        "fs_mgr_roots.cpp",
75        "fs_mgr_vendor_overlay.cpp",
76        ":libfiemap_srcs",
77    ],
78    shared_libs: [
79        "libbase",
80        "libcrypto",
81        "libcrypto_utils",
82        "libcutils",
83        "libext4_utils",
84        "libfec",
85        "liblog",
86        "liblp",
87        "libselinux",
88    ],
89    static_libs: [
90        "libavb",
91        "libfs_avb",
92        "libfstab",
93        "libdm",
94        "libgsi",
95    ],
96    export_static_lib_headers: [
97        "libfs_avb",
98        "libfstab",
99        "libdm",
100    ],
101    export_shared_lib_headers: [
102        "liblp",
103    ],
104    whole_static_libs: [
105        "liblogwrap",
106        "libdm",
107        "libext2_uuid",
108        "libfscrypt",
109        "libfstab",
110    ],
111    cppflags: [
112        "-DALLOW_ADBD_DISABLE_VERITY=0",
113    ],
114    product_variables: {
115        debuggable: {
116            cppflags: [
117                "-UALLOW_ADBD_DISABLE_VERITY",
118                "-DALLOW_ADBD_DISABLE_VERITY=1",
119            ],
120        },
121    },
122    header_libs: [
123        "libfiemap_headers",
124        "libstorage_literals_headers",
125    ],
126    export_header_lib_headers: [
127        "libfiemap_headers",
128    ],
129    target: {
130        platform: {
131            required: [
132                "e2freefrag",
133                "e2fsdroid",
134            ],
135        },
136        recovery: {
137            required: [
138                "e2fsdroid.recovery",
139            ],
140        },
141    },
142}
143
144// Two variants of libfs_mgr are provided: libfs_mgr and libfs_mgr_binder.
145// Use libfs_mgr in recovery, first-stage-init, or when libfiemap or overlayfs
146// is not used.
147//
148// Use libfs_mgr_binder when not in recovery/first-stage init, or when overlayfs
149// or libfiemap is needed. In this case, libfiemap will proxy over binder to
150// gsid.
151cc_library {
152    // Do not ever allow this library to be vendor_available as a shared library.
153    // It does not have a stable interface.
154    name: "libfs_mgr",
155    ramdisk_available: true,
156    vendor_ramdisk_available: true,
157    recovery_available: true,
158    defaults: [
159        "libfs_mgr_defaults",
160    ],
161    srcs: [
162        ":libfiemap_passthrough_srcs",
163    ],
164}
165
166cc_library {
167    // Do not ever allow this library to be vendor_available as a shared library.
168    // It does not have a stable interface.
169    name: "libfs_mgr_binder",
170    defaults: [
171        "libfs_mgr_defaults",
172        "libfiemap_binder_defaults",
173    ],
174}
175
176cc_library_static {
177    // Do not ever make this a shared library as long as it is vendor_available.
178    // It does not have a stable interface.
179    name: "libfstab",
180    vendor_available: true,
181    ramdisk_available: true,
182    vendor_ramdisk_available: true,
183    recovery_available: true,
184    host_supported: true,
185    defaults: ["fs_mgr_defaults"],
186    srcs: [
187        "fs_mgr_fstab.cpp",
188        "fs_mgr_boot_config.cpp",
189        "fs_mgr_slotselect.cpp",
190    ],
191    target: {
192        darwin: {
193            enabled: false,
194        },
195        vendor: {
196            cflags: [
197                // Skipping entries in fstab should only be done in a system
198                // process as the config file is in /system_ext.
199                // Remove the op from the vendor variant.
200                "-DNO_SKIP_MOUNT",
201            ],
202        },
203    },
204    export_include_dirs: ["include_fstab"],
205    header_libs: [
206        "libbase_headers",
207        "libgsi_headers",
208    ],
209}
210
211cc_binary {
212    name: "remount",
213    defaults: ["fs_mgr_defaults"],
214    static_libs: [
215        "libavb_user",
216        "libgsid",
217        "libvold_binder",
218    ],
219    shared_libs: [
220        "libbootloader_message",
221        "libbase",
222        "libbinder",
223        "libcutils",
224        "libcrypto",
225        "libext4_utils",
226        "libfs_mgr_binder",
227        "liblog",
228        "liblp",
229        "libselinux",
230        "libutils",
231    ],
232    header_libs: [
233        "libcutils_headers",
234    ],
235    srcs: [
236        "fs_mgr_remount.cpp",
237    ],
238    cppflags: [
239        "-DALLOW_ADBD_DISABLE_VERITY=0",
240    ],
241    product_variables: {
242        debuggable: {
243            cppflags: [
244                "-UALLOW_ADBD_DISABLE_VERITY",
245                "-DALLOW_ADBD_DISABLE_VERITY=1",
246            ],
247            init_rc: [
248                "clean_scratch_files.rc",
249            ],
250        },
251    },
252    symlinks: [
253        "clean_scratch_files",
254        "disable-verity",
255        "enable-verity",
256        "set-verity-state",
257    ],
258}
259