From 38b639710e9e2496cade16c19f5a70e407bd757a Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sat, 16 Mar 2013 01:12:12 +0900 Subject: [PATCH] merge with master --- packaging/capi-system-info.spec | 2 +- src/system_info.c | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packaging/capi-system-info.spec b/packaging/capi-system-info.spec index 9682d1f..705b36f 100644 --- a/packaging/capi-system-info.spec +++ b/packaging/capi-system-info.spec @@ -1,7 +1,7 @@ #sbs-git:slp/api/system-info capi-system-info 0.1.0 63d15bafa590ee9de869c8a8ade712e06828e5c3 Name: capi-system-info Summary: A System Information library in SLP C API -Version: 0.1.7 +Version: 0.1.8 Release: 0 Group: System/Libraries License: Apache License, Version 2.0 and IEFT RFC Collection diff --git a/src/system_info.c b/src/system_info.c index 36c7f86..b32f61a 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -24,6 +24,7 @@ #include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -427,30 +428,23 @@ system_info_mode_type_e system_info_get_system_info_model_type() int system_info_init(void) { - FILE *fp; - char str[MAXBUFSIZE]; + struct utsname device_name; extern char *strcasestr(const char *s, const char *find); - fp = popen("uname -m", "r"); - if (NULL == fp) { - LOGE("cannot execute uname command!!!"); + int error = uname(&device_name); + + if (error != 0) { + LOGE("uname returns error!!!"); return SYSTEM_INFO_ERROR_IO_ERROR; } else { - while (fgets(str, MAXBUFSIZE, fp)) { - if (strcasestr(str, "emulated")) { + if (strcasestr(device_name.machine, "emulated")) system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_EMULATOR; - system_info_set_system_info_initialized(1); - pclose(fp); - return SYSTEM_INFO_ERROR_NONE; - - } - } - + else system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_TARGET; + system_info_set_system_info_initialized(1); - pclose(fp); - return SYSTEM_INFO_ERROR_NONE; } + return SYSTEM_INFO_ERROR_NONE; } static int system_info_get(system_info_key_e key, system_info_h *system_info) -- 2.7.4