42
|
1 |
/*
|
|
2 |
* sam/types.h - SAM-FS types.
|
|
3 |
*
|
|
4 |
* Description:
|
|
5 |
* Defines SAM-FS types and lots of other things.
|
|
6 |
*
|
|
7 |
*/
|
|
8 |
|
|
9 |
/*
|
|
10 |
* SAM-QFS_notice_begin
|
|
11 |
*
|
|
12 |
* Solaris 2.x Sun Storage & Archiving Management File System
|
|
13 |
*
|
|
14 |
* Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
15 |
*
|
|
16 |
* U.S. Government Rights - Commercial software. Government users are
|
|
17 |
* subject to the Sun Microsystems, Inc. standard license agreement and applicable
|
|
18 |
* provisions of the FAR and its supplements.
|
|
19 |
*
|
|
20 |
* Use is subject to license terms. Sun, Sun Microsystems and the Sun logo
|
|
21 |
* are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S.
|
|
22 |
* and other countries.
|
|
23 |
*
|
|
24 |
* SAM-QFS_notice_end
|
|
25 |
*/
|
|
26 |
|
|
27 |
/*
|
|
28 |
* LGPL NOTICE
|
|
29 |
*
|
|
30 |
* This library is free software; you can redistribute it and/or
|
|
31 |
* modify it under the terms of the GNU Lesser General Public
|
|
32 |
* License as published by the Free Software Foundation; either
|
|
33 |
* version 2.1 of the License, or (at your option) any later version.
|
|
34 |
*
|
|
35 |
* This library is distributed in the hope that it will be useful,
|
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
38 |
* Lesser General Public License for more details.
|
|
39 |
*
|
|
40 |
* You should have received a copy of the GNU Lesser General Public
|
|
41 |
* License along with this library; if not, write to the Free Software
|
|
42 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
43 |
*/
|
|
44 |
|
|
45 |
#ifndef _SAM_TYPES_H
|
|
46 |
#define _SAM_TYPES_H
|
|
47 |
|
|
48 |
#ifdef sun
|
|
49 |
#pragma ident "$Revision$"
|
|
50 |
#endif
|
|
51 |
|
|
52 |
#ifdef linux
|
|
53 |
|
|
54 |
#ifndef __KERNEL__
|
|
55 |
#include <sys/types.h>
|
|
56 |
#include <netdb.h>
|
|
57 |
#endif /* __KERNEL__ */
|
|
58 |
|
|
59 |
#else /* linux */
|
|
60 |
|
|
61 |
#include <sys/types.h>
|
|
62 |
#include <netdb.h>
|
|
63 |
|
|
64 |
#endif /* linux */
|
|
65 |
|
|
66 |
#include "sam-sys_types.h"
|
|
67 |
|
|
68 |
/*
|
|
69 |
* These typedefs are part of an emerging ANSI-C standard for fixed-size
|
|
70 |
* integer types.
|
|
71 |
* They are available in Solaris 2.6 (and above) in /usr/include/sys/types.h.
|
|
72 |
*/
|
|
73 |
|
|
74 |
#if defined _SYS_INT_TYPES_H
|
|
75 |
/*
|
|
76 |
* (uint8_t, uint32_t and uint64_t are defined in Solaris 2.5
|
|
77 |
* /usr/include/sys/synch.h.
|
|
78 |
*/
|
|
79 |
#define _UINT8_T
|
|
80 |
#define _UINT16_T
|
|
81 |
#define _INT32_T
|
|
82 |
#define _UINT32_T
|
|
83 |
#define _INT64_T
|
|
84 |
#define _UINT64_T
|
|
85 |
#endif /* defined _SYS_INTTYPES_H */
|
|
86 |
|
|
87 |
#if !defined _UINT8_T
|
|
88 |
#define _UINT8_T
|
|
89 |
typedef unsigned char uint8_t;
|
|
90 |
#endif /* !defined _UINT8_T */
|
|
91 |
#if !defined _UINT16_T
|
|
92 |
#define _UINT16_T
|
|
93 |
typedef unsigned short uint16_t;
|
|
94 |
#endif /* !defined uint16_t */
|
|
95 |
#if !defined _INT32_T
|
|
96 |
#define _INT32_T
|
|
97 |
typedef int int32_t;
|
|
98 |
#endif /* !defined _INT32_T */
|
|
99 |
#if !defined _UINT32_T
|
|
100 |
#define _UINT32_T
|
|
101 |
typedef unsigned int uint32_t;
|
|
102 |
#endif /* !defined _UINT32_T */
|
|
103 |
#if !defined _INT64_T
|
|
104 |
#define _INT64_T
|
|
105 |
typedef long long int64_t;
|
|
106 |
#endif /* !defined _INT64_T */
|
|
107 |
#if !defined _UINT64_T
|
|
108 |
#define _UINT64_T
|
|
109 |
typedef unsigned long long uint64_t;
|
|
110 |
#endif /* !defined _UINT64_T */
|
|
111 |
|
|
112 |
#if !defined(FALSE)
|
|
113 |
#define FALSE (0)
|
|
114 |
#endif
|
|
115 |
#if !defined(TRUE)
|
|
116 |
#define TRUE (1)
|
|
117 |
#endif
|
|
118 |
|
|
119 |
/* The following is for the lawyers */
|
|
120 |
#define COPYRIGHT "Copyright (c) 2001 Sun Microsystems, Inc. All Rights Reserved. SUN PROPRIETARY/CONFIDENTIAL."
|
|
121 |
|
|
122 |
#define RESELL_LIB "libresel.so"
|
|
123 |
|
|
124 |
/*
|
|
125 |
* Set errno for MT and non-MT callers.
|
|
126 |
* errno is defined differently for MT and non-MT compiled modules.
|
|
127 |
* This macro may be used to properly return errno for both types
|
|
128 |
* of modules linked to non-MT compiled library modules.
|
|
129 |
* The underlying Solaris errno function is ___errno().
|
|
130 |
*/
|
|
131 |
extern int *___errno(void);
|
|
132 |
#define SetErrno (*(___errno()))
|
|
133 |
|
|
134 |
/*
|
|
135 |
* Return the difference between two pointers.
|
|
136 |
* lint produces warning: possible ptrdiff_t overflow when two pointers
|
|
137 |
* are subtracted.
|
|
138 |
* Returns 0 if the difference is negative.
|
|
139 |
* The 'lint' version obviously will not do the work.
|
|
140 |
*/
|
|
141 |
#if !defined(lint)
|
|
142 |
#define Ptrdiff(a, b) ((((char *)(a) - (char *)(b)) > 0) ? \
|
|
143 |
((char *)(a) - (char *)(b)) : 0)
|
|
144 |
#else /* !defined(lint) */
|
|
145 |
#define Ptrdiff(a, b) (memcmp((a), (b), 1))
|
|
146 |
#endif /* !defined(lint) */
|
|
147 |
|
|
148 |
/*
|
|
149 |
* Round value to be structure aligned.
|
|
150 |
* Structures may have a size that is not a multiple of 64-bits.
|
|
151 |
* When these structures are packed in a file that will be memory
|
|
152 |
* mapped, the size must be rounded to a 64-bit multiple for SPARC
|
|
153 |
* and a 32-bit multiple for AMD.
|
|
154 |
*/
|
|
155 |
#if defined(__sparc)
|
|
156 |
#define STRUCT_RND(v) ((((v)+sizeof (longlong_t)-1) \
|
|
157 |
/ sizeof (longlong_t)) * sizeof (longlong_t))
|
|
158 |
#elif defined(__i386) || defined(__amd64) || defined(x86_64) || defined(ia64)
|
|
159 |
#define STRUCT_RND(v) ((((v)+sizeof (int32_t)-1) \
|
|
160 |
/ sizeof (int32_t)) * sizeof (int32_t))
|
|
161 |
#else
|
|
162 |
** ERROR ** unknown architecture
|
|
163 |
#endif
|
|
164 |
|
|
165 |
/*
|
|
166 |
* All filesystem OTW structures must be 64-bit aligned,
|
|
167 |
* regardless of the architecture for the server and clients.
|
|
168 |
*/
|
|
169 |
#define STRUCT_RND64(v) ((((v)+sizeof (longlong_t)-1) \
|
|
170 |
/ sizeof (longlong_t)) * sizeof (longlong_t))
|
|
171 |
|
|
172 |
#if defined(O_LARGEFILE) /* Needed on open for large files */
|
|
173 |
#define SAM_O_LARGEFILE O_LARGEFILE
|
|
174 |
#else
|
|
175 |
#define SAM_O_LARGEFILE 0
|
|
176 |
#endif
|
|
177 |
|
|
178 |
#define SAM_FSTYPE "samfs" /* st_fstype string for SAM-FS */
|
|
179 |
|
|
180 |
#define ROBOT_NO_SLOT 0xffffffff /* used to flag no slot. */
|
|
181 |
|
|
182 |
/*
|
|
183 |
* When the space left on a tape (in units of 1024) falls below this,
|
|
184 |
* the tape will be considered full.
|
|
185 |
*/
|
|
186 |
#define TAPE_IS_FULL 100
|
|
187 |
|
|
188 |
/*
|
|
189 |
* HASAM running file
|
|
190 |
*/
|
|
191 |
|
|
192 |
#define HASAM_TMP_DIR "/var/run"
|
|
193 |
#define HASAM_RUN_FILE HASAM_TMP_DIR"/hasam_running"
|
|
194 |
|
|
195 |
#define BARCODE_LEN 36 /* length of barcode w/o null by */
|
|
196 |
|
|
197 |
typedef int ATOM_INT_T; /* Int with atomic memory reference */
|
|
198 |
|
|
199 |
typedef uint64_t fsize_t; /* Size of a file in bytes */
|
|
200 |
typedef int64_t sfsize_t;
|
|
201 |
#define FSIZE_MAX 0x7fffffffffffffff
|
|
202 |
|
|
203 |
typedef char uname_t[32]; /* Device name */
|
|
204 |
typedef char upath_t[128]; /* Path name */
|
|
205 |
|
|
206 |
typedef char mtype_t[5]; /* Media type */
|
|
207 |
typedef char vsn_t[32]; /* ANSI Volume serial name, 31 chars */
|
|
208 |
/* null terminated */
|
|
209 |
/* Tape VSNs are 6 chars or less */
|
|
210 |
|
|
211 |
typedef char host_t[MAXHOSTNAMELEN]; /* Host name */
|
|
212 |
|
|
213 |
typedef uint16_t media_t; /* Media type */
|
|
214 |
typedef uint16_t dtype_t; /* Device type */
|
|
215 |
typedef uint16_t equ_t; /* Equipment ordinal */
|
|
216 |
#define EQU_MAX 65534 /* Maximum value for equipment ordinal */
|
|
217 |
/* (need one reserved for historian) */
|
|
218 |
|
|
219 |
/*
|
|
220 |
* Common memory mapped file prefix.
|
|
221 |
* If the MfValid field becomes zero, the file should be renewed.
|
|
222 |
* MapFileDetach() then MapFileAttach().
|
|
223 |
*/
|
|
224 |
typedef struct MappedFile {
|
|
225 |
uint32_t MfMagic; /* Magic number of file */
|
|
226 |
uint32_t MfLen; /* Length of file mapped */
|
|
227 |
uint32_t MfValid; /* File valid if non-zero */
|
|
228 |
} MappedFile_t;
|
|
229 |
|
|
230 |
typedef uint32_t sam_ino_t;
|
|
231 |
|
|
232 |
typedef struct sam_id { /* Inode identification */
|
|
233 |
sam_ino_t ino; /* I-number */
|
|
234 |
int32_t gen; /* Generation number */
|
|
235 |
} sam_id_t;
|
|
236 |
|
|
237 |
typedef struct csum { /* Data verification value */
|
|
238 |
uint32_t csum_val[4];
|
|
239 |
} csum_t;
|
|
240 |
|
|
241 |
typedef int32_t sam_time_t; /* 32-bit time */
|
|
242 |
|
|
243 |
typedef struct sam_timestruc {
|
|
244 |
int32_t tv_sec;
|
|
245 |
int32_t tv_nsec;
|
|
246 |
} sam_timestruc_t;
|
|
247 |
|
|
248 |
typedef struct sam_flagtext {
|
|
249 |
uint64_t flagmask;
|
|
250 |
char *flagtext;
|
|
251 |
} sam_flagtext_t;
|
|
252 |
|
|
253 |
#define SAM_POINTER(t) union { t *ptr; uint32_t p32; uint64_t p64; }
|
|
254 |
|
|
255 |
|
|
256 |
/*
|
|
257 |
* the following used in the SC_fsreleaser system call
|
|
258 |
*/
|
|
259 |
#define RELEASER_STARTED 1
|
|
260 |
#define RELEASER_FINISHED 0
|
|
261 |
|
|
262 |
#define DF_THR_STK (0)
|
|
263 |
#define SM_THR_STK DF_THR_STK
|
|
264 |
#define MD_THR_STK DF_THR_STK
|
|
265 |
#define LG_THR_STK DF_THR_STK
|
|
266 |
#define HG_THR_STK DF_THR_STK
|
|
267 |
|
|
268 |
/*
|
|
269 |
* Rounding directions
|
|
270 |
*/
|
|
271 |
typedef enum sam_round {
|
|
272 |
SAM_ROUND_DOWN = 0,
|
|
273 |
SAM_ROUND_UP = 1
|
|
274 |
} sam_round_t;
|
|
275 |
|
|
276 |
#endif /* _SAM_TYPES_H */
|