Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
[dragonfly.git] / sys / vfs / hammer2 / hammer2_vnops.c
CommitLineData
703720e4
MD
1#include <sys/param.h>
2#include <sys/systm.h>
3#include <sys/kernel.h>
4#include <sys/fcntl.h>
5#include <sys/buf.h>
6#include <sys/proc.h>
7#include <sys/namei.h>
8#include <sys/mount.h>
9#include <sys/vnode.h>
f0206a67 10#include <sys/mountctl.h>
703720e4
MD
11
12#include "hammer2.h"
13
14
15/*
16 * Last reference to a vnode is going away but it is still cached.
17 */
18int
19hammer2_inactive(struct vop_inactive_args *ap)
20{
21 struct vnode *vp;
22 struct hammer2_inode *ip;
23 struct hammer2_mount *hmp;
24
25 kprintf("hammer2_inactive\n");
26
27 vp = ap->a_vp;
28 ip = VTOI(vp);
703720e4
MD
29
30 return (0);
31}
32
33/*
34 * Reclaim a vnode so that it can be reused; after the inode is
35 * disassociated, the filesystem must manage it alone.
36 */
37int
38hammer2_reclaim(struct vop_reclaim_args *ap)
39{
40 struct vnode *vp;
41 struct hammer2_inode *ip;
42 struct hammer2_mount *hmp;
43
44 kprintf("hammer2_reclaim\n");
45
46 /* Is the vnode locked? Must it be on exit? */
47
48 vp = ap->a_vp;
49 ip = VTOI(vp);
0e92b724 50 hmp = ip->mp;
703720e4
MD
51
52 vp->v_data = NULL;
0e92b724 53 ip->vp = NULL;
703720e4
MD
54
55 return (0);
56}
57
58
59int
60hammer2_fsync(struct vop_fsync_args *ap)
61{
62 kprintf("hammer2_fsync\n");
63 return (EOPNOTSUPP);
64}
65
66int
67hammer2_access(struct vop_access_args *ap)
68{
69 kprintf("hammer2_access\n");
70 return (0);
71}
72
73int
74hammer2_getattr(struct vop_getattr_args *ap)
75{
76 struct vnode *vp;
77 struct vattr *vap;
78 struct hammer2_inode *ip;
79
80 vp = ap->a_vp;
81 vap = ap->a_vap;
82
83 kprintf("hammer2_getattr\n");
84
85 ip = VTOI(vp);
86 hammer2_inode_lock_sh(ip);
87
88 vap->va_type = vp->v_type;
89 vap->va_mode = 0777;
90 vap->va_nlink = 1;
91 vap->va_uid = 0;
92 vap->va_gid = 0;
93 vap->va_size = 0;
94 vap->va_blocksize = PAGE_SIZE;
95 vap->va_flags = 0;
96
97 hammer2_inode_unlock_sh(ip);
98
99 return (0);
100}
101
102int
103hammer2_readdir(struct vop_readdir_args *ap)
104{
105 kprintf("hammer2_readdir\n");
106 return (EOPNOTSUPP);
107}
108
109int
110hammer2_read(struct vop_read_args *ap)
111{
47902fef
VS
112 return (EOPNOTSUPP);
113}
703720e4 114
47902fef
VS
115int
116hammer2_write(struct vop_write_args *ap)
117{
118 return (EOPNOTSUPP);
703720e4
MD
119}
120
121int
122hammer2_nresolve(struct vop_nresolve_args *ap)
123{
124 kprintf("hammer2_nresolve\n");
47902fef 125 return (EOPNOTSUPP);
703720e4
MD
126}
127
128int
129hammer2_bmap(struct vop_bmap_args *ap)
130{
131 kprintf("hammer2_bmap\n");
132 return (EOPNOTSUPP);
133}
134
135int
136hammer2_open(struct vop_open_args *ap)
137{
138 kprintf("hammer2_open\n");
139 return vop_stdopen(ap);
140}
141
142int
143hammer2_strategy(struct vop_strategy_args *ap)
144{
145 struct vnode *vp;
146 struct bio *biop;
147 struct buf *bp;
148 struct hammer2_inode *ip;
149 int error;
150
151 vp = ap->a_vp;
152 biop = ap->a_bio;
153 bp = biop->bio_buf;
154 ip = VTOI(vp);
155
156 switch(bp->b_cmd) {
157 case (BUF_CMD_READ):
158 case (BUF_CMD_WRITE):
159 default:
160 bp->b_error = error = EINVAL;
161 bp->b_flags |= B_ERROR;
162 biodone(biop);
163 break;
164 }
165
166 return (error);
167}
168
f0206a67
VS
169int
170hammer2_mountctl(struct vop_mountctl_args *ap)
171{
172 struct mount *mp;
173 struct hammer2_mount *hmp;
174 int rc;
175
176 switch (ap->a_op) {
177 case (MOUNTCTL_SET_EXPORT):
178 mp = ap->a_head.a_ops->head.vv_mount;
179 hmp = MPTOH2(mp);
180
181 if (ap->a_ctllen != sizeof(struct export_args))
182 rc = (EINVAL);
183 else
184 rc = vfs_export(mp, &hmp->hm_export,
185 (const struct export_args *) ap->a_ctl);
186 break;
187 default:
188 rc = vop_stdmountctl(ap);
189 break;
190 }
191 return (rc);
192}
193
703720e4
MD
194struct vop_ops hammer2_vnode_vops = {
195 .vop_default = vop_defaultop,
196 .vop_fsync = hammer2_fsync,
197 .vop_getpages = vop_stdgetpages,
198 .vop_putpages = vop_stdputpages,
199 .vop_access = hammer2_access,
200 .vop_getattr = hammer2_getattr,
47902fef
VS
201 .vop_readdir = hammer2_readdir,
202 .vop_read = hammer2_read,
203 .vop_write = hammer2_write,
703720e4
MD
204 .vop_open = hammer2_open,
205 .vop_inactive = hammer2_inactive,
206 .vop_reclaim = hammer2_reclaim,
207 .vop_nresolve = hammer2_nresolve,
f0206a67 208 .vop_mountctl = hammer2_mountctl,
47902fef
VS
209 .vop_bmap = hammer2_bmap,
210 .vop_strategy = hammer2_strategy,
703720e4
MD
211};
212
213struct vop_ops hammer2_spec_vops = {
214
215};
216
217struct vop_ops hammer2_fifo_vops = {
218
219};