Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Apr 2010 10:47:54 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r207270 - stable/8/sys/kern
Message-ID:  <201004271047.o3RAlsfe085351@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Apr 27 10:47:54 2010
New Revision: 207270
URL: http://svn.freebsd.org/changeset/base/207270

Log:
  MFC r206547:
  Handle a case in kern_openat() when vn_open() change file type from
  DTYPE_VNODE.

Modified:
  stable/8/sys/kern/vfs_syscalls.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/8/sys/kern/vfs_syscalls.c	Tue Apr 27 09:48:43 2010	(r207269)
+++ stable/8/sys/kern/vfs_syscalls.c	Tue Apr 27 10:47:54 2010	(r207270)
@@ -1047,8 +1047,6 @@ kern_openat(struct thread *td, int fd, c
 	struct filedesc *fdp = p->p_fd;
 	struct file *fp;
 	struct vnode *vp;
-	struct vattr vat;
-	struct mount *mp;
 	int cmode;
 	struct file *nfp;
 	int type, indx, error;
@@ -1141,7 +1139,7 @@ kern_openat(struct thread *td, int fd, c
 	}
 
 	VOP_UNLOCK(vp, 0);
-	if (flags & (O_EXLOCK | O_SHLOCK)) {
+	if (fp->f_type == DTYPE_VNODE && (flags & (O_EXLOCK | O_SHLOCK)) != 0) {
 		lf.l_whence = SEEK_SET;
 		lf.l_start = 0;
 		lf.l_len = 0;
@@ -1158,18 +1156,7 @@ kern_openat(struct thread *td, int fd, c
 		atomic_set_int(&fp->f_flag, FHASLOCK);
 	}
 	if (flags & O_TRUNC) {
-		if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
-			goto bad;
-		VATTR_NULL(&vat);
-		vat.va_size = 0;
-		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-#ifdef MAC
-		error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp);
-		if (error == 0)
-#endif
-			error = VOP_SETATTR(vp, &vat, td->td_ucred);
-		VOP_UNLOCK(vp, 0);
-		vn_finished_write(mp);
+		error = fo_truncate(fp, 0, td->td_ucred, td);
 		if (error)
 			goto bad;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004271047.o3RAlsfe085351>