vfs_vnops.c (1542) | vfs_vnops.c (1549) |
---|---|
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. --- 46 unchanged lines hidden (view full) --- 55 56struct fileops vnops = 57 { vn_read, vn_write, vn_ioctl, vn_select, vn_closefile }; 58 59/* 60 * Common code for vnode open operations. 61 * Check permissions, and call the VOP_OPEN or VOP_CREATE routine. 62 */ | 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. --- 46 unchanged lines hidden (view full) --- 55 56struct fileops vnops = 57 { vn_read, vn_write, vn_ioctl, vn_select, vn_closefile }; 58 59/* 60 * Common code for vnode open operations. 61 * Check permissions, and call the VOP_OPEN or VOP_CREATE routine. 62 */ |
63int |
|
63vn_open(ndp, fmode, cmode) 64 register struct nameidata *ndp; 65 int fmode, cmode; 66{ 67 register struct vnode *vp; 68 register struct proc *p = ndp->ni_cnd.cn_proc; 69 register struct ucred *cred = p->p_ucred; 70 struct vattr vat; --- 76 unchanged lines hidden (view full) --- 147 return (error); 148} 149 150/* 151 * Check for write permissions on the specified vnode. 152 * The read-only status of the file system is checked. 153 * Also, prototype text segments cannot be written. 154 */ | 64vn_open(ndp, fmode, cmode) 65 register struct nameidata *ndp; 66 int fmode, cmode; 67{ 68 register struct vnode *vp; 69 register struct proc *p = ndp->ni_cnd.cn_proc; 70 register struct ucred *cred = p->p_ucred; 71 struct vattr vat; --- 76 unchanged lines hidden (view full) --- 148 return (error); 149} 150 151/* 152 * Check for write permissions on the specified vnode. 153 * The read-only status of the file system is checked. 154 * Also, prototype text segments cannot be written. 155 */ |
156int |
|
155vn_writechk(vp) 156 register struct vnode *vp; 157{ 158 159 /* 160 * Disallow write attempts on read-only file systems; 161 * unless the file is a socket or a block or character 162 * device resident on the file system. --- 12 unchanged lines hidden (view full) --- 175 if ((vp->v_flag & VTEXT) && !vnode_pager_uncache(vp)) 176 return (ETXTBSY); 177 return (0); 178} 179 180/* 181 * Vnode close call 182 */ | 157vn_writechk(vp) 158 register struct vnode *vp; 159{ 160 161 /* 162 * Disallow write attempts on read-only file systems; 163 * unless the file is a socket or a block or character 164 * device resident on the file system. --- 12 unchanged lines hidden (view full) --- 177 if ((vp->v_flag & VTEXT) && !vnode_pager_uncache(vp)) 178 return (ETXTBSY); 179 return (0); 180} 181 182/* 183 * Vnode close call 184 */ |
185int |
|
183vn_close(vp, flags, cred, p) 184 register struct vnode *vp; 185 int flags; 186 struct ucred *cred; 187 struct proc *p; 188{ 189 int error; 190 191 if (flags & FWRITE) 192 vp->v_writecount--; 193 error = VOP_CLOSE(vp, flags, cred, p); 194 vrele(vp); 195 return (error); 196} 197 198/* 199 * Package up an I/O request on a vnode into a uio and do it. 200 */ | 186vn_close(vp, flags, cred, p) 187 register struct vnode *vp; 188 int flags; 189 struct ucred *cred; 190 struct proc *p; 191{ 192 int error; 193 194 if (flags & FWRITE) 195 vp->v_writecount--; 196 error = VOP_CLOSE(vp, flags, cred, p); 197 vrele(vp); 198 return (error); 199} 200 201/* 202 * Package up an I/O request on a vnode into a uio and do it. 203 */ |
204int |
|
201vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) 202 enum uio_rw rw; 203 struct vnode *vp; 204 caddr_t base; 205 int len; 206 off_t offset; 207 enum uio_seg segflg; 208 int ioflg; --- 29 unchanged lines hidden (view full) --- 238 if ((ioflg & IO_NODELOCKED) == 0) 239 VOP_UNLOCK(vp); 240 return (error); 241} 242 243/* 244 * File table vnode read routine. 245 */ | 205vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) 206 enum uio_rw rw; 207 struct vnode *vp; 208 caddr_t base; 209 int len; 210 off_t offset; 211 enum uio_seg segflg; 212 int ioflg; --- 29 unchanged lines hidden (view full) --- 242 if ((ioflg & IO_NODELOCKED) == 0) 243 VOP_UNLOCK(vp); 244 return (error); 245} 246 247/* 248 * File table vnode read routine. 249 */ |
250int |
|
246vn_read(fp, uio, cred) 247 struct file *fp; 248 struct uio *uio; 249 struct ucred *cred; 250{ 251 register struct vnode *vp = (struct vnode *)fp->f_data; 252 int count, error; 253 --- 6 unchanged lines hidden (view full) --- 260 fp->f_offset += count - uio->uio_resid; 261 VOP_UNLOCK(vp); 262 return (error); 263} 264 265/* 266 * File table vnode write routine. 267 */ | 251vn_read(fp, uio, cred) 252 struct file *fp; 253 struct uio *uio; 254 struct ucred *cred; 255{ 256 register struct vnode *vp = (struct vnode *)fp->f_data; 257 int count, error; 258 --- 6 unchanged lines hidden (view full) --- 265 fp->f_offset += count - uio->uio_resid; 266 VOP_UNLOCK(vp); 267 return (error); 268} 269 270/* 271 * File table vnode write routine. 272 */ |
273int |
|
268vn_write(fp, uio, cred) 269 struct file *fp; 270 struct uio *uio; 271 struct ucred *cred; 272{ 273 register struct vnode *vp = (struct vnode *)fp->f_data; 274 int count, error, ioflag = 0; 275 --- 12 unchanged lines hidden (view full) --- 288 fp->f_offset += count - uio->uio_resid; 289 VOP_UNLOCK(vp); 290 return (error); 291} 292 293/* 294 * File table vnode stat routine. 295 */ | 274vn_write(fp, uio, cred) 275 struct file *fp; 276 struct uio *uio; 277 struct ucred *cred; 278{ 279 register struct vnode *vp = (struct vnode *)fp->f_data; 280 int count, error, ioflag = 0; 281 --- 12 unchanged lines hidden (view full) --- 294 fp->f_offset += count - uio->uio_resid; 295 VOP_UNLOCK(vp); 296 return (error); 297} 298 299/* 300 * File table vnode stat routine. 301 */ |
302int |
|
296vn_stat(vp, sb, p) 297 struct vnode *vp; 298 register struct stat *sb; 299 struct proc *p; 300{ 301 struct vattr vattr; 302 register struct vattr *vap; 303 int error; --- 48 unchanged lines hidden (view full) --- 352 sb->st_gen = vap->va_gen; 353 sb->st_blocks = vap->va_bytes / S_BLKSIZE; 354 return (0); 355} 356 357/* 358 * File table vnode ioctl routine. 359 */ | 303vn_stat(vp, sb, p) 304 struct vnode *vp; 305 register struct stat *sb; 306 struct proc *p; 307{ 308 struct vattr vattr; 309 register struct vattr *vap; 310 int error; --- 48 unchanged lines hidden (view full) --- 359 sb->st_gen = vap->va_gen; 360 sb->st_blocks = vap->va_bytes / S_BLKSIZE; 361 return (0); 362} 363 364/* 365 * File table vnode ioctl routine. 366 */ |
367int |
|
360vn_ioctl(fp, com, data, p) 361 struct file *fp; 362 int com; 363 caddr_t data; 364 struct proc *p; 365{ 366 register struct vnode *vp = ((struct vnode *)fp->f_data); 367 struct vattr vattr; --- 26 unchanged lines hidden (view full) --- 394 } 395 return (error); 396 } 397} 398 399/* 400 * File table vnode select routine. 401 */ | 368vn_ioctl(fp, com, data, p) 369 struct file *fp; 370 int com; 371 caddr_t data; 372 struct proc *p; 373{ 374 register struct vnode *vp = ((struct vnode *)fp->f_data); 375 struct vattr vattr; --- 26 unchanged lines hidden (view full) --- 402 } 403 return (error); 404 } 405} 406 407/* 408 * File table vnode select routine. 409 */ |
410int |
|
402vn_select(fp, which, p) 403 struct file *fp; 404 int which; 405 struct proc *p; 406{ 407 408 return (VOP_SELECT(((struct vnode *)fp->f_data), which, fp->f_flag, 409 fp->f_cred, p)); 410} 411 412/* 413 * File table vnode close routine. 414 */ | 411vn_select(fp, which, p) 412 struct file *fp; 413 int which; 414 struct proc *p; 415{ 416 417 return (VOP_SELECT(((struct vnode *)fp->f_data), which, fp->f_flag, 418 fp->f_cred, p)); 419} 420 421/* 422 * File table vnode close routine. 423 */ |
424int |
|
415vn_closefile(fp, p) 416 struct file *fp; 417 struct proc *p; 418{ 419 420 return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, 421 fp->f_cred, p)); 422} | 425vn_closefile(fp, p) 426 struct file *fp; 427 struct proc *p; 428{ 429 430 return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, 431 fp->f_cred, p)); 432} |