Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
xen.5854
xs-11-tdb-record-header.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xs-11-tdb-record-header.patch of Package xen.5854
commit 2d41c050176bd9972d1c49c60a710e399045dc80 Author: Juergen Gross <jgross@suse.com> Date: Mon Dec 5 08:48:44 2016 +0100 xenstore: use common tdb record header in xenstore The layout of the tdb record of xenstored is defined at multiple places: read_node(), write_node() and in xs_tdb_dump.c Use a common structure instead. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Index: xen-4.4.4-testing/tools/xenstore/xenstore_lib.h =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstore_lib.h +++ xen-4.4.4-testing/tools/xenstore/xenstore_lib.h @@ -42,6 +42,14 @@ struct xs_permissions enum xs_perm_type perms; }; +/* Header of the node record in tdb. */ +struct xs_tdb_record_hdr { + uint32_t num_perms; + uint32_t datalen; + uint32_t childlen; + struct xs_permissions perms[0]; +}; + /* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */ #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) Index: xen-4.4.4-testing/tools/xenstore/xenstored_core.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstored_core.c +++ xen-4.4.4-testing/tools/xenstore/xenstored_core.c @@ -411,7 +411,7 @@ static struct node *read_node(struct con const char *name) { TDB_DATA key, data; - uint32_t *p; + struct xs_tdb_record_hdr *hdr; struct node *node; TDB_CONTEXT * context = tdb_context(conn); @@ -436,13 +436,13 @@ static struct node *read_node(struct con talloc_steal(node, data.dptr); /* Datalen, childlen, number of permissions */ - p = (uint32_t *)data.dptr; - node->num_perms = p[0]; - node->datalen = p[1]; - node->childlen = p[2]; + hdr = (void *)data.dptr; + node->num_perms = hdr->num_perms; + node->datalen = hdr->datalen; + node->childlen = hdr->childlen; /* Permissions are struct xs_permissions. */ - node->perms = (void *)&p[3]; + node->perms = hdr->perms; /* Data is binary blob (usually ascii, no nul). */ node->data = node->perms + node->num_perms; /* Children is strings, nul separated. */ @@ -460,11 +460,12 @@ static bool write_node(struct connection TDB_DATA key, data; void *p; + struct xs_tdb_record_hdr *hdr; key.dptr = (void *)node->name; key.dsize = strlen(node->name); - data.dsize = 3*sizeof(uint32_t) + data.dsize = sizeof(*hdr) + node->num_perms*sizeof(node->perms[0]) + node->datalen + node->childlen; @@ -474,13 +475,13 @@ static bool write_node(struct connection add_change_node(conn, node, false); data.dptr = talloc_size(node, data.dsize); - ((uint32_t *)data.dptr)[0] = node->num_perms; - ((uint32_t *)data.dptr)[1] = node->datalen; - ((uint32_t *)data.dptr)[2] = node->childlen; - p = data.dptr + 3 * sizeof(uint32_t); + hdr = (void *)data.dptr; + hdr->num_perms = node->num_perms; + hdr->datalen = node->datalen; + hdr->childlen = node->childlen; - memcpy(p, node->perms, node->num_perms*sizeof(node->perms[0])); - p += node->num_perms*sizeof(node->perms[0]); + memcpy(hdr->perms, node->perms, node->num_perms*sizeof(node->perms[0])); + p = hdr->perms + node->num_perms; memcpy(p, node->data, node->datalen); p += node->datalen; memcpy(p, node->children, node->childlen); Index: xen-4.4.4-testing/tools/xenstore/xs_tdb_dump.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xs_tdb_dump.c +++ xen-4.4.4-testing/tools/xenstore/xs_tdb_dump.c @@ -10,14 +10,7 @@ #include "talloc.h" #include "utils.h" -struct record_hdr { - uint32_t num_perms; - uint32_t datalen; - uint32_t childlen; - struct xs_permissions perms[0]; -}; - -static uint32_t total_size(struct record_hdr *hdr) +static uint32_t total_size(struct xs_tdb_record_hdr *hdr) { return sizeof(*hdr) + hdr->num_perms * sizeof(struct xs_permissions) + hdr->datalen + hdr->childlen; @@ -57,7 +50,7 @@ int main(int argc, char *argv[]) key = tdb_firstkey(tdb); while (key.dptr) { TDB_DATA data; - struct record_hdr *hdr; + struct xs_tdb_record_hdr *hdr; data = tdb_fetch(tdb, key); hdr = (void *)data.dptr;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor