xref: /illumos-gate/usr/src/uts/common/sys/devcache.h (revision 2d6eb4a5)
1*83c4dfe9Sjg /*
2*83c4dfe9Sjg  * CDDL HEADER START
3*83c4dfe9Sjg  *
4*83c4dfe9Sjg  * The contents of this file are subject to the terms of the
5*83c4dfe9Sjg  * Common Development and Distribution License (the "License").
6*83c4dfe9Sjg  * You may not use this file except in compliance with the License.
7*83c4dfe9Sjg  *
8*83c4dfe9Sjg  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*83c4dfe9Sjg  * or http://www.opensolaris.org/os/licensing.
10*83c4dfe9Sjg  * See the License for the specific language governing permissions
11*83c4dfe9Sjg  * and limitations under the License.
12*83c4dfe9Sjg  *
13*83c4dfe9Sjg  * When distributing Covered Code, include this CDDL HEADER in each
14*83c4dfe9Sjg  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*83c4dfe9Sjg  * If applicable, add the following below this CDDL HEADER, with the
16*83c4dfe9Sjg  * fields enclosed by brackets "[]" replaced with your own identifying
17*83c4dfe9Sjg  * information: Portions Copyright [yyyy] [name of copyright owner]
18*83c4dfe9Sjg  *
19*83c4dfe9Sjg  * CDDL HEADER END
20*83c4dfe9Sjg  */
21*83c4dfe9Sjg /*
22*83c4dfe9Sjg  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*83c4dfe9Sjg  * Use is subject to license terms.
24*83c4dfe9Sjg  */
25*83c4dfe9Sjg 
26*83c4dfe9Sjg #ifndef	_SYS_DEVCACHE_H
27*83c4dfe9Sjg #define	_SYS_DEVCACHE_H
28*83c4dfe9Sjg 
29*83c4dfe9Sjg #ifdef	__cplusplus
30*83c4dfe9Sjg extern "C" {
31*83c4dfe9Sjg #endif
32*83c4dfe9Sjg 
33*83c4dfe9Sjg #include <sys/list.h>
34*83c4dfe9Sjg 
35*83c4dfe9Sjg #ifdef	_KERNEL
36*83c4dfe9Sjg 
37*83c4dfe9Sjg /*
38*83c4dfe9Sjg  * Handle reference to a registered file
39*83c4dfe9Sjg  */
40*83c4dfe9Sjg typedef struct __nvf_handle *nvf_handle_t;
41*83c4dfe9Sjg 
42*83c4dfe9Sjg /*
43*83c4dfe9Sjg  * Registration descriptor for a cache file within /etc/devices
44*83c4dfe9Sjg  *
45*83c4dfe9Sjg  * path			- cache file path path
46*83c4dfe9Sjg  * unpack_list		- when reading, called to unpack nvlist
47*83c4dfe9Sjg  * pack_list		- when writing, called to pack nvlist
48*83c4dfe9Sjg  * list_free		- free data contained within list
49*83c4dfe9Sjg  * write_complete	- called when write is completed
50*83c4dfe9Sjg  */
51*83c4dfe9Sjg typedef struct nvf_ops {
52*83c4dfe9Sjg 	char		*nvfr_cache_path;
53*83c4dfe9Sjg 	int		(*nvfr_unpack_nvlist)(nvf_handle_t, nvlist_t *, char *);
54*83c4dfe9Sjg 	int		(*nvfr_pack_list)(nvf_handle_t, nvlist_t **);
55*83c4dfe9Sjg 	void		(*nvfr_list_free)(nvf_handle_t);
56*83c4dfe9Sjg 	void		(*nvfr_write_complete)(nvf_handle_t);
57*83c4dfe9Sjg } nvf_ops_t;
58*83c4dfe9Sjg 
59*83c4dfe9Sjg /*
60*83c4dfe9Sjg  * Client interfaces
61*83c4dfe9Sjg  */
62*83c4dfe9Sjg 
63*83c4dfe9Sjg nvf_handle_t	nvf_register_file(nvf_ops_t *);
64*83c4dfe9Sjg int		nvf_read_file(nvf_handle_t);
65*83c4dfe9Sjg void		nvf_wake_daemon(void);
66*83c4dfe9Sjg void		nvf_error(const char *, ...);
67*83c4dfe9Sjg char		*nvf_cache_name(nvf_handle_t);
68*83c4dfe9Sjg krwlock_t	*nvf_lock(nvf_handle_t);
69*83c4dfe9Sjg list_t		*nvf_list(nvf_handle_t);
70*83c4dfe9Sjg void		nvf_mark_dirty(nvf_handle_t);
71*83c4dfe9Sjg int		nvf_is_dirty(nvf_handle_t);
72*83c4dfe9Sjg 
73*83c4dfe9Sjg #endif	/* _KERNEL */
74*83c4dfe9Sjg 
75*83c4dfe9Sjg #ifdef	__cplusplus
76*83c4dfe9Sjg }
77*83c4dfe9Sjg #endif
78*83c4dfe9Sjg 
79*83c4dfe9Sjg #endif	/* _SYS_DEVCACHE_H */
80