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