xref: /titanic_44/usr/src/uts/common/fs/objfs/objfs_odir.c (revision 18c2aff776a775d34a4c9893a4c72e0434d68e36)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <fs/fs_subr.h>
30 
31 #include <sys/kmem.h>
32 #include <sys/modctl.h>
33 #include <sys/objfs.h>
34 #include <sys/objfs_impl.h>
35 #include <sys/stat.h>
36 
37 static gfs_dirent_t objfs_odir_entries[] = {
38 	{ "object", objfs_create_data, 0 },
39 	{ NULL }
40 };
41 
42 /* ARGSUSED */
43 static ino64_t
44 objfs_odir_do_inode(vnode_t *vp, int index)
45 {
46 	objfs_odirnode_t *odir = vp->v_data;
47 
48 	return (OBJFS_INO_DATA(odir->objfs_odir_modctl->mod_id));
49 }
50 
51 vnode_t *
52 objfs_create_odirnode(vnode_t *pvp, struct modctl *mp)
53 {
54 	vnode_t *vp = gfs_dir_create(sizeof (objfs_odirnode_t), pvp,
55 	    objfs_ops_odir, objfs_odir_entries, objfs_odir_do_inode,
56 	    OBJFS_NAME_MAX, NULL, NULL);
57 	objfs_odirnode_t *onode = vp->v_data;
58 
59 	onode->objfs_odir_modctl = mp;
60 
61 	return (vp);
62 }
63 
64 /* ARGSUSED */
65 static int
66 objfs_odir_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr)
67 {
68 	timestruc_t now;
69 
70 	vap->va_type = VDIR;
71 	vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP |
72 	    S_IROTH | S_IXOTH;
73 	vap->va_nodeid = gfs_file_inode(vp);
74 	vap->va_nlink = vap->va_size = 2;
75 	gethrestime(&now);
76 	vap->va_atime = vap->va_ctime = vap->va_mtime = now;
77 	return (objfs_common_getattr(vp, vap));
78 }
79 
80 const fs_operation_def_t objfs_tops_odir[] = {
81 	{ VOPNAME_OPEN,		objfs_dir_open },
82 	{ VOPNAME_CLOSE,	objfs_common_close },
83 	{ VOPNAME_IOCTL,	fs_inval },
84 	{ VOPNAME_GETATTR,	objfs_odir_getattr },
85 	{ VOPNAME_ACCESS,	objfs_dir_access },
86 	{ VOPNAME_READDIR,	gfs_vop_readdir },
87 	{ VOPNAME_LOOKUP,	gfs_vop_lookup },
88 	{ VOPNAME_SEEK,		fs_seek },
89 	{ VOPNAME_INACTIVE,	(fs_generic_func_p) gfs_vop_inactive },
90 	{ NULL }
91 };
92