Name: app2sd
Summary: Application installation on external memory
-Version: 0.5.36
+Version: 0.5.42
Release: 1
Group: Application Framework/Application Installer
License: Apache-2.0
SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES VERSION ${VERSION})
SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES COMPILE_FLAGS "${libapp2sd_CFLAGS}")
-TARGET_LINK_LIBRARIES(${APP2SD} ${libpkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${APP2SD} ${libpkgs_LDFLAGS} "-lm")
SET(CMAKE_INSTALL_PREFIX "/usr")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
#include <errno.h>
#include <sys/mount.h>
#include <app2sd_interface.h>
+#include <math.h>
#define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
#define DEV_MAJOR 7
#define FS_TYPE "ext4"
+#define INTERNAL_STORAGE_PATH "/opt/usr"
typedef enum mount_type_t {
MOUNT_TYPE_RD = 0,
char *device_node = NULL;
char *devi = NULL;
char *result = NULL;
+ int reqd_disk_size = size + ceil(size*0.2);
/*Validate the function parameter recieved */
if (pkgid == NULL || dir_list == NULL || size <= 0) {
app2ext_print("App2Sd Error : Unable to get available free memory in MMC %d\n", ret);
return APP2EXT_ERROR_MMC_STATUS;
}
+ app2ext_print("Size details for application installation:size=%dMB, reqd_disk_size=%dMB, free_mmc_size=%dMB\n",
+ size, reqd_disk_size, free_mmc_mem);
/*If avaialalbe free memory in MMC is less than required size + 5MB , return error */
- if ((size + PKG_BUF_SIZE + MEM_BUF_SIZE) > free_mmc_mem) {
+ if ((reqd_disk_size + PKG_BUF_SIZE + MEM_BUF_SIZE) > free_mmc_mem) {
app2ext_print("Insufficient memory in MMC for application installation %d\n", ret);
return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
}
/*Create a loopback device */
- ret = _app2sd_create_loopback_device(pkgid, (size+PKG_BUF_SIZE));
+ ret = _app2sd_create_loopback_device(pkgid, (reqd_disk_size+PKG_BUF_SIZE));
if (ret) {
app2ext_print("App2Sd Error : Package already present\n");
char buf_dir[FILENAME_MAX] = { 0, };
int rt = 0;
rt = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
if (rt < 0) {
- app2ext_print("fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
+ app2ext_print("fail to update installed location to db[%s, %d]\n", pkgid, INSTALL_EXTERNAL);
}
}
return ret;
END:
// vconf_set_int(VCONFKEY_PKGMGR_STATUS, ret);
- _app2sd_make_result_info_file(pkgid, ret);
+ _app2sd_make_result_info_file((char*)pkgid, ret);
return ret;
}
char *device_node = NULL;
unsigned long long curr_size = 0;
FILE *fp = NULL;
+ int reqd_disk_size = size + ceil(size*0.2);
/*Validate function arguments*/
if (pkgid == NULL || dir_list == NULL || size<=0) {
fclose(fp);
/*Get installed app size*/
curr_size = _app2sd_calculate_file_size(app_path);
- curr_size = (curr_size/1024)/1024;
+ curr_size = (curr_size)/(1024 * 1024);
if (curr_size==0) {
app2ext_print
("App2SD Error: App Entry is not present in SD Card\n");
return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
}
- if (curr_size<size) {
- ret = _app2sd_update_loopback_device_size(pkgid, size, dir_list);
+ if ((int)curr_size < reqd_disk_size) {
+ ret = _app2sd_update_loopback_device_size(pkgid, reqd_disk_size, dir_list);
if(APP2EXT_SUCCESS !=ret) {
app2ext_print
("App2SD Error: _app2sd_update_loopback_device_size() failed\n");
/*Do mounting */
ret =
_app2sd_mount_app_content(pkgid, device_node,
- MOUNT_TYPE_RW, NULL,
+ MOUNT_TYPE_RW, dir_list,
APP2SD_PRE_UPGRADE);
if (ret) {
app2ext_print("App2Sd Error : Re-mount failed\n");
#include <app2sd_internals.h>
#include <app2sd_interface.h>
+#include <sys/xattr.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <stdio.h>
#include <time.h>
#include <dlog.h>
#include <privilege-control.h>
+#include <sys/statvfs.h>
+
+extern int app2sd_force_clean(const char *pkgid);
/*
########### Internal APIs ##################
free(result);
return NULL;
} else {
- ret_result = strtok(dev, delims);
+ char *saveptr = NULL;
+ ret_result = strtok_r(dev, delims, &saveptr);
if (ret_result)
devnode = strdup(ret_result);
}
{
int ret = APP2EXT_SUCCESS;
FILE *fp = NULL;
- if (NULL == device_path) {
+ char err_buf[1024] = {0,};
+
+ if (device_path == NULL) {
app2ext_print("App2Sd Error: invalid param [NULL]\n");
return APP2EXT_ERROR_INVALID_ARGUMENTS;
}
const char *argv[] = { "/sbin/mkfs.ext4", device_path, NULL };
fp = fopen(device_path, "r+");
if (fp == NULL) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
app2ext_print
("App2sd Error: Unable to access %s [System errono is %d.....%s]\n",
- device_path, errno, strerror(errno));
+ device_path, errno, err_buf);
return APP2EXT_ERROR_ACCESS_FILE;
} else {
fclose(fp);
}
ret = _xsystem(argv);
if (ret) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
app2ext_print
("App2Sd Error : creating file system failed [System error is %s\n",
- strerror(errno));
+ err_buf);
return APP2EXT_ERROR_CREATE_FS;
}
return ret;
mode_t mode = DIR_PERMS;
char app_dir_path[FILENAME_MAX] = { 0, };
char app_dir_mmc_path[FILENAME_MAX] = { 0, };
+ struct timespec time = {
+ .tv_sec = 0,
+ .tv_nsec = 1000 * 1000 * 200
+ };
+
if (NULL == pkgid || NULL == dev) {
app2ext_print("App2Sd Error : Input param is NULL %s %s \n",
pkgid, dev);
}
}
- usleep(200 * 1000); /* 200ms sleep*/
+ nanosleep(&time, NULL); /* 200ms sleep */
app2ext_print ("App2Sd info : give a delay for mount\n");
switch (mount_type) {
break;
}
}
- if (cmd == APP2SD_PRE_INSTALL || cmd == APP2SD_MOVE_APP_TO_MMC) {
+ if (cmd == APP2SD_PRE_INSTALL || cmd == APP2SD_MOVE_APP_TO_MMC || cmd == APP2SD_PRE_UPGRADE) {
ret = _app2sd_create_directory_entry(pkgid, dir_list);
}
return ret;
{
int ret = APP2EXT_SUCCESS;
char app_dir_mmc_path[FILENAME_MAX] = { 0, };
+
snprintf(app_dir_mmc_path, FILENAME_MAX, "%s%s/.mmc", APP_INSTALLATION_PATH, pkgid);
if ((ret = umount(app_dir_mmc_path)) < 0) {
- app2ext_print("Unable to umount the dir %s\n", strerror(errno));
+ char err_buf[1024] = {0,};
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ app2ext_print("Unable to umount the dir %s\n", err_buf);
}
return ret;
}
int ret = APP2EXT_SUCCESS;
ret = _app2sd_copy_dir(src_path, arch_path);
- if (ret) {
- if (ret != APP2EXT_ERROR_ACCESS_FILE) {
- app2ext_print
- ("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
- src_path, arch_path, strerror(errno));
- return APP2EXT_ERROR_MOVE;
- }
+ if (ret && ret != APP2EXT_ERROR_ACCESS_FILE) {
+ char err_buf[1024] = {0,};
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ app2ext_print("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
+ src_path, arch_path, err_buf);
+ return APP2EXT_ERROR_MOVE;
}
+
ret = _app2sd_delete_directory((char *)src_path);
- if (ret) {
- if (ret != APP2EXT_ERROR_ACCESS_FILE) {
- app2ext_print("App2Sd Error : unable to delete %s \n", src_path);
- return APP2EXT_ERROR_DELETE_DIRECTORY;
- }
+ if (ret && ret != APP2EXT_ERROR_ACCESS_FILE) {
+ app2ext_print("App2Sd Error : unable to delete %s \n", src_path);
+ return APP2EXT_ERROR_DELETE_DIRECTORY;
}
+
return ret;
}
char mmc_path[FILENAME_MAX] = { 0, };
unsigned long long total_size = 0;
int reqd_size = 0;
+ int reqd_disk_size = 0;
char *device_node = NULL;
char *devi = NULL;
mode_t mode = DIR_PERMS;
("Already %s entry is present in the SD Card, delete entry and go on without return\n",
pkgid);
fclose(fp);
+ app2sd_force_clean(pkgid);
// return APP2EXT_ERROR_ALREADY_FILE_PRESENT;
}
list = g_list_next(list);
}
- reqd_size = ((total_size / 1024) / 1024) + 2;
+ reqd_size = ((total_size)/( 1024 * 1024)) + 2;
+ reqd_disk_size = reqd_size + ceil(reqd_size * 0.2);
/*Find avialable free memory in the MMC card */
ret =
return APP2EXT_ERROR_MMC_STATUS;
}
/*If avaialalbe free memory in MMC is less than required size + 5MB , return error */
- if (reqd_size > free_mmc_mem) {
+ if (reqd_disk_size > free_mmc_mem) {
app2ext_print
("App2Sd Error : Insufficient memory in MMC for application installation %d\n",
ret);
}
/*Create a loopback device */
ret =
- _app2sd_create_loopback_device(pkgid, (reqd_size+PKG_BUF_SIZE));
+ _app2sd_create_loopback_device(pkgid, (reqd_disk_size+PKG_BUF_SIZE));
if (ret) {
app2ext_print
("App2Sd Error : loopback node creation failed\n");
app_mmc_path);
if (ret) {
if (ret == APP2EXT_ERROR_ACCESS_FILE) {
- app2ext_print
- ("App2Sd Error : unable to access %s\n",
- path);
+ app2ext_print("App2Sd Error : unable to access %s\n", path);
} else {
- app2ext_print
- ("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
- path,
- app_mmc_path,
- strerror
- (errno));
+ char err_buf[1024] = {0,};
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ app2ext_print("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
+ path, app_mmc_path, err_buf);
// return APP2EXT_ERROR_MOVE;
}
}
FILE *fp = NULL;
GList *list = NULL;
app2ext_dir_details* dir_detail = NULL;
+ int reqd_size = 0;
+ int free_internal_mem = 0;
+ struct statvfs buf = {0,};
+ unsigned long long temp = 0;
+ char err_buf[1024] = {0,};
snprintf(app_mmc_path, FILENAME_MAX,
"%s%s/.mmc", APP_INSTALLATION_PATH, pkgid);
fp = NULL;
}
+ memset((void *)&buf, '\0', sizeof(struct statvfs));
+ ret = statvfs(INTERNAL_STORAGE_PATH, &buf);
+ if (0 == ret){
+ temp = (buf.f_bsize * buf.f_bavail)/(1024*1024);
+ free_internal_mem = (int)temp;
+ }else{
+ app2ext_print("App2SD Error: Unable to get internal storage size\n");
+ return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY; /*TODO: new error no for internal?*/
+ }
+
+ /*check app entry is there in sd card or not. */
+ snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
+ pkgid);
+ app2ext_print("App2Sd Log : Checking path %s\n", app_path);
+ fp = fopen(app_path, "r+");
+ if (fp == NULL) {
+ app2ext_print
+ ("App2SD Error: App Entry is not present in SD Card\n");
+ return APP2EXT_ERROR_INVALID_PACKAGE;
+ }
+ fclose(fp);
+ /*Get installed app size*/
+ temp = _app2sd_calculate_file_size(app_path);
+ reqd_size = (int)((temp)/(1024 * 1024));
+ app2ext_print("App2Sd Log : Reqd size is %d\n", reqd_size);
+
+ if (reqd_size == 0) {
+ app2ext_print
+ ("App2SD Error: App Entry is not present in SD Card\n");
+ return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
+ }
+
+ app2ext_print("Reqd Size: %d MB, free internal mem %d MB\n", reqd_size, free_internal_mem);
+ /*If avaialalbe free memory in internal storage is less than required size, return error */
+ if (reqd_size > free_internal_mem) {
+ app2ext_print
+ ("App2Sd Error : Insufficient memory in internal storage for application installation %d\n",
+ ret);
+ return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY; /*TODO: new error no for internal?*/
+ }
/*Get the associated device node for SD card applicationer */
+ snprintf(app_path, FILENAME_MAX, "%s%s/", APP_INSTALLATION_PATH,
+ pkgid);
+
device_node =
_app2sd_find_associated_device_node(pkgid);
if (NULL == device_node) {
app_archive_path);
if (ret) {
if (ret == APP2EXT_ERROR_ACCESS_FILE) {
- app2ext_print
- ("App2Sd Error : unable to access %s\n",
- path);
+ app2ext_print("App2Sd Error : unable to access %s\n", path);
} else {
- app2ext_print
- ("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
- path,
- app_archive_path,
- strerror
- (errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ app2ext_print("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
+ path, app_archive_path, err_buf);
// return APP2EXT_ERROR_MOVE;
}
}
ret = unlink(path);
if (ret) {
if (errno == ENOENT) {
- app2ext_print
- ("App2Sd Error : Directory %s does not exist\n",
- path);
+ app2ext_print("App2Sd Error : Directory %s does not exist\n", path);
} else {
- app2ext_print
- ("App2Sd Error : unable to remove the symbolic link file %s, it is already unlinked!!!\n",
- path);
+ app2ext_print("App2Sd Error : unable to remove the symbolic link file %s, it is already unlinked!!!\n", path);
// return APP2EXT_ERROR_DELETE_LINK_FILE;
}
}
memset((void *)&path, '\0',
FILENAME_MAX);
snprintf(path, FILENAME_MAX,
- "%s%s/.archive/%s", APP_INSTALLATION_PATH,
- pkgid,
- dir_detail->name);
- ret =
- _app2sd_copy_dir
- (path, app_path);
+ "%s%s/.archive/%s", APP_INSTALLATION_PATH,
+ pkgid, dir_detail->name);
+ ret = _app2sd_copy_dir(path, app_path);
if (ret) {
if (ret == APP2EXT_ERROR_ACCESS_FILE) {
- app2ext_print
- ("App2Sd Error : unable to access %s\n",
- path);
+ app2ext_print("App2Sd Error : unable to access %s\n", path);
} else {
- app2ext_print
- ("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
- path,
- app_path,
- strerror
- (errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ app2ext_print("App2Sd Error : unable to copy from %s to %s .....err is %s\n",
+ path, app_path, err_buf);
// return APP2EXT_ERROR_MOVE;
}
}
list = g_list_next(list);
}
+ app2ext_print("App2Sd info : Copying file completed\n");
ret = _app2sd_unmount_app_content(pkgid);
if (ret) {
app2ext_print
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
{
int status = 0;
pid_t pid;
+ char err_buf[1024] = {0,};
+
pid = fork();
switch (pid) {
case -1:
return -1;
case 0:
/* child */
+ strerror_r(errno, err_buf, sizeof(err_buf));
if (execvp(argv[0], (char *const *)argv) < 0) {
- fprintf(stderr, "execvp failed %d....%s\n", errno, strerror(errno)); /*Don't use d_msg_app2sd */
+ fprintf(stderr, "execvp failed %d....%s\n", errno, err_buf); /*Don't use d_msg_app2sd */
}
_exit(-1);
default:
{
struct statvfs buf;
int ret = 0;
+ unsigned long long temp = 0;
if (sd_path == NULL || free_mem == NULL) {
app2ext_print("App2Sd Error : Invalid input parameter\n");
return -1;
("App2SD Error: Unable to get SD Card memory information\n");
return APP2EXT_ERROR_MMC_INFORMATION;
}
- *free_mem = ((buf.f_bfree * buf.f_bsize) / 1024) / 1024;
+ temp = (unsigned long long)buf.f_bsize*buf.f_bavail;
+ *free_mem = (int)(temp/(1024*1024));
return 0;
}
int _app2sd_delete_directory(char *dirname)
{
DIR *dp = NULL;
- struct dirent *ep = NULL;
+ struct dirent ep;
+ struct dirent *er = NULL;
char abs_filename[FILENAME_MAX] = { 0, };
int ret = 0;
+
dp = opendir(dirname);
if (dp != NULL) {
- while ((ep = readdir(dp)) != NULL) {
+ while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
struct stat stFileInfo;
snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
- ep->d_name);
+ ep.d_name);
if (lstat(abs_filename, &stFileInfo) < 0) {
perror(abs_filename);
}
if (S_ISDIR(stFileInfo.st_mode)) {
- if (strcmp(ep->d_name, ".")
- && strcmp(ep->d_name, "..")) {
+ if (strcmp(ep.d_name, ".")
+ && strcmp(ep.d_name, "..")) {
ret = _app2sd_delete_directory(abs_filename);
if (ret <0) {
(void)closedir(dp);
{
int ret = 0;
DIR *dp = NULL;
- struct dirent *ep = NULL;
+ struct dirent ep;
+ struct dirent *er = NULL;
char abs_filename[FILENAME_MAX] = { 0, };
app2ext_print("star clean_symlink [%s]", dirname);
dp = opendir(dirname);
if (dp != NULL) {
- while ((ep = readdir(dp)) != NULL) {
- struct stat stFileInfo;
+ while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
char mmc_path[PATH_MAX] = {0};
- if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, ".."))
+ if (!strcmp(ep.d_name, ".") || !strcmp(ep.d_name, ".."))
continue;
/*get realpath find symlink to ".mmc" and unlink it*/
- snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, ep->d_name);
- realpath(abs_filename, mmc_path);
+ snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, ep.d_name);
+ char *path = realpath(abs_filename, mmc_path);
+ if(!path){
+ app2ext_print("realpath failed\n");
+ }
if (strstr(mmc_path,".mmc")) {
app2ext_print("force unlink [%s]", abs_filename);
{
static unsigned long long total = 0;
DIR *dp = NULL;
- struct dirent *ep = NULL;
+ struct dirent ep;
+ struct dirent *er = NULL;
char abs_filename[FILENAME_MAX] = { 0, };;
+
dp = opendir(dirname);
if (dp != NULL) {
- while ((ep = readdir(dp)) != NULL) {
+ while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
struct stat stFileInfo;
snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
- ep->d_name);
+ ep.d_name);
if (stat(abs_filename, &stFileInfo) < 0)
perror(abs_filename);
total += stFileInfo.st_size;
if (S_ISDIR(stFileInfo.st_mode)) {
- if (strcmp(ep->d_name, ".")
- && strcmp(ep->d_name, "..")) {
+ if (strcmp(ep.d_name, ".")
+ && strcmp(ep.d_name, "..")) {
_app2sd_calculate_dir_size
(abs_filename);
}
char buf[FILENAME_MAX] = { 0, };
char *ret_result = NULL;
int result = 0;
+ char err_buf[1024] = {0,};
+
if (pipe(my_pipe) < 0) {
fprintf(stderr, "Unable to create pipe\n");
return NULL;
close(2);
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
- fprintf(stderr, "execvp failed %d....%s\n", errno, strerror(errno)); /*Don't use d_msg_app2sd */
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "execvp failed %d....%s\n", errno, err_buf); /*Don't use d_msg_app2sd */
}
_exit(-1);
default:
/* parent */
close(my_pipe[1]);
result = read(my_pipe[0], buf, FILENAME_MAX);
- if (result < 0)
- fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
+ if (result < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "read failed %d....%s\n", errno, err_buf);
+ }
break;
}
char buf[FILENAME_MAX] = { 0, };
char *ret_result = NULL;
int result = 0;
+ char err_buf[1024] = {0,};
+
if (pipe(my_pipe) < 0) {
fprintf(stderr, "Unable to create pipe\n");
return NULL;
close(2);
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
/* parent */
close(my_pipe[1]);
result = read(my_pipe[0], buf, FILENAME_MAX);
- if (result < 0)
- fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
+ if (result < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "read failed %d....%s\n", errno, err_buf);
+ }
break;
}
char buf[FILENAME_MAX] = { 0, };
char *ret_result = NULL;
int result = 0;
+ char err_buf[1024] = {0,};
+
if (pipe(my_pipe) < 0) {
fprintf(stderr, "Unable to create pipe\n");
return NULL;
close(2);
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
/* parent */
close(my_pipe[1]);
result = read(my_pipe[0], buf, FILENAME_MAX);
- if (result < 0)
- fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
+ if (result < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "read failed %d....%s\n", errno, err_buf);
+ }
break;
}
const char *argv[] = { "/sbin/losetup", "-f", NULL };
pid_t pid;
int my_pipe[2] = { 0, };
- char buf[FILENAME_MAX+1] = { 0, };
+ char buf[FILENAME_MAX + 1] = { 0, };
char *ret_result = NULL;
int result = 0;
+ char err_buf[1024] = {0,};
+
if (pipe(my_pipe) < 0) {
fprintf(stderr, "Unable to create pipe\n");
return NULL;
close(2);
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
- fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
- close(result);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "dup failed %d....%s\n", errno, err_buf);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
/* parent */
close(my_pipe[1]);
result = read(my_pipe[0], buf, FILENAME_MAX);
- if (result < 0)
- fprintf(stderr, "read failed %d....%s\n", errno, strerror(errno));
+ if (result < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ fprintf(stderr, "read failed %d....%s\n", errno, err_buf);
+ }
break;
}
int i = 0;
int appname_len = strlen(pkgid);
int j = appname_len;
+ unsigned int seed;
/* Length of the password */
ret_result = (char*)malloc(PASSWD_LEN+1);
memset((void *)ret_result, '\0', PASSWD_LEN+1);
while(i < PASSWD_LEN) {
- char_1 = (rand()+pkgid[j--])%ASCII_PASSWD_CHAR;
- char_2 = rand()%ASCII_PASSWD_CHAR;
+ seed = time(NULL);
+ char_1 = (rand_r(&seed)+pkgid[j--])%ASCII_PASSWD_CHAR;
+ char_2 = rand_r(&seed)%ASCII_PASSWD_CHAR;
passwd[i] = set[char_1];
passwd[i+1] = set[(pkgid[j--])*2];
if (i<PASSWD_LEN-3)
int ret = 0;
DIR *dir = NULL;
char buf[FILENAME_MAX] = { 0, };
- struct dirent entry, *result;
+ struct dirent entry, *result = NULL;
dir = opendir(APP2SD_PATH);
if (!dir) {
int ret = 0;
DIR *dir = NULL;
char buf[FILENAME_MAX] = { 0, };
- struct dirent entry, *result;
+ struct dirent entry, *result = NULL;
dir = opendir(APP2SD_PATH);
if (!dir) {