All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] xenstore: xenbus cannot be opened read-only
@ 2011-11-09 18:11 Daniel De Graaf
  2011-11-09 18:11 ` [PATCH 2/2] xenstat: Use local domain names Daniel De Graaf
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel De Graaf @ 2011-11-09 18:11 UTC (permalink / raw)
  To: ian.jackson; +Cc: Daniel De Graaf, xen-devel

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>
---
 tools/xenstore/xs.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index c72ea83..df270f7 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;
 }
-- 
1.7.6.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-13 15:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09 18:11 [PATCH 1/2] xenstore: xenbus cannot be opened read-only Daniel De Graaf
2011-11-09 18:11 ` [PATCH 2/2] xenstat: Use local domain names Daniel De Graaf
2011-11-10 19:51   ` Ian Campbell
2011-11-22 17:08     ` Ian Jackson
2012-03-08 23:06   ` Xentop - Domain-0 statistics Kaushik Kumar Ram
2012-03-09  0:43     ` Ian Campbell
2012-03-12 11:36       ` Ian Jackson
2012-03-13 15:41       ` Xentop - Domain-0 statistics [and 1 more messages] Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.