17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5aa59c4crsb * Common Development and Distribution License (the "License").
6aa59c4crsb * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
22aa59c4crsb * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
247c478bdstevel@tonic-gate */
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#include <fs/fs_subr.h>
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate#include <sys/kmem.h>
317c478bdstevel@tonic-gate#include <sys/modctl.h>
327c478bdstevel@tonic-gate#include <sys/objfs.h>
337c478bdstevel@tonic-gate#include <sys/objfs_impl.h>
34aa59c4crsb#include <sys/vfs_opreg.h>
357c478bdstevel@tonic-gate#include <sys/stat.h>
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gatestatic gfs_dirent_t objfs_odir_entries[] = {
387c478bdstevel@tonic-gate	{ "object", objfs_create_data, 0 },
397c478bdstevel@tonic-gate	{ NULL }
407c478bdstevel@tonic-gate};
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate/* ARGSUSED */
437c478bdstevel@tonic-gatestatic ino64_t
447c478bdstevel@tonic-gateobjfs_odir_do_inode(vnode_t *vp, int index)
457c478bdstevel@tonic-gate{
467c478bdstevel@tonic-gate	objfs_odirnode_t *odir = vp->v_data;
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gate	return (OBJFS_INO_DATA(odir->objfs_odir_modctl->mod_id));
497c478bdstevel@tonic-gate}
507c478bdstevel@tonic-gate
517c478bdstevel@tonic-gatevnode_t *
527c478bdstevel@tonic-gateobjfs_create_odirnode(vnode_t *pvp, struct modctl *mp)
537c478bdstevel@tonic-gate{
547c478bdstevel@tonic-gate	vnode_t *vp = gfs_dir_create(sizeof (objfs_odirnode_t), pvp,
557c478bdstevel@tonic-gate	    objfs_ops_odir, objfs_odir_entries, objfs_odir_do_inode,
567c478bdstevel@tonic-gate	    OBJFS_NAME_MAX, NULL, NULL);
577c478bdstevel@tonic-gate	objfs_odirnode_t *onode = vp->v_data;
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate	onode->objfs_odir_modctl = mp;
607c478bdstevel@tonic-gate
617c478bdstevel@tonic-gate	return (vp);
627c478bdstevel@tonic-gate}
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gate/* ARGSUSED */
657c478bdstevel@tonic-gatestatic int
66da6c28aamwobjfs_odir_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
67da6c28aamw	caller_context_t *ct)
687c478bdstevel@tonic-gate{
697c478bdstevel@tonic-gate	timestruc_t now;
707c478bdstevel@tonic-gate
717c478bdstevel@tonic-gate	vap->va_type = VDIR;
727c478bdstevel@tonic-gate	vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP |
737c478bdstevel@tonic-gate	    S_IROTH | S_IXOTH;
747c478bdstevel@tonic-gate	vap->va_nodeid = gfs_file_inode(vp);
757c478bdstevel@tonic-gate	vap->va_nlink = vap->va_size = 2;
767c478bdstevel@tonic-gate	gethrestime(&now);
777c478bdstevel@tonic-gate	vap->va_atime = vap->va_ctime = vap->va_mtime = now;
787c478bdstevel@tonic-gate	return (objfs_common_getattr(vp, vap));
797c478bdstevel@tonic-gate}
807c478bdstevel@tonic-gate
817c478bdstevel@tonic-gateconst fs_operation_def_t objfs_tops_odir[] = {
82aa59c4crsb	{ VOPNAME_OPEN,		{ .vop_open = objfs_dir_open } },
83aa59c4crsb	{ VOPNAME_CLOSE,	{ .vop_close = objfs_common_close } },
84aa59c4crsb	{ VOPNAME_IOCTL,	{ .error = fs_inval } },
85aa59c4crsb	{ VOPNAME_GETATTR,	{ .vop_getattr = objfs_odir_getattr } },
86aa59c4crsb	{ VOPNAME_ACCESS,	{ .vop_access = objfs_dir_access } },
87aa59c4crsb	{ VOPNAME_READDIR,	{ .vop_readdir = gfs_vop_readdir } },
88aa59c4crsb	{ VOPNAME_LOOKUP,	{ .vop_lookup = gfs_vop_lookup } },
89aa59c4crsb	{ VOPNAME_SEEK,		{ .vop_seek = fs_seek } },
90aa59c4crsb	{ VOPNAME_INACTIVE,	{ .vop_inactive = gfs_vop_inactive } },
917c478bdstevel@tonic-gate	{ NULL }
927c478bdstevel@tonic-gate};
93