xref: /onnv-gate/usr/src/uts/common/fs/objfs/objfs_common.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
5*5331Samw  * Common Development and Distribution License (the "License").
6*5331Samw  * 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 /*
22*5331Samw  * 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 <sys/errno.h>
290Sstevel@tonic-gate #include <sys/file.h>
300Sstevel@tonic-gate #include <sys/objfs.h>
310Sstevel@tonic-gate #include <sys/objfs_impl.h>
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * For directories, make sure we are using large-file aware interfaces and we
350Sstevel@tonic-gate  * aren't trying to open it writeable.
360Sstevel@tonic-gate  */
370Sstevel@tonic-gate /* ARGSUSED */
380Sstevel@tonic-gate int
objfs_dir_open(vnode_t ** cpp,int flag,cred_t * cr,caller_context_t * ct)39*5331Samw objfs_dir_open(vnode_t **cpp, int flag, cred_t *cr,
40*5331Samw     caller_context_t *ct)
410Sstevel@tonic-gate {
420Sstevel@tonic-gate 	if ((flag & (FOFFMAX | FWRITE)) != FOFFMAX)
430Sstevel@tonic-gate 		return (EINVAL);
440Sstevel@tonic-gate 
450Sstevel@tonic-gate 	return (0);
460Sstevel@tonic-gate }
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * For all vnodes which have no cleanup to do at close time.
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate /* ARGSUSED */
520Sstevel@tonic-gate int
objfs_common_close(vnode_t * vp,int flag,int count,offset_t off,cred_t * cr,caller_context_t * ct)53*5331Samw objfs_common_close(vnode_t *vp, int flag, int count, offset_t off, cred_t *cr,
54*5331Samw     caller_context_t *ct)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	return (0);
570Sstevel@tonic-gate }
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /*
60*5331Samw  * For directories, ensure we're not open for writing.
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate /* ARGSUSED */
630Sstevel@tonic-gate int
objfs_dir_access(vnode_t * vp,int mode,int flags,cred_t * cr,caller_context_t * ct)64*5331Samw objfs_dir_access(vnode_t *vp, int mode, int flags, cred_t *cr,
65*5331Samw     caller_context_t *ct)
660Sstevel@tonic-gate {
670Sstevel@tonic-gate 	if (mode & VWRITE)
680Sstevel@tonic-gate 		return (EACCES);
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 	return (0);
710Sstevel@tonic-gate }
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
740Sstevel@tonic-gate  * Fills in common fields for getattr().
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate int
objfs_common_getattr(vnode_t * vp,vattr_t * vap)770Sstevel@tonic-gate objfs_common_getattr(vnode_t *vp, vattr_t *vap)
780Sstevel@tonic-gate {
790Sstevel@tonic-gate 	vap->va_uid = 0;
800Sstevel@tonic-gate 	vap->va_gid = 0;
810Sstevel@tonic-gate 	vap->va_rdev = 0;
820Sstevel@tonic-gate 	vap->va_blksize = DEV_BSIZE;
830Sstevel@tonic-gate 	vap->va_nblocks = howmany(vap->va_size, vap->va_blksize);
840Sstevel@tonic-gate 	vap->va_seq = 0;
850Sstevel@tonic-gate 	vap->va_fsid = vp->v_vfsp->vfs_dev;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	return (0);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * Returns the number objects currently loaded in the system.
920Sstevel@tonic-gate  */
930Sstevel@tonic-gate int
objfs_nobjs(void)940Sstevel@tonic-gate objfs_nobjs(void)
950Sstevel@tonic-gate {
960Sstevel@tonic-gate 	int count = 0;
970Sstevel@tonic-gate 	struct modctl *mp;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	mutex_enter(&mod_lock);
1000Sstevel@tonic-gate 	mp = &modules;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	do {
1030Sstevel@tonic-gate 		if (mp->mod_loaded)
1040Sstevel@tonic-gate 			count++;
1050Sstevel@tonic-gate 	} while ((mp = mp->mod_next) != &modules);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	mutex_exit(&mod_lock);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 	return (count);
1100Sstevel@tonic-gate }
111