fs_config.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2007 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. /* This file is used to define the properties of the filesystem
  17. ** images generated by build tools (mkbootfs and mkyaffs2image) and
  18. ** by the device side of adb.
  19. */
  20. #ifndef _LIBS_CUTILS_PRIVATE_FS_CONFIG_H
  21. #define _LIBS_CUTILS_PRIVATE_FS_CONFIG_H
  22. #include <stdint.h>
  23. #include <sys/cdefs.h>
  24. #include <sys/types.h>
  25. #if defined(__BIONIC__)
  26. #include <linux/capability.h>
  27. #else // defined(__BIONIC__)
  28. #include "android_filesystem_capability.h"
  29. #endif // defined(__BIONIC__)
  30. #define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
  31. /*
  32. * binary format for the runtime <partition>/etc/fs_config_(dirs|files)
  33. * filesystem override files.
  34. */
  35. /* The following structure is stored little endian */
  36. struct fs_path_config_from_file {
  37. uint16_t len;
  38. uint16_t mode;
  39. uint16_t uid;
  40. uint16_t gid;
  41. uint64_t capabilities;
  42. char prefix[];
  43. } __attribute__((__aligned__(sizeof(uint64_t))));
  44. struct fs_path_config {
  45. unsigned mode;
  46. unsigned uid;
  47. unsigned gid;
  48. uint64_t capabilities;
  49. const char* prefix;
  50. };
  51. /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
  52. __BEGIN_DECLS
  53. /*
  54. * Used in:
  55. * build/tools/fs_config/fs_config.c
  56. * build/tools/fs_get_stats/fs_get_stats.c
  57. * system/extras/ext4_utils/make_ext4fs_main.c
  58. * external/squashfs-tools/squashfs-tools/android.c
  59. * system/core/cpio/mkbootfs.c
  60. * system/core/adb/file_sync_service.cpp
  61. * system/extras/ext4_utils/canned_fs_config.c
  62. */
  63. void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
  64. unsigned* mode, uint64_t* capabilities);
  65. ssize_t fs_config_generate(char* buffer, size_t length, const struct fs_path_config* pc);
  66. __END_DECLS
  67. #endif /* _LIBS_CUTILS_PRIVATE_FS_CONFIG_H */