6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/time.h>
31 #include <sys/cred.h>
32 #include <sys/vfs.h>
33 #include <sys/vfs_opreg.h>
34 #include <sys/gfs.h>
35 #include <sys/vnode.h>
36 #include <sys/systm.h>
37 #include <sys/errno.h>
38 #include <sys/sysmacros.h>
39 #include <fs/fs_subr.h>
40 #include <sys/contract.h>
41 #include <sys/contract_impl.h>
42 #include <sys/ctfs.h>
43 #include <sys/ctfs_impl.h>
44 #include <sys/file.h>
45
46 /*
47 * CTFS routines for the /system/contract/<type>/<ctid>/ctl vnode.
218 case CT_CADOPT:
219 error = contract_adopt(ct, curproc);
220 break;
221
222 default:
223 return (EINVAL);
224 }
225
226 return (error);
227 }
228
229 const fs_operation_def_t ctfs_tops_ctl[] = {
230 { VOPNAME_OPEN, { .vop_open = ctfs_ctl_open } },
231 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
232 { VOPNAME_IOCTL, { .vop_ioctl = ctfs_ctl_ioctl } },
233 { VOPNAME_GETATTR, { .vop_getattr = ctfs_ctl_getattr } },
234 { VOPNAME_ACCESS, { .vop_access = ctfs_ctl_access } },
235 { VOPNAME_READDIR, { .error = fs_notdir } },
236 { VOPNAME_LOOKUP, { .error = fs_notdir } },
237 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
238 { NULL, NULL }
239 };
240
241 /*
242 * ctfs_create_statnode
243 *
244 * If necessary, creates a ctlnode for a status file and inserts it
245 * into the specified cdirnode's gfs_dir_t. Returns either the
246 * existing vnode or the new one.
247 */
248 vnode_t *
249 ctfs_create_statnode(vnode_t *pvp)
250 {
251 vnode_t *vp;
252 ctfs_cdirnode_t *cdirnode = pvp->v_data;
253 ctfs_ctlnode_t *ctlnode;
254
255 vp = gfs_file_create(sizeof (ctfs_ctlnode_t), pvp, ctfs_ops_stat);
256 ctlnode = vp->v_data;
257 /*
258 * We transitively have a hold on the contract through our
317 kmem_free(bufp, len);
318 STRUCT_FSET(st, ctst_nbytes, len);
319 } else {
320 return (EINVAL);
321 }
322 if (copyout(STRUCT_BUF(st), (void *)arg, STRUCT_SIZE(st)))
323 return (EFAULT);
324
325 return (0);
326 }
327
328 const fs_operation_def_t ctfs_tops_stat[] = {
329 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
330 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
331 { VOPNAME_IOCTL, { .vop_ioctl = ctfs_stat_ioctl } },
332 { VOPNAME_GETATTR, { .vop_getattr = ctfs_stat_getattr } },
333 { VOPNAME_ACCESS, { .vop_access = ctfs_access_readonly } },
334 { VOPNAME_READDIR, { .error = fs_notdir } },
335 { VOPNAME_LOOKUP, { .error = fs_notdir } },
336 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
337 { NULL, NULL }
338 };
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26
27
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/time.h>
31 #include <sys/cred.h>
32 #include <sys/vfs.h>
33 #include <sys/vfs_opreg.h>
34 #include <sys/gfs.h>
35 #include <sys/vnode.h>
36 #include <sys/systm.h>
37 #include <sys/errno.h>
38 #include <sys/sysmacros.h>
39 #include <fs/fs_subr.h>
40 #include <sys/contract.h>
41 #include <sys/contract_impl.h>
42 #include <sys/ctfs.h>
43 #include <sys/ctfs_impl.h>
44 #include <sys/file.h>
45
46 /*
47 * CTFS routines for the /system/contract/<type>/<ctid>/ctl vnode.
218 case CT_CADOPT:
219 error = contract_adopt(ct, curproc);
220 break;
221
222 default:
223 return (EINVAL);
224 }
225
226 return (error);
227 }
228
229 const fs_operation_def_t ctfs_tops_ctl[] = {
230 { VOPNAME_OPEN, { .vop_open = ctfs_ctl_open } },
231 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
232 { VOPNAME_IOCTL, { .vop_ioctl = ctfs_ctl_ioctl } },
233 { VOPNAME_GETATTR, { .vop_getattr = ctfs_ctl_getattr } },
234 { VOPNAME_ACCESS, { .vop_access = ctfs_ctl_access } },
235 { VOPNAME_READDIR, { .error = fs_notdir } },
236 { VOPNAME_LOOKUP, { .error = fs_notdir } },
237 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
238 { NULL, { NULL } }
239 };
240
241 /*
242 * ctfs_create_statnode
243 *
244 * If necessary, creates a ctlnode for a status file and inserts it
245 * into the specified cdirnode's gfs_dir_t. Returns either the
246 * existing vnode or the new one.
247 */
248 vnode_t *
249 ctfs_create_statnode(vnode_t *pvp)
250 {
251 vnode_t *vp;
252 ctfs_cdirnode_t *cdirnode = pvp->v_data;
253 ctfs_ctlnode_t *ctlnode;
254
255 vp = gfs_file_create(sizeof (ctfs_ctlnode_t), pvp, ctfs_ops_stat);
256 ctlnode = vp->v_data;
257 /*
258 * We transitively have a hold on the contract through our
317 kmem_free(bufp, len);
318 STRUCT_FSET(st, ctst_nbytes, len);
319 } else {
320 return (EINVAL);
321 }
322 if (copyout(STRUCT_BUF(st), (void *)arg, STRUCT_SIZE(st)))
323 return (EFAULT);
324
325 return (0);
326 }
327
328 const fs_operation_def_t ctfs_tops_stat[] = {
329 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
330 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
331 { VOPNAME_IOCTL, { .vop_ioctl = ctfs_stat_ioctl } },
332 { VOPNAME_GETATTR, { .vop_getattr = ctfs_stat_getattr } },
333 { VOPNAME_ACCESS, { .vop_access = ctfs_access_readonly } },
334 { VOPNAME_READDIR, { .error = fs_notdir } },
335 { VOPNAME_LOOKUP, { .error = fs_notdir } },
336 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
337 { NULL, { NULL } }
338 };
|