fem.h revision d7334e518c844ea303c302d359e39ee1316a314c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FEM_H
#define _SYS_FEM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/pathname.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
struct fs_operation_def; /* from vfs.h */
/*
* overview:
*
* fem - file event monitoring
*
* File Event Monitoring is a formalized mechanism to monitor events on a
* the consumer to request event notifications for specified files and
* directories. The consumers, which intercept the events, are responsible for
* delivering the event to the next interceptor or the terminal destination.
*
*/
/*
* protocol:
*
* vnode -> fem_head.
* There can only be one fem_head for a vnode.
* Once attached, the fem_head persists until explicitly detached
* or the vnode expires.
*
* fem_head -> fem_list.
* There can be many lists for a head, as each reconfiguration of
* the list causes a new one to be created and initialized from the
* old one. For this reason, modules cannot assume that they can
* reach thier list by vnode->fem_head->fem_list->list[n] == mod;
*
* fem_arg -> vnode, &vnode.
* This relationship is established at the head of the call (ie. in
* femhead_open()) where the fem_arg is allocated. Intermediate nodes
* have direct access to this.
*
* fem_arg -> fem_node
* This relationship is established at the head of the call (ie. in
* femhead_open()) where the fem_arg is allocated. The fem_arg is
* updated as intermediate nodes are invoked, however not as they
* return. For this reason, nodes which are interested in maintaining
* context following a "next" should store a copy of the fem_available
* field before invoking the 'next'.
*/
typedef int femop_t();
typedef void (*fem_func_t)(void *);
/*
* The following enumerations specify the conditions
* should be installed. These are used when calling
* fem_install() and fsem_install()
*/
typedef enum femhow {
FORCE = 0, /* Force the installation of this monitor */
} femhow_t;
struct fem_node {
void *fn_available;
union {
void *anon; /* anonymous, for updates */
} fn_op;
void (*fn_av_hold)(void *); /* Hold for "fn_available" */
void (*fn_av_rele)(void *); /* Release for "fn_available" */
};
struct fem_arg {
union {
**vpp;
void *anon;
} fa_vnode;
};
struct fem_list {
int feml_tos; /* top of stack pointer(index) */
int feml_ssize; /* stack size */
int feml_pad; /* alignment */
};
struct fem_head {
};
/*
* FEM_OPS defines all the FEM operations. It is used to define
* the fem structure (below) and the fs_func_p union (vfs_opreg.h).
*/
#define FEM_OPS \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
vsecattr_t *vsecp); \
int flags); \
vsecattr_t *vsecp); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
caller_context_t *ct); \
/* NB: No ";" */
struct fem {
const char *name;
const struct fs_operation_def *templ;
FEM_OPS; /* Signatures of all FEM operations (femops) */
};
/*
* FSEM_OPS defines all the FSEM operations. It is used to define
* the fsem structure (below) and the fs_func_p union (vfs_opreg.h).
*/
#define FSEM_OPS \
enum whymountroot reason); \
struct fsem {
const char *name;
const struct fs_operation_def *templ;
FSEM_OPS; /* Signatures of all FSEM operations (fsemops) */
};
int flags);
extern void fem_init(void); /* called once, by startup */
/* fem api */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FEM_H */