Lines Matching defs:cur

175 fsnode_isroot(const fsnode *cur)
177 return (strcmp(cur->name, ".") == 0);
181 fsnode_valid(const fsnode *cur)
183 return (cur->type == S_IFREG || cur->type == S_IFDIR ||
184 cur->type == S_IFLNK);
195 for (fsnode *cur = root; cur != NULL; cur = cur->next) {
196 if (!fsnode_valid(cur)) {
198 inode_type(cur->type), cur->path, cur->name);
201 if (cb(cur, arg) == 0)
203 if (cur->type == S_IFDIR && cur->child != NULL)
204 fsnode_foreach(cur->child, cb, arg);
209 fs_populate_dirent(struct fs_populate_arg *arg, fsnode *cur, uint64_t dnid)
214 switch (cur->type) {
229 zap_add_uint64(dir->zap, cur->name, ZFS_DIRENT_MAKE(type, dnid));
264 fs_populate_path(const fsnode *cur, struct fs_populate_arg *arg,
267 if (cur->contents != NULL) {
271 n = strlcpy(path, cur->contents, sz);
273 } else if (cur->root == NULL) {
277 n = strlcpy(path, cur->name, sz);
284 cur->root, cur->path, cur->name);
291 fs_open(const fsnode *cur, struct fs_populate_arg *arg, int flags)
296 fs_populate_path(cur, arg, path, sizeof(path), &fd);
305 fs_open_can_fail(const fsnode *cur, struct fs_populate_arg *arg, int flags)
310 fs_populate_path(cur, arg, path, sizeof(path), &fd);
316 fs_readlink(const fsnode *cur, struct fs_populate_arg *arg,
322 if (cur->symlink != NULL) {
325 n = strlcpy(buf, cur->symlink, bufsz);
330 fs_populate_path(cur, arg, path, sizeof(path), &fd);
334 err(1, "readlinkat(%s)", cur->name);
355 fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur,
372 sb = &cur->inode->st;
374 switch (cur->type) {
377 links = cur->inode->nlink;
391 for (fsnode *c = fsnode_isroot(cur) ? cur->next : cur->child;
409 fs_readlink(cur, arg, target, sizeof(target));
511 if (cur->type == S_IFLNK) {
524 fs_populate_file(fsnode *cur, struct fs_populate_arg *arg)
536 assert(cur->type == S_IFREG);
537 assert((cur->inode->flags & FI_ROOT) == 0);
541 assert(cur->inode->ino != 0);
542 if ((cur->inode->flags & FI_ALLOCATED) != 0) {
549 fs_populate_dirent(arg, cur, cur->inode->ino);
555 cur->inode->ino = dnid;
556 cur->inode->flags |= FI_ALLOCATED;
558 fd = fs_open(cur, arg, O_RDONLY);
562 size = cur->inode->st.st_size;
575 err(1, "reading from '%s'", cur->name);
578 cur->name);
593 fs_populate_sattrs(arg, cur, dnode);
594 fs_populate_dirent(arg, cur, dnid);
598 fs_populate_dir(fsnode *cur, struct fs_populate_arg *arg)
605 assert(cur->type == S_IFDIR);
606 assert((cur->inode->flags & FI_ALLOCATED) == 0);
617 fs_populate_dirent(arg, cur, dnid);
623 dirfd = fs_open_can_fail(cur, arg, O_DIRECTORY | O_RDONLY);
633 fs_populate_sattrs(arg, cur, dnode);
639 if ((cur->inode->flags & FI_ROOT) == 0) {
649 fs_build_one(arg->zfs, cur->inode->param, cur->child, dirfd);
654 fs_populate_symlink(fsnode *cur, struct fs_populate_arg *arg)
659 assert(cur->type == S_IFLNK);
660 assert((cur->inode->flags & (FI_ALLOCATED | FI_ROOT)) == 0);
665 fs_populate_dirent(arg, cur, dnid);
667 fs_populate_sattrs(arg, cur, dnode);
671 fsnode_next(fsnode *cur)
673 for (cur = cur->next; cur != NULL; cur = cur->next) {
674 if (fsnode_valid(cur))
675 return (cur);
681 fs_foreach_populate(fsnode *cur, void *_arg)
688 switch (cur->type) {
690 fs_populate_file(cur, arg);
693 if (fsnode_isroot(cur))
695 fs_populate_dir(cur, arg);
698 fs_populate_symlink(cur, arg);
704 ret = (cur->inode->flags & FI_ROOT) != 0 ? 0 : 1;
706 if (fsnode_next(cur) == NULL &&
707 (cur->child == NULL || (cur->inode->flags & FI_ROOT) != 0)) {
721 cur = cur->parent;
722 } while (cur != NULL && fsnode_next(cur) == NULL &&
723 (cur->inode->flags & FI_ROOT) == 0);
837 fsnode *cur, *root;
864 cur = root;
875 cur = root;
881 for (; cur != NULL && strcmp(cur->name, name) != 0;
882 cur = cur->next)
884 if (cur == NULL) {
890 if (cur->type != S_IFDIR) {
896 cur = cur->child;
900 if (cur != NULL) {
901 assert(cur->type == S_IFDIR);
908 assert((cur->inode->flags & FI_ROOT) == 0);
909 if (cur != root)
910 cur->inode->flags |= FI_ROOT;
911 assert(cur->inode->param == NULL);
912 cur->inode->param = dsldir;
919 fs_foreach_mark(fsnode *cur, void *arg)
924 if (cur->type == S_IFDIR && fsnode_isroot(cur))
927 if (cur->inode->ino == 0) {
928 cur->inode->ino = ++(*countp);
929 cur->inode->nlink = 1;
931 cur->inode->nlink++;
934 return ((cur->inode->flags & FI_ROOT) != 0 ? 0 : 1);