Lines Matching refs:node
106 * Initialize vnode with tmpfs node.
109 tmpfs_init_vnode(struct vnode *vp, tmpfs_node_t *node)
113 KASSERT(node->tn_vnode == NULL);
115 /* Share the interlock with the node. */
116 if (node->tn_type == VREG) {
117 slock = node->tn_spec.tn_reg.tn_aobj->vmobjlock;
123 vp->v_type = node->tn_type;
130 spec_node_init(vp, node->tn_spec.tn_dev.tn_rdev);
136 if (node->tn_spec.tn_dir.tn_parent == node)
145 panic("bad node type %d", vp->v_type);
149 vp->v_data = node;
150 node->tn_vnode = vp;
151 uvm_vnp_setsize(vp, node->tn_size);
152 KASSERT(node->tn_mode != VNOVAL);
153 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true);
163 tmpfs_node_t *node;
165 KASSERT(key_len == sizeof(node));
166 memcpy(&node, key, key_len);
168 if (node->tn_links == 0)
171 tmpfs_init_vnode(vp, node);
188 tmpfs_node_t *node, *dnode;
204 node = tmpfs_node_get(tmp);
205 if (node == NULL)
209 node->tn_links = 0;
210 node->tn_vnode = NULL;
211 node->tn_holdcount = 0;
212 node->tn_dirent_hint = NULL;
216 * sizeof(*node)), this may produce duplicate inode numbers
219 node->tn_id = (ino_t)((uintptr_t)node / sizeof(*node));
225 node->tn_gen = TMPFS_NODE_GEN_MASK & cprng_fast32();
226 } while (node->tn_gen == 0);
230 node->tn_type = vap->va_type;
231 node->tn_size = 0;
232 node->tn_flags = 0;
233 node->tn_lockf = NULL;
235 node->tn_tflags = 0;
236 vfs_timestamp(&node->tn_atime);
237 node->tn_birthtime = node->tn_atime;
238 node->tn_ctime = node->tn_atime;
239 node->tn_mtime = node->tn_atime;
240 mutex_init(&node->tn_timelock, MUTEX_DEFAULT, IPL_NONE);
244 node->tn_uid = vap->va_uid;
245 node->tn_gid = vap->va_gid;
249 node->tn_uid = kauth_cred_geteuid(cred);
250 node->tn_gid = dnode->tn_gid;
253 node->tn_mode = vap->va_mode;
256 switch (node->tn_type) {
261 node->tn_spec.tn_dev.tn_rdev = vap->va_rdev;
265 TAILQ_INIT(&node->tn_spec.tn_dir.tn_dir);
266 node->tn_spec.tn_dir.tn_parent = NULL;
267 node->tn_spec.tn_dir.tn_seq_arena = NULL;
268 node->tn_spec.tn_dir.tn_next_seq = TMPFS_DIRSEQ_START;
269 node->tn_spec.tn_dir.tn_readdir_lastp = NULL;
272 node->tn_links++;
278 node->tn_size = 0;
279 node->tn_spec.tn_lnk.tn_link = NULL;
283 node->tn_spec.tn_reg.tn_aobj =
285 node->tn_spec.tn_reg.tn_aobj_pages = 0;
288 panic("bad node type %d", vp->v_type);
292 tmpfs_init_vnode(vp, node);
295 LIST_INSERT_HEAD(&tmp->tm_nodes, node, tn_entries);
309 tmpfs_free_node(tmpfs_mount_t *tmp, tmpfs_node_t *node)
315 hold = atomic_or_32_nv(&node->tn_holdcount, TMPFS_NODE_RECLAIMED);
316 /* Defer destruction to last thread holding this node. */
321 LIST_REMOVE(node, tn_entries);
324 switch (node->tn_type) {
326 if (node->tn_size > 0) {
327 tmpfs_strname_free(tmp, node->tn_spec.tn_lnk.tn_link,
328 node->tn_size);
336 objsz = PAGE_SIZE * node->tn_spec.tn_reg.tn_aobj_pages;
340 if (node->tn_spec.tn_reg.tn_aobj != NULL) {
341 uao_detach(node->tn_spec.tn_reg.tn_aobj);
345 KASSERT(node->tn_size == 0);
346 KASSERT(node->tn_spec.tn_dir.tn_seq_arena == NULL);
347 KASSERT(TAILQ_EMPTY(&node->tn_spec.tn_dir.tn_dir));
348 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL ||
349 node == tmp->tm_root);
354 KASSERT(node->tn_vnode == NULL);
355 KASSERT(node->tn_links == 0);
357 mutex_destroy(&node->tn_timelock);
358 tmpfs_node_put(tmp, node);
372 tmpfs_node_t *dnode = VP_TO_TMPFS_DIR(dvp), *node;
417 node = VP_TO_TMPFS_NODE(*vpp);
420 node->tn_spec.tn_lnk.tn_link = slink;
421 node->tn_size = ssize;
433 tmpfs_dir_attach(dnode, de, node);
435 /* Make node opaque if requested. */
437 node->tn_flags |= UF_OPAQUE;
492 * => Increases link count on the associated node.
493 * => Increases link count on directory node if our node is VDIR.
498 tmpfs_dir_attach(tmpfs_node_t *dnode, tmpfs_dirent_t *de, tmpfs_node_t *node)
511 de->td_node = node;
512 if (node != TMPFS_NODE_WHITEOUT) {
513 KASSERT(node->tn_links < LINK_MAX);
514 node->tn_links++;
517 node->tn_dirent_hint = de;
529 if (node != TMPFS_NODE_WHITEOUT && node->tn_type == VDIR) {
531 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL);
532 node->tn_spec.tn_dir.tn_parent = dnode;
539 TMPFS_VALIDATE_DIR(node);
547 * => Decreases link count on the associated node.
548 * => Decreases the link count on directory node, if our node is VDIR.
556 tmpfs_node_t *node = de->td_node;
561 if (__predict_true(node != TMPFS_NODE_WHITEOUT)) {
563 node->tn_dirent_hint = NULL;
565 KASSERT(node->tn_links > 0);
566 node->tn_links--;
569 if (node->tn_type == VDIR) {
570 KASSERT(node->tn_spec.tn_dir.tn_parent == dnode);
571 node->tn_spec.tn_dir.tn_parent = NULL;
600 tmpfs_dir_lookup(tmpfs_node_t *node, struct componentname *cnp)
606 KASSERT(VOP_ISLOCKED(node->tn_vnode));
609 TMPFS_VALIDATE_DIR(node);
611 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) {
628 tmpfs_dir_cached(tmpfs_node_t *node)
630 tmpfs_dirent_t *de = node->tn_dirent_hint;
632 KASSERT(VOP_ISLOCKED(node->tn_vnode));
637 KASSERT(de->td_node == node);
643 return (node->tn_type != VDIR && node->tn_links > 1) ? NULL : de;
737 tmpfs_dir_lookupbyseq(tmpfs_node_t *node, off_t seq)
739 tmpfs_dirent_t *de = node->tn_spec.tn_dir.tn_readdir_lastp;
741 TMPFS_VALIDATE_DIR(node);
751 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) {
765 tmpfs_dir_getdotents(tmpfs_node_t *node, struct dirent *dp, struct uio *uio)
773 dp->d_fileno = node->tn_id;
778 dp->d_fileno = node->tn_spec.tn_dir.tn_parent->tn_id;
780 de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir);
781 next = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF;
808 tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio, off_t *cntp)
814 KASSERT(VOP_ISLOCKED(node->tn_vnode));
815 TMPFS_VALIDATE_DIR(node);
824 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) {
830 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) {
842 de = tmpfs_dir_lookupbyseq(node, uio->uio_offset);
883 uio->uio_offset = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF;
884 node->tn_spec.tn_dir.tn_readdir_lastp = de;
886 tmpfs_update(node->tn_vnode, TMPFS_UPDATE_ATIME);
904 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
905 struct uvm_object *uobj = node->tn_spec.tn_reg.tn_aobj;
915 oldsize = node->tn_size;
918 KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages);
932 zerolen = MIN(round_page(newsize), node->tn_size) - newsize;
936 node->tn_spec.tn_reg.tn_aobj_pages = newpages;
937 node->tn_size = newsize;
960 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
973 * those on the node, we need special permission to change them.
975 if ((flags & SF_SETTABLE) != (node->tn_flags & SF_SETTABLE)) {
981 * Indicate that this node's flags have system attributes in them if
984 if (node->tn_flags & (SF_IMMUTABLE | SF_APPEND)) {
989 genfs_can_chflags(vp, cred, node->tn_uid, changing_sysflags));
1004 node->tn_flags &= SF_SETTABLE;
1005 node->tn_flags |= (flags & UF_SETTABLE);
1007 node->tn_flags = flags;
1019 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1029 if (node->tn_flags & (IMMUTABLE | APPEND))
1033 NULL, genfs_can_chmod(vp, cred, node->tn_uid, node->tn_gid, mode));
1037 node->tn_mode = (mode & ALLPERMS);
1039 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true);
1052 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1060 uid = node->tn_uid;
1063 gid = node->tn_gid;
1071 if (node->tn_flags & (IMMUTABLE | APPEND))
1075 NULL, genfs_can_chown(vp, cred, node->tn_uid, node->tn_gid, uid,
1080 node->tn_uid = uid;
1081 node->tn_gid = gid;
1083 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true);
1093 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1122 if (node->tn_flags & (IMMUTABLE | APPEND)) {
1131 if (node->tn_size != length &&
1147 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1157 if (node->tn_flags & (IMMUTABLE | APPEND))
1161 genfs_can_chtimes(vp, cred, node->tn_uid, vaflags));
1165 mutex_enter(&node->tn_timelock);
1167 atomic_and_uint(&node->tn_tflags, ~TMPFS_UPDATE_ATIME);
1168 node->tn_atime = *atime;
1171 atomic_and_uint(&node->tn_tflags, ~TMPFS_UPDATE_MTIME);
1172 node->tn_mtime = *mtime;
1175 node->tn_birthtime = *btime;
1177 mutex_exit(&node->tn_timelock);
1187 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1190 KASSERT(mutex_owned(&node->tn_timelock));
1192 if ((tflags |= atomic_swap_uint(&node->tn_tflags, 0)) == 0) {
1198 node->tn_atime = nowtm;
1201 node->tn_mtime = nowtm;
1204 node->tn_ctime = nowtm;
1214 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1216 if ((tflags | atomic_load_relaxed(&node->tn_tflags)) == 0) {
1220 mutex_enter(&node->tn_timelock);
1222 mutex_exit(&node->tn_timelock);
1231 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp);
1234 cur = atomic_load_relaxed(&node->tn_tflags);
1236 atomic_or_uint(&node->tn_tflags, tflags);