#define MEDIA_DB_SPACE_LIMIT 20971520
#endif
-#define MEDIA_DEFAULT_UID 5001
-
#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
#define MS_STRING_VALID(str) (str && strlen(str) > 0)
int ms_sys_get_device_list(GSList **dev_list);
void ms_sys_unset_poweroff_cb(void);
-int ms_sys_get_uid(uid_t *uid);
+uid_t ms_sys_get_uid(void);
#endif
}
#endif /*_USE_TVPD_MODE*/
-int ms_sys_get_uid(uid_t *uid)
+
+#define MEDIA_DEFAULT_UID 5001
+uid_t ms_sys_get_uid(void)
{
uid_t *list = NULL;
- int users = -1;
- users = sd_get_uids(&list);
- if (users > 0) {
- *uid = list[0];
- MS_SAFE_FREE(list);
- } else {
- MS_DBG_ERR("No login user!.");
- MS_SAFE_FREE(list);
- return MS_MEDIA_ERR_INTERNAL;
+ uid_t result = 0;
+
+ if (sd_get_uids(&list) > 0) {
+ result = list[0];
+ free(list);
+ return result;
}
- return MS_MEDIA_ERR_NONE;
+
+ return MEDIA_DEFAULT_UID;
}
int ms_check_corrupt_mediadb(void)
{
sqlite3 *db_handle = NULL;
- uid_t uid = MEDIA_DEFAULT_UID;
-
- ms_sys_get_uid(&uid);
+ uid_t uid = ms_sys_get_uid();
if (media_db_connect(&db_handle, uid, false) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("Failed to connect DB");
char *storage_path = NULL;
sqlite3 *handle = NULL;
int validity = 0;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
- ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
if (mount_path != NULL && mount_uuid != NULL) {
void ms_storage_remove_handler(const char *mount_path, const char *mount_uuid)
{
sqlite3 *handle = NULL;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
if (mount_path != NULL && mount_uuid != NULL) {
- ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
ms_set_storage_validity(handle, mount_uuid, 0, uid);
ms_send_storage_otg_scan_request(mount_path, mount_uuid, MS_SCAN_INVALID, uid);
ms_disconnect_db(handle);
} else if (mount_path != NULL && g_strcmp0(mount_path, STORAGE_REMOVED) == 0) {
- ms_sys_get_uid(&uid);
ms_connect_db(&handle, uid);
ms_set_all_storage_validity(handle, 0, uid);
sqlite3 *handle = NULL;
int validity = 0;
ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
ms_connect_db(&handle, uid);
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
char device_id[MS_UUID_SIZE] = {0,};
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
if (!mount_path)
return;
{
char *mount_path = NULL;
bool is_reset = false;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
MS_DBG_WARN("usb_event_callback BEGIN[%s]", action);
if (!usb_device) {
mount_path = usb_device_get_mountpath(usb_device);
- ms_sys_get_uid(&uid);
-
if (!strcmp(action, "mounted")) {
MS_DBG_SWARN("USB MOUNTED, mountpath : %s", mount_path);
ms_check_mediadb(uid, &is_reset);
static bool __ms_deal_reset_status(void)
{
int value = 0;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
if (!ms_config_get_int(MS_VCONF_KEY_RESET_STATUS, &value)) {
MS_DBG_ERR("get db/media_server/reset_status failed");
{
int status = 0;
int scanner_pid = 0;
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
if (!power_off) {
if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status))
return -1;
}
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
uint64_t db_size = 0;
uint64_t free_space = 0;
{
int ret = MS_MEDIA_ERR_NONE;
#ifdef _USE_TVPD_MODE
- uid_t uid = MEDIA_DEFAULT_UID;
+ uid_t uid = ms_sys_get_uid();
sqlite3 *db_handle = NULL;
- ms_sys_get_uid(&uid);
-
ret = ms_connect_db(&db_handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db failed [%d]", ret);
/* auto scan tv interal storage */
char *internal_path = NULL;
- ms_sys_get_uid(&uid);
ms_user_get_internal_root_path(uid, &internal_path);
ms_send_storage_scan_request(internal_path, INTERNAL_STORAGE_ID, MS_SCAN_PART, uid);
g_free(internal_path);