Merge commit '0b09d754d66bb2026be92bbbc38f7c8ba454cf0c'
[unleashed.git] / kernel / fs / objfs / objfs_odir.c
blobc2247ffc8f6a28232e3ea4089c90970fcfc2302a
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/fs_subr.h>
30 #include <sys/kmem.h>
31 #include <sys/modctl.h>
32 #include <sys/objfs.h>
33 #include <sys/objfs_impl.h>
34 #include <sys/vfs.h>
35 #include <sys/stat.h>
37 static const struct vnodeops objfs_ops_odir;
39 static gfs_dirent_t objfs_odir_entries[] = {
40 { "object", objfs_create_data, 0 },
41 { NULL }
44 /* ARGSUSED */
45 static ino64_t
46 objfs_odir_do_inode(vnode_t *vp, int index)
48 objfs_odirnode_t *odir = vp->v_data;
50 return (OBJFS_INO_DATA(odir->objfs_odir_modctl->mod_id));
53 vnode_t *
54 objfs_create_odirnode(vnode_t *pvp, struct modctl *mp)
56 vnode_t *vp = gfs_dir_create(sizeof (objfs_odirnode_t), pvp,
57 &objfs_ops_odir, objfs_odir_entries, objfs_odir_do_inode,
58 OBJFS_NAME_MAX, NULL, NULL);
59 objfs_odirnode_t *onode = vp->v_data;
61 onode->objfs_odir_modctl = mp;
63 return (vp);
66 /* ARGSUSED */
67 static int
68 objfs_odir_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
69 caller_context_t *ct)
71 timestruc_t now;
73 vap->va_type = VDIR;
74 vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP |
75 S_IROTH | S_IXOTH;
76 vap->va_nodeid = gfs_file_inode(vp);
77 vap->va_nlink = vap->va_size = 2;
78 gethrestime(&now);
79 vap->va_atime = vap->va_ctime = vap->va_mtime = now;
80 return (objfs_common_getattr(vp, vap));
83 static const struct vnodeops objfs_ops_odir = {
84 .vnop_name = "objfs object directory",
85 .vop_open = objfs_dir_open,
86 .vop_close = objfs_common_close,
87 .vop_ioctl = fs_inval,
88 .vop_getattr = objfs_odir_getattr,
89 .vop_access = objfs_dir_access,
90 .vop_readdir = gfs_vop_readdir,
91 .vop_lookup = gfs_vop_lookup,
92 .vop_seek = fs_seek,
93 .vop_inactive = gfs_vop_inactive,