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>
44 #include <sys/pathname.h>
47 * CTFS routines for the /system/contract/all vnode.
50 static int ctfs_adir_do_readdir(vnode_t
*, void *, int *, offset_t
*,
51 offset_t
*, void *, int);
52 static int ctfs_adir_do_lookup(vnode_t
*, const char *, vnode_t
**, ino64_t
*,
53 cred_t
*, int, int *, pathname_t
*);
56 * ctfs_create_adirnode
60 ctfs_create_adirnode(vnode_t
*pvp
)
62 vnode_t
*vp
= gfs_dir_create(sizeof (ctfs_adirnode_t
), pvp
,
63 &ctfs_ops_adir
, NULL
, NULL
, CTFS_NAME_MAX
, ctfs_adir_do_readdir
,
70 * ctfs_adir_getattr - fop_getattr entry point
85 for (i
= 0, total
= 0; i
< ct_ntypes
; i
++)
86 total
+= contract_type_count(ct_types
[i
]);
88 vap
->va_size
= 2 + total
;
89 vap
->va_ctime
.tv_sec
= vp
->v_vfsp
->vfs_mtime
;
90 vap
->va_ctime
.tv_nsec
= 0;
91 vap
->va_mtime
= vap
->va_atime
= vap
->va_ctime
;
92 ctfs_common_getattr(vp
, vap
);
99 ctfs_adir_do_lookup(vnode_t
*vp
, const char *nm
, vnode_t
**vpp
, ino64_t
*inop
,
100 cred_t
*cr
, int flags
, int *deflags
, pathname_t
*rpnp
)
105 i
= stoi((char **)&nm
);
109 ct
= contract_ptr(i
, VTOZONE(vp
)->zone_uniqid
);
113 *vpp
= ctfs_create_symnode(vp
, ct
);
114 *inop
= CTFS_INO_CT_LINK(ct
->ct_id
);
122 ctfs_adir_do_readdir(vnode_t
*vp
, void *dp
, int *eofp
,
123 offset_t
*offp
, offset_t
*nextp
, void *unused
, int flags
)
127 struct dirent64
*odp
= dp
;
129 ASSERT(!(flags
& V_RDDIR_ENTFLAGS
));
131 zuniqid
= VTOZONE(vp
)->zone_uniqid
;
132 next
= contract_lookup(zuniqid
, *offp
);
139 odp
->d_ino
= CTFS_INO_CT_LINK(next
);
140 numtos(next
, odp
->d_name
);
147 const struct vnodeops ctfs_ops_adir
= {
148 .vnop_name
= "ctfs all directory",
149 .vop_open
= ctfs_open
,
150 .vop_close
= ctfs_close
,
151 .vop_ioctl
= fs_inval
,
152 .vop_getattr
= ctfs_adir_getattr
,
153 .vop_access
= ctfs_access_dir
,
154 .vop_readdir
= gfs_vop_readdir
,
155 .vop_lookup
= gfs_vop_lookup
,
157 .vop_inactive
= gfs_vop_inactive
,