blob: 925da85c2831ac7f04235aaddc5e0dfb93e07eee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*
* 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
* or http://www.opensolaris.org/os/licensing.
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DEVCACHE_IMPL_H
#define _SYS_DEVCACHE_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/list.h>
/*
* /etc/devices cache files format
* Leave some padding for easy extension in the future
*/
#define NVPF_HDR_MAGIC 0xdeb1dcac
#define NVPF_HDR_VERSION 1
#define NVPF_HDR_SIZE 128
typedef struct nvpacked_file_hdr {
union {
struct nvfp_hdr {
uint32_t magic;
int32_t version;
int64_t size;
uint16_t hdr_chksum;
uint16_t chksum;
} nvpf;
uchar_t nvpf_pad[NVPF_HDR_SIZE];
} un;
} nvpf_hdr_t;
#define nvpf_magic un.nvpf.magic
#define nvpf_version un.nvpf.version
#define nvpf_size un.nvpf.size
#define nvpf_hdr_chksum un.nvpf.hdr_chksum
#define nvpf_chksum un.nvpf.chksum
#ifdef _KERNEL
/*
* Descriptor used for kernel-level file i/o
*/
typedef struct kfile {
struct vnode *kf_vp;
int kf_vnflags;
char *kf_fname;
offset_t kf_fpos;
int kf_state;
} kfile_t;
/*
* File descriptor for files in the nvlist format
*/
typedef struct nvfiledesc nvfd_t;
/*
* Descriptor for a file managed as a backing store for some
* kernel-generated device state such as device devids,
* vhci-to-phci mapping, etc.
* Each client can manage the data in any form convenient.
* providing functions to unpack (read) and pack (write)
* the data as an nvlist.
*
* Clients should not reference this structure directly
* but through the handle returned when registering.
*/
struct nvfiledesc {
nvf_ops_t *nvf_ops; /* client ops vectors */
int nvf_flags; /* flags */
list_t nvf_data_list; /* data list */
krwlock_t nvf_lock; /* lock for data list */
list_node_t nvf_link; /* link to next file desc */
};
/*
* nvf_flags
*/
#define NVF_F_DIRTY 0x01 /* needs to be flushed */
#define NVF_F_FLUSHING 0x02 /* in process of being flushed */
#define NVF_F_ERROR 0x04 /* most recent flush failed */
#define NVF_F_READONLY 0x10 /* file is read-only */
#define NVF_F_CREATE_MSG 0x20 /* file not found on boot, emit msg */
#define NVF_F_REBUILD_MSG 0x40 /* file was found corrupted, emit msg */
#define NVF_IS_DIRTY(nvfd) ((nvfd)->nvf_flags & NVF_F_DIRTY)
#define NVF_MARK_DIRTY(nvfd) ((nvfd)->nvf_flags |= NVF_F_DIRTY)
#define NVF_CLEAR_DIRTY(nvfd) ((nvfd)->nvf_flags &= ~NVF_F_DIRTY)
#define NVF_IS_READONLY(nvfd) ((nvfd)->nvf_flags & NVF_F_READONLY)
#define NVF_MARK_READONLY(nvfd) ((nvfd)->nvf_flags |= NVF_F_READONLY)
/* shorthand to client ops */
#define nvf_cache_path nvf_ops->nvfr_cache_path
#define nvf_unpack_nvlist nvf_ops->nvfr_unpack_nvlist
#define nvf_pack_list nvf_ops->nvfr_pack_list
#define nvf_list_free nvf_ops->nvfr_list_free
#define nvf_write_complete nvf_ops->nvfr_write_complete
/*
* More thorough error reporting available both debug &
* non-debug kernels, but turned off by default.
*/
extern int kfio_report_error; /* kernel file i/o operations */
/*
* Suffix of temporary file for updates
*/
#define MAX_SUFFIX_LEN 4
#define NEW_FILENAME_SUFFIX "new"
#ifdef DEBUG
#define NVPDAEMON_DEBUG(args) { if (nvpdaemon_debug) cmn_err args; }
#define KFDEBUG(args) { if (kfio_debug) cmn_err args; }
#define KFDEBUG1(args) { if (kfio_debug > 1) cmn_err args; }
#define KFDEBUG2(args) { if (kfio_debug > 2) cmn_err args; }
#define KFDUMP(args) { if (kfio_debug > 2) args; }
#else
#define NVPDAEMON_DEBUG(args)
#define KFDEBUG(args)
#define KFDEBUG1(args)
#define KFDEBUG2(args)
#define KFDUMP(args)
#endif /* DEBUG */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DEVCACHE_IMPL_H */
|