vfs_vnops.c (101983) | vfs_vnops.c (102003) |
---|---|
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 * $FreeBSD: head/sys/kern/vfs_vnops.c 101983 2002-08-16 12:52:03Z rwatson $ | 39 * $FreeBSD: head/sys/kern/vfs_vnops.c 102003 2002-08-17 02:36:16Z rwatson $ |
40 */ 41 42#include "opt_mac.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/fcntl.h> 47#include <sys/file.h> --- 12 unchanged lines hidden (view full) --- 60#include <sys/ttycom.h> 61#include <sys/conf.h> 62#include <sys/syslog.h> 63 64#include <machine/limits.h> 65 66static int vn_closefile(struct file *fp, struct thread *td); 67static int vn_ioctl(struct file *fp, u_long com, void *data, | 40 */ 41 42#include "opt_mac.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/fcntl.h> 47#include <sys/file.h> --- 12 unchanged lines hidden (view full) --- 60#include <sys/ttycom.h> 61#include <sys/conf.h> 62#include <sys/syslog.h> 63 64#include <machine/limits.h> 65 66static int vn_closefile(struct file *fp, struct thread *td); 67static int vn_ioctl(struct file *fp, u_long com, void *data, |
68 struct thread *td); | 68 struct ucred *active_cred, struct thread *td); |
69static int vn_read(struct file *fp, struct uio *uio, 70 struct ucred *active_cred, int flags, struct thread *td); 71static int vn_poll(struct file *fp, int events, struct ucred *active_cred, 72 struct thread *td); 73static int vn_kqfilter(struct file *fp, struct knote *kn); 74static int vn_statfile(struct file *fp, struct stat *sb, 75 struct ucred *active_cred, struct thread *td); 76static int vn_write(struct file *fp, struct uio *uio, --- 639 unchanged lines hidden (view full) --- 716#endif 717 return (0); 718} 719 720/* 721 * File table vnode ioctl routine. 722 */ 723static int | 69static int vn_read(struct file *fp, struct uio *uio, 70 struct ucred *active_cred, int flags, struct thread *td); 71static int vn_poll(struct file *fp, int events, struct ucred *active_cred, 72 struct thread *td); 73static int vn_kqfilter(struct file *fp, struct knote *kn); 74static int vn_statfile(struct file *fp, struct stat *sb, 75 struct ucred *active_cred, struct thread *td); 76static int vn_write(struct file *fp, struct uio *uio, --- 639 unchanged lines hidden (view full) --- 716#endif 717 return (0); 718} 719 720/* 721 * File table vnode ioctl routine. 722 */ 723static int |
724vn_ioctl(fp, com, data, td) | 724vn_ioctl(fp, com, data, active_cred, td) |
725 struct file *fp; 726 u_long com; 727 void *data; | 725 struct file *fp; 726 u_long com; 727 void *data; |
728 struct ucred *active_cred; |
|
728 struct thread *td; 729{ 730 register struct vnode *vp = ((struct vnode *)fp->f_data); 731 struct vnode *vpold; 732 struct vattr vattr; 733 int error; 734 735 switch (vp->v_type) { 736 737 case VREG: 738 case VDIR: 739 if (com == FIONREAD) { 740 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); | 729 struct thread *td; 730{ 731 register struct vnode *vp = ((struct vnode *)fp->f_data); 732 struct vnode *vpold; 733 struct vattr vattr; 734 int error; 735 736 switch (vp->v_type) { 737 738 case VREG: 739 case VDIR: 740 if (com == FIONREAD) { 741 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); |
741 error = VOP_GETATTR(vp, &vattr, td->td_ucred, td); | 742 error = VOP_GETATTR(vp, &vattr, active_cred, td); |
742 VOP_UNLOCK(vp, 0, td); 743 if (error) 744 return (error); 745 *(int *)data = vattr.va_size - fp->f_offset; 746 return (0); 747 } 748 if (com == FIONBIO || com == FIOASYNC) /* XXX */ 749 return (0); /* XXX */ --- 7 unchanged lines hidden (view full) --- 757 case VCHR: 758 case VBLK: 759 if (com == FIODTYPE) { 760 if (vp->v_type != VCHR && vp->v_type != VBLK) 761 return (ENOTTY); 762 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK; 763 return (0); 764 } | 743 VOP_UNLOCK(vp, 0, td); 744 if (error) 745 return (error); 746 *(int *)data = vattr.va_size - fp->f_offset; 747 return (0); 748 } 749 if (com == FIONBIO || com == FIOASYNC) /* XXX */ 750 return (0); /* XXX */ --- 7 unchanged lines hidden (view full) --- 758 case VCHR: 759 case VBLK: 760 if (com == FIODTYPE) { 761 if (vp->v_type != VCHR && vp->v_type != VBLK) 762 return (ENOTTY); 763 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK; 764 return (0); 765 } |
765 error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_ucred, td); | 766 error = VOP_IOCTL(vp, com, data, fp->f_flag, active_cred, td); |
766 if (error == 0 && com == TIOCSCTTY) { 767 768 /* Do nothing if reassigning same control tty */ 769 sx_slock(&proctree_lock); 770 if (td->td_proc->p_session->s_ttyvp == vp) { 771 sx_sunlock(&proctree_lock); 772 return (0); 773 } --- 356 unchanged lines hidden --- | 767 if (error == 0 && com == TIOCSCTTY) { 768 769 /* Do nothing if reassigning same control tty */ 770 sx_slock(&proctree_lock); 771 if (td->td_proc->p_session->s_ttyvp == vp) { 772 sx_sunlock(&proctree_lock); 773 return (0); 774 } --- 356 unchanged lines hidden --- |