#include <pthread.h>
#include <fcntl.h>
#include <vconf.h>
+#include <stdlib.h>
#include <semaphore.h>
} \
} while (0)
+static void unlink_if_symbolic_link(const char *path)
+{
+ int ret = 0;
+ char *resolved_path = NULL;
+
+ if (path == NULL)
+ return;
+
+ /* return if it does not exist */
+ if ((ret = access(path, F_OK)))
+ return;
+
+ if ((resolved_path = realpath(path, NULL))) {
+ /* assume that the path paramether is an absolute path */
+ if (strcmp(path, resolved_path)) {
+ debug_warning("unexpected symbolic link!, unlink the symbolic link(%s) to the resolved path(%s)", path, resolved_path);
+ unlink(path);
+ }
+ free(resolved_path);
+ } else {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ debug_warning("failed to realpath() for path:%s, err:%s", path, str_error);
+ }
+}
+
EXPORT_API
int mm_sound_boot_ready(int timeout_sec)
{
close(fd);
fd = -1;
+ unlink_if_symbolic_link(KEYTONE_PATH);
/* Open PIPE */
fd = open(KEYTONE_PATH, O_WRONLY | O_NONBLOCK);
if (fd == -1) {
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <stdlib.h>
#include <mm_debug.h>
#include <mm_error.h>
focus_sound_info_t g_focus_sound_handle[FOCUS_HANDLE_MAX];
+static void unlink_if_symbolic_link(const char *path)
+{
+ int ret = 0;
+ char *resolved_path = NULL;
+
+ if (path == NULL)
+ return;
+
+ /* return if it does not exist */
+ if ((ret = access(path, F_OK)))
+ return;
+
+ if ((resolved_path = realpath(path, NULL))) {
+ /* assume that the path paramether is an absolute path */
+ if (strcmp(path, resolved_path)) {
+ debug_warning("unexpected symbolic link!, unlink the symbolic link(%s) to the resolved path(%s)", path, resolved_path);
+ unlink(path);
+ }
+ free(resolved_path);
+ } else {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ debug_warning("failed to realpath() for path:%s, err:%s", path, str_error);
+ }
+}
+
static gpointer _focus_thread_func(gpointer data)
{
unsigned int thread_id = (unsigned int)pthread_self();
int tmpfd = -1;
unsigned int buf = 0;
char *filename2 = g_strdup_printf("/tmp/FOCUS.%d.%dr", focus_handle->focus_pid, cb_data.handle);
+
+ unlink_if_symbolic_link(filename2);
tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
if (tmpfd < 0) {
char str_error[256];
int tmpfd = -1;
int buf = -1;
char *filename2 = g_strdup_printf("/tmp/FOCUS.%d.%d.wchr", focus_handle->focus_pid, cb_data.handle);
+
+ unlink_if_symbolic_link(filename2);
tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
if (tmpfd < 0) {
char str_error[256];
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
}
+ unlink_if_symbolic_link(filename);
pre_mask = umask(0);
if (mknod(filename, S_IFIFO|0666, 0))
debug_error("mknod() failure, errno(%d)", errno);