blob: 1679d148f4ec055a25711ffaa0b81d55abc03868 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
18#define LOG_TAG "installd"
19
20#include <stdio.h>
21#include <stdlib.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
33#include <cutils/sockets.h>
34#include <cutils/log.h>
35#include <cutils/properties.h>
36
37#include <private/android_filesystem_config.h>
38
39#if INCLUDE_SYS_MOUNT_FOR_STATFS
40#include <sys/mount.h>
41#else
42#include <sys/statfs.h>
43#endif
44
45#define SOCKET_PATH "installd"
46
47
48/* elements combined with a valid package name to form paths */
49
50#define PKG_DIR_PREFIX "/data/data/"
Oscar Montemayora8529f62009-11-18 10:14:20 -080051#define PKG_SEC_DIR_PREFIX "/data/secure/data/"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052#define PKG_DIR_POSTFIX ""
53
54#define PKG_LIB_PREFIX "/data/data/"
Oscar Montemayora8529f62009-11-18 10:14:20 -080055#define PKG_SEC_LIB_PREFIX "/data/secure/data/"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056#define PKG_LIB_POSTFIX "/lib"
57
58#define CACHE_DIR_PREFIX "/data/data/"
Oscar Montemayora8529f62009-11-18 10:14:20 -080059#define CACHE_SEC_DIR_PREFIX "/data/secure/data/"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060#define CACHE_DIR_POSTFIX "/cache"
61
62#define APK_DIR_PREFIX "/data/app/"
63
Oscar Montemayora8529f62009-11-18 10:14:20 -080064/* Encrypted File SYstems constants */
65#define USE_ENCRYPTED_FS 1
66#define USE_UNENCRYPTED_FS 0
67
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068/* other handy constants */
69
70#define PROTECTED_DIR_PREFIX "/data/app-private/"
71
72#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
73#define DALVIK_CACHE_POSTFIX "/classes.dex"
74
75
76#define PKG_NAME_MAX 128 /* largest allowed package name */
77#define PKG_PATH_MAX 256 /* max size of any path we use */
78
79
80/* util.c */
81
82int create_pkg_path(char path[PKG_PATH_MAX],
83 const char *prefix,
84 const char *pkgname,
85 const char *postfix);
86
87int create_cache_path(char path[PKG_PATH_MAX], const char *src);
88
89int delete_dir_contents(const char *pathname,
90 int also_delete_dir,
91 const char *ignore);
92
93int delete_dir_contents_fd(int dfd, const char *name);
94
95/* commands.c */
96
Oscar Montemayora8529f62009-11-18 10:14:20 -080097int install(const char *pkgname, int encrypted_fs_flag, uid_t uid, gid_t gid);
98int uninstall(const char *pkgname, int encrypted_fs_flag);
99int delete_user_data(const char *pkgname, int encrypted_fs_flag);
100int delete_cache(const char *pkgname, int encrypted_fs_flag);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101int move_dex(const char *src, const char *dst);
102int rm_dex(const char *path);
103int protect(char *pkgname, gid_t gid);
104int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath,
Oscar Montemayora8529f62009-11-18 10:14:20 -0800105 int *codesize, int *datasize, int *cachesize, int encrypted_fs_flag);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106int free_cache(int free_size);
107int dexopt(const char *apk_path, uid_t uid, int is_public);