aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-11-22 17:07:32 +0000
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-11-22 17:07:32 +0000
commit27be7560a57c9965dbf39b214c021dd90ea297e9 (patch)
tree21e32335753fe297f4c6af02ac780ed6288fbb39 /tools/xenstore
parentebbd2561b4cefb299f0f68a88b2788504223de18 (diff)
downloadxen-27be7560a57c9965dbf39b214c021dd90ea297e9.tar.gz
xen-27be7560a57c9965dbf39b214c021dd90ea297e9.tar.bz2
xen-27be7560a57c9965dbf39b214c021dd90ea297e9.zip
xenstore: xenbus cannot be opened read-only
In order to read keys from xenstore, the xenstore libraries need to write the request to the xenbus socket. This means that the socket cannot be opened read-only. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/xenstore')
-rw-r--r--tools/xenstore/xs.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index c72ea83d96..df270f7dd2 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -182,15 +182,13 @@ error:
return -1;
}
-static int get_dev(const char *connect_to, unsigned long flags)
+static int get_dev(const char *connect_to)
{
- if (flags & XS_OPEN_READONLY)
- return open(connect_to, O_RDONLY);
- else
- return open(connect_to, O_RDWR);
+ /* We cannot open read-only because requests are writes */
+ return open(connect_to, O_RDWR);
}
-static struct xs_handle *get_handle(const char *connect_to, unsigned long flags)
+static struct xs_handle *get_handle(const char *connect_to)
{
struct stat buf;
struct xs_handle *h = NULL;
@@ -202,7 +200,7 @@ static struct xs_handle *get_handle(const char *connect_to, unsigned long flags)
if (S_ISSOCK(buf.st_mode))
fd = get_socket(connect_to);
else
- fd = get_dev(connect_to, flags);
+ fd = get_dev(connect_to);
if (fd == -1)
return NULL;
@@ -258,12 +256,12 @@ struct xs_handle *xs_open(unsigned long flags)
struct xs_handle *xsh = NULL;
if (flags & XS_OPEN_READONLY)
- xsh = get_handle(xs_daemon_socket_ro(), flags);
+ xsh = get_handle(xs_daemon_socket_ro());
else
- xsh = get_handle(xs_daemon_socket(), flags);
+ xsh = get_handle(xs_daemon_socket());
if (!xsh && !(flags & XS_OPEN_SOCKETONLY))
- xsh = get_handle(xs_domain_dev(), flags);
+ xsh = get_handle(xs_domain_dev());
return xsh;
}