app/eventdev: switch sequence number to dynamic mbuf field
[dpdk.git] / lib / librte_power / guest_channel.c
index 439cd2f..7b5926e 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <glob.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 static int global_fds[RTE_MAX_LCORE] = { [0 ... RTE_MAX_LCORE-1] = -1 };
 
+int
+guest_channel_host_check_exists(const char *path)
+{
+       char glob_path[PATH_MAX];
+       glob_t g;
+       int ret;
+
+       /* we cannot know in advance which cores have VM channels, so glob */
+       snprintf(glob_path, PATH_MAX, "%s.*", path);
+
+       ret = glob(glob_path, GLOB_NOSORT, NULL, &g);
+       if (ret != 0) {
+               /* couldn't read anything */
+               ret = 0;
+               goto out;
+       }
+
+       /* do we have at least one match? */
+       ret = g.gl_pathc > 0;
+
+out:
+       globfree(&g);
+       return ret;
+}
+
 int
 guest_channel_host_connect(const char *path, unsigned int lcore_id)
 {
@@ -148,7 +174,7 @@ int power_guest_channel_read_msg(void *pkt,
                return -1;
        } else if (ret < 0) {
                RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n",
-                               strerror(ret));
+                               strerror(errno));
                return -1;
        }