port_impl.h revision df2381bfa5cf7dd654bcf30b2f5af53f34f3043a
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_PORT_IMPL_H
#define _SYS_PORT_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Note:
* The contents of this file are private to the implementation of the
* Solaris system and event ports subsystem and are subject to change
* at any time without notice.
*/
#include <sys/poll_impl.h>
#include <sys/port_kernel.h>
/*
* port system call codes
*/
#define PORT_CREATE 0 /* create a port */
#define PORT_CODE_MASK 0xff
/* port_dispatch() flags */
/* port limits */
#ifdef _KERNEL
/* portkev_flags masks */
typedef struct port_alert {
int portal_events; /* passed to alert event */
void *portal_user; /* passed to alert event */
} port_alert_t;
/*
* The port_queue_t structure is responsible for the management of all
* event activities within a port.
*/
typedef struct port_queue {
int portq_flags;
int portq_thrcnt; /* # of threads waiting for events */
int portq_getn; /* # of threads retrieving events */
} port_queue_t;
/* defines for portq_flags */
typedef struct port {
int port_fd;
} port_t;
/* defines for port_flags */
/*
* global control structure of port framework
*/
typedef struct port_control {
/*
* Every thread waiting on an object will use this structure to store
* all dependencies (flags, counters, events) before it awakes with
* some events/transactions completed
*/
typedef struct portget {
int portget_state;
struct portget *portget_next;
struct portget *portget_prev;
} portget_t;
/* defines for portget_state */
extern port_control_t port_control;
extern uint_t port_max_list;
/*
* port_getn() needs this structure to manage inter-process event delivery.
*/
typedef struct port_gettimer {
int pgt_timecheck;
struct timespec *pgt_timeout;
/* pgt_flags */
/*
* portfd_t is required to synchronize the association of fds with a port
* and the per-process list of open files.
* There is a pointer to a portfd structure in uf_entry_t.
* If a fd is closed then closeandsetf() is able to detect the association of
* the fd with a port or with a list of ports. closeandsetf() will dissociate
* the fd from the port(s).
*/
typedef struct portfd {
} portfd_t;
/*
* PORT_SOURCE_FILE -- File Events Notification sources
*/
(PORTFOP_HASHSIZE - 1))])
/*
* This structure is used to register a file object to be watched.
*
* The pfop_flags are protected by the vnode's pvp_mutex lock.
* The pfop list (vnode's list) is protected by the pvp_mutex when it is on
* the vnode's list.
*
* All the rest of the fields are protected by the port's source cache lock
* pfcp_lock.
*/
typedef struct portfop {
int pfop_events;
int pfop_flags; /* above flags. */
struct portfop_cache *pfop_pcache;
char *pfop_cname; /* file component name */
int pfop_clen;
} portfop_t;
/*
* pfop_flags
*/
#define PORT_FOP_ACTIVE 0x1
#define PORT_FOP_REMOVING 0x2
#define PORT_FOP_KEV_ONQ 0x4
typedef struct portfop_vfs {
int pvfs_unmount; /* 1 if unmount in progress */
typedef struct portfop_vfs_hash {
struct portfop_vfs *pvfshash_pvfsp;
typedef struct portfop_vp {
int pvp_cnt; /* number of watches */
struct portfop_vfs *pvp_pvfsp;
} portfop_vp_t;
#define PORTFOP_PVFSHASH_SZ 256
/*
* file operations flag.
*/
/*
* PORT_SOURCE_FILE - vnode operations
*/
#define FOP_FILE_OPEN 0x00000001
#define FOP_FILE_READ 0x00000002
#define FOP_FILE_WRITE 0x00000004
#define FOP_FILE_MAP 0x00000008
#define FOP_FILE_IOCTL 0x00000010
#define FOP_FILE_CREATE 0x00000020
#define FOP_FILE_MKDIR 0x00000040
#define FOP_FILE_SYMLINK 0x00000080
#define FOP_FILE_LINK 0x00000100
#define FOP_FILE_RENAME 0x00000200
#define FOP_FILE_REMOVE 0x00000400
#define FOP_FILE_RMDIR 0x00000800
#define FOP_FILE_READDIR 0x00001000
#define FOP_FILE_RENAMESRC 0x00002000
#define FOP_FILE_RENAMEDST 0x00004000
#define FOP_FILE_REMOVEFILE 0x00008000
#define FOP_FILE_REMOVEDIR 0x00010000
#define FOP_FILE_SETSECATTR 0x00020000
#define FOP_FILE_SETATTR_ATIME 0x00040000
#define FOP_FILE_SETATTR_MTIME 0x00080000
#define FOP_FILE_SETATTR_CTIME 0x00100000
#define FOP_FILE_LINK_SRC 0x00200000
/*
* File modification event.
*/
/*
* File access event
*/
/*
* File attrib event
*/
/*
* valid watchable events
*/
/* --- End file events --- */
/*
* port_kstat_t contains the event port kernel values which are
* exported to kstat.
* Currently only the number of active ports is exported.
*/
typedef struct port_kstat {
} port_kstat_t;
/* misc functions */
void port_push_eventq(port_queue_t *);
int port_remove_done_event(struct port_kevent *);
void port_block(port_queue_t *);
void port_unblock(port_queue_t *);
/* PORT_SOURCE_FD cache management */
/* file close management */
extern void addfd_port(int, portfd_t *);
extern void delfd_port(int, portfd_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PORT_IMPL_H */