1 /* $NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $ */
2
3 /*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Juergen Hannken-Illjes.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/vnode.h>
38 #include <sys/mount.h>
39
40 #include <miscfs/specfs/specdev.h>
41
42 VFS_PROTOS(dead);
43
44 static void dead_panic(void);
45
46 extern const struct vnodeopv_desc dead_vnodeop_opv_desc;
47
48 static const struct vnodeopv_desc * const dead_vnodeopv_descs[] = {
49 &dead_vnodeop_opv_desc,
50 NULL
51 };
52
53 struct mount *dead_rootmount;
54
55 struct vfsops dead_vfsops = {
56 .vfs_name = "dead",
57 .vfs_min_mount_data = 0,
58 .vfs_mount = (void *)dead_panic,
59 .vfs_start = (void *)dead_panic,
60 .vfs_unmount = (void *)dead_panic,
61 .vfs_root = (void *)dead_panic,
62 .vfs_quotactl = (void *)dead_panic,
63 .vfs_statvfs = (void *)dead_panic,
64 .vfs_sync = (void *)dead_panic,
65 .vfs_vget = (void *)dead_panic,
66 .vfs_loadvnode = (void *)dead_panic,
67 .vfs_newvnode = dead_newvnode,
68 .vfs_fhtovp = (void *)dead_panic,
69 .vfs_vptofh = (void *)dead_panic,
70 .vfs_init = (void *)dead_panic,
71 .vfs_reinit = (void *)dead_panic,
72 .vfs_done = (void *)dead_panic,
73 .vfs_mountroot = (void *)dead_panic,
74 .vfs_snapshot = (void *)dead_panic,
75 .vfs_extattrctl = (void *)dead_panic,
76 .vfs_suspendctl = (void *)dead_panic,
77 .vfs_renamelock_enter = (void *)dead_panic,
78 .vfs_renamelock_exit = (void *)dead_panic,
79 .vfs_fsync = (void *)eopnotsupp,
80 .vfs_opv_descs = dead_vnodeopv_descs
81 };
82
83 static void
dead_panic(void)84 dead_panic(void)
85 {
86
87 panic("dead fs operation used");
88 }
89
90 /*
91 * Create a new anonymous device vnode.
92 */
93 int
dead_newvnode(struct mount * mp,struct vnode * dvp,struct vnode * vp,struct vattr * vap,kauth_cred_t cred,size_t * key_len,const void ** new_key)94 dead_newvnode(struct mount *mp, struct vnode *dvp, struct vnode *vp,
95 struct vattr *vap, kauth_cred_t cred,
96 size_t *key_len, const void **new_key)
97 {
98
99 KASSERT(mp == dead_rootmount);
100 KASSERT(dvp == NULL);
101 KASSERT(vap->va_type == VCHR || vap->va_type == VBLK);
102 KASSERT(vap->va_rdev != VNOVAL);
103
104 vp->v_tag = VT_NON;
105 vp->v_type = vap->va_type;
106 vp->v_op = spec_vnodeop_p;
107 vp->v_vflag |= VV_MPSAFE;
108 uvm_vnp_setsize(vp, 0);
109 spec_node_init(vp, vap->va_rdev);
110
111 *key_len = sizeof(vp->v_interlock);
112 *new_key = &vp->v_interlock;
113
114 return 0;
115 }
116