Print this page
fixup .text where possible
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/ctfs/ctfs_latest.c
+++ new/usr/src/uts/common/fs/ctfs/ctfs_latest.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
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
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 -#pragma ident "%Z%%M% %I% %E% SMI"
27 26
27 +
28 28 #include <sys/types.h>
29 29 #include <sys/param.h>
30 30 #include <sys/time.h>
31 31 #include <sys/cred.h>
32 32 #include <sys/vfs.h>
33 33 #include <sys/vfs_opreg.h>
34 34 #include <sys/gfs.h>
35 35 #include <sys/vnode.h>
36 36 #include <sys/systm.h>
37 37 #include <sys/errno.h>
38 38 #include <sys/sysmacros.h>
39 39 #include <fs/fs_subr.h>
40 40 #include <sys/contract.h>
41 41 #include <sys/contract_impl.h>
42 42 #include <sys/ctfs.h>
43 43 #include <sys/ctfs_impl.h>
44 44 #include <sys/file.h>
45 45
46 46 /*
47 47 * CTFS routines for the /system/contract/<type>/latest vnode.
48 48 */
49 49
50 50 /*
51 51 * ctfs_create_latenode
52 52 */
53 53 vnode_t *
54 54 ctfs_create_latenode(vnode_t *pvp)
55 55 {
56 56 return (gfs_file_create(sizeof (ctfs_latenode_t), pvp,
57 57 ctfs_ops_latest));
58 58 }
59 59
60 60 /*
61 61 * ctfs_latest_nested_open
62 62 *
63 63 * The latest node is just a doorway to the status file; this function
64 64 * is used by ctfs_latest_access, ctfs_latest_open, and
65 65 * ctfs_latest_getattr to obtain that file.
66 66 */
67 67 static vnode_t *
68 68 ctfs_latest_nested_open(vnode_t *vp, cred_t *cr)
69 69 {
70 70 contract_t *ct = ttolwp(curthread)->lwp_ct_latest[
71 71 gfs_file_index(gfs_file_parent(vp))];
72 72
73 73 if (ct) {
74 74 vnode_t *cvp, *svp;
75 75
76 76 cvp = ctfs_create_cdirnode(gfs_file_parent(vp), ct);
77 77
78 78 gfs_file_set_index(cvp, -1);
79 79
80 80 VERIFY(gfs_dir_lookup(cvp, "status", &svp,
81 81 cr, 0, NULL, NULL) == 0);
82 82
83 83 VN_RELE(cvp);
84 84
85 85 return (svp);
86 86 }
87 87
88 88 return (NULL);
89 89 }
90 90
91 91 /*
92 92 * ctfs_latest_access - VOP_ACCESS entry point
93 93 *
94 94 * Fails if there isn't a latest contract.
95 95 */
96 96 /* ARGSUSED */
97 97 static int
98 98 ctfs_latest_access(
99 99 vnode_t *vp,
100 100 int mode,
101 101 int flags,
102 102 cred_t *cr,
103 103 caller_context_t *ct)
104 104 {
105 105 vnode_t *nvp;
106 106
107 107 if (mode & (VEXEC | VWRITE))
108 108 return (EACCES);
109 109
110 110 if (nvp = ctfs_latest_nested_open(vp, cr)) {
111 111 VN_RELE(nvp);
112 112 return (0);
113 113 }
114 114
115 115 return (ESRCH);
116 116 }
117 117
118 118 /*
119 119 * ctfs_latest_open - VOP_OPEN entry point
120 120 *
121 121 * After checking the mode bits, opens and returns the status file for
122 122 * the LWP's latest contract.
123 123 */
124 124 static int
125 125 ctfs_latest_open(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
126 126 {
127 127 vnode_t *nvp;
128 128
129 129 if (flag != (FREAD | FOFFMAX))
130 130 return (EINVAL);
131 131
132 132 if (nvp = ctfs_latest_nested_open(*vpp, cr)) {
133 133 VN_RELE(*vpp);
134 134 *vpp = nvp;
135 135 return (VOP_OPEN(vpp, flag, cr, ct));
136 136 }
137 137
138 138 return (ESRCH);
139 139 }
140 140
141 141 /*
142 142 * ctfs_latest_getattr - the VOP_GETATTR entry point
143 143 *
144 144 * Fetches and calls VOP_GETATTR on the status file for the LWP's
145 145 * latest contract. Otherwise it fakes up something bland.
146 146 */
147 147 static int
148 148 ctfs_latest_getattr(
149 149 vnode_t *vp,
150 150 vattr_t *vap,
151 151 int flags,
152 152 cred_t *cr,
153 153 caller_context_t *ct)
154 154 {
155 155 vnode_t *nvp;
156 156
157 157 if (nvp = ctfs_latest_nested_open(vp, cr)) {
158 158 int res = VOP_GETATTR(nvp, vap, flags, cr, ct);
159 159 VN_RELE(nvp);
160 160 return (res);
161 161 }
162 162
163 163 vap->va_type = VREG;
164 164 vap->va_mode = 0444;
165 165 vap->va_nlink = 1;
166 166 vap->va_size = 0;
167 167 vap->va_ctime.tv_sec = vp->v_vfsp->vfs_mtime;
168 168 vap->va_ctime.tv_nsec = 0;
169 169 vap->va_atime = vap->va_mtime = vap->va_ctime;
170 170 ctfs_common_getattr(vp, vap);
171 171
172 172 return (0);
173 173 }
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
174 174
175 175 const fs_operation_def_t ctfs_tops_latest[] = {
176 176 { VOPNAME_OPEN, { .vop_open = ctfs_latest_open } },
177 177 { VOPNAME_CLOSE, { .error = fs_inval } },
178 178 { VOPNAME_IOCTL, { .error = fs_inval } },
179 179 { VOPNAME_GETATTR, { .vop_getattr = ctfs_latest_getattr } },
180 180 { VOPNAME_ACCESS, { .vop_access = ctfs_latest_access } },
181 181 { VOPNAME_READDIR, { .error = fs_notdir } },
182 182 { VOPNAME_LOOKUP, { .error = fs_notdir } },
183 183 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
184 - { NULL, NULL }
184 + { NULL, { NULL } }
185 185 };
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX