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_tdir.c
+++ new/usr/src/uts/common/fs/ctfs/ctfs_tdir.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 #include <sys/pathname.h>
46 46
47 47 /*
48 48 * Entries in a /system/contract/<type> directory.
49 49 */
50 50 static gfs_dirent_t ctfs_tdir_dirents[] = {
51 51 { "bundle", ctfs_create_bundle },
52 52 { "pbundle", ctfs_create_pbundle },
53 53 { "template", ctfs_create_tmplnode },
54 54 { "latest", ctfs_create_latenode, GFS_CACHE_VNODE },
55 55 { NULL }
56 56 };
57 57 #define CTFS_NSPECIALS ((sizeof ctfs_tdir_dirents / sizeof (gfs_dirent_t)) - 1)
58 58
59 59 static int ctfs_tdir_do_readdir(vnode_t *, void *, int *, offset_t *,
60 60 offset_t *, void *, int);
61 61 static int ctfs_tdir_do_lookup(vnode_t *, const char *, vnode_t **, ino64_t *,
62 62 cred_t *, int, int *, pathname_t *);
63 63 static ino64_t ctfs_tdir_do_inode(vnode_t *, int);
64 64
65 65 /*
66 66 * ctfs_create_tdirnode
67 67 */
68 68 vnode_t *
69 69 ctfs_create_tdirnode(vnode_t *pvp)
70 70 {
71 71 return (gfs_dir_create(sizeof (ctfs_tdirnode_t), pvp, ctfs_ops_tdir,
72 72 ctfs_tdir_dirents, ctfs_tdir_do_inode, CTFS_NAME_MAX,
73 73 ctfs_tdir_do_readdir, ctfs_tdir_do_lookup));
74 74 }
75 75
76 76 /*
77 77 * ctfs_tdir_getattr - VOP_GETATTR entry point
78 78 */
79 79 /* ARGSUSED */
80 80 static int
81 81 ctfs_tdir_getattr(
82 82 vnode_t *vp,
83 83 vattr_t *vap,
84 84 int flags,
85 85 cred_t *cr,
86 86 caller_context_t *ct)
87 87 {
88 88 vap->va_type = VDIR;
89 89 vap->va_mode = 0555;
90 90 vap->va_nlink = 2 + CTFS_NSPECIALS;
91 91 vap->va_size = vap->va_nlink +
92 92 contract_type_count(ct_types[gfs_file_index(vp)]);
93 93 vap->va_ctime.tv_sec = vp->v_vfsp->vfs_mtime;
94 94 vap->va_ctime.tv_nsec = 0;
95 95 contract_type_time(ct_types[gfs_file_index(vp)], &vap->va_atime);
96 96 vap->va_mtime = vap->va_atime;
97 97 ctfs_common_getattr(vp, vap);
98 98
99 99 return (0);
100 100 }
101 101
102 102 static ino64_t
103 103 ctfs_tdir_do_inode(vnode_t *vp, int index)
104 104 {
105 105 return (CTFS_INO_TYPE_FILE(gfs_file_index(vp), index));
106 106 }
107 107
108 108 /* ARGSUSED */
109 109 static int
110 110 ctfs_tdir_do_readdir(vnode_t *vp, void *dp, int *eofp,
111 111 offset_t *offp, offset_t *nextp, void *data, int flags)
112 112 {
113 113 uint64_t zuniqid;
114 114 ctid_t next;
115 115 ct_type_t *ty = ct_types[gfs_file_index(vp)];
116 116 struct dirent64 *odp = dp;
117 117
118 118 ASSERT(!(flags & V_RDDIR_ENTFLAGS));
119 119
120 120 zuniqid = VTOZONE(vp)->zone_uniqid;
121 121 next = contract_type_lookup(ty, zuniqid, *offp);
122 122
123 123 if (next == -1) {
124 124 *eofp = 1;
125 125 return (0);
126 126 }
127 127
128 128 odp->d_ino = CTFS_INO_CT_DIR(next);
129 129 numtos(next, odp->d_name);
130 130 *offp = next;
131 131 *nextp = next + 1;
132 132
133 133 return (0);
134 134 }
135 135
136 136 /* ARGSUSED */
137 137 static int
138 138 ctfs_tdir_do_lookup(vnode_t *vp, const char *nm, vnode_t **vpp, ino64_t *inop,
139 139 cred_t *cr, int flags, int *deflags, pathname_t *rpnp)
140 140 {
141 141 int i;
142 142 contract_t *ct;
143 143
144 144 i = stoi((char **)&nm);
145 145 if (*nm != '\0')
146 146 return (ENOENT);
147 147
148 148 ct = contract_type_ptr(ct_types[gfs_file_index(vp)], i,
149 149 VTOZONE(vp)->zone_uniqid);
150 150 if (ct == NULL)
151 151 return (ENOENT);
152 152
153 153 *vpp = ctfs_create_cdirnode(vp, ct);
154 154 *inop = gfs_file_inode(*vpp);
155 155 contract_rele(ct);
156 156 return (0);
157 157 }
158 158
↓ open down ↓ |
121 lines elided |
↑ open up ↑ |
159 159 const fs_operation_def_t ctfs_tops_tdir[] = {
160 160 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
161 161 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
162 162 { VOPNAME_IOCTL, { .error = fs_inval } },
163 163 { VOPNAME_GETATTR, { .vop_getattr = ctfs_tdir_getattr } },
164 164 { VOPNAME_ACCESS, { .vop_access = ctfs_access_dir } },
165 165 { VOPNAME_READDIR, { .vop_readdir = gfs_vop_readdir } },
166 166 { VOPNAME_LOOKUP, { .vop_lookup = gfs_vop_lookup } },
167 167 { VOPNAME_SEEK, { .vop_seek = fs_seek } },
168 168 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
169 - { NULL, NULL }
169 + { NULL, { NULL } }
170 170 };
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX