xref: /onnv-gate/usr/src/uts/common/fs/objfs/objfs_odir.c (revision 5331:3047ad28a67b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53898Srsb  * Common Development and Distribution License (the "License").
63898Srsb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
223898Srsb  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <fs/fs_subr.h>
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include <sys/kmem.h>
310Sstevel@tonic-gate #include <sys/modctl.h>
320Sstevel@tonic-gate #include <sys/objfs.h>
330Sstevel@tonic-gate #include <sys/objfs_impl.h>
343898Srsb #include <sys/vfs_opreg.h>
350Sstevel@tonic-gate #include <sys/stat.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate static gfs_dirent_t objfs_odir_entries[] = {
380Sstevel@tonic-gate 	{ "object", objfs_create_data, 0 },
390Sstevel@tonic-gate 	{ NULL }
400Sstevel@tonic-gate };
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /* ARGSUSED */
430Sstevel@tonic-gate static ino64_t
objfs_odir_do_inode(vnode_t * vp,int index)440Sstevel@tonic-gate objfs_odir_do_inode(vnode_t *vp, int index)
450Sstevel@tonic-gate {
460Sstevel@tonic-gate 	objfs_odirnode_t *odir = vp->v_data;
470Sstevel@tonic-gate 
480Sstevel@tonic-gate 	return (OBJFS_INO_DATA(odir->objfs_odir_modctl->mod_id));
490Sstevel@tonic-gate }
500Sstevel@tonic-gate 
510Sstevel@tonic-gate vnode_t *
objfs_create_odirnode(vnode_t * pvp,struct modctl * mp)520Sstevel@tonic-gate objfs_create_odirnode(vnode_t *pvp, struct modctl *mp)
530Sstevel@tonic-gate {
540Sstevel@tonic-gate 	vnode_t *vp = gfs_dir_create(sizeof (objfs_odirnode_t), pvp,
550Sstevel@tonic-gate 	    objfs_ops_odir, objfs_odir_entries, objfs_odir_do_inode,
560Sstevel@tonic-gate 	    OBJFS_NAME_MAX, NULL, NULL);
570Sstevel@tonic-gate 	objfs_odirnode_t *onode = vp->v_data;
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 	onode->objfs_odir_modctl = mp;
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 	return (vp);
620Sstevel@tonic-gate }
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /* ARGSUSED */
650Sstevel@tonic-gate static int
objfs_odir_getattr(vnode_t * vp,vattr_t * vap,int flags,cred_t * cr,caller_context_t * ct)66*5331Samw objfs_odir_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
67*5331Samw 	caller_context_t *ct)
680Sstevel@tonic-gate {
690Sstevel@tonic-gate 	timestruc_t now;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	vap->va_type = VDIR;
720Sstevel@tonic-gate 	vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP |
730Sstevel@tonic-gate 	    S_IROTH | S_IXOTH;
740Sstevel@tonic-gate 	vap->va_nodeid = gfs_file_inode(vp);
750Sstevel@tonic-gate 	vap->va_nlink = vap->va_size = 2;
760Sstevel@tonic-gate 	gethrestime(&now);
770Sstevel@tonic-gate 	vap->va_atime = vap->va_ctime = vap->va_mtime = now;
780Sstevel@tonic-gate 	return (objfs_common_getattr(vp, vap));
790Sstevel@tonic-gate }
800Sstevel@tonic-gate 
810Sstevel@tonic-gate const fs_operation_def_t objfs_tops_odir[] = {
823898Srsb 	{ VOPNAME_OPEN,		{ .vop_open = objfs_dir_open } },
833898Srsb 	{ VOPNAME_CLOSE,	{ .vop_close = objfs_common_close } },
843898Srsb 	{ VOPNAME_IOCTL,	{ .error = fs_inval } },
853898Srsb 	{ VOPNAME_GETATTR,	{ .vop_getattr = objfs_odir_getattr } },
863898Srsb 	{ VOPNAME_ACCESS,	{ .vop_access = objfs_dir_access } },
873898Srsb 	{ VOPNAME_READDIR,	{ .vop_readdir = gfs_vop_readdir } },
883898Srsb 	{ VOPNAME_LOOKUP,	{ .vop_lookup = gfs_vop_lookup } },
893898Srsb 	{ VOPNAME_SEEK,		{ .vop_seek = fs_seek } },
903898Srsb 	{ VOPNAME_INACTIVE,	{ .vop_inactive = gfs_vop_inactive } },
910Sstevel@tonic-gate 	{ NULL }
920Sstevel@tonic-gate };
93