+ if (ndp->ni_dvp)
+ iput(dp);
+ iput(ip);
+ return (error);
+}
+
+/*
+ * symlink -- make a symbolic link
+ */
+ufs_symlink(ndp, vap, target)
+ struct nameidata *ndp;
+ struct vattr *vap;
+ char *target;
+{
+ struct inode *ip;
+ int error;
+
+ error = maknode(IFLNK | vap->va_mode, ndp, &ip);
+ if (error)
+ return (error);
+ error = vn_rdwr(UIO_WRITE, ITOV(ip), target, strlen(target), (off_t)0,
+ UIO_SYSSPACE, IO_NODELOCKED, ndp->ni_cred, (int *)0);
+ iput(ip);
+ return (error);
+}
+
+/*
+ * Vnode op for read and write
+ */
+ufs_readdir(vp, uio, cred, eofflagp)
+ struct vnode *vp;
+ register struct uio *uio;
+ struct ucred *cred;
+ int *eofflagp;
+{
+ int count, lost, error;
+
+ count = uio->uio_resid;
+ count &= ~(DIRBLKSIZ - 1);
+ lost = uio->uio_resid - count;
+ if (count < DIRBLKSIZ || (uio->uio_offset & (DIRBLKSIZ -1)))
+ return (EINVAL);
+ uio->uio_resid = count;
+ uio->uio_iov->iov_len = count;
+ error = ufs_read(vp, uio, 0, cred);
+ uio->uio_resid += lost;
+ if ((VTOI(vp)->i_size - uio->uio_offset) <= 0)
+ *eofflagp = 1;
+ else
+ *eofflagp = 0;
+ return (error);
+}
+
+/*
+ * Return target name of a symbolic link
+ */
+ufs_readlink(vp, uiop, cred)
+ struct vnode *vp;
+ struct uio *uiop;
+ struct ucred *cred;
+{
+
+ return (ufs_read(vp, uiop, 0, cred));
+}
+
+/*
+ * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually
+ * done. Iff ni_vp/ni_dvp not null and locked, unlock.
+ */
+ufs_abortop(ndp)
+ register struct nameidata *ndp;
+{
+
+ if (ndp->ni_dvp) {
+ if (VOP_ISLOCKED(ndp->ni_dvp))
+ VOP_UNLOCK(ndp->ni_dvp);
+ vrele(ndp->ni_dvp);
+ }
+ if (ndp->ni_vp) {
+ if (VOP_ISLOCKED(ndp->ni_vp))
+ VOP_UNLOCK(ndp->ni_vp);
+ vrele(ndp->ni_vp);
+ }
+ return;
+}
+
+/*
+ * Lock an inode.
+ */
+ufs_lock(vp)
+ struct vnode *vp;
+{
+ register struct inode *ip = VTOI(vp);
+
+ ILOCK(ip);
+ return (0);
+}
+
+/*
+ * Unlock an inode.
+ */
+ufs_unlock(vp)
+ struct vnode *vp;
+{
+ register struct inode *ip = VTOI(vp);
+
+ if (!(ip->i_flag & ILOCKED))
+ panic("ufs_unlock NOT LOCKED");
+ IUNLOCK(ip);
+ return (0);
+}
+
+/*
+ * Check for a locked inode.
+ */
+ufs_islocked(vp)
+ struct vnode *vp;
+{
+
+ if (VTOI(vp)->i_flag & ILOCKED)
+ return (1);
+ return (0);
+}
+
+/*
+ * Get access to bmap
+ */
+ufs_bmap(vp, bn, vpp, bnp)
+ struct vnode *vp;
+ daddr_t bn;
+ struct vnode **vpp;
+ daddr_t *bnp;
+{
+ struct inode *ip = VTOI(vp);
+
+ if (vpp != NULL)
+ *vpp = ip->i_devvp;
+ if (bnp == NULL)
+ return (0);
+ return (bmap(ip, bn, bnp, (daddr_t *)0, (int *)0));
+}
+
+/*
+ * Just call the device strategy routine
+ */
+int checkoverlap = 1;
+
+ufs_strategy(bp)
+ register struct buf *bp;
+{
+ register struct inode *ip = VTOI(bp->b_vp);
+ register struct buf *ep;
+ struct vnode *vp;
+ struct buf *ebp;
+ daddr_t start, last;
+ int error;
+
+ if (bp->b_vp->v_type == VBLK || bp->b_vp->v_type == VCHR)
+ panic("ufs_strategy: spec");
+ if (bp->b_blkno == bp->b_lblkno) {
+ if (error = bmap(ip, bp->b_lblkno, &bp->b_blkno))
+ return (error);
+ if ((long)bp->b_blkno == -1)
+ clrbuf(bp);
+ }
+ if ((long)bp->b_blkno == -1) {
+ biodone(bp);
+ return (0);
+ }
+ if (checkoverlap) {
+ ebp = &buf[nbuf];
+ start = bp->b_blkno;
+ last = start + btodb(bp->b_bcount) - 1;
+ for (ep = buf; ep < ebp; ep++) {
+ if (ep == bp || (ep->b_flags & B_INVAL) ||
+ ep->b_vp == (struct vnode *)0)
+ continue;
+ if (VOP_BMAP(ep->b_vp, (daddr_t)0, &vp, (daddr_t)0))
+ continue;
+ if (vp != ip->i_devvp)
+ continue;
+ /* look for overlap */
+ if (ep->b_bcount == 0 || ep->b_blkno > last ||
+ ep->b_blkno + btodb(ep->b_bcount) <= start)
+ continue;
+ vprint("Disk overlap", vp);
+ printf("\tstart %d, end %d overlap start %d, end %d\n",
+ start, last, ep->b_blkno,
+ ep->b_blkno + btodb(ep->b_bcount) - 1);
+ }
+ }
+ vp = ip->i_devvp;
+ bp->b_dev = vp->v_rdev;
+ (*(vp->v_op->vn_strategy))(bp);
+ return (0);
+}
+
+/*
+ * Print out the contents of an inode.
+ */
+ufs_print(vp)
+ struct vnode *vp;
+{
+ register struct inode *ip = VTOI(vp);
+
+ printf("tag VT_UFS, ino %d, on dev %d, %d", ip->i_number,
+ major(ip->i_dev), minor(ip->i_dev));
+#ifdef FIFO
+ if (vp->v_type == VFIFO)
+ fifo_printinfo(vp);
+#endif /* FIFO */
+ printf("%s\n", (ip->i_flag & ILOCKED) ? " (LOCKED)" : "");
+ if (ip->i_spare0 == 0)
+ return;
+ printf("\towner pid %d", ip->i_spare0);
+ if (ip->i_spare1)
+ printf(" waiting pid %d", ip->i_spare1);
+ printf("\n");
+}
+
+/*
+ * Read wrapper for special devices.
+ */
+ufsspec_read(vp, uio, ioflag, cred)
+ struct vnode *vp;
+ struct uio *uio;
+ int ioflag;
+ struct ucred *cred;
+{
+
+ /*
+ * Set access flag.
+ */
+ VTOI(vp)->i_flag |= IACC;
+ return (spec_read(vp, uio, ioflag, cred));
+}
+
+/*
+ * Write wrapper for special devices.
+ */
+ufsspec_write(vp, uio, ioflag, cred)
+ struct vnode *vp;
+ struct uio *uio;
+ int ioflag;
+ struct ucred *cred;
+{
+
+ /*
+ * Set update and change flags.
+ */
+ VTOI(vp)->i_flag |= IUPD|ICHG;
+ return (spec_write(vp, uio, ioflag, cred));
+}
+
+/*
+ * Close wrapper for special devices.
+ *
+ * Update the times on the inode then do device close.
+ */
+ufsspec_close(vp, fflag, cred)
+ struct vnode *vp;
+ int fflag;
+ struct ucred *cred;
+{
+ register struct inode *ip = VTOI(vp);
+
+ if (vp->v_usecount > 1 && !(ip->i_flag & ILOCKED))
+ ITIMES(ip, &time, &time);
+ return (spec_close(vp, fflag, cred));
+}
+
+#ifdef FIFO
+/*
+ * Read wrapper for fifo's
+ */
+ufsfifo_read(vp, uio, ioflag, cred)
+ struct vnode *vp;
+ struct uio *uio;
+ int ioflag;
+ struct ucred *cred;
+{
+
+ /*
+ * Set access flag.
+ */
+ VTOI(vp)->i_flag |= IACC;
+ return (fifo_read(vp, uio, ioflag, cred));