FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Change size of the given vnode.
 * Caller should execute tmpfs_update on vp after a successful execution.
 * The vnode must be locked on entry and remain locked on exit.
 */
Change size of the given vnode.
Caller should execute tmpfs_update on vp after a successful execution.
The vnode must be locked on entry and remain locked on exit.
Change size of the given vnode . Caller should execute tmpfs_update on vp after a successful execution . The vnode must be locked on entry and remain locked on exit .
int
tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred,
    struct thread *p)
{
	int error;
	struct tmpfs_node *node;
	MPASS(VOP_ISLOCKED(vp));
	node = VP_TO_TMPFS_NODE(vp);
	error = 0;
	switch (vp->v_type) {
	case VDIR:
		return EISDIR;
	case VREG:
		if (vp->v_mount->mnt_flag & MNT_RDONLY)
			return EROFS;
		break;
	case VBLK:
	case VCHR:
	case VFIFO:
		return 0;
	default:
		return EOPNOTSUPP;
	}
	if (node->tn_flags & (IMMUTABLE | APPEND))
		return EPERM;
	error = tmpfs_truncate(vp, size);
	MPASS(VOP_ISLOCKED(vp));
	return error;
}
int tmpfs_chsize ( struct vnode * vp , u_quad_t size , struct ucred * cred , struct thread * p ) { int error ; struct tmpfs_node * node ; MPASS ( VOP_ISLOCKED ( vp ) ) ; node = VP_TO_TMPFS_NODE ( vp ) ; error = 0 ; switch ( vp -> v_type ) { case VDIR : return EISDIR ; case VREG : if ( vp -> v_mount -> mnt_flag & MNT_RDONLY ) return EROFS ; break ; case VBLK : case VCHR : case VFIFO : return 0 ; default : return EOPNOTSUPP ; } if ( node -> tn_flags & ( IMMUTABLE | APPEND ) ) return EPERM ; error = tmpfs_truncate ( vp , size ) ; MPASS ( VOP_ISLOCKED ( vp ) ) ; return error ; }
Change size of the given vnode.
Change size of the given vnode .
/* Decide whether this is a valid operation based on the file type. */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* Allow modifications of special files even if in the file
		 * system is mounted read-only (we are not modifying the
		 * files themselves, but the objects they represent). */ /* Anything else is unsupported. */ /* Immutable or append-only files cannot be modified, either. */ /* tmpfs_truncate will raise the NOTE_EXTEND and NOTE_ATTRIB kevents
	 * for us, as will update tn_status; no need to do that here. */