ia64/linux-2.6.18-xen.hg

changeset 874:68d582b0ad05

xenbus: allow any xenbus command over /proc/xen/xenbus.

Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 14:28:48 2009 +0100 (2009-05-19)
parents 57acc535fd37
children e17af34d4d90
files drivers/xen/xenbus/xenbus_dev.c
line diff
     1.1 --- a/drivers/xen/xenbus/xenbus_dev.c	Mon May 18 14:14:15 2009 +0100
     1.2 +++ b/drivers/xen/xenbus/xenbus_dev.c	Tue May 19 14:28:48 2009 +0100
     1.3 @@ -224,50 +224,6 @@ static ssize_t xenbus_dev_write(struct f
     1.4  	msg_type = u->u.msg.type;
     1.5  
     1.6  	switch (msg_type) {
     1.7 -	case XS_TRANSACTION_START:
     1.8 -	case XS_TRANSACTION_END:
     1.9 -	case XS_DIRECTORY:
    1.10 -	case XS_READ:
    1.11 -	case XS_GET_PERMS:
    1.12 -	case XS_RELEASE:
    1.13 -	case XS_GET_DOMAIN_PATH:
    1.14 -	case XS_WRITE:
    1.15 -	case XS_MKDIR:
    1.16 -	case XS_RM:
    1.17 -	case XS_SET_PERMS:
    1.18 -		if (msg_type == XS_TRANSACTION_START) {
    1.19 -			trans = kmalloc(sizeof(*trans), GFP_KERNEL);
    1.20 -			if (!trans) {
    1.21 -				rc = -ENOMEM;
    1.22 -				goto out;
    1.23 -			}
    1.24 -		}
    1.25 -
    1.26 -		reply = xenbus_dev_request_and_reply(&u->u.msg);
    1.27 -		if (IS_ERR(reply)) {
    1.28 -			kfree(trans);
    1.29 -			rc = PTR_ERR(reply);
    1.30 -			goto out;
    1.31 -		}
    1.32 -
    1.33 -		if (msg_type == XS_TRANSACTION_START) {
    1.34 -			trans->handle.id = simple_strtoul(reply, NULL, 0);
    1.35 -			list_add(&trans->list, &u->transactions);
    1.36 -		} else if (msg_type == XS_TRANSACTION_END) {
    1.37 -			list_for_each_entry(trans, &u->transactions, list)
    1.38 -				if (trans->handle.id == u->u.msg.tx_id)
    1.39 -					break;
    1.40 -			BUG_ON(&trans->list == &u->transactions);
    1.41 -			list_del(&trans->list);
    1.42 -			kfree(trans);
    1.43 -		}
    1.44 -		mutex_lock(&u->reply_mutex);
    1.45 -		queue_reply(u, (char *)&u->u.msg, sizeof(u->u.msg));
    1.46 -		queue_reply(u, (char *)reply, u->u.msg.len);
    1.47 -		mutex_unlock(&u->reply_mutex);
    1.48 -		kfree(reply);
    1.49 -		break;
    1.50 -
    1.51  	case XS_WATCH:
    1.52  	case XS_UNWATCH: {
    1.53  		static const char *XS_RESP = "OK";
    1.54 @@ -323,7 +279,37 @@ static ssize_t xenbus_dev_write(struct f
    1.55  	}
    1.56  
    1.57  	default:
    1.58 -		rc = -EINVAL;
    1.59 +		if (msg_type == XS_TRANSACTION_START) {
    1.60 +			trans = kmalloc(sizeof(*trans), GFP_KERNEL);
    1.61 +			if (!trans) {
    1.62 +				rc = -ENOMEM;
    1.63 +				goto out;
    1.64 +			}
    1.65 +		}
    1.66 +
    1.67 +		reply = xenbus_dev_request_and_reply(&u->u.msg);
    1.68 +		if (IS_ERR(reply)) {
    1.69 +			kfree(trans);
    1.70 +			rc = PTR_ERR(reply);
    1.71 +			goto out;
    1.72 +		}
    1.73 +
    1.74 +		if (msg_type == XS_TRANSACTION_START) {
    1.75 +			trans->handle.id = simple_strtoul(reply, NULL, 0);
    1.76 +			list_add(&trans->list, &u->transactions);
    1.77 +		} else if (msg_type == XS_TRANSACTION_END) {
    1.78 +			list_for_each_entry(trans, &u->transactions, list)
    1.79 +				if (trans->handle.id == u->u.msg.tx_id)
    1.80 +					break;
    1.81 +			BUG_ON(&trans->list == &u->transactions);
    1.82 +			list_del(&trans->list);
    1.83 +			kfree(trans);
    1.84 +		}
    1.85 +		mutex_lock(&u->reply_mutex);
    1.86 +		queue_reply(u, (char *)&u->u.msg, sizeof(u->u.msg));
    1.87 +		queue_reply(u, (char *)reply, u->u.msg.len);
    1.88 +		mutex_unlock(&u->reply_mutex);
    1.89 +		kfree(reply);
    1.90  		break;
    1.91  	}
    1.92