Add more debugging to installd
If a command to installd fails, it would be nice to know exactly why. Log failures and the errno associated with the failures. Change-Id: Ia3122675f243037c556d3a49d06da7e03b8c59f6
This commit is contained in:
@@ -24,7 +24,6 @@ int install(const char *pkgname, int encrypted_fs_flag, uid_t uid, gid_t gid)
|
||||
if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
|
||||
LOGE("invalid uid/gid: %d %d\n", uid, gid);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
if (encrypted_fs_flag == USE_UNENCRYPTED_FS) {
|
||||
@@ -143,6 +142,7 @@ static int disk_free()
|
||||
if (statfs(PKG_DIR_PREFIX, &sfs) == 0) {
|
||||
return sfs.f_bavail * sfs.f_bsize;
|
||||
} else {
|
||||
LOGE("Couldn't statfs " PKG_DIR_PREFIX ": %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ int free_cache(int free_size)
|
||||
/* First try encrypted dir */
|
||||
d = opendir(PKG_SEC_DIR_PREFIX);
|
||||
if (d == NULL) {
|
||||
LOGE("cannot open %s\n", PKG_SEC_DIR_PREFIX);
|
||||
LOGE("cannot open %s: %s\n", PKG_SEC_DIR_PREFIX, strerror(errno));
|
||||
} else {
|
||||
dfd = dirfd(d);
|
||||
|
||||
@@ -203,7 +203,7 @@ int free_cache(int free_size)
|
||||
/* Next try unencrypted dir... */
|
||||
d = opendir(PKG_DIR_PREFIX);
|
||||
if (d == NULL) {
|
||||
LOGE("cannot open %s\n", PKG_DIR_PREFIX);
|
||||
LOGE("cannot open %s: %s\n", PKG_DIR_PREFIX, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
dfd = dirfd(d);
|
||||
@@ -279,6 +279,7 @@ int move_dex(const char *src, const char *dst)
|
||||
|
||||
LOGI("move %s -> %s\n", src_dex, dst_dex);
|
||||
if (rename(src_dex, dst_dex) < 0) {
|
||||
LOGE("Couldn't move %s: %s\n", src_dex, strerror(errno));
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -294,6 +295,7 @@ int rm_dex(const char *path)
|
||||
|
||||
LOGI("unlink %s\n", dex_path);
|
||||
if (unlink(dex_path) < 0) {
|
||||
LOGE("Couldn't unlink %s: %s\n", dex_path, strerror(errno));
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -98,11 +98,13 @@ static int _delete_dir_contents(DIR *d, const char *ignore)
|
||||
|
||||
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
|
||||
if (subfd < 0) {
|
||||
LOGE("Couldn't openat %s: %s\n", name, strerror(errno));
|
||||
result = -1;
|
||||
continue;
|
||||
}
|
||||
subdir = fdopendir(subfd);
|
||||
if (subdir == NULL) {
|
||||
LOGE("Couldn't fdopendir %s: %s\n", name, strerror(errno));
|
||||
close(subfd);
|
||||
result = -1;
|
||||
continue;
|
||||
@@ -112,10 +114,12 @@ static int _delete_dir_contents(DIR *d, const char *ignore)
|
||||
}
|
||||
closedir(subdir);
|
||||
if (unlinkat(dfd, name, AT_REMOVEDIR) < 0) {
|
||||
LOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
|
||||
result = -1;
|
||||
}
|
||||
} else {
|
||||
if (unlinkat(dfd, name, 0) < 0) {
|
||||
LOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
@@ -133,12 +137,14 @@ int delete_dir_contents(const char *pathname,
|
||||
|
||||
d = opendir(pathname);
|
||||
if (d == NULL) {
|
||||
LOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno));
|
||||
return -errno;
|
||||
}
|
||||
res = _delete_dir_contents(d, ignore);
|
||||
closedir(d);
|
||||
if (also_delete_dir) {
|
||||
if (rmdir(pathname)) {
|
||||
LOGE("Couldn't rmdir %s: %s\n", pathname, strerror(errno));
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
@@ -152,10 +158,12 @@ int delete_dir_contents_fd(int dfd, const char *name)
|
||||
|
||||
fd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
|
||||
if (fd < 0) {
|
||||
LOGE("Couldn't openat %s: %s\n", name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
d = fdopendir(fd);
|
||||
if (d == NULL) {
|
||||
LOGE("Couldn't fdopendir %s: %s\n", name, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user