Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/ctfs/ctfs_tmpl.c
+++ new/usr/src/uts/common/fs/ctfs/ctfs_tmpl.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/param.h>
28 28 #include <sys/time.h>
29 29 #include <sys/cred.h>
30 30 #include <sys/vfs.h>
31 31 #include <sys/vfs_opreg.h>
32 32 #include <sys/gfs.h>
33 33 #include <sys/vnode.h>
34 34 #include <sys/systm.h>
35 35 #include <sys/errno.h>
36 36 #include <sys/sysmacros.h>
37 37 #include <fs/fs_subr.h>
38 38 #include <sys/contract.h>
39 39 #include <sys/contract_impl.h>
40 40 #include <sys/ctfs.h>
41 41 #include <sys/ctfs_impl.h>
42 42 #include <sys/file.h>
43 43 #include <sys/model.h>
44 44
45 45 /*
46 46 * CTFS routines for the /system/contract/<type>/template vnode.
47 47 */
48 48
49 49 /*
50 50 * ctfs_create_tmplnode
51 51 *
52 52 * Creates a new template and tdirnode, and returns the tdirnode.
53 53 */
54 54 vnode_t *
55 55 ctfs_create_tmplnode(vnode_t *pvp)
56 56 {
57 57 vnode_t *vp;
58 58 ctfs_tmplnode_t *tmplnode;
59 59
60 60 ASSERT(gfs_file_index(pvp) < ct_ntypes);
61 61
62 62 vp = gfs_file_create(sizeof (ctfs_tmplnode_t), pvp, ctfs_ops_tmpl);
63 63 tmplnode = vp->v_data;
64 64 tmplnode->ctfs_tmn_tmpl =
65 65 ct_types[gfs_file_index(pvp)]->ct_type_default();
66 66
67 67 return (vp);
68 68 }
69 69
70 70 /*
71 71 * ctfs_tmpl_open - VOP_OPEN entry point
72 72 *
73 73 * Just ensures the right mode bits are set.
74 74 */
75 75 /* ARGSUSED */
76 76 static int
77 77 ctfs_tmpl_open(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
78 78 {
79 79 if (flag != (FREAD | FWRITE | FOFFMAX))
80 80 return (EINVAL);
81 81
82 82 return (0);
83 83 }
84 84
85 85 /*
86 86 * ctfs_tmpl_getattr - VOP_GETATTR entry point
87 87 */
88 88 /* ARGSUSED */
89 89 static int
90 90 ctfs_tmpl_getattr(
91 91 vnode_t *vp,
92 92 vattr_t *vap,
93 93 int flags,
94 94 cred_t *cr,
95 95 caller_context_t *ct)
96 96 {
97 97 vap->va_type = VREG;
98 98 vap->va_mode = 0666;
99 99 vap->va_nlink = 1;
100 100 vap->va_size = 0;
101 101 vap->va_ctime.tv_sec = vp->v_vfsp->vfs_mtime;
102 102 vap->va_ctime.tv_nsec = 0;
103 103 vap->va_atime = vap->va_mtime = vap->va_ctime;
104 104 ctfs_common_getattr(vp, vap);
105 105
106 106 return (0);
107 107 }
108 108
109 109 /*
110 110 * ctfs_tmpl_ioctl - VOP_IOCTL entry point
111 111 *
112 112 * All the ct_tmpl_*(3contract) interfaces point here.
113 113 */
114 114 /* ARGSUSED */
115 115 static int
116 116 ctfs_tmpl_ioctl(
117 117 vnode_t *vp,
118 118 int cmd,
119 119 intptr_t arg,
120 120 int flag,
121 121 cred_t *cr,
122 122 int *rvalp,
123 123 caller_context_t *ct)
124 124 {
125 125 ctfs_tmplnode_t *tmplnode = vp->v_data;
126 126 ct_kparam_t kparam;
127 127 ct_param_t *param = &kparam.param;
128 128 ctid_t ctid;
129 129 int error;
130 130
131 131 switch (cmd) {
132 132 case CT_TACTIVATE:
133 133 ASSERT(tmplnode->ctfs_tmn_tmpl != NULL);
134 134 ctmpl_activate(tmplnode->ctfs_tmn_tmpl);
135 135 break;
136 136 case CT_TCLEAR:
137 137 ASSERT(tmplnode->ctfs_tmn_tmpl != NULL);
138 138 ctmpl_clear(tmplnode->ctfs_tmn_tmpl);
139 139 break;
140 140 case CT_TCREATE:
141 141 ASSERT(tmplnode->ctfs_tmn_tmpl != NULL);
142 142 error = ctmpl_create(tmplnode->ctfs_tmn_tmpl, &ctid);
143 143 if (error)
144 144 return (error);
145 145 *rvalp = ctid;
146 146 break;
147 147 case CT_TSET:
148 148 error = ctparam_copyin((void *)arg, &kparam, flag, cmd);
149 149 if (error != 0)
150 150 return (error);
151 151 error = ctmpl_set(tmplnode->ctfs_tmn_tmpl, &kparam, cr);
152 152 kmem_free(kparam.ctpm_kbuf, param->ctpm_size);
153 153
154 154 return (error);
155 155 case CT_TGET:
156 156 error = ctparam_copyin((void *)arg, &kparam, flag, cmd);
157 157 if (error != 0)
158 158 return (error);
159 159 error = ctmpl_get(tmplnode->ctfs_tmn_tmpl, &kparam);
160 160 if (error != 0) {
161 161 kmem_free(kparam.ctpm_kbuf, param->ctpm_size);
162 162 } else {
163 163 error = ctparam_copyout(&kparam, (void *)arg, flag);
164 164 }
165 165
166 166 return (error);
167 167 default:
168 168 return (EINVAL);
169 169 }
170 170
171 171 return (0);
172 172 }
173 173
174 174 /*
175 175 * ctfs_tmpl_inactive - VOP_INACTIVE entry point
176 176 */
177 177 /* ARGSUSED */
178 178 static void
179 179 ctfs_tmpl_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
180 180 {
181 181 ctfs_tmplnode_t *tmplnode;
182 182
183 183 if ((tmplnode = gfs_file_inactive(vp)) != NULL) {
184 184 ctmpl_free(tmplnode->ctfs_tmn_tmpl);
185 185 kmem_free(tmplnode, sizeof (ctfs_tmplnode_t));
186 186 }
187 187 }
↓ open down ↓ |
187 lines elided |
↑ open up ↑ |
188 188
189 189 const fs_operation_def_t ctfs_tops_tmpl[] = {
190 190 { VOPNAME_OPEN, { .vop_open = ctfs_tmpl_open } },
191 191 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
192 192 { VOPNAME_IOCTL, { .vop_ioctl = ctfs_tmpl_ioctl } },
193 193 { VOPNAME_GETATTR, { .vop_getattr = ctfs_tmpl_getattr } },
194 194 { VOPNAME_ACCESS, { .vop_access = ctfs_access_readwrite } },
195 195 { VOPNAME_READDIR, { .error = fs_notdir } },
196 196 { VOPNAME_LOOKUP, { .error = fs_notdir } },
197 197 { VOPNAME_INACTIVE, { .vop_inactive = ctfs_tmpl_inactive } },
198 - { NULL, NULL }
198 + { NULL, { NULL } }
199 199 };
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX