b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER START
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The contents of this file are subject to the terms of the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Common Development and Distribution License (the "License").
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You may not use this file except in compliance with the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * or http://www.opensolaris.org/os/licensing.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * See the License for the specific language governing permissions
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * and limitations under the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * When distributing Covered Code, include this CDDL HEADER in each
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * If applicable, add the following below this CDDL HEADER, with the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner]
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER END
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Use is subject to license terms.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#ifndef _SYS_VFS_OPREG_H
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#define _SYS_VFS_OPREG_H
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#include <sys/vfs.h>
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#include <sys/fem.h>
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#ifdef __cplusplus
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossextern "C" {
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The following union allows us to use C99's "designated initializer"
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * feature so that we can have strong typechecking for the operations
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * used in the the fs_operation_def structures.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosstypedef union fs_func {
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fs_generic_func_p fs_generic; /* Generic function signature */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross int (*error)(); /* Signature of error function */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross VFS_OPS; /* Signatures of all vfs operations (vfsops) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross VNODE_OPS; /* Signatures of all vnode operations (vops) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross FEM_OPS; /* Signatures of all FEM operations (femops) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross FSEM_OPS; /* Signatures of all FSEM ops (fsemops) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross} fs_func_p;
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * File systems use arrays of fs_operation_def structures to form
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * name/value pairs of operations. These arrays get passed to:
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * - vn_make_ops() to create vnodeops
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * - vfs_makefsops()/vfs_setfsops() to create vfsops.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosstypedef struct fs_operation_def {
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross char *name; /* name of operation (NULL at end) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fs_func_p func; /* function implementing operation */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross} fs_operation_def_t;
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The operation registration mechanism uses two master tables of operations:
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * one for vnode operations (vn_ops_table[]) and one for vfs operations
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * structures. They contain all of the information necessary for the system
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * to populate an operations structure (e.g., vnodeops, vfsops).
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross *
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * File systems call registration routines (vfs_setfsops(), vfs_makefsops(),
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * and vn_make_ops()) and pass in their operations specification tables
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * (arrays of fs_operation_def structures). These routines use the master
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * table(s) of operations to build a vnodeops or vfsops structure.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosstypedef struct fs_operation_trans_def {
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross char *name; /* name of operation (NULL at end) */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross int offset; /* byte offset within ops vector */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fs_generic_func_p defaultFunc; /* default function */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fs_generic_func_p errorFunc; /* error function */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross} fs_operation_trans_def_t;
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Generic operations vector types (used for vfs/vnode ops registration).
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossextern int fs_default(); /* "default" function placeholder */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossextern int fs_error(); /* "error" function placeholder */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossint fs_build_vector(void *vector, int *unused_ops,
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross const fs_operation_trans_def_t *translation,
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross const fs_operation_def_t *operations);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Public operations.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossint vn_make_ops(const char *, const struct fs_operation_def *,
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross vnodeops_t **);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossvoid vn_freevnodeops(vnodeops_t *);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossint vfs_setfsops(int, const fs_operation_def_t *, vfsops_t **);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossint vfs_makefsops(const fs_operation_def_t *, vfsops_t **);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossvoid vfs_freevfsops(vfsops_t *);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossint vfs_freevfsops_by_type(int);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif /* _KERNEL */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#ifdef __cplusplus
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross}
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif /* _SYS_VFS_OPREG_H */