diff --git a/sys/fs/cd9660/cd9660_node.h b/sys/fs/cd9660/cd9660_node.h index e099763f8ab5..7d8fc813a787 100644 --- a/sys/fs/cd9660/cd9660_node.h +++ b/sys/fs/cd9660/cd9660_node.h @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_node.h,v 1.9 2005/11/02 12:38:58 yamt Exp $ */ +/* $NetBSD: cd9660_node.h,v 1.10 2005/11/11 15:50:57 yamt Exp $ */ /*- * Copyright (c) 1994 @@ -129,6 +129,7 @@ int cd9660_strategy(void *); int cd9660_print(void *); int cd9660_islocked(void *); int cd9660_pathconf(void *); +int cd9660_setattr(void *); int cd9660_blkatoff(struct vnode *, off_t, char **, struct buf **); void cd9660_defattr(struct iso_directory_record *, diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 8cadd320a9cd..c79a649c2c06 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vnops.c,v 1.16 2005/11/02 12:38:58 yamt Exp $ */ +/* $NetBSD: cd9660_vnops.c,v 1.17 2005/11/11 15:50:57 yamt Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.16 2005/11/02 12:38:58 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.17 2005/11/11 15:50:57 yamt Exp $"); #include #include @@ -836,6 +836,51 @@ cd9660_pathconf(v) /* NOTREACHED */ } +/* + * Allow changing the size for special files (and fifos). + */ +int +cd9660_setattr(v) + void *v; +{ + struct vop_setattr_args /* { + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + struct ucred *a_cred; + struct proc *a_p; + } */ *ap = v; + struct vattr *vap = ap->a_vap; + struct vnode *vp = ap->a_vp; + + /* + * Only size is changeable. + */ + if (vap->va_type != VNON + || vap->va_nlink != (nlink_t)VNOVAL + || vap->va_fsid != VNOVAL + || vap->va_fileid != VNOVAL + || vap->va_blocksize != VNOVAL + || vap->va_rdev != (dev_t)VNOVAL + || (int)vap->va_bytes != VNOVAL + || vap->va_gen != VNOVAL + || vap->va_flags != VNOVAL + || vap->va_uid != (uid_t)VNOVAL + || vap->va_gid != (gid_t)VNOVAL + || vap->va_atime.tv_sec != VNOVAL + || vap->va_mtime.tv_sec != VNOVAL + || vap->va_mode != (mode_t)VNOVAL) + return EOPNOTSUPP; + + if (vap->va_size != VNOVAL + && vp->v_type != VCHR + && vp->v_type != VBLK + && vp->v_type != VFIFO) + return EOPNOTSUPP; + + return 0; +} + /* * Global vfs data structures for isofs */ @@ -851,7 +896,6 @@ cd9660_pathconf(v) #define cd9660_advlock genfs_einval #define cd9660_bwrite genfs_eopnotsupp #define cd9660_revoke genfs_revoke -#define cd9660_setattr genfs_eopnotsupp /* * Global vfs data structures for cd9660 diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index e1eb9ef365e5..9e7a0ecd9668 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.13 2005/11/08 23:04:03 yamt Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.14 2005/11/11 15:50:57 yamt Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.13 2005/11/08 23:04:03 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.14 2005/11/11 15:50:57 yamt Exp $"); #include #include @@ -1141,8 +1141,6 @@ tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred, case VDIR: return EISDIR; - case VLNK: - /* FALLTHROUGH */ case VREG: if (vp->v_mount->mnt_flag & MNT_RDONLY) return EROFS; @@ -1152,17 +1150,15 @@ tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred, /* FALLTHROUGH */ case VCHR: /* FALLTHROUGH */ - case VSOCK: - /* FALLTHROUGH */ case VFIFO: /* 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). */ - break; + return 0; default: /* Anything else is unsupported. */ - return EINVAL; + return EOPNOTSUPP; } /* Immutable or append-only files cannot be modified, either. */ diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index bd3d749d09fe..caca35ebc456 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_inode.c,v 1.50 2005/11/02 12:39:00 yamt Exp $ */ +/* $NetBSD: ext2fs_inode.c,v 1.51 2005/11/11 15:50:57 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.50 2005/11/02 12:39:00 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.51 2005/11/11 15:50:57 yamt Exp $"); #include #include @@ -262,6 +262,11 @@ ext2fs_truncate(struct vnode *ovp, off_t length, int ioflag, int sync; struct ufsmount *ump = oip->i_ump; + if (ovp->v_type == VCHR || ovp->v_type == VBLK || + ovp->v_type == VFIFO || ovp->v_type == VSOCK) { + return 0; + } + if (length < 0) return (EINVAL); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 36b8fb5116f1..4b94f92d02d7 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.77 2005/11/02 12:39:00 yamt Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.78 2005/11/11 15:50:57 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.77 2005/11/02 12:39:00 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.78 2005/11/11 15:50:57 yamt Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -180,6 +180,12 @@ ffs_truncate(struct vnode *ovp, off_t length, int ioflag, struct ucred *cred, int sync; struct ufsmount *ump = oip->i_ump; + if (ovp->v_type == VCHR || ovp->v_type == VBLK || + ovp->v_type == VFIFO || ovp->v_type == VSOCK) { + KASSERT(oip->i_size == 0); + return 0; + } + if (length < 0) return (EINVAL); diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index aa1abd668895..91aac47fe8d3 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_inode.c,v 1.98 2005/11/02 12:39:14 yamt Exp $ */ +/* $NetBSD: lfs_inode.c,v 1.99 2005/11/11 15:50:57 yamt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.98 2005/11/02 12:39:14 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.99 2005/11/11 15:50:57 yamt Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -223,6 +223,12 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, int usepc; struct ufsmount *ump = oip->i_ump; + if (ovp->v_type == VCHR || ovp->v_type == VBLK || + ovp->v_type == VFIFO || ovp->v_type == VSOCK) { + KASSERT(oip->i_size == 0); + return 0; + } + if (length < 0) return (EINVAL); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 40df087da761..fb07e4465cea 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.136 2005/11/02 12:39:14 yamt Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.137 2005/11/11 15:50:57 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993, 1995 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.136 2005/11/02 12:39:14 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.137 2005/11/11 15:50:57 yamt Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -435,19 +435,22 @@ ufs_setattr(void *v) switch (vp->v_type) { case VDIR: return (EISDIR); - case VLNK: + case VCHR: + case VBLK: + case VFIFO: + break; case VREG: if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if ((ip->i_flags & SF_SNAPSHOT) != 0) return (EPERM); + error = UFS_TRUNCATE(vp, vap->va_size, 0, cred, p); + if (error) + return (error); break; default: - break; + return (EOPNOTSUPP); } - error = UFS_TRUNCATE(vp, vap->va_size, 0, cred, p); - if (error) - return (error); } ip = VTOI(vp); if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL ||