4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 #include <sys/types.h>
30 #include <dbus/dbus-glib.h>
31 #include <dbus/dbus.h>
32 #include <dbus/dbus-glib-lowlevel.h>
33 #include <sys/statvfs.h>
35 #ifdef _SET_VIP_PROCESS
36 #include <sys/prctl.h>
38 #include <system_info.h>
39 #include <dd-display.h>
41 #ifndef _USE_DEVICED_DBUS
42 #include <usb-device.h>
45 #include "media-util.h"
46 #include "media-server-ipc.h"
47 #include "media-common-dbg.h"
48 #include "media-common-system.h"
49 #include "media-common-utils.h"
51 #define MS_DRM_CONTENT_TYPE_LENGTH 100
53 /* it's for 32bit file offset */
55 unsigned long int f_bsize;
56 unsigned long int f_frsize;
57 unsigned long int f_blocks;
58 unsigned long int f_bfree;
59 unsigned long int f_bavail;
60 unsigned long int f_files;
61 unsigned long int f_ffree;
62 unsigned long int f_favail;
63 unsigned long int f_fsid;
64 #ifdef _STATVFSBUF_F_UNUSED
67 unsigned long int f_flag;
68 unsigned long int f_namemax;
72 bool ms_is_mmc_inserted(void)
75 ms_stg_type_e stg_type = MS_STG_TYPE_MMC;
76 GArray *dev_list = NULL;
78 ret = ms_sys_get_device_list(stg_type, &dev_list);
79 if (ret == MS_MEDIA_ERR_NONE) {
80 if (dev_list != NULL) {
81 MS_DBG_ERR("MMC FOUND[%d]", dev_list->len);
82 ms_sys_release_device_list(&dev_list);
85 MS_DBG_ERR("MMC NOT FOUND");
88 MS_DBG_ERR("ms_sys_get_device_list failed");
94 static char* __media_get_path(uid_t uid)
96 char *result_passwd = NULL;
97 struct group *grpinfo = NULL;
99 if (uid == getuid()) {
100 grpinfo = getgrnam("users");
101 if (grpinfo == NULL) {
102 MS_DBG_ERR("getgrnam(users) returns NULL !");
105 if (MS_STRING_VALID(MEDIA_ROOT_PATH_INTERNAL))
106 result_passwd = strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL));
108 struct passwd *userinfo = getpwuid(uid);
109 if (userinfo == NULL) {
110 MS_DBG_ERR("getpwuid(%d) returns NULL !", uid);
113 grpinfo = getgrnam("users");
114 if (grpinfo == NULL) {
115 MS_DBG_ERR("getgrnam(users) returns NULL !");
118 // Compare git_t type and not group name
119 if (grpinfo->gr_gid != userinfo->pw_gid) {
120 MS_DBG_ERR("UID [%d] does not belong to 'users' group!", uid);
123 result_passwd = strndup(userinfo->pw_dir, strlen(userinfo->pw_dir));
126 return result_passwd;
129 ms_storage_type_t ms_get_storage_type_by_full(const char *path, uid_t uid)
132 int ret = MS_MEDIA_ERR_NONE;
133 char * user_path = NULL;
136 return MS_MEDIA_ERR_INVALID_PATH;
138 #ifdef _USE_SENIOR_MODE
139 if(ms_is_support_senior_mode()) {
140 if (strncmp(path, MEDIA_ROOT_PATH_SENIOR_MODE, strlen(MEDIA_ROOT_PATH_SENIOR_MODE)) == 0) {
141 return MS_STORAGE_EXTERNAL;
146 user_path = __media_get_path(uid);
147 if (user_path == NULL)
148 return MS_MEDIA_ERR_OUT_OF_MEMORY;
150 length_path = strlen(user_path);
152 if (strncmp(path, user_path, length_path) == 0) {
153 ret = MS_STORAGE_INTERNAL;
154 } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0)) {
155 ret = MS_STORAGE_EXTERNAL;
156 } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
157 ret = MS_STORAGE_EXTERNAL_USB;
159 MS_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
160 ret = MS_MEDIA_ERR_INVALID_PATH;
163 MS_SAFE_FREE(user_path);
168 int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2)
171 int real_size = size - 1;
173 if (!res || !pattern || !str1 || !str2)
174 return MS_MEDIA_ERR_INVALID_PARAMETER;
176 if (real_size < (int)(strlen(str1) + strlen(str2)))
177 return MS_MEDIA_ERR_INVALID_PARAMETER;
179 len = snprintf(res, real_size, pattern, str1, str2);
181 return MS_MEDIA_ERR_INVALID_PARAMETER;
186 return MS_MEDIA_ERR_NONE;
189 int ms_strcopy(char *res, const int size, const char *pattern, const char *str1)
192 int real_size = size;
194 if (!res || !pattern || !str1) {
195 MS_DBG_ERR("parameta is invalid");
196 return MS_MEDIA_ERR_INVALID_PARAMETER;
199 if (real_size < (int)(strlen(str1))) {
200 MS_DBG_ERR("size is wrong");
201 return MS_MEDIA_ERR_INVALID_PARAMETER;
204 len = snprintf(res, real_size, pattern, str1);
206 MS_DBG_ERR("snprintf failed");
207 return MS_MEDIA_ERR_INVALID_PARAMETER;
212 return MS_MEDIA_ERR_NONE;
215 bool ms_config_get_int(const char *key, int *value)
219 if (!key || !value) {
220 MS_DBG_ERR("Arguments key or value is NULL");
224 err = vconf_get_int(key, value);
230 MS_DBG_ERR("Unexpected error code: %d", err);
235 bool ms_config_set_int(const char *key, int value)
240 MS_DBG_ERR("Arguments key is NULL");
244 err = vconf_set_int(key, value);
250 MS_DBG_ERR("Unexpected error code: %d", err);
255 bool ms_config_get_str(const char *key, char **value)
259 if (key == NULL || value == NULL) {
260 MS_DBG_ERR("Arguments key or value is NULL");
264 res = vconf_get_str(key);
265 if (MS_STRING_VALID(res)) {
266 *value = strdup(res);
274 bool ms_config_set_str(const char *key, const char *value)
278 if (!key || !value) {
279 MS_DBG_ERR("Arguments key or value is NULL");
283 err = vconf_set_str(key, value);
287 MS_DBG_ERR("fail to vconf_set_str %d", err);
292 bool ms_config_get_bool(const char *key, int *value)
296 if (!key || !value) {
297 MS_DBG_ERR("Arguments key or value is NULL");
301 err = vconf_get_bool(key, value);
307 MS_DBG_ERR("Unexpected error code: %d", err);
312 static int get_memory_size(const char *path, struct statvfs_32 *buf)
317 ret = statvfs(path, &s);
319 MS_DBG_ERR("statvfs failed[%d]", ret);
321 return MS_MEDIA_ERR_INTERNAL;
324 buf->f_bsize = s.f_bsize;
325 buf->f_frsize = s.f_frsize;
326 buf->f_blocks = (unsigned long)s.f_blocks;
327 buf->f_bfree = (unsigned long)s.f_bfree;
328 buf->f_bavail = (unsigned long)s.f_bavail;
329 buf->f_files = (unsigned long)s.f_files;
330 buf->f_ffree = (unsigned long)s.f_ffree;
331 buf->f_favail = (unsigned long)s.f_favail;
332 buf->f_fsid = s.f_fsid;
333 buf->f_flag = s.f_flag;
334 buf->f_namemax = s.f_namemax;
336 return MS_MEDIA_ERR_NONE;
339 int ms_get_remain_space(double *free_space)
341 int ret = MS_MEDIA_ERR_NONE;
342 struct statvfs_32 temp;
344 ret = get_memory_size("/opt", &temp);
345 if (ret != MS_MEDIA_ERR_NONE) {
346 MS_DBG_ERR("fail to get memory size");
350 // MS_DBG_ERR("Total mem : %lf, Avail mem : %lf", (double)temp.f_frsize*temp.f_blocks, (double)temp.f_bsize*temp.f_bavail);
352 *free_space = (double)temp.f_bsize*temp.f_bavail;
357 #ifdef _USE_RECORDED_CONTENT
358 bool ms_is_support_pvr(void)
362 if (system_info_get_value_int(SYSTEM_INFO_KEY_PVR_SUPPORTED, &nSupportPVR) != SYSTEM_INFO_ERROR_NONE) {
363 MS_DBG_ERR("Get PVR Support failed");
367 MS_DBG("PVR Support : [%d]", nSupportPVR);
369 return (nSupportPVR != 0);
373 #ifdef _USE_SENIOR_MODE
374 bool ms_is_support_senior_mode()
376 bool bSupportSeniorMode = false;
378 if(system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
379 MS_DBG_ERR("Get senior mode support failed");
383 MS_DBG("Senior mode support : [%d]", bSupportSeniorMode);
385 return bSupportSeniorMode;
389 int ms_check_file_path(const char *file_path, uid_t uid)
394 /* check location of file */
395 /* file must exists under "/opt/usr/media" or "/opt/storage/sdcard" */
396 if (!ms_is_valid_path(file_path, uid)) {
397 MS_DBG_ERR("Invalid path : %s", file_path);
398 return MS_MEDIA_ERR_INVALID_PATH;
401 /* check the file exits actually */
402 exist = open(file_path, O_RDONLY);
404 MS_DBG_ERR("[%s]open files");
405 return MS_MEDIA_ERR_INVALID_PATH;
409 /* check type of the path */
410 /* It must be a regular file */
411 memset(&file_st, 0, sizeof(struct stat));
412 if (stat(file_path, &file_st) == 0) {
413 if (!S_ISREG(file_st.st_mode)) {
414 /* In this case, it is not a regula file */
415 MS_DBG_ERR("this path is not a file");
416 return MS_MEDIA_ERR_INVALID_PATH;
419 MS_DBG_STRERROR("stat failed");
420 return MS_MEDIA_ERR_INVALID_PATH;
423 return MS_MEDIA_ERR_NONE;
426 int ms_check_ignore_dir(const char *full_path, uid_t uid)
428 int ret = MS_MEDIA_ERR_NONE;
429 char *dir_path = NULL;
430 char *leaf_path = NULL;
431 char *usr_path = NULL;
433 ret = ms_check_file_path(full_path, uid);
434 if (ret != MS_MEDIA_ERR_NONE) {
435 MS_DBG_ERR("invalid path : %s", full_path);
436 return MS_MEDIA_ERR_INVALID_PATH;
439 dir_path = g_path_get_dirname(full_path);
440 if (dir_path == NULL || strcmp(dir_path, ".") == 0) {
441 MS_DBG_ERR("getting directory path is failed : %s", full_path);
442 MS_SAFE_FREE(dir_path);
443 return MS_MEDIA_ERR_INVALID_PATH;
446 usr_path = ms_get_path(uid);
447 if (usr_path == NULL) {
448 MS_DBG_ERR("ms_get_path() fail");
449 MS_SAFE_FREE(dir_path);
450 return MS_MEDIA_ERR_INTERNAL;
454 if (ms_check_scan_ignore(dir_path) != MS_MEDIA_ERR_NONE) {
455 ret = MS_MEDIA_ERR_INVALID_PATH;
459 #ifdef _USE_SENIOR_MODE
460 if(ms_is_support_senior_mode()) {
461 if(strcmp(dir_path, MEDIA_ROOT_PATH_SENIOR_MODE) == 0)
465 if (strcmp(dir_path, usr_path) == 0)
467 else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(dir_path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0))
469 else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(dir_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
472 leaf_path = strrchr(dir_path, '/');
473 if (leaf_path != NULL) {
474 int seek_len = leaf_path -dir_path;
475 dir_path[seek_len] = '\0';
477 MS_DBG_ERR("Fail to find leaf path");
478 ret = MS_MEDIA_ERR_INVALID_PATH;
483 MS_SAFE_FREE(dir_path);
484 MS_SAFE_FREE(usr_path);
489 int ms_check_scan_ignore(char * path)
493 const char *ignore_path = "/.scan_ignore";
494 char *check_ignore_file = NULL;
495 int ret = MS_MEDIA_ERR_NONE;
497 if (strstr(path, "/.")) {
498 MS_DBG_ERR("hidden path");
499 ret = MS_MEDIA_ERR_INVALID_PATH;
503 fd = open(path, O_RDONLY | O_DIRECTORY);
505 MS_DBG_ERR("%s folder opendir fails", path);
506 ret = MS_MEDIA_ERR_INVALID_PATH;
508 if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) {
509 MS_DBG_ERR("Fail to get USB path");
513 if (strstr(path, MEDIA_ROOT_PATH_USB) != NULL) {
514 if (errno == ENOENT) {
515 /*if the directory does not exist, check the device is unmounted*/
516 if (!ms_storage_mount_status(path)) {
517 MS_DBG_ERR("Device is unmounted[%s]", path);
518 ret = MS_MEDIA_ERR_USB_UNMOUNTED;
524 struct stat folder_st;
525 if (stat(path, &folder_st) == 0) {
526 MS_DBG_ERR("DEV[%ld] INODE[%lld] UID[%ld] GID[%ld] MODE[%lo] PATH[%s]", (long)folder_st.st_dev, (long long)folder_st.st_ino,
527 (long)folder_st.st_uid, (long)folder_st.st_gid, (unsigned long) folder_st.st_mode, path);
529 MS_DBG_ERR("%s folder stat fails", path);
534 /* check the file exits actually */
537 path_len = strlen(path) + strlen(ignore_path) + 1;
538 check_ignore_file = malloc(path_len);
539 if (check_ignore_file != NULL) {
540 memset(check_ignore_file, 0x0, path_len);
541 snprintf(check_ignore_file, path_len, "%s%s", path, ignore_path);
543 exist = open(check_ignore_file, O_RDONLY);
545 MS_DBG_ERR("scan_ignore exists [%s]", check_ignore_file);
546 ret = MS_MEDIA_ERR_INVALID_PATH;
549 MS_SAFE_FREE(check_ignore_file);
551 MS_DBG_ERR("malloc failed");
552 ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
563 if (exist >= 0) close(exist);
568 char* ms_get_path(uid_t uid)
571 char *result_passwd = NULL;
572 struct group *grpinfo = NULL;
573 if (uid == getuid()) {
574 grpinfo = getgrnam("users");
575 if (grpinfo == NULL) {
576 MS_DBG_ERR("getgrnam(users) returns NULL !");
579 if (MS_STRING_VALID(MEDIA_ROOT_PATH_INTERNAL))
580 result_passwd = strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL));
582 char passwd_str[MAX_FILEPATH_LEN] = {0, };
583 struct passwd *userinfo = getpwuid(uid);
584 if (userinfo == NULL) {
585 MS_DBG_ERR("getpwuid(%d) returns NULL !", uid);
588 grpinfo = getgrnam("users");
589 if (grpinfo == NULL) {
590 MS_DBG_ERR("getgrnam(users) returns NULL !");
593 // Compare git_t type and not group name
594 if (grpinfo->gr_gid != userinfo->pw_gid) {
595 MS_DBG_ERR("UID [%d] does not belong to 'users' group!", uid);
599 len = snprintf(passwd_str, sizeof(passwd_str), "%s/%s", userinfo->pw_dir, MEDIA_CONTENT_PATH);
601 result_passwd = strndup(passwd_str, len);
604 return result_passwd;
607 bool ms_storage_mount_status(const char* start_path)
610 #ifndef _USE_DEVICED_DBUS
613 usb_device_list_h list;
615 char *mount_path = NULL;
617 char *storage_path = NULL;
618 char *remain_path = NULL;
621 remain_path = strstr(start_path+strlen(MEDIA_ROOT_PATH_USB) +1, "/");
622 if (remain_path != NULL)
623 remain_len = strlen(remain_path);
625 storage_path = strndup(start_path, strlen(start_path) - remain_len);
627 MS_DBG_ERR("storage_path [%s]", storage_path);
629 err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
631 count = usb_device_list_get_count(list);
633 err = usb_device_list_get_first(list, &device);
634 if(err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
635 mount_path = usb_device_get_mountpath(device);
636 if (mount_path != NULL) {
637 MS_DBG_ERR("mount_path [%s]", mount_path);
638 if (strlen(mount_path) == strlen(storage_path)) {
639 if (strncmp(mount_path, storage_path, strlen(mount_path)) == 0) {
640 MS_DBG_ERR("start path is mounted [%s]", start_path);
648 while(usb_device_list_get_next(list, &device) == 0) {
650 mount_path = usb_device_get_mountpath(device);
651 if (mount_path != NULL) {
652 MS_DBG_ERR("mount_path [%s]", mount_path);
653 if (strlen(mount_path) == strlen(storage_path)) {
654 if (strncmp(mount_path, storage_path, strlen(mount_path)) == 0) {
655 MS_DBG_ERR("start path is mounted [%s]", start_path);
666 usb_device_free_device_list(list);
668 MS_DBG_ERR("usb_device_get_device_list falied [%d]", err);
671 MS_SAFE_FREE(storage_path);
676 bool ms_is_valid_path(const char *path, uid_t uid)
679 char *usr_path = NULL;
684 usr_path = ms_get_path(uid);
685 if (usr_path == NULL)
688 #ifdef _USE_SENIOR_MODE
689 if(ms_is_support_senior_mode()) {
690 if (strncmp(path, MEDIA_ROOT_PATH_SENIOR_MODE, strlen(MEDIA_ROOT_PATH_SENIOR_MODE)) == 0)
695 if (strncmp(path, usr_path, strlen(usr_path)) == 0)
697 else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0))
699 else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
704 MS_SAFE_FREE(usr_path);
709 int ms_set_db_status(ms_db_status_type_t status, ms_storage_type_t storage_type)
711 int res = MS_MEDIA_ERR_NONE;
714 if (status == MS_DB_UPDATING) {
715 if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATING)) {
716 res = MS_MEDIA_ERR_VCONF_SET_FAIL;
717 MS_DBG_ERR("ms_config_set_int failed");
720 if (storage_type == MS_STORAGE_EXTERNAL) {
721 if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADING)) {
722 res = MS_MEDIA_ERR_VCONF_SET_FAIL;
723 MS_DBG_ERR("ms_config_set_int failed");
727 if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
728 res = MS_MEDIA_ERR_VCONF_SET_FAIL;
729 MS_DBG_ERR("ms_config_set_int failed");
732 if (storage_type == MS_STORAGE_EXTERNAL) {
733 if (!ms_config_set_int(VCONFKEY_FILEMANAGER_MMC_STATUS, VCONFKEY_FILEMANAGER_MMC_LOADED)) {
734 res = MS_MEDIA_ERR_VCONF_SET_FAIL;
735 MS_DBG_ERR("ms_config_set_int failed");
740 err = ms_set_power_mode(status);
741 if (err != MS_MEDIA_ERR_NONE) {
742 MS_DBG_ERR("ms_set_power_mode fail");
749 int ms_set_power_mode(ms_db_status_type_t status)
751 int res = MS_MEDIA_ERR_NONE;
756 err = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
758 res = MS_MEDIA_ERR_INTERNAL;
761 err = display_unlock_state(LCD_OFF, PM_RESET_TIMER);
763 res = MS_MEDIA_ERR_INTERNAL;
766 MS_DBG_ERR("Unacceptable type : %d", status);
773 void ms_trim_dir_path(char *dir_path)
775 /* need implementation */
776 /* if dir_path is not NULL terminated, this function will occure crash */
777 int len = strlen(dir_path);
779 if (dir_path[len -1] == '/')
780 dir_path[len -1] = '\0';
783 bool ms_check_folder_path(const char *folder_path)
787 dp = opendir(folder_path);
789 MS_DBG_ERR("Deleted folder path");
797 int ms_check_size_mediadb(uid_t uid, double *db_size)
799 int ret = MS_MEDIA_ERR_NONE;
800 char *db_path = NULL;
803 ret = media_db_get_media_db_path(uid, &db_path);
805 if(stat(db_path, &buf) == 0) {
806 *db_size = buf.st_size;
808 MS_DBG_STRERROR("stat failed");
809 ret = MS_MEDIA_ERR_INTERNAL;
812 MS_SAFE_FREE(db_path);
817 #ifdef _SET_VIP_PROCESS
818 #define PROC_OOM_SCORE_ADJ_PATH "/proc/%d/oom_score_adj"
819 #define VIP_OOM_SCORE_ADJ (-1000)
820 #define PROC_NAME_MAX 1024
821 #define PROC_BUF_MAX 64
823 static int ms_get_cmdline_from_proc(pid_t pid, char *cmdline)
825 char buf[PROC_BUF_MAX];
826 char cmdline_buf[PROC_NAME_MAX];
830 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
831 fp = fopen(buf, "r");
833 return MS_MEDIA_ERR_INTERNAL;
835 if (fgets(cmdline_buf, PROC_NAME_MAX-1, fp) == NULL) {
837 return MS_MEDIA_ERR_INTERNAL;
841 filename = strrchr(cmdline_buf, '/');
842 if (filename == NULL)
843 filename = cmdline_buf;
845 filename = filename + 1;
847 strncpy(cmdline, filename, PROC_NAME_MAX-1);
849 return MS_MEDIA_ERR_NONE;
852 int ms_set_vip_process(void)
856 static pid_t pid = 0;
857 static char process_name[PROC_NAME_MAX] = {0};
858 static char *appid = NULL;
862 if (ms_get_cmdline_from_proc(pid, process_name)) {
863 MS_DBG_ERR("%s: Read process name failed pid[%d]\n", __func__, pid);
864 return MS_MEDIA_ERR_INTERNAL;
866 appid = process_name;
868 MS_DBG("Process name[%s]:Pid[%d]", appid, pid);
870 if (prctl(PR_GET_DUMPABLE) == 0)
871 prctl(PR_SET_DUMPABLE, 1);
873 snprintf(buf, sizeof(buf), PROC_OOM_SCORE_ADJ_PATH, pid);
874 id = open(buf, O_WRONLY, 0777);
876 MS_DBG_ERR("fopen %s failed errno:%d", buf, errno);
877 return MS_MEDIA_ERR_INTERNAL;
879 snprintf(buf, sizeof(buf), "%d", VIP_OOM_SCORE_ADJ);
880 if (write(id, buf, strlen(buf)) < 0) {
881 MS_DBG_ERR("write() failed errno=%d", errno);
883 return MS_MEDIA_ERR_INTERNAL;
886 return MS_MEDIA_ERR_NONE;