ia64/xen-unstable

changeset 5426:957e3573240e

bitkeeper revision 1.1705.1.15 (42a9af28Mzva9Shzn8gUSiuJSM-TbA)

xenstore fixes for read-only connections.
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 10 15:18:00 2005 +0000 (2005-06-10)
parents 4bcb6d1a8fc5
children d44caae57112 bd865b72e7ab
files tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_domain.c tools/xenstore/xs_test.c
line diff
     1.1 --- a/tools/xenstore/xenstored_core.c	Fri Jun 10 14:38:22 2005 +0000
     1.2 +++ b/tools/xenstore/xenstored_core.c	Fri Jun 10 15:18:00 2005 +0000
     1.3 @@ -617,7 +617,7 @@ bool check_node_perms(struct connection 
     1.4  		return false;
     1.5  	}
     1.6  
     1.7 -	if (!conn->write && (perm & XS_PERM_WRITE)) {
     1.8 +	if (!conn->can_write && (perm & XS_PERM_WRITE)) {
     1.9  		errno = EROFS;
    1.10  		return false;
    1.11  	}
    1.12 @@ -938,6 +938,12 @@ static bool process_message(struct conne
    1.13  		return do_set_perms(conn, in);
    1.14  
    1.15  	case XS_SHUTDOWN:
    1.16 +		/* FIXME: Implement gentle shutdown too. */
    1.17 +		/* Only tools can do this. */
    1.18 +		if (conn->id != 0)
    1.19 +			return send_error(conn, EACCES);
    1.20 +		if (!conn->can_write)
    1.21 +			return send_error(conn, EROFS);
    1.22  		send_ack(conn, XS_SHUTDOWN);
    1.23  		/* Everything hangs off auto-free context, freed at exit. */
    1.24  		exit(0);
    1.25 @@ -1137,6 +1143,7 @@ struct connection *new_connection(connwr
    1.26  	new->transaction = NULL;
    1.27  	new->write = write;
    1.28  	new->read = read;
    1.29 +	new->can_write = true;
    1.30  
    1.31  	talloc_set_fail_handler(out_of_mem, &talloc_fail);
    1.32  	if (setjmp(talloc_fail)) {
    1.33 @@ -1170,10 +1177,11 @@ static void accept_connection(int sock, 
    1.34  	if (fd < 0)
    1.35  		return;
    1.36  
    1.37 -	conn = new_connection(canwrite ? writefd : NULL, readfd);
    1.38 -	if (conn)
    1.39 +	conn = new_connection(writefd, readfd);
    1.40 +	if (conn) {
    1.41  		conn->fd = fd;
    1.42 -	else
    1.43 +		conn->can_write = canwrite;
    1.44 +	} else
    1.45  		close(fd);
    1.46  }
    1.47  
     2.1 --- a/tools/xenstore/xenstored_core.h	Fri Jun 10 14:38:22 2005 +0000
     2.2 +++ b/tools/xenstore/xenstored_core.h	Fri Jun 10 15:18:00 2005 +0000
     2.3 @@ -56,6 +56,9 @@ struct connection
     2.4  	/* Are we blocked waiting for a transaction to end?  Contains node. */
     2.5  	char *blocked;
     2.6  
     2.7 +	/* Is this a read-only connection? */
     2.8 +	bool can_write;
     2.9 +
    2.10  	/* Our current event.  If all used, we're waiting for ack. */
    2.11  	struct watch_event *event;
    2.12  
     3.1 --- a/tools/xenstore/xenstored_domain.c	Fri Jun 10 14:38:22 2005 +0000
     3.2 +++ b/tools/xenstore/xenstored_domain.c	Fri Jun 10 15:18:00 2005 +0000
     3.3 @@ -268,6 +268,9 @@ bool do_introduce(struct connection *con
     3.4  	if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec))
     3.5  		return send_error(conn, EINVAL);
     3.6  
     3.7 +	if (!conn->can_write)
     3.8 +		return send_error(conn, EROFS);
     3.9 +
    3.10  	/* Hang domain off "in" until we're finished. */
    3.11  	domain = talloc(in, struct domain);
    3.12  	domain->domid = atoi(vec[0]);
     4.1 --- a/tools/xenstore/xs_test.c	Fri Jun 10 14:38:22 2005 +0000
     4.2 +++ b/tools/xenstore/xs_test.c	Fri Jun 10 15:18:00 2005 +0000
     4.3 @@ -176,11 +176,11 @@ static void __attribute__((noreturn)) us
     4.4  	     "  watch <path> <prio>\n"
     4.5  	     "  waitwatch\n"
     4.6  	     "  ackwatch\n"
     4.7 -	     "  unwatch <path>\n"
     4.8 +	     "  unwatch <path> <token>\n"
     4.9  	     "  close\n"
    4.10  	     "  start <node>\n"
    4.11  	     "  abort\n"
    4.12 -	     "  introduce <domid> <mfn> <eventchn>\n"
    4.13 +	     "  introduce <domid> <mfn> <eventchn> <path>\n"
    4.14  	     "  commit\n"
    4.15  	     "  sleep <seconds>\n"
    4.16  	     "  dump\n");