#include <sys/types.h>
#include <fcntl.h>
-#include <errno.h>
#include <vconf.h>
-#include <aul/aul.h>
-#include <grp.h>
-#include <pwd.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
-#ifdef _SET_VIP_PROCESS
-#include <sys/prctl.h>
-#endif
-#include <system_info.h>
-#include <dd-display.h>
-#ifndef _USE_DEVICED_DBUS
+#ifdef _USE_TVPD_MODE
+#include <sys/prctl.h>
#include <usb-device.h>
#endif
+#include <system_info.h>
+#include <device/power.h>
#include "media-util.h"
#include "media-server-ipc.h"
#include "media-common-system.h"
#include "media-common-utils.h"
-/* it's for 32bit file offset */
-struct statvfs_32 {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
- unsigned long int f_blocks;
- unsigned long int f_bfree;
- unsigned long int f_bavail;
- unsigned long int f_files;
- unsigned long int f_ffree;
- unsigned long int f_favail;
- unsigned long int f_fsid;
-#ifdef _STATVFSBUF_F_UNUSED
- int __f_unused;
-#endif
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
-};
-
-int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2)
-{
- int len = 0;
- int real_size = size - 1;
-
- if (!res || !pattern || !str1 || !str2)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- if (real_size < (int)(strlen(str1) + strlen(str2)))
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- len = snprintf(res, real_size, pattern, str1, str2);
- if (len < 0) {
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- res[len] = '\0';
-
- return MS_MEDIA_ERR_NONE;
-}
-
bool ms_config_get_int(const char *key, int *value)
{
int err;
}
err = vconf_get_int(key, value);
- if (err == 0)
+ if (err == VCONF_OK)
return true;
- else if (err == -1)
- return false;
- else
- MS_DBG_ERR("Unexpected error code: %d", err);
+
+ MS_DBG_ERR("Error code: %d", err);
return false;
}
}
err = vconf_set_int(key, value);
- if (err == 0)
+ if (err == VCONF_OK)
return true;
- else if (err == -1)
- return false;
- else
- MS_DBG_ERR("Unexpected error code: %d", err);
- return false;
-}
-
-bool ms_config_get_str(const char *key, char **value)
-{
- char *res = NULL;
-
- if (key == NULL || value == NULL) {
- MS_DBG_ERR("Arguments key or value is NULL");
- return false;
- }
-
- res = vconf_get_str(key);
- if (MS_STRING_VALID(res)) {
- *value = strdup(res);
- MS_SAFE_FREE(res);
- return true;
- }
+ MS_DBG_ERR("Error code: %d", err);
return false;
}
-bool ms_config_set_str(const char *key, const char *value)
-{
- int err;
-
- if (!key || !value) {
- MS_DBG_ERR("Arguments key or value is NULL");
- return false;
- }
-
- err = vconf_set_str(key, value);
- if (err == 0)
- return true;
- else
- MS_DBG_ERR("fail to vconf_set_str %d", err);
-
- return false;
-}
-
-bool ms_config_get_bool(const char *key, int *value)
-{
- int err;
-
- if (!key || !value) {
- MS_DBG_ERR("Arguments key or value is NULL");
- return false;
- }
-
- err = vconf_get_bool(key, value);
- if (err == 0)
- return true;
- else if (err == -1)
- return false;
- else
- MS_DBG_ERR("Unexpected error code: %d", err);
-
- return false;
-}
-
-static int get_memory_size(const char *path, struct statvfs_32 *buf)
+int ms_get_remain_space(uint64_t *free_space)
{
+ int ret = MS_MEDIA_ERR_NONE;
+ const char *path = "/opt";
struct statvfs s;
- int ret;
ret = statvfs(path, &s);
- if (ret) {
+ if (ret != 0) {
MS_DBG_ERR("statvfs failed[%d]", ret);
MS_DBG_STRERROR();
return MS_MEDIA_ERR_INTERNAL;
}
- buf->f_bsize = s.f_bsize;
- buf->f_frsize = s.f_frsize;
- buf->f_blocks = (unsigned long)s.f_blocks;
- buf->f_bfree = (unsigned long)s.f_bfree;
- buf->f_bavail = (unsigned long)s.f_bavail;
- buf->f_files = (unsigned long)s.f_files;
- buf->f_ffree = (unsigned long)s.f_ffree;
- buf->f_favail = (unsigned long)s.f_favail;
- buf->f_fsid = s.f_fsid;
- buf->f_flag = s.f_flag;
- buf->f_namemax = s.f_namemax;
+ /* f_bsize:unsigned long, f_bavail:fsblkcnt_t(unsigned long) */
+ *free_space = (uint64_t)s.f_bsize * (uint64_t)s.f_bavail;
return MS_MEDIA_ERR_NONE;
}
-int ms_get_remain_space(double *free_space)
-{
- int ret = MS_MEDIA_ERR_NONE;
- struct statvfs_32 temp;
-
- ret = get_memory_size("/opt", &temp);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("fail to get memory size");
- return ret;
- }
-
-// MS_DBG_ERR("Total mem : %lf, Avail mem : %lf", (double)temp.f_frsize*temp.f_blocks, (double)temp.f_bsize*temp.f_bavail);
-
- *free_space = (double)temp.f_bsize*temp.f_bavail;
-
- return ret;
-}
-
-#ifdef _USE_RECORDED_CONTENT
+#ifdef _USE_TVPD_MODE
bool ms_is_support_pvr(void)
{
-
- int nSupportPVR = 0;
- if (system_info_get_value_int(SYSTEM_INFO_KEY_PVR_SUPPORTED, &nSupportPVR) != SYSTEM_INFO_ERROR_NONE) {
+ bool bSupportPVR = false;
+ if (system_info_get_custom_bool("com.samsung/featureconf/pvr.pvr_support", &bSupportPVR) != SYSTEM_INFO_ERROR_NONE) {
MS_DBG_ERR("Get PVR Support failed");
return false;
}
- MS_DBG("PVR Support : [%d]", nSupportPVR);
+ MS_DBG("PVR Support : [%d]", bSupportPVR);
- return (nSupportPVR != 0);
+ return bSupportPVR;
}
#endif
-#ifdef _USE_SENIOR_MODE
-bool ms_is_support_senior_mode()
+bool ms_is_valid_symlink(const char *path)
{
- bool bSupportSeniorMode = false;
+#ifdef _USE_TVPD_MODE
+ return false;
+#else
+ g_autofree char *real_path = realpath(path, NULL);
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
- MS_DBG_ERR("Get senior mode support failed");
+ if (!real_path)
return false;
- }
-
- MS_DBG("Senior mode support : [%d]", bSupportSeniorMode);
- return bSupportSeniorMode;
-}
+ return (g_strcmp0(real_path, MEDIA_SHARE_PATH) == 0);
#endif
+}
int ms_check_file_path(const char *file_path, uid_t uid)
{
- int exist;
- struct stat file_st;
ms_user_storage_type_e storage_type = -1;
int ret = MS_MEDIA_ERR_NONE;
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- /* check location of file */
- /* file must exists under "/opt/usr/media" or "/opt/storage/sdcard" */
ret = ms_user_get_storage_type(uid, file_path, &storage_type);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PATH, "Invalid path");
+ MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
- /* check the file exits actually */
- exist = open(file_path, O_RDONLY);
- if (exist < 0) {
- MS_DBG_SERR("open file fail [%s]", file_path);
- return MS_MEDIA_ERR_INVALID_PATH;
- }
- close(exist);
-
- /* check type of the path */
- /* It must be a regular file */
- memset(&file_st, 0, sizeof(struct stat));
- if (stat(file_path, &file_st) == 0) {
- if (!S_ISREG(file_st.st_mode)) {
- /* In this case, it is not a regula file */
- MS_DBG_ERR("this path is not a file");
- return MS_MEDIA_ERR_INVALID_PATH;
- }
- } else {
- MS_DBG_STRERROR("stat failed");
- return MS_MEDIA_ERR_INVALID_PATH;
+ if (!g_file_test(file_path, G_FILE_TEST_IS_REGULAR)) {
+ MS_DBG_SERR("g_file_test fail [%s]", file_path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
return MS_MEDIA_ERR_NONE;
{
int ret = MS_MEDIA_ERR_NONE;
char *dir_path = NULL;
- char *leaf_path = NULL;
- char *usr_path = NULL;
+ char *next = NULL;
+ int next_pos = 0;
ret = ms_check_file_path(full_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("invalid path : %s", full_path);
- return MS_MEDIA_ERR_INVALID_PATH;
- }
+ MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
- dir_path = g_path_get_dirname(full_path);
- if (dir_path == NULL || strcmp(dir_path, ".") == 0) {
- MS_DBG_ERR("getting directory path is failed : %s", full_path);
- MS_SAFE_FREE(dir_path);
- return MS_MEDIA_ERR_INVALID_PATH;
- }
+ if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && !strncmp(full_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB))) {
+ next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
+ } else {
+ ret = ms_user_get_internal_root_path(uid, &dir_path);
+ MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_internal_root_path() fail");
- ret = ms_user_get_internal_root_path(uid, &usr_path);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_user_get_internal_root_path() fail");
- MS_SAFE_FREE(dir_path);
- return MS_MEDIA_ERR_INTERNAL;
+ next_pos = strlen(dir_path);
+ g_free(dir_path);
+ dir_path = NULL;
}
- while (1) {
- if (ms_check_scan_ignore(dir_path) != MS_MEDIA_ERR_NONE) {
- ret = MS_MEDIA_ERR_INVALID_PATH;
- break;
- }
-
-#ifdef _USE_SENIOR_MODE
- if (ms_is_support_senior_mode()) {
- if (strcmp(dir_path, MEDIA_ROOT_PATH_SENIOR_MODE) == 0)
- break;
- }
-#endif
- if (strcmp(dir_path, usr_path) == 0)
- break;
- else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(dir_path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0))
- break;
- else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(dir_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
- break;
- else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(dir_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
- break;
+ while ((next = strstr(full_path + next_pos, "/"))) {
+ next_pos = (next - full_path);
+ dir_path = g_strndup(full_path, next_pos);
+ next_pos++;
- leaf_path = strrchr(dir_path, '/');
- if (leaf_path != NULL) {
- int seek_len = leaf_path -dir_path;
- dir_path[seek_len] = '\0';
- } else {
- MS_DBG_ERR("Fail to find leaf path");
- ret = MS_MEDIA_ERR_INVALID_PATH;
+ ret = ms_check_scan_ignore(dir_path, uid);
+ g_free(dir_path);
+ if (ret != MS_MEDIA_ERR_NONE)
break;
- }
}
- MS_SAFE_FREE(dir_path);
- MS_SAFE_FREE(usr_path);
-
return ret;
}
-int ms_check_scan_ignore(char * path)
+int ms_check_scan_ignore(char * path, uid_t uid)
{
- int fd = -1;
- int exist = -1;
- const char *ignore_path = "/.scan_ignore";
- char *check_ignore_file = NULL;
int ret = MS_MEDIA_ERR_NONE;
+ const char *ignore_file = ".scan_ignore";
+ char *tmp_path = NULL;
+ char *org_path = NULL;
+ char ignore_path[MS_FILE_PATH_LEN_MAX] = {0, };
+
+#ifndef _USE_TVPD_MODE
+ char replace[MS_FILE_PATH_LEN_MAX] = {0, };
+ char *mediashared = NULL;
+#endif
+
+ /* Check for symbolic link */
+ tmp_path = realpath(path, NULL);
+ /* Get trimmed path */
+ org_path = g_canonicalize_filename(path, NULL);
- if (strstr(path, "/.")) {
- MS_DBG_ERR("hidden path");
- ret = MS_MEDIA_ERR_INVALID_PATH;
- goto ERROR;
+#ifdef _USE_TVPD_MODE
+ if (g_strcmp0(tmp_path, org_path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ g_free(org_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
+#else
+ if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) {
+ ms_user_get_mediashared_path(uid, &mediashared);
+ snprintf(replace, MS_FILE_PATH_LEN_MAX, "%s%s", mediashared, tmp_path + strlen(MEDIA_SHARE_PATH));
+ MS_SAFE_FREE(mediashared);
+ if (g_strcmp0(replace, org_path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ g_free(org_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ } else {
+ if (g_strcmp0(tmp_path, org_path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ g_free(org_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ }
+#endif
+ MS_SAFE_FREE(tmp_path);
+ g_free(org_path);
- fd = open(path, O_RDONLY | O_DIRECTORY);
- if (fd == -1) {
- MS_DBG_ERR("%s folder opendir fails", path);
- ret = MS_MEDIA_ERR_INVALID_PATH;
+ if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ snprintf(ignore_path, sizeof(ignore_path), "%s/%s", path, ignore_file);
+
+ if (g_file_test(ignore_path, G_FILE_TEST_EXISTS)) {
+ MS_DBG_WARN("scan ignore file exist [%s]", ignore_path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ } else {
+ MS_DBG_ERR("g_file_test fails[%s]", path);
+ ret = MS_MEDIA_ERR_INVALID_PARAMETER;
if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) {
MS_DBG_ERR("Fail to get USB path");
- goto ERROR;
+ return ret;
}
if (strstr(path, MEDIA_ROOT_PATH_USB) != NULL) {
- if (errno == ENOENT) {
- /*if the directory does not exist, check the device is unmounted*/
- if (!ms_storage_mount_status(path)) {
- MS_DBG_ERR("Device is unmounted[%s]", path);
- ret = MS_MEDIA_ERR_USB_UNMOUNTED;
- goto ERROR;
- }
- }
- }
-
- struct stat folder_st;
- if (stat(path, &folder_st) == 0) {
- MS_DBG_WARN("DEV[%ld] INODE[%lld] UID[%ld] GID[%ld] MODE[%lo] PATH[%s]", (long)folder_st.st_dev, (long long)folder_st.st_ino,
- (long)folder_st.st_uid, (long)folder_st.st_gid, (unsigned long) folder_st.st_mode, path);
- } else {
- MS_DBG_ERR("%s folder stat fails", path);
- }
-
- goto ERROR;
- } else {
- /* check the file exits actually */
- int path_len = 0;
-
- path_len = strlen(path) + strlen(ignore_path) + 1;
- check_ignore_file = malloc(path_len);
- if (check_ignore_file != NULL) {
- memset(check_ignore_file, 0x0, path_len);
- snprintf(check_ignore_file, path_len, "%s%s", path, ignore_path);
-
- exist = open(check_ignore_file, O_RDONLY);
- if (exist >= 0) {
- MS_DBG_WARN("scan_ignore exists [%s]", check_ignore_file);
- ret = MS_MEDIA_ERR_INVALID_PATH;
+ /*if the directory does not exist, check the device is unmounted*/
+ if (!ms_storage_mount_status(path)) {
+ MS_DBG_ERR("Device is unmounted[%s]", path);
+ return MS_MEDIA_ERR_USB_UNMOUNTED;
}
-
- MS_SAFE_FREE(check_ignore_file);
- } else {
- MS_DBG_ERR("malloc failed");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
}
}
-ERROR:
+ return ret;
+}
- if (fd != -1) {
- close(fd);
- fd = -1;
- }
+#ifdef _USE_TVPD_MODE
+typedef struct storage_result {
+ char *storage_path;
+ bool result;
+} storage_result_s;
- if (exist >= 0) close(exist);
+static void __ms_check_mount_status(usb_device_h usb_device, void *user_data)
+{
+ storage_result_s *data = (storage_result_s *)user_data;
+ char *mount_path = NULL;
- return ret;
+ mount_path = usb_device_get_mountpath(usb_device);
+ if (!mount_path)
+ return;
+
+ MS_DBG_SWARN("mount_path [%s]", mount_path);
+ data->result = (g_strcmp0(mount_path, data->storage_path) == 0);
}
+#endif
-bool ms_storage_mount_status(const char* start_path)
+bool ms_storage_mount_status(const char *start_path)
{
bool ret = false;
-#ifndef _USE_DEVICED_DBUS
- int count = 0;
- int err = 0;
- usb_device_list_h list;
- usb_device_h device;
- char *mount_path = NULL;
-
- char *storage_path = NULL;
+#ifdef _USE_TVPD_MODE
+ storage_result_s res = {0, };
char *remain_path = NULL;
int remain_len = 0;
- remain_path = strstr(start_path+strlen(MEDIA_ROOT_PATH_USB) +1, "/");
+ remain_path = strstr(start_path + strlen(MEDIA_ROOT_PATH_USB) + 1, "/");
if (remain_path != NULL)
remain_len = strlen(remain_path);
- storage_path = strndup(start_path, strlen(start_path) - remain_len);
-
- MS_DBG_WARN("storage_path [%s]", storage_path);
-
- err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
- if (err == 0) {
- count = usb_device_list_get_count(list);
- if (count > 0) {
- err = usb_device_list_get_first(list, &device);
- if (err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
- mount_path = usb_device_get_mountpath(device);
- if (mount_path != NULL) {
- MS_DBG_WARN("mount_path [%s]", mount_path);
- if (strlen(mount_path) == strlen(storage_path)) {
- if (strncmp(mount_path, storage_path, strlen(mount_path)) == 0) {
- MS_DBG_WARN("start path is mounted [%s]", start_path);
- ret = true;
- }
- }
- }
- }
+ res.storage_path = g_strndup(start_path, strlen(start_path) - remain_len);
- if (ret != true) {
- while (usb_device_list_get_next(list, &device) == 0) {
- if (device != NULL) {
- mount_path = usb_device_get_mountpath(device);
- if (mount_path != NULL) {
- MS_DBG_WARN("mount_path [%s]", mount_path);
- if (strlen(mount_path) == strlen(storage_path)) {
- if (strncmp(mount_path, storage_path, strlen(mount_path)) == 0) {
- MS_DBG_WARN("start path is mounted [%s]", start_path);
- ret = true;
- break;
- }
- }
- }
- }
- }
- }
- }
+ MS_DBG_SWARN("storage_path [%s]", res.storage_path);
- usb_device_free_device_list(list);
- } else {
- MS_DBG_ERR("usb_device_get_device_list falied [%d]", err);
- }
+ usb_mass_storage_foreach(__ms_check_mount_status, &res);
+ g_free(res.storage_path);
+ ret = res.result;
- MS_SAFE_FREE(storage_path);
+ if (ret)
+ MS_DBG_SWARN("start path is mounted [%s]", start_path);
#endif
return ret;
}
-int ms_set_db_status(ms_db_status_type_t status, ms_storage_type_t storage_type)
+int ms_set_db_status(ms_db_status_type_t status, ms_user_storage_type_e storage_type)
{
- int res = MS_MEDIA_ERR_NONE;
- int err = 0;
+ int ret = MS_MEDIA_ERR_NONE;
if (status == MS_DB_UPDATING) {
- if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATING)) {
- res = MS_MEDIA_ERR_VCONF_SET_FAIL;
- MS_DBG_ERR("ms_config_set_int failed");
- }
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATING))
+ goto ERROR;
- if (storage_type == MS_STORAGE_EXTERNAL) {
- if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADING)) {
- res = MS_MEDIA_ERR_VCONF_SET_FAIL;
- MS_DBG_ERR("ms_config_set_int failed");
- }
+ if (storage_type == MS_USER_STORAGE_EXTERNAL) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADING))
+ goto ERROR;
}
} else {
- if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
- res = MS_MEDIA_ERR_VCONF_SET_FAIL;
- MS_DBG_ERR("ms_config_set_int failed");
- }
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED))
+ goto ERROR;
- if (storage_type == MS_STORAGE_EXTERNAL) {
- if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADED)) {
- res = MS_MEDIA_ERR_VCONF_SET_FAIL;
- MS_DBG_ERR("ms_config_set_int failed");
- }
+ if (storage_type == MS_USER_STORAGE_EXTERNAL) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADED))
+ goto ERROR;
}
}
- err = ms_set_power_mode(status);
- if (err != MS_MEDIA_ERR_NONE) {
+ ret = ms_set_power_mode(status);
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_set_power_mode fail");
- res = err;
- }
- return res;
+ return ret;
+ERROR:
+ MS_DBG_ERR("ms_config_set_int failed");
+ return MS_MEDIA_ERR_INTERNAL;
}
int ms_set_power_mode(ms_db_status_type_t status)
switch (status) {
case MS_DB_UPDATING:
- err = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ err = device_power_request_lock(POWER_LOCK_CPU, 0);
if (err != 0)
res = MS_MEDIA_ERR_INTERNAL;
break;
case MS_DB_UPDATED:
- err = display_unlock_state(LCD_OFF, PM_RESET_TIMER);
+ err = device_power_release_lock(POWER_LOCK_CPU);
if (err != 0)
res = MS_MEDIA_ERR_INTERNAL;
break;
dir_path[len -1] = '\0';
}
-bool ms_check_folder_path(const char *folder_path)
-{
- DIR *dp = NULL;
-
- dp = opendir(folder_path);
- if (dp == NULL) {
- MS_DBG_ERR("Deleted folder path");
- return false;
- }
- closedir(dp);
-
- return true;
-}
-
-int ms_check_size_mediadb(uid_t uid, double *db_size)
+int ms_check_size_mediadb(uid_t uid, uint64_t *db_size)
{
int ret = MS_MEDIA_ERR_NONE;
char *db_path = NULL;
ret = ms_user_get_media_db_path(uid, &db_path);
if (stat(db_path, &buf) == 0) {
- *db_size = buf.st_size;
+ *db_size = (uint64_t)buf.st_size;
} else {
MS_DBG_STRERROR("stat failed");
ret = MS_MEDIA_ERR_INTERNAL;
}
- MS_SAFE_FREE(db_path);
+ g_free(db_path);
return ret;
}
-#ifdef _SET_VIP_PROCESS
+#ifdef _USE_TVPD_MODE
#define PROC_OOM_SCORE_ADJ_PATH "/proc/%d/oom_score_adj"
#define VIP_OOM_SCORE_ADJ (-1000)
#define PROC_NAME_MAX 1024
/* Get Pid */
pid = getpid();
if (ms_get_cmdline_from_proc(pid, process_name)) {
- MS_DBG_ERR("%s: Read process name failed pid[%d]\n", __func__, pid);
+ MS_DBG_ERR("%s: Read process name failed pid[%d]", __func__, pid);
return MS_MEDIA_ERR_INTERNAL;
}
appid = process_name;