4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/types.h>
29 #include <sys/param.h>
34 #include <sys/vnode.h>
35 #include <sys/systm.h>
36 #include <sys/errno.h>
37 #include <sys/sysmacros.h>
38 #include <sys/fs_subr.h>
39 #include <sys/contract.h>
40 #include <sys/contract_impl.h>
42 #include <sys/ctfs_impl.h>
46 * CTFS routines for the /system/contract/<type>/latest vnode.
50 * ctfs_create_latenode
53 ctfs_create_latenode(vnode_t
*pvp
)
55 return (gfs_file_create(sizeof (ctfs_latenode_t
), pvp
,
60 * ctfs_latest_nested_open
62 * The latest node is just a doorway to the status file; this function
63 * is used by ctfs_latest_access, ctfs_latest_open, and
64 * ctfs_latest_getattr to obtain that file.
67 ctfs_latest_nested_open(vnode_t
*vp
, cred_t
*cr
)
69 contract_t
*ct
= ttolwp(curthread
)->lwp_ct_latest
[
70 gfs_file_index(gfs_file_parent(vp
))];
75 cvp
= ctfs_create_cdirnode(gfs_file_parent(vp
), ct
);
77 gfs_file_set_index(cvp
, -1);
79 VERIFY(gfs_dir_lookup(cvp
, "status", &svp
,
80 cr
, 0, NULL
, NULL
) == 0);
91 * ctfs_latest_access - fop_access entry point
93 * Fails if there isn't a latest contract.
102 caller_context_t
*ct
)
106 if (mode
& (VEXEC
| VWRITE
))
109 if (nvp
= ctfs_latest_nested_open(vp
, cr
)) {
118 * ctfs_latest_open - fop_open entry point
120 * After checking the mode bits, opens and returns the status file for
121 * the LWP's latest contract.
124 ctfs_latest_open(vnode_t
**vpp
, int flag
, cred_t
*cr
, caller_context_t
*ct
)
131 if (nvp
= ctfs_latest_nested_open(*vpp
, cr
)) {
134 return (fop_open(vpp
, flag
, cr
, ct
));
141 * ctfs_latest_getattr - the fop_getattr entry point
143 * Fetches and calls fop_getattr on the status file for the LWP's
144 * latest contract. Otherwise it fakes up something bland.
152 caller_context_t
*ct
)
156 if (nvp
= ctfs_latest_nested_open(vp
, cr
)) {
157 int res
= fop_getattr(nvp
, vap
, flags
, cr
, ct
);
166 vap
->va_ctime
.tv_sec
= vp
->v_vfsp
->vfs_mtime
;
167 vap
->va_ctime
.tv_nsec
= 0;
168 vap
->va_atime
= vap
->va_mtime
= vap
->va_ctime
;
169 ctfs_common_getattr(vp
, vap
);
174 const struct vnodeops ctfs_ops_latest
= {
175 .vnop_name
= "ctfs latest file",
176 .vop_open
= ctfs_latest_open
,
177 .vop_close
= fs_inval
,
178 .vop_ioctl
= fs_inval
,
179 .vop_getattr
= ctfs_latest_getattr
,
180 .vop_access
= ctfs_latest_access
,
181 .vop_readdir
= fs_notdir
,
182 .vop_lookup
= fs_notdir
,
183 .vop_inactive
= gfs_vop_inactive
,