Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25429378 authored by Kenny Root's avatar Kenny Root Committed by Android (Google) Code Review
Browse files

Merge "Allow installd to handle large partitions" into gingerbread

parents 45cda90b 3e319a99
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ int delete_cache(const char *pkgname, int encrypted_fs_flag)
/* TODO(oam): depending on use case (ecryptfs or dmcrypt)
 * change implementation
 */
static int disk_free()
static int64_t disk_free()
{
    struct statfs sfs;
    if (statfs(PKG_DIR_PREFIX, &sfs) == 0) {
@@ -154,18 +154,18 @@ static int disk_free()
 * also require that apps constantly modify file metadata even
 * when just reading from the cache, which is pretty awful.
 */
int free_cache(int free_size)
int free_cache(int64_t free_size)
{
    const char *name;
    int dfd, subfd;
    DIR *d;
    struct dirent *de;
    int avail;
    int64_t avail;

    avail = disk_free();
    if (avail < 0) return -1;

    LOGI("free_cache(%d) avail %d\n", free_size, avail);
    LOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", free_size, avail);
    if (avail >= free_size) return 0;

    /* First try encrypted dir */
@@ -327,10 +327,10 @@ int protect(char *pkgname, gid_t gid)
    return 0;
}

static int stat_size(struct stat *s)
static int64_t stat_size(struct stat *s)
{
    int blksize = s->st_blksize;
    int size = s->st_size;
    int64_t blksize = s->st_blksize;
    int64_t size = s->st_size;

    if (blksize) {
            /* round up to filesystem block size */
@@ -340,9 +340,9 @@ static int stat_size(struct stat *s)
    return size;
}

static int calculate_dir_size(int dfd)
static int64_t calculate_dir_size(int dfd)
{
    int size = 0;
    int64_t size = 0;
    struct stat s;
    DIR *d;
    struct dirent *de;
@@ -378,7 +378,7 @@ static int calculate_dir_size(int dfd)

int get_size(const char *pkgname, const char *apkpath,
             const char *fwdlock_apkpath,
             int *_codesize, int *_datasize, int *_cachesize, int encrypted_fs_flag)
             int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize, int encrypted_fs_flag)
{
    DIR *d;
    int dfd;
@@ -386,9 +386,9 @@ int get_size(const char *pkgname, const char *apkpath,
    struct stat s;
    char path[PKG_PATH_MAX];

    int codesize = 0;
    int datasize = 0;
    int cachesize = 0;
    int64_t codesize = 0;
    int64_t datasize = 0;
    int64_t cachesize = 0;

        /* count the source apk as code -- but only if it's not
         * on the /system partition and its not on the sdcard.
@@ -445,7 +445,7 @@ int get_size(const char *pkgname, const char *apkpath,
            }
            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
            if (subfd >= 0) {
                int size = calculate_dir_size(subfd);
                int64_t size = calculate_dir_size(subfd);
                if (!strcmp(name,"lib")) {
                    codesize += size;
                } else if(!strcmp(name,"cache")) {
+9 −5
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ static int do_rename(char **arg, char reply[REPLY_MAX])

static int do_free_cache(char **arg, char reply[REPLY_MAX]) /* TODO int:free_size */
{
    return free_cache(atoi(arg[0])); /* free_size */
    return free_cache((int64_t)atoll(arg[0])); /* free_size */
}

static int do_rm_cache(char **arg, char reply[REPLY_MAX])
@@ -75,15 +75,19 @@ static int do_protect(char **arg, char reply[REPLY_MAX])

static int do_get_size(char **arg, char reply[REPLY_MAX])
{
    int codesize = 0;
    int datasize = 0;
    int cachesize = 0;
    int64_t codesize = 0;
    int64_t datasize = 0;
    int64_t cachesize = 0;
    int res = 0;

        /* pkgdir, apkpath */
    res = get_size(arg[0], arg[1], arg[2], &codesize, &datasize, &cachesize, atoi(arg[3]));

    sprintf(reply,"%d %d %d", codesize, datasize, cachesize);
    /*
     * Each int64_t can take up 22 characters printed out. Make sure it
     * doesn't go over REPLY_MAX in the future.
     */
    snprintf(reply, REPLY_MAX, "%" PRId64 " %" PRId64 " %" PRId64, codesize, datasize, cachesize);
    return res;
}

+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
@@ -105,7 +107,7 @@ int move_dex(const char *src, const char *dst);
int rm_dex(const char *path);
int protect(char *pkgname, gid_t gid);
int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath,
             int *codesize, int *datasize, int *cachesize, int encrypted_fs_flag);
int free_cache(int free_size);
             int64_t *codesize, int64_t *datasize, int64_t *cachesize, int encrypted_fs_flag);
int free_cache(int64_t free_size);
int dexopt(const char *apk_path, uid_t uid, int is_public);
int movefiles();