Lines Matching refs:node
32 // Create a dirtree node from a path, with stat and symlink info.
43 // open code this because haven't got node to call dirtree_parentfd() on yet
81 // Return path to this node, assembled recursively.
87 char *dirtree_path(struct dirtree *node, int *plen)
92 if (!node) {
98 len = (plen ? *plen : 0)+strlen(node->name)+1;
99 path = dirtree_path(node->parent, &len);
101 len = stpcpy(path+len, node->name) - path;
107 int dirtree_parentfd(struct dirtree *node)
109 return node->parent ? node->parent->dirfd : AT_FDCWD;
112 // Handle callback for a node in the tree. Returns saved node(s) if
114 // returns NULL. If !callback return top node unchanged.
118 int (*callback)(struct dirtree *node))
138 // Recursively read/process children of directory node, filtering through
141 int dirtree_recurse(struct dirtree *node,
142 int (*callback)(struct dirtree *node), int dirfd, int flags)
144 struct dirtree *new, **ddt = &(node->child);
148 node->dirfd = dirfd;
149 if (node->dirfd == -1 || !(dir = fdopendir(node->dirfd))) {
151 char *path = dirtree_path(node, 0);
155 close(node->dirfd);
166 if (!(new = dirtree_add_node(node, entry->d_name, flags))) continue;
178 node->again |= 1;
179 flags = callback(node);
184 node->dirfd = -1;
190 // return just the top node. Use dirtree_notdotdot callback to allocate a
191 // tree of struct dirtree nodes and return pointer to root node for later
197 int (*callback)(struct dirtree *node))
203 struct dirtree *dirtree_read(char *path, int (*callback)(struct dirtree *node))