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_cdir.c
+++ new/usr/src/uts/common/fs/ctfs/ctfs_cdir.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 2007 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 #include <sys/pathname.h>
46 46
47 47 /*
48 48 * Entries in a /system/contract/<type>/<ctid> directory.
49 49 */
50 50 static gfs_dirent_t ctfs_ctls[] = {
51 51 { "ctl", ctfs_create_ctlnode, GFS_CACHE_VNODE, },
52 52 { "status", ctfs_create_statnode, GFS_CACHE_VNODE },
53 53 { "events", ctfs_create_evnode },
54 54 { NULL }
55 55 };
56 56 #define CTFS_NCTLS ((sizeof ctfs_ctls / sizeof (gfs_dirent_t)) - 1)
57 57
58 58 static ino64_t ctfs_cdir_do_inode(vnode_t *, int);
59 59
60 60 /*
61 61 * ctfs_create_cdirnode
62 62 *
63 63 * If necessary, creates a cdirnode for the specified contract and
64 64 * inserts it into the contract's list of vnodes. Returns either the
65 65 * existing vnode or the new one.
66 66 */
67 67 vnode_t *
68 68 ctfs_create_cdirnode(vnode_t *pvp, contract_t *ct)
69 69 {
70 70 vnode_t *vp;
71 71 ctfs_cdirnode_t *cdir;
72 72
73 73 if ((vp = contract_vnode_get(ct, pvp->v_vfsp)) != NULL)
74 74 return (vp);
75 75
76 76 vp = gfs_dir_create(sizeof (ctfs_cdirnode_t), pvp, ctfs_ops_cdir,
77 77 ctfs_ctls, ctfs_cdir_do_inode, CTFS_NAME_MAX, NULL, NULL);
78 78 cdir = vp->v_data;
79 79
80 80 /*
81 81 * We must set the inode because this is called explicitly rather than
82 82 * through GFS callbacks.
83 83 */
84 84 gfs_file_set_inode(vp, CTFS_INO_CT_DIR(ct->ct_id));
85 85
86 86 cdir->ctfs_cn_contract = ct;
87 87 contract_hold(ct);
88 88 contract_vnode_set(ct, &cdir->ctfs_cn_linkage, vp);
89 89
90 90 return (vp);
91 91 }
92 92
93 93 /*
94 94 * ctfs_cdir_getattr - VOP_GETATTR entry point
95 95 */
96 96 /* ARGSUSED */
97 97 static int
98 98 ctfs_cdir_getattr(
99 99 vnode_t *vp,
100 100 vattr_t *vap,
101 101 int flags,
102 102 cred_t *cr,
103 103 caller_context_t *ct)
104 104 {
105 105 ctfs_cdirnode_t *cdirnode = vp->v_data;
106 106
107 107 vap->va_type = VDIR;
108 108 vap->va_mode = 0555;
109 109 vap->va_nlink = 2 + CTFS_NCTLS;
110 110 vap->va_size = vap->va_nlink;
111 111 vap->va_ctime = cdirnode->ctfs_cn_contract->ct_ctime;
112 112 mutex_enter(&cdirnode->ctfs_cn_contract->ct_events.ctq_lock);
113 113 vap->va_atime = vap->va_mtime =
114 114 cdirnode->ctfs_cn_contract->ct_events.ctq_atime;
115 115 mutex_exit(&cdirnode->ctfs_cn_contract->ct_events.ctq_lock);
116 116 ctfs_common_getattr(vp, vap);
117 117
118 118 return (0);
119 119 }
120 120
121 121 /*
122 122 * ctfs_cdir_do_inode - return inode number based on static index
123 123 */
124 124 static ino64_t
125 125 ctfs_cdir_do_inode(vnode_t *vp, int index)
126 126 {
127 127 ctfs_cdirnode_t *cdirnode = vp->v_data;
128 128
129 129 return (CTFS_INO_CT_FILE(cdirnode->ctfs_cn_contract->ct_id, index));
130 130 }
131 131
132 132 /*
133 133 * ctfs_cdir_inactive - VOP_INACTIVE entry point
134 134 */
135 135 /* ARGSUSED */
136 136 static void
137 137 ctfs_cdir_inactive(vnode_t *vp, cred_t *cr, caller_context_t *cct)
138 138 {
139 139 ctfs_cdirnode_t *cdirnode = vp->v_data;
140 140 contract_t *ct = cdirnode->ctfs_cn_contract;
141 141
142 142 mutex_enter(&ct->ct_lock);
143 143 if (gfs_dir_inactive(vp) == NULL) {
144 144 mutex_exit(&ct->ct_lock);
145 145 return;
146 146 }
147 147
148 148 list_remove(&ct->ct_vnodes, &cdirnode->ctfs_cn_linkage);
149 149 mutex_exit(&ct->ct_lock);
150 150
151 151 contract_rele(ct);
152 152 kmem_free(cdirnode, sizeof (ctfs_cdirnode_t));
153 153 }
154 154
155 155
↓ open down ↓ |
118 lines elided |
↑ open up ↑ |
156 156 const fs_operation_def_t ctfs_tops_cdir[] = {
157 157 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
158 158 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
159 159 { VOPNAME_IOCTL, { .error = fs_inval } },
160 160 { VOPNAME_GETATTR, { .vop_getattr = ctfs_cdir_getattr } },
161 161 { VOPNAME_ACCESS, { .vop_access = ctfs_access_dir } },
162 162 { VOPNAME_READDIR, { .vop_readdir = gfs_vop_readdir } },
163 163 { VOPNAME_LOOKUP, { .vop_lookup = gfs_vop_lookup } },
164 164 { VOPNAME_SEEK, { .vop_seek = fs_seek } },
165 165 { VOPNAME_INACTIVE, { .vop_inactive = ctfs_cdir_inactive } },
166 - { NULL, NULL }
166 + { NULL, { NULL } }
167 167 };
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX