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