diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index c638e46221eb..02ae390e2573 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -2447,34 +2447,36 @@ const char *dump_state_buffered_data(FILE *fp, const struct connection *c, return NULL; } -const char *dump_state_node_perms(FILE *fp, struct xs_state_node *sn, - const struct xs_permissions *perms, +const char *dump_state_node_perms(FILE *fp, const struct xs_permissions *perms, unsigned int n_perms) { unsigned int p; for (p = 0; p < n_perms; p++) { + struct xs_state_node_perm sp; + switch ((int)perms[p].perms & ~XS_PERM_IGNORE) { case XS_PERM_READ: - sn->perms[p].access = XS_STATE_NODE_PERM_READ; + sp.access = XS_STATE_NODE_PERM_READ; break; case XS_PERM_WRITE: - sn->perms[p].access = XS_STATE_NODE_PERM_WRITE; + sp.access = XS_STATE_NODE_PERM_WRITE; break; case XS_PERM_READ | XS_PERM_WRITE: - sn->perms[p].access = XS_STATE_NODE_PERM_BOTH; + sp.access = XS_STATE_NODE_PERM_BOTH; break; default: - sn->perms[p].access = XS_STATE_NODE_PERM_NONE; + sp.access = XS_STATE_NODE_PERM_NONE; break; } - sn->perms[p].flags = (perms[p].perms & XS_PERM_IGNORE) + sp.flags = (perms[p].perms & XS_PERM_IGNORE) ? XS_STATE_NODE_PERM_IGNORE : 0; - sn->perms[p].domid = perms[p].id; - } + sp.domid = perms[p].id; - if (fwrite(sn->perms, sizeof(*sn->perms), n_perms, fp) != n_perms) - return "Dump node permissions error"; + if (fwrite(&sp, sizeof(sp), 1, fp) != 1) + return "Dump node permission error"; + + } return NULL; } @@ -2519,7 +2521,7 @@ static const char *dump_state_node_tree(FILE *fp, char *path) if (fwrite(&sn, sizeof(sn), 1, fp) != 1) return "Dump node state error"; - ret = dump_state_node_perms(fp, &sn, hdr->perms, hdr->num_perms); + ret = dump_state_node_perms(fp, hdr->perms, hdr->num_perms); if (ret) return ret; diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 1cdbc3dcb5f7..b50ea3f57d5a 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -271,8 +271,7 @@ const char *dump_state_buffered_data(FILE *fp, const struct connection *c, const struct connection *conn, struct xs_state_connection *sc); const char *dump_state_nodes(FILE *fp, const void *ctx); -const char *dump_state_node_perms(FILE *fp, struct xs_state_node *sn, - const struct xs_permissions *perms, +const char *dump_state_node_perms(FILE *fp, const struct xs_permissions *perms, unsigned int n_perms); void read_state_global(const void *ctx, const void *state); diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 2d333b3ff68b..0c17937c0f66 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -1254,7 +1254,7 @@ static const char *dump_state_special_node(FILE *fp, const char *name, if (fwrite(&sn, sizeof(sn), 1, fp) != 1) return "Dump special node error"; - ret = dump_state_node_perms(fp, &sn, perms->p, perms->num); + ret = dump_state_node_perms(fp, perms->p, perms->num); if (ret) return ret;