PageRenderTime 27ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/cmds/installd/installd.h

http://github.com/CyanogenMod/android_frameworks_base
C Header | 160 lines | 99 code | 40 blank | 21 comment | 0 complexity | 77fef5a6ad4ad69386eb4e357b42bdf9 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, CC0-1.0, BitTorrent-1.0, BSD-3-Clause
  1. /*
  2. **
  3. ** Copyright 2008, The Android Open Source Project
  4. **
  5. ** Licensed under the Apache License, Version 2.0 (the "License");
  6. ** you may not use this file except in compliance with the License.
  7. ** You may obtain a copy of the License at
  8. **
  9. ** http://www.apache.org/licenses/LICENSE-2.0
  10. **
  11. ** Unless required by applicable law or agreed to in writing, software
  12. ** distributed under the License is distributed on an "AS IS" BASIS,
  13. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ** See the License for the specific language governing permissions and
  15. ** limitations under the License.
  16. */
  17. #define LOG_TAG "installd"
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <inttypes.h>
  22. #include <sys/stat.h>
  23. #include <dirent.h>
  24. #include <unistd.h>
  25. #include <ctype.h>
  26. #include <fcntl.h>
  27. #include <errno.h>
  28. #include <utime.h>
  29. #include <sys/socket.h>
  30. #include <sys/types.h>
  31. #include <sys/wait.h>
  32. #include <cutils/sockets.h>
  33. #include <cutils/log.h>
  34. #include <cutils/properties.h>
  35. #include <private/android_filesystem_config.h>
  36. #if INCLUDE_SYS_MOUNT_FOR_STATFS
  37. #include <sys/mount.h>
  38. #else
  39. #include <sys/statfs.h>
  40. #endif
  41. #define SOCKET_PATH "installd"
  42. /* elements combined with a valid package name to form paths */
  43. #define PRIMARY_USER_PREFIX "data/"
  44. #define SECONDARY_USER_PREFIX "user/"
  45. #define PKG_DIR_POSTFIX ""
  46. #define PKG_LIB_POSTFIX "/lib"
  47. #define CACHE_DIR_POSTFIX "/cache"
  48. #define DATA_SUBDIR "data/" // sub-directory under ANDROID_DATA
  49. #define APP_SUBDIR "app/" // sub-directory under ANDROID_DATA
  50. /* other handy constants */
  51. #define PRIVATE_APP_SUBDIR "app-private/" // sub-directory under ANDROID_DATA
  52. #define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
  53. #define DALVIK_SYSTEM_CACHE_PREFIX "/cache/dalvik-cache/"
  54. #define DALVIK_CACHE_POSTFIX "/classes.dex"
  55. #define UPDATE_COMMANDS_DIR_PREFIX "/system/etc/updatecmds/"
  56. #define PKG_NAME_MAX 128 /* largest allowed package name */
  57. #define PKG_PATH_MAX 256 /* max size of any path we use */
  58. /* data structures */
  59. typedef struct {
  60. char* path;
  61. size_t len;
  62. } dir_rec_t;
  63. typedef struct {
  64. size_t count;
  65. dir_rec_t* dirs;
  66. } dir_rec_array_t;
  67. extern dir_rec_t android_app_dir;
  68. extern dir_rec_t android_app_private_dir;
  69. extern dir_rec_t android_data_dir;
  70. extern dir_rec_t android_datadata_dir;
  71. extern dir_rec_t android_asec_dir;
  72. extern dir_rec_array_t android_system_dirs;
  73. /* util.c */
  74. int create_pkg_path_in_dir(char path[PKG_PATH_MAX],
  75. const dir_rec_t* dir,
  76. const char* pkgname,
  77. const char* postfix);
  78. int create_pkg_path(char path[PKG_PATH_MAX],
  79. const char *pkgname,
  80. const char *postfix,
  81. uid_t persona);
  82. int create_persona_path(char path[PKG_PATH_MAX],
  83. uid_t persona);
  84. int create_move_path(char path[PKG_PATH_MAX],
  85. const char* pkgname,
  86. const char* leaf,
  87. uid_t persona);
  88. int is_valid_package_name(const char* pkgname);
  89. int create_cache_path(char path[PKG_PATH_MAX], const char *src);
  90. int delete_dir_contents(const char *pathname,
  91. int also_delete_dir,
  92. const char *ignore);
  93. int delete_dir_contents_fd(int dfd, const char *name);
  94. int validate_system_app_path(const char* path);
  95. int get_path_from_env(dir_rec_t* rec, const char* var);
  96. int get_path_from_string(dir_rec_t* rec, const char* path);
  97. int copy_and_append(dir_rec_t* dst, const dir_rec_t* src, const char* suffix);
  98. int validate_apk_path(const char *path);
  99. int append_and_increment(char** dst, const char* src, size_t* dst_size);
  100. char *build_string2(char *s1, char *s2);
  101. char *build_string3(char *s1, char *s2, char *s3);
  102. /* commands.c */
  103. int install(const char *pkgname, uid_t uid, gid_t gid);
  104. int uninstall(const char *pkgname, uid_t persona);
  105. int renamepkg(const char *oldpkgname, const char *newpkgname);
  106. int delete_user_data(const char *pkgname, uid_t persona);
  107. int make_user_data(const char *pkgname, uid_t uid, uid_t persona);
  108. int delete_persona(uid_t persona);
  109. int delete_cache(const char *pkgname);
  110. int move_dex(const char *src, const char *dst);
  111. int rm_dex(const char *path);
  112. int protect(char *pkgname, gid_t gid);
  113. int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath,
  114. const char *asecpath, int64_t *codesize, int64_t *datasize, int64_t *cachesize,
  115. int64_t *asecsize);
  116. int free_cache(int64_t free_size);
  117. int dexopt(const char *apk_path, uid_t uid, int is_public);
  118. int movefiles();
  119. int linklib(const char* target, const char* source);
  120. int unlinklib(const char* libPath);