Lines Matching defs:path

21 int create_pkg_path_in_dir(char path[PKG_PATH_MAX],
41 char *dst = path;
44 if (append_and_increment(&dst, dir->path, &dst_size) < 0
47 ALOGE("Error building APK path");
55 * Create the package path name for a given package name with a postfix for
58 int create_pkg_path(char path[PKG_PATH_MAX],
79 if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
81 ALOGE("Error building prefix for APK path");
88 ALOGW("Error appending UID to APK path");
94 dir.path = prefix;
97 return create_pkg_path_in_dir(path, &dir, pkgname, postfix);
101 * Create the path name for user data for a certain persona.
104 int create_persona_path(char path[PKG_PATH_MAX],
117 char *dst = path;
120 if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
122 ALOGE("Error building prefix for user path");
128 ALOGE("Error building user path");
133 ALOGE("Error appending persona id to path");
141 * Create the path name for media for a certain persona.
144 int create_persona_media_path(char path[PATH_MAX], userid_t userid) {
145 if (snprintf(path, PATH_MAX, "%s%d", android_media_dir.path, userid) > PATH_MAX) {
151 int create_move_path(char path[PKG_PATH_MAX],
161 sprintf(path, "%s%s%s/%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgname, leaf);
325 // Verify the path won't extend beyond our buffer, to avoid
365 if (statfs(android_data_dir.path, &sfs) == 0) {
368 ALOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno));
553 // Update pathBase for the new path... this may change dirName
554 // if that is also pointing to the path, but we are done with it
562 // Whoops, the final path is too long! We'll just delete
564 ALOGW("Cache dir %s truncated in path %s; deleting dir\n",
586 // Build final full path for file... this may change dirName
587 // if that is also pointing to the path, but we are done with it
602 // Whoops, the final path is too long! We'll just delete
604 ALOGW("Cache file %s truncated in path %s; deleting\n",
671 static char *create_dir_path(char path[PATH_MAX], cache_dir_t* dir)
673 char *pos = path;
675 pos = create_dir_path(path, dir->parent);
688 static void delete_cache_dir(char path[PATH_MAX], cache_dir_t* dir)
691 create_dir_path(path, dir);
692 ALOGI("DEL DIR %s\n", path);
694 if (rmdir(path)) {
695 ALOGE("Couldn't rmdir %s: %s\n", path, strerror(errno));
701 if (delete_dir_contents(path, 1, NULL)) {
708 delete_cache_dir(path, dir->parent);
713 create_dir_path(path, dir);
714 ALOGI("DEL CONTENTS %s\n", path);
715 delete_dir_contents(path, 0, NULL);
730 char path[PATH_MAX];
743 delete_cache_dir(path, dir);
757 strcpy(create_dir_path(path, file->dir), file->name);
758 ALOGI("DEL (mod %d) %s\n", (int)file->modTime, path);
759 if (unlink(path) < 0) {
760 ALOGE("Couldn't unlink %s: %s\n", path, strerror(errno));
764 delete_cache_dir(path, file->dir);
796 * Checks whether a path points to a system app (.apk file). Returns 0
799 int validate_system_app_path(const char* path) {
804 if (!strncmp(path, android_system_dirs.dirs[i].path, dir_len)) {
805 if (path[dir_len] == '.' || strchr(path + dir_len, '/') != NULL) {
806 ALOGE("invalid system apk path '%s' (trickery)\n", path);
817 * Get the contents of a environment variable that contains a path. Caller
822 const char* path = getenv(var);
823 int ret = get_path_from_string(rec, path);
837 int get_path_from_string(dir_rec_t* rec, const char* path) {
838 if (path == NULL) {
841 const size_t path_len = strlen(path);
846 // Make sure path is absolute.
847 if (path[0] != '/') {
851 if (path[path_len - 1] == '/') {
854 rec->path = strdup(path);
855 if (rec->path == NULL) {
867 rec->path = malloc(dst_size);
868 if (rec->path == NULL) {
872 dst = rec->path;
874 if (append_and_increment(&dst, path, &dst_size) < 0
876 ALOGE("Error canonicalizing path");
880 rec->len = dst - rec->path;
889 dst->path = (char*) malloc(dstSize);
891 if (dst->path == NULL
892 || snprintf(dst->path, dstSize, "%s%s", src->path, suffix)
894 ALOGE("Could not allocate memory to hold appended path; aborting\n");
902 * Check whether path points to a valid path for an APK file. An ASEC
904 * when an invalid path is encountered and 0 when a valid path is encountered.
906 int validate_apk_path(const char *path)
913 if (!strncmp(path, android_app_dir.path, android_app_dir.len)) {
915 } else if (!strncmp(path, android_app_private_dir.path, android_app_private_dir.len)) {
917 } else if (!strncmp(path, android_asec_dir.path, android_asec_dir.len)) {
921 ALOGE("invalid apk path '%s' (bad prefix)\n", path);
925 path_len = strlen(path);
928 * Only allow the path to have a subdirectory if it's been marked as being allowed.
930 if ((subdir = strchr(path + dir_len, '/')) != NULL) {
933 || (path_len > (size_t) (subdir - path) && (strchr(subdir, '/') != NULL))) {
934 ALOGE("invalid apk path '%s' (subdir?)\n", path);
943 if (path[dir_len] == '.'
945 ALOGE("invalid apk path '%s' (trickery)\n", path);
997 char path[PATH_MAX];