WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1/2] xenstore: xenbus cannot be opened read-only

To: ian.jackson@xxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1/2] xenstore: xenbus cannot be opened read-only
From: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Date: Wed, 9 Nov 2011 13:11:26 -0500
Cc: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 09 Nov 2011 10:19:24 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxx>
---
 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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>