return perms[0].perms & mask;
}
-static char *get_parent(const char *node)
+/*
+ * Get name of node parent.
+ * Temporary memory allocations are done with ctx.
+ */
+static char *get_parent(const void *ctx, const char *node)
{
char *slash = strrchr(node + 1, '/');
if (!slash)
- return talloc_strdup(node, "/");
- return talloc_asprintf(node, "%.*s", (int)(slash - node), node);
+ return talloc_strdup(ctx, "/");
+ return talloc_asprintf(ctx, "%.*s", (int)(slash - node), node);
}
/* What do parents say? */
struct node *node;
do {
- name = get_parent(name);
+ name = get_parent(name, name);
node = read_node(conn, name);
if (node)
break;
const char *base;
unsigned int baselen;
struct node *parent, *node;
- char *children, *parentname = get_parent(name);
+ char *children, *parentname = get_parent(name, name);
/* If parent doesn't exist, create it. */
parent = read_node(conn, parentname);
/* Delete from parent first, then if we crash, the worst that can
happen is the child will continue to take up space, but will
otherwise be unreachable. */
- struct node *parent = read_node(conn, get_parent(name));
+ struct node *parent = read_node(conn, get_parent(name, name));
if (!parent) {
send_error(conn, EINVAL);
return 0;
if (!node) {
/* Didn't exist already? Fine, if parent exists. */
if (errno == ENOENT) {
- node = read_node(conn, get_parent(name));
+ node = read_node(conn, get_parent(in, name));
if (node) {
send_ack(conn, XS_RM);
return;