xref: /netbsd-src/sys/miscfs/genfs/genfs_vnops.c (revision d0fed6c87ddc40a8bffa6f99e7433ddfc864dd83)
1 #include <sys/param.h>
2 #include <sys/systm.h>
3 #include <sys/kernel.h>
4 #include <sys/mount.h>
5 #include <sys/namei.h>
6 #include <sys/vnode.h>
7 #include <sys/malloc.h>
8 #include <sys/poll.h>
9 
10 #include <miscfs/genfs/genfs.h>
11 
12 int
13 genfs_poll(v)
14 	void *v;
15 {
16 	struct vop_poll_args /* {
17 		struct vnode *a_vp;
18 		int a_events;
19 		struct proc *a_p;
20 	} */ *ap = v;
21 
22 	return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
23 }
24 
25 int
26 genfs_fsync(v)
27 	void *v;
28 {
29 	struct vop_fsync_args /* {
30 		struct vnode *a_vp;
31 		struct ucred *a_cred;
32 		int a_waitfor;
33 		struct proc *a_p;
34 	} */ *ap = v;
35 	register struct vnode *vp = ap->a_vp;
36 	struct timespec ts;
37 
38 	vflushbuf(vp, ap->a_waitfor == MNT_WAIT);
39 	TIMEVAL_TO_TIMESPEC(&time, &ts);
40 	return (VOP_UPDATE(ap->a_vp, &ts, &ts, ap->a_waitfor == MNT_WAIT));
41 }
42 
43 int
44 genfs_seek(v)
45 	void *v;
46 {
47 	struct vop_seek_args /* {
48 		struct vnode *a_vp;
49 		off_t a_oldoff;
50 		off_t a_newoff;
51 		struct ucred *a_ucred;
52 	} */ *ap = v;
53 
54 	if (ap->a_newoff < 0)
55 		return (EINVAL);
56 
57 	return (0);
58 }
59 
60 int
61 genfs_abortop(v)
62 	void *v;
63 {
64 	struct vop_abortop_args /* {
65 		struct vnode *a_dvp;
66 		struct componentname *a_cnp;
67 	} */ *ap = v;
68 
69 	if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
70 		FREE(ap->a_cnp->cn_pnbuf, M_NAMEI);
71 	return (0);
72 }
73 
74 /*ARGSUSED*/
75 int
76 genfs_badop(v)
77 	void *v;
78 {
79 
80 	panic("genfs: bad op");
81 }
82 
83 /*ARGSUSED*/
84 int
85 genfs_nullop(v)
86 	void *v;
87 {
88 
89 	return (0);
90 }
91 
92 /*ARGSUSED*/
93 int
94 genfs_eopnotsupp(v)
95 	void *v;
96 {
97 
98 	return (EOPNOTSUPP);
99 }
100 
101 /*ARGSUSED*/
102 int
103 genfs_ebadf(v)
104 	void *v;
105 {
106 
107 	return (EBADF);
108 }
109