"bin_path" is stored in global variale.
"get_log_redirection_path()" provide *real* redirection path
that is aquired by system runtime information.
(In Windows, it works on WINVER > 0x600 - vista or newer - only.
Otherwise, it still provide assembled log path using legacy method.)
Change-Id: I24e04d3238a6a6727b025f51250d8646674b9662
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
#include <windows.h>
extern bool hax_allowed;
#elif defined(CONFIG_DARWIN)
+#include <fcntl.h>
extern bool hax_allowed;
#endif
char log_path[PATH_MAX] = { 0, };
#endif
-const char *get_bin_path(void)
-{
- const char *bin_path = get_variable(KEYWORD_BIN_PATH);
- // guarantee bin_path is not NULL
- if (!bin_path) {
- bin_path = "";
- }
- return bin_path;
-}
-
-const char *get_log_path(void)
-{
-#ifdef SUPPORT_LEGACY_ARGS
- if (log_path[0]) {
- return log_path;
- }
-#endif
- const char *log_path = get_variable("log_path");
-
- // if "log_path" is not exist, make it first.
- if (!log_path) {
- char *vms_path = get_variable("vms_path");
- char *vm_name = get_variable("vm_name");
- if (!vms_path || !vm_name) {
- // we can not specify log path.
- // emulator may not be launched from emulator-manager.
- log_path = "";
- }
- else {
- log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name);
- }
-
- set_variable("log_path", log_path, false);
- }
-
- return log_path;
-}
-
/* sdl bits per pixel */
void set_emul_sdl_bpp(int bpp)
{
return _emul_info.sdl_bpp;
}
-bool is_netclient_tap_attached(void)
-{
- NetClientState *ncs[MAX_QUEUE_NUM];
- int queues, i;
-
- queues = qemu_find_net_clients_except(NULL, ncs,
- NET_CLIENT_OPTIONS_KIND_NIC,
- MAX_QUEUE_NUM);
- for (i = 0; i < queues; ++i) {
- if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_TAP &&
- (ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC ||
- // for legacy -net option.
- ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT)) {
- return true;
- }
- }
-
- return false;
-}
-
void set_emul_guest_ip(char *ip)
{
strncpy(_emul_info.guest_ip, ip, strlen(ip));
//
// launch_conf_path
+// only set by emulator.c when start up
const char *launch_conf_file = NULL;
+// bin path
+// only set by osutil-{OS}.c when start up
+const char *bin_path = "";
+
+const char *get_bin_path(void)
+{
+ return bin_path;
+}
+
+// log path
+static const char *log_redirect_path;
+
+#ifdef CONFIG_WIN32
+// for Windows version
+extern OSVERSIONINFO osvi;
+#endif
+
+const char *get_log_redirect_path(void)
+{
+#ifdef SUPPORT_LEGACY_ARGS
+ if (log_path[0]) {
+ return log_path;
+ }
+#endif
+ int result = -1;
+ char log_filename[PATH_MAX];
+
+ // should we compare stdout(fd/1) and stderr(fd/2) ??
+#if defined(CONFIG_LINUX)
+ result = readlink("/proc/self/fd/1", log_filename, PATH_MAX);
+#elif defined(CONFIG_DARWIN)
+ result = fcntl(STDOUT_FILENO, F_GETPATH, log_filename);
+#elif defined(CONFIG_WIN32)
+# if WINVER >= 0x600
+ // works only vista or newer...
+ if (osvi.dwMajorVersion >= 6) {
+ char win32_log_filename_normalized[PATH_MAX];
+ HANDLE handle_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD ret = GetFinalPathNameByHandle(handle_stdout,
+ win32_log_filename_normalized,
+ PATH_MAX, FILE_NAME_NORMALIZED);
+ // strip "\\?\"
+ if (ret > 0) {
+ g_stpcpy(log_filename, win32_log_filename_normalized + 4);
+ result = 0;
+ } else {
+ result = -1;
+ }
+ }
+# endif
+#endif
+ if (result >= 0) {
+ log_redirect_path = g_path_get_dirname(log_filename);
+ } else {
+ // fail safe
+ LOG_WARNING("Can not identify log redirection path, "
+ "We should assume it !!!\n");
+
+ char *vms_path = get_variable("vms_path");
+ char *vm_name = get_variable("vm_name");
+ if (!vms_path || !vm_name) {
+ // we can not specify log path.
+ // emulator may not be launched from emulator-manager.
+ log_redirect_path = "";
+ }
+ else {
+ log_redirect_path = g_strdup_printf("%s/%s/logs",
+ vms_path, vm_name);
+ }
+ }
+
+ return log_redirect_path;
+}
+
+
// drive image file
static const char *drive_image_file = NULL;
return is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN);
}
+// tap attached
+bool is_netclient_tap_attached(void)
+{
+ NetClientState *ncs[MAX_QUEUE_NUM];
+ int queues, i;
+
+ queues = qemu_find_net_clients_except(NULL, ncs,
+ NET_CLIENT_OPTIONS_KIND_NIC,
+ MAX_QUEUE_NUM);
+ for (i = 0; i < queues; ++i) {
+ if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_TAP &&
+ (ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC ||
+ // for legacy -net option.
+ ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
// vm_data_path
static const char *vm_data_path = NULL;
}
// display resolution
+// only set by vl.c when start up
int initial_resolution_width = -1;
int initial_resolution_height = -1;
#endif
char const *get_bin_path(void);
-char const *get_log_path(void);
+char const *get_log_redirect_path(void);
/* setter */
void set_emul_win_scale(double scale);
bool get_emuld_connection(void);
bool get_sdb_connection(void);
-bool is_netclient_tap_attached(void);
int get_max_touch_point(void);
/* multi-touch */
// cleaned-up
extern const char *launch_conf_file;
+extern const char *bin_path;
+extern int initial_resolution_width;
+extern int initial_resolution_height;
const char *get_drive_image_file(void);
const char *get_http_proxy_addr(void);
const char *get_vm_name(void);
const char *get_profile_name(void);
-const char* get_host_directory_sharing_path(void);
const char *get_vm_data_path(void);
+const char* get_host_directory_sharing_path(void);
bool is_gpu_accel_enabled(void);
bool is_pci_device_enabled(int device_id);
bool is_mouse_enabled(void);
bool is_touchscreen_enabled(void);
+bool is_netclient_tap_attached(void);
uint64_t get_ram_size(void);
#include "config-host.h"
+#ifdef CONFIG_DARWIN
+#include "sys/syslimits.h"
+#endif
+
#if !defined(PATH_MAX)
#if defined(MAX_PATH)
#define PATH_MAX MAX_PATH
#define SUPPORT_SKIN_OPTIONS
#endif
-#define KEYWORD_BIN_PATH "_BIN_PATH_"
-
void set_variable(const char * const arg1, const char * const arg2, bool override);
char *get_variable(const char * const name);
void reset_variables(void);
/* collect log path information */
#define LOGPATH_TEXT "log_path="
- const char* log_path = get_log_path();
+ const char* log_path = get_log_redirect_path();
int log_path_len = strlen(LOGPATH_TEXT) + strlen(log_path) + delimiter_len;
total_len += (log_path_len + 1);
}
insertTableRow(vmInfoTable, QString(DETAILED_INFO_LOG_PATH),
- QString(get_log_path()), QString(get_log_path()));
+ QString(get_log_redirect_path()), QString(get_log_redirect_path()));
#if 0
insertTableRow(vmInfoTable, DETAILED_INFO_TELNET_PORT,
void set_bin_path_os(char const *const exec_argv)
{
char *file_name = NULL;
- char bin_path[PATH_MAX] = { 0, };
+ char bin_path_os[PATH_MAX] = { 0, };
if (!exec_argv) {
return;
return;
}
- g_strlcpy(bin_path, data, strlen(data) - strlen(file_name) + 1);
- g_strlcat(bin_path, "/", PATH_MAX);
-
- set_variable(KEYWORD_BIN_PATH, bin_path, true);
+ g_strlcpy(bin_path_os, data, strlen(data) - strlen(file_name) + 1);
+ g_strlcat(bin_path_os, "/", PATH_MAX);
free(data);
+
+ bin_path = g_strdup(bin_path_os);
}
int get_number_of_processors(void)
void set_bin_path_os(char const *const exec_argv)
{
char link_path[PATH_MAX] = { 0, };
- char bin_path[PATH_MAX] = { 0, };
+ char bin_path_os[PATH_MAX] = { 0, };
char *file_name = NULL;
ssize_t len = readlink("/proc/self/exe", link_path, sizeof(link_path) - 1);
link_path[len] = '\0';
file_name = g_strrstr(link_path, "/");
- g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
+ g_strlcpy(bin_path_os, link_path, strlen(link_path) - strlen(file_name) + 1);
- g_strlcat(bin_path, "/", PATH_MAX);
+ g_strlcat(bin_path_os, "/", PATH_MAX);
- set_variable(KEYWORD_BIN_PATH, bin_path, true);
+ bin_path = g_strdup(bin_path_os);
}
int get_number_of_processors(void)
void set_bin_path_os(char const *const exec_argv)
{
char link_path[PATH_MAX] = { 0, };
- char bin_path[PATH_MAX] = { 0, };
+ char bin_path_os[PATH_MAX] = { 0, };
char *file_name = NULL;
if (!GetModuleFileName(NULL, link_path, PATH_MAX)) {
}
file_name = g_strrstr(link_path, "\\");
- g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
- g_strlcat(bin_path, "\\", PATH_MAX);
+ g_strlcpy(bin_path_os, link_path, strlen(link_path) - strlen(file_name) + 1);
+ g_strlcat(bin_path_os, "\\", PATH_MAX);
- set_variable(KEYWORD_BIN_PATH, bin_path, true);
+ bin_path = g_strdup(bin_path_os);
}
int get_number_of_processors(void)
return num_processors;
}
+// FIXME
+OSVERSIONINFO osvi;
+
void print_system_info_os(void)
{
INFO("* Windows\n");
INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING);
/* Retrieves information about the current os */
- OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);