Home | History | Annotate | Download | only in installd

Lines Matching full:path

40  * Create the path name where package app contents should be stored for
54 * Create the path name where package data should be stored for the given
67 int create_pkg_path(char path[PKG_PATH_MAX], const char *pkgname,
70 path[0] = '\0';
77 path[0] = '\0';
80 strcpy(path, tmp);
95 * Create the path name for app data.
102 * Create the path name for user data for a certain userid.
118 * Create the path name for media for a certain userid.
130 std::string path(create_data_path(volume_uuid) + "/" + SECONDARY_USER_PREFIX);
131 DIR* dir = opendir(path.c_str());
134 PLOG(ERROR) << "Failed to opendir " << path;
157 * Create the path name for config for a certain userid.
160 int create_user_config_path(char path[PATH_MAX], userid_t userid) {
161 if (snprintf(path, PATH_MAX, "%s%d", "/data/misc/user/", userid) > PATH_MAX) {
167 int create_move_path(char path[PKG_PATH_MAX],
177 sprintf(path, "%s%s%s/%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgname, leaf);
446 // Verify the path won't extend beyond our buffer, to avoid
449 ALOGW("Path exceeds limit: %s%s", basepath, dir);
674 // Update pathBase for the new path... this may change dirName
675 // if that is also pointing to the path, but we are done with it
683 // Whoops, the final path is too long! We'll just delete
685 ALOGW("Cache dir %s truncated in path %s; deleting dir\n",
707 // Build final full path for file... this may change dirName
708 // if that is also pointing to the path, but we are done with it
723 // Whoops, the final path is too long! We'll just delete
725 ALOGW("Cache file %s truncated in path %s; deleting\n",
792 static char *create_dir_path(char path[PATH_MAX], cache_dir_t* dir)
794 char *pos = path;
796 pos = create_dir_path(path, dir->parent);
809 static void delete_cache_dir(char path[PATH_MAX], cache_dir_t* dir)
812 create_dir_path(path, dir);
813 ALOGI("DEL DIR %s\n", path);
815 if (rmdir(path)) {
816 ALOGE("Couldn't rmdir %s: %s\n", path, strerror(errno));
822 if (delete_dir_contents(path, 1, NULL)) {
829 delete_cache_dir(path, dir->parent);
834 create_dir_path(path, dir);
835 ALOGI("DEL CONTENTS %s\n", path);
836 delete_dir_contents(path, 0, NULL);
851 char path[PATH_MAX];
864 delete_cache_dir(path, dir);
878 strcpy(create_dir_path(path, file->dir), file->name);
879 ALOGI("DEL (mod %d) %s\n", (int)file->modTime, path);
880 if (unlink(path) < 0) {
881 ALOGE("Couldn't unlink %s: %s\n", path, strerror(errno));
885 delete_cache_dir(path, file->dir);
917 * Validate that the path is valid in the context of the provided directory.
918 * The path is allowed to have at most one subdirectory and no indirections
921 static int validate_path(const dir_rec_t* dir, const char* path, int maxSubdirs) {
923 const char* subdir = strchr(path + dir_len, '/');
925 // Only allow the path to have at most one subdirectory.
929 ALOGE("invalid apk path '%s' (subdir?)\n", path);
935 if ((path[dir_len] == '.') || ((subdir != NULL) && (*subdir == '.'))) {
936 ALOGE("invalid apk path '%s' (trickery)\n", path);
944 * Checks whether a path points to a system app (.apk file). Returns 0
947 int validate_system_app_path(const char* path) {
952 if (!strncmp(path, android_system_dirs.dirs[i].path, dir_len)) {
953 return validate_path(android_system_dirs.dirs + i, path, 1);
961 * Get the contents of a environment variable that contains a path. Caller
966 const char* path = getenv(var);
967 int ret = get_path_from_string(rec, path);
981 int get_path_from_string(dir_rec_t* rec, const char* path) {
982 if (path == NULL) {
985 const size_t path_len = strlen(path);
990 // Make sure path is absolute.
991 if (path[0] != '/') {
995 if (path[path_len - 1] == '/') {
996 // Path ends with a forward slash. Make our own copy.
998 rec->path = strdup(path);
999 if (rec->path == NULL) {
1005 // Path does not end with a slash. Generate a new string.
1011 rec->path = (char*) malloc(dst_size);
1012 if (rec->path == NULL) {
1016 dst = rec->path;
1018 if (append_and_increment(&dst, path, &dst_size) < 0
1020 ALOGE("Error canonicalizing path");
1024 rec->len = dst - rec->path;
1033 dst->path = (char*) malloc(dstSize);
1035 if (dst->path == NULL
1036 || snprintf(dst->path, dstSize, "%s%s", src->path, suffix)
1038 ALOGE("Could not allocate memory to hold appended path; aborting\n");
1046 * Check whether path points to a valid pathpath must
1047 * begin with a whitelisted prefix path and must be no deeper than |maxSubdirs| within
1048 * that path. Returns -1 when an invalid path is encountered and 0 when a valid path
1051 static int validate_apk_path_internal(const char *path, int maxSubdirs) {
1053 if (!strncmp(path, android_app_dir.path, android_app_dir.len)) {
1055 } else if (!strncmp(path, android_app_private_dir.path, android_app_private_dir.len)) {
1057 } else if (!strncmp(path, android_asec_dir.path, android_asec_dir.len)) {
1059 } else if (!strncmp(path, android_mnt_expand_dir.path, android_mnt_expand_dir.len)) {
1068 return validate_path(dir, path, maxSubdirs);
1071 int validate_apk_path(const char* path) {
1072 return validate_apk_path_internal(path, 1 /* maxSubdirs */);
1075 int validate_apk_path_subdirs(const char* path) {
1076 return validate_apk_path_internal(path, 3 /* maxSubdirs */);