vfs_vnops.c (14424) | vfs_vnops.c (17761) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 |
39 * $Id: vfs_vnops.c,v 1.24 1996/03/02 03:45:05 dyson Exp $ | 39 * $Id: vfs_vnops.c,v 1.25 1996/03/09 06:42:15 dyson Exp $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/file.h> 46#include <sys/stat.h> 47#include <sys/buf.h> --- 109 unchanged lines hidden (view full) --- 157 error = VOP_SETATTR(vp, vap, cred, p); 158 if (error) 159 goto bad; 160 } 161 error = VOP_OPEN(vp, fmode, cred, p); 162 if (error) 163 goto bad; 164 /* | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/file.h> 46#include <sys/stat.h> 47#include <sys/buf.h> --- 109 unchanged lines hidden (view full) --- 157 error = VOP_SETATTR(vp, vap, cred, p); 158 if (error) 159 goto bad; 160 } 161 error = VOP_OPEN(vp, fmode, cred, p); 162 if (error) 163 goto bad; 164 /* |
165 * this is here for VMIO support | 165 * Make sure that a VM object is created for VMIO support. |
166 */ 167 if (vp->v_type == VREG) { | 166 */ 167 if (vp->v_type == VREG) { |
168 if ((error = vn_vmio_open(vp, p, cred)) != 0) | 168 if ((error = vfs_object_create(vp, p, cred, 1)) != 0) |
169 goto bad; 170 } | 169 goto bad; 170 } |
171 |
|
171 if (fmode & FWRITE) 172 vp->v_writecount++; 173 return (0); 174bad: 175 vput(vp); 176 return (error); 177} 178 --- 27 unchanged lines hidden (view full) --- 206 struct ucred *cred; 207 struct proc *p; 208{ 209 int error; 210 211 if (flags & FWRITE) 212 vp->v_writecount--; 213 error = VOP_CLOSE(vp, flags, cred, p); | 172 if (fmode & FWRITE) 173 vp->v_writecount++; 174 return (0); 175bad: 176 vput(vp); 177 return (error); 178} 179 --- 27 unchanged lines hidden (view full) --- 207 struct ucred *cred; 208 struct proc *p; 209{ 210 int error; 211 212 if (flags & FWRITE) 213 vp->v_writecount--; 214 error = VOP_CLOSE(vp, flags, cred, p); |
214 vn_vmio_close(vp); | 215 vrele(vp); |
215 return (error); 216} 217 218/* 219 * Package up an I/O request on a vnode into a uio and do it. 220 */ 221int 222vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) --- 234 unchanged lines hidden (view full) --- 457vn_closefile(fp, p) 458 struct file *fp; 459 struct proc *p; 460{ 461 462 return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, 463 fp->f_cred, p)); 464} | 216 return (error); 217} 218 219/* 220 * Package up an I/O request on a vnode into a uio and do it. 221 */ 222int 223vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) --- 234 unchanged lines hidden (view full) --- 458vn_closefile(fp, p) 459 struct file *fp; 460 struct proc *p; 461{ 462 463 return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, 464 fp->f_cred, p)); 465} |
465 466int 467vn_vmio_open(vp, p, cred) 468 struct vnode *vp; 469 struct proc *p; 470 struct ucred *cred; 471{ 472 struct vattr vat; 473 int error; 474 /* 475 * this is here for VMIO support 476 */ 477 if (vp->v_type == VREG || vp->v_type == VBLK) { 478retry: 479 if ((vp->v_flag & VVMIO) == 0) { 480 if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0) 481 return error; 482 (void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0); 483 vp->v_flag |= VVMIO; 484 } else { 485 vm_object_t object; 486 if ((object = vp->v_object) && 487 (object->flags & OBJ_DEAD)) { 488 VOP_UNLOCK(vp); 489 tsleep(object, PVM, "vodead", 0); 490 VOP_LOCK(vp); 491 goto retry; 492 } 493 if (!object) 494 panic("vn_open: VMIO object missing"); 495 vm_object_reference(object); 496 } 497 } 498 return 0; 499} 500 501void 502vn_vmio_close(vp) 503 struct vnode *vp; 504{ 505 /* 506 * this code is here for VMIO support, will eventually 507 * be in vfs code. 508 */ 509 if (vp->v_flag & VVMIO) { 510 vrele(vp); 511 if (vp->v_object == NULL) 512 panic("vn_close: VMIO object missing"); 513 vm_object_deallocate(vp->v_object); 514 } else 515 vrele(vp); 516} | |