xen-vtx-unstable

diff tools/xenstore/xs.c @ 6750:d8637529daff

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>
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 12 21:42:26 2005 +0000 (2005-09-12)
parents 80afc502461b
children 4d899a738d59 8ca0f98ba8e2
line diff
     1.1 --- a/tools/xenstore/xs.c	Mon Sep 12 21:12:16 2005 +0000
     1.2 +++ b/tools/xenstore/xs.c	Mon Sep 12 21:42:26 2005 +0000
     1.3 @@ -97,19 +97,32 @@ static struct xs_handle *get_dev(const c
     1.4  	return NULL;
     1.5  }
     1.6  
     1.7 +static struct xs_handle *get_handle(const char *connect_to)
     1.8 +{
     1.9 +	struct stat buf;
    1.10 +
    1.11 +	if (stat(connect_to, &buf) != 0)
    1.12 +		return NULL;
    1.13 +
    1.14 +	if (S_ISSOCK(buf.st_mode))
    1.15 +		return get_socket(connect_to);
    1.16 +	else
    1.17 +		return get_dev(connect_to);
    1.18 +}
    1.19 +
    1.20  struct xs_handle *xs_daemon_open(void)
    1.21  {
    1.22 -	return get_socket(xs_daemon_socket());
    1.23 +	return get_handle(xs_daemon_socket());
    1.24  }
    1.25  
    1.26  struct xs_handle *xs_daemon_open_readonly(void)
    1.27  {
    1.28 -	return get_socket(xs_daemon_socket_ro());
    1.29 +	return get_handle(xs_daemon_socket_ro());
    1.30  }
    1.31  
    1.32  struct xs_handle *xs_domain_open(void)
    1.33  {
    1.34 -	return get_dev(xs_domain_dev());
    1.35 +	return get_handle(xs_domain_dev());
    1.36  }
    1.37  
    1.38  void xs_daemon_close(struct xs_handle *h)