1# Copyright (c) 2024-2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni") 16 17## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg 18ohos_prebuilt_etc("storage_daemon_cfg") { 19 source = "storage_daemon.cfg" 20 relative_install_dir = "init" 21 part_name = "storage_service" 22 subsystem_name = "filemanagement" 23} 24 25## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg 26config("storage_daemon_config") { 27 include_dirs = [ 28 "include", 29 "include/utils", 30 "../storage_manager/include", 31 "${storage_interface_path}/innerkits/storage_manager/native", 32 "../common/include", 33 ] 34} 35 36## Install disk_config to /system/etc/storage_daemon/disk_config 37ohos_prebuilt_etc("storage_daemon_disk_config") { 38 source = "disk_config" 39 relative_install_dir = "storage_daemon" 40 part_name = "storage_service" 41 subsystem_name = "filemanagement" 42} 43 44ohos_executable("storage_daemon") { 45 branch_protector_ret = "pac_ret" 46 sanitize = { 47 integer_overflow = true 48 ubsan = true 49 boundary_sanitize = true 50 cfi = true 51 cfi_cross_dso = true 52 debug = false 53 } 54 55 sources = [ 56 "ipc/src/storage_daemon.cpp", 57 "ipc/src/storage_daemon_stub.cpp", 58 "ipc/src/storage_manager_client.cpp", 59 "main.cpp", 60 "observer/appstate_observer.cpp", 61 "quota/quota_manager.cpp", 62 "user/src/mount_manager.cpp", 63 "user/src/user_manager.cpp", 64 "utils/disk_utils.cpp", 65 "utils/mount_argument_utils.cpp", 66 ] 67 68 defines = [ 69 "STORAGE_LOG_TAG = \"StorageDaemon\"", 70 "LOG_DOMAIN = 0xD004301", 71 "KMSG_LOG", 72 ] 73 74 cflags = [ 75 "-fstack-protector-strong", 76 "-O2", 77 ] 78 79 if (storage_service_user_file_sharing) { 80 defines += [ "USER_FILE_SHARING" ] 81 sources += [ 82 "file_sharing/src/acl.cpp", 83 "file_sharing/src/file_sharing.cpp", 84 "file_sharing/src/setacl.cpp", 85 ] 86 } 87 88 if (storage_service_external_storage_manager) { 89 defines += [ "EXTERNAL_STORAGE_MANAGER" ] 90 sources += [ 91 "disk/src/disk_config.cpp", 92 "disk/src/disk_info.cpp", 93 "disk/src/disk_manager.cpp", 94 "netlink/src/netlink_data.cpp", 95 "netlink/src/netlink_handler.cpp", 96 "netlink/src/netlink_listener.cpp", 97 "netlink/src/netlink_manager.cpp", 98 "volume/src/external_volume_info.cpp", 99 "volume/src/process.cpp", 100 "volume/src/volume_info.cpp", 101 "volume/src/volume_manager.cpp", 102 ] 103 } 104 105 if (storage_service_external_storage_qos_trans) { 106 defines += [ "EXTERNAL_STORAGE_QOS_TRANS" ] 107 } 108 109 configs = [ ":storage_daemon_config" ] 110 111 deps = [ 112 ":sdc", 113 ":storage_common_utils", 114 "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", 115 ] 116 117 external_deps = [ 118 "ability_base:base", 119 "ability_base:want", 120 "ability_base:zuri", 121 "app_file_service:fileshare_native", 122 "app_file_service:fileuri_native", 123 "app_file_service:sandbox_helper_native", 124 "bounds_checking_function:libsec_shared", 125 "bundle_framework:appexecfwk_base", 126 "bundle_framework:appexecfwk_core", 127 "c_utils:utils", 128 "eventhandler:libeventhandler", 129 "hicollie:libhicollie", 130 "hilog:libhilog", 131 "hisysevent:libhisysevent", 132 "init:libbegetutil", 133 "ipc:ipc_single", 134 "os_account:os_account_innerkits", 135 "safwk:system_ability_fwk", 136 "samgr:samgr_proxy", 137 ] 138 139 if (storage_service_user_crypto_manager) { 140 defines += [ 141 "USER_CRYPTO_MANAGER", 142 "USER_CRYPTO_MIGRATE_KEY", 143 ] 144 deps += [ 145 "crypto:libsdcrypto", 146 "libfscrypt:libfscryptutils", 147 ] 148 external_deps += [ "huks:libhukssdk" ] 149 } 150 151 if (enable_user_auth_framework) { 152 defines += [ "USER_AUTH_FRAMEWORK" ] 153 external_deps += [ "user_auth_framework:userauth_client" ] 154 } 155 156 if (storage_service_cloud_fuse) { 157 defines += [ "DFS_SERVICE" ] 158 external_deps += [ "dfs_service:cloud_daemon_kit_inner" ] 159 } 160 if (build_selinux) { 161 defines += [ "USE_LIBRESTORECON" ] 162 external_deps += [ "selinux_adapter:librestorecon" ] 163 } 164 165 if (enable_screenlock_manager) { 166 defines += [ "ENABLE_SCREENLOCK_MANAGER" ] 167 external_deps += [ "screenlock_mgr:screenlock_client" ] 168 } 169 170 if (support_open_source_libmtp && 171 storage_service_external_storage_qos_trans) { 172 defines += [ "SUPPORT_OPEN_SOURCE_MTP_DEVICE" ] 173 sources += [ 174 "mtp/src/mtp_device_manager.cpp", 175 "mtp/src/mtp_device_monitor.cpp", 176 "mtp/src/usb_event_subscriber.cpp", 177 ] 178 external_deps += [ 179 "ability_base:want", 180 "cJSON:cjson", 181 "common_event_service:cesfwk_innerkits", 182 "config_policy:configpolicy_util", 183 "init:libbeget_proxy", 184 "libmtp:libmtp", 185 ] 186 } 187 188 if (storage_service_media_fuse) { 189 defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ] 190 external_deps += [ "ability_runtime:app_manager" ] 191 } 192 193 ldflags = [ 194 "-Wl,-z,max-page-size=4096", 195 "-Wl,-z,separate-code", 196 ] 197 198 subsystem_name = "filemanagement" 199 part_name = "storage_service" 200 install_enable = true 201} 202 203config("sdc_config") { 204 include_dirs = [ 205 "include", 206 "../common/include", 207 "client/include", 208 "../../interfaces/innerkits/storage_manager/native", 209 "../storage_manager/include", 210 ] 211} 212 213ohos_executable("sdc") { 214 branch_protector_ret = "pac_ret" 215 sanitize = { 216 integer_overflow = true 217 ubsan = true 218 boundary_sanitize = true 219 cfi = true 220 cfi_cross_dso = true 221 debug = false 222 } 223 224 sources = [ 225 "client/storage_daemon_client.cpp", 226 "ipc/src/storage_daemon_proxy.cpp", 227 "sdc.cpp", 228 ] 229 230 defines = [ 231 "STORAGE_LOG_TAG = \"StorageDaemon\"", 232 "LOG_DOMAIN = 0xD004301", 233 "KMSG_LOG", 234 ] 235 236 cflags = [ 237 "-fstack-protector-strong", 238 "-O2", 239 ] 240 241 configs = [ ":sdc_config" ] 242 243 deps = [ 244 ":storage_common_utils", 245 "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy", 246 ] 247 248 if (storage_service_user_crypto_manager) { 249 defines += [ "USER_CRYPTO_MANAGER" ] 250 deps += [ "libfscrypt:libfscryptutils" ] 251 } 252 253 if (storage_service_media_fuse) { 254 defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ] 255 } 256 257 if (build_variant == "root") { 258 defines += [ "SDC_TEST_ENABLE" ] 259 } 260 261 external_deps = [ 262 "c_utils:utils", 263 "hilog:libhilog", 264 "ipc:ipc_single", 265 "safwk:system_ability_fwk", 266 "samgr:samgr_proxy", 267 ] 268 269 subsystem_name = "filemanagement" 270 part_name = "storage_service" 271 install_enable = true 272} 273 274ohos_shared_library("storage_common_utils") { 275 branch_protector_ret = "pac_ret" 276 sanitize = { 277 integer_overflow = true 278 ubsan = true 279 boundary_sanitize = true 280 cfi = true 281 cfi_cross_dso = true 282 debug = false 283 } 284 285 include_dirs = [ 286 "./include", 287 "./include/utils", 288 "../common/include", 289 "${storage_interface_path}/innerkits/storage_manager/native", 290 ] 291 292 defines = [ 293 "STORAGE_LOG_TAG = \"StorageCommonUtils\"", 294 "LOG_DOMAIN = 0xD004301", 295 ] 296 297 cflags = [ 298 "-D_FORTIFY_SOURCE=2", 299 "-fstack-protector-strong", 300 "-O2", 301 ] 302 303 sources = [ 304 "./utils/disk_utils.cpp", 305 "./utils/file_utils.cpp", 306 "./utils/hi_audit.cpp", 307 "./utils/mount_argument_utils.cpp", 308 "./utils/storage_radar.cpp", 309 "./utils/storage_statistics_radar.cpp", 310 "./utils/storage_xcollie.cpp", 311 "./utils/string_utils.cpp", 312 "./utils/zip_util.cpp", 313 ] 314 315 external_deps = [ 316 "cJSON:cjson", 317 "c_utils:utils", 318 "hicollie:libhicollie", 319 "hilog:libhilog", 320 "hisysevent:libhisysevent", 321 "zlib:shared_libz", 322 ] 323 324 if (build_selinux) { 325 defines += [ "USE_LIBRESTORECON" ] 326 327 external_deps += [ "selinux_adapter:librestorecon" ] 328 } 329 330 if (storage_service_external_storage_qos_trans) { 331 defines += [ "EXTERNAL_STORAGE_QOS_TRANS" ] 332 external_deps += [ "qos_manager:concurrent_task_client" ] 333 } 334 335 if (storage_service_media_fuse) { 336 defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ] 337 } 338 339 subsystem_name = "filemanagement" 340 part_name = "storage_service" 341 install_enable = true 342} 343 344ohos_prebuilt_etc("usb_config.para") { 345 source = "usb_config.para" 346 part_name = "storage_service" 347 subsystem_name = "filemanagement" 348 module_install_dir = "etc/param" 349} 350 351ohos_prebuilt_etc("usb_config.para.dac") { 352 source = "usb_config.para.dac" 353 part_name = "storage_service" 354 subsystem_name = "filemanagement" 355 module_install_dir = "etc/param" 356} 357 358group("storage_daemon_usb_param") { 359 deps = [ 360 ":usb_config.para", 361 ":usb_config.para.dac", 362 ] 363} 364 365group("storage_daemon_third_party") { 366 deps = [] 367 if (storage_service_external_storage_manager && storage_service_fstools) { 368 external_deps = [ 369 "FreeBSD:fsck_msdos", 370 "FreeBSD:newfs_msdos", 371 "e2fsprogs:blkid", 372 "e2fsprogs:libext2_blkid", 373 "e2fsprogs:libext2_com_err", 374 "e2fsprogs:libext2fs", 375 "exfatprogs:exfatlabel", 376 "exfatprogs:fsck.exfat", 377 "exfatprogs:mkfs.exfat", 378 "gptfdisk:sgdisk", 379 "ntfs-3g:fsck.ntfs", 380 "ntfs-3g:mount.ntfs", 381 "ntfs-3g:ntfslabel", 382 ] 383 } 384 external_deps += [ 385 "f2fs-tools:fsck.f2fs", 386 "f2fs-tools:libf2fs", 387 "f2fs-tools:mkfs.f2fs", 388 ] 389} 390 391group("storage_daemon_unit_test") { 392 testonly = true 393 deps = [ 394 "client/test:storage_daemon_client_test", 395 "crypto/test/base_key_test:base_key_test", 396 "crypto/test/crypto_test:crypto_test", 397 "crypto/test/fscrypt_key_v1_ext_test:fscrypt_key_v1_ext_test", 398 "crypto/test/huks_master_test:huks_master_test", 399 "crypto/test/iam_client_test:iam_client_test", 400 "crypto/test/iam_client_user_auth_framework_test:iam_client_user_auth_framework_test", 401 "crypto/test/key_backup_test:key_backup_test", 402 "crypto/test/key_manager_test:key_manager_test", 403 "crypto/test/recover_manager_test:recover_manager_test", 404 "file_sharing/test:file_sharing_test", 405 "ipc/test:storage_daemon_ipc_test", 406 "quota/test:storage_daemon_quota_test", 407 "user/test:storage_daemon_user_test", 408 "utils/test:storage_daemon_utils_test", 409 ] 410 411 if (storage_service_user_crypto_manager) { 412 deps += [ 413 "crypto/test:crypto_test", 414 "crypto/test/fscrypt_v1_test:fscrypt_key_v1_test", 415 "crypto/test/fscrypt_v2_test:fscrypt_key_v2_test", 416 ] 417 } 418 419 if (storage_service_external_storage_manager) { 420 deps += [ 421 "disk/test:storage_daemon_disk_test", 422 "netlink/test:storage_daemon_netlink_test", 423 "volume/test:storage_daemon_volume_test", 424 ] 425 } 426 if (support_open_source_libmtp && 427 storage_service_external_storage_qos_trans) { 428 deps += [ 429 "mtp/test:storage_daemon_mtp_test", 430 "mtpfs/test:storage_daemon_mtpfs_test", 431 ] 432 } 433} 434