Deleted Added
full compact
vfs_vnops.c (72200) vfs_vnops.c (72521)
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 72200 2001-02-09 06:11:45Z bmilekic $
39 * $FreeBSD: head/sys/kern/vfs_vnops.c 72521 2001-02-15 16:34:11Z jlemon $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/fcntl.h>
45#include <sys/file.h>
46#include <sys/stat.h>
47#include <sys/proc.h>
48#include <sys/mount.h>
49#include <sys/mutex.h>
50#include <sys/namei.h>
51#include <sys/vnode.h>
52#include <sys/bio.h>
53#include <sys/buf.h>
54#include <sys/filio.h>
55#include <sys/ttycom.h>
56#include <sys/conf.h>
57
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/fcntl.h>
45#include <sys/file.h>
46#include <sys/stat.h>
47#include <sys/proc.h>
48#include <sys/mount.h>
49#include <sys/mutex.h>
50#include <sys/namei.h>
51#include <sys/vnode.h>
52#include <sys/bio.h>
53#include <sys/buf.h>
54#include <sys/filio.h>
55#include <sys/ttycom.h>
56#include <sys/conf.h>
57
58#include <ufs/ufs/quota.h>
59#include <ufs/ufs/inode.h>
60
61static int vn_closefile __P((struct file *fp, struct proc *p));
62static int vn_ioctl __P((struct file *fp, u_long com, caddr_t data,
63 struct proc *p));
64static int vn_read __P((struct file *fp, struct uio *uio,
65 struct ucred *cred, int flags, struct proc *p));
66static int vn_poll __P((struct file *fp, int events, struct ucred *cred,
67 struct proc *p));
58static int vn_closefile __P((struct file *fp, struct proc *p));
59static int vn_ioctl __P((struct file *fp, u_long com, caddr_t data,
60 struct proc *p));
61static int vn_read __P((struct file *fp, struct uio *uio,
62 struct ucred *cred, int flags, struct proc *p));
63static int vn_poll __P((struct file *fp, int events, struct ucred *cred,
64 struct proc *p));
65static int vn_kqfilter __P((struct file *fp, struct knote *kn));
68static int vn_statfile __P((struct file *fp, struct stat *sb, struct proc *p));
69static int vn_write __P((struct file *fp, struct uio *uio,
70 struct ucred *cred, int flags, struct proc *p));
71
66static int vn_statfile __P((struct file *fp, struct stat *sb, struct proc *p));
67static int vn_write __P((struct file *fp, struct uio *uio,
68 struct ucred *cred, int flags, struct proc *p));
69
72struct fileops vnops =
73 { vn_read, vn_write, vn_ioctl, vn_poll, vn_statfile, vn_closefile };
74
75static int filt_nullattach(struct knote *kn);
76static int filt_vnattach(struct knote *kn);
77static void filt_vndetach(struct knote *kn);
78static int filt_vnode(struct knote *kn, long hint);
79static int filt_vnread(struct knote *kn, long hint);
80
81struct filterops vn_filtops =
82 { 1, filt_vnattach, filt_vndetach, filt_vnode };
83
84/*
85 * XXX
86 * filt_vnread is ufs-specific, so the attach routine should really
87 * switch out to different filterops based on the vn filetype
88 */
89struct filterops vn_rwfiltops[] = {
90 { 1, filt_vnattach, filt_vndetach, filt_vnread },
91 { 1, filt_nullattach, NULL, NULL },
70struct fileops vnops = {
71 vn_read, vn_write, vn_ioctl, vn_poll, vn_kqfilter,
72 vn_statfile, vn_closefile
92};
93
94/*
95 * Common code for vnode open operations.
96 * Check permissions, and call the VOP_OPEN or VOP_CREATE routine.
97 *
98 * Note that this does NOT free nameidata for the successful case,
99 * due to the NDINIT being done elsewhere.

--- 710 unchanged lines hidden (view full) ---

810 if ((mp->mnt_kern_flag & MNTK_SUSPEND) == 0)
811 return;
812 mp->mnt_kern_flag &= ~(MNTK_SUSPEND | MNTK_SUSPENDED);
813 wakeup(&mp->mnt_writeopcount);
814 wakeup(&mp->mnt_flag);
815}
816
817static int
73};
74
75/*
76 * Common code for vnode open operations.
77 * Check permissions, and call the VOP_OPEN or VOP_CREATE routine.
78 *
79 * Note that this does NOT free nameidata for the successful case,
80 * due to the NDINIT being done elsewhere.

--- 710 unchanged lines hidden (view full) ---

791 if ((mp->mnt_kern_flag & MNTK_SUSPEND) == 0)
792 return;
793 mp->mnt_kern_flag &= ~(MNTK_SUSPEND | MNTK_SUSPENDED);
794 wakeup(&mp->mnt_writeopcount);
795 wakeup(&mp->mnt_flag);
796}
797
798static int
818filt_vnattach(struct knote *kn)
799vn_kqfilter(struct file *fp, struct knote *kn)
819{
800{
820 struct vnode *vp;
821
801
822 if (kn->kn_fp->f_type != DTYPE_VNODE &&
823 kn->kn_fp->f_type != DTYPE_FIFO)
824 return (EBADF);
825
826 vp = (struct vnode *)kn->kn_fp->f_data;
827
828 /*
829 * XXX
830 * this is a hack simply to cause the filter attach to fail
831 * for non-ufs filesystems, until the support for them is done.
832 */
833 if ((vp)->v_tag != VT_UFS)
834 return (EOPNOTSUPP);
835
836 mtx_lock(&vp->v_pollinfo.vpi_lock);
837 SLIST_INSERT_HEAD(&vp->v_pollinfo.vpi_selinfo.si_note, kn, kn_selnext);
838 mtx_unlock(&vp->v_pollinfo.vpi_lock);
839
840 return (0);
802 return (VOP_KQFILTER(((struct vnode *)fp->f_data), kn));
841}
842
803}
804
843static void
844filt_vndetach(struct knote *kn)
845{
846 struct vnode *vp = (struct vnode *)kn->kn_fp->f_data;
847
848 mtx_lock(&vp->v_pollinfo.vpi_lock);
849 SLIST_REMOVE(&vp->v_pollinfo.vpi_selinfo.si_note,
850 kn, knote, kn_selnext);
851 mtx_unlock(&vp->v_pollinfo.vpi_lock);
852}
853
854static int
855filt_vnode(struct knote *kn, long hint)
856{
857
858 if (kn->kn_sfflags & hint)
859 kn->kn_fflags |= hint;
860 return (kn->kn_fflags != 0);
861}
862
863static int
864filt_nullattach(struct knote *kn)
865{
866 return (ENXIO);
867}
868
869/*ARGSUSED*/
870static int
871filt_vnread(struct knote *kn, long hint)
872{
873 struct vnode *vp = (struct vnode *)kn->kn_fp->f_data;
874 struct inode *ip = VTOI(vp);
875
876 kn->kn_data = ip->i_size - kn->kn_fp->f_offset;
877 return (kn->kn_data != 0);
878}
879
880/*
881 * Simplified in-kernel wrapper calls for extended attribute access.
882 * Both calls pass in a NULL credential, authorizing as "kernel" access.
883 * Set IO_NODELOCKED in ioflg if the vnode is already locked.
884 */
885int
886vn_extattr_get(struct vnode *vp, int ioflg, const char *attrname, int *buflen,
887 char *buf, struct proc *p)

--- 94 unchanged lines hidden ---
805/*
806 * Simplified in-kernel wrapper calls for extended attribute access.
807 * Both calls pass in a NULL credential, authorizing as "kernel" access.
808 * Set IO_NODELOCKED in ioflg if the vnode is already locked.
809 */
810int
811vn_extattr_get(struct vnode *vp, int ioflg, const char *attrname, int *buflen,
812 char *buf, struct proc *p)

--- 94 unchanged lines hidden ---