return node;
}
-static bool write_node(struct connection *conn, struct node *node)
+static int xs_write_node(struct connection *conn, struct node *node)
{
/*
* conn will be null when this is called from manual_node.
corrupt(conn, "Write of %s failed", key.dptr);
goto error;
}
- return true;
+ return 0;
error:
errno = ENOSPC;
- return false;
+ return errno;
}
static enum xs_perm_type perm_for_conn(struct connection *conn,
/* We write out the nodes down, setting destructor in case
* something goes wrong. */
for (i = node; i; i = i->parent) {
- if (!write_node(conn, i)) {
+ if (xs_write_node(conn, i)) {
domain_entry_dec(conn, i);
return NULL;
}
} else {
node->data = in->buffer + offset;
node->datalen = datalen;
- if (!write_node(conn, node))
+ if (xs_write_node(conn, node))
return errno;
}
}
-static bool remove_child_entry(struct connection *conn, struct node *node,
- size_t offset)
+static int xs_remove_child_entry(struct connection *conn, struct node *node,
+ size_t offset)
{
size_t childlen = strlen(node->children + offset);
memdel(node->children, offset, childlen + 1, node->childlen);
node->childlen -= childlen + 1;
- return write_node(conn, node);
+ return xs_write_node(conn, node);
}
-static bool delete_child(struct connection *conn,
- struct node *node, const char *childname)
+static int xs_delete_child(struct connection *conn,
+ struct node *node, const char *childname)
{
unsigned int i;
for (i = 0; i < node->childlen; i += strlen(node->children+i) + 1) {
if (streq(node->children+i, childname)) {
- return remove_child_entry(conn, node, i);
+ return xs_remove_child_entry(conn, node, i);
}
}
corrupt(conn, "Can't find child '%s' in %s", childname, node->name);
- return false;
+ return ENOENT;
}
if (!parent)
return (errno == ENOMEM) ? ENOMEM : EINVAL;
- if (!delete_child(conn, parent, basename(name)))
+ if (xs_delete_child(conn, parent, basename(name)))
return EINVAL;
delete_node(conn, node, true);
node->num_perms = num;
domain_entry_inc(conn, node);
- if (!write_node(conn, node))
+ if (xs_write_node(conn, node))
return errno;
fire_watches(conn, in, name, false);
if (child)
node->childlen = strlen(child) + 1;
- if (!write_node(NULL, node))
+ if (xs_write_node(NULL, node))
barf_perror("Could not create initial node %s", name);
talloc_free(node);
}
childname);
if (recovery) {
- remove_child_entry(NULL, node,
+ xs_remove_child_entry(NULL, node,
i);
i -= childlen + 1;
}
childname);
if (recovery) {
- remove_child_entry(NULL, node, i);
+ xs_remove_child_entry(NULL, node, i);
i -= childlen + 1;
}
} else {