xref: /titanic_44/usr/src/uts/common/sys/port_impl.h (revision 72102e7461c97dc268d21d9dd8f02da45f174acd)
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
534709573Sraf  * Common Development and Distribution License (the "License").
634709573Sraf  * 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  */
2134709573Sraf 
227c478bd9Sstevel@tonic-gate /*
237c88c50eSPramod Batni  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*72102e74SBryan Cantrill /*
28*72102e74SBryan Cantrill  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
29*72102e74SBryan Cantrill  */
30*72102e74SBryan Cantrill 
317c478bd9Sstevel@tonic-gate #ifndef	_SYS_PORT_IMPL_H
327c478bd9Sstevel@tonic-gate #define	_SYS_PORT_IMPL_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Note:
417c478bd9Sstevel@tonic-gate  * The contents of this file are private to the implementation of the
427c478bd9Sstevel@tonic-gate  * Solaris system and event ports subsystem and are subject to change
437c478bd9Sstevel@tonic-gate  * at any time without notice.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include <sys/poll_impl.h>
477c478bd9Sstevel@tonic-gate #include <sys/port.h>
487c478bd9Sstevel@tonic-gate #include <sys/port_kernel.h>
497c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
50df2381bfSpraks #include <sys/fem.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * port system call codes
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate #define	PORT_CREATE	0	/* create a port */
567c478bd9Sstevel@tonic-gate #define	PORT_ASSOCIATE	1	/* register object or object list */
577c478bd9Sstevel@tonic-gate #define	PORT_DISSOCIATE	2	/* remove object association */
587c478bd9Sstevel@tonic-gate #define	PORT_SEND	3	/* send user-defined event to a port */
597c478bd9Sstevel@tonic-gate #define	PORT_SENDN	4	/* send user-defined event to a list of ports */
607c478bd9Sstevel@tonic-gate #define	PORT_GET	5	/* receive object with events */
617c478bd9Sstevel@tonic-gate #define	PORT_GETN	6	/* receive list of objects with events */
627c478bd9Sstevel@tonic-gate #define	PORT_ALERT	7	/* set port in alert mode */
637c478bd9Sstevel@tonic-gate #define	PORT_DISPATCH	8	/* dispatch object with events */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	PORT_SYS_NOPORT		0x100	/* system call without port-id */
667c478bd9Sstevel@tonic-gate #define	PORT_SYS_NOSHARE	0x200	/* non shareable event */
677c478bd9Sstevel@tonic-gate #define	PORT_CODE_MASK		0xff
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* port_dispatch() flags */
707c478bd9Sstevel@tonic-gate #define	PORT_SHARE_EVENT	0x01	/* event can be shared between procs */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /* port limits */
737c478bd9Sstevel@tonic-gate #define	PORT_MAX_LIST	8192	/* max. # of list ent. per syscall */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #ifdef _KERNEL
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define	PORT_SCACHE_SIZE	16	/* start source cache size */
787c478bd9Sstevel@tonic-gate #define	PORT_SHASH(cookie)	(cookie & (PORT_SCACHE_SIZE-1))
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* portkev_flags masks */
817c478bd9Sstevel@tonic-gate #define	PORT_CLEANUP_DONE	(PORT_KEV_FREE|PORT_KEV_DONEQ)
827c478bd9Sstevel@tonic-gate #define	PORT_KEV_CACHE		(PORT_KEV_CACHED|PORT_KEV_SCACHED)
837c478bd9Sstevel@tonic-gate #define	PORT_KEV_WIRED		(PORT_KEV_PRIVATE|PORT_KEV_CACHE)
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	PORT_FREE_EVENT(pev)	(((pev)->portkev_flags & PORT_KEV_CACHE) == 0)
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate typedef struct port_alert {
887c478bd9Sstevel@tonic-gate 	int	portal_events;		/* passed to alert event */
897c478bd9Sstevel@tonic-gate 	pid_t	portal_pid;		/* owner of the alert mode */
907c478bd9Sstevel@tonic-gate 	uintptr_t portal_object;	/* passed to alert event */
917c478bd9Sstevel@tonic-gate 	void	*portal_user;		/* passed to alert event */
927c478bd9Sstevel@tonic-gate } port_alert_t;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * The port_queue_t structure is responsible for the management of all
967c478bd9Sstevel@tonic-gate  * event activities within a port.
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate typedef struct port_queue {
997c478bd9Sstevel@tonic-gate 	kmutex_t 	portq_mutex;
1007c478bd9Sstevel@tonic-gate 	kcondvar_t	portq_closecv;
10134709573Sraf 	kcondvar_t	portq_block_cv;
1027c478bd9Sstevel@tonic-gate 	int		portq_flags;
1037c478bd9Sstevel@tonic-gate 	uint_t		portq_nent;	/* number of events in the queue */
1047c478bd9Sstevel@tonic-gate 	uint_t		portq_nget;	/* events required for waiting thread */
1057c478bd9Sstevel@tonic-gate 	uint_t		portq_tnent;	/* number of events in the temp queue */
1067c478bd9Sstevel@tonic-gate 	int		portq_thrcnt;	/* # of threads waiting for events */
1077c478bd9Sstevel@tonic-gate 	int		portq_getn;	/* # of threads retrieving events */
1087c478bd9Sstevel@tonic-gate 	struct	portget	*portq_thread;	/* queue of waiting threads */
1097c478bd9Sstevel@tonic-gate 	struct port_fdcache *portq_pcp;	/* fd cache */
1107c478bd9Sstevel@tonic-gate 	list_t		portq_list;	/* port event list */
1117c478bd9Sstevel@tonic-gate 	list_t		portq_get_list;	/* port event list for port_get(n) */
1127c478bd9Sstevel@tonic-gate 	kmutex_t	portq_source_mutex;
1137c478bd9Sstevel@tonic-gate 	port_source_t	**portq_scache;
1147c478bd9Sstevel@tonic-gate 	port_alert_t	portq_alert;	/* alert event data	*/
1157c478bd9Sstevel@tonic-gate } port_queue_t;
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /* defines for portq_flags */
1187c478bd9Sstevel@tonic-gate #define	PORTQ_ALERT	   0x01	/* port in alert state */
1197c478bd9Sstevel@tonic-gate #define	PORTQ_CLOSE	   0x02 /* closing port	*/
1207c478bd9Sstevel@tonic-gate #define	PORTQ_WAIT_EVENTS  0x04 /* waiting for new events */
1217c478bd9Sstevel@tonic-gate #define	PORTQ_POLLIN	   0x08 /* events available in the event queue */
1227c478bd9Sstevel@tonic-gate #define	PORTQ_POLLOUT	   0x10 /* space available for new events */
12334709573Sraf #define	PORTQ_BLOCKED	   0x20 /* port is blocked by port_getn() */
12411dc39ddSpraks #define	PORTQ_POLLWK_PEND  0x40 /* pollwakeup is pending, blocks port close */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #define	VTOEP(v)  ((struct port *)(v->v_data))
1277c478bd9Sstevel@tonic-gate #define	EPTOV(ep) ((struct vnode *)(ep)->port_vnode)
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate typedef	struct	port {
1317c478bd9Sstevel@tonic-gate 	vnode_t		*port_vnode;
1327c478bd9Sstevel@tonic-gate 	kmutex_t	port_mutex;
1337c478bd9Sstevel@tonic-gate 	kcondvar_t	port_cv;	/* resource control */
1347c478bd9Sstevel@tonic-gate 	uint_t		port_flags;
1357c478bd9Sstevel@tonic-gate 	pid_t		port_pid;
1367c478bd9Sstevel@tonic-gate 	int		port_fd;
1377c478bd9Sstevel@tonic-gate 	uint_t		port_max_events; /* max. number of event per port */
1387c478bd9Sstevel@tonic-gate 	uint_t		port_max_list;	/* max. number of list structs	*/
1397c478bd9Sstevel@tonic-gate 	uint_t		port_curr;	/* current number of event structs */
1407c478bd9Sstevel@tonic-gate 	pollhead_t	port_pollhd;
1417c478bd9Sstevel@tonic-gate 	timespec_t	port_ctime;
1427c478bd9Sstevel@tonic-gate 	uid_t		port_uid;
1437c478bd9Sstevel@tonic-gate 	gid_t		port_gid;
1447c478bd9Sstevel@tonic-gate 	port_queue_t	port_queue;	/* global queue */
1457c478bd9Sstevel@tonic-gate } port_t;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /* defines for port_flags */
1487c478bd9Sstevel@tonic-gate #define	PORT_INIT	0x01		/* port initialized */
1497c478bd9Sstevel@tonic-gate #define	PORT_CLOSED	0x02		/* owner closed the port */
1507c478bd9Sstevel@tonic-gate #define	PORT_EVENTS	0x04		/* waiting for event resources */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * global control structure of port framework
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate typedef	struct	port_control {
1567c478bd9Sstevel@tonic-gate 	kmutex_t	pc_mutex;
1577c478bd9Sstevel@tonic-gate 	uint_t		pc_nents;	/* ports currently allocated */
1587c478bd9Sstevel@tonic-gate 	struct	kmem_cache *pc_cache;	/* port event structures */
1597c478bd9Sstevel@tonic-gate } port_control_t;
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * Every thread waiting on an object will use this structure to store
1647c478bd9Sstevel@tonic-gate  * all dependencies (flags, counters, events) before it awakes with
1657c478bd9Sstevel@tonic-gate  * some events/transactions completed
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate typedef	struct	portget {
1687c478bd9Sstevel@tonic-gate 	int		portget_state;
1697c478bd9Sstevel@tonic-gate 	uint_t		portget_nget;	/* number of expected events */
1707c478bd9Sstevel@tonic-gate 	pid_t		portget_pid;
1717c478bd9Sstevel@tonic-gate 	kcondvar_t	portget_cv;
1727c478bd9Sstevel@tonic-gate 	port_alert_t	portget_alert;
1737c478bd9Sstevel@tonic-gate 	struct	portget	*portget_next;
1747c478bd9Sstevel@tonic-gate 	struct	portget	*portget_prev;
1757c478bd9Sstevel@tonic-gate } portget_t;
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /* defines for portget_state */
1787c478bd9Sstevel@tonic-gate #define	PORTGET_ALERT		0x01	/* wake up and return alert event */
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate extern	port_control_t	port_control;
1817c478bd9Sstevel@tonic-gate extern	uint_t	port_max_list;
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * port_getn() needs this structure to manage inter-process event delivery.
1857c478bd9Sstevel@tonic-gate  */
1867c478bd9Sstevel@tonic-gate typedef struct	port_gettimer {
1877c478bd9Sstevel@tonic-gate 	ushort_t	pgt_flags;
1887c478bd9Sstevel@tonic-gate 	ushort_t	pgt_loop;
1893348528fSdm120769 	int		pgt_timecheck;
1907c478bd9Sstevel@tonic-gate 	timespec_t	pgt_rqtime;
1917c478bd9Sstevel@tonic-gate 	timespec_t	*pgt_rqtp;
1927c478bd9Sstevel@tonic-gate 	struct timespec	*pgt_timeout;
1937c478bd9Sstevel@tonic-gate } port_gettimer_t;
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /* pgt_flags */
1967c478bd9Sstevel@tonic-gate #define	PORTGET_ONE		0x01	/* return only 1 object */
1977c478bd9Sstevel@tonic-gate #define	PORTGET_WAIT_EVENTS	0x02	/* thread is waiting for new events */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate  * portfd_t is required to synchronize the association of fds with a port
2017c478bd9Sstevel@tonic-gate  * and the per-process list of open files.
2027c478bd9Sstevel@tonic-gate  * There is a pointer to a portfd structure in uf_entry_t.
2037c478bd9Sstevel@tonic-gate  * If a fd is closed then closeandsetf() is able to detect the association of
2047c478bd9Sstevel@tonic-gate  * the fd with a port or with a list of ports. closeandsetf() will dissociate
2057c478bd9Sstevel@tonic-gate  * the fd from the port(s).
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate typedef struct portfd {
2087c478bd9Sstevel@tonic-gate 	struct polldat	pfd_pd;
2097c478bd9Sstevel@tonic-gate 	struct portfd	*pfd_next;
2107c478bd9Sstevel@tonic-gate 	struct portfd	*pfd_prev;
2117c88c50eSPramod Batni 	kthread_t	*pfd_thread;
2127c478bd9Sstevel@tonic-gate } portfd_t;
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate #define	PFTOD(pfd)	(&(pfd)->pfd_pd)
2157c478bd9Sstevel@tonic-gate #define	PDTOF(pdp)	((struct portfd *)(pdp))
2167c478bd9Sstevel@tonic-gate #define	PORT_FD_BUCKET(pcp, fd) \
2177c478bd9Sstevel@tonic-gate 	(&(pcp)->pc_hash[((fd) % (pcp)->pc_hashsize)])
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate /*
220df2381bfSpraks  * PORT_SOURCE_FILE -- File Events Notification sources
221df2381bfSpraks  */
222df2381bfSpraks #define	PORT_FOP_BUCKET(pcp, id) \
223df2381bfSpraks 	(portfop_t **)(&(pcp)->pfc_hash[(((ulong_t)id >> 8) & \
224df2381bfSpraks 	    (PORTFOP_HASHSIZE - 1))])
225df2381bfSpraks 
226df2381bfSpraks /*
227df2381bfSpraks  * This structure is used to register a file object to be watched.
228df2381bfSpraks  *
229df2381bfSpraks  * The pfop_flags are protected by the vnode's pvp_mutex lock.
230df2381bfSpraks  * The pfop list (vnode's list) is protected by the pvp_mutex when it is on
231df2381bfSpraks  * the vnode's list.
232df2381bfSpraks  *
233df2381bfSpraks  * All the rest of the fields are protected by the port's source cache lock
234df2381bfSpraks  * pfcp_lock.
235df2381bfSpraks  */
236df2381bfSpraks typedef struct  portfop {
237df2381bfSpraks 	int		pfop_events;
238df2381bfSpraks 	int		pfop_flags;	/* above flags. */
239df2381bfSpraks 	uintptr_t	pfop_object;	/* object address */
240df2381bfSpraks 	vnode_t		*pfop_vp;
241df2381bfSpraks 	vnode_t		*pfop_dvp;
242df2381bfSpraks 	port_t		*pfop_pp;
243df2381bfSpraks 	fem_t		*pfop_fem;
244df2381bfSpraks 	list_node_t	pfop_node;	/* list of pfop's per vnode */
245df2381bfSpraks 	struct portfop	*pfop_hashnext;	/* hash list */
246df2381bfSpraks 	pid_t		pfop_pid;	/* owner of portfop */
247df2381bfSpraks 	struct portfop_cache *pfop_pcache;
248df2381bfSpraks 	port_kevent_t	*pfop_pev;	/* event pointers */
249df2381bfSpraks 	char		*pfop_cname;	/* file component name */
250df2381bfSpraks 	int		pfop_clen;
251073af7d9Spraks 	kthread_t	*pfop_callrid;	/* thread doing the associate */
252df2381bfSpraks } portfop_t;
253df2381bfSpraks 
254df2381bfSpraks /*
255df2381bfSpraks  * pfop_flags
256df2381bfSpraks  */
257df2381bfSpraks #define		PORT_FOP_ACTIVE		0x1
258df2381bfSpraks #define		PORT_FOP_REMOVING	0x2
259df2381bfSpraks #define		PORT_FOP_KEV_ONQ	0x4
260df2381bfSpraks 
261df2381bfSpraks typedef struct portfop_vfs {
262df2381bfSpraks 	vfs_t		*pvfs;
263df2381bfSpraks 	int		pvfs_unmount;	/* 1 if unmount in progress */
264df2381bfSpraks 	list_t		pvfs_pvplist;	/* list of vnodes from */
265df2381bfSpraks 	fsem_t		*pvfs_fsemp;
266df2381bfSpraks 	struct portfop_vfs *pvfs_next;	/* hash list */
267df2381bfSpraks } portfop_vfs_t;
268df2381bfSpraks 
269df2381bfSpraks typedef struct portfop_vfs_hash {
270df2381bfSpraks 	kmutex_t	pvfshash_mutex;
271df2381bfSpraks 	struct portfop_vfs *pvfshash_pvfsp;
272df2381bfSpraks } portfop_vfs_hash_t;
273df2381bfSpraks 
274df2381bfSpraks typedef struct portfop_vp {
275df2381bfSpraks 	vnode_t		*pvp_vp;
276df2381bfSpraks 	kmutex_t	pvp_mutex;
277df2381bfSpraks 	int		pvp_cnt;	/* number of watches */
278df2381bfSpraks 	list_t		pvp_pfoplist;
279df2381bfSpraks 	list_node_t	pvp_pvfsnode;
280df2381bfSpraks 	struct portfop *pvp_lpfop;	/* oldest pfop */
281df2381bfSpraks 	fem_t		*pvp_femp;
282df2381bfSpraks 	struct portfop_vfs *pvp_pvfsp;
283df2381bfSpraks } portfop_vp_t;
284df2381bfSpraks 
285df2381bfSpraks #define	PORTFOP_PVFSHASH_SZ	256
286df2381bfSpraks #define	PORTFOP_PVFSHASH(vfsp)	(((uintptr_t)(vfsp) >> 4) % PORTFOP_PVFSHASH_SZ)
287df2381bfSpraks 
288df2381bfSpraks /*
289df2381bfSpraks  * file operations flag.
290df2381bfSpraks  */
291df2381bfSpraks 
292df2381bfSpraks /*
293df2381bfSpraks  * PORT_SOURCE_FILE - vnode operations
294df2381bfSpraks  */
295df2381bfSpraks 
296df2381bfSpraks #define	FOP_FILE_OPEN		0x00000001
297df2381bfSpraks #define	FOP_FILE_READ		0x00000002
298df2381bfSpraks #define	FOP_FILE_WRITE		0x00000004
299df2381bfSpraks #define	FOP_FILE_MAP		0x00000008
300df2381bfSpraks #define	FOP_FILE_IOCTL		0x00000010
301df2381bfSpraks #define	FOP_FILE_CREATE		0x00000020
302df2381bfSpraks #define	FOP_FILE_MKDIR		0x00000040
303df2381bfSpraks #define	FOP_FILE_SYMLINK	0x00000080
304df2381bfSpraks #define	FOP_FILE_LINK		0x00000100
305df2381bfSpraks #define	FOP_FILE_RENAME		0x00000200
306df2381bfSpraks #define	FOP_FILE_REMOVE		0x00000400
307df2381bfSpraks #define	FOP_FILE_RMDIR		0x00000800
308df2381bfSpraks #define	FOP_FILE_READDIR	0x00001000
309df2381bfSpraks #define	FOP_FILE_RENAMESRC	0x00002000
310df2381bfSpraks #define	FOP_FILE_RENAMEDST	0x00004000
311df2381bfSpraks #define	FOP_FILE_REMOVEFILE	0x00008000
312df2381bfSpraks #define	FOP_FILE_REMOVEDIR	0x00010000
313df2381bfSpraks #define	FOP_FILE_SETSECATTR	0x00020000
314df2381bfSpraks #define	FOP_FILE_SETATTR_ATIME	0x00040000
315df2381bfSpraks #define	FOP_FILE_SETATTR_MTIME	0x00080000
316df2381bfSpraks #define	FOP_FILE_SETATTR_CTIME	0x00100000
317df2381bfSpraks #define	FOP_FILE_LINK_SRC	0x00200000
318*72102e74SBryan Cantrill #define	FOP_FILE_TRUNC		0x00400000
319df2381bfSpraks 
320df2381bfSpraks /*
321df2381bfSpraks  * File modification event.
322df2381bfSpraks  */
323df2381bfSpraks #define	FOP_MODIFIED_MASK	(FOP_FILE_WRITE|FOP_FILE_CREATE \
324df2381bfSpraks 				|FOP_FILE_REMOVE|FOP_FILE_LINK \
325df2381bfSpraks 				|FOP_FILE_RENAMESRC|FOP_FILE_RENAMEDST \
326df2381bfSpraks 				|FOP_FILE_MKDIR|FOP_FILE_RMDIR \
327df2381bfSpraks 				|FOP_FILE_SYMLINK|FOP_FILE_SETATTR_MTIME)
328df2381bfSpraks 
329df2381bfSpraks /*
330df2381bfSpraks  * File access event
331df2381bfSpraks  */
332df2381bfSpraks #define	FOP_ACCESS_MASK		(FOP_FILE_READ|FOP_FILE_READDIR \
333df2381bfSpraks 				|FOP_FILE_MAP|FOP_FILE_SETATTR_ATIME)
334df2381bfSpraks 
335df2381bfSpraks /*
336df2381bfSpraks  * File attrib event
337df2381bfSpraks  */
338df2381bfSpraks #define	FOP_ATTRIB_MASK		(FOP_FILE_WRITE|FOP_FILE_CREATE \
339df2381bfSpraks 				|FOP_FILE_REMOVE|FOP_FILE_LINK \
340df2381bfSpraks 				|FOP_FILE_RENAMESRC|FOP_FILE_RENAMEDST \
341df2381bfSpraks 				|FOP_FILE_MKDIR|FOP_FILE_RMDIR \
342df2381bfSpraks 				|FOP_FILE_SYMLINK|FOP_FILE_SETATTR_CTIME \
343df2381bfSpraks 				|FOP_FILE_LINK_SRC|FOP_FILE_SETSECATTR)
344df2381bfSpraks 
345df2381bfSpraks 
346df2381bfSpraks /*
347*72102e74SBryan Cantrill  * File trunc event
348*72102e74SBryan Cantrill  */
349*72102e74SBryan Cantrill #define	FOP_TRUNC_MASK		(FOP_FILE_TRUNC|FOP_FILE_CREATE)
350*72102e74SBryan Cantrill 
351*72102e74SBryan Cantrill /*
352df2381bfSpraks  * valid watchable events
353df2381bfSpraks  */
354df2381bfSpraks #define	FILE_EVENTS_MASK	(FILE_ACCESS|FILE_MODIFIED|FILE_ATTRIB \
355*72102e74SBryan Cantrill 				|FILE_NOFOLLOW|FILE_TRUNC)
356df2381bfSpraks /* --- End file events --- */
357df2381bfSpraks 
358df2381bfSpraks /*
3597c478bd9Sstevel@tonic-gate  * port_kstat_t contains the event port kernel values which are
3607c478bd9Sstevel@tonic-gate  * exported to kstat.
3617c478bd9Sstevel@tonic-gate  * Currently only the number of active ports is exported.
3627c478bd9Sstevel@tonic-gate  */
3637c478bd9Sstevel@tonic-gate typedef struct port_kstat {
3647c478bd9Sstevel@tonic-gate 	kstat_named_t	pks_ports;
3657c478bd9Sstevel@tonic-gate } port_kstat_t;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate /* misc functions */
3687c478bd9Sstevel@tonic-gate int	port_alloc_event_block(port_t *, int, int, struct port_kevent **);
3697c478bd9Sstevel@tonic-gate void	port_push_eventq(port_queue_t *);
370df2381bfSpraks int	port_remove_done_event(struct port_kevent *);
3717c478bd9Sstevel@tonic-gate struct	port_kevent *port_get_kevent(list_t *, struct port_kevent *);
37234709573Sraf void	port_block(port_queue_t *);
37334709573Sraf void	port_unblock(port_queue_t *);
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /* PORT_SOURCE_FD cache management */
3767c478bd9Sstevel@tonic-gate void port_pcache_remove_fd(port_fdcache_t *, portfd_t *);
3779f23d599Spraks int port_remove_fd_object(portfd_t *, struct port *, port_fdcache_t *);
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate /* file close management */
3807c478bd9Sstevel@tonic-gate extern void addfd_port(int, portfd_t *);
3817c478bd9Sstevel@tonic-gate extern void delfd_port(int, portfd_t *);
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3867c478bd9Sstevel@tonic-gate }
3877c478bd9Sstevel@tonic-gate #endif
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate #endif	/* _SYS_PORT_IMPL_H */
390