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
5da6c28aamw * Common Development and Distribution License (the "License").
6da6c28aamw * 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/*
22da6c28aamw * 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 <sys/errno.h>
297c478bdstevel@tonic-gate#include <sys/file.h>
307c478bdstevel@tonic-gate#include <sys/objfs.h>
317c478bdstevel@tonic-gate#include <sys/objfs_impl.h>
327c478bdstevel@tonic-gate
337c478bdstevel@tonic-gate/*
347c478bdstevel@tonic-gate * For directories, make sure we are using large-file aware interfaces and we
357c478bdstevel@tonic-gate * aren't trying to open it writeable.
367c478bdstevel@tonic-gate */
377c478bdstevel@tonic-gate/* ARGSUSED */
387c478bdstevel@tonic-gateint
39da6c28aamwobjfs_dir_open(vnode_t **cpp, int flag, cred_t *cr,
40da6c28aamw    caller_context_t *ct)
417c478bdstevel@tonic-gate{
427c478bdstevel@tonic-gate	if ((flag & (FOFFMAX | FWRITE)) != FOFFMAX)
437c478bdstevel@tonic-gate		return (EINVAL);
447c478bdstevel@tonic-gate
457c478bdstevel@tonic-gate	return (0);
467c478bdstevel@tonic-gate}
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gate/*
497c478bdstevel@tonic-gate * For all vnodes which have no cleanup to do at close time.
507c478bdstevel@tonic-gate */
517c478bdstevel@tonic-gate/* ARGSUSED */
527c478bdstevel@tonic-gateint
53da6c28aamwobjfs_common_close(vnode_t *vp, int flag, int count, offset_t off, cred_t *cr,
54da6c28aamw    caller_context_t *ct)
557c478bdstevel@tonic-gate{
567c478bdstevel@tonic-gate	return (0);
577c478bdstevel@tonic-gate}
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate/*
60da6c28aamw * For directories, ensure we're not open for writing.
617c478bdstevel@tonic-gate */
627c478bdstevel@tonic-gate/* ARGSUSED */
637c478bdstevel@tonic-gateint
64da6c28aamwobjfs_dir_access(vnode_t *vp, int mode, int flags, cred_t *cr,
65da6c28aamw    caller_context_t *ct)
667c478bdstevel@tonic-gate{
677c478bdstevel@tonic-gate	if (mode & VWRITE)
687c478bdstevel@tonic-gate		return (EACCES);
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate	return (0);
717c478bdstevel@tonic-gate}
727c478bdstevel@tonic-gate
737c478bdstevel@tonic-gate/*
747c478bdstevel@tonic-gate * Fills in common fields for getattr().
757c478bdstevel@tonic-gate */
767c478bdstevel@tonic-gateint
777c478bdstevel@tonic-gateobjfs_common_getattr(vnode_t *vp, vattr_t *vap)
787c478bdstevel@tonic-gate{
797c478bdstevel@tonic-gate	vap->va_uid = 0;
807c478bdstevel@tonic-gate	vap->va_gid = 0;
817c478bdstevel@tonic-gate	vap->va_rdev = 0;
827c478bdstevel@tonic-gate	vap->va_blksize = DEV_BSIZE;
837c478bdstevel@tonic-gate	vap->va_nblocks = howmany(vap->va_size, vap->va_blksize);
847c478bdstevel@tonic-gate	vap->va_seq = 0;
857c478bdstevel@tonic-gate	vap->va_fsid = vp->v_vfsp->vfs_dev;
867c478bdstevel@tonic-gate
877c478bdstevel@tonic-gate	return (0);
887c478bdstevel@tonic-gate}
897c478bdstevel@tonic-gate
907c478bdstevel@tonic-gate/*
917c478bdstevel@tonic-gate * Returns the number objects currently loaded in the system.
927c478bdstevel@tonic-gate */
937c478bdstevel@tonic-gateint
947c478bdstevel@tonic-gateobjfs_nobjs(void)
957c478bdstevel@tonic-gate{
967c478bdstevel@tonic-gate	int count = 0;
977c478bdstevel@tonic-gate	struct modctl *mp;
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gate	mutex_enter(&mod_lock);
1007c478bdstevel@tonic-gate	mp = &modules;
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate	do {
1037c478bdstevel@tonic-gate		if (mp->mod_loaded)
1047c478bdstevel@tonic-gate			count++;
1057c478bdstevel@tonic-gate	} while ((mp = mp->mod_next) != &modules);
1067c478bdstevel@tonic-gate
1077c478bdstevel@tonic-gate	mutex_exit(&mod_lock);
1087c478bdstevel@tonic-gate
1097c478bdstevel@tonic-gate	return (count);
1107c478bdstevel@tonic-gate}
111