diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -120,7 +120,8 @@ */ if (vp == NULL) { KASSERT((object->flags & OBJ_TMPFS_VREF) == 0, - ("object %p with OBJ_TMPFS_VREF but without vnode", object)); + ("object %p with OBJ_TMPFS_VREF but without vnode", + object)); VM_OBJECT_WUNLOCK(object); return; } @@ -131,7 +132,8 @@ VNPASS(vp->v_usecount > 0, vp); } else { VNASSERT((object->flags & OBJ_TMPFS_VREF) != 0, vp, - ("object with writable mappings does not have a reference")); + ("object with writable mappings does not " + "have a reference")); } if (old == new) { @@ -534,11 +536,13 @@ symlink = NULL; if (!tmp->tm_nonc) { - symlink = cache_symlink_alloc(nnode->tn_size + 1, M_WAITOK); + symlink = cache_symlink_alloc(nnode->tn_size + 1, + M_WAITOK); symlink_smr = true; } if (symlink == NULL) { - symlink = malloc(nnode->tn_size + 1, M_TMPFSNAME, M_WAITOK); + symlink = malloc(nnode->tn_size + 1, M_TMPFSNAME, + M_WAITOK); symlink_smr = false; } memcpy(symlink, target, nnode->tn_size + 1); @@ -550,14 +554,15 @@ * 1. nnode is not yet visible to the world * 2. both tn_link_target and tn_link_smr get populated * 3. release fence publishes their content - * 4. tn_link_target content is immutable until node destruction, - * where the pointer gets set to NULL + * 4. tn_link_target content is immutable until node + * destruction, where the pointer gets set to NULL * 5. tn_link_smr is never changed once set * - * As a result it is sufficient to issue load consume on the node - * pointer to also get the above content in a stable manner. - * Worst case tn_link_smr flag may be set to true despite being stale, - * while the target buffer is already cleared out. + * As a result it is sufficient to issue load consume + * on the node pointer to also get the above content + * in a stable manner. Worst case tn_link_smr flag + * may be set to true despite being stale, while the + * target buffer is already cleared out. */ atomic_store_ptr(&nnode->tn_link_target, symlink); atomic_store_char((char *)&nnode->tn_link_smr, symlink_smr); @@ -635,9 +640,10 @@ MPASS((node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0); /* - * Make sure this is a node type we can deal with. Everything is explicitly - * enumerated without the 'default' clause so the compiler can throw an - * error in case a new type is added. + * Make sure this is a node type we can deal with. Everything + * is explicitly enumerated without the 'default' clause so + * the compiler can throw an error in case a new type is + * added. */ switch (node->tn_type) { case VBLK: @@ -651,17 +657,16 @@ case VNON: case VBAD: case VMARKER: - panic("%s: bad type %d for node %p", __func__, (int)node->tn_type, node); + panic("%s: bad type %d for node %p", __func__, + (int)node->tn_type, node); } #endif switch (node->tn_type) { case VREG: uobj = node->tn_reg.tn_aobj; - if (uobj != NULL) { - if (uobj->size != 0) - atomic_subtract_long(&tmp->tm_pages_used, uobj->size); - } + if (uobj != NULL && uobj->size != 0) + atomic_subtract_long(&tmp->tm_pages_used, uobj->size); tmpfs_free_tmp(tmp); @@ -1882,7 +1887,7 @@ */ int tmpfs_chflags(struct vnode *vp, u_long flags, struct ucred *cred, - struct thread *p) + struct thread *td) { int error; struct tmpfs_node *node; @@ -1905,7 +1910,7 @@ * Callers may only modify the file flags on objects they * have VADMIN rights for. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* * Unprivileged processes are not permitted to unset system @@ -1938,7 +1943,8 @@ * The vnode must be locked on entry and remain locked on exit. */ int -tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, struct thread *p) +tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, + struct thread *td) { int error; struct tmpfs_node *node; @@ -1961,7 +1967,7 @@ * To modify the permissions on a file, must possess VADMIN * for that file. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* @@ -1999,7 +2005,7 @@ */ int tmpfs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred, - struct thread *p) + struct thread *td) { int error; struct tmpfs_node *node; @@ -2032,7 +2038,7 @@ * To modify the ownership of a file, must possess VADMIN for that * file. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* @@ -2053,7 +2059,8 @@ node->tn_status |= TMPFS_NODE_CHANGED; - if ((node->tn_mode & (S_ISUID | S_ISGID)) && (ouid != uid || ogid != gid)) { + if ((node->tn_mode & (S_ISUID | S_ISGID)) != 0 && + (ouid != uid || ogid != gid)) { if (priv_check_cred(cred, PRIV_VFS_RETAINSUGID)) { newmode = node->tn_mode & ~(S_ISUID | S_ISGID); atomic_store_short(&node->tn_mode, newmode); @@ -2072,7 +2079,7 @@ */ int tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred, - struct thread *p) + struct thread *td) { int error; struct tmpfs_node *node; @@ -2131,7 +2138,7 @@ */ int tmpfs_chtimes(struct vnode *vp, struct vattr *vap, - struct ucred *cred, struct thread *l) + struct ucred *cred, struct thread *td) { int error; struct tmpfs_node *node; @@ -2148,21 +2155,17 @@ if (node->tn_flags & (IMMUTABLE | APPEND)) return (EPERM); - error = vn_utimes_perm(vp, vap, cred, l); + error = vn_utimes_perm(vp, vap, cred, td); if (error != 0) return (error); if (vap->va_atime.tv_sec != VNOVAL) node->tn_accessed = true; - if (vap->va_mtime.tv_sec != VNOVAL) node->tn_status |= TMPFS_NODE_MODIFIED; - if (vap->va_birthtime.tv_sec != VNOVAL) node->tn_status |= TMPFS_NODE_MODIFIED; - tmpfs_itimes(vp, &vap->va_atime, &vap->va_mtime); - if (vap->va_birthtime.tv_sec != VNOVAL) node->tn_birthtime = vap->va_birthtime; ASSERT_VOP_ELOCKED(vp, "chtimes2");