2 * Copyright (c) 2011-2012 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/kernel.h>
38 #include <sys/fcntl.h>
41 #include <sys/namei.h>
42 #include <sys/mount.h>
43 #include <sys/vnode.h>
44 #include <sys/mountctl.h>
49 * Last reference to a vnode is going away but it is still cached.
53 hammer2_vop_inactive(struct vop_inactive_args *ap)
56 struct hammer2_inode *ip;
58 struct hammer2_mount *hmp;
61 kprintf("hammer2_inactive\n");
70 * Reclaim a vnode so that it can be reused; after the inode is
71 * disassociated, the filesystem must manage it alone.
75 hammer2_vop_reclaim(struct vop_reclaim_args *ap)
78 struct hammer2_inode *ip;
79 struct hammer2_mount *hmp;
85 hammer2_inode_lock_ex(ip);
88 hammer2_inode_unlock_ex(ip);
91 * XXX handle background sync when ip dirty, kernel will no longer
92 * notify us regarding this inode because there is no longer a
93 * vnode attached to it.
101 hammer2_vop_fsync(struct vop_fsync_args *ap)
103 kprintf("hammer2_fsync\n");
109 hammer2_vop_access(struct vop_access_args *ap)
111 kprintf("hammer2_access\n");
117 hammer2_vop_getattr(struct vop_getattr_args *ap)
121 struct hammer2_inode *ip;
126 kprintf("hammer2_getattr\n");
129 hammer2_inode_lock_sh(ip);
131 vap->va_type = vp->v_type;
137 vap->va_blocksize = PAGE_SIZE;
140 hammer2_inode_unlock_sh(ip);
147 hammer2_vop_readdir(struct vop_readdir_args *ap)
149 kprintf("hammer2_readdir\n");
155 hammer2_vop_read(struct vop_read_args *ap)
162 hammer2_vop_write(struct vop_write_args *ap)
169 hammer2_vop_nresolve(struct vop_nresolve_args *ap)
171 kprintf("hammer2_nresolve\n");
177 hammer2_vop_bmap(struct vop_bmap_args *ap)
179 kprintf("hammer2_bmap\n");
185 hammer2_vop_open(struct vop_open_args *ap)
187 kprintf("hammer2_open\n");
188 return vop_stdopen(ap);
193 hammer2_vop_strategy(struct vop_strategy_args *ap)
198 struct hammer2_inode *ip;
208 case (BUF_CMD_WRITE):
210 bp->b_error = error = EINVAL;
211 bp->b_flags |= B_ERROR;
221 hammer2_vop_mountctl(struct vop_mountctl_args *ap)
224 struct hammer2_mount *hmp;
228 case (MOUNTCTL_SET_EXPORT):
229 mp = ap->a_head.a_ops->head.vv_mount;
232 if (ap->a_ctllen != sizeof(struct export_args))
235 rc = vfs_export(mp, &hmp->export,
236 (const struct export_args *)ap->a_ctl);
239 rc = vop_stdmountctl(ap);
245 struct vop_ops hammer2_vnode_vops = {
246 .vop_default = vop_defaultop,
247 .vop_fsync = hammer2_vop_fsync,
248 .vop_getpages = vop_stdgetpages,
249 .vop_putpages = vop_stdputpages,
250 .vop_access = hammer2_vop_access,
251 .vop_getattr = hammer2_vop_getattr,
252 .vop_readdir = hammer2_vop_readdir,
253 .vop_read = hammer2_vop_read,
254 .vop_write = hammer2_vop_write,
255 .vop_open = hammer2_vop_open,
256 .vop_inactive = hammer2_vop_inactive,
257 .vop_reclaim = hammer2_vop_reclaim,
258 .vop_nresolve = hammer2_vop_nresolve,
259 .vop_mountctl = hammer2_vop_mountctl,
260 .vop_bmap = hammer2_vop_bmap,
261 .vop_strategy = hammer2_vop_strategy,
264 struct vop_ops hammer2_spec_vops = {
268 struct vop_ops hammer2_fifo_vops = {