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>
This commit is contained in:
cl349@firebug.cl.cam.ac.uk committed 2005-08-18 19:21:09 +00:00
1 parent b3aeb9b7bf
commit 90562ffd56
2 files changed
+27 -36

No files matched your search

@@ -109,47 +109,41 @@ static struct xen_bus_type xenbus_frontend = {
},
};
/* For backends, does lookup on uuid (up to /). Returns domid, or -errno. */
int xenbus_uuid_to_domid(const char *uuid)
{
int err, domid, len;
char path[strlen("/domain/") + 50];
len = strcspn(uuid, "/");
if (snprintf(path, sizeof(path), "/domain/%.*s", len, uuid)
>= sizeof(path))
return -ENOSPC;
err = xenbus_scanf(path, "id", "%i", &domid);
if (err != 1)
return err;
return domid;
}
/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
{
unsigned int typelen, uuidlen;
int domid;
const char *p;
int domid, err;
const char *devid, *type, *frontend;
unsigned int typelen;
nodename = strchr(nodename, '/');
if (!nodename)
type = strchr(nodename, '/');
if (!type)
return -EINVAL;
nodename++;
typelen = strcspn(nodename, "/");
if (!typelen || nodename[typelen] != '/')
type++;
typelen = strcspn(type, "/");
if (!typelen || type[typelen] != '/')
return -EINVAL;
p = nodename + typelen + 1;
uuidlen = strcspn(p, "/");
if (!uuidlen || p[uuidlen] != '/')
return -EINVAL;
domid = xenbus_uuid_to_domid(p);
if (domid < 0)
return domid;
p += uuidlen + 1;
devid = strrchr(nodename, '/') + 1;
err = xenbus_gather(nodename, "frontend-id", "%i", &domid,
"frontend", NULL, &frontend,
NULL);
if (err)
return err;
if (strlen(frontend) == 0)
err = -ERANGE;
if (!err && !xenbus_exists(frontend, ""))
err = -ENOENT;
if (err) {
kfree(frontend);
return err;
}
if (snprintf(bus_id, BUS_ID_SIZE,
"%.*s-%i-%s", typelen, nodename, domid, p) >= BUS_ID_SIZE)
"%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
return -ENOSPC;
return 0;
}
@@ -126,9 +126,6 @@ int register_xenbus_watch(struct xenbus_watch *watch);
void unregister_xenbus_watch(struct xenbus_watch *watch);
void reregister_xenbus_watches(void);
/* For backends, does lookup on uuid (up to /). Returns domid, or -errno. */
int xenbus_uuid_to_domid(const char *uuid);
/* Called from xen core code. */
void xenbus_suspend(void);
void xenbus_resume(void);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.