xref: /titanic_41/usr/src/uts/common/sys/lvm/md_names.h (revision 82629e3015252bf18319ba3815c773df23e21436)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_MD_NAMES_H
28 #define	_SYS_MD_NAMES_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	NM_ALLOC_SIZE	512
37 #define	NM_DID_ALLOC_SIZE	1024
38 
39 #define	NM_NOCOMMIT	0x0100
40 #define	NM_SHARED	1
41 #define	NM_NOTSHARED	0
42 #define	NM_DEVID	0x0010
43 #define	NM_IMP_SHARED	0x0020
44 #define	NM_DEVID_VALID		1
45 #define	NM_DEVID_INVALID	0
46 
47 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
48 #pragma pack(4)
49 #endif
50 
51 #ifdef _KERNEL
52 struct nm_rec_hdr {
53 	uint_t		r_revision;	/* revision number */
54 	uint_t		r_alloc_size;	/* alloc'd record size */
55 	uint_t		r_used_size;	/* number bytes used */
56 	mddb_recid_t	r_next_recid;	/* record id of next record */
57 	uint32_t	xr_next_rec;	/* ptr to record, calc at boot */
58 	mdkey_t		r_next_key;	/* Next key for alloc'd entry */
59 };
60 #else /* ! _KERNEL */
61 struct nm_rec_hdr {
62 	uint_t		r_revision;	/* revision number */
63 	uint_t		r_alloc_size;	/* alloc'd record size */
64 	uint_t		r_used_size;	/* number bytes used */
65 	mddb_recid_t	r_next_recid;	/* record id of next record */
66 	void		*r_next_rec;	/* ptr to record, calc at boot */
67 	mdkey_t		r_next_key;	/* Next key for alloc'd entry */
68 };
69 #endif /* _KERNEL */
70 
71 struct nm_next_hdr {
72 	struct nm_next_hdr	*nmn_nextp;
73 	void			*nmn_record;
74 };
75 
76 struct nm_shr_rec {
77 	struct nm_rec_hdr	sr_rec_hdr;	/* Record header */
78 	struct	nm_shared_name {
79 		mdkey_t	sn_key;		/* Unique key for this name */
80 		uint32_t sn_count;	/* Count of users of this name */
81 		uint32_t sn_data;	/* Data ptr for users (e.g., devops */
82 					/* sn_data NOT USED anywhere */
83 		ushort_t sn_namlen;	/* Length of string in nmsn_name */
84 		char	sn_name[1];	/* Driver/Directory name */
85 	} sr_name[1];
86 };
87 
88 #define	SHR_NAMSIZ(n) \
89 	(((sizeof (struct nm_shared_name) - 1) + \
90 	    (n)->sn_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1))
91 
92 struct nm_rec {
93 	struct nm_rec_hdr	r_rec_hdr;	/* Record header */
94 	struct nm_name {
95 		side_t	n_side;		/* (key 1) side associated with */
96 		mdkey_t	n_key;		/* (key 2) allocated unique key */
97 		uint32_t n_count;	/* reference count */
98 		minor_t	n_minor;	/* minor number of device */
99 		mdkey_t	n_drv_key;	/* Key of driver name in nm_shared */
100 		mdkey_t	n_dir_key;	/* Key of dir. name in nm_shared */
101 		ushort_t n_namlen;	/* Length of string in nme_name */
102 		char	n_name[1];	/* Filename of device is here */
103 	} r_name[1];
104 };
105 
106 #define	NAMSIZ(n) \
107 	(((sizeof (struct nm_name) - 1) + \
108 	    (n)->n_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1))
109 
110 /*
111  * Device id support
112  */
113 struct devid_shr_rec {
114 	struct nm_rec_hdr	did_rec_hdr;
115 	struct did_shr_name {
116 		mdkey_t	did_key;
117 		uint32_t did_count;
118 		uint32_t did_data;
119 		ushort_t did_size;
120 		char	did_devid[1];
121 	} device_id[1];
122 };
123 
124 #define	DID_SHR_NAMSIZ(n) \
125 	(((sizeof (struct did_shr_name) - 1) + \
126 	    (n)->did_size + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1))
127 
128 
129 struct devid_min_rec {
130 	struct nm_rec_hdr	min_rec_hdr;
131 	struct did_min_name {
132 		side_t	min_side;
133 		mdkey_t	min_key;
134 		uint32_t min_count;
135 		mdkey_t	min_devid_key;
136 		ushort_t min_namlen;
137 		char	min_name[1];
138 	} minor_name[1];
139 };
140 
141 #define	DID_NAMSIZ(n) \
142 	(((sizeof (struct did_min_name) - 1) + \
143 	    (n)->min_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1))
144 
145 
146 struct nm_header {
147 	uint_t			h_revision;	/* revision number */
148 	struct nm_rec_hdr	h_names;	/* device-name structures */
149 	struct nm_rec_hdr	h_shared;	/* shared structures */
150 };
151 
152 struct nm_header_hdr {
153 	struct nm_header	*hh_header;
154 	struct nm_next_hdr	hh_names;
155 	struct nm_next_hdr	hh_shared;
156 };
157 
158 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
159 #pragma pack()
160 #endif
161 
162 #ifdef	__cplusplus
163 }
164 #endif
165 
166 #endif	/* _SYS_MD_NAMES_H */
167