aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/xs.c
diff options
context:
space:
mode:
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>2005-09-12 21:42:26 +0000
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>2005-09-12 21:42:26 +0000
commitbd843d47d8a4dbab1b273420b52d3e3eb290df9b (patch)
tree4c57d3e43999443f3dbfa1f1d917fc6d4152f803 /tools/xenstore/xs.c
parent493519fd231c627f3356107ba0f819870090b180 (diff)
downloadxen-bd843d47d8a4dbab1b273420b52d3e3eb290df9b.tar.gz
xen-bd843d47d8a4dbab1b273420b52d3e3eb290df9b.tar.bz2
xen-bd843d47d8a4dbab1b273420b52d3e3eb290df9b.zip
Always allow overriding where clients connect through XENSTORED_PATH.
Detect if we're connecting to a socket or to the domain device and open accordingly. Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Diffstat (limited to 'tools/xenstore/xs.c')
-rw-r--r--tools/xenstore/xs.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index 95fc942c4a..9991cefc61 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -97,19 +97,32 @@ static struct xs_handle *get_dev(const char *connect_to)
return NULL;
}
+static struct xs_handle *get_handle(const char *connect_to)
+{
+ struct stat buf;
+
+ if (stat(connect_to, &buf) != 0)
+ return NULL;
+
+ if (S_ISSOCK(buf.st_mode))
+ return get_socket(connect_to);
+ else
+ return get_dev(connect_to);
+}
+
struct xs_handle *xs_daemon_open(void)
{
- return get_socket(xs_daemon_socket());
+ return get_handle(xs_daemon_socket());
}
struct xs_handle *xs_daemon_open_readonly(void)
{
- return get_socket(xs_daemon_socket_ro());
+ return get_handle(xs_daemon_socket_ro());
}
struct xs_handle *xs_domain_open(void)
{
- return get_dev(xs_domain_dev());
+ return get_handle(xs_domain_dev());
}
void xs_daemon_close(struct xs_handle *h)