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