ia64/xen-unstable

changeset 6264:a028975ecc05

Get rid of xenbus_uuid_to_domid - get the frontend id from the node.
We don't want to parse paths we read out of the store to _construct_
other paths and tie down the store layout for no good reason.
Also require the frontend path to exist and be valid before creating
the device.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 18 19:21:09 2005 +0000 (2005-08-18)
parents b0893b876c8c
children 5a97aa8698d9
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/include/asm-xen/xenbus.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Aug 18 19:15:22 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Aug 18 19:21:09 2005 +0000
     1.3 @@ -109,47 +109,41 @@ static struct xen_bus_type xenbus_fronte
     1.4  	},
     1.5  };
     1.6  
     1.7 -/* For backends, does lookup on uuid (up to /).  Returns domid, or -errno. */
     1.8 -int xenbus_uuid_to_domid(const char *uuid)
     1.9 -{
    1.10 -	int err, domid, len;
    1.11 -	char path[strlen("/domain/") + 50];
    1.12 -
    1.13 -	len = strcspn(uuid, "/");
    1.14 -	if (snprintf(path, sizeof(path), "/domain/%.*s", len, uuid)
    1.15 -	    >= sizeof(path))
    1.16 -		return -ENOSPC;
    1.17 -	err = xenbus_scanf(path, "id", "%i", &domid);
    1.18 -	if (err != 1)
    1.19 -		return err;
    1.20 -	return domid;
    1.21 -}
    1.22 -
    1.23  /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
    1.24  static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
    1.25  {
    1.26 -	unsigned int typelen, uuidlen;
    1.27 -	int domid;
    1.28 -	const char *p;
    1.29 +	int domid, err;
    1.30 +	const char *devid, *type, *frontend;
    1.31 +	unsigned int typelen;
    1.32  
    1.33 -	nodename = strchr(nodename, '/');
    1.34 -	if (!nodename)
    1.35 +	type = strchr(nodename, '/');
    1.36 +	if (!type)
    1.37 +		return -EINVAL;
    1.38 +	type++;
    1.39 +	typelen = strcspn(type, "/");
    1.40 +	if (!typelen || type[typelen] != '/')
    1.41  		return -EINVAL;
    1.42 -	nodename++;
    1.43 -	typelen = strcspn(nodename, "/");
    1.44 -	if (!typelen || nodename[typelen] != '/')
    1.45 -		return -EINVAL;
    1.46 -	p = nodename + typelen + 1;
    1.47 -	uuidlen = strcspn(p, "/");
    1.48 -	if (!uuidlen || p[uuidlen] != '/')
    1.49 -		return -EINVAL;
    1.50 -	domid = xenbus_uuid_to_domid(p);
    1.51 -	if (domid < 0)
    1.52 -		return domid;
    1.53 -	p += uuidlen + 1;
    1.54 +
    1.55 +	devid = strrchr(nodename, '/') + 1;
    1.56 +
    1.57 +	err = xenbus_gather(nodename, "frontend-id", "%i", &domid,
    1.58 +			    "frontend", NULL, &frontend,
    1.59 +			    NULL);
    1.60 +	if (err)
    1.61 +		return err;
    1.62 +	if (strlen(frontend) == 0)
    1.63 +		err = -ERANGE;
    1.64 +
    1.65 +	if (!err && !xenbus_exists(frontend, ""))
    1.66 +		err = -ENOENT;
    1.67 +
    1.68 +	if (err) {
    1.69 +		kfree(frontend);
    1.70 +		return err;
    1.71 +	}
    1.72  
    1.73  	if (snprintf(bus_id, BUS_ID_SIZE,
    1.74 -		     "%.*s-%i-%s", typelen, nodename, domid, p) >= BUS_ID_SIZE)
    1.75 +		     "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
    1.76  		return -ENOSPC;
    1.77  	return 0;
    1.78  }
     2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Thu Aug 18 19:15:22 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Thu Aug 18 19:21:09 2005 +0000
     2.3 @@ -126,9 +126,6 @@ int register_xenbus_watch(struct xenbus_
     2.4  void unregister_xenbus_watch(struct xenbus_watch *watch);
     2.5  void reregister_xenbus_watches(void);
     2.6  
     2.7 -/* For backends, does lookup on uuid (up to /).  Returns domid, or -errno. */
     2.8 -int xenbus_uuid_to_domid(const char *uuid);
     2.9 -
    2.10  /* Called from xen core code. */
    2.11  void xenbus_suspend(void);
    2.12  void xenbus_resume(void);