• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/config/components/idl_tool/idl.gni")
15import("//build/ohos.gni")
16import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
17
18## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg
19idl_gen_interface("storage_daemon_interface") {
20  sources = [ "${storage_daemon_path}/IStorageDaemon.idl" ]
21  sources_callback = [ "../storage_manager/IUeceActivationCallback.idl" ]
22  log_tag = "StorageDaemon"
23  log_domainid = "0xD004301"
24}
25
26ohos_source_set("storage_daemon_ipc") {
27  sanitize = {
28    debug = false
29    cfi = true
30    cfi_cross_dso = true
31  }
32  output_values = get_target_outputs(":storage_daemon_interface")
33  sources = []
34  sources += filter_include(output_values, [ "*.cpp" ])
35  public_configs = [ ":storage_daemon_config" ]
36  deps = [ ":storage_daemon_interface" ]
37  external_deps = [
38    "c_utils:utils",
39    "hilog:libhilog",
40    "hitrace:hitrace_meter",
41    "ipc:ipc_core",
42  ]
43  part_name = "storage_service"
44  subsystem_name = "filemanagement"
45}
46
47ohos_source_set("storage_daemon_header") {
48  sanitize = {
49    debug = false
50    cfi = true
51    cfi_cross_dso = true
52  }
53  public_configs = [ ":storage_daemon_config" ]
54  deps = [ ":storage_daemon_interface" ]
55  external_deps = [
56    "c_utils:utils",
57    "hilog:libhilog",
58    "hitrace:hitrace_meter",
59    "ipc:ipc_core",
60  ]
61  part_name = "storage_service"
62  subsystem_name = "filemanagement"
63}
64
65ohos_prebuilt_etc("storage_daemon_cfg") {
66  source = "storage_daemon.cfg"
67  relative_install_dir = "init"
68  part_name = "storage_service"
69  subsystem_name = "filemanagement"
70}
71
72## Install storage_daemon.cfg to /system/etc/init/storage_daemon.cfg
73config("storage_daemon_config") {
74  include_dirs = [
75    "include",
76    "include/utils",
77    "${storage_manager_path}/include",
78    "${storage_interface_path}/innerkits/storage_manager/native",
79    "${storage_service_common_path}/include",
80    "${target_gen_dir}",
81    "${storage_daemon_path}/include/ipc",
82  ]
83}
84
85## Install disk_config to /system/etc/storage_daemon/disk_config
86ohos_prebuilt_etc("storage_daemon_disk_config") {
87  source = "disk_config"
88  relative_install_dir = "storage_daemon"
89  part_name = "storage_service"
90  subsystem_name = "filemanagement"
91}
92
93ohos_executable("storage_daemon") {
94  branch_protector_ret = "pac_ret"
95  sanitize = {
96    integer_overflow = true
97    ubsan = true
98    boundary_sanitize = true
99    cfi = true
100    cfi_cross_dso = true
101    debug = false
102  }
103
104  sources = [
105    "ipc/src/storage_daemon.cpp",
106    "ipc/src/storage_daemon_provider.cpp",
107    "ipc/src/storage_manager_client.cpp",
108    "main.cpp",
109    "observer/appstate_observer.cpp",
110    "quota/quota_manager.cpp",
111    "user/src/mount_manager.cpp",
112    "user/src/mount_manager_ext.cpp",
113    "user/src/user_manager.cpp",
114    "utils/disk_utils.cpp",
115    "utils/mount_argument_utils.cpp",
116  ]
117
118  defines = [
119    "STORAGE_LOG_TAG = \"StorageDaemon\"",
120    "LOG_DOMAIN = 0xD004301",
121    "KMSG_LOG",
122  ]
123
124  cflags = [
125    "-fstack-protector-strong",
126    "-O2",
127  ]
128
129  if (storage_service_user_file_sharing) {
130    defines += [ "USER_FILE_SHARING" ]
131    sources += [
132      "file_sharing/src/acl.cpp",
133      "file_sharing/src/file_sharing.cpp",
134      "file_sharing/src/setacl.cpp",
135    ]
136  }
137
138  if (storage_service_external_storage_manager) {
139    defines += [ "EXTERNAL_STORAGE_MANAGER" ]
140    sources += [
141      "disk/src/disk_config.cpp",
142      "disk/src/disk_info.cpp",
143      "disk/src/disk_manager.cpp",
144      "netlink/src/netlink_data.cpp",
145      "netlink/src/netlink_handler.cpp",
146      "netlink/src/netlink_listener.cpp",
147      "netlink/src/netlink_manager.cpp",
148      "volume/src/external_volume_info.cpp",
149      "volume/src/process.cpp",
150      "volume/src/volume_info.cpp",
151      "volume/src/volume_manager.cpp",
152    ]
153  }
154
155  if (storage_service_external_storage_qos_trans) {
156    defines += [ "EXTERNAL_STORAGE_QOS_TRANS" ]
157  }
158
159  configs = [ ":storage_daemon_config" ]
160
161  deps = [
162    ":sdc",
163    ":storage_common_utils",
164    ":storage_daemon_ipc",
165    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
166  ]
167
168  external_deps = [
169    "ability_base:base",
170    "ability_base:want",
171    "ability_base:zuri",
172    "app_file_service:fileshare_native",
173    "app_file_service:fileuri_native",
174    "app_file_service:sandbox_helper_native",
175    "bounds_checking_function:libsec_shared",
176    "bundle_framework:appexecfwk_base",
177    "bundle_framework:appexecfwk_core",
178    "c_utils:utils",
179    "eventhandler:libeventhandler",
180    "hicollie:libhicollie",
181    "hilog:libhilog",
182    "hisysevent:libhisysevent",
183    "hitrace:hitrace_meter",
184    "init:libbegetutil",
185    "ipc:ipc_single",
186    "os_account:os_account_innerkits",
187    "safwk:system_ability_fwk",
188    "samgr:samgr_proxy",
189  ]
190
191  if (storage_service_user_crypto_manager) {
192    defines += [
193      "USER_CRYPTO_MANAGER",
194      "USER_CRYPTO_MIGRATE_KEY",
195    ]
196    deps += [
197      "crypto:libsdcrypto",
198      "libfscrypt:libfscryptutils",
199    ]
200    external_deps += [
201      "huks:libhukssdk",
202    ]
203  }
204
205  if (enable_user_auth_framework) {
206    defines += [ "USER_AUTH_FRAMEWORK" ]
207    external_deps += [ "user_auth_framework:userauth_client" ]
208  }
209
210  if (storage_service_cloud_fuse) {
211    defines += [ "DFS_SERVICE" ]
212    external_deps += [ "dfs_service:cloud_daemon_kit_inner" ]
213  }
214  if (build_selinux) {
215    defines += [ "USE_LIBRESTORECON" ]
216    external_deps += [ "selinux_adapter:librestorecon" ]
217  }
218
219  if (enable_screenlock_manager) {
220    defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
221    external_deps += [ "screenlock_mgr:screenlock_client" ]
222  }
223
224  if (support_open_source_libmtp &&
225      storage_service_external_storage_qos_trans) {
226    defines += [ "SUPPORT_OPEN_SOURCE_MTP_DEVICE" ]
227    sources += [
228      "mtp/src/mtp_device_manager.cpp",
229      "mtp/src/mtp_device_monitor.cpp",
230      "mtp/src/usb_event_subscriber.cpp",
231    ]
232    external_deps += [
233      "ability_base:want",
234      "cJSON:cjson",
235      "common_event_service:cesfwk_innerkits",
236      "init:libbeget_proxy",
237      "libmtp:libmtp",
238      "usb_manager:usbsrv_client",
239    ]
240  }
241
242  if (storage_service_media_fuse) {
243    defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ]
244    external_deps += [ "ability_runtime:app_manager" ]
245  }
246
247  if (enable_huks_hdi) {
248    defines += [ "HUKS_IDL_ENVIRONMENT" ]
249    external_deps += [ "drivers_interface_huks:libhuks_proxy_1.1", ]
250  }
251
252  if (storage_service_el5_filekey_manager) {
253    defines += [ "EL5_FILEKEY_MANAGER" ]
254    external_deps += [ "access_token:el5_filekey_manager_sdk" ]
255  }
256
257  ldflags = [
258    "-Wl,-z,max-page-size=4096",
259    "-Wl,-z,separate-code",
260  ]
261
262  subsystem_name = "filemanagement"
263  part_name = "storage_service"
264  install_enable = true
265}
266
267config("sdc_config") {
268  include_dirs = [
269    "include",
270    "client/include",
271    "${storage_interface_path}/innerkits/storage_manager/native",
272    "${storage_manager_path}/include",
273    "${storage_service_common_path}/include",
274  ]
275}
276
277ohos_executable("sdc") {
278  branch_protector_ret = "pac_ret"
279  sanitize = {
280    integer_overflow = true
281    ubsan = true
282    boundary_sanitize = true
283    cfi = true
284    cfi_cross_dso = true
285    debug = false
286  }
287
288  sources = [
289    "client/storage_daemon_client.cpp",
290    "sdc.cpp",
291  ]
292
293  defines = [
294    "STORAGE_LOG_TAG = \"StorageDaemon\"",
295    "LOG_DOMAIN = 0xD004301",
296    "KMSG_LOG",
297  ]
298
299  cflags = [
300    "-fstack-protector-strong",
301    "-O2",
302  ]
303
304  configs = [ ":sdc_config" ]
305
306  deps = [
307    ":storage_common_utils",
308    ":storage_daemon_interface",
309    ":storage_daemon_ipc",
310    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
311  ]
312
313  if (storage_service_user_crypto_manager) {
314    defines += [ "USER_CRYPTO_MANAGER" ]
315    deps += [ "libfscrypt:libfscryptutils" ]
316  }
317
318  if (storage_service_media_fuse) {
319    defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ]
320  }
321
322  if (build_variant == "root") {
323    defines += [ "SDC_TEST_ENABLE" ]
324  }
325
326  external_deps = [
327    "cJSON:cjson",
328    "c_utils:utils",
329    "hilog:libhilog",
330    "ipc:ipc_single",
331    "safwk:system_ability_fwk",
332    "samgr:samgr_proxy",
333  ]
334
335  subsystem_name = "filemanagement"
336  part_name = "storage_service"
337  install_enable = true
338}
339
340ohos_shared_library("storage_common_utils") {
341  branch_protector_ret = "pac_ret"
342  sanitize = {
343    integer_overflow = true
344    ubsan = true
345    boundary_sanitize = true
346    cfi = true
347    cfi_cross_dso = true
348    debug = false
349  }
350
351  include_dirs = [
352    "include",
353    "include/utils",
354    "${storage_service_common_path}/include",
355    "${storage_interface_path}/innerkits/storage_manager/native",
356  ]
357
358  defines = [
359    "STORAGE_LOG_TAG = \"StorageCommonUtils\"",
360    "LOG_DOMAIN = 0xD004301",
361  ]
362
363  cflags = [
364    "-D_FORTIFY_SOURCE=2",
365    "-fstack-protector-strong",
366    "-O2",
367  ]
368
369  sources = [
370    "utils/disk_utils.cpp",
371    "utils/file_utils.cpp",
372    "utils/hi_audit.cpp",
373    "utils/mount_argument_utils.cpp",
374    "utils/storage_radar.cpp",
375    "utils/storage_statistics_radar.cpp",
376    "utils/storage_xcollie.cpp",
377    "utils/string_utils.cpp",
378    "utils/zip_util.cpp",
379  ]
380
381  external_deps = [
382    "cJSON:cjson",
383    "c_utils:utils",
384    "hicollie:libhicollie",
385    "hilog:libhilog",
386    "hisysevent:libhisysevent",
387    "init:libbegetutil",
388    "zlib:shared_libz",
389  ]
390
391  if (build_selinux) {
392    defines += [ "USE_LIBRESTORECON" ]
393
394    external_deps += [ "selinux_adapter:librestorecon" ]
395  }
396
397  if (storage_service_external_storage_qos_trans) {
398    defines += [ "EXTERNAL_STORAGE_QOS_TRANS" ]
399    external_deps += [ "qos_manager:concurrent_task_client" ]
400  }
401
402  if (storage_service_media_fuse) {
403    defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ]
404  }
405
406  subsystem_name = "filemanagement"
407  part_name = "storage_service"
408  install_enable = true
409}
410
411ohos_prebuilt_etc("usb_config.para") {
412  source = "usb_config.para"
413  part_name = "storage_service"
414  subsystem_name = "filemanagement"
415  module_install_dir = "etc/param"
416}
417
418ohos_prebuilt_etc("usb_config.para.dac") {
419  source = "usb_config.para.dac"
420  part_name = "storage_service"
421  subsystem_name = "filemanagement"
422  module_install_dir = "etc/param"
423}
424
425group("storage_daemon_usb_param") {
426  deps = [
427    ":usb_config.para",
428    ":usb_config.para.dac",
429  ]
430}
431
432group("storage_daemon_third_party") {
433  deps = []
434  if (storage_service_external_storage_manager && storage_service_fstools) {
435    external_deps = [
436      "e2fsprogs:blkid",
437      "e2fsprogs:libext2_blkid",
438      "e2fsprogs:libext2_com_err",
439      "e2fsprogs:libext2fs",
440      "exfatprogs:exfatlabel",
441      "exfatprogs:fsck.exfat",
442      "exfatprogs:mkfs.exfat",
443      "gptfdisk:sgdisk",
444      "ntfs-3g:fsck.ntfs",
445      "ntfs-3g:mount.ntfs",
446      "ntfs-3g:ntfslabel",
447    ]
448  }
449  external_deps += [
450    "f2fs-tools:fsck.f2fs",
451    "f2fs-tools:libf2fs",
452    "f2fs-tools:mkfs.f2fs",
453  ]
454}
455
456group("storage_daemon_unit_test") {
457  testonly = true
458  deps = [
459    "client/test:storage_daemon_client_test",
460    "crypto/test/base_key_test:base_key_test",
461    "crypto/test/crypto_test:crypto_test",
462    "crypto/test/fbex_test:fbex_test",
463    "crypto/test/fscrypt_key_v1_ext_test:fscrypt_key_v1_ext_test",
464    "crypto/test/iam_client_test:iam_client_test",
465    "crypto/test/iam_client_user_auth_framework_test:iam_client_user_auth_framework_test",
466    "crypto/test/crypto_delay_handler_test:crypto_delay_handler_test",
467    "crypto/test/key_backup_test:key_backup_test",
468    "crypto/test/key_crypto_utils_test:key_crypto_utils_test",
469    "crypto/test/key_manager_test:key_manager_test",
470    "crypto/test/recover_manager_test:recover_manager_test",
471    "file_sharing/test:file_sharing_test",
472    "ipc/test:storage_daemon_ipc_test",
473    "libfscrypt/test:lib_fscrypt_test",
474    "quota/test:storage_daemon_quota_test",
475    "user/test:storage_daemon_user_test",
476    "utils/test:storage_daemon_utils_test",
477  ]
478
479  if (storage_service_user_crypto_manager) {
480    deps += [
481      "crypto/test:crypto_test",
482      "crypto/test/fscrypt_v1_test:fscrypt_key_v1_test",
483      "crypto/test/fscrypt_v2_test:fscrypt_key_v2_test",
484    ]
485  }
486
487  if (storage_service_external_storage_manager) {
488    deps += [
489      "disk/test:storage_daemon_disk_test",
490      "netlink/test:storage_daemon_netlink_test",
491      "volume/test:storage_daemon_volume_test",
492    ]
493  }
494  if (support_open_source_libmtp &&
495      storage_service_external_storage_qos_trans) {
496    deps += [
497      "mtp/test:storage_daemon_mtp_test",
498      "mtpfs/test:storage_daemon_mtpfs_test",
499    ]
500  }
501  if (enable_huks_hdi) {
502    deps += [ "crypto/test/huks_master_test:huks_master_test", ]
503  }
504}
505