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
5ddfcde86Srsb * Common Development and Distribution License (the "License").
6ddfcde86Srsb * 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 /*
22c242f9a0Schunli zhang - Sun Microsystems - Irvine United States * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
287c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
297c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
307c478bd9Sstevel@tonic-gate #include <sys/errno.h>
317c478bd9Sstevel@tonic-gate #include <sys/param.h>
327c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
337c478bd9Sstevel@tonic-gate #include <sys/systm.h>
347c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
357c478bd9Sstevel@tonic-gate #include <sys/debug.h>
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate #include <sys/fem.h>
387c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
397c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
40aa59c4cbSrsb #include <sys/vfs_opreg.h>
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #define NNODES_DEFAULT 8 /* Default number of nodes in a fem_list */
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate * fl_ntob(n) - Fem_list: number of nodes to bytes
457c478bd9Sstevel@tonic-gate * Given the number of nodes in a fem_list return the size, in bytes,
467c478bd9Sstevel@tonic-gate * of the fem_list structure.
477c478bd9Sstevel@tonic-gate */
487c478bd9Sstevel@tonic-gate #define fl_ntob(n) (sizeof (struct fem_list) + \
497c478bd9Sstevel@tonic-gate ((n) - 1) * sizeof (struct fem_node))
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate typedef enum {
527c478bd9Sstevel@tonic-gate FEMTYPE_NULL, /* Uninitialized */
537c478bd9Sstevel@tonic-gate FEMTYPE_VNODE,
547c478bd9Sstevel@tonic-gate FEMTYPE_VFS,
557c478bd9Sstevel@tonic-gate FEMTYPE_NTYPES
567c478bd9Sstevel@tonic-gate } femtype_t;
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate #define FEM_HEAD(_t) femtype[(_t)].head.fn_op.anon
597c478bd9Sstevel@tonic-gate #define FEM_GUARD(_t) femtype[(_t)].guard
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate static struct fem_type_info {
627c478bd9Sstevel@tonic-gate struct fem_node head;
637c478bd9Sstevel@tonic-gate struct fem_node guard;
647c478bd9Sstevel@tonic-gate femop_t *errf;
657c478bd9Sstevel@tonic-gate } femtype[FEMTYPE_NTYPES];
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate * For each type, two tables - the translation offset definition, which
707c478bd9Sstevel@tonic-gate * is used by fs_build_vector to layout the operation(s) vector; and the
717c478bd9Sstevel@tonic-gate * guard_operation_vector which protects from stack under-run.
727c478bd9Sstevel@tonic-gate */
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate int fem_err();
757c478bd9Sstevel@tonic-gate int fsem_err();
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate #define _FEMOPDEF(name, member) \
79aa59c4cbSrsb { VOPNAME_##name, offsetof(fem_t, femop_##member), NULL, fem_err }
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate static fs_operation_trans_def_t fem_opdef[] = {
827c478bd9Sstevel@tonic-gate _FEMOPDEF(OPEN, open),
837c478bd9Sstevel@tonic-gate _FEMOPDEF(CLOSE, close),
847c478bd9Sstevel@tonic-gate _FEMOPDEF(READ, read),
857c478bd9Sstevel@tonic-gate _FEMOPDEF(WRITE, write),
867c478bd9Sstevel@tonic-gate _FEMOPDEF(IOCTL, ioctl),
877c478bd9Sstevel@tonic-gate _FEMOPDEF(SETFL, setfl),
887c478bd9Sstevel@tonic-gate _FEMOPDEF(GETATTR, getattr),
897c478bd9Sstevel@tonic-gate _FEMOPDEF(SETATTR, setattr),
907c478bd9Sstevel@tonic-gate _FEMOPDEF(ACCESS, access),
917c478bd9Sstevel@tonic-gate _FEMOPDEF(LOOKUP, lookup),
927c478bd9Sstevel@tonic-gate _FEMOPDEF(CREATE, create),
937c478bd9Sstevel@tonic-gate _FEMOPDEF(REMOVE, remove),
947c478bd9Sstevel@tonic-gate _FEMOPDEF(LINK, link),
957c478bd9Sstevel@tonic-gate _FEMOPDEF(RENAME, rename),
967c478bd9Sstevel@tonic-gate _FEMOPDEF(MKDIR, mkdir),
977c478bd9Sstevel@tonic-gate _FEMOPDEF(RMDIR, rmdir),
987c478bd9Sstevel@tonic-gate _FEMOPDEF(READDIR, readdir),
997c478bd9Sstevel@tonic-gate _FEMOPDEF(SYMLINK, symlink),
1007c478bd9Sstevel@tonic-gate _FEMOPDEF(READLINK, readlink),
1017c478bd9Sstevel@tonic-gate _FEMOPDEF(FSYNC, fsync),
1027c478bd9Sstevel@tonic-gate _FEMOPDEF(INACTIVE, inactive),
1037c478bd9Sstevel@tonic-gate _FEMOPDEF(FID, fid),
1047c478bd9Sstevel@tonic-gate _FEMOPDEF(RWLOCK, rwlock),
1057c478bd9Sstevel@tonic-gate _FEMOPDEF(RWUNLOCK, rwunlock),
1067c478bd9Sstevel@tonic-gate _FEMOPDEF(SEEK, seek),
1077c478bd9Sstevel@tonic-gate _FEMOPDEF(CMP, cmp),
1087c478bd9Sstevel@tonic-gate _FEMOPDEF(FRLOCK, frlock),
1097c478bd9Sstevel@tonic-gate _FEMOPDEF(SPACE, space),
1107c478bd9Sstevel@tonic-gate _FEMOPDEF(REALVP, realvp),
1117c478bd9Sstevel@tonic-gate _FEMOPDEF(GETPAGE, getpage),
1127c478bd9Sstevel@tonic-gate _FEMOPDEF(PUTPAGE, putpage),
1137c478bd9Sstevel@tonic-gate _FEMOPDEF(MAP, map),
1147c478bd9Sstevel@tonic-gate _FEMOPDEF(ADDMAP, addmap),
1157c478bd9Sstevel@tonic-gate _FEMOPDEF(DELMAP, delmap),
1167c478bd9Sstevel@tonic-gate _FEMOPDEF(POLL, poll),
1177c478bd9Sstevel@tonic-gate _FEMOPDEF(DUMP, dump),
1187c478bd9Sstevel@tonic-gate _FEMOPDEF(PATHCONF, pathconf),
1197c478bd9Sstevel@tonic-gate _FEMOPDEF(PAGEIO, pageio),
1207c478bd9Sstevel@tonic-gate _FEMOPDEF(DUMPCTL, dumpctl),
1217c478bd9Sstevel@tonic-gate _FEMOPDEF(DISPOSE, dispose),
1227c478bd9Sstevel@tonic-gate _FEMOPDEF(SETSECATTR, setsecattr),
1237c478bd9Sstevel@tonic-gate _FEMOPDEF(GETSECATTR, getsecattr),
1247c478bd9Sstevel@tonic-gate _FEMOPDEF(SHRLOCK, shrlock),
1257c478bd9Sstevel@tonic-gate _FEMOPDEF(VNEVENT, vnevent),
126c242f9a0Schunli zhang - Sun Microsystems - Irvine United States _FEMOPDEF(REQZCBUF, reqzcbuf),
127c242f9a0Schunli zhang - Sun Microsystems - Irvine United States _FEMOPDEF(RETZCBUF, retzcbuf),
1287c478bd9Sstevel@tonic-gate { NULL, 0, NULL, NULL }
1297c478bd9Sstevel@tonic-gate };
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate #define _FEMGUARD(name, ignore) \
1337c478bd9Sstevel@tonic-gate { VOPNAME_##name, (femop_t *)fem_err }
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate static struct fs_operation_def fem_guard_ops[] = {
1367c478bd9Sstevel@tonic-gate _FEMGUARD(OPEN, open),
1377c478bd9Sstevel@tonic-gate _FEMGUARD(CLOSE, close),
1387c478bd9Sstevel@tonic-gate _FEMGUARD(READ, read),
1397c478bd9Sstevel@tonic-gate _FEMGUARD(WRITE, write),
1407c478bd9Sstevel@tonic-gate _FEMGUARD(IOCTL, ioctl),
1417c478bd9Sstevel@tonic-gate _FEMGUARD(SETFL, setfl),
1427c478bd9Sstevel@tonic-gate _FEMGUARD(GETATTR, getattr),
1437c478bd9Sstevel@tonic-gate _FEMGUARD(SETATTR, setattr),
1447c478bd9Sstevel@tonic-gate _FEMGUARD(ACCESS, access),
1457c478bd9Sstevel@tonic-gate _FEMGUARD(LOOKUP, lookup),
1467c478bd9Sstevel@tonic-gate _FEMGUARD(CREATE, create),
1477c478bd9Sstevel@tonic-gate _FEMGUARD(REMOVE, remove),
1487c478bd9Sstevel@tonic-gate _FEMGUARD(LINK, link),
1497c478bd9Sstevel@tonic-gate _FEMGUARD(RENAME, rename),
1507c478bd9Sstevel@tonic-gate _FEMGUARD(MKDIR, mkdir),
1517c478bd9Sstevel@tonic-gate _FEMGUARD(RMDIR, rmdir),
1527c478bd9Sstevel@tonic-gate _FEMGUARD(READDIR, readdir),
1537c478bd9Sstevel@tonic-gate _FEMGUARD(SYMLINK, symlink),
1547c478bd9Sstevel@tonic-gate _FEMGUARD(READLINK, readlink),
1557c478bd9Sstevel@tonic-gate _FEMGUARD(FSYNC, fsync),
1567c478bd9Sstevel@tonic-gate _FEMGUARD(INACTIVE, inactive),
1577c478bd9Sstevel@tonic-gate _FEMGUARD(FID, fid),
1587c478bd9Sstevel@tonic-gate _FEMGUARD(RWLOCK, rwlock),
1597c478bd9Sstevel@tonic-gate _FEMGUARD(RWUNLOCK, rwunlock),
1607c478bd9Sstevel@tonic-gate _FEMGUARD(SEEK, seek),
1617c478bd9Sstevel@tonic-gate _FEMGUARD(CMP, cmp),
1627c478bd9Sstevel@tonic-gate _FEMGUARD(FRLOCK, frlock),
1637c478bd9Sstevel@tonic-gate _FEMGUARD(SPACE, space),
1647c478bd9Sstevel@tonic-gate _FEMGUARD(REALVP, realvp),
1657c478bd9Sstevel@tonic-gate _FEMGUARD(GETPAGE, getpage),
1667c478bd9Sstevel@tonic-gate _FEMGUARD(PUTPAGE, putpage),
1677c478bd9Sstevel@tonic-gate _FEMGUARD(MAP, map),
1687c478bd9Sstevel@tonic-gate _FEMGUARD(ADDMAP, addmap),
1697c478bd9Sstevel@tonic-gate _FEMGUARD(DELMAP, delmap),
1707c478bd9Sstevel@tonic-gate _FEMGUARD(POLL, poll),
1717c478bd9Sstevel@tonic-gate _FEMGUARD(DUMP, dump),
1727c478bd9Sstevel@tonic-gate _FEMGUARD(PATHCONF, pathconf),
1737c478bd9Sstevel@tonic-gate _FEMGUARD(PAGEIO, pageio),
1747c478bd9Sstevel@tonic-gate _FEMGUARD(DUMPCTL, dumpctl),
1757c478bd9Sstevel@tonic-gate _FEMGUARD(DISPOSE, dispose),
1767c478bd9Sstevel@tonic-gate _FEMGUARD(SETSECATTR, setsecattr),
1777c478bd9Sstevel@tonic-gate _FEMGUARD(GETSECATTR, getsecattr),
1787c478bd9Sstevel@tonic-gate _FEMGUARD(SHRLOCK, shrlock),
1797c478bd9Sstevel@tonic-gate _FEMGUARD(VNEVENT, vnevent),
180c242f9a0Schunli zhang - Sun Microsystems - Irvine United States _FEMGUARD(REQZCBUF, reqzcbuf),
181c242f9a0Schunli zhang - Sun Microsystems - Irvine United States _FEMGUARD(RETZCBUF, retzcbuf),
1827c478bd9Sstevel@tonic-gate { NULL, NULL }
1837c478bd9Sstevel@tonic-gate };
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate #define _FSEMOPDEF(name, member) \
187aa59c4cbSrsb { VFSNAME_##name, offsetof(fsem_t, fsemop_##member), NULL, fsem_err }
1887c478bd9Sstevel@tonic-gate
1897c478bd9Sstevel@tonic-gate static fs_operation_trans_def_t fsem_opdef[] = {
190b1659ed9SToomas Soome _FSEMOPDEF(MOUNT, mount),
1917c478bd9Sstevel@tonic-gate _FSEMOPDEF(UNMOUNT, unmount),
1927c478bd9Sstevel@tonic-gate _FSEMOPDEF(ROOT, root),
1937c478bd9Sstevel@tonic-gate _FSEMOPDEF(STATVFS, statvfs),
1947c478bd9Sstevel@tonic-gate _FSEMOPDEF(SYNC, sync),
1957c478bd9Sstevel@tonic-gate _FSEMOPDEF(VGET, vget),
1967c478bd9Sstevel@tonic-gate _FSEMOPDEF(MOUNTROOT, mountroot),
1977c478bd9Sstevel@tonic-gate _FSEMOPDEF(FREEVFS, freevfs),
1987c478bd9Sstevel@tonic-gate _FSEMOPDEF(VNSTATE, vnstate),
1997c478bd9Sstevel@tonic-gate { NULL, 0, NULL, NULL }
2007c478bd9Sstevel@tonic-gate };
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate #define _FSEMGUARD(name, ignore) \
2037c478bd9Sstevel@tonic-gate { VFSNAME_##name, (femop_t *)fsem_err }
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate static struct fs_operation_def fsem_guard_ops[] = {
206b1659ed9SToomas Soome _FSEMGUARD(MOUNT, mount),
2077c478bd9Sstevel@tonic-gate _FSEMGUARD(UNMOUNT, unmount),
2087c478bd9Sstevel@tonic-gate _FSEMGUARD(ROOT, root),
2097c478bd9Sstevel@tonic-gate _FSEMGUARD(STATVFS, statvfs),
2107c478bd9Sstevel@tonic-gate _FSEMGUARD(SYNC, sync),
2117c478bd9Sstevel@tonic-gate _FSEMGUARD(VGET, vget),
2127c478bd9Sstevel@tonic-gate _FSEMGUARD(MOUNTROOT, mountroot),
2137c478bd9Sstevel@tonic-gate _FSEMGUARD(FREEVFS, freevfs),
2147c478bd9Sstevel@tonic-gate _FSEMGUARD(VNSTATE, vnstate),
2157c478bd9Sstevel@tonic-gate { NULL, NULL}
2167c478bd9Sstevel@tonic-gate };
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate /*
2207c478bd9Sstevel@tonic-gate * vsop_find, vfsop_find -
2217c478bd9Sstevel@tonic-gate *
2227c478bd9Sstevel@tonic-gate * These macros descend the stack until they find either a basic
2237c478bd9Sstevel@tonic-gate * vnode/vfs operation [ indicated by a null fn_available ] or a
2247c478bd9Sstevel@tonic-gate * stacked item where this method is non-null [_vsop].
2257c478bd9Sstevel@tonic-gate *
2267c478bd9Sstevel@tonic-gate * The DEBUG one is written with a single function which manually applies
2277c478bd9Sstevel@tonic-gate * the structure offsets. It can have additional debugging support.
2287c478bd9Sstevel@tonic-gate */
2297c478bd9Sstevel@tonic-gate
2307c478bd9Sstevel@tonic-gate #ifndef DEBUG
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate #define vsop_find(ap, func, funct, arg0, _vop, _vsop) \
2337c478bd9Sstevel@tonic-gate for (;;) { \
2347c478bd9Sstevel@tonic-gate if ((ap)->fa_fnode->fn_available == NULL) { \
2357c478bd9Sstevel@tonic-gate *(func) = (funct (*)())((ap)->fa_fnode->fn_op.vnode->_vop); \
2367c478bd9Sstevel@tonic-gate *(arg0) = (void *)(ap)->fa_vnode.vp; \
2377c478bd9Sstevel@tonic-gate break; \
2387c478bd9Sstevel@tonic-gate } else if ((*(func) = (funct (*)())((ap)->fa_fnode->fn_op.fem->_vsop))\
2397c478bd9Sstevel@tonic-gate != NULL) { \
2407c478bd9Sstevel@tonic-gate *(arg0) = (void *) (ap); \
2417c478bd9Sstevel@tonic-gate break; \
2427c478bd9Sstevel@tonic-gate } else { \
2437c478bd9Sstevel@tonic-gate (ap)->fa_fnode--; \
2447c478bd9Sstevel@tonic-gate } \
2457c478bd9Sstevel@tonic-gate } \
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate #define vfsop_find(ap, func, funct, arg0, _vop, _vsop) \
2487c478bd9Sstevel@tonic-gate for (;;) { \
2497c478bd9Sstevel@tonic-gate if ((ap)->fa_fnode->fn_available == NULL) { \
2507c478bd9Sstevel@tonic-gate *(func) = (funct (*)())((ap)->fa_fnode->fn_op.vfs->_vop); \
2517c478bd9Sstevel@tonic-gate *(arg0) = (void *)(ap)->fa_vnode.vp; \
2527c478bd9Sstevel@tonic-gate break; \
2537c478bd9Sstevel@tonic-gate } else if ((*(func) = (funct (*)())((ap)->fa_fnode->fn_op.fsem->_vsop))\
2547c478bd9Sstevel@tonic-gate != NULL) { \
2557c478bd9Sstevel@tonic-gate *(arg0) = (void *) (ap); \
2567c478bd9Sstevel@tonic-gate break; \
2577c478bd9Sstevel@tonic-gate } else { \
2587c478bd9Sstevel@tonic-gate (ap)->fa_fnode--; \
2597c478bd9Sstevel@tonic-gate } \
2607c478bd9Sstevel@tonic-gate } \
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate #else
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate #define vsop_find(ap, func, funct, arg0, _vop, _vsop) \
2657c478bd9Sstevel@tonic-gate *(arg0) = _op_find((ap), (void **)(func), \
2667c478bd9Sstevel@tonic-gate offsetof(vnodeops_t, _vop), offsetof(fem_t, _vsop))
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate #define vfsop_find(ap, func, funct, arg0, _fop, _fsop) \
2697c478bd9Sstevel@tonic-gate *(arg0) = _op_find((ap), (void **)(func), \
2707c478bd9Sstevel@tonic-gate offsetof(vfsops_t, _fop), offsetof(fsem_t, _fsop))
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gate static void *
_op_find(femarg_t * ap,void ** fp,int offs0,int offs1)2737c478bd9Sstevel@tonic-gate _op_find(femarg_t *ap, void **fp, int offs0, int offs1)
2747c478bd9Sstevel@tonic-gate {
2757c478bd9Sstevel@tonic-gate void *ptr;
2767c478bd9Sstevel@tonic-gate for (;;) {
2777c478bd9Sstevel@tonic-gate struct fem_node *fnod = ap->fa_fnode;
2787c478bd9Sstevel@tonic-gate if (fnod->fn_available == NULL) {
2797c478bd9Sstevel@tonic-gate *fp = *(void **)((char *)fnod->fn_op.anon + offs0);
2807c478bd9Sstevel@tonic-gate ptr = (void *)(ap->fa_vnode.anon);
2817c478bd9Sstevel@tonic-gate break;
2827c478bd9Sstevel@tonic-gate } else if ((*fp = *(void **)((char *)fnod->fn_op.anon+offs1))
283d7334e51Srm != NULL) {
2847c478bd9Sstevel@tonic-gate ptr = (void *)(ap);
2857c478bd9Sstevel@tonic-gate break;
2867c478bd9Sstevel@tonic-gate } else {
2877c478bd9Sstevel@tonic-gate ap->fa_fnode--;
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate return (ptr);
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate #endif
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate static fem_t *
fem_alloc()2957c478bd9Sstevel@tonic-gate fem_alloc()
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate fem_t *p;
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gate p = (fem_t *)kmem_alloc(sizeof (*p), KM_SLEEP);
3007c478bd9Sstevel@tonic-gate return (p);
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate void
fem_free(fem_t * p)3047c478bd9Sstevel@tonic-gate fem_free(fem_t *p)
3057c478bd9Sstevel@tonic-gate {
3067c478bd9Sstevel@tonic-gate kmem_free(p, sizeof (*p));
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate
3097c478bd9Sstevel@tonic-gate static fsem_t *
fsem_alloc()3107c478bd9Sstevel@tonic-gate fsem_alloc()
3117c478bd9Sstevel@tonic-gate {
3127c478bd9Sstevel@tonic-gate fsem_t *p;
3137c478bd9Sstevel@tonic-gate
3147c478bd9Sstevel@tonic-gate p = (fsem_t *)kmem_alloc(sizeof (*p), KM_SLEEP);
3157c478bd9Sstevel@tonic-gate return (p);
3167c478bd9Sstevel@tonic-gate }
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate void
fsem_free(fsem_t * p)3197c478bd9Sstevel@tonic-gate fsem_free(fsem_t *p)
3207c478bd9Sstevel@tonic-gate {
3217c478bd9Sstevel@tonic-gate kmem_free(p, sizeof (*p));
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate /*
3267c478bd9Sstevel@tonic-gate * fem_get, fem_release - manage reference counts on the stack.
3277c478bd9Sstevel@tonic-gate *
3287c478bd9Sstevel@tonic-gate * The list of monitors can be updated while operations are in
3297c478bd9Sstevel@tonic-gate * progress on the object.
3307c478bd9Sstevel@tonic-gate *
3317c478bd9Sstevel@tonic-gate * The reference count facilitates this by counting the number of
3327c478bd9Sstevel@tonic-gate * current accessors, and deconstructing the list when it is exhausted.
3337c478bd9Sstevel@tonic-gate *
3347c478bd9Sstevel@tonic-gate * fem_lock() is required to:
3357c478bd9Sstevel@tonic-gate * look at femh_list
3367c478bd9Sstevel@tonic-gate * update what femh_list points to
3377c478bd9Sstevel@tonic-gate * update femh_list
3387c478bd9Sstevel@tonic-gate * increase femh_list->feml_refc.
3397c478bd9Sstevel@tonic-gate *
3407c478bd9Sstevel@tonic-gate * the feml_refc can decrement without holding the lock;
3417c478bd9Sstevel@tonic-gate * when feml_refc becomes zero, the list is destroyed.
3427c478bd9Sstevel@tonic-gate *
3437c478bd9Sstevel@tonic-gate */
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate static struct fem_list *
fem_lock(struct fem_head * fp)3467c478bd9Sstevel@tonic-gate fem_lock(struct fem_head *fp)
3477c478bd9Sstevel@tonic-gate {
3487c478bd9Sstevel@tonic-gate struct fem_list *sp = NULL;
3497c478bd9Sstevel@tonic-gate
3507c478bd9Sstevel@tonic-gate ASSERT(fp != NULL);
3517c478bd9Sstevel@tonic-gate mutex_enter(&fp->femh_lock);
3527c478bd9Sstevel@tonic-gate sp = fp->femh_list;
3537c478bd9Sstevel@tonic-gate return (sp);
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate
3567c478bd9Sstevel@tonic-gate static void
fem_unlock(struct fem_head * fp)3577c478bd9Sstevel@tonic-gate fem_unlock(struct fem_head *fp)
3587c478bd9Sstevel@tonic-gate {
3597c478bd9Sstevel@tonic-gate ASSERT(fp != NULL);
3607c478bd9Sstevel@tonic-gate mutex_exit(&fp->femh_lock);
3617c478bd9Sstevel@tonic-gate }
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate /*
3647c478bd9Sstevel@tonic-gate * Addref can only be called while its head->lock is held.
3657c478bd9Sstevel@tonic-gate */
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gate static void
fem_addref(struct fem_list * sp)3687c478bd9Sstevel@tonic-gate fem_addref(struct fem_list *sp)
3697c478bd9Sstevel@tonic-gate {
3701a5e258fSJosef 'Jeff' Sipek atomic_inc_32(&sp->feml_refc);
3717c478bd9Sstevel@tonic-gate }
3727c478bd9Sstevel@tonic-gate
373677d097aSjwahlig static uint32_t
fem_delref(struct fem_list * sp)3747c478bd9Sstevel@tonic-gate fem_delref(struct fem_list *sp)
3757c478bd9Sstevel@tonic-gate {
3761a5e258fSJosef 'Jeff' Sipek return (atomic_dec_32_nv(&sp->feml_refc));
3777c478bd9Sstevel@tonic-gate }
3787c478bd9Sstevel@tonic-gate
3797c478bd9Sstevel@tonic-gate static struct fem_list *
fem_get(struct fem_head * fp)3807c478bd9Sstevel@tonic-gate fem_get(struct fem_head *fp)
3817c478bd9Sstevel@tonic-gate {
3827c478bd9Sstevel@tonic-gate struct fem_list *sp = NULL;
3837c478bd9Sstevel@tonic-gate
3847c478bd9Sstevel@tonic-gate if (fp != NULL) {
3857c478bd9Sstevel@tonic-gate if ((sp = fem_lock(fp)) != NULL) {
3867c478bd9Sstevel@tonic-gate fem_addref(sp);
3877c478bd9Sstevel@tonic-gate }
3887c478bd9Sstevel@tonic-gate fem_unlock(fp);
3897c478bd9Sstevel@tonic-gate }
3907c478bd9Sstevel@tonic-gate return (sp);
3917c478bd9Sstevel@tonic-gate }
3927c478bd9Sstevel@tonic-gate
3937c478bd9Sstevel@tonic-gate static void
fem_release(struct fem_list * sp)3947c478bd9Sstevel@tonic-gate fem_release(struct fem_list *sp)
3957c478bd9Sstevel@tonic-gate {
3967c478bd9Sstevel@tonic-gate int i;
3977c478bd9Sstevel@tonic-gate
398677d097aSjwahlig ASSERT(sp->feml_refc != 0);
399677d097aSjwahlig if (fem_delref(sp) == 0) {
4007c478bd9Sstevel@tonic-gate /*
4017c478bd9Sstevel@tonic-gate * Before freeing the list, we need to release the
4027c478bd9Sstevel@tonic-gate * caller-provided data.
4037c478bd9Sstevel@tonic-gate */
4047c478bd9Sstevel@tonic-gate for (i = sp->feml_tos; i > 0; i--) {
4057c478bd9Sstevel@tonic-gate struct fem_node *fnp = &sp->feml_nodes[i];
4067c478bd9Sstevel@tonic-gate
4077c478bd9Sstevel@tonic-gate if (fnp->fn_av_rele)
4087c478bd9Sstevel@tonic-gate (*(fnp->fn_av_rele))(fnp->fn_available);
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate kmem_free(sp, fl_ntob(sp->feml_ssize));
4117c478bd9Sstevel@tonic-gate }
4127c478bd9Sstevel@tonic-gate }
4137c478bd9Sstevel@tonic-gate
4147c478bd9Sstevel@tonic-gate
4157c478bd9Sstevel@tonic-gate /*
4167c478bd9Sstevel@tonic-gate * These are the 'head' operations which perform the interposition.
4177c478bd9Sstevel@tonic-gate *
4187c478bd9Sstevel@tonic-gate * This set must be 1:1, onto with the (vnodeops, vfsos).
4197c478bd9Sstevel@tonic-gate *
4207c478bd9Sstevel@tonic-gate * If there is a desire to globally disable interposition for a particular
4217c478bd9Sstevel@tonic-gate * method, the corresponding 'head' routine should unearth the base method
4227c478bd9Sstevel@tonic-gate * and invoke it directly rather than bypassing the function.
4237c478bd9Sstevel@tonic-gate *
4247c478bd9Sstevel@tonic-gate * All the functions are virtually the same, save for names, types & args.
4257c478bd9Sstevel@tonic-gate * 1. get a reference to the monitor stack for this object.
4267c478bd9Sstevel@tonic-gate * 2. store the top of stack into the femarg structure.
4277c478bd9Sstevel@tonic-gate * 3. store the basic object (vnode *, vnode **, vfs *) in the femarg struc.
4287c478bd9Sstevel@tonic-gate * 4. invoke the "top" method for this object.
4297c478bd9Sstevel@tonic-gate * 5. release the reference to the monitor stack.
4307c478bd9Sstevel@tonic-gate *
4317c478bd9Sstevel@tonic-gate */
4327c478bd9Sstevel@tonic-gate
4337c478bd9Sstevel@tonic-gate static int
vhead_open(vnode_t ** vpp,int mode,cred_t * cr,caller_context_t * ct)434da6c28aaSamw vhead_open(vnode_t **vpp, int mode, cred_t *cr, caller_context_t *ct)
4357c478bd9Sstevel@tonic-gate {
4367c478bd9Sstevel@tonic-gate femarg_t farg;
4377c478bd9Sstevel@tonic-gate struct fem_list *femsp;
4387c478bd9Sstevel@tonic-gate int (*func)();
4397c478bd9Sstevel@tonic-gate void *arg0;
4407c478bd9Sstevel@tonic-gate int errc;
4417c478bd9Sstevel@tonic-gate
4427c478bd9Sstevel@tonic-gate if ((femsp = fem_lock((*vpp)->v_femhead)) == NULL) {
4437c478bd9Sstevel@tonic-gate func = (int (*)()) ((*vpp)->v_op->vop_open);
4447c478bd9Sstevel@tonic-gate arg0 = (void *)vpp;
4457c478bd9Sstevel@tonic-gate fem_unlock((*vpp)->v_femhead);
446da6c28aaSamw errc = (*func)(arg0, mode, cr, ct);
4477c478bd9Sstevel@tonic-gate } else {
4487c478bd9Sstevel@tonic-gate fem_addref(femsp);
4497c478bd9Sstevel@tonic-gate fem_unlock((*vpp)->v_femhead);
4507c478bd9Sstevel@tonic-gate farg.fa_vnode.vpp = vpp;
4517c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
452aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_open, femop_open);
453da6c28aaSamw errc = (*func)(arg0, mode, cr, ct);
4547c478bd9Sstevel@tonic-gate fem_release(femsp);
4557c478bd9Sstevel@tonic-gate }
4567c478bd9Sstevel@tonic-gate return (errc);
4577c478bd9Sstevel@tonic-gate }
4587c478bd9Sstevel@tonic-gate
4597c478bd9Sstevel@tonic-gate static int
vhead_close(vnode_t * vp,int flag,int count,offset_t offset,cred_t * cr,caller_context_t * ct)460da6c28aaSamw vhead_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr,
461b1659ed9SToomas Soome caller_context_t *ct)
4627c478bd9Sstevel@tonic-gate {
4637c478bd9Sstevel@tonic-gate femarg_t farg;
4647c478bd9Sstevel@tonic-gate struct fem_list *femsp;
4657c478bd9Sstevel@tonic-gate int (*func)();
4667c478bd9Sstevel@tonic-gate void *arg0;
4677c478bd9Sstevel@tonic-gate int errc;
4687c478bd9Sstevel@tonic-gate
4697c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
4707c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_close);
4717c478bd9Sstevel@tonic-gate arg0 = vp;
4727c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
473da6c28aaSamw errc = (*func)(arg0, flag, count, offset, cr, ct);
4747c478bd9Sstevel@tonic-gate } else {
4757c478bd9Sstevel@tonic-gate fem_addref(femsp);
4767c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
4777c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
4787c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
479aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_close, femop_close);
480da6c28aaSamw errc = (*func)(arg0, flag, count, offset, cr, ct);
4817c478bd9Sstevel@tonic-gate fem_release(femsp);
4827c478bd9Sstevel@tonic-gate }
4837c478bd9Sstevel@tonic-gate return (errc);
4847c478bd9Sstevel@tonic-gate }
4857c478bd9Sstevel@tonic-gate
4867c478bd9Sstevel@tonic-gate static int
vhead_read(vnode_t * vp,uio_t * uiop,int ioflag,cred_t * cr,caller_context_t * ct)4877c478bd9Sstevel@tonic-gate vhead_read(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr,
488b1659ed9SToomas Soome caller_context_t *ct)
4897c478bd9Sstevel@tonic-gate {
4907c478bd9Sstevel@tonic-gate femarg_t farg;
4917c478bd9Sstevel@tonic-gate struct fem_list *femsp;
4927c478bd9Sstevel@tonic-gate int (*func)();
4937c478bd9Sstevel@tonic-gate void *arg0;
4947c478bd9Sstevel@tonic-gate int errc;
4957c478bd9Sstevel@tonic-gate
4967c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
4977c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_read);
4987c478bd9Sstevel@tonic-gate arg0 = vp;
4997c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5007c478bd9Sstevel@tonic-gate errc = (*func)(arg0, uiop, ioflag, cr, ct);
5017c478bd9Sstevel@tonic-gate } else {
5027c478bd9Sstevel@tonic-gate fem_addref(femsp);
5037c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5047c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
5057c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
506aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_read, femop_read);
5077c478bd9Sstevel@tonic-gate errc = (*func)(arg0, uiop, ioflag, cr, ct);
5087c478bd9Sstevel@tonic-gate fem_release(femsp);
5097c478bd9Sstevel@tonic-gate }
5107c478bd9Sstevel@tonic-gate return (errc);
5117c478bd9Sstevel@tonic-gate }
5127c478bd9Sstevel@tonic-gate
5137c478bd9Sstevel@tonic-gate static int
vhead_write(vnode_t * vp,uio_t * uiop,int ioflag,cred_t * cr,caller_context_t * ct)5147c478bd9Sstevel@tonic-gate vhead_write(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr,
515b1659ed9SToomas Soome caller_context_t *ct)
5167c478bd9Sstevel@tonic-gate {
5177c478bd9Sstevel@tonic-gate femarg_t farg;
5187c478bd9Sstevel@tonic-gate struct fem_list *femsp;
5197c478bd9Sstevel@tonic-gate int (*func)();
5207c478bd9Sstevel@tonic-gate void *arg0;
5217c478bd9Sstevel@tonic-gate int errc;
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5247c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_write);
5257c478bd9Sstevel@tonic-gate arg0 = vp;
5267c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5277c478bd9Sstevel@tonic-gate errc = (*func)(arg0, uiop, ioflag, cr, ct);
5287c478bd9Sstevel@tonic-gate } else {
5297c478bd9Sstevel@tonic-gate fem_addref(femsp);
5307c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5317c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
5327c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
533aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_write, femop_write);
5347c478bd9Sstevel@tonic-gate errc = (*func)(arg0, uiop, ioflag, cr, ct);
5357c478bd9Sstevel@tonic-gate fem_release(femsp);
5367c478bd9Sstevel@tonic-gate }
5377c478bd9Sstevel@tonic-gate return (errc);
5387c478bd9Sstevel@tonic-gate }
5397c478bd9Sstevel@tonic-gate
5407c478bd9Sstevel@tonic-gate static int
vhead_ioctl(vnode_t * vp,int cmd,intptr_t arg,int flag,cred_t * cr,int * rvalp,caller_context_t * ct)5417c478bd9Sstevel@tonic-gate vhead_ioctl(vnode_t *vp, int cmd, intptr_t arg, int flag, cred_t *cr,
542b1659ed9SToomas Soome int *rvalp, caller_context_t *ct)
5437c478bd9Sstevel@tonic-gate {
5447c478bd9Sstevel@tonic-gate femarg_t farg;
5457c478bd9Sstevel@tonic-gate struct fem_list *femsp;
5467c478bd9Sstevel@tonic-gate int (*func)();
5477c478bd9Sstevel@tonic-gate void *arg0;
5487c478bd9Sstevel@tonic-gate int errc;
5497c478bd9Sstevel@tonic-gate
5507c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5517c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_ioctl);
5527c478bd9Sstevel@tonic-gate arg0 = vp;
5537c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
554da6c28aaSamw errc = (*func)(arg0, cmd, arg, flag, cr, rvalp, ct);
5557c478bd9Sstevel@tonic-gate } else {
5567c478bd9Sstevel@tonic-gate fem_addref(femsp);
5577c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5587c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
5597c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
560aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_ioctl, femop_ioctl);
561da6c28aaSamw errc = (*func)(arg0, cmd, arg, flag, cr, rvalp, ct);
5627c478bd9Sstevel@tonic-gate fem_release(femsp);
5637c478bd9Sstevel@tonic-gate }
5647c478bd9Sstevel@tonic-gate return (errc);
5657c478bd9Sstevel@tonic-gate }
5667c478bd9Sstevel@tonic-gate
5677c478bd9Sstevel@tonic-gate static int
vhead_setfl(vnode_t * vp,int oflags,int nflags,cred_t * cr,caller_context_t * ct)568da6c28aaSamw vhead_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr,
569b1659ed9SToomas Soome caller_context_t *ct)
5707c478bd9Sstevel@tonic-gate {
5717c478bd9Sstevel@tonic-gate femarg_t farg;
5727c478bd9Sstevel@tonic-gate struct fem_list *femsp;
5737c478bd9Sstevel@tonic-gate int (*func)();
5747c478bd9Sstevel@tonic-gate void *arg0;
5757c478bd9Sstevel@tonic-gate int errc;
5767c478bd9Sstevel@tonic-gate
5777c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5787c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_setfl);
5797c478bd9Sstevel@tonic-gate arg0 = vp;
5807c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
581da6c28aaSamw errc = (*func)(arg0, oflags, nflags, cr, ct);
5827c478bd9Sstevel@tonic-gate } else {
5837c478bd9Sstevel@tonic-gate fem_addref(femsp);
5847c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
5857c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
5867c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
587aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_setfl, femop_setfl);
588da6c28aaSamw errc = (*func)(arg0, oflags, nflags, cr, ct);
5897c478bd9Sstevel@tonic-gate fem_release(femsp);
5907c478bd9Sstevel@tonic-gate }
5917c478bd9Sstevel@tonic-gate return (errc);
5927c478bd9Sstevel@tonic-gate }
5937c478bd9Sstevel@tonic-gate
5947c478bd9Sstevel@tonic-gate static int
vhead_getattr(vnode_t * vp,vattr_t * vap,int flags,cred_t * cr,caller_context_t * ct)595da6c28aaSamw vhead_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
596b1659ed9SToomas Soome caller_context_t *ct)
5977c478bd9Sstevel@tonic-gate {
5987c478bd9Sstevel@tonic-gate femarg_t farg;
5997c478bd9Sstevel@tonic-gate struct fem_list *femsp;
6007c478bd9Sstevel@tonic-gate int (*func)();
6017c478bd9Sstevel@tonic-gate void *arg0;
6027c478bd9Sstevel@tonic-gate int errc;
6037c478bd9Sstevel@tonic-gate
6047c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6057c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_getattr);
6067c478bd9Sstevel@tonic-gate arg0 = vp;
6077c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
608da6c28aaSamw errc = (*func)(arg0, vap, flags, cr, ct);
6097c478bd9Sstevel@tonic-gate } else {
6107c478bd9Sstevel@tonic-gate fem_addref(femsp);
6117c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
6127c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
6137c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6147c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_getattr,
615d7334e51Srm femop_getattr);
616da6c28aaSamw errc = (*func)(arg0, vap, flags, cr, ct);
6177c478bd9Sstevel@tonic-gate fem_release(femsp);
6187c478bd9Sstevel@tonic-gate }
6197c478bd9Sstevel@tonic-gate return (errc);
6207c478bd9Sstevel@tonic-gate }
6217c478bd9Sstevel@tonic-gate
6227c478bd9Sstevel@tonic-gate static int
vhead_setattr(vnode_t * vp,vattr_t * vap,int flags,cred_t * cr,caller_context_t * ct)6237c478bd9Sstevel@tonic-gate vhead_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
624b1659ed9SToomas Soome caller_context_t *ct)
6257c478bd9Sstevel@tonic-gate {
6267c478bd9Sstevel@tonic-gate femarg_t farg;
6277c478bd9Sstevel@tonic-gate struct fem_list *femsp;
6287c478bd9Sstevel@tonic-gate int (*func)();
6297c478bd9Sstevel@tonic-gate void *arg0;
6307c478bd9Sstevel@tonic-gate int errc;
6317c478bd9Sstevel@tonic-gate
6327c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6337c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_setattr);
6347c478bd9Sstevel@tonic-gate arg0 = vp;
6357c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
6367c478bd9Sstevel@tonic-gate errc = (*func)(arg0, vap, flags, cr, ct);
6377c478bd9Sstevel@tonic-gate } else {
6387c478bd9Sstevel@tonic-gate fem_addref(femsp);
6397c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
6407c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
6417c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6427c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_setattr,
643d7334e51Srm femop_setattr);
6447c478bd9Sstevel@tonic-gate errc = (*func)(arg0, vap, flags, cr, ct);
6457c478bd9Sstevel@tonic-gate fem_release(femsp);
6467c478bd9Sstevel@tonic-gate }
6477c478bd9Sstevel@tonic-gate return (errc);
6487c478bd9Sstevel@tonic-gate }
6497c478bd9Sstevel@tonic-gate
6507c478bd9Sstevel@tonic-gate static int
vhead_access(vnode_t * vp,int mode,int flags,cred_t * cr,caller_context_t * ct)651da6c28aaSamw vhead_access(vnode_t *vp, int mode, int flags, cred_t *cr,
652b1659ed9SToomas Soome caller_context_t *ct)
6537c478bd9Sstevel@tonic-gate {
6547c478bd9Sstevel@tonic-gate femarg_t farg;
6557c478bd9Sstevel@tonic-gate struct fem_list *femsp;
6567c478bd9Sstevel@tonic-gate int (*func)();
6577c478bd9Sstevel@tonic-gate void *arg0;
6587c478bd9Sstevel@tonic-gate int errc;
6597c478bd9Sstevel@tonic-gate
6607c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6617c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_access);
6627c478bd9Sstevel@tonic-gate arg0 = vp;
6637c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
664da6c28aaSamw errc = (*func)(arg0, mode, flags, cr, ct);
6657c478bd9Sstevel@tonic-gate } else {
6667c478bd9Sstevel@tonic-gate fem_addref(femsp);
6677c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
6687c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
6697c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6707c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_access,
671d7334e51Srm femop_access);
672da6c28aaSamw errc = (*func)(arg0, mode, flags, cr, ct);
6737c478bd9Sstevel@tonic-gate fem_release(femsp);
6747c478bd9Sstevel@tonic-gate }
6757c478bd9Sstevel@tonic-gate return (errc);
6767c478bd9Sstevel@tonic-gate }
6777c478bd9Sstevel@tonic-gate
6787c478bd9Sstevel@tonic-gate static int
vhead_lookup(vnode_t * dvp,char * nm,vnode_t ** vpp,pathname_t * pnp,int flags,vnode_t * rdir,cred_t * cr,caller_context_t * ct,int * direntflags,pathname_t * realpnp)6797c478bd9Sstevel@tonic-gate vhead_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
680b1659ed9SToomas Soome int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
681b1659ed9SToomas Soome int *direntflags, pathname_t *realpnp)
6827c478bd9Sstevel@tonic-gate {
6837c478bd9Sstevel@tonic-gate femarg_t farg;
6847c478bd9Sstevel@tonic-gate struct fem_list *femsp;
6857c478bd9Sstevel@tonic-gate int (*func)();
6867c478bd9Sstevel@tonic-gate void *arg0;
6877c478bd9Sstevel@tonic-gate int errc;
6887c478bd9Sstevel@tonic-gate
6897c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
6907c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_lookup);
6917c478bd9Sstevel@tonic-gate arg0 = dvp;
6927c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
693da6c28aaSamw errc = (*func)(arg0, nm, vpp, pnp, flags, rdir, cr, ct,
694d7334e51Srm direntflags, realpnp);
6957c478bd9Sstevel@tonic-gate } else {
6967c478bd9Sstevel@tonic-gate fem_addref(femsp);
6977c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
6987c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
6997c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7007c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_lookup,
701d7334e51Srm femop_lookup);
702da6c28aaSamw errc = (*func)(arg0, nm, vpp, pnp, flags, rdir, cr, ct,
703d7334e51Srm direntflags, realpnp);
7047c478bd9Sstevel@tonic-gate fem_release(femsp);
7057c478bd9Sstevel@tonic-gate }
7067c478bd9Sstevel@tonic-gate return (errc);
7077c478bd9Sstevel@tonic-gate }
7087c478bd9Sstevel@tonic-gate
7097c478bd9Sstevel@tonic-gate static int
vhead_create(vnode_t * dvp,char * name,vattr_t * vap,vcexcl_t excl,int mode,vnode_t ** vpp,cred_t * cr,int flag,caller_context_t * ct,vsecattr_t * vsecp)7107c478bd9Sstevel@tonic-gate vhead_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
711b1659ed9SToomas Soome int mode, vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct,
712b1659ed9SToomas Soome vsecattr_t *vsecp)
7137c478bd9Sstevel@tonic-gate {
7147c478bd9Sstevel@tonic-gate femarg_t farg;
7157c478bd9Sstevel@tonic-gate struct fem_list *femsp;
7167c478bd9Sstevel@tonic-gate int (*func)();
7177c478bd9Sstevel@tonic-gate void *arg0;
7187c478bd9Sstevel@tonic-gate int errc;
7197c478bd9Sstevel@tonic-gate
7207c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
7217c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_create);
7227c478bd9Sstevel@tonic-gate arg0 = dvp;
7237c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
724da6c28aaSamw errc = (*func)(arg0, name, vap, excl, mode, vpp, cr, flag,
725d7334e51Srm ct, vsecp);
7267c478bd9Sstevel@tonic-gate } else {
7277c478bd9Sstevel@tonic-gate fem_addref(femsp);
7287c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
7297c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
7307c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7317c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_create,
732d7334e51Srm femop_create);
733da6c28aaSamw errc = (*func)(arg0, name, vap, excl, mode, vpp, cr, flag,
734d7334e51Srm ct, vsecp);
7357c478bd9Sstevel@tonic-gate fem_release(femsp);
7367c478bd9Sstevel@tonic-gate }
7377c478bd9Sstevel@tonic-gate return (errc);
7387c478bd9Sstevel@tonic-gate }
7397c478bd9Sstevel@tonic-gate
7407c478bd9Sstevel@tonic-gate static int
vhead_remove(vnode_t * dvp,char * nm,cred_t * cr,caller_context_t * ct,int flags)741da6c28aaSamw vhead_remove(vnode_t *dvp, char *nm, cred_t *cr, caller_context_t *ct,
742b1659ed9SToomas Soome int flags)
7437c478bd9Sstevel@tonic-gate {
7447c478bd9Sstevel@tonic-gate femarg_t farg;
7457c478bd9Sstevel@tonic-gate struct fem_list *femsp;
7467c478bd9Sstevel@tonic-gate int (*func)();
7477c478bd9Sstevel@tonic-gate void *arg0;
7487c478bd9Sstevel@tonic-gate int errc;
7497c478bd9Sstevel@tonic-gate
7507c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
7517c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_remove);
7527c478bd9Sstevel@tonic-gate arg0 = dvp;
7537c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
754da6c28aaSamw errc = (*func)(arg0, nm, cr, ct, flags);
7557c478bd9Sstevel@tonic-gate } else {
7567c478bd9Sstevel@tonic-gate fem_addref(femsp);
7577c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
7587c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
7597c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7607c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_remove,
761d7334e51Srm femop_remove);
762da6c28aaSamw errc = (*func)(arg0, nm, cr, ct, flags);
7637c478bd9Sstevel@tonic-gate fem_release(femsp);
7647c478bd9Sstevel@tonic-gate }
7657c478bd9Sstevel@tonic-gate return (errc);
7667c478bd9Sstevel@tonic-gate }
7677c478bd9Sstevel@tonic-gate
7687c478bd9Sstevel@tonic-gate static int
vhead_link(vnode_t * tdvp,vnode_t * svp,char * tnm,cred_t * cr,caller_context_t * ct,int flags)769da6c28aaSamw vhead_link(vnode_t *tdvp, vnode_t *svp, char *tnm, cred_t *cr,
770b1659ed9SToomas Soome caller_context_t *ct, int flags)
7717c478bd9Sstevel@tonic-gate {
7727c478bd9Sstevel@tonic-gate femarg_t farg;
7737c478bd9Sstevel@tonic-gate struct fem_list *femsp;
7747c478bd9Sstevel@tonic-gate int (*func)();
7757c478bd9Sstevel@tonic-gate void *arg0;
7767c478bd9Sstevel@tonic-gate int errc;
7777c478bd9Sstevel@tonic-gate
7787c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(tdvp->v_femhead)) == NULL) {
7797c478bd9Sstevel@tonic-gate func = (int (*)()) (tdvp->v_op->vop_link);
7807c478bd9Sstevel@tonic-gate arg0 = tdvp;
7817c478bd9Sstevel@tonic-gate fem_unlock(tdvp->v_femhead);
782da6c28aaSamw errc = (*func)(arg0, svp, tnm, cr, ct, flags);
7837c478bd9Sstevel@tonic-gate } else {
7847c478bd9Sstevel@tonic-gate fem_addref(femsp);
7857c478bd9Sstevel@tonic-gate fem_unlock(tdvp->v_femhead);
7867c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = tdvp;
7877c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
788aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_link, femop_link);
789da6c28aaSamw errc = (*func)(arg0, svp, tnm, cr, ct, flags);
7907c478bd9Sstevel@tonic-gate fem_release(femsp);
7917c478bd9Sstevel@tonic-gate }
7927c478bd9Sstevel@tonic-gate return (errc);
7937c478bd9Sstevel@tonic-gate }
7947c478bd9Sstevel@tonic-gate
7957c478bd9Sstevel@tonic-gate static int
vhead_rename(vnode_t * sdvp,char * snm,vnode_t * tdvp,char * tnm,cred_t * cr,caller_context_t * ct,int flags)7967c478bd9Sstevel@tonic-gate vhead_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
797b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct, int flags)
7987c478bd9Sstevel@tonic-gate {
7997c478bd9Sstevel@tonic-gate femarg_t farg;
8007c478bd9Sstevel@tonic-gate struct fem_list *femsp;
8017c478bd9Sstevel@tonic-gate int (*func)();
8027c478bd9Sstevel@tonic-gate void *arg0;
8037c478bd9Sstevel@tonic-gate int errc;
8047c478bd9Sstevel@tonic-gate
8057c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(sdvp->v_femhead)) == NULL) {
8067c478bd9Sstevel@tonic-gate func = (int (*)()) (sdvp->v_op->vop_rename);
8077c478bd9Sstevel@tonic-gate arg0 = sdvp;
8087c478bd9Sstevel@tonic-gate fem_unlock(sdvp->v_femhead);
809da6c28aaSamw errc = (*func)(arg0, snm, tdvp, tnm, cr, ct, flags);
8107c478bd9Sstevel@tonic-gate } else {
8117c478bd9Sstevel@tonic-gate fem_addref(femsp);
8127c478bd9Sstevel@tonic-gate fem_unlock(sdvp->v_femhead);
8137c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = sdvp;
8147c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8157c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_rename,
816d7334e51Srm femop_rename);
817da6c28aaSamw errc = (*func)(arg0, snm, tdvp, tnm, cr, ct, flags);
8187c478bd9Sstevel@tonic-gate fem_release(femsp);
8197c478bd9Sstevel@tonic-gate }
8207c478bd9Sstevel@tonic-gate return (errc);
8217c478bd9Sstevel@tonic-gate }
8227c478bd9Sstevel@tonic-gate
8237c478bd9Sstevel@tonic-gate static int
vhead_mkdir(vnode_t * dvp,char * dirname,vattr_t * vap,vnode_t ** vpp,cred_t * cr,caller_context_t * ct,int flags,vsecattr_t * vsecp)8247c478bd9Sstevel@tonic-gate vhead_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp,
825b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct, int flags, vsecattr_t *vsecp)
8267c478bd9Sstevel@tonic-gate {
8277c478bd9Sstevel@tonic-gate femarg_t farg;
8287c478bd9Sstevel@tonic-gate struct fem_list *femsp;
8297c478bd9Sstevel@tonic-gate int (*func)();
8307c478bd9Sstevel@tonic-gate void *arg0;
8317c478bd9Sstevel@tonic-gate int errc;
8327c478bd9Sstevel@tonic-gate
8337c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
8347c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_mkdir);
8357c478bd9Sstevel@tonic-gate arg0 = dvp;
8367c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
837da6c28aaSamw errc = (*func)(arg0, dirname, vap, vpp, cr, ct, flags, vsecp);
8387c478bd9Sstevel@tonic-gate } else {
8397c478bd9Sstevel@tonic-gate fem_addref(femsp);
8407c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
8417c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
8427c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
843aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_mkdir, femop_mkdir);
844da6c28aaSamw errc = (*func)(arg0, dirname, vap, vpp, cr, ct, flags, vsecp);
8457c478bd9Sstevel@tonic-gate fem_release(femsp);
8467c478bd9Sstevel@tonic-gate }
8477c478bd9Sstevel@tonic-gate return (errc);
8487c478bd9Sstevel@tonic-gate }
8497c478bd9Sstevel@tonic-gate
8507c478bd9Sstevel@tonic-gate static int
vhead_rmdir(vnode_t * dvp,char * nm,vnode_t * cdir,cred_t * cr,caller_context_t * ct,int flags)851da6c28aaSamw vhead_rmdir(vnode_t *dvp, char *nm, vnode_t *cdir, cred_t *cr,
852b1659ed9SToomas Soome caller_context_t *ct, int flags)
8537c478bd9Sstevel@tonic-gate {
8547c478bd9Sstevel@tonic-gate femarg_t farg;
8557c478bd9Sstevel@tonic-gate struct fem_list *femsp;
8567c478bd9Sstevel@tonic-gate int (*func)();
8577c478bd9Sstevel@tonic-gate void *arg0;
8587c478bd9Sstevel@tonic-gate int errc;
8597c478bd9Sstevel@tonic-gate
8607c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
8617c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_rmdir);
8627c478bd9Sstevel@tonic-gate arg0 = dvp;
8637c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
864da6c28aaSamw errc = (*func)(arg0, nm, cdir, cr, ct, flags);
8657c478bd9Sstevel@tonic-gate } else {
8667c478bd9Sstevel@tonic-gate fem_addref(femsp);
8677c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
8687c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
8697c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
870aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_rmdir, femop_rmdir);
871da6c28aaSamw errc = (*func)(arg0, nm, cdir, cr, ct, flags);
8727c478bd9Sstevel@tonic-gate fem_release(femsp);
8737c478bd9Sstevel@tonic-gate }
8747c478bd9Sstevel@tonic-gate return (errc);
8757c478bd9Sstevel@tonic-gate }
8767c478bd9Sstevel@tonic-gate
8777c478bd9Sstevel@tonic-gate static int
vhead_readdir(vnode_t * vp,uio_t * uiop,cred_t * cr,int * eofp,caller_context_t * ct,int flags)878da6c28aaSamw vhead_readdir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp,
879b1659ed9SToomas Soome caller_context_t *ct, int flags)
8807c478bd9Sstevel@tonic-gate {
8817c478bd9Sstevel@tonic-gate femarg_t farg;
8827c478bd9Sstevel@tonic-gate struct fem_list *femsp;
8837c478bd9Sstevel@tonic-gate int (*func)();
8847c478bd9Sstevel@tonic-gate void *arg0;
8857c478bd9Sstevel@tonic-gate int errc;
8867c478bd9Sstevel@tonic-gate
8877c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
8887c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_readdir);
8897c478bd9Sstevel@tonic-gate arg0 = vp;
8907c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
891da6c28aaSamw errc = (*func)(arg0, uiop, cr, eofp, ct, flags);
8927c478bd9Sstevel@tonic-gate } else {
8937c478bd9Sstevel@tonic-gate fem_addref(femsp);
8947c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
8957c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
8967c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8977c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_readdir,
898d7334e51Srm femop_readdir);
899da6c28aaSamw errc = (*func)(arg0, uiop, cr, eofp, ct, flags);
9007c478bd9Sstevel@tonic-gate fem_release(femsp);
9017c478bd9Sstevel@tonic-gate }
9027c478bd9Sstevel@tonic-gate return (errc);
9037c478bd9Sstevel@tonic-gate }
9047c478bd9Sstevel@tonic-gate
9057c478bd9Sstevel@tonic-gate static int
vhead_symlink(vnode_t * dvp,char * linkname,vattr_t * vap,char * target,cred_t * cr,caller_context_t * ct,int flags)9067c478bd9Sstevel@tonic-gate vhead_symlink(vnode_t *dvp, char *linkname, vattr_t *vap, char *target,
907b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct, int flags)
9087c478bd9Sstevel@tonic-gate {
9097c478bd9Sstevel@tonic-gate femarg_t farg;
9107c478bd9Sstevel@tonic-gate struct fem_list *femsp;
9117c478bd9Sstevel@tonic-gate int (*func)();
9127c478bd9Sstevel@tonic-gate void *arg0;
9137c478bd9Sstevel@tonic-gate int errc;
9147c478bd9Sstevel@tonic-gate
9157c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
9167c478bd9Sstevel@tonic-gate func = (int (*)()) (dvp->v_op->vop_symlink);
9177c478bd9Sstevel@tonic-gate arg0 = dvp;
9187c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
919da6c28aaSamw errc = (*func)(arg0, linkname, vap, target, cr, ct, flags);
9207c478bd9Sstevel@tonic-gate } else {
9217c478bd9Sstevel@tonic-gate fem_addref(femsp);
9227c478bd9Sstevel@tonic-gate fem_unlock(dvp->v_femhead);
9237c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = dvp;
9247c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9257c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_symlink,
926d7334e51Srm femop_symlink);
927da6c28aaSamw errc = (*func)(arg0, linkname, vap, target, cr, ct, flags);
9287c478bd9Sstevel@tonic-gate fem_release(femsp);
9297c478bd9Sstevel@tonic-gate }
9307c478bd9Sstevel@tonic-gate return (errc);
9317c478bd9Sstevel@tonic-gate }
9327c478bd9Sstevel@tonic-gate
9337c478bd9Sstevel@tonic-gate static int
vhead_readlink(vnode_t * vp,uio_t * uiop,cred_t * cr,caller_context_t * ct)934da6c28aaSamw vhead_readlink(vnode_t *vp, uio_t *uiop, cred_t *cr, caller_context_t *ct)
9357c478bd9Sstevel@tonic-gate {
9367c478bd9Sstevel@tonic-gate femarg_t farg;
9377c478bd9Sstevel@tonic-gate struct fem_list *femsp;
9387c478bd9Sstevel@tonic-gate int (*func)();
9397c478bd9Sstevel@tonic-gate void *arg0;
9407c478bd9Sstevel@tonic-gate int errc;
9417c478bd9Sstevel@tonic-gate
9427c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9437c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_readlink);
9447c478bd9Sstevel@tonic-gate arg0 = vp;
9457c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
946da6c28aaSamw errc = (*func)(arg0, uiop, cr, ct);
9477c478bd9Sstevel@tonic-gate } else {
9487c478bd9Sstevel@tonic-gate fem_addref(femsp);
9497c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
9507c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
9517c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9527c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_readlink,
953d7334e51Srm femop_readlink);
954da6c28aaSamw errc = (*func)(arg0, uiop, cr, ct);
9557c478bd9Sstevel@tonic-gate fem_release(femsp);
9567c478bd9Sstevel@tonic-gate }
9577c478bd9Sstevel@tonic-gate return (errc);
9587c478bd9Sstevel@tonic-gate }
9597c478bd9Sstevel@tonic-gate
9607c478bd9Sstevel@tonic-gate static int
vhead_fsync(vnode_t * vp,int syncflag,cred_t * cr,caller_context_t * ct)961da6c28aaSamw vhead_fsync(vnode_t *vp, int syncflag, cred_t *cr, caller_context_t *ct)
9627c478bd9Sstevel@tonic-gate {
9637c478bd9Sstevel@tonic-gate femarg_t farg;
9647c478bd9Sstevel@tonic-gate struct fem_list *femsp;
9657c478bd9Sstevel@tonic-gate int (*func)();
9667c478bd9Sstevel@tonic-gate void *arg0;
9677c478bd9Sstevel@tonic-gate int errc;
9687c478bd9Sstevel@tonic-gate
9697c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9707c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_fsync);
9717c478bd9Sstevel@tonic-gate arg0 = vp;
9727c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
973da6c28aaSamw errc = (*func)(arg0, syncflag, cr, ct);
9747c478bd9Sstevel@tonic-gate } else {
9757c478bd9Sstevel@tonic-gate fem_addref(femsp);
9767c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
9777c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
9787c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
979aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_fsync, femop_fsync);
980da6c28aaSamw errc = (*func)(arg0, syncflag, cr, ct);
9817c478bd9Sstevel@tonic-gate fem_release(femsp);
9827c478bd9Sstevel@tonic-gate }
9837c478bd9Sstevel@tonic-gate return (errc);
9847c478bd9Sstevel@tonic-gate }
9857c478bd9Sstevel@tonic-gate
986b1659ed9SToomas Soome static int
vhead_inactive(vnode_t * vp,cred_t * cr,caller_context_t * ct)987da6c28aaSamw vhead_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
9887c478bd9Sstevel@tonic-gate {
9897c478bd9Sstevel@tonic-gate femarg_t farg;
9907c478bd9Sstevel@tonic-gate struct fem_list *femsp;
9917c478bd9Sstevel@tonic-gate void (*func)();
9927c478bd9Sstevel@tonic-gate void *arg0;
9937c478bd9Sstevel@tonic-gate
9947c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9957c478bd9Sstevel@tonic-gate func = (void (*)()) (vp->v_op->vop_inactive);
9967c478bd9Sstevel@tonic-gate arg0 = vp;
9977c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
998da6c28aaSamw (*func)(arg0, cr, ct);
9997c478bd9Sstevel@tonic-gate } else {
10007c478bd9Sstevel@tonic-gate fem_addref(femsp);
10017c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10027c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
10037c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10047c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, void, &arg0, vop_inactive,
1005d7334e51Srm femop_inactive);
1006da6c28aaSamw (*func)(arg0, cr, ct);
10077c478bd9Sstevel@tonic-gate fem_release(femsp);
10087c478bd9Sstevel@tonic-gate }
1009b1659ed9SToomas Soome return (0);
10107c478bd9Sstevel@tonic-gate }
10117c478bd9Sstevel@tonic-gate
10127c478bd9Sstevel@tonic-gate static int
vhead_fid(vnode_t * vp,fid_t * fidp,caller_context_t * ct)1013da6c28aaSamw vhead_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
10147c478bd9Sstevel@tonic-gate {
10157c478bd9Sstevel@tonic-gate femarg_t farg;
10167c478bd9Sstevel@tonic-gate struct fem_list *femsp;
10177c478bd9Sstevel@tonic-gate int (*func)();
10187c478bd9Sstevel@tonic-gate void *arg0;
10197c478bd9Sstevel@tonic-gate int errc;
10207c478bd9Sstevel@tonic-gate
10217c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10227c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_fid);
10237c478bd9Sstevel@tonic-gate arg0 = vp;
10247c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1025da6c28aaSamw errc = (*func)(arg0, fidp, ct);
10267c478bd9Sstevel@tonic-gate } else {
10277c478bd9Sstevel@tonic-gate fem_addref(femsp);
10287c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10297c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
10307c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1031aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_fid, femop_fid);
1032da6c28aaSamw errc = (*func)(arg0, fidp, ct);
10337c478bd9Sstevel@tonic-gate fem_release(femsp);
10347c478bd9Sstevel@tonic-gate }
10357c478bd9Sstevel@tonic-gate return (errc);
10367c478bd9Sstevel@tonic-gate }
10377c478bd9Sstevel@tonic-gate
10387c478bd9Sstevel@tonic-gate static int
vhead_rwlock(vnode_t * vp,int write_lock,caller_context_t * ct)10397c478bd9Sstevel@tonic-gate vhead_rwlock(vnode_t *vp, int write_lock, caller_context_t *ct)
10407c478bd9Sstevel@tonic-gate {
10417c478bd9Sstevel@tonic-gate femarg_t farg;
10427c478bd9Sstevel@tonic-gate struct fem_list *femsp;
10437c478bd9Sstevel@tonic-gate int (*func)();
10447c478bd9Sstevel@tonic-gate void *arg0;
10457c478bd9Sstevel@tonic-gate int errc;
10467c478bd9Sstevel@tonic-gate
10477c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10487c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_rwlock);
10497c478bd9Sstevel@tonic-gate arg0 = vp;
10507c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10517c478bd9Sstevel@tonic-gate errc = (*func)(arg0, write_lock, ct);
10527c478bd9Sstevel@tonic-gate } else {
10537c478bd9Sstevel@tonic-gate fem_addref(femsp);
10547c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10557c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
10567c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10577c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_rwlock,
1058d7334e51Srm femop_rwlock);
10597c478bd9Sstevel@tonic-gate errc = (*func)(arg0, write_lock, ct);
10607c478bd9Sstevel@tonic-gate fem_release(femsp);
10617c478bd9Sstevel@tonic-gate }
10627c478bd9Sstevel@tonic-gate return (errc);
10637c478bd9Sstevel@tonic-gate }
10647c478bd9Sstevel@tonic-gate
1065b1659ed9SToomas Soome static int
vhead_rwunlock(vnode_t * vp,int write_lock,caller_context_t * ct)10667c478bd9Sstevel@tonic-gate vhead_rwunlock(vnode_t *vp, int write_lock, caller_context_t *ct)
10677c478bd9Sstevel@tonic-gate {
10687c478bd9Sstevel@tonic-gate femarg_t farg;
10697c478bd9Sstevel@tonic-gate struct fem_list *femsp;
10707c478bd9Sstevel@tonic-gate void (*func)();
10717c478bd9Sstevel@tonic-gate void *arg0;
10727c478bd9Sstevel@tonic-gate
10737c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10747c478bd9Sstevel@tonic-gate func = (void (*)()) (vp->v_op->vop_rwunlock);
10757c478bd9Sstevel@tonic-gate arg0 = vp;
10767c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10777c478bd9Sstevel@tonic-gate (*func)(arg0, write_lock, ct);
10787c478bd9Sstevel@tonic-gate } else {
10797c478bd9Sstevel@tonic-gate fem_addref(femsp);
10807c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
10817c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
10827c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10837c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, void, &arg0, vop_rwunlock,
1084d7334e51Srm femop_rwunlock);
10857c478bd9Sstevel@tonic-gate (*func)(arg0, write_lock, ct);
10867c478bd9Sstevel@tonic-gate fem_release(femsp);
10877c478bd9Sstevel@tonic-gate }
1088b1659ed9SToomas Soome return (0);
10897c478bd9Sstevel@tonic-gate }
10907c478bd9Sstevel@tonic-gate
10917c478bd9Sstevel@tonic-gate static int
vhead_seek(vnode_t * vp,offset_t ooff,offset_t * noffp,caller_context_t * ct)1092da6c28aaSamw vhead_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, caller_context_t *ct)
10937c478bd9Sstevel@tonic-gate {
10947c478bd9Sstevel@tonic-gate femarg_t farg;
10957c478bd9Sstevel@tonic-gate struct fem_list *femsp;
10967c478bd9Sstevel@tonic-gate int (*func)();
10977c478bd9Sstevel@tonic-gate void *arg0;
10987c478bd9Sstevel@tonic-gate int errc;
10997c478bd9Sstevel@tonic-gate
11007c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11017c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_seek);
11027c478bd9Sstevel@tonic-gate arg0 = vp;
11037c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1104da6c28aaSamw errc = (*func)(arg0, ooff, noffp, ct);
11057c478bd9Sstevel@tonic-gate } else {
11067c478bd9Sstevel@tonic-gate fem_addref(femsp);
11077c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
11087c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
11097c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1110aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_seek, femop_seek);
1111da6c28aaSamw errc = (*func)(arg0, ooff, noffp, ct);
11127c478bd9Sstevel@tonic-gate fem_release(femsp);
11137c478bd9Sstevel@tonic-gate }
11147c478bd9Sstevel@tonic-gate return (errc);
11157c478bd9Sstevel@tonic-gate }
11167c478bd9Sstevel@tonic-gate
11177c478bd9Sstevel@tonic-gate static int
vhead_cmp(vnode_t * vp1,vnode_t * vp2,caller_context_t * ct)1118da6c28aaSamw vhead_cmp(vnode_t *vp1, vnode_t *vp2, caller_context_t *ct)
11197c478bd9Sstevel@tonic-gate {
11207c478bd9Sstevel@tonic-gate femarg_t farg;
11217c478bd9Sstevel@tonic-gate struct fem_list *femsp;
11227c478bd9Sstevel@tonic-gate int (*func)();
11237c478bd9Sstevel@tonic-gate void *arg0;
11247c478bd9Sstevel@tonic-gate int errc;
11257c478bd9Sstevel@tonic-gate
11267c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp1->v_femhead)) == NULL) {
11277c478bd9Sstevel@tonic-gate func = (int (*)()) (vp1->v_op->vop_cmp);
11287c478bd9Sstevel@tonic-gate arg0 = vp1;
11297c478bd9Sstevel@tonic-gate fem_unlock(vp1->v_femhead);
1130da6c28aaSamw errc = (*func)(arg0, vp2, ct);
11317c478bd9Sstevel@tonic-gate } else {
11327c478bd9Sstevel@tonic-gate fem_addref(femsp);
11337c478bd9Sstevel@tonic-gate fem_unlock(vp1->v_femhead);
11347c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp1;
11357c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1136aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_cmp, femop_cmp);
1137da6c28aaSamw errc = (*func)(arg0, vp2, ct);
11387c478bd9Sstevel@tonic-gate fem_release(femsp);
11397c478bd9Sstevel@tonic-gate }
11407c478bd9Sstevel@tonic-gate return (errc);
11417c478bd9Sstevel@tonic-gate }
11427c478bd9Sstevel@tonic-gate
11437c478bd9Sstevel@tonic-gate static int
vhead_frlock(vnode_t * vp,int cmd,struct flock64 * bfp,int flag,offset_t offset,struct flk_callback * flk_cbp,cred_t * cr,caller_context_t * ct)11447c478bd9Sstevel@tonic-gate vhead_frlock(vnode_t *vp, int cmd, struct flock64 *bfp, int flag,
1145b1659ed9SToomas Soome offset_t offset, struct flk_callback *flk_cbp, cred_t *cr,
1146b1659ed9SToomas Soome caller_context_t *ct)
11477c478bd9Sstevel@tonic-gate {
11487c478bd9Sstevel@tonic-gate femarg_t farg;
11497c478bd9Sstevel@tonic-gate struct fem_list *femsp;
11507c478bd9Sstevel@tonic-gate int (*func)();
11517c478bd9Sstevel@tonic-gate void *arg0;
11527c478bd9Sstevel@tonic-gate int errc;
11537c478bd9Sstevel@tonic-gate
11547c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11557c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_frlock);
11567c478bd9Sstevel@tonic-gate arg0 = vp;
11577c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1158da6c28aaSamw errc = (*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr, ct);
11597c478bd9Sstevel@tonic-gate } else {
11607c478bd9Sstevel@tonic-gate fem_addref(femsp);
11617c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
11627c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
11637c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
11647c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_frlock,
1165d7334e51Srm femop_frlock);
1166da6c28aaSamw errc = (*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr, ct);
11677c478bd9Sstevel@tonic-gate fem_release(femsp);
11687c478bd9Sstevel@tonic-gate }
11697c478bd9Sstevel@tonic-gate return (errc);
11707c478bd9Sstevel@tonic-gate }
11717c478bd9Sstevel@tonic-gate
11727c478bd9Sstevel@tonic-gate static int
vhead_space(vnode_t * vp,int cmd,struct flock64 * bfp,int flag,offset_t offset,cred_t * cr,caller_context_t * ct)11737c478bd9Sstevel@tonic-gate vhead_space(vnode_t *vp, int cmd, struct flock64 *bfp, int flag,
1174b1659ed9SToomas Soome offset_t offset, cred_t *cr, caller_context_t *ct)
11757c478bd9Sstevel@tonic-gate {
11767c478bd9Sstevel@tonic-gate femarg_t farg;
11777c478bd9Sstevel@tonic-gate struct fem_list *femsp;
11787c478bd9Sstevel@tonic-gate int (*func)();
11797c478bd9Sstevel@tonic-gate void *arg0;
11807c478bd9Sstevel@tonic-gate int errc;
11817c478bd9Sstevel@tonic-gate
11827c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11837c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_space);
11847c478bd9Sstevel@tonic-gate arg0 = vp;
11857c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
11867c478bd9Sstevel@tonic-gate errc = (*func)(arg0, cmd, bfp, flag, offset, cr, ct);
11877c478bd9Sstevel@tonic-gate } else {
11887c478bd9Sstevel@tonic-gate fem_addref(femsp);
11897c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
11907c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
11917c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1192aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_space, femop_space);
11937c478bd9Sstevel@tonic-gate errc = (*func)(arg0, cmd, bfp, flag, offset, cr, ct);
11947c478bd9Sstevel@tonic-gate fem_release(femsp);
11957c478bd9Sstevel@tonic-gate }
11967c478bd9Sstevel@tonic-gate return (errc);
11977c478bd9Sstevel@tonic-gate }
11987c478bd9Sstevel@tonic-gate
11997c478bd9Sstevel@tonic-gate static int
vhead_realvp(vnode_t * vp,vnode_t ** vpp,caller_context_t * ct)1200da6c28aaSamw vhead_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct)
12017c478bd9Sstevel@tonic-gate {
12027c478bd9Sstevel@tonic-gate femarg_t farg;
12037c478bd9Sstevel@tonic-gate struct fem_list *femsp;
12047c478bd9Sstevel@tonic-gate int (*func)();
12057c478bd9Sstevel@tonic-gate void *arg0;
12067c478bd9Sstevel@tonic-gate int errc;
12077c478bd9Sstevel@tonic-gate
12087c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12097c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_realvp);
12107c478bd9Sstevel@tonic-gate arg0 = vp;
12117c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1212da6c28aaSamw errc = (*func)(arg0, vpp, ct);
12137c478bd9Sstevel@tonic-gate } else {
12147c478bd9Sstevel@tonic-gate fem_addref(femsp);
12157c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
12167c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
12177c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12187c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_realvp,
1219d7334e51Srm femop_realvp);
1220da6c28aaSamw errc = (*func)(arg0, vpp, ct);
12217c478bd9Sstevel@tonic-gate fem_release(femsp);
12227c478bd9Sstevel@tonic-gate }
12237c478bd9Sstevel@tonic-gate return (errc);
12247c478bd9Sstevel@tonic-gate }
12257c478bd9Sstevel@tonic-gate
12267c478bd9Sstevel@tonic-gate static int
vhead_getpage(vnode_t * vp,offset_t off,size_t len,uint_t * protp,struct page ** plarr,size_t plsz,struct seg * seg,caddr_t addr,enum seg_rw rw,cred_t * cr,caller_context_t * ct)12277c478bd9Sstevel@tonic-gate vhead_getpage(vnode_t *vp, offset_t off, size_t len, uint_t *protp,
1228b1659ed9SToomas Soome struct page **plarr, size_t plsz, struct seg *seg, caddr_t addr,
1229b1659ed9SToomas Soome enum seg_rw rw, cred_t *cr, caller_context_t *ct)
12307c478bd9Sstevel@tonic-gate {
12317c478bd9Sstevel@tonic-gate femarg_t farg;
12327c478bd9Sstevel@tonic-gate struct fem_list *femsp;
12337c478bd9Sstevel@tonic-gate int (*func)();
12347c478bd9Sstevel@tonic-gate void *arg0;
12357c478bd9Sstevel@tonic-gate int errc;
12367c478bd9Sstevel@tonic-gate
12377c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12387c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_getpage);
12397c478bd9Sstevel@tonic-gate arg0 = vp;
12407c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
12417c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, len, protp, plarr, plsz, seg,
1242d7334e51Srm addr, rw, cr, ct);
12437c478bd9Sstevel@tonic-gate } else {
12447c478bd9Sstevel@tonic-gate fem_addref(femsp);
12457c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
12467c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
12477c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12487c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_getpage,
1249d7334e51Srm femop_getpage);
12507c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, len, protp, plarr, plsz, seg,
1251d7334e51Srm addr, rw, cr, ct);
12527c478bd9Sstevel@tonic-gate fem_release(femsp);
12537c478bd9Sstevel@tonic-gate }
12547c478bd9Sstevel@tonic-gate return (errc);
12557c478bd9Sstevel@tonic-gate }
12567c478bd9Sstevel@tonic-gate
12577c478bd9Sstevel@tonic-gate static int
vhead_putpage(vnode_t * vp,offset_t off,size_t len,int flags,cred_t * cr,caller_context_t * ct)1258da6c28aaSamw vhead_putpage(vnode_t *vp, offset_t off, size_t len, int flags, cred_t *cr,
1259b1659ed9SToomas Soome caller_context_t *ct)
12607c478bd9Sstevel@tonic-gate {
12617c478bd9Sstevel@tonic-gate femarg_t farg;
12627c478bd9Sstevel@tonic-gate struct fem_list *femsp;
12637c478bd9Sstevel@tonic-gate int (*func)();
12647c478bd9Sstevel@tonic-gate void *arg0;
12657c478bd9Sstevel@tonic-gate int errc;
12667c478bd9Sstevel@tonic-gate
12677c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12687c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_putpage);
12697c478bd9Sstevel@tonic-gate arg0 = vp;
12707c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1271da6c28aaSamw errc = (*func)(arg0, off, len, flags, cr, ct);
12727c478bd9Sstevel@tonic-gate } else {
12737c478bd9Sstevel@tonic-gate fem_addref(femsp);
12747c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
12757c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
12767c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12777c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_putpage,
1278d7334e51Srm femop_putpage);
1279da6c28aaSamw errc = (*func)(arg0, off, len, flags, cr, ct);
12807c478bd9Sstevel@tonic-gate fem_release(femsp);
12817c478bd9Sstevel@tonic-gate }
12827c478bd9Sstevel@tonic-gate return (errc);
12837c478bd9Sstevel@tonic-gate }
12847c478bd9Sstevel@tonic-gate
12857c478bd9Sstevel@tonic-gate static int
vhead_map(vnode_t * vp,offset_t off,struct as * as,caddr_t * addrp,size_t len,uchar_t prot,uchar_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)12867c478bd9Sstevel@tonic-gate vhead_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
1287b1659ed9SToomas Soome size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
1288b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
12897c478bd9Sstevel@tonic-gate {
12907c478bd9Sstevel@tonic-gate femarg_t farg;
12917c478bd9Sstevel@tonic-gate struct fem_list *femsp;
12927c478bd9Sstevel@tonic-gate int (*func)();
12937c478bd9Sstevel@tonic-gate void *arg0;
12947c478bd9Sstevel@tonic-gate int errc;
12957c478bd9Sstevel@tonic-gate
12967c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12977c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_map);
12987c478bd9Sstevel@tonic-gate arg0 = vp;
12997c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13007c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addrp, len, prot, maxprot,
1301d7334e51Srm flags, cr, ct);
13027c478bd9Sstevel@tonic-gate } else {
13037c478bd9Sstevel@tonic-gate fem_addref(femsp);
13047c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13057c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
13067c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1307aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_map, femop_map);
13087c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addrp, len, prot, maxprot,
1309d7334e51Srm flags, cr, ct);
13107c478bd9Sstevel@tonic-gate fem_release(femsp);
13117c478bd9Sstevel@tonic-gate }
13127c478bd9Sstevel@tonic-gate return (errc);
13137c478bd9Sstevel@tonic-gate }
13147c478bd9Sstevel@tonic-gate
13157c478bd9Sstevel@tonic-gate static int
vhead_addmap(vnode_t * vp,offset_t off,struct as * as,caddr_t addr,size_t len,uchar_t prot,uchar_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)13167c478bd9Sstevel@tonic-gate vhead_addmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
1317b1659ed9SToomas Soome size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
1318b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
13197c478bd9Sstevel@tonic-gate {
13207c478bd9Sstevel@tonic-gate femarg_t farg;
13217c478bd9Sstevel@tonic-gate struct fem_list *femsp;
13227c478bd9Sstevel@tonic-gate int (*func)();
13237c478bd9Sstevel@tonic-gate void *arg0;
13247c478bd9Sstevel@tonic-gate int errc;
13257c478bd9Sstevel@tonic-gate
13267c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13277c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_addmap);
13287c478bd9Sstevel@tonic-gate arg0 = vp;
13297c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13307c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
1331d7334e51Srm flags, cr, ct);
13327c478bd9Sstevel@tonic-gate } else {
13337c478bd9Sstevel@tonic-gate fem_addref(femsp);
13347c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13357c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
13367c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
13377c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_addmap,
1338d7334e51Srm femop_addmap);
13397c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
1340d7334e51Srm flags, cr, ct);
13417c478bd9Sstevel@tonic-gate fem_release(femsp);
13427c478bd9Sstevel@tonic-gate }
13437c478bd9Sstevel@tonic-gate return (errc);
13447c478bd9Sstevel@tonic-gate }
13457c478bd9Sstevel@tonic-gate
13467c478bd9Sstevel@tonic-gate static int
vhead_delmap(vnode_t * vp,offset_t off,struct as * as,caddr_t addr,size_t len,uint_t prot,uint_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)13477c478bd9Sstevel@tonic-gate vhead_delmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
1348b1659ed9SToomas Soome size_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cr,
1349b1659ed9SToomas Soome caller_context_t *ct)
13507c478bd9Sstevel@tonic-gate {
13517c478bd9Sstevel@tonic-gate femarg_t farg;
13527c478bd9Sstevel@tonic-gate struct fem_list *femsp;
13537c478bd9Sstevel@tonic-gate int (*func)();
13547c478bd9Sstevel@tonic-gate void *arg0;
13557c478bd9Sstevel@tonic-gate int errc;
13567c478bd9Sstevel@tonic-gate
13577c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13587c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_delmap);
13597c478bd9Sstevel@tonic-gate arg0 = vp;
13607c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13617c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
1362d7334e51Srm flags, cr, ct);
13637c478bd9Sstevel@tonic-gate } else {
13647c478bd9Sstevel@tonic-gate fem_addref(femsp);
13657c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13667c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
13677c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
13687c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_delmap,
1369d7334e51Srm femop_delmap);
13707c478bd9Sstevel@tonic-gate errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
1371d7334e51Srm flags, cr, ct);
13727c478bd9Sstevel@tonic-gate fem_release(femsp);
13737c478bd9Sstevel@tonic-gate }
13747c478bd9Sstevel@tonic-gate return (errc);
13757c478bd9Sstevel@tonic-gate }
13767c478bd9Sstevel@tonic-gate
13777c478bd9Sstevel@tonic-gate static int
vhead_poll(vnode_t * vp,short events,int anyyet,short * reventsp,struct pollhead ** phpp,caller_context_t * ct)13787c478bd9Sstevel@tonic-gate vhead_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
1379b1659ed9SToomas Soome struct pollhead **phpp, caller_context_t *ct)
13807c478bd9Sstevel@tonic-gate {
13817c478bd9Sstevel@tonic-gate femarg_t farg;
13827c478bd9Sstevel@tonic-gate struct fem_list *femsp;
13837c478bd9Sstevel@tonic-gate int (*func)();
13847c478bd9Sstevel@tonic-gate void *arg0;
13857c478bd9Sstevel@tonic-gate int errc;
13867c478bd9Sstevel@tonic-gate
13877c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13887c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_poll);
13897c478bd9Sstevel@tonic-gate arg0 = vp;
13907c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1391da6c28aaSamw errc = (*func)(arg0, events, anyyet, reventsp, phpp, ct);
13927c478bd9Sstevel@tonic-gate } else {
13937c478bd9Sstevel@tonic-gate fem_addref(femsp);
13947c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
13957c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
13967c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1397aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_poll, femop_poll);
1398da6c28aaSamw errc = (*func)(arg0, events, anyyet, reventsp, phpp, ct);
13997c478bd9Sstevel@tonic-gate fem_release(femsp);
14007c478bd9Sstevel@tonic-gate }
14017c478bd9Sstevel@tonic-gate return (errc);
14027c478bd9Sstevel@tonic-gate }
14037c478bd9Sstevel@tonic-gate
14047c478bd9Sstevel@tonic-gate static int
vhead_dump(vnode_t * vp,caddr_t addr,offset_t lbdn,offset_t dblks,caller_context_t * ct)1405d7334e51Srm vhead_dump(vnode_t *vp, caddr_t addr, offset_t lbdn, offset_t dblks,
1406d7334e51Srm caller_context_t *ct)
14077c478bd9Sstevel@tonic-gate {
14087c478bd9Sstevel@tonic-gate femarg_t farg;
14097c478bd9Sstevel@tonic-gate struct fem_list *femsp;
14107c478bd9Sstevel@tonic-gate int (*func)();
14117c478bd9Sstevel@tonic-gate void *arg0;
14127c478bd9Sstevel@tonic-gate int errc;
14137c478bd9Sstevel@tonic-gate
14147c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14157c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_dump);
14167c478bd9Sstevel@tonic-gate arg0 = vp;
14177c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1418da6c28aaSamw errc = (*func)(arg0, addr, lbdn, dblks, ct);
14197c478bd9Sstevel@tonic-gate } else {
14207c478bd9Sstevel@tonic-gate fem_addref(femsp);
14217c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
14227c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
14237c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1424aa59c4cbSrsb vsop_find(&farg, &func, int, &arg0, vop_dump, femop_dump);
1425da6c28aaSamw errc = (*func)(arg0, addr, lbdn, dblks, ct);
14267c478bd9Sstevel@tonic-gate fem_release(femsp);
14277c478bd9Sstevel@tonic-gate }
14287c478bd9Sstevel@tonic-gate return (errc);
14297c478bd9Sstevel@tonic-gate }
14307c478bd9Sstevel@tonic-gate
14317c478bd9Sstevel@tonic-gate static int
vhead_pathconf(vnode_t * vp,int cmd,ulong_t * valp,cred_t * cr,caller_context_t * ct)1432da6c28aaSamw vhead_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
1433b1659ed9SToomas Soome caller_context_t *ct)
14347c478bd9Sstevel@tonic-gate {
14357c478bd9Sstevel@tonic-gate femarg_t farg;
14367c478bd9Sstevel@tonic-gate struct fem_list *femsp;
14377c478bd9Sstevel@tonic-gate int (*func)();
14387c478bd9Sstevel@tonic-gate void *arg0;
14397c478bd9Sstevel@tonic-gate int errc;
14407c478bd9Sstevel@tonic-gate
14417c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14427c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_pathconf);
14437c478bd9Sstevel@tonic-gate arg0 = vp;
14447c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1445da6c28aaSamw errc = (*func)(arg0, cmd, valp, cr, ct);
14467c478bd9Sstevel@tonic-gate } else {
14477c478bd9Sstevel@tonic-gate fem_addref(femsp);
14487c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
14497c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
14507c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14517c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_pathconf,
1452d7334e51Srm femop_pathconf);
1453da6c28aaSamw errc = (*func)(arg0, cmd, valp, cr, ct);
14547c478bd9Sstevel@tonic-gate fem_release(femsp);
14557c478bd9Sstevel@tonic-gate }
14567c478bd9Sstevel@tonic-gate return (errc);
14577c478bd9Sstevel@tonic-gate }
14587c478bd9Sstevel@tonic-gate
14597c478bd9Sstevel@tonic-gate static int
vhead_pageio(vnode_t * vp,struct page * pp,u_offset_t io_off,size_t io_len,int flags,cred_t * cr,caller_context_t * ct)14607c478bd9Sstevel@tonic-gate vhead_pageio(vnode_t *vp, struct page *pp, u_offset_t io_off,
1461b1659ed9SToomas Soome size_t io_len, int flags, cred_t *cr, caller_context_t *ct)
14627c478bd9Sstevel@tonic-gate {
14637c478bd9Sstevel@tonic-gate femarg_t farg;
14647c478bd9Sstevel@tonic-gate struct fem_list *femsp;
14657c478bd9Sstevel@tonic-gate int (*func)();
14667c478bd9Sstevel@tonic-gate void *arg0;
14677c478bd9Sstevel@tonic-gate int errc;
14687c478bd9Sstevel@tonic-gate
14697c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14707c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_pageio);
14717c478bd9Sstevel@tonic-gate arg0 = vp;
14727c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1473da6c28aaSamw errc = (*func)(arg0, pp, io_off, io_len, flags, cr, ct);
14747c478bd9Sstevel@tonic-gate } else {
14757c478bd9Sstevel@tonic-gate fem_addref(femsp);
14767c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
14777c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
14787c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14797c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_pageio,
1480d7334e51Srm femop_pageio);
1481da6c28aaSamw errc = (*func)(arg0, pp, io_off, io_len, flags, cr, ct);
14827c478bd9Sstevel@tonic-gate fem_release(femsp);
14837c478bd9Sstevel@tonic-gate }
14847c478bd9Sstevel@tonic-gate return (errc);
14857c478bd9Sstevel@tonic-gate }
14867c478bd9Sstevel@tonic-gate
14877c478bd9Sstevel@tonic-gate static int
vhead_dumpctl(vnode_t * vp,int action,offset_t * blkp,caller_context_t * ct)1488d7334e51Srm vhead_dumpctl(vnode_t *vp, int action, offset_t *blkp, caller_context_t *ct)
14897c478bd9Sstevel@tonic-gate {
14907c478bd9Sstevel@tonic-gate femarg_t farg;
14917c478bd9Sstevel@tonic-gate struct fem_list *femsp;
14927c478bd9Sstevel@tonic-gate int (*func)();
14937c478bd9Sstevel@tonic-gate void *arg0;
14947c478bd9Sstevel@tonic-gate int errc;
14957c478bd9Sstevel@tonic-gate
14967c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14977c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_dumpctl);
14987c478bd9Sstevel@tonic-gate arg0 = vp;
14997c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1500da6c28aaSamw errc = (*func)(arg0, action, blkp, ct);
15017c478bd9Sstevel@tonic-gate } else {
15027c478bd9Sstevel@tonic-gate fem_addref(femsp);
15037c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
15047c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
15057c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15067c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_dumpctl,
1507d7334e51Srm femop_dumpctl);
1508da6c28aaSamw errc = (*func)(arg0, action, blkp, ct);
15097c478bd9Sstevel@tonic-gate fem_release(femsp);
15107c478bd9Sstevel@tonic-gate }
15117c478bd9Sstevel@tonic-gate return (errc);
15127c478bd9Sstevel@tonic-gate }
15137c478bd9Sstevel@tonic-gate
1514b1659ed9SToomas Soome static int
vhead_dispose(vnode_t * vp,struct page * pp,int flag,int dn,cred_t * cr,caller_context_t * ct)1515da6c28aaSamw vhead_dispose(vnode_t *vp, struct page *pp, int flag, int dn, cred_t *cr,
1516b1659ed9SToomas Soome caller_context_t *ct)
15177c478bd9Sstevel@tonic-gate {
15187c478bd9Sstevel@tonic-gate femarg_t farg;
15197c478bd9Sstevel@tonic-gate struct fem_list *femsp;
15207c478bd9Sstevel@tonic-gate void (*func)();
15217c478bd9Sstevel@tonic-gate void *arg0;
15227c478bd9Sstevel@tonic-gate
15237c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15247c478bd9Sstevel@tonic-gate func = (void (*)()) (vp->v_op->vop_dispose);
15257c478bd9Sstevel@tonic-gate arg0 = vp;
15267c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1527da6c28aaSamw (*func)(arg0, pp, flag, dn, cr, ct);
15287c478bd9Sstevel@tonic-gate } else {
15297c478bd9Sstevel@tonic-gate fem_addref(femsp);
15307c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
15317c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
15327c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15337c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, void, &arg0, vop_dispose,
1534d7334e51Srm femop_dispose);
1535da6c28aaSamw (*func)(arg0, pp, flag, dn, cr, ct);
15367c478bd9Sstevel@tonic-gate fem_release(femsp);
15377c478bd9Sstevel@tonic-gate }
1538b1659ed9SToomas Soome return (0);
15397c478bd9Sstevel@tonic-gate }
15407c478bd9Sstevel@tonic-gate
15417c478bd9Sstevel@tonic-gate static int
vhead_setsecattr(vnode_t * vp,vsecattr_t * vsap,int flag,cred_t * cr,caller_context_t * ct)1542da6c28aaSamw vhead_setsecattr(vnode_t *vp, vsecattr_t *vsap, int flag, cred_t *cr,
1543b1659ed9SToomas Soome caller_context_t *ct)
15447c478bd9Sstevel@tonic-gate {
15457c478bd9Sstevel@tonic-gate femarg_t farg;
15467c478bd9Sstevel@tonic-gate struct fem_list *femsp;
15477c478bd9Sstevel@tonic-gate int (*func)();
15487c478bd9Sstevel@tonic-gate void *arg0;
15497c478bd9Sstevel@tonic-gate int errc;
15507c478bd9Sstevel@tonic-gate
15517c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15527c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_setsecattr);
15537c478bd9Sstevel@tonic-gate arg0 = vp;
15547c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1555da6c28aaSamw errc = (*func)(arg0, vsap, flag, cr, ct);
15567c478bd9Sstevel@tonic-gate } else {
15577c478bd9Sstevel@tonic-gate fem_addref(femsp);
15587c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
15597c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
15607c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15617c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_setsecattr,
1562d7334e51Srm femop_setsecattr);
1563da6c28aaSamw errc = (*func)(arg0, vsap, flag, cr, ct);
15647c478bd9Sstevel@tonic-gate fem_release(femsp);
15657c478bd9Sstevel@tonic-gate }
15667c478bd9Sstevel@tonic-gate return (errc);
15677c478bd9Sstevel@tonic-gate }
15687c478bd9Sstevel@tonic-gate
15697c478bd9Sstevel@tonic-gate static int
vhead_getsecattr(vnode_t * vp,vsecattr_t * vsap,int flag,cred_t * cr,caller_context_t * ct)1570da6c28aaSamw vhead_getsecattr(vnode_t *vp, vsecattr_t *vsap, int flag, cred_t *cr,
1571b1659ed9SToomas Soome caller_context_t *ct)
15727c478bd9Sstevel@tonic-gate {
15737c478bd9Sstevel@tonic-gate femarg_t farg;
15747c478bd9Sstevel@tonic-gate struct fem_list *femsp;
15757c478bd9Sstevel@tonic-gate int (*func)();
15767c478bd9Sstevel@tonic-gate void *arg0;
15777c478bd9Sstevel@tonic-gate int errc;
15787c478bd9Sstevel@tonic-gate
15797c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15807c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_getsecattr);
15817c478bd9Sstevel@tonic-gate arg0 = vp;
15827c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1583da6c28aaSamw errc = (*func)(arg0, vsap, flag, cr, ct);
15847c478bd9Sstevel@tonic-gate } else {
15857c478bd9Sstevel@tonic-gate fem_addref(femsp);
15867c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
15877c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
15887c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15897c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_getsecattr,
1590d7334e51Srm femop_getsecattr);
1591da6c28aaSamw errc = (*func)(arg0, vsap, flag, cr, ct);
15927c478bd9Sstevel@tonic-gate fem_release(femsp);
15937c478bd9Sstevel@tonic-gate }
15947c478bd9Sstevel@tonic-gate return (errc);
15957c478bd9Sstevel@tonic-gate }
15967c478bd9Sstevel@tonic-gate
15977c478bd9Sstevel@tonic-gate static int
vhead_shrlock(vnode_t * vp,int cmd,struct shrlock * shr,int flag,cred_t * cr,caller_context_t * ct)15987c478bd9Sstevel@tonic-gate vhead_shrlock(vnode_t *vp, int cmd, struct shrlock *shr, int flag,
1599b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
16007c478bd9Sstevel@tonic-gate {
16017c478bd9Sstevel@tonic-gate femarg_t farg;
16027c478bd9Sstevel@tonic-gate struct fem_list *femsp;
16037c478bd9Sstevel@tonic-gate int (*func)();
16047c478bd9Sstevel@tonic-gate void *arg0;
16057c478bd9Sstevel@tonic-gate int errc;
16067c478bd9Sstevel@tonic-gate
16077c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
16087c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_shrlock);
16097c478bd9Sstevel@tonic-gate arg0 = vp;
16107c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1611da6c28aaSamw errc = (*func)(arg0, cmd, shr, flag, cr, ct);
16127c478bd9Sstevel@tonic-gate } else {
16137c478bd9Sstevel@tonic-gate fem_addref(femsp);
16147c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
16157c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
16167c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16177c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_shrlock,
1618d7334e51Srm femop_shrlock);
1619da6c28aaSamw errc = (*func)(arg0, cmd, shr, flag, cr, ct);
16207c478bd9Sstevel@tonic-gate fem_release(femsp);
16217c478bd9Sstevel@tonic-gate }
16227c478bd9Sstevel@tonic-gate return (errc);
16237c478bd9Sstevel@tonic-gate }
16247c478bd9Sstevel@tonic-gate
16257c478bd9Sstevel@tonic-gate static int
vhead_vnevent(vnode_t * vp,vnevent_t vnevent,vnode_t * dvp,char * cname,caller_context_t * ct)1626da6c28aaSamw vhead_vnevent(vnode_t *vp, vnevent_t vnevent, vnode_t *dvp, char *cname,
1627da6c28aaSamw caller_context_t *ct)
16287c478bd9Sstevel@tonic-gate {
16297c478bd9Sstevel@tonic-gate femarg_t farg;
16307c478bd9Sstevel@tonic-gate struct fem_list *femsp;
16317c478bd9Sstevel@tonic-gate int (*func)();
16327c478bd9Sstevel@tonic-gate void *arg0;
16337c478bd9Sstevel@tonic-gate int errc;
16347c478bd9Sstevel@tonic-gate
16357c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
16367c478bd9Sstevel@tonic-gate func = (int (*)()) (vp->v_op->vop_vnevent);
16377c478bd9Sstevel@tonic-gate arg0 = vp;
16387c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
1639da6c28aaSamw errc = (*func)(arg0, vnevent, dvp, cname, ct);
16407c478bd9Sstevel@tonic-gate } else {
16417c478bd9Sstevel@tonic-gate fem_addref(femsp);
16427c478bd9Sstevel@tonic-gate fem_unlock(vp->v_femhead);
16437c478bd9Sstevel@tonic-gate farg.fa_vnode.vp = vp;
16447c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16457c478bd9Sstevel@tonic-gate vsop_find(&farg, &func, int, &arg0, vop_vnevent,
1646d7334e51Srm femop_vnevent);
1647da6c28aaSamw errc = (*func)(arg0, vnevent, dvp, cname, ct);
16487c478bd9Sstevel@tonic-gate fem_release(femsp);
16497c478bd9Sstevel@tonic-gate }
16507c478bd9Sstevel@tonic-gate return (errc);
16517c478bd9Sstevel@tonic-gate }
16527c478bd9Sstevel@tonic-gate
1653c242f9a0Schunli zhang - Sun Microsystems - Irvine United States static int
vhead_reqzcbuf(vnode_t * vp,enum uio_rw ioflag,xuio_t * xuiop,cred_t * cr,caller_context_t * ct)1654c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vhead_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuiop, cred_t *cr,
1655c242f9a0Schunli zhang - Sun Microsystems - Irvine United States caller_context_t *ct)
1656c242f9a0Schunli zhang - Sun Microsystems - Irvine United States {
1657c242f9a0Schunli zhang - Sun Microsystems - Irvine United States femarg_t farg;
1658c242f9a0Schunli zhang - Sun Microsystems - Irvine United States struct fem_list *femsp;
1659c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int (*func)();
1660c242f9a0Schunli zhang - Sun Microsystems - Irvine United States void *arg0;
1661c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int errc;
1662c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
1663c242f9a0Schunli zhang - Sun Microsystems - Irvine United States if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
1664c242f9a0Schunli zhang - Sun Microsystems - Irvine United States func = (int (*)()) (vp->v_op->vop_reqzcbuf);
1665c242f9a0Schunli zhang - Sun Microsystems - Irvine United States arg0 = vp;
1666c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_unlock(vp->v_femhead);
1667c242f9a0Schunli zhang - Sun Microsystems - Irvine United States errc = (*func)(arg0, ioflag, xuiop, cr, ct);
1668c242f9a0Schunli zhang - Sun Microsystems - Irvine United States } else {
1669c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_addref(femsp);
1670c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_unlock(vp->v_femhead);
1671c242f9a0Schunli zhang - Sun Microsystems - Irvine United States farg.fa_vnode.vp = vp;
1672c242f9a0Schunli zhang - Sun Microsystems - Irvine United States farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1673c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vsop_find(&farg, &func, int, &arg0, vop_reqzcbuf,
1674c242f9a0Schunli zhang - Sun Microsystems - Irvine United States femop_reqzcbuf);
1675c242f9a0Schunli zhang - Sun Microsystems - Irvine United States errc = (*func)(arg0, ioflag, xuiop, cr, ct);
1676c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_release(femsp);
1677c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
1678c242f9a0Schunli zhang - Sun Microsystems - Irvine United States return (errc);
1679c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
1680c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
1681c242f9a0Schunli zhang - Sun Microsystems - Irvine United States static int
vhead_retzcbuf(vnode_t * vp,xuio_t * xuiop,cred_t * cr,caller_context_t * ct)1682c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vhead_retzcbuf(vnode_t *vp, xuio_t *xuiop, cred_t *cr, caller_context_t *ct)
1683c242f9a0Schunli zhang - Sun Microsystems - Irvine United States {
1684c242f9a0Schunli zhang - Sun Microsystems - Irvine United States femarg_t farg;
1685c242f9a0Schunli zhang - Sun Microsystems - Irvine United States struct fem_list *femsp;
1686c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int (*func)();
1687c242f9a0Schunli zhang - Sun Microsystems - Irvine United States void *arg0;
1688c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int errc;
1689c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
1690c242f9a0Schunli zhang - Sun Microsystems - Irvine United States if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
1691c242f9a0Schunli zhang - Sun Microsystems - Irvine United States func = (int (*)()) (vp->v_op->vop_retzcbuf);
1692c242f9a0Schunli zhang - Sun Microsystems - Irvine United States arg0 = vp;
1693c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_unlock(vp->v_femhead);
1694c242f9a0Schunli zhang - Sun Microsystems - Irvine United States errc = (*func)(arg0, xuiop, cr, ct);
1695c242f9a0Schunli zhang - Sun Microsystems - Irvine United States } else {
1696c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_addref(femsp);
1697c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_unlock(vp->v_femhead);
1698c242f9a0Schunli zhang - Sun Microsystems - Irvine United States farg.fa_vnode.vp = vp;
1699c242f9a0Schunli zhang - Sun Microsystems - Irvine United States farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1700c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vsop_find(&farg, &func, int, &arg0, vop_retzcbuf,
1701c242f9a0Schunli zhang - Sun Microsystems - Irvine United States femop_retzcbuf);
1702c242f9a0Schunli zhang - Sun Microsystems - Irvine United States errc = (*func)(arg0, xuiop, cr, ct);
1703c242f9a0Schunli zhang - Sun Microsystems - Irvine United States fem_release(femsp);
1704c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
1705c242f9a0Schunli zhang - Sun Microsystems - Irvine United States return (errc);
1706c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
1707c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
17087c478bd9Sstevel@tonic-gate static int
fshead_mount(vfs_t * vfsp,vnode_t * mvp,struct mounta * uap,cred_t * cr)17097c478bd9Sstevel@tonic-gate fshead_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
17107c478bd9Sstevel@tonic-gate {
17117c478bd9Sstevel@tonic-gate fsemarg_t farg;
17127c478bd9Sstevel@tonic-gate struct fem_list *femsp;
17137c478bd9Sstevel@tonic-gate int (*func)();
17147c478bd9Sstevel@tonic-gate void *arg0;
17157c478bd9Sstevel@tonic-gate int errc;
17167c478bd9Sstevel@tonic-gate
1717ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1718ddfcde86Srsb
17197c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17207c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_mount;
17217c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17227c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, mvp, uap, cr);
17237c478bd9Sstevel@tonic-gate } else {
17247c478bd9Sstevel@tonic-gate fem_addref(femsp);
17257c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17267c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
17277c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17287c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, int, &arg0, vfs_mount,
1729d7334e51Srm fsemop_mount);
17307c478bd9Sstevel@tonic-gate errc = (*func)(arg0, mvp, uap, cr);
17317c478bd9Sstevel@tonic-gate fem_release(femsp);
17327c478bd9Sstevel@tonic-gate }
17337c478bd9Sstevel@tonic-gate return (errc);
17347c478bd9Sstevel@tonic-gate }
17357c478bd9Sstevel@tonic-gate
17367c478bd9Sstevel@tonic-gate static int
fshead_unmount(vfs_t * vfsp,int flag,cred_t * cr)17377c478bd9Sstevel@tonic-gate fshead_unmount(vfs_t *vfsp, int flag, cred_t *cr)
17387c478bd9Sstevel@tonic-gate {
17397c478bd9Sstevel@tonic-gate fsemarg_t farg;
17407c478bd9Sstevel@tonic-gate struct fem_list *femsp;
17417c478bd9Sstevel@tonic-gate int (*func)();
17427c478bd9Sstevel@tonic-gate void *arg0;
17437c478bd9Sstevel@tonic-gate int errc;
17447c478bd9Sstevel@tonic-gate
1745ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1746ddfcde86Srsb
17477c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17487c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_unmount;
17497c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17507c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, flag, cr);
17517c478bd9Sstevel@tonic-gate } else {
17527c478bd9Sstevel@tonic-gate fem_addref(femsp);
17537c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17547c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
17557c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17567c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, int, &arg0, vfs_unmount,
1757d7334e51Srm fsemop_unmount);
17587c478bd9Sstevel@tonic-gate errc = (*func)(arg0, flag, cr);
17597c478bd9Sstevel@tonic-gate fem_release(femsp);
17607c478bd9Sstevel@tonic-gate }
17617c478bd9Sstevel@tonic-gate return (errc);
17627c478bd9Sstevel@tonic-gate }
17637c478bd9Sstevel@tonic-gate
17647c478bd9Sstevel@tonic-gate static int
fshead_root(vfs_t * vfsp,vnode_t ** vpp)17657c478bd9Sstevel@tonic-gate fshead_root(vfs_t *vfsp, vnode_t **vpp)
17667c478bd9Sstevel@tonic-gate {
17677c478bd9Sstevel@tonic-gate fsemarg_t farg;
17687c478bd9Sstevel@tonic-gate struct fem_list *femsp;
17697c478bd9Sstevel@tonic-gate int (*func)();
17707c478bd9Sstevel@tonic-gate void *arg0;
17717c478bd9Sstevel@tonic-gate int errc;
17727c478bd9Sstevel@tonic-gate
1773ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1774ddfcde86Srsb
17757c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17767c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_root;
17777c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17787c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, vpp);
17797c478bd9Sstevel@tonic-gate } else {
17807c478bd9Sstevel@tonic-gate fem_addref(femsp);
17817c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
17827c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
17837c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1784aa59c4cbSrsb vfsop_find(&farg, &func, int, &arg0, vfs_root, fsemop_root);
17857c478bd9Sstevel@tonic-gate errc = (*func)(arg0, vpp);
17867c478bd9Sstevel@tonic-gate fem_release(femsp);
17877c478bd9Sstevel@tonic-gate }
17887c478bd9Sstevel@tonic-gate return (errc);
17897c478bd9Sstevel@tonic-gate }
17907c478bd9Sstevel@tonic-gate
17917c478bd9Sstevel@tonic-gate static int
fshead_statvfs(vfs_t * vfsp,statvfs64_t * sp)17927c478bd9Sstevel@tonic-gate fshead_statvfs(vfs_t *vfsp, statvfs64_t *sp)
17937c478bd9Sstevel@tonic-gate {
17947c478bd9Sstevel@tonic-gate fsemarg_t farg;
17957c478bd9Sstevel@tonic-gate struct fem_list *femsp;
17967c478bd9Sstevel@tonic-gate int (*func)();
17977c478bd9Sstevel@tonic-gate void *arg0;
17987c478bd9Sstevel@tonic-gate int errc;
17997c478bd9Sstevel@tonic-gate
1800ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1801ddfcde86Srsb
18027c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18037c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_statvfs;
18047c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18057c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, sp);
18067c478bd9Sstevel@tonic-gate } else {
18077c478bd9Sstevel@tonic-gate fem_addref(femsp);
18087c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18097c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
18107c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
18117c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, int, &arg0, vfs_statvfs,
1812d7334e51Srm fsemop_statvfs);
18137c478bd9Sstevel@tonic-gate errc = (*func)(arg0, sp);
18147c478bd9Sstevel@tonic-gate fem_release(femsp);
18157c478bd9Sstevel@tonic-gate }
18167c478bd9Sstevel@tonic-gate return (errc);
18177c478bd9Sstevel@tonic-gate }
18187c478bd9Sstevel@tonic-gate
18197c478bd9Sstevel@tonic-gate static int
fshead_sync(vfs_t * vfsp,short flag,cred_t * cr)18207c478bd9Sstevel@tonic-gate fshead_sync(vfs_t *vfsp, short flag, cred_t *cr)
18217c478bd9Sstevel@tonic-gate {
18227c478bd9Sstevel@tonic-gate fsemarg_t farg;
18237c478bd9Sstevel@tonic-gate struct fem_list *femsp;
18247c478bd9Sstevel@tonic-gate int (*func)();
18257c478bd9Sstevel@tonic-gate void *arg0;
18267c478bd9Sstevel@tonic-gate int errc;
18277c478bd9Sstevel@tonic-gate
1828ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1829ddfcde86Srsb
18307c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18317c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_sync;
18327c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18337c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, flag, cr);
18347c478bd9Sstevel@tonic-gate } else {
18357c478bd9Sstevel@tonic-gate fem_addref(femsp);
18367c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18377c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
18387c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1839aa59c4cbSrsb vfsop_find(&farg, &func, int, &arg0, vfs_sync, fsemop_sync);
18407c478bd9Sstevel@tonic-gate errc = (*func)(arg0, flag, cr);
18417c478bd9Sstevel@tonic-gate fem_release(femsp);
18427c478bd9Sstevel@tonic-gate }
18437c478bd9Sstevel@tonic-gate return (errc);
18447c478bd9Sstevel@tonic-gate }
18457c478bd9Sstevel@tonic-gate
18467c478bd9Sstevel@tonic-gate static int
fshead_vget(vfs_t * vfsp,vnode_t ** vpp,fid_t * fidp)18477c478bd9Sstevel@tonic-gate fshead_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
18487c478bd9Sstevel@tonic-gate {
18497c478bd9Sstevel@tonic-gate fsemarg_t farg;
18507c478bd9Sstevel@tonic-gate struct fem_list *femsp;
18517c478bd9Sstevel@tonic-gate int (*func)();
18527c478bd9Sstevel@tonic-gate void *arg0;
18537c478bd9Sstevel@tonic-gate int errc;
18547c478bd9Sstevel@tonic-gate
1855ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1856ddfcde86Srsb
18577c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18587c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_vget;
18597c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18607c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, vpp, fidp);
18617c478bd9Sstevel@tonic-gate } else {
18627c478bd9Sstevel@tonic-gate fem_addref(femsp);
18637c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18647c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
18657c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
1866aa59c4cbSrsb vfsop_find(&farg, &func, int, &arg0, vfs_vget, fsemop_vget);
18677c478bd9Sstevel@tonic-gate errc = (*func)(arg0, vpp, fidp);
18687c478bd9Sstevel@tonic-gate fem_release(femsp);
18697c478bd9Sstevel@tonic-gate }
18707c478bd9Sstevel@tonic-gate return (errc);
18717c478bd9Sstevel@tonic-gate }
18727c478bd9Sstevel@tonic-gate
18737c478bd9Sstevel@tonic-gate static int
fshead_mountroot(vfs_t * vfsp,enum whymountroot reason)18747c478bd9Sstevel@tonic-gate fshead_mountroot(vfs_t *vfsp, enum whymountroot reason)
18757c478bd9Sstevel@tonic-gate {
18767c478bd9Sstevel@tonic-gate fsemarg_t farg;
18777c478bd9Sstevel@tonic-gate struct fem_list *femsp;
18787c478bd9Sstevel@tonic-gate int (*func)();
18797c478bd9Sstevel@tonic-gate void *arg0;
18807c478bd9Sstevel@tonic-gate int errc;
18817c478bd9Sstevel@tonic-gate
1882ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1883ddfcde86Srsb
18847c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18857c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_mountroot;
18867c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18877c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, reason);
18887c478bd9Sstevel@tonic-gate } else {
18897c478bd9Sstevel@tonic-gate fem_addref(femsp);
18907c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
18917c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
18927c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
18937c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, int, &arg0, vfs_mountroot,
1894d7334e51Srm fsemop_mountroot);
18957c478bd9Sstevel@tonic-gate errc = (*func)(arg0, reason);
18967c478bd9Sstevel@tonic-gate fem_release(femsp);
18977c478bd9Sstevel@tonic-gate }
18987c478bd9Sstevel@tonic-gate return (errc);
18997c478bd9Sstevel@tonic-gate }
19007c478bd9Sstevel@tonic-gate
1901b1659ed9SToomas Soome static int
fshead_freevfs(vfs_t * vfsp)19027c478bd9Sstevel@tonic-gate fshead_freevfs(vfs_t *vfsp)
19037c478bd9Sstevel@tonic-gate {
19047c478bd9Sstevel@tonic-gate fsemarg_t farg;
19057c478bd9Sstevel@tonic-gate struct fem_list *femsp;
19067c478bd9Sstevel@tonic-gate void (*func)();
19077c478bd9Sstevel@tonic-gate void *arg0;
19087c478bd9Sstevel@tonic-gate
1909ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1910ddfcde86Srsb
19117c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
19127c478bd9Sstevel@tonic-gate func = (void (*)()) vfsp->vfs_op->vfs_freevfs;
19137c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
19147c478bd9Sstevel@tonic-gate (*func)(vfsp);
19157c478bd9Sstevel@tonic-gate } else {
19167c478bd9Sstevel@tonic-gate fem_addref(femsp);
19177c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
19187c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
19197c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
19207c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, void, &arg0, vfs_freevfs,
1921d7334e51Srm fsemop_freevfs);
19227c478bd9Sstevel@tonic-gate (*func)(arg0);
19237c478bd9Sstevel@tonic-gate fem_release(femsp);
19247c478bd9Sstevel@tonic-gate }
1925b1659ed9SToomas Soome return (0);
19267c478bd9Sstevel@tonic-gate }
19277c478bd9Sstevel@tonic-gate
19287c478bd9Sstevel@tonic-gate static int
fshead_vnstate(vfs_t * vfsp,vnode_t * vp,vntrans_t nstate)19297c478bd9Sstevel@tonic-gate fshead_vnstate(vfs_t *vfsp, vnode_t *vp, vntrans_t nstate)
19307c478bd9Sstevel@tonic-gate {
19317c478bd9Sstevel@tonic-gate fsemarg_t farg;
19327c478bd9Sstevel@tonic-gate struct fem_list *femsp;
19337c478bd9Sstevel@tonic-gate int (*func)();
19347c478bd9Sstevel@tonic-gate void *arg0;
19357c478bd9Sstevel@tonic-gate int errc;
19367c478bd9Sstevel@tonic-gate
1937ddfcde86Srsb ASSERT(vfsp->vfs_implp);
1938ddfcde86Srsb
19397c478bd9Sstevel@tonic-gate if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
19407c478bd9Sstevel@tonic-gate func = (int (*)()) vfsp->vfs_op->vfs_vnstate;
19417c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
19427c478bd9Sstevel@tonic-gate errc = (*func)(vfsp, vp, nstate);
19437c478bd9Sstevel@tonic-gate } else {
19447c478bd9Sstevel@tonic-gate fem_addref(femsp);
19457c478bd9Sstevel@tonic-gate fem_unlock(vfsp->vfs_femhead);
19467c478bd9Sstevel@tonic-gate farg.fa_vnode.vfsp = vfsp;
19477c478bd9Sstevel@tonic-gate farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
19487c478bd9Sstevel@tonic-gate vfsop_find(&farg, &func, int, &arg0, vfs_vnstate,
1949d7334e51Srm fsemop_vnstate);
19507c478bd9Sstevel@tonic-gate errc = (*func)(arg0, vp, nstate);
19517c478bd9Sstevel@tonic-gate fem_release(femsp);
19527c478bd9Sstevel@tonic-gate }
19537c478bd9Sstevel@tonic-gate return (errc);
19547c478bd9Sstevel@tonic-gate }
19557c478bd9Sstevel@tonic-gate
19567c478bd9Sstevel@tonic-gate
19577c478bd9Sstevel@tonic-gate /*
19587c478bd9Sstevel@tonic-gate * specification table for the vhead vnode operations.
19597c478bd9Sstevel@tonic-gate * It is an error for any operations to be missing.
19607c478bd9Sstevel@tonic-gate */
19617c478bd9Sstevel@tonic-gate
19627c478bd9Sstevel@tonic-gate static struct fs_operation_def fhead_vn_spec[] = {
19637c478bd9Sstevel@tonic-gate { VOPNAME_OPEN, (femop_t *)vhead_open },
19647c478bd9Sstevel@tonic-gate { VOPNAME_CLOSE, (femop_t *)vhead_close },
19657c478bd9Sstevel@tonic-gate { VOPNAME_READ, (femop_t *)vhead_read },
19667c478bd9Sstevel@tonic-gate { VOPNAME_WRITE, (femop_t *)vhead_write },
19677c478bd9Sstevel@tonic-gate { VOPNAME_IOCTL, (femop_t *)vhead_ioctl },
19687c478bd9Sstevel@tonic-gate { VOPNAME_SETFL, (femop_t *)vhead_setfl },
19697c478bd9Sstevel@tonic-gate { VOPNAME_GETATTR, (femop_t *)vhead_getattr },
19707c478bd9Sstevel@tonic-gate { VOPNAME_SETATTR, (femop_t *)vhead_setattr },
19717c478bd9Sstevel@tonic-gate { VOPNAME_ACCESS, (femop_t *)vhead_access },
19727c478bd9Sstevel@tonic-gate { VOPNAME_LOOKUP, (femop_t *)vhead_lookup },
19737c478bd9Sstevel@tonic-gate { VOPNAME_CREATE, (femop_t *)vhead_create },
19747c478bd9Sstevel@tonic-gate { VOPNAME_REMOVE, (femop_t *)vhead_remove },
19757c478bd9Sstevel@tonic-gate { VOPNAME_LINK, (femop_t *)vhead_link },
19767c478bd9Sstevel@tonic-gate { VOPNAME_RENAME, (femop_t *)vhead_rename },
19777c478bd9Sstevel@tonic-gate { VOPNAME_MKDIR, (femop_t *)vhead_mkdir },
19787c478bd9Sstevel@tonic-gate { VOPNAME_RMDIR, (femop_t *)vhead_rmdir },
19797c478bd9Sstevel@tonic-gate { VOPNAME_READDIR, (femop_t *)vhead_readdir },
19807c478bd9Sstevel@tonic-gate { VOPNAME_SYMLINK, (femop_t *)vhead_symlink },
19817c478bd9Sstevel@tonic-gate { VOPNAME_READLINK, (femop_t *)vhead_readlink },
19827c478bd9Sstevel@tonic-gate { VOPNAME_FSYNC, (femop_t *)vhead_fsync },
19837c478bd9Sstevel@tonic-gate { VOPNAME_INACTIVE, (femop_t *)vhead_inactive },
19847c478bd9Sstevel@tonic-gate { VOPNAME_FID, (femop_t *)vhead_fid },
19857c478bd9Sstevel@tonic-gate { VOPNAME_RWLOCK, (femop_t *)vhead_rwlock },
19867c478bd9Sstevel@tonic-gate { VOPNAME_RWUNLOCK, (femop_t *)vhead_rwunlock },
19877c478bd9Sstevel@tonic-gate { VOPNAME_SEEK, (femop_t *)vhead_seek },
19887c478bd9Sstevel@tonic-gate { VOPNAME_CMP, (femop_t *)vhead_cmp },
19897c478bd9Sstevel@tonic-gate { VOPNAME_FRLOCK, (femop_t *)vhead_frlock },
19907c478bd9Sstevel@tonic-gate { VOPNAME_SPACE, (femop_t *)vhead_space },
19917c478bd9Sstevel@tonic-gate { VOPNAME_REALVP, (femop_t *)vhead_realvp },
19927c478bd9Sstevel@tonic-gate { VOPNAME_GETPAGE, (femop_t *)vhead_getpage },
19937c478bd9Sstevel@tonic-gate { VOPNAME_PUTPAGE, (femop_t *)vhead_putpage },
19947c478bd9Sstevel@tonic-gate { VOPNAME_MAP, (femop_t *)vhead_map },
19957c478bd9Sstevel@tonic-gate { VOPNAME_ADDMAP, (femop_t *)vhead_addmap },
19967c478bd9Sstevel@tonic-gate { VOPNAME_DELMAP, (femop_t *)vhead_delmap },
19977c478bd9Sstevel@tonic-gate { VOPNAME_POLL, (femop_t *)vhead_poll },
19987c478bd9Sstevel@tonic-gate { VOPNAME_DUMP, (femop_t *)vhead_dump },
19997c478bd9Sstevel@tonic-gate { VOPNAME_PATHCONF, (femop_t *)vhead_pathconf },
20007c478bd9Sstevel@tonic-gate { VOPNAME_PAGEIO, (femop_t *)vhead_pageio },
20017c478bd9Sstevel@tonic-gate { VOPNAME_DUMPCTL, (femop_t *)vhead_dumpctl },
20027c478bd9Sstevel@tonic-gate { VOPNAME_DISPOSE, (femop_t *)vhead_dispose },
20037c478bd9Sstevel@tonic-gate { VOPNAME_SETSECATTR, (femop_t *)vhead_setsecattr },
20047c478bd9Sstevel@tonic-gate { VOPNAME_GETSECATTR, (femop_t *)vhead_getsecattr },
20057c478bd9Sstevel@tonic-gate { VOPNAME_SHRLOCK, (femop_t *)vhead_shrlock },
20067c478bd9Sstevel@tonic-gate { VOPNAME_VNEVENT, (femop_t *)vhead_vnevent },
2007c242f9a0Schunli zhang - Sun Microsystems - Irvine United States { VOPNAME_REQZCBUF, (femop_t *)vhead_reqzcbuf },
2008c242f9a0Schunli zhang - Sun Microsystems - Irvine United States { VOPNAME_RETZCBUF, (femop_t *)vhead_retzcbuf },
20097c478bd9Sstevel@tonic-gate { NULL, NULL }
20107c478bd9Sstevel@tonic-gate };
20117c478bd9Sstevel@tonic-gate
20127c478bd9Sstevel@tonic-gate /*
20137c478bd9Sstevel@tonic-gate * specification table for the vfshead vnode operations.
20147c478bd9Sstevel@tonic-gate * It is an error for any operations to be missing.
20157c478bd9Sstevel@tonic-gate */
20167c478bd9Sstevel@tonic-gate
20177c478bd9Sstevel@tonic-gate static struct fs_operation_def fshead_vfs_spec[] = {
20187c478bd9Sstevel@tonic-gate { VFSNAME_MOUNT, (femop_t *)fshead_mount },
20197c478bd9Sstevel@tonic-gate { VFSNAME_UNMOUNT, (femop_t *)fshead_unmount },
20207c478bd9Sstevel@tonic-gate { VFSNAME_ROOT, (femop_t *)fshead_root },
20217c478bd9Sstevel@tonic-gate { VFSNAME_STATVFS, (femop_t *)fshead_statvfs },
20227c478bd9Sstevel@tonic-gate { VFSNAME_SYNC, (femop_t *)fshead_sync },
20237c478bd9Sstevel@tonic-gate { VFSNAME_VGET, (femop_t *)fshead_vget },
20247c478bd9Sstevel@tonic-gate { VFSNAME_MOUNTROOT, (femop_t *)fshead_mountroot },
20257c478bd9Sstevel@tonic-gate { VFSNAME_FREEVFS, (femop_t *)fshead_freevfs },
20267c478bd9Sstevel@tonic-gate { VFSNAME_VNSTATE, (femop_t *)fshead_vnstate },
20277c478bd9Sstevel@tonic-gate { NULL, NULL }
20287c478bd9Sstevel@tonic-gate };
20297c478bd9Sstevel@tonic-gate
20307c478bd9Sstevel@tonic-gate /*
20317c478bd9Sstevel@tonic-gate * This set of routines transfer control to the next stacked monitor.
20327c478bd9Sstevel@tonic-gate *
20337c478bd9Sstevel@tonic-gate * Each routine is identical except for naming, types and arguments.
20347c478bd9Sstevel@tonic-gate *
20357c478bd9Sstevel@tonic-gate * The basic steps are:
20367c478bd9Sstevel@tonic-gate * 1. Decrease the stack pointer by one.
20377c478bd9Sstevel@tonic-gate * 2. If the current item is a base operation (vnode, vfs), goto 5.
20387c478bd9Sstevel@tonic-gate * 3. If the current item does not have a corresponding operation, goto 1
20397c478bd9Sstevel@tonic-gate * 4. Return by invoking the current item with the argument handle.
20407c478bd9Sstevel@tonic-gate * 5. Return by invoking the base operation with the base object.
20417c478bd9Sstevel@tonic-gate *
20427c478bd9Sstevel@tonic-gate * for each classification, there needs to be at least one "next" operation
20437c478bd9Sstevel@tonic-gate * for each "head"operation.
20447c478bd9Sstevel@tonic-gate *
20457c478bd9Sstevel@tonic-gate */
20467c478bd9Sstevel@tonic-gate
20477c478bd9Sstevel@tonic-gate int
vnext_open(femarg_t * vf,int mode,cred_t * cr,caller_context_t * ct)2048da6c28aaSamw vnext_open(femarg_t *vf, int mode, cred_t *cr, caller_context_t *ct)
20497c478bd9Sstevel@tonic-gate {
20507c478bd9Sstevel@tonic-gate int (*func)() = NULL;
20517c478bd9Sstevel@tonic-gate void *arg0 = NULL;
20527c478bd9Sstevel@tonic-gate
20537c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
20547c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2055aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_open, femop_open);
20567c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
20577c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2058da6c28aaSamw return ((*func)(arg0, mode, cr, ct));
20597c478bd9Sstevel@tonic-gate }
20607c478bd9Sstevel@tonic-gate
20617c478bd9Sstevel@tonic-gate int
vnext_close(femarg_t * vf,int flag,int count,offset_t offset,cred_t * cr,caller_context_t * ct)2062da6c28aaSamw vnext_close(femarg_t *vf, int flag, int count, offset_t offset, cred_t *cr,
2063b1659ed9SToomas Soome caller_context_t *ct)
20647c478bd9Sstevel@tonic-gate {
20657c478bd9Sstevel@tonic-gate int (*func)() = NULL;
20667c478bd9Sstevel@tonic-gate void *arg0 = NULL;
20677c478bd9Sstevel@tonic-gate
20687c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
20697c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2070aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_close, femop_close);
20717c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
20727c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2073da6c28aaSamw return ((*func)(arg0, flag, count, offset, cr, ct));
20747c478bd9Sstevel@tonic-gate }
20757c478bd9Sstevel@tonic-gate
20767c478bd9Sstevel@tonic-gate int
vnext_read(femarg_t * vf,uio_t * uiop,int ioflag,cred_t * cr,caller_context_t * ct)20777c478bd9Sstevel@tonic-gate vnext_read(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr,
2078b1659ed9SToomas Soome caller_context_t *ct)
20797c478bd9Sstevel@tonic-gate {
20807c478bd9Sstevel@tonic-gate int (*func)() = NULL;
20817c478bd9Sstevel@tonic-gate void *arg0 = NULL;
20827c478bd9Sstevel@tonic-gate
20837c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
20847c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2085aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_read, femop_read);
20867c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
20877c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
20887c478bd9Sstevel@tonic-gate return ((*func)(arg0, uiop, ioflag, cr, ct));
20897c478bd9Sstevel@tonic-gate }
20907c478bd9Sstevel@tonic-gate
20917c478bd9Sstevel@tonic-gate int
vnext_write(femarg_t * vf,uio_t * uiop,int ioflag,cred_t * cr,caller_context_t * ct)20927c478bd9Sstevel@tonic-gate vnext_write(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr,
2093b1659ed9SToomas Soome caller_context_t *ct)
20947c478bd9Sstevel@tonic-gate {
20957c478bd9Sstevel@tonic-gate int (*func)() = NULL;
20967c478bd9Sstevel@tonic-gate void *arg0 = NULL;
20977c478bd9Sstevel@tonic-gate
20987c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
20997c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2100aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_write, femop_write);
21017c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21027c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
21037c478bd9Sstevel@tonic-gate return ((*func)(arg0, uiop, ioflag, cr, ct));
21047c478bd9Sstevel@tonic-gate }
21057c478bd9Sstevel@tonic-gate
21067c478bd9Sstevel@tonic-gate int
vnext_ioctl(femarg_t * vf,int cmd,intptr_t arg,int flag,cred_t * cr,int * rvalp,caller_context_t * ct)21077c478bd9Sstevel@tonic-gate vnext_ioctl(femarg_t *vf, int cmd, intptr_t arg, int flag, cred_t *cr,
2108b1659ed9SToomas Soome int *rvalp, caller_context_t *ct)
21097c478bd9Sstevel@tonic-gate {
21107c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21117c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21127c478bd9Sstevel@tonic-gate
21137c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21147c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2115aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_ioctl, femop_ioctl);
21167c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21177c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2118da6c28aaSamw return ((*func)(arg0, cmd, arg, flag, cr, rvalp, ct));
21197c478bd9Sstevel@tonic-gate }
21207c478bd9Sstevel@tonic-gate
21217c478bd9Sstevel@tonic-gate int
vnext_setfl(femarg_t * vf,int oflags,int nflags,cred_t * cr,caller_context_t * ct)2122da6c28aaSamw vnext_setfl(femarg_t *vf, int oflags, int nflags, cred_t *cr,
2123b1659ed9SToomas Soome caller_context_t *ct)
21247c478bd9Sstevel@tonic-gate {
21257c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21267c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21277c478bd9Sstevel@tonic-gate
21287c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21297c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2130aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_setfl, femop_setfl);
21317c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21327c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2133da6c28aaSamw return ((*func)(arg0, oflags, nflags, cr, ct));
21347c478bd9Sstevel@tonic-gate }
21357c478bd9Sstevel@tonic-gate
21367c478bd9Sstevel@tonic-gate int
vnext_getattr(femarg_t * vf,vattr_t * vap,int flags,cred_t * cr,caller_context_t * ct)2137da6c28aaSamw vnext_getattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr,
2138b1659ed9SToomas Soome caller_context_t *ct)
21397c478bd9Sstevel@tonic-gate {
21407c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21417c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21427c478bd9Sstevel@tonic-gate
21437c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21447c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2145aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_getattr, femop_getattr);
21467c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21477c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2148da6c28aaSamw return ((*func)(arg0, vap, flags, cr, ct));
21497c478bd9Sstevel@tonic-gate }
21507c478bd9Sstevel@tonic-gate
21517c478bd9Sstevel@tonic-gate int
vnext_setattr(femarg_t * vf,vattr_t * vap,int flags,cred_t * cr,caller_context_t * ct)21527c478bd9Sstevel@tonic-gate vnext_setattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr,
2153b1659ed9SToomas Soome caller_context_t *ct)
21547c478bd9Sstevel@tonic-gate {
21557c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21567c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21577c478bd9Sstevel@tonic-gate
21587c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21597c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2160aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_setattr, femop_setattr);
21617c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21627c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
21637c478bd9Sstevel@tonic-gate return ((*func)(arg0, vap, flags, cr, ct));
21647c478bd9Sstevel@tonic-gate }
21657c478bd9Sstevel@tonic-gate
21667c478bd9Sstevel@tonic-gate int
vnext_access(femarg_t * vf,int mode,int flags,cred_t * cr,caller_context_t * ct)2167da6c28aaSamw vnext_access(femarg_t *vf, int mode, int flags, cred_t *cr,
2168b1659ed9SToomas Soome caller_context_t *ct)
21697c478bd9Sstevel@tonic-gate {
21707c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21717c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21727c478bd9Sstevel@tonic-gate
21737c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21747c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2175aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_access, femop_access);
21767c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21777c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2178da6c28aaSamw return ((*func)(arg0, mode, flags, cr, ct));
21797c478bd9Sstevel@tonic-gate }
21807c478bd9Sstevel@tonic-gate
21817c478bd9Sstevel@tonic-gate int
vnext_lookup(femarg_t * vf,char * nm,vnode_t ** vpp,pathname_t * pnp,int flags,vnode_t * rdir,cred_t * cr,caller_context_t * ct,int * direntflags,pathname_t * realpnp)21827c478bd9Sstevel@tonic-gate vnext_lookup(femarg_t *vf, char *nm, vnode_t **vpp, pathname_t *pnp,
2183b1659ed9SToomas Soome int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
2184b1659ed9SToomas Soome int *direntflags, pathname_t *realpnp)
21857c478bd9Sstevel@tonic-gate {
21867c478bd9Sstevel@tonic-gate int (*func)() = NULL;
21877c478bd9Sstevel@tonic-gate void *arg0 = NULL;
21887c478bd9Sstevel@tonic-gate
21897c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
21907c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2191aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_lookup, femop_lookup);
21927c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
21937c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2194da6c28aaSamw return ((*func)(arg0, nm, vpp, pnp, flags, rdir, cr, ct,
2195d7334e51Srm direntflags, realpnp));
21967c478bd9Sstevel@tonic-gate }
21977c478bd9Sstevel@tonic-gate
21987c478bd9Sstevel@tonic-gate int
vnext_create(femarg_t * vf,char * name,vattr_t * vap,vcexcl_t excl,int mode,vnode_t ** vpp,cred_t * cr,int flag,caller_context_t * ct,vsecattr_t * vsecp)21997c478bd9Sstevel@tonic-gate vnext_create(femarg_t *vf, char *name, vattr_t *vap, vcexcl_t excl,
2200b1659ed9SToomas Soome int mode, vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct,
2201b1659ed9SToomas Soome vsecattr_t *vsecp)
22027c478bd9Sstevel@tonic-gate {
22037c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22047c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22057c478bd9Sstevel@tonic-gate
22067c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22077c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2208aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_create, femop_create);
22097c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22107c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2211da6c28aaSamw return ((*func)(arg0, name, vap, excl, mode, vpp, cr, flag, ct, vsecp));
22127c478bd9Sstevel@tonic-gate }
22137c478bd9Sstevel@tonic-gate
22147c478bd9Sstevel@tonic-gate int
vnext_remove(femarg_t * vf,char * nm,cred_t * cr,caller_context_t * ct,int flags)2215da6c28aaSamw vnext_remove(femarg_t *vf, char *nm, cred_t *cr, caller_context_t *ct,
2216b1659ed9SToomas Soome int flags)
22177c478bd9Sstevel@tonic-gate {
22187c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22197c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22207c478bd9Sstevel@tonic-gate
22217c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22227c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2223aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_remove, femop_remove);
22247c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22257c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2226da6c28aaSamw return ((*func)(arg0, nm, cr, ct, flags));
22277c478bd9Sstevel@tonic-gate }
22287c478bd9Sstevel@tonic-gate
22297c478bd9Sstevel@tonic-gate int
vnext_link(femarg_t * vf,vnode_t * svp,char * tnm,cred_t * cr,caller_context_t * ct,int flags)2230da6c28aaSamw vnext_link(femarg_t *vf, vnode_t *svp, char *tnm, cred_t *cr,
2231b1659ed9SToomas Soome caller_context_t *ct, int flags)
22327c478bd9Sstevel@tonic-gate {
22337c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22347c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22357c478bd9Sstevel@tonic-gate
22367c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22377c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2238aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_link, femop_link);
22397c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22407c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2241da6c28aaSamw return ((*func)(arg0, svp, tnm, cr, ct, flags));
22427c478bd9Sstevel@tonic-gate }
22437c478bd9Sstevel@tonic-gate
22447c478bd9Sstevel@tonic-gate int
vnext_rename(femarg_t * vf,char * snm,vnode_t * tdvp,char * tnm,cred_t * cr,caller_context_t * ct,int flags)2245da6c28aaSamw vnext_rename(femarg_t *vf, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr,
2246b1659ed9SToomas Soome caller_context_t *ct, int flags)
22477c478bd9Sstevel@tonic-gate {
22487c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22497c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22507c478bd9Sstevel@tonic-gate
22517c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22527c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2253aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_rename, femop_rename);
22547c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22557c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2256da6c28aaSamw return ((*func)(arg0, snm, tdvp, tnm, cr, ct, flags));
22577c478bd9Sstevel@tonic-gate }
22587c478bd9Sstevel@tonic-gate
22597c478bd9Sstevel@tonic-gate int
vnext_mkdir(femarg_t * vf,char * dirname,vattr_t * vap,vnode_t ** vpp,cred_t * cr,caller_context_t * ct,int flags,vsecattr_t * vsecp)22607c478bd9Sstevel@tonic-gate vnext_mkdir(femarg_t *vf, char *dirname, vattr_t *vap, vnode_t **vpp,
2261b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct, int flags, vsecattr_t *vsecp)
22627c478bd9Sstevel@tonic-gate {
22637c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22647c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22657c478bd9Sstevel@tonic-gate
22667c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22677c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2268aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_mkdir, femop_mkdir);
22697c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22707c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2271da6c28aaSamw return ((*func)(arg0, dirname, vap, vpp, cr, ct, flags, vsecp));
22727c478bd9Sstevel@tonic-gate }
22737c478bd9Sstevel@tonic-gate
22747c478bd9Sstevel@tonic-gate int
vnext_rmdir(femarg_t * vf,char * nm,vnode_t * cdir,cred_t * cr,caller_context_t * ct,int flags)2275da6c28aaSamw vnext_rmdir(femarg_t *vf, char *nm, vnode_t *cdir, cred_t *cr,
2276b1659ed9SToomas Soome caller_context_t *ct, int flags)
22777c478bd9Sstevel@tonic-gate {
22787c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22797c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22807c478bd9Sstevel@tonic-gate
22817c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22827c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2283aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_rmdir, femop_rmdir);
22847c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
22857c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2286da6c28aaSamw return ((*func)(arg0, nm, cdir, cr, ct, flags));
22877c478bd9Sstevel@tonic-gate }
22887c478bd9Sstevel@tonic-gate
22897c478bd9Sstevel@tonic-gate int
vnext_readdir(femarg_t * vf,uio_t * uiop,cred_t * cr,int * eofp,caller_context_t * ct,int flags)2290da6c28aaSamw vnext_readdir(femarg_t *vf, uio_t *uiop, cred_t *cr, int *eofp,
2291b1659ed9SToomas Soome caller_context_t *ct, int flags)
22927c478bd9Sstevel@tonic-gate {
22937c478bd9Sstevel@tonic-gate int (*func)() = NULL;
22947c478bd9Sstevel@tonic-gate void *arg0 = NULL;
22957c478bd9Sstevel@tonic-gate
22967c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
22977c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2298aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_readdir, femop_readdir);
22997c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23007c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2301da6c28aaSamw return ((*func)(arg0, uiop, cr, eofp, ct, flags));
23027c478bd9Sstevel@tonic-gate }
23037c478bd9Sstevel@tonic-gate
23047c478bd9Sstevel@tonic-gate int
vnext_symlink(femarg_t * vf,char * linkname,vattr_t * vap,char * target,cred_t * cr,caller_context_t * ct,int flags)23057c478bd9Sstevel@tonic-gate vnext_symlink(femarg_t *vf, char *linkname, vattr_t *vap, char *target,
2306b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct, int flags)
23077c478bd9Sstevel@tonic-gate {
23087c478bd9Sstevel@tonic-gate int (*func)() = NULL;
23097c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23107c478bd9Sstevel@tonic-gate
23117c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23127c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2313aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_symlink, femop_symlink);
23147c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23157c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2316da6c28aaSamw return ((*func)(arg0, linkname, vap, target, cr, ct, flags));
23177c478bd9Sstevel@tonic-gate }
23187c478bd9Sstevel@tonic-gate
23197c478bd9Sstevel@tonic-gate int
vnext_readlink(femarg_t * vf,uio_t * uiop,cred_t * cr,caller_context_t * ct)2320da6c28aaSamw vnext_readlink(femarg_t *vf, uio_t *uiop, cred_t *cr, caller_context_t *ct)
23217c478bd9Sstevel@tonic-gate {
23227c478bd9Sstevel@tonic-gate int (*func)() = NULL;
23237c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23247c478bd9Sstevel@tonic-gate
23257c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23267c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2327aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_readlink, femop_readlink);
23287c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23297c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2330da6c28aaSamw return ((*func)(arg0, uiop, cr, ct));
23317c478bd9Sstevel@tonic-gate }
23327c478bd9Sstevel@tonic-gate
23337c478bd9Sstevel@tonic-gate int
vnext_fsync(femarg_t * vf,int syncflag,cred_t * cr,caller_context_t * ct)2334da6c28aaSamw vnext_fsync(femarg_t *vf, int syncflag, cred_t *cr, caller_context_t *ct)
23357c478bd9Sstevel@tonic-gate {
23367c478bd9Sstevel@tonic-gate int (*func)() = NULL;
23377c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23387c478bd9Sstevel@tonic-gate
23397c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23407c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2341aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_fsync, femop_fsync);
23427c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23437c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2344da6c28aaSamw return ((*func)(arg0, syncflag, cr, ct));
23457c478bd9Sstevel@tonic-gate }
23467c478bd9Sstevel@tonic-gate
23477c478bd9Sstevel@tonic-gate void
vnext_inactive(femarg_t * vf,cred_t * cr,caller_context_t * ct)2348da6c28aaSamw vnext_inactive(femarg_t *vf, cred_t *cr, caller_context_t *ct)
23497c478bd9Sstevel@tonic-gate {
23507c478bd9Sstevel@tonic-gate void (*func)() = NULL;
23517c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23527c478bd9Sstevel@tonic-gate
23537c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23547c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2355aa59c4cbSrsb vsop_find(vf, &func, void, &arg0, vop_inactive, femop_inactive);
23567c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23577c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2358da6c28aaSamw (*func)(arg0, cr, ct);
23597c478bd9Sstevel@tonic-gate }
23607c478bd9Sstevel@tonic-gate
23617c478bd9Sstevel@tonic-gate int
vnext_fid(femarg_t * vf,fid_t * fidp,caller_context_t * ct)2362da6c28aaSamw vnext_fid(femarg_t *vf, fid_t *fidp, caller_context_t *ct)
23637c478bd9Sstevel@tonic-gate {
23647c478bd9Sstevel@tonic-gate int (*func)() = NULL;
23657c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23667c478bd9Sstevel@tonic-gate
23677c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23687c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2369aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_fid, femop_fid);
23707c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23717c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2372da6c28aaSamw return ((*func)(arg0, fidp, ct));
23737c478bd9Sstevel@tonic-gate }
23747c478bd9Sstevel@tonic-gate
23757c478bd9Sstevel@tonic-gate int
vnext_rwlock(femarg_t * vf,int write_lock,caller_context_t * ct)23767c478bd9Sstevel@tonic-gate vnext_rwlock(femarg_t *vf, int write_lock, caller_context_t *ct)
23777c478bd9Sstevel@tonic-gate {
23787c478bd9Sstevel@tonic-gate int (*func)() = NULL;
23797c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23807c478bd9Sstevel@tonic-gate
23817c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23827c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2383aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_rwlock, femop_rwlock);
23847c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23857c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
23867c478bd9Sstevel@tonic-gate return ((*func)(arg0, write_lock, ct));
23877c478bd9Sstevel@tonic-gate }
23887c478bd9Sstevel@tonic-gate
23897c478bd9Sstevel@tonic-gate void
vnext_rwunlock(femarg_t * vf,int write_lock,caller_context_t * ct)23907c478bd9Sstevel@tonic-gate vnext_rwunlock(femarg_t *vf, int write_lock, caller_context_t *ct)
23917c478bd9Sstevel@tonic-gate {
23927c478bd9Sstevel@tonic-gate void (*func)() = NULL;
23937c478bd9Sstevel@tonic-gate void *arg0 = NULL;
23947c478bd9Sstevel@tonic-gate
23957c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
23967c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2397aa59c4cbSrsb vsop_find(vf, &func, void, &arg0, vop_rwunlock, femop_rwunlock);
23987c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
23997c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
24007c478bd9Sstevel@tonic-gate (*func)(arg0, write_lock, ct);
24017c478bd9Sstevel@tonic-gate }
24027c478bd9Sstevel@tonic-gate
24037c478bd9Sstevel@tonic-gate int
vnext_seek(femarg_t * vf,offset_t ooff,offset_t * noffp,caller_context_t * ct)2404da6c28aaSamw vnext_seek(femarg_t *vf, offset_t ooff, offset_t *noffp, caller_context_t *ct)
24057c478bd9Sstevel@tonic-gate {
24067c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24077c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24087c478bd9Sstevel@tonic-gate
24097c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24107c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2411aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_seek, femop_seek);
24127c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24137c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2414da6c28aaSamw return ((*func)(arg0, ooff, noffp, ct));
24157c478bd9Sstevel@tonic-gate }
24167c478bd9Sstevel@tonic-gate
24177c478bd9Sstevel@tonic-gate int
vnext_cmp(femarg_t * vf,vnode_t * vp2,caller_context_t * ct)2418da6c28aaSamw vnext_cmp(femarg_t *vf, vnode_t *vp2, caller_context_t *ct)
24197c478bd9Sstevel@tonic-gate {
24207c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24217c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24227c478bd9Sstevel@tonic-gate
24237c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24247c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2425aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_cmp, femop_cmp);
24267c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24277c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2428da6c28aaSamw return ((*func)(arg0, vp2, ct));
24297c478bd9Sstevel@tonic-gate }
24307c478bd9Sstevel@tonic-gate
24317c478bd9Sstevel@tonic-gate int
vnext_frlock(femarg_t * vf,int cmd,struct flock64 * bfp,int flag,offset_t offset,struct flk_callback * flk_cbp,cred_t * cr,caller_context_t * ct)24327c478bd9Sstevel@tonic-gate vnext_frlock(femarg_t *vf, int cmd, struct flock64 *bfp, int flag,
2433b1659ed9SToomas Soome offset_t offset, struct flk_callback *flk_cbp, cred_t *cr,
2434b1659ed9SToomas Soome caller_context_t *ct)
24357c478bd9Sstevel@tonic-gate {
24367c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24377c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24387c478bd9Sstevel@tonic-gate
24397c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24407c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2441aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_frlock, femop_frlock);
24427c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24437c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2444da6c28aaSamw return ((*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr, ct));
24457c478bd9Sstevel@tonic-gate }
24467c478bd9Sstevel@tonic-gate
24477c478bd9Sstevel@tonic-gate int
vnext_space(femarg_t * vf,int cmd,struct flock64 * bfp,int flag,offset_t offset,cred_t * cr,caller_context_t * ct)24487c478bd9Sstevel@tonic-gate vnext_space(femarg_t *vf, int cmd, struct flock64 *bfp, int flag,
2449b1659ed9SToomas Soome offset_t offset, cred_t *cr, caller_context_t *ct)
24507c478bd9Sstevel@tonic-gate {
24517c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24527c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24537c478bd9Sstevel@tonic-gate
24547c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24557c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2456aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_space, femop_space);
24577c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24587c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
24597c478bd9Sstevel@tonic-gate return ((*func)(arg0, cmd, bfp, flag, offset, cr, ct));
24607c478bd9Sstevel@tonic-gate }
24617c478bd9Sstevel@tonic-gate
24627c478bd9Sstevel@tonic-gate int
vnext_realvp(femarg_t * vf,vnode_t ** vpp,caller_context_t * ct)2463da6c28aaSamw vnext_realvp(femarg_t *vf, vnode_t **vpp, caller_context_t *ct)
24647c478bd9Sstevel@tonic-gate {
24657c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24667c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24677c478bd9Sstevel@tonic-gate
24687c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24697c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2470aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_realvp, femop_realvp);
24717c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24727c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2473da6c28aaSamw return ((*func)(arg0, vpp, ct));
24747c478bd9Sstevel@tonic-gate }
24757c478bd9Sstevel@tonic-gate
24767c478bd9Sstevel@tonic-gate int
vnext_getpage(femarg_t * vf,offset_t off,size_t len,uint_t * protp,struct page ** plarr,size_t plsz,struct seg * seg,caddr_t addr,enum seg_rw rw,cred_t * cr,caller_context_t * ct)24777c478bd9Sstevel@tonic-gate vnext_getpage(femarg_t *vf, offset_t off, size_t len, uint_t *protp,
2478b1659ed9SToomas Soome struct page **plarr, size_t plsz, struct seg *seg, caddr_t addr,
2479b1659ed9SToomas Soome enum seg_rw rw, cred_t *cr, caller_context_t *ct)
24807c478bd9Sstevel@tonic-gate {
24817c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24827c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24837c478bd9Sstevel@tonic-gate
24847c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
24857c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2486aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_getpage, femop_getpage);
24877c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
24887c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
24897c478bd9Sstevel@tonic-gate return ((*func)(arg0, off, len, protp, plarr, plsz, seg, addr, rw,
2490d7334e51Srm cr, ct));
24917c478bd9Sstevel@tonic-gate }
24927c478bd9Sstevel@tonic-gate
24937c478bd9Sstevel@tonic-gate int
vnext_putpage(femarg_t * vf,offset_t off,size_t len,int flags,cred_t * cr,caller_context_t * ct)24947c478bd9Sstevel@tonic-gate vnext_putpage(femarg_t *vf, offset_t off, size_t len, int flags,
2495b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
24967c478bd9Sstevel@tonic-gate {
24977c478bd9Sstevel@tonic-gate int (*func)() = NULL;
24987c478bd9Sstevel@tonic-gate void *arg0 = NULL;
24997c478bd9Sstevel@tonic-gate
25007c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25017c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2502aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_putpage, femop_putpage);
25037c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25047c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2505da6c28aaSamw return ((*func)(arg0, off, len, flags, cr, ct));
25067c478bd9Sstevel@tonic-gate }
25077c478bd9Sstevel@tonic-gate
25087c478bd9Sstevel@tonic-gate int
vnext_map(femarg_t * vf,offset_t off,struct as * as,caddr_t * addrp,size_t len,uchar_t prot,uchar_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)25097c478bd9Sstevel@tonic-gate vnext_map(femarg_t *vf, offset_t off, struct as *as, caddr_t *addrp,
2510b1659ed9SToomas Soome size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
2511b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
25127c478bd9Sstevel@tonic-gate {
25137c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25147c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25157c478bd9Sstevel@tonic-gate
25167c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25177c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2518aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_map, femop_map);
25197c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25207c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
25217c478bd9Sstevel@tonic-gate return ((*func)(arg0, off, as, addrp, len, prot, maxprot, flags,
2522d7334e51Srm cr, ct));
25237c478bd9Sstevel@tonic-gate }
25247c478bd9Sstevel@tonic-gate
25257c478bd9Sstevel@tonic-gate int
vnext_addmap(femarg_t * vf,offset_t off,struct as * as,caddr_t addr,size_t len,uchar_t prot,uchar_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)25267c478bd9Sstevel@tonic-gate vnext_addmap(femarg_t *vf, offset_t off, struct as *as, caddr_t addr,
2527b1659ed9SToomas Soome size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
2528b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
25297c478bd9Sstevel@tonic-gate {
25307c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25317c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25327c478bd9Sstevel@tonic-gate
25337c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25347c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2535aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_addmap, femop_addmap);
25367c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25377c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2538da6c28aaSamw return ((*func)(arg0, off, as, addr, len, prot, maxprot, flags,
2539d7334e51Srm cr, ct));
25407c478bd9Sstevel@tonic-gate }
25417c478bd9Sstevel@tonic-gate
25427c478bd9Sstevel@tonic-gate int
vnext_delmap(femarg_t * vf,offset_t off,struct as * as,caddr_t addr,size_t len,uint_t prot,uint_t maxprot,uint_t flags,cred_t * cr,caller_context_t * ct)25437c478bd9Sstevel@tonic-gate vnext_delmap(femarg_t *vf, offset_t off, struct as *as, caddr_t addr,
2544b1659ed9SToomas Soome size_t len, uint_t prot, uint_t maxprot, uint_t flags,
2545b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
25467c478bd9Sstevel@tonic-gate {
25477c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25487c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25497c478bd9Sstevel@tonic-gate
25507c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25517c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2552aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_delmap, femop_delmap);
25537c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25547c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2555da6c28aaSamw return ((*func)(arg0, off, as, addr, len, prot, maxprot, flags,
2556d7334e51Srm cr, ct));
25577c478bd9Sstevel@tonic-gate }
25587c478bd9Sstevel@tonic-gate
25597c478bd9Sstevel@tonic-gate int
vnext_poll(femarg_t * vf,short events,int anyyet,short * reventsp,struct pollhead ** phpp,caller_context_t * ct)25607c478bd9Sstevel@tonic-gate vnext_poll(femarg_t *vf, short events, int anyyet, short *reventsp,
2561b1659ed9SToomas Soome struct pollhead **phpp, caller_context_t *ct)
25627c478bd9Sstevel@tonic-gate {
25637c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25647c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25657c478bd9Sstevel@tonic-gate
25667c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25677c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2568aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_poll, femop_poll);
25697c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25707c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2571da6c28aaSamw return ((*func)(arg0, events, anyyet, reventsp, phpp, ct));
25727c478bd9Sstevel@tonic-gate }
25737c478bd9Sstevel@tonic-gate
25747c478bd9Sstevel@tonic-gate int
vnext_dump(femarg_t * vf,caddr_t addr,offset_t lbdn,offset_t dblks,caller_context_t * ct)2575d7334e51Srm vnext_dump(femarg_t *vf, caddr_t addr, offset_t lbdn, offset_t dblks,
2576b1659ed9SToomas Soome caller_context_t *ct)
25777c478bd9Sstevel@tonic-gate {
25787c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25797c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25807c478bd9Sstevel@tonic-gate
25817c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25827c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2583aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_dump, femop_dump);
25847c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
25857c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2586da6c28aaSamw return ((*func)(arg0, addr, lbdn, dblks, ct));
25877c478bd9Sstevel@tonic-gate }
25887c478bd9Sstevel@tonic-gate
25897c478bd9Sstevel@tonic-gate int
vnext_pathconf(femarg_t * vf,int cmd,ulong_t * valp,cred_t * cr,caller_context_t * ct)2590da6c28aaSamw vnext_pathconf(femarg_t *vf, int cmd, ulong_t *valp, cred_t *cr,
2591b1659ed9SToomas Soome caller_context_t *ct)
25927c478bd9Sstevel@tonic-gate {
25937c478bd9Sstevel@tonic-gate int (*func)() = NULL;
25947c478bd9Sstevel@tonic-gate void *arg0 = NULL;
25957c478bd9Sstevel@tonic-gate
25967c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
25977c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2598aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_pathconf, femop_pathconf);
25997c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26007c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2601da6c28aaSamw return ((*func)(arg0, cmd, valp, cr, ct));
26027c478bd9Sstevel@tonic-gate }
26037c478bd9Sstevel@tonic-gate
26047c478bd9Sstevel@tonic-gate int
vnext_pageio(femarg_t * vf,struct page * pp,u_offset_t io_off,size_t io_len,int flags,cred_t * cr,caller_context_t * ct)26057c478bd9Sstevel@tonic-gate vnext_pageio(femarg_t *vf, struct page *pp, u_offset_t io_off,
2606b1659ed9SToomas Soome size_t io_len, int flags, cred_t *cr, caller_context_t *ct)
26077c478bd9Sstevel@tonic-gate {
26087c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26097c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26107c478bd9Sstevel@tonic-gate
26117c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26127c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2613aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_pageio, femop_pageio);
26147c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26157c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2616da6c28aaSamw return ((*func)(arg0, pp, io_off, io_len, flags, cr, ct));
26177c478bd9Sstevel@tonic-gate }
26187c478bd9Sstevel@tonic-gate
26197c478bd9Sstevel@tonic-gate int
vnext_dumpctl(femarg_t * vf,int action,offset_t * blkp,caller_context_t * ct)2620d7334e51Srm vnext_dumpctl(femarg_t *vf, int action, offset_t *blkp, caller_context_t *ct)
26217c478bd9Sstevel@tonic-gate {
26227c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26237c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26247c478bd9Sstevel@tonic-gate
26257c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26267c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2627aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_dumpctl, femop_dumpctl);
26287c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26297c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2630da6c28aaSamw return ((*func)(arg0, action, blkp, ct));
26317c478bd9Sstevel@tonic-gate }
26327c478bd9Sstevel@tonic-gate
26337c478bd9Sstevel@tonic-gate void
vnext_dispose(femarg_t * vf,struct page * pp,int flag,int dn,cred_t * cr,caller_context_t * ct)2634da6c28aaSamw vnext_dispose(femarg_t *vf, struct page *pp, int flag, int dn, cred_t *cr,
2635b1659ed9SToomas Soome caller_context_t *ct)
26367c478bd9Sstevel@tonic-gate {
26377c478bd9Sstevel@tonic-gate void (*func)() = NULL;
26387c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26397c478bd9Sstevel@tonic-gate
26407c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26417c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2642aa59c4cbSrsb vsop_find(vf, &func, void, &arg0, vop_dispose, femop_dispose);
26437c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26447c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2645da6c28aaSamw (*func)(arg0, pp, flag, dn, cr, ct);
26467c478bd9Sstevel@tonic-gate }
26477c478bd9Sstevel@tonic-gate
26487c478bd9Sstevel@tonic-gate int
vnext_setsecattr(femarg_t * vf,vsecattr_t * vsap,int flag,cred_t * cr,caller_context_t * ct)2649da6c28aaSamw vnext_setsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, cred_t *cr,
2650b1659ed9SToomas Soome caller_context_t *ct)
26517c478bd9Sstevel@tonic-gate {
26527c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26537c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26547c478bd9Sstevel@tonic-gate
26557c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26567c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2657aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_setsecattr, femop_setsecattr);
26587c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26597c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2660da6c28aaSamw return ((*func)(arg0, vsap, flag, cr, ct));
26617c478bd9Sstevel@tonic-gate }
26627c478bd9Sstevel@tonic-gate
26637c478bd9Sstevel@tonic-gate int
vnext_getsecattr(femarg_t * vf,vsecattr_t * vsap,int flag,cred_t * cr,caller_context_t * ct)2664da6c28aaSamw vnext_getsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, cred_t *cr,
2665b1659ed9SToomas Soome caller_context_t *ct)
26667c478bd9Sstevel@tonic-gate {
26677c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26687c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26697c478bd9Sstevel@tonic-gate
26707c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26717c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2672aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_getsecattr, femop_getsecattr);
26737c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26747c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2675da6c28aaSamw return ((*func)(arg0, vsap, flag, cr, ct));
26767c478bd9Sstevel@tonic-gate }
26777c478bd9Sstevel@tonic-gate
26787c478bd9Sstevel@tonic-gate int
vnext_shrlock(femarg_t * vf,int cmd,struct shrlock * shr,int flag,cred_t * cr,caller_context_t * ct)26797c478bd9Sstevel@tonic-gate vnext_shrlock(femarg_t *vf, int cmd, struct shrlock *shr, int flag,
2680b1659ed9SToomas Soome cred_t *cr, caller_context_t *ct)
26817c478bd9Sstevel@tonic-gate {
26827c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26837c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26847c478bd9Sstevel@tonic-gate
26857c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
26867c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2687aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_shrlock, femop_shrlock);
26887c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
26897c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2690da6c28aaSamw return ((*func)(arg0, cmd, shr, flag, cr, ct));
26917c478bd9Sstevel@tonic-gate }
26927c478bd9Sstevel@tonic-gate
26937c478bd9Sstevel@tonic-gate int
vnext_vnevent(femarg_t * vf,vnevent_t vnevent,vnode_t * dvp,char * cname,caller_context_t * ct)2694da6c28aaSamw vnext_vnevent(femarg_t *vf, vnevent_t vnevent, vnode_t *dvp, char *cname,
2695da6c28aaSamw caller_context_t *ct)
26967c478bd9Sstevel@tonic-gate {
26977c478bd9Sstevel@tonic-gate int (*func)() = NULL;
26987c478bd9Sstevel@tonic-gate void *arg0 = NULL;
26997c478bd9Sstevel@tonic-gate
27007c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
27017c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2702aa59c4cbSrsb vsop_find(vf, &func, int, &arg0, vop_vnevent, femop_vnevent);
27037c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
27047c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
2705da6c28aaSamw return ((*func)(arg0, vnevent, dvp, cname, ct));
27067c478bd9Sstevel@tonic-gate }
27077c478bd9Sstevel@tonic-gate
2708c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int
vnext_reqzcbuf(femarg_t * vf,enum uio_rw ioflag,xuio_t * xuiop,cred_t * cr,caller_context_t * ct)2709c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vnext_reqzcbuf(femarg_t *vf, enum uio_rw ioflag, xuio_t *xuiop, cred_t *cr,
2710c242f9a0Schunli zhang - Sun Microsystems - Irvine United States caller_context_t *ct)
2711c242f9a0Schunli zhang - Sun Microsystems - Irvine United States {
2712c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int (*func)() = NULL;
2713c242f9a0Schunli zhang - Sun Microsystems - Irvine United States void *arg0 = NULL;
2714c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
2715c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(vf != NULL);
2716c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vf->fa_fnode--;
2717c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vsop_find(vf, &func, int, &arg0, vop_reqzcbuf, femop_reqzcbuf);
2718c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(func != NULL);
2719c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(arg0 != NULL);
2720c242f9a0Schunli zhang - Sun Microsystems - Irvine United States return ((*func)(arg0, ioflag, xuiop, cr, ct));
2721c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
2722c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
2723c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int
vnext_retzcbuf(femarg_t * vf,xuio_t * xuiop,cred_t * cr,caller_context_t * ct)2724c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vnext_retzcbuf(femarg_t *vf, xuio_t *xuiop, cred_t *cr, caller_context_t *ct)
2725c242f9a0Schunli zhang - Sun Microsystems - Irvine United States {
2726c242f9a0Schunli zhang - Sun Microsystems - Irvine United States int (*func)() = NULL;
2727c242f9a0Schunli zhang - Sun Microsystems - Irvine United States void *arg0 = NULL;
2728c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
2729c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(vf != NULL);
2730c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vf->fa_fnode--;
2731c242f9a0Schunli zhang - Sun Microsystems - Irvine United States vsop_find(vf, &func, int, &arg0, vop_retzcbuf, femop_retzcbuf);
2732c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(func != NULL);
2733c242f9a0Schunli zhang - Sun Microsystems - Irvine United States ASSERT(arg0 != NULL);
2734c242f9a0Schunli zhang - Sun Microsystems - Irvine United States return ((*func)(arg0, xuiop, cr, ct));
2735c242f9a0Schunli zhang - Sun Microsystems - Irvine United States }
2736c242f9a0Schunli zhang - Sun Microsystems - Irvine United States
27377c478bd9Sstevel@tonic-gate int
vfsnext_mount(fsemarg_t * vf,vnode_t * mvp,struct mounta * uap,cred_t * cr)27387c478bd9Sstevel@tonic-gate vfsnext_mount(fsemarg_t *vf, vnode_t *mvp, struct mounta *uap, cred_t *cr)
27397c478bd9Sstevel@tonic-gate {
27407c478bd9Sstevel@tonic-gate int (*func)() = NULL;
27417c478bd9Sstevel@tonic-gate void *arg0 = NULL;
27427c478bd9Sstevel@tonic-gate
27437c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
27447c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2745aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_mount, fsemop_mount);
27467c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
27477c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
27487c478bd9Sstevel@tonic-gate return ((*func)(arg0, mvp, uap, cr));
27497c478bd9Sstevel@tonic-gate }
27507c478bd9Sstevel@tonic-gate
27517c478bd9Sstevel@tonic-gate int
vfsnext_unmount(fsemarg_t * vf,int flag,cred_t * cr)27527c478bd9Sstevel@tonic-gate vfsnext_unmount(fsemarg_t *vf, int flag, cred_t *cr)
27537c478bd9Sstevel@tonic-gate {
27547c478bd9Sstevel@tonic-gate int (*func)() = NULL;
27557c478bd9Sstevel@tonic-gate void *arg0 = NULL;
27567c478bd9Sstevel@tonic-gate
27577c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
27587c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2759aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_unmount, fsemop_unmount);
27607c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
27617c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
27627c478bd9Sstevel@tonic-gate return ((*func)(arg0, flag, cr));
27637c478bd9Sstevel@tonic-gate }
27647c478bd9Sstevel@tonic-gate
27657c478bd9Sstevel@tonic-gate int
vfsnext_root(fsemarg_t * vf,vnode_t ** vpp)27667c478bd9Sstevel@tonic-gate vfsnext_root(fsemarg_t *vf, vnode_t **vpp)
27677c478bd9Sstevel@tonic-gate {
27687c478bd9Sstevel@tonic-gate int (*func)() = NULL;
27697c478bd9Sstevel@tonic-gate void *arg0 = NULL;
27707c478bd9Sstevel@tonic-gate
27717c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
27727c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2773aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_root, fsemop_root);
27747c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
27757c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
27767c478bd9Sstevel@tonic-gate return ((*func)(arg0, vpp));
27777c478bd9Sstevel@tonic-gate }
27787c478bd9Sstevel@tonic-gate
27797c478bd9Sstevel@tonic-gate int
vfsnext_statvfs(fsemarg_t * vf,statvfs64_t * sp)27807c478bd9Sstevel@tonic-gate vfsnext_statvfs(fsemarg_t *vf, statvfs64_t *sp)
27817c478bd9Sstevel@tonic-gate {
27827c478bd9Sstevel@tonic-gate int (*func)() = NULL;
27837c478bd9Sstevel@tonic-gate void *arg0 = NULL;
27847c478bd9Sstevel@tonic-gate
27857c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
27867c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2787aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_statvfs, fsemop_statvfs);
27887c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
27897c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
27907c478bd9Sstevel@tonic-gate return ((*func)(arg0, sp));
27917c478bd9Sstevel@tonic-gate }
27927c478bd9Sstevel@tonic-gate
27937c478bd9Sstevel@tonic-gate int
vfsnext_sync(fsemarg_t * vf,short flag,cred_t * cr)27947c478bd9Sstevel@tonic-gate vfsnext_sync(fsemarg_t *vf, short flag, cred_t *cr)
27957c478bd9Sstevel@tonic-gate {
27967c478bd9Sstevel@tonic-gate int (*func)() = NULL;
27977c478bd9Sstevel@tonic-gate void *arg0 = NULL;
27987c478bd9Sstevel@tonic-gate
27997c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
28007c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2801aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_sync, fsemop_sync);
28027c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
28037c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
28047c478bd9Sstevel@tonic-gate return ((*func)(arg0, flag, cr));
28057c478bd9Sstevel@tonic-gate }
28067c478bd9Sstevel@tonic-gate
28077c478bd9Sstevel@tonic-gate int
vfsnext_vget(fsemarg_t * vf,vnode_t ** vpp,fid_t * fidp)28087c478bd9Sstevel@tonic-gate vfsnext_vget(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp)
28097c478bd9Sstevel@tonic-gate {
28107c478bd9Sstevel@tonic-gate int (*func)() = NULL;
28117c478bd9Sstevel@tonic-gate void *arg0 = NULL;
28127c478bd9Sstevel@tonic-gate
28137c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
28147c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2815aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_vget, fsemop_vget);
28167c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
28177c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
28187c478bd9Sstevel@tonic-gate return ((*func)(arg0, vpp, fidp));
28197c478bd9Sstevel@tonic-gate }
28207c478bd9Sstevel@tonic-gate
28217c478bd9Sstevel@tonic-gate int
vfsnext_mountroot(fsemarg_t * vf,enum whymountroot reason)28227c478bd9Sstevel@tonic-gate vfsnext_mountroot(fsemarg_t *vf, enum whymountroot reason)
28237c478bd9Sstevel@tonic-gate {
28247c478bd9Sstevel@tonic-gate int (*func)() = NULL;
28257c478bd9Sstevel@tonic-gate void *arg0 = NULL;
28267c478bd9Sstevel@tonic-gate
28277c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
28287c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2829aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_mountroot, fsemop_mountroot);
28307c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
28317c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
28327c478bd9Sstevel@tonic-gate return ((*func)(arg0, reason));
28337c478bd9Sstevel@tonic-gate }
28347c478bd9Sstevel@tonic-gate
28357c478bd9Sstevel@tonic-gate void
vfsnext_freevfs(fsemarg_t * vf)28367c478bd9Sstevel@tonic-gate vfsnext_freevfs(fsemarg_t *vf)
28377c478bd9Sstevel@tonic-gate {
28387c478bd9Sstevel@tonic-gate void (*func)() = NULL;
28397c478bd9Sstevel@tonic-gate void *arg0 = NULL;
28407c478bd9Sstevel@tonic-gate
28417c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
28427c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2843aa59c4cbSrsb vfsop_find(vf, &func, void, &arg0, vfs_freevfs, fsemop_freevfs);
28447c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
28457c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
28467c478bd9Sstevel@tonic-gate (*func)(arg0);
28477c478bd9Sstevel@tonic-gate }
28487c478bd9Sstevel@tonic-gate
28497c478bd9Sstevel@tonic-gate int
vfsnext_vnstate(fsemarg_t * vf,vnode_t * vp,vntrans_t nstate)28507c478bd9Sstevel@tonic-gate vfsnext_vnstate(fsemarg_t *vf, vnode_t *vp, vntrans_t nstate)
28517c478bd9Sstevel@tonic-gate {
28527c478bd9Sstevel@tonic-gate int (*func)() = NULL;
28537c478bd9Sstevel@tonic-gate void *arg0 = NULL;
28547c478bd9Sstevel@tonic-gate
28557c478bd9Sstevel@tonic-gate ASSERT(vf != NULL);
28567c478bd9Sstevel@tonic-gate vf->fa_fnode--;
2857aa59c4cbSrsb vfsop_find(vf, &func, int, &arg0, vfs_vnstate, fsemop_vnstate);
28587c478bd9Sstevel@tonic-gate ASSERT(func != NULL);
28597c478bd9Sstevel@tonic-gate ASSERT(arg0 != NULL);
28607c478bd9Sstevel@tonic-gate return ((*func)(arg0, vp, nstate));
28617c478bd9Sstevel@tonic-gate }
28627c478bd9Sstevel@tonic-gate
28637c478bd9Sstevel@tonic-gate
28647c478bd9Sstevel@tonic-gate /*
28657c478bd9Sstevel@tonic-gate * Create a new fem_head and associate with the vnode.
28667c478bd9Sstevel@tonic-gate * To keep the unaugmented vnode access path lock free, we spin
28677c478bd9Sstevel@tonic-gate * update this - create a new one, then try and install it. If
28687c478bd9Sstevel@tonic-gate * we fail to install, release the old one and pretend we succeeded.
28697c478bd9Sstevel@tonic-gate */
28707c478bd9Sstevel@tonic-gate
28717c478bd9Sstevel@tonic-gate static struct fem_head *
new_femhead(struct fem_head ** hp)28727c478bd9Sstevel@tonic-gate new_femhead(struct fem_head **hp)
28737c478bd9Sstevel@tonic-gate {
28747c478bd9Sstevel@tonic-gate struct fem_head *head;
28757c478bd9Sstevel@tonic-gate
28767c478bd9Sstevel@tonic-gate head = kmem_alloc(sizeof (*head), KM_SLEEP);
28777c478bd9Sstevel@tonic-gate mutex_init(&head->femh_lock, NULL, MUTEX_DEFAULT, NULL);
28787c478bd9Sstevel@tonic-gate head->femh_list = NULL;
287975d94465SJosef 'Jeff' Sipek if (atomic_cas_ptr(hp, NULL, head) != NULL) {
28807c478bd9Sstevel@tonic-gate kmem_free(head, sizeof (*head));
28817c478bd9Sstevel@tonic-gate head = *hp;
28827c478bd9Sstevel@tonic-gate }
28837c478bd9Sstevel@tonic-gate return (head);
28847c478bd9Sstevel@tonic-gate }
28857c478bd9Sstevel@tonic-gate
28867c478bd9Sstevel@tonic-gate /*
28877c478bd9Sstevel@tonic-gate * Create a fem_list. The fem_list that gets returned is in a
28887c478bd9Sstevel@tonic-gate * very rudimentary state and MUST NOT be used until it's initialized
28897c478bd9Sstevel@tonic-gate * (usually by femlist_construct() or fem_dup_list()). The refcount
28907c478bd9Sstevel@tonic-gate * and size is set properly and top-of-stack is set to the "guard" node
28917c478bd9Sstevel@tonic-gate * just to be consistent.
28927c478bd9Sstevel@tonic-gate *
28937c478bd9Sstevel@tonic-gate * If anyone were to accidentally trying to run on this fem_list before
28947c478bd9Sstevel@tonic-gate * it's initialized then the system would likely panic trying to defererence
28957c478bd9Sstevel@tonic-gate * the (NULL) fn_op pointer.
28967c478bd9Sstevel@tonic-gate *
28977c478bd9Sstevel@tonic-gate */
28987c478bd9Sstevel@tonic-gate static struct fem_list *
femlist_create(int numnodes)28997c478bd9Sstevel@tonic-gate femlist_create(int numnodes)
29007c478bd9Sstevel@tonic-gate {
29017c478bd9Sstevel@tonic-gate struct fem_list *sp;
29027c478bd9Sstevel@tonic-gate
29037c478bd9Sstevel@tonic-gate sp = kmem_alloc(fl_ntob(numnodes), KM_SLEEP);
29047c478bd9Sstevel@tonic-gate sp->feml_refc = 1;
29057c478bd9Sstevel@tonic-gate sp->feml_ssize = numnodes;
29067c478bd9Sstevel@tonic-gate sp->feml_nodes[0] = FEM_GUARD(FEMTYPE_NULL);
29077c478bd9Sstevel@tonic-gate sp->feml_tos = 0;
29087c478bd9Sstevel@tonic-gate return (sp);
29097c478bd9Sstevel@tonic-gate }
29107c478bd9Sstevel@tonic-gate
29117c478bd9Sstevel@tonic-gate /*
29127c478bd9Sstevel@tonic-gate * Construct a new femlist.
29137c478bd9Sstevel@tonic-gate * The list is constructed with the appropriate type of guard to
29147c478bd9Sstevel@tonic-gate * anchor it, and inserts the original ops.
29157c478bd9Sstevel@tonic-gate */
29167c478bd9Sstevel@tonic-gate
29177c478bd9Sstevel@tonic-gate static struct fem_list *
femlist_construct(void * baseops,int type,int numnodes)29187c478bd9Sstevel@tonic-gate femlist_construct(void *baseops, int type, int numnodes)
29197c478bd9Sstevel@tonic-gate {
29207c478bd9Sstevel@tonic-gate struct fem_list *sp;
29217c478bd9Sstevel@tonic-gate
29227c478bd9Sstevel@tonic-gate sp = femlist_create(numnodes);
29237c478bd9Sstevel@tonic-gate sp->feml_nodes[0] = FEM_GUARD(type);
29247c478bd9Sstevel@tonic-gate sp->feml_nodes[1].fn_op.anon = baseops;
29257c478bd9Sstevel@tonic-gate sp->feml_nodes[1].fn_available = NULL;
29267c478bd9Sstevel@tonic-gate sp->feml_nodes[1].fn_av_hold = NULL;
29277c478bd9Sstevel@tonic-gate sp->feml_nodes[1].fn_av_rele = NULL;
29287c478bd9Sstevel@tonic-gate sp->feml_tos = 1;
29297c478bd9Sstevel@tonic-gate return (sp);
29307c478bd9Sstevel@tonic-gate }
29317c478bd9Sstevel@tonic-gate
29327c478bd9Sstevel@tonic-gate /*
29337c478bd9Sstevel@tonic-gate * Duplicate a list. Copy the original list to the clone.
29347c478bd9Sstevel@tonic-gate *
29357c478bd9Sstevel@tonic-gate * NOTE: The caller must have the fem_head for the lists locked.
29367c478bd9Sstevel@tonic-gate * Assuming the appropriate lock is held and the caller has done the
29377c478bd9Sstevel@tonic-gate * math right, the clone list should be big enough to old the original.
29387c478bd9Sstevel@tonic-gate */
29397c478bd9Sstevel@tonic-gate
29407c478bd9Sstevel@tonic-gate static void
fem_dup_list(struct fem_list * orig,struct fem_list * clone)29417c478bd9Sstevel@tonic-gate fem_dup_list(struct fem_list *orig, struct fem_list *clone)
29427c478bd9Sstevel@tonic-gate {
29437c478bd9Sstevel@tonic-gate int i;
29447c478bd9Sstevel@tonic-gate
29457c478bd9Sstevel@tonic-gate ASSERT(clone->feml_ssize >= orig->feml_ssize);
29467c478bd9Sstevel@tonic-gate
29477c478bd9Sstevel@tonic-gate bcopy(orig->feml_nodes, clone->feml_nodes,
2948d7334e51Srm sizeof (orig->feml_nodes[0]) * orig->feml_ssize);
29497c478bd9Sstevel@tonic-gate clone->feml_tos = orig->feml_tos;
29507c478bd9Sstevel@tonic-gate /*
29517c478bd9Sstevel@tonic-gate * Now that we've copied the old list (orig) to the new list (clone),
29527c478bd9Sstevel@tonic-gate * we need to walk the new list and put another hold on fn_available.
29537c478bd9Sstevel@tonic-gate */
29547c478bd9Sstevel@tonic-gate for (i = clone->feml_tos; i > 0; i--) {
29557c478bd9Sstevel@tonic-gate struct fem_node *fnp = &clone->feml_nodes[i];
29567c478bd9Sstevel@tonic-gate
29577c478bd9Sstevel@tonic-gate if (fnp->fn_av_hold)
29587c478bd9Sstevel@tonic-gate (*(fnp->fn_av_hold))(fnp->fn_available);
29597c478bd9Sstevel@tonic-gate }
29607c478bd9Sstevel@tonic-gate }
29617c478bd9Sstevel@tonic-gate
29627c478bd9Sstevel@tonic-gate
29637c478bd9Sstevel@tonic-gate static int
fem_push_node(struct fem_head ** hp,void ** baseops,int type,struct fem_node * nnode,femhow_t how)29647c478bd9Sstevel@tonic-gate fem_push_node(
2965b1659ed9SToomas Soome struct fem_head **hp,
2966b1659ed9SToomas Soome void **baseops,
2967b1659ed9SToomas Soome int type,
2968b1659ed9SToomas Soome struct fem_node *nnode,
2969b1659ed9SToomas Soome femhow_t how)
29707c478bd9Sstevel@tonic-gate {
29717c478bd9Sstevel@tonic-gate struct fem_head *hd;
29727c478bd9Sstevel@tonic-gate struct fem_list *list;
29737c478bd9Sstevel@tonic-gate void *oldops;
29747c478bd9Sstevel@tonic-gate int retry;
29757c478bd9Sstevel@tonic-gate int error = 0;
29767c478bd9Sstevel@tonic-gate int i;
29777c478bd9Sstevel@tonic-gate
29787c478bd9Sstevel@tonic-gate /* Validate the node */
29797c478bd9Sstevel@tonic-gate if ((nnode->fn_op.anon == NULL) || (nnode->fn_available == NULL)) {
29807c478bd9Sstevel@tonic-gate return (EINVAL);
29817c478bd9Sstevel@tonic-gate }
29827c478bd9Sstevel@tonic-gate
29837c478bd9Sstevel@tonic-gate if ((hd = *hp) == NULL) { /* construct a proto-list */
29847c478bd9Sstevel@tonic-gate hd = new_femhead(hp);
29857c478bd9Sstevel@tonic-gate }
29867c478bd9Sstevel@tonic-gate /*
29877c478bd9Sstevel@tonic-gate * RULE: once a femhead has been pushed onto a object, it cannot be
29887c478bd9Sstevel@tonic-gate * removed until the object is destroyed. It can be deactivated by
29897c478bd9Sstevel@tonic-gate * placing the original 'object operations' onto the object, which
29907c478bd9Sstevel@tonic-gate * will ignore the femhead.
29917c478bd9Sstevel@tonic-gate * The loop will exist when the femh_list has space to push a monitor
29927c478bd9Sstevel@tonic-gate * onto it.
29937c478bd9Sstevel@tonic-gate */
29947c478bd9Sstevel@tonic-gate do {
29957c478bd9Sstevel@tonic-gate retry = 1;
29967c478bd9Sstevel@tonic-gate list = fem_lock(hd);
29977c478bd9Sstevel@tonic-gate oldops = *baseops;
29987c478bd9Sstevel@tonic-gate
29997c478bd9Sstevel@tonic-gate if (list != NULL) {
30007c478bd9Sstevel@tonic-gate if (list->feml_tos+1 < list->feml_ssize) {
30017c478bd9Sstevel@tonic-gate retry = 0;
30027c478bd9Sstevel@tonic-gate } else {
30037c478bd9Sstevel@tonic-gate struct fem_list *olist = list;
30047c478bd9Sstevel@tonic-gate
30057c478bd9Sstevel@tonic-gate fem_addref(olist);
30067c478bd9Sstevel@tonic-gate fem_unlock(hd);
30077c478bd9Sstevel@tonic-gate list = femlist_create(olist->feml_ssize * 2);
30087c478bd9Sstevel@tonic-gate (void) fem_lock(hd);
30097c478bd9Sstevel@tonic-gate if (hd->femh_list == olist) {
30107c478bd9Sstevel@tonic-gate if (list->feml_ssize <=
3011d7334e51Srm olist->feml_ssize) {
30127c478bd9Sstevel@tonic-gate /*
30137c478bd9Sstevel@tonic-gate * We have a new list, but it
30147c478bd9Sstevel@tonic-gate * is too small to hold the
30157c478bd9Sstevel@tonic-gate * original contents plus the
30167c478bd9Sstevel@tonic-gate * one to push. Release the
30177c478bd9Sstevel@tonic-gate * new list and start over.
30187c478bd9Sstevel@tonic-gate */
30197c478bd9Sstevel@tonic-gate fem_release(list);
30207c478bd9Sstevel@tonic-gate fem_unlock(hd);
30217c478bd9Sstevel@tonic-gate } else {
30227c478bd9Sstevel@tonic-gate /*
30237c478bd9Sstevel@tonic-gate * Life is good: Our new list
30247c478bd9Sstevel@tonic-gate * is big enough to hold the
30257c478bd9Sstevel@tonic-gate * original list (olist) + 1.
30267c478bd9Sstevel@tonic-gate */
30277c478bd9Sstevel@tonic-gate fem_dup_list(olist, list);
30287c478bd9Sstevel@tonic-gate /* orphan this list */
30297c478bd9Sstevel@tonic-gate hd->femh_list = list;
3030677d097aSjwahlig (void) fem_delref(olist);
30317c478bd9Sstevel@tonic-gate retry = 0;
30327c478bd9Sstevel@tonic-gate }
30337c478bd9Sstevel@tonic-gate } else {
30347c478bd9Sstevel@tonic-gate /* concurrent update, retry */
30357c478bd9Sstevel@tonic-gate fem_release(list);
30367c478bd9Sstevel@tonic-gate fem_unlock(hd);
30377c478bd9Sstevel@tonic-gate }
30387c478bd9Sstevel@tonic-gate /* remove the reference we added above */
30397c478bd9Sstevel@tonic-gate fem_release(olist);
30407c478bd9Sstevel@tonic-gate }
30417c478bd9Sstevel@tonic-gate } else {
30427c478bd9Sstevel@tonic-gate fem_unlock(hd);
30437c478bd9Sstevel@tonic-gate list = femlist_construct(oldops, type, NNODES_DEFAULT);
30447c478bd9Sstevel@tonic-gate (void) fem_lock(hd);
30457c478bd9Sstevel@tonic-gate if (hd->femh_list != NULL || *baseops != oldops) {
30467c478bd9Sstevel@tonic-gate /* concurrent update, retry */
30477c478bd9Sstevel@tonic-gate fem_release(list);
30487c478bd9Sstevel@tonic-gate fem_unlock(hd);
30497c478bd9Sstevel@tonic-gate } else {
30507c478bd9Sstevel@tonic-gate hd->femh_list = list;
30517c478bd9Sstevel@tonic-gate *baseops = FEM_HEAD(type);
30527c478bd9Sstevel@tonic-gate retry = 0;
30537c478bd9Sstevel@tonic-gate }
30547c478bd9Sstevel@tonic-gate }
30557c478bd9Sstevel@tonic-gate } while (retry);
30567c478bd9Sstevel@tonic-gate
30577c478bd9Sstevel@tonic-gate ASSERT(mutex_owner(&hd->femh_lock) == curthread);
30587c478bd9Sstevel@tonic-gate ASSERT(list->feml_tos+1 < list->feml_ssize);
30597c478bd9Sstevel@tonic-gate
30607c478bd9Sstevel@tonic-gate /*
30617c478bd9Sstevel@tonic-gate * The presence of "how" will modify the behavior of how/if
30627c478bd9Sstevel@tonic-gate * nodes are pushed. If it's FORCE, then we can skip
30637c478bd9Sstevel@tonic-gate * all the checks and push it on.
30647c478bd9Sstevel@tonic-gate */
30657c478bd9Sstevel@tonic-gate if (how != FORCE) {
30667c478bd9Sstevel@tonic-gate /* Start at the top and work our way down */
30677c478bd9Sstevel@tonic-gate for (i = list->feml_tos; i > 0; i--) {
30687c478bd9Sstevel@tonic-gate void *fn_av = list->feml_nodes[i].fn_available;
30697c478bd9Sstevel@tonic-gate void *fn_op = list->feml_nodes[i].fn_op.anon;
30707c478bd9Sstevel@tonic-gate
30717c478bd9Sstevel@tonic-gate /*
30727c478bd9Sstevel@tonic-gate * OPARGUNIQ means that this node should not
30737c478bd9Sstevel@tonic-gate * be pushed on if a node with the same op/avail
30747c478bd9Sstevel@tonic-gate * combination exists. This situation returns
30757c478bd9Sstevel@tonic-gate * EBUSY.
30767c478bd9Sstevel@tonic-gate *
30777c478bd9Sstevel@tonic-gate * OPUNIQ means that this node should not be
30787c478bd9Sstevel@tonic-gate * pushed on if a node with the same op exists.
30797c478bd9Sstevel@tonic-gate * This situation also returns EBUSY.
30807c478bd9Sstevel@tonic-gate */
30817c478bd9Sstevel@tonic-gate switch (how) {
30827c478bd9Sstevel@tonic-gate
30837c478bd9Sstevel@tonic-gate case OPUNIQ:
30847c478bd9Sstevel@tonic-gate if (fn_op == nnode->fn_op.anon) {
30857c478bd9Sstevel@tonic-gate error = EBUSY;
30867c478bd9Sstevel@tonic-gate }
30877c478bd9Sstevel@tonic-gate break;
30887c478bd9Sstevel@tonic-gate
30897c478bd9Sstevel@tonic-gate case OPARGUNIQ:
30907c478bd9Sstevel@tonic-gate if ((fn_op == nnode->fn_op.anon) &&
30917c478bd9Sstevel@tonic-gate (fn_av == nnode->fn_available)) {
30927c478bd9Sstevel@tonic-gate error = EBUSY;
30937c478bd9Sstevel@tonic-gate }
30947c478bd9Sstevel@tonic-gate break;
30957c478bd9Sstevel@tonic-gate
30967c478bd9Sstevel@tonic-gate default:
30977c478bd9Sstevel@tonic-gate error = EINVAL; /* Unexpected value */
30987c478bd9Sstevel@tonic-gate break;
30997c478bd9Sstevel@tonic-gate }
31007c478bd9Sstevel@tonic-gate
31017c478bd9Sstevel@tonic-gate if (error)
31027c478bd9Sstevel@tonic-gate break;
31037c478bd9Sstevel@tonic-gate }
31047c478bd9Sstevel@tonic-gate }
31057c478bd9Sstevel@tonic-gate
31067c478bd9Sstevel@tonic-gate if (error == 0) {
31077c478bd9Sstevel@tonic-gate /*
31087c478bd9Sstevel@tonic-gate * If no errors, slap the node on the list.
31097c478bd9Sstevel@tonic-gate * Note: The following is a structure copy.
31107c478bd9Sstevel@tonic-gate */
31117c478bd9Sstevel@tonic-gate list->feml_nodes[++(list->feml_tos)] = *nnode;
31127c478bd9Sstevel@tonic-gate }
31137c478bd9Sstevel@tonic-gate
31147c478bd9Sstevel@tonic-gate fem_unlock(hd);
31157c478bd9Sstevel@tonic-gate return (error);
31167c478bd9Sstevel@tonic-gate }
31177c478bd9Sstevel@tonic-gate
31187c478bd9Sstevel@tonic-gate /*
31197c478bd9Sstevel@tonic-gate * Remove a node by copying the list above it down a notch.
31207c478bd9Sstevel@tonic-gate * If the list is busy, replace it with an idle one and work
31217c478bd9Sstevel@tonic-gate * upon it.
31227c478bd9Sstevel@tonic-gate * A node matches if the opset matches and the datap matches or is
31237c478bd9Sstevel@tonic-gate * null.
31247c478bd9Sstevel@tonic-gate */
31257c478bd9Sstevel@tonic-gate
31267c478bd9Sstevel@tonic-gate static int
remove_node(struct fem_list * sp,void ** baseops,void * opset,void * datap)31277c478bd9Sstevel@tonic-gate remove_node(struct fem_list *sp, void **baseops, void *opset, void *datap)
31287c478bd9Sstevel@tonic-gate {
31297c478bd9Sstevel@tonic-gate int i;
31307c478bd9Sstevel@tonic-gate struct fem_node *fn;
31317c478bd9Sstevel@tonic-gate
3132*c6f039c7SToomas Soome fn = NULL;
31337c478bd9Sstevel@tonic-gate for (i = sp->feml_tos; i > 0; i--) {
3134*c6f039c7SToomas Soome fn = sp->feml_nodes + i;
31357c478bd9Sstevel@tonic-gate if (fn->fn_op.anon == opset &&
31367c478bd9Sstevel@tonic-gate (fn->fn_available == datap || datap == NULL)) {
31377c478bd9Sstevel@tonic-gate break;
31387c478bd9Sstevel@tonic-gate }
31397c478bd9Sstevel@tonic-gate }
31407c478bd9Sstevel@tonic-gate if (i == 0) {
31417c478bd9Sstevel@tonic-gate return (EINVAL);
31427c478bd9Sstevel@tonic-gate }
31437c478bd9Sstevel@tonic-gate
31447c478bd9Sstevel@tonic-gate /*
31457c478bd9Sstevel@tonic-gate * At this point we have a node in-hand (*fn) that we are about
31467c478bd9Sstevel@tonic-gate * to remove by overwriting it and adjusting the stack. This is
31477c478bd9Sstevel@tonic-gate * our last chance to do anything with this node so we do the
31487c478bd9Sstevel@tonic-gate * release on the arg.
31497c478bd9Sstevel@tonic-gate */
31507c478bd9Sstevel@tonic-gate if (fn->fn_av_rele)
31517c478bd9Sstevel@tonic-gate (*(fn->fn_av_rele))(fn->fn_available);
31527c478bd9Sstevel@tonic-gate
31537c478bd9Sstevel@tonic-gate while (i++ < sp->feml_tos) {
31547c478bd9Sstevel@tonic-gate sp->feml_nodes[i-1] = sp->feml_nodes[i];
31557c478bd9Sstevel@tonic-gate }
31567c478bd9Sstevel@tonic-gate if (--(sp->feml_tos) == 1) { /* Empty, restore ops */
31577c478bd9Sstevel@tonic-gate *baseops = sp->feml_nodes[1].fn_op.anon;
31587c478bd9Sstevel@tonic-gate }
31597c478bd9Sstevel@tonic-gate return (0);
31607c478bd9Sstevel@tonic-gate }
31617c478bd9Sstevel@tonic-gate
31627c478bd9Sstevel@tonic-gate static int
fem_remove_node(struct fem_head * fh,void ** baseops,void * opset,void * datap)31637c478bd9Sstevel@tonic-gate fem_remove_node(struct fem_head *fh, void **baseops, void *opset, void *datap)
31647c478bd9Sstevel@tonic-gate {
31657c478bd9Sstevel@tonic-gate struct fem_list *sp;
3166de7d3445Sjwahlig int error = 0;
31677c478bd9Sstevel@tonic-gate int retry;
31687c478bd9Sstevel@tonic-gate
31697c478bd9Sstevel@tonic-gate if (fh == NULL) {
31707c478bd9Sstevel@tonic-gate return (EINVAL);
31717c478bd9Sstevel@tonic-gate }
31727c478bd9Sstevel@tonic-gate
31737c478bd9Sstevel@tonic-gate do {
31747c478bd9Sstevel@tonic-gate retry = 0;
31757c478bd9Sstevel@tonic-gate if ((sp = fem_lock(fh)) == NULL) {
31767c478bd9Sstevel@tonic-gate fem_unlock(fh);
31777c478bd9Sstevel@tonic-gate error = EINVAL;
31787c478bd9Sstevel@tonic-gate } else if (sp->feml_refc == 1) {
31797c478bd9Sstevel@tonic-gate error = remove_node(sp, baseops, opset, datap);
31807c478bd9Sstevel@tonic-gate if (sp->feml_tos == 1) {
31817c478bd9Sstevel@tonic-gate /*
31827c478bd9Sstevel@tonic-gate * The top-of-stack was decremented by
31837c478bd9Sstevel@tonic-gate * remove_node(). If it got down to 1,
31847c478bd9Sstevel@tonic-gate * then the base ops were replaced and we
31857c478bd9Sstevel@tonic-gate * call fem_release() which will free the
31867c478bd9Sstevel@tonic-gate * fem_list.
31877c478bd9Sstevel@tonic-gate */
31887c478bd9Sstevel@tonic-gate fem_release(sp);
31897c478bd9Sstevel@tonic-gate fh->femh_list = NULL;
31907c478bd9Sstevel@tonic-gate /* XXX - Do we need a membar_producer() call? */
31917c478bd9Sstevel@tonic-gate }
31927c478bd9Sstevel@tonic-gate fem_unlock(fh);
31937c478bd9Sstevel@tonic-gate } else {
31947c478bd9Sstevel@tonic-gate /* busy - install a new one without this monitor */
31957c478bd9Sstevel@tonic-gate struct fem_list *nsp; /* New fem_list being cloned */
31967c478bd9Sstevel@tonic-gate
31977c478bd9Sstevel@tonic-gate fem_addref(sp);
31987c478bd9Sstevel@tonic-gate fem_unlock(fh);
31997c478bd9Sstevel@tonic-gate nsp = femlist_create(sp->feml_ssize);
32007c478bd9Sstevel@tonic-gate if (fem_lock(fh) == sp) {
32017c478bd9Sstevel@tonic-gate /*
32027c478bd9Sstevel@tonic-gate * We popped out of the lock, created a
32037c478bd9Sstevel@tonic-gate * list, then relocked. If we're in here
32047c478bd9Sstevel@tonic-gate * then the fem_head points to the same list
32057c478bd9Sstevel@tonic-gate * it started with.
32067c478bd9Sstevel@tonic-gate */
32077c478bd9Sstevel@tonic-gate fem_dup_list(sp, nsp);
32087c478bd9Sstevel@tonic-gate error = remove_node(nsp, baseops, opset, datap);
32097c478bd9Sstevel@tonic-gate if (error != 0) {
32107c478bd9Sstevel@tonic-gate fem_release(nsp);
32117c478bd9Sstevel@tonic-gate } else if (nsp->feml_tos == 1) {
32127c478bd9Sstevel@tonic-gate /* New list now empty, tear it down */
32137c478bd9Sstevel@tonic-gate fem_release(nsp);
32147c478bd9Sstevel@tonic-gate fh->femh_list = NULL;
32157c478bd9Sstevel@tonic-gate } else {
32167c478bd9Sstevel@tonic-gate fh->femh_list = nsp;
32177c478bd9Sstevel@tonic-gate }
3218677d097aSjwahlig (void) fem_delref(sp);
32197c478bd9Sstevel@tonic-gate } else {
32207c478bd9Sstevel@tonic-gate /* List changed while locked, try again... */
32217c478bd9Sstevel@tonic-gate fem_release(nsp);
32227c478bd9Sstevel@tonic-gate retry = 1;
32237c478bd9Sstevel@tonic-gate }
3224de7d3445Sjwahlig /*
3225de7d3445Sjwahlig * If error is set, then we tried to remove a node
3226de7d3445Sjwahlig * from the list, but failed. This means that we
3227de7d3445Sjwahlig * will still be using this list so don't release it.
3228de7d3445Sjwahlig */
3229de7d3445Sjwahlig if (error == 0)
3230de7d3445Sjwahlig fem_release(sp);
32317c478bd9Sstevel@tonic-gate fem_unlock(fh);
32327c478bd9Sstevel@tonic-gate }
32337c478bd9Sstevel@tonic-gate } while (retry);
32347c478bd9Sstevel@tonic-gate return (error);
32357c478bd9Sstevel@tonic-gate }
32367c478bd9Sstevel@tonic-gate
32377c478bd9Sstevel@tonic-gate
32387c478bd9Sstevel@tonic-gate /*
32397c478bd9Sstevel@tonic-gate * perform operation on each element until one returns non zero
32407c478bd9Sstevel@tonic-gate */
32417c478bd9Sstevel@tonic-gate static int
fem_walk_list(struct fem_list * sp,int (* f)(struct fem_node *,void *,void *),void * mon,void * arg)32427c478bd9Sstevel@tonic-gate fem_walk_list(
3243b1659ed9SToomas Soome struct fem_list *sp,
3244b1659ed9SToomas Soome int (*f)(struct fem_node *, void *, void *),
3245b1659ed9SToomas Soome void *mon,
3246b1659ed9SToomas Soome void *arg)
32477c478bd9Sstevel@tonic-gate {
32487c478bd9Sstevel@tonic-gate int i;
32497c478bd9Sstevel@tonic-gate
32507c478bd9Sstevel@tonic-gate ASSERT(sp != NULL);
32517c478bd9Sstevel@tonic-gate for (i = sp->feml_tos; i > 0; i--) {
32527c478bd9Sstevel@tonic-gate if ((*f)(sp->feml_nodes+i, mon, arg) != 0) {
32537c478bd9Sstevel@tonic-gate break;
32547c478bd9Sstevel@tonic-gate }
32557c478bd9Sstevel@tonic-gate }
32567c478bd9Sstevel@tonic-gate return (i);
32577c478bd9Sstevel@tonic-gate }
32587c478bd9Sstevel@tonic-gate
32597c478bd9Sstevel@tonic-gate /*
32607c478bd9Sstevel@tonic-gate * companion comparison functions.
32617c478bd9Sstevel@tonic-gate */
32627c478bd9Sstevel@tonic-gate static int
fem_compare_mon(struct fem_node * n,void * mon,void * arg)32637c478bd9Sstevel@tonic-gate fem_compare_mon(struct fem_node *n, void *mon, void *arg)
32647c478bd9Sstevel@tonic-gate {
32657c478bd9Sstevel@tonic-gate return ((n->fn_op.anon == mon) && (n->fn_available == arg));
32667c478bd9Sstevel@tonic-gate }
32677c478bd9Sstevel@tonic-gate
32687c478bd9Sstevel@tonic-gate /*
32697c478bd9Sstevel@tonic-gate * VNODE interposition.
32707c478bd9Sstevel@tonic-gate */
32717c478bd9Sstevel@tonic-gate
32727c478bd9Sstevel@tonic-gate int
fem_create(char * name,const struct fs_operation_def * templ,fem_t ** actual)32737c478bd9Sstevel@tonic-gate fem_create(char *name, const struct fs_operation_def *templ,
32747c478bd9Sstevel@tonic-gate fem_t **actual)
32757c478bd9Sstevel@tonic-gate {
32767c478bd9Sstevel@tonic-gate int unused_ops = 0;
32777c478bd9Sstevel@tonic-gate int e;
32787c478bd9Sstevel@tonic-gate fem_t *newf;
32797c478bd9Sstevel@tonic-gate
32807c478bd9Sstevel@tonic-gate newf = fem_alloc();
32817c478bd9Sstevel@tonic-gate newf->name = name;
32827c478bd9Sstevel@tonic-gate newf->templ = templ;
32837c478bd9Sstevel@tonic-gate
32847c478bd9Sstevel@tonic-gate e = fs_build_vector(newf, &unused_ops, fem_opdef, templ);
32857c478bd9Sstevel@tonic-gate if (e != 0) {
32867c478bd9Sstevel@tonic-gate #ifdef DEBUG
32877c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "fem_create: error %d building vector", e);
32887c478bd9Sstevel@tonic-gate #endif
32897c478bd9Sstevel@tonic-gate fem_free(newf);
32907c478bd9Sstevel@tonic-gate } else {
32917c478bd9Sstevel@tonic-gate *actual = newf;
32927c478bd9Sstevel@tonic-gate }
32937c478bd9Sstevel@tonic-gate return (e);
32947c478bd9Sstevel@tonic-gate }
32957c478bd9Sstevel@tonic-gate
32967c478bd9Sstevel@tonic-gate int
fem_install(vnode_t * vp,fem_t * mon,void * arg,femhow_t how,void (* arg_hold)(void *),void (* arg_rele)(void *))32977c478bd9Sstevel@tonic-gate fem_install(
3298b1659ed9SToomas Soome vnode_t *vp, /* Vnode on which monitor is being installed */
3299b1659ed9SToomas Soome fem_t *mon, /* Monitor operations being installed */
3300b1659ed9SToomas Soome void *arg, /* Opaque data used by monitor */
3301b1659ed9SToomas Soome femhow_t how, /* Installation control */
3302b1659ed9SToomas Soome void (*arg_hold)(void *), /* Hold routine for "arg" */
3303b1659ed9SToomas Soome void (*arg_rele)(void *)) /* Release routine for "arg" */
33047c478bd9Sstevel@tonic-gate {
33057c478bd9Sstevel@tonic-gate int error;
33067c478bd9Sstevel@tonic-gate struct fem_node nnode;
33077c478bd9Sstevel@tonic-gate
33087c478bd9Sstevel@tonic-gate nnode.fn_available = arg;
33097c478bd9Sstevel@tonic-gate nnode.fn_op.fem = mon;
33107c478bd9Sstevel@tonic-gate nnode.fn_av_hold = arg_hold;
33117c478bd9Sstevel@tonic-gate nnode.fn_av_rele = arg_rele;
33127c478bd9Sstevel@tonic-gate /*
33137c478bd9Sstevel@tonic-gate * If we have a non-NULL hold function, do the hold right away.
33147c478bd9Sstevel@tonic-gate * The release is done in remove_node().
33157c478bd9Sstevel@tonic-gate */
33167c478bd9Sstevel@tonic-gate if (arg_hold)
33177c478bd9Sstevel@tonic-gate (*arg_hold)(arg);
33187c478bd9Sstevel@tonic-gate
33197c478bd9Sstevel@tonic-gate error = fem_push_node(&vp->v_femhead, (void **)&vp->v_op, FEMTYPE_VNODE,
3320d7334e51Srm &nnode, how);
33217c478bd9Sstevel@tonic-gate
33227c478bd9Sstevel@tonic-gate /* If there was an error then the monitor wasn't pushed */
33237c478bd9Sstevel@tonic-gate if (error && arg_rele)
33247c478bd9Sstevel@tonic-gate (*arg_rele)(arg);
33257c478bd9Sstevel@tonic-gate
33267c478bd9Sstevel@tonic-gate return (error);
33277c478bd9Sstevel@tonic-gate }
33287c478bd9Sstevel@tonic-gate
33297c478bd9Sstevel@tonic-gate int
fem_is_installed(vnode_t * v,fem_t * mon,void * arg)33307c478bd9Sstevel@tonic-gate fem_is_installed(vnode_t *v, fem_t *mon, void *arg)
33317c478bd9Sstevel@tonic-gate {
33327c478bd9Sstevel@tonic-gate int e;
33337c478bd9Sstevel@tonic-gate struct fem_list *fl;
33347c478bd9Sstevel@tonic-gate
33357c478bd9Sstevel@tonic-gate fl = fem_get(v->v_femhead);
33367c478bd9Sstevel@tonic-gate if (fl != NULL) {
33377c478bd9Sstevel@tonic-gate e = fem_walk_list(fl, fem_compare_mon, (void *)mon, arg);
33387c478bd9Sstevel@tonic-gate fem_release(fl);
33397c478bd9Sstevel@tonic-gate return (e);
33407c478bd9Sstevel@tonic-gate }
33417c478bd9Sstevel@tonic-gate return (0);
33427c478bd9Sstevel@tonic-gate }
33437c478bd9Sstevel@tonic-gate
33447c478bd9Sstevel@tonic-gate int
fem_uninstall(vnode_t * v,fem_t * mon,void * arg)33457c478bd9Sstevel@tonic-gate fem_uninstall(vnode_t *v, fem_t *mon, void *arg)
33467c478bd9Sstevel@tonic-gate {
33477c478bd9Sstevel@tonic-gate int e;
33487c478bd9Sstevel@tonic-gate e = fem_remove_node(v->v_femhead, (void **)&v->v_op,
3349d7334e51Srm (void *)mon, arg);
33507c478bd9Sstevel@tonic-gate return (e);
33517c478bd9Sstevel@tonic-gate }
33527c478bd9Sstevel@tonic-gate
33537c478bd9Sstevel@tonic-gate void
fem_setvnops(vnode_t * v,vnodeops_t * newops)33547c478bd9Sstevel@tonic-gate fem_setvnops(vnode_t *v, vnodeops_t *newops)
33557c478bd9Sstevel@tonic-gate {
33567c478bd9Sstevel@tonic-gate vnodeops_t *r;
33577c478bd9Sstevel@tonic-gate
33587c478bd9Sstevel@tonic-gate ASSERT(v != NULL);
33597c478bd9Sstevel@tonic-gate ASSERT(newops != NULL);
33607c478bd9Sstevel@tonic-gate
33617c478bd9Sstevel@tonic-gate do {
33627c478bd9Sstevel@tonic-gate r = v->v_op;
33637c478bd9Sstevel@tonic-gate membar_consumer();
33647c478bd9Sstevel@tonic-gate if (v->v_femhead != NULL) {
33657c478bd9Sstevel@tonic-gate struct fem_list *fl;
33667c478bd9Sstevel@tonic-gate if ((fl = fem_lock(v->v_femhead)) != NULL) {
33677c478bd9Sstevel@tonic-gate fl->feml_nodes[1].fn_op.vnode = newops;
33687c478bd9Sstevel@tonic-gate fem_unlock(v->v_femhead);
33697c478bd9Sstevel@tonic-gate return;
33707c478bd9Sstevel@tonic-gate }
33717c478bd9Sstevel@tonic-gate fem_unlock(v->v_femhead);
33727c478bd9Sstevel@tonic-gate }
337375d94465SJosef 'Jeff' Sipek } while (atomic_cas_ptr(&v->v_op, r, newops) != r);
33747c478bd9Sstevel@tonic-gate }
33757c478bd9Sstevel@tonic-gate
33767c478bd9Sstevel@tonic-gate vnodeops_t *
fem_getvnops(vnode_t * v)33777c478bd9Sstevel@tonic-gate fem_getvnops(vnode_t *v)
33787c478bd9Sstevel@tonic-gate {
33797c478bd9Sstevel@tonic-gate vnodeops_t *r;
33807c478bd9Sstevel@tonic-gate
33817c478bd9Sstevel@tonic-gate ASSERT(v != NULL);
33827c478bd9Sstevel@tonic-gate
33837c478bd9Sstevel@tonic-gate r = v->v_op;
33847c478bd9Sstevel@tonic-gate membar_consumer();
33857c478bd9Sstevel@tonic-gate if (v->v_femhead != NULL) {
33867c478bd9Sstevel@tonic-gate struct fem_list *fl;
33877c478bd9Sstevel@tonic-gate if ((fl = fem_lock(v->v_femhead)) != NULL) {
33887c478bd9Sstevel@tonic-gate r = fl->feml_nodes[1].fn_op.vnode;
33897c478bd9Sstevel@tonic-gate }
33907c478bd9Sstevel@tonic-gate fem_unlock(v->v_femhead);
33917c478bd9Sstevel@tonic-gate }
33927c478bd9Sstevel@tonic-gate return (r);
33937c478bd9Sstevel@tonic-gate }
33947c478bd9Sstevel@tonic-gate
33957c478bd9Sstevel@tonic-gate
33967c478bd9Sstevel@tonic-gate /*
33977c478bd9Sstevel@tonic-gate * VFS interposition
33987c478bd9Sstevel@tonic-gate */
33997c478bd9Sstevel@tonic-gate int
fsem_create(char * name,const struct fs_operation_def * templ,fsem_t ** actual)34007c478bd9Sstevel@tonic-gate fsem_create(char *name, const struct fs_operation_def *templ,
34017c478bd9Sstevel@tonic-gate fsem_t **actual)
34027c478bd9Sstevel@tonic-gate {
34037c478bd9Sstevel@tonic-gate int unused_ops = 0;
34047c478bd9Sstevel@tonic-gate int e;
34057c478bd9Sstevel@tonic-gate fsem_t *newv;
34067c478bd9Sstevel@tonic-gate
34077c478bd9Sstevel@tonic-gate newv = fsem_alloc();
34087c478bd9Sstevel@tonic-gate newv->name = (const char *)name;
34097c478bd9Sstevel@tonic-gate newv->templ = templ;
34107c478bd9Sstevel@tonic-gate
34117c478bd9Sstevel@tonic-gate e = fs_build_vector(newv, &unused_ops, fsem_opdef, templ);
34127c478bd9Sstevel@tonic-gate if (e != 0) {
34137c478bd9Sstevel@tonic-gate #ifdef DEBUG
34147c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "fsem_create: error %d building vector", e);
34157c478bd9Sstevel@tonic-gate #endif
34167c478bd9Sstevel@tonic-gate fsem_free(newv);
34177c478bd9Sstevel@tonic-gate } else {
34187c478bd9Sstevel@tonic-gate *actual = newv;
34197c478bd9Sstevel@tonic-gate }
34207c478bd9Sstevel@tonic-gate return (e);
34217c478bd9Sstevel@tonic-gate }
34227c478bd9Sstevel@tonic-gate
34237c478bd9Sstevel@tonic-gate /*
34247c478bd9Sstevel@tonic-gate * These need to be re-written, but there should be more common bits.
34257c478bd9Sstevel@tonic-gate */
34267c478bd9Sstevel@tonic-gate
34277c478bd9Sstevel@tonic-gate int
fsem_is_installed(struct vfs * v,fsem_t * mon,void * arg)34287c478bd9Sstevel@tonic-gate fsem_is_installed(struct vfs *v, fsem_t *mon, void *arg)
34297c478bd9Sstevel@tonic-gate {
34307c478bd9Sstevel@tonic-gate struct fem_list *fl;
34317c478bd9Sstevel@tonic-gate
3432ddfcde86Srsb if (v->vfs_implp == NULL)
3433ddfcde86Srsb return (0);
3434ddfcde86Srsb
34357c478bd9Sstevel@tonic-gate fl = fem_get(v->vfs_femhead);
34367c478bd9Sstevel@tonic-gate if (fl != NULL) {
34377c478bd9Sstevel@tonic-gate int e;
34387c478bd9Sstevel@tonic-gate e = fem_walk_list(fl, fem_compare_mon, (void *)mon, arg);
34397c478bd9Sstevel@tonic-gate fem_release(fl);
34407c478bd9Sstevel@tonic-gate return (e);
34417c478bd9Sstevel@tonic-gate }
34427c478bd9Sstevel@tonic-gate return (0);
34437c478bd9Sstevel@tonic-gate }
34447c478bd9Sstevel@tonic-gate
34457c478bd9Sstevel@tonic-gate int
fsem_install(struct vfs * vfsp,fsem_t * mon,void * arg,femhow_t how,void (* arg_hold)(void *),void (* arg_rele)(void *))34467c478bd9Sstevel@tonic-gate fsem_install(
3447b1659ed9SToomas Soome struct vfs *vfsp, /* VFS on which monitor is being installed */
3448b1659ed9SToomas Soome fsem_t *mon, /* Monitor operations being installed */
3449b1659ed9SToomas Soome void *arg, /* Opaque data used by monitor */
3450b1659ed9SToomas Soome femhow_t how, /* Installation control */
3451b1659ed9SToomas Soome void (*arg_hold)(void *), /* Hold routine for "arg" */
3452b1659ed9SToomas Soome void (*arg_rele)(void *)) /* Release routine for "arg" */
34537c478bd9Sstevel@tonic-gate {
34547c478bd9Sstevel@tonic-gate int error;
34557c478bd9Sstevel@tonic-gate struct fem_node nnode;
34567c478bd9Sstevel@tonic-gate
3457ddfcde86Srsb /* If this vfs hasn't been properly initialized, fail the install */
3458ddfcde86Srsb if (vfsp->vfs_implp == NULL)
3459ddfcde86Srsb return (EINVAL);
3460ddfcde86Srsb
34617c478bd9Sstevel@tonic-gate nnode.fn_available = arg;
34627c478bd9Sstevel@tonic-gate nnode.fn_op.fsem = mon;
34637c478bd9Sstevel@tonic-gate nnode.fn_av_hold = arg_hold;
34647c478bd9Sstevel@tonic-gate nnode.fn_av_rele = arg_rele;
34657c478bd9Sstevel@tonic-gate /*
34667c478bd9Sstevel@tonic-gate * If we have a non-NULL hold function, do the hold right away.
34677c478bd9Sstevel@tonic-gate * The release is done in remove_node().
34687c478bd9Sstevel@tonic-gate */
34697c478bd9Sstevel@tonic-gate if (arg_hold)
34707c478bd9Sstevel@tonic-gate (*arg_hold)(arg);
34717c478bd9Sstevel@tonic-gate
34727c478bd9Sstevel@tonic-gate error = fem_push_node(&vfsp->vfs_femhead, (void **)&vfsp->vfs_op,
3473d7334e51Srm FEMTYPE_VFS, &nnode, how);
34747c478bd9Sstevel@tonic-gate
34757c478bd9Sstevel@tonic-gate /* If there was an error then the monitor wasn't pushed */
34767c478bd9Sstevel@tonic-gate if (error && arg_rele)
34777c478bd9Sstevel@tonic-gate (*arg_rele)(arg);
34787c478bd9Sstevel@tonic-gate
34797c478bd9Sstevel@tonic-gate return (error);
34807c478bd9Sstevel@tonic-gate }
34817c478bd9Sstevel@tonic-gate
34827c478bd9Sstevel@tonic-gate int
fsem_uninstall(struct vfs * v,fsem_t * mon,void * arg)34837c478bd9Sstevel@tonic-gate fsem_uninstall(struct vfs *v, fsem_t *mon, void *arg)
34847c478bd9Sstevel@tonic-gate {
34857c478bd9Sstevel@tonic-gate int e;
3486ddfcde86Srsb
3487ddfcde86Srsb if (v->vfs_implp == NULL)
3488ddfcde86Srsb return (EINVAL);
3489ddfcde86Srsb
34907c478bd9Sstevel@tonic-gate e = fem_remove_node(v->vfs_femhead, (void **)&v->vfs_op,
3491d7334e51Srm (void *)mon, arg);
34927c478bd9Sstevel@tonic-gate return (e);
34937c478bd9Sstevel@tonic-gate }
34947c478bd9Sstevel@tonic-gate
34957c478bd9Sstevel@tonic-gate void
fsem_setvfsops(vfs_t * v,vfsops_t * newops)34967c478bd9Sstevel@tonic-gate fsem_setvfsops(vfs_t *v, vfsops_t *newops)
34977c478bd9Sstevel@tonic-gate {
34987c478bd9Sstevel@tonic-gate vfsops_t *r;
34997c478bd9Sstevel@tonic-gate
35007c478bd9Sstevel@tonic-gate ASSERT(v != NULL);
35017c478bd9Sstevel@tonic-gate ASSERT(newops != NULL);
3502ddfcde86Srsb ASSERT(v->vfs_implp);
35037c478bd9Sstevel@tonic-gate
35047c478bd9Sstevel@tonic-gate do {
35057c478bd9Sstevel@tonic-gate r = v->vfs_op;
35067c478bd9Sstevel@tonic-gate membar_consumer();
35077c478bd9Sstevel@tonic-gate if (v->vfs_femhead != NULL) {
35087c478bd9Sstevel@tonic-gate struct fem_list *fl;
35097c478bd9Sstevel@tonic-gate if ((fl = fem_lock(v->vfs_femhead)) != NULL) {
35107c478bd9Sstevel@tonic-gate fl->feml_nodes[1].fn_op.vfs = newops;
35117c478bd9Sstevel@tonic-gate fem_unlock(v->vfs_femhead);
35127c478bd9Sstevel@tonic-gate return;
35137c478bd9Sstevel@tonic-gate }
35147c478bd9Sstevel@tonic-gate fem_unlock(v->vfs_femhead);
35157c478bd9Sstevel@tonic-gate }
351675d94465SJosef 'Jeff' Sipek } while (atomic_cas_ptr(&v->vfs_op, r, newops) != r);
35177c478bd9Sstevel@tonic-gate }
35187c478bd9Sstevel@tonic-gate
35197c478bd9Sstevel@tonic-gate vfsops_t *
fsem_getvfsops(vfs_t * v)35207c478bd9Sstevel@tonic-gate fsem_getvfsops(vfs_t *v)
35217c478bd9Sstevel@tonic-gate {
35227c478bd9Sstevel@tonic-gate vfsops_t *r;
35237c478bd9Sstevel@tonic-gate
35247c478bd9Sstevel@tonic-gate ASSERT(v != NULL);
3525ddfcde86Srsb ASSERT(v->vfs_implp);
35267c478bd9Sstevel@tonic-gate
35277c478bd9Sstevel@tonic-gate r = v->vfs_op;
35287c478bd9Sstevel@tonic-gate membar_consumer();
35297c478bd9Sstevel@tonic-gate if (v->vfs_femhead != NULL) {
35307c478bd9Sstevel@tonic-gate struct fem_list *fl;
35317c478bd9Sstevel@tonic-gate if ((fl = fem_lock(v->vfs_femhead)) != NULL) {
35327c478bd9Sstevel@tonic-gate r = fl->feml_nodes[1].fn_op.vfs;
35337c478bd9Sstevel@tonic-gate }
35347c478bd9Sstevel@tonic-gate fem_unlock(v->vfs_femhead);
35357c478bd9Sstevel@tonic-gate }
35367c478bd9Sstevel@tonic-gate return (r);
35377c478bd9Sstevel@tonic-gate }
35387c478bd9Sstevel@tonic-gate
35397c478bd9Sstevel@tonic-gate /*
35407c478bd9Sstevel@tonic-gate * Setup FEM.
35417c478bd9Sstevel@tonic-gate */
35427c478bd9Sstevel@tonic-gate void
fem_init()35437c478bd9Sstevel@tonic-gate fem_init()
35447c478bd9Sstevel@tonic-gate {
35457c478bd9Sstevel@tonic-gate struct fem_type_info *fi;
35467c478bd9Sstevel@tonic-gate
35477c478bd9Sstevel@tonic-gate /*
35487c478bd9Sstevel@tonic-gate * This femtype is only used for fem_list creation so we only
35497c478bd9Sstevel@tonic-gate * need the "guard" to be initialized so that feml_tos has
35507c478bd9Sstevel@tonic-gate * some rudimentary meaning. A fem_list must not be used until
35517c478bd9Sstevel@tonic-gate * it has been initialized (either via femlist_construct() or
35527c478bd9Sstevel@tonic-gate * fem_dup_list()). Anything that tries to use this fem_list
35537c478bd9Sstevel@tonic-gate * before it's actually initialized would panic the system as
35547c478bd9Sstevel@tonic-gate * soon as "fn_op" (NULL) is dereferenced.
35557c478bd9Sstevel@tonic-gate */
35567c478bd9Sstevel@tonic-gate fi = femtype + FEMTYPE_NULL;
35577c478bd9Sstevel@tonic-gate fi->errf = fem_err;
35587c478bd9Sstevel@tonic-gate fi->guard.fn_available = (void *)&fi->guard;
35597c478bd9Sstevel@tonic-gate fi->guard.fn_av_hold = NULL;
35607c478bd9Sstevel@tonic-gate fi->guard.fn_av_rele = NULL;
35617c478bd9Sstevel@tonic-gate fi->guard.fn_op.anon = NULL;
35627c478bd9Sstevel@tonic-gate
35637c478bd9Sstevel@tonic-gate fi = femtype + FEMTYPE_VNODE;
35647c478bd9Sstevel@tonic-gate fi->errf = fem_err;
35657c478bd9Sstevel@tonic-gate fi->head.fn_available = NULL;
35667c478bd9Sstevel@tonic-gate fi->head.fn_av_hold = NULL;
35677c478bd9Sstevel@tonic-gate fi->head.fn_av_rele = NULL;
35687c478bd9Sstevel@tonic-gate (void) vn_make_ops("fem-head", fhead_vn_spec, &fi->head.fn_op.vnode);
35697c478bd9Sstevel@tonic-gate fi->guard.fn_available = (void *)&fi->guard;
35707c478bd9Sstevel@tonic-gate fi->guard.fn_av_hold = NULL;
35717c478bd9Sstevel@tonic-gate fi->guard.fn_av_rele = NULL;
35727c478bd9Sstevel@tonic-gate (void) fem_create("fem-guard", fem_guard_ops, &fi->guard.fn_op.fem);
35737c478bd9Sstevel@tonic-gate
35747c478bd9Sstevel@tonic-gate fi = femtype + FEMTYPE_VFS;
35757c478bd9Sstevel@tonic-gate fi->errf = fsem_err;
35767c478bd9Sstevel@tonic-gate fi->head.fn_available = NULL;
35777c478bd9Sstevel@tonic-gate fi->head.fn_av_hold = NULL;
35787c478bd9Sstevel@tonic-gate fi->head.fn_av_rele = NULL;
35797c478bd9Sstevel@tonic-gate (void) vfs_makefsops(fshead_vfs_spec, &fi->head.fn_op.vfs);
35807c478bd9Sstevel@tonic-gate
35817c478bd9Sstevel@tonic-gate fi->guard.fn_available = (void *)&fi->guard;
35827c478bd9Sstevel@tonic-gate fi->guard.fn_av_hold = NULL;
35837c478bd9Sstevel@tonic-gate fi->guard.fn_av_rele = NULL;
35847c478bd9Sstevel@tonic-gate (void) fsem_create("fem-guard", fsem_guard_ops, &fi->guard.fn_op.fsem);
35857c478bd9Sstevel@tonic-gate }
35867c478bd9Sstevel@tonic-gate
35877c478bd9Sstevel@tonic-gate
35887c478bd9Sstevel@tonic-gate int
fem_err()35897c478bd9Sstevel@tonic-gate fem_err()
35907c478bd9Sstevel@tonic-gate {
35917c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "fem/vnode operations corrupt");
35927c478bd9Sstevel@tonic-gate return (0);
35937c478bd9Sstevel@tonic-gate }
35947c478bd9Sstevel@tonic-gate
35957c478bd9Sstevel@tonic-gate int
fsem_err()35967c478bd9Sstevel@tonic-gate fsem_err()
35977c478bd9Sstevel@tonic-gate {
35987c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "fem/vfs operations corrupt");
35997c478bd9Sstevel@tonic-gate return (0);
36007c478bd9Sstevel@tonic-gate }
3601