/*
- * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
*
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
- * @(#)ufs_vnops.c 7.115 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ufs_vnops.c 8.1 (Berkeley) 6/11/93
*/
#include <sys/param.h>
} else {
if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND))
return (EPERM);
- ip->i_flags &= 0xffff0000;
- ip->i_flags |= (vap->va_flags & 0xffff);
+ ip->i_flags &= SF_SETTABLE;
+ ip->i_flags |= (vap->va_flags & UF_SETTABLE);
}
ip->i_flag |= ICHG;
if (vap->va_flags & (IMMUTABLE | APPEND))
if (vap->va_atime.ts_sec != VNOVAL || vap->va_mtime.ts_sec != VNOVAL) {
if (cred->cr_uid != ip->i_uid &&
(error = suser(cred, &p->p_acflag)) &&
- ((vap->va_cflags & VA_UTIMES_NULL) != 0 ||
+ ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
(error = VOP_ACCESS(vp, VWRITE, cred, p))))
return (error);
if (vap->va_atime.ts_sec != VNOVAL)
goto out;
if ((tcnp->cn_flags & SAVESTART) == 0)
panic("ufs_rename: lost to startdir");
- p->p_spare[1]--;
if (error = relookup(tdvp, &tvp, tcnp))
goto out;
dp = VTOI(tdvp);
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
if ((fcnp->cn_flags & SAVESTART) == 0)
panic("ufs_rename: lost from startdir");
- p->p_spare[1]--;
(void) relookup(fdvp, &fvp, fcnp);
if (fvp != NULL) {
xp = VTOI(fvp);
dmode = vap->va_mode & 0777;
dmode |= IFDIR;
/*
- * Must simulate part of maknode here to acquire the inode, but
- * not have it entered in the parent directory. The entry is made
- * later after writing "." and ".." entries.
+ * Must simulate part of ufs_makeinode here to acquire the inode,
+ * but not have it entered in the parent directory. The entry is
+ * made later after writing "." and ".." entries.
*/
if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp))
goto out;
* Calculate the logical to physical mapping if not done already,
* then call the device strategy routine.
*/
-int checkblk = 0;
int
ufs_strategy(ap)
struct vop_strategy_args /* {
register struct buf *bp = ap->a_bp;
register struct vnode *vp = bp->b_vp;
register struct inode *ip;
- daddr_t blkno;
int error;
ip = VTOI(vp);
if (vp->v_type == VBLK || vp->v_type == VCHR)
panic("ufs_strategy: spec");
- if ((checkblk && (long)bp->b_lblkno >= 0 &&
- (bp->b_flags & B_XXX) == 0) ||
- bp->b_blkno == bp->b_lblkno) {
- if (error = VOP_BMAP(vp, bp->b_lblkno, NULL, &blkno, NULL)) {
+ if (bp->b_blkno == bp->b_lblkno) {
+ if (error =
+ VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL)) {
bp->b_error = error;
bp->b_flags |= B_ERROR;
biodone(bp);
return (error);
}
- if (bp->b_blkno != bp->b_lblkno && bp->b_blkno != blkno &&
- !((bp->b_flags & B_READ) && (long)blkno == -1))
- panic("ufs_strategy: bad blkno %d != %d", bp->b_blkno,
- blkno);
- /* If this is a clustered block, check sub-blocks as well */
- if (bp->b_saveaddr) {
- struct buf *tbp;
- struct cluster_save *b_save = bp->b_saveaddr;
- int i;
- daddr_t bn;
- for (i = 0; i < b_save->bs_nchildren; i++) {
- tbp = b_save->bs_children[i];
- if ((tbp->b_flags & B_XXX) == 0 &&
- !VOP_BMAP(vp, tbp->b_lblkno, NULL,
- &bn, NULL) && tbp->b_blkno != bn)
- panic("ufs_strategy: bad bno %d != %d",
- bp->b_blkno, blkno);
- }
- }
- bp->b_blkno = blkno;
if ((long)bp->b_blkno == -1)
- if ((bp->b_flags & B_READ) == 0)
- panic("ufs_startegy: write unallocated block");
- else
- clrbuf(bp);
+ clrbuf(bp);
}
- bp->b_flags &=~ B_XXX;
if ((long)bp->b_blkno == -1) {
biodone(bp);
return (0);
}
#endif /* FIFO */
+/*
+ * Return POSIX pathconf information applicable to ufs filesystems.
+ */
+ufs_pathconf(ap)
+ struct vop_pathconf_args /* {
+ struct vnode *a_vp;
+ int a_name;
+ int *a_retval;
+ } */ *ap;
+{
+
+ switch (ap->a_name) {
+ case _PC_LINK_MAX:
+ *ap->a_retval = LINK_MAX;
+ return (0);
+ case _PC_NAME_MAX:
+ *ap->a_retval = NAME_MAX;
+ return (0);
+ case _PC_PATH_MAX:
+ *ap->a_retval = PATH_MAX;
+ return (0);
+ case _PC_PIPE_BUF:
+ *ap->a_retval = PIPE_BUF;
+ return (0);
+ case _PC_CHOWN_RESTRICTED:
+ *ap->a_retval = 1;
+ return (0);
+ case _PC_NO_TRUNC:
+ *ap->a_retval = 1;
+ return (0);
+ default:
+ return (EINVAL);
+ }
+ /* NOTREACHED */
+}
+
/*
* Advisory record locking support
*/
return (error);
}
ip = VTOI(tvp);
- ip->i_uid = cnp->cn_cred->cr_uid;
ip->i_gid = pdir->i_gid;
+ if ((mode & IFMT) == IFLNK)
+ ip->i_uid = pdir->i_uid;
+ else
+ ip->i_uid = cnp->cn_cred->cr_uid;
#ifdef QUOTA
if ((error = getinoquota(ip)) ||
(error = chkiq(ip, 1, cnp->cn_cred, 0))) {