1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 #if !(defined H5O_FRIEND || defined H5O_MODULE)
15 #error "Do not include this file outside the H5O package!"
16 #endif
17 
18 #ifndef _H5Opkg_H
19 #define _H5Opkg_H
20 
21 /* Get package's private header */
22 #include "H5Oprivate.h"		/* Object headers		  	*/
23 
24 /* Other private headers needed by this file */
25 #include "H5ACprivate.h"        /* Metadata cache                       */
26 #include "H5FLprivate.h"	/* Free Lists                           */
27 
28 /* Object header macros */
29 #define H5O_NMESGS	8 		/*initial number of messages	     */
30 #define H5O_NCHUNKS	2		/*initial number of chunks	     */
31 #define H5O_MIN_SIZE	22		/* Min. obj header data size (must be big enough for a message prefix and a continuation message) */
32 #define H5O_MSG_TYPES   27              /* # of types of messages            */
33 #define H5O_MAX_CRT_ORDER_IDX 65535     /* Max. creation order index value   */
34 
35 /* Versions of object header structure */
36 
37 /* Initial version of the object header format */
38 #define H5O_VERSION_1		1
39 
40 /* Revised version - leaves out reserved bytes and alignment padding, and adds
41  *      magic number as prefix and checksum as suffix for all chunks.
42  */
43 #define H5O_VERSION_2		2
44 
45 /* The latest version of the format.  Look through the 'flush'
46  *      and 'size' callback for places to change when updating this. */
47 #define H5O_VERSION_LATEST	H5O_VERSION_2
48 
49 /*
50  * Align messages on 8-byte boundaries because we would like to copy the
51  * object header chunks directly into memory and operate on them there, even
52  * on 64-bit architectures.  This allows us to reduce the number of disk I/O
53  * requests with a minimum amount of mem-to-mem copies.
54  *
55  * Note: We no longer attempt to do this. - QAK, 10/16/06
56  */
57 #define H5O_ALIGN_OLD(X)	(8 * (((X) + 7) / 8))
58 #define H5O_ALIGN_VERS(V, X)						      \
59     (((V) == H5O_VERSION_1) ?						      \
60 		H5O_ALIGN_OLD(X)					      \
61         :								      \
62 		(X)							      \
63     )
64 #define H5O_ALIGN_OH(O, X)						      \
65      H5O_ALIGN_VERS((O)->version, X)
66 #define H5O_ALIGN_F(F, X)						      \
67      H5O_ALIGN_VERS((H5F_USE_LATEST_FLAGS(F, H5F_LATEST_OBJ_HEADER) ? H5O_VERSION_LATEST : H5O_VERSION_1), X)
68 
69 /* Size of checksum (on disk) */
70 #define H5O_SIZEOF_CHKSUM               4
71 
72 /* ========= Object Creation properties ============ */
73 /* Default values for some of the object creation properties */
74 /* NOTE: The H5O_CRT_ATTR_MAX_COMPACT_DEF & H5O_CRT_ATTR_MIN_DENSE_DEF values
75  *      are "built into" the file format, make certain existing files with
76  *      default attribute phase change storage are handled correctly if they
77  *      are changed.
78  */
79 #define H5O_CRT_ATTR_MAX_COMPACT_DEF    8
80 #define H5O_CRT_ATTR_MIN_DENSE_DEF      6
81 #define H5O_CRT_OHDR_FLAGS_DEF          H5O_HDR_STORE_TIMES
82 
83 /* Object header status flag definitions */
84 #define H5O_HDR_CHUNK0_1                0x00    /* Use 1-byte value for chunk #0 size */
85 #define H5O_HDR_CHUNK0_2                0x01    /* Use 2-byte value for chunk #0 size */
86 #define H5O_HDR_CHUNK0_4                0x02    /* Use 4-byte value for chunk #0 size */
87 #define H5O_HDR_CHUNK0_8                0x03    /* Use 8-byte value for chunk #0 size */
88 
89 /*
90  * Size of object header prefix.
91  */
92 #define H5O_SIZEOF_HDR(O)						      \
93     (((O)->version == H5O_VERSION_1)  					      \
94         ?								      \
95             H5O_ALIGN_OLD(1 +	/*version number	*/		      \
96                 1 +		/*reserved 		*/		      \
97                 2 +		/*number of messages	*/		      \
98                 4 +		/*reference count	*/		      \
99                 4)		/*chunk data size	*/		      \
100         :								      \
101             (H5_SIZEOF_MAGIC +	/*magic number  	*/		      \
102                 1 +		/*version number 	*/		      \
103                 1 +		/*flags		 	*/		      \
104                 (((O)->flags & H5O_HDR_STORE_TIMES) ? (			      \
105                   4 +		/*access time		*/		      \
106                   4 +		/*modification time	*/		      \
107                   4 +		/*change time		*/		      \
108                   4		/*birth time		*/		      \
109                 ) : 0) +						      \
110                 (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? (	      \
111                   2 +		/*max compact attributes */		      \
112                   2		/*min dense attributes	*/		      \
113                 ) : 0) +						      \
114                 (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \
115                 H5O_SIZEOF_CHKSUM) /*checksum size	*/		      \
116     )
117 
118 /*
119  * Size of object header message prefix
120  */
121 #define H5O_SIZEOF_MSGHDR_VERS(V,C)					      \
122     (((V) == H5O_VERSION_1)  						      \
123         ?								      \
124             H5O_ALIGN_OLD(2 +	/*message type		*/		      \
125                 2 +		/*sizeof message data	*/		      \
126                 1 +		/*flags              	*/		      \
127                 3)		/*reserved		*/		      \
128         :								      \
129             (1 +		/*message type		*/		      \
130                 2 + 		/*sizeof message data	*/		      \
131                 1 +		/*flags              	*/		      \
132                 ((C) ? (						      \
133                   2		/*creation index     	*/		      \
134                 ) : 0))							      \
135     )
136 #define H5O_SIZEOF_MSGHDR_OH(O)						      \
137     H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)
138 #define H5O_SIZEOF_MSGHDR_F(F, C)						      \
139     H5O_SIZEOF_MSGHDR_VERS((H5F_USE_LATEST_FLAGS(F, H5F_LATEST_OBJ_HEADER) || H5F_STORE_MSG_CRT_IDX(F)) ? H5O_VERSION_LATEST : H5O_VERSION_1, (C))
140 
141 /*
142  * Size of chunk "header" for each chunk
143  */
144 #define H5O_SIZEOF_CHKHDR_VERS(V)					      \
145     (((V) == H5O_VERSION_1)  						      \
146         ?								      \
147             0 +		/*no magic #  */				      \
148                 0 	/*no checksum */				      \
149         :								      \
150             H5_SIZEOF_MAGIC + 		/*magic #  */			      \
151                 H5O_SIZEOF_CHKSUM 	/*checksum */			      \
152     )
153 #define H5O_SIZEOF_CHKHDR_OH(O)						      \
154     H5O_SIZEOF_CHKHDR_VERS((O)->version)
155 
156 /*
157  * Size of checksum for each chunk
158  */
159 #define H5O_SIZEOF_CHKSUM_VERS(V)					      \
160     (((V) == H5O_VERSION_1)  						      \
161         ?								      \
162             0 		/*no checksum */				      \
163         :								      \
164             H5O_SIZEOF_CHKSUM 		/*checksum */			      \
165     )
166 #define H5O_SIZEOF_CHKSUM_OH(O)						      \
167     H5O_SIZEOF_CHKSUM_VERS((O)->version)
168 
169 /* Input/output flags for decode functions */
170 #define H5O_DECODEIO_NOCHANGE           0x01u   /* IN: do not modify values */
171 #define H5O_DECODEIO_DIRTY              0x02u   /* OUT: message has been changed */
172 
173 /* Macro to incremend ndecode_dirtied (only if we are debugging) */
174 #ifndef NDEBUG
175 #define INCR_NDECODE_DIRTIED(OH) (OH)->ndecode_dirtied++;
176 #else /* NDEBUG */
177 #define INCR_NDECODE_DIRTIED(OH) ;
178 #endif /* NDEBUG */
179 
180 /* Load native information for a message, if it's not already present */
181 /* (Only works for messages with decode callback) */
182 #define H5O_LOAD_NATIVE(F, DXPL, IOF, OH, MSG, ERR)                           \
183     if(NULL == (MSG)->native) {                                               \
184         const H5O_msg_class_t	*msg_type = (MSG)->type;                      \
185         unsigned                ioflags = (IOF);                              \
186                                                                               \
187         /* Decode the message */                                              \
188         HDassert(msg_type->decode);                                           \
189         if(NULL == ((MSG)->native = (msg_type->decode)((F), (DXPL), (OH), (MSG)->flags, &ioflags, (MSG)->raw))) \
190             HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
191                                                                               \
192         /* Mark the message dirty if it was changed by decoding */            \
193         if((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \
194             (MSG)->dirty = TRUE;                                              \
195             /* Increment the count of messages dirtied by decoding, but */    \
196             /* only ifndef NDEBUG */                                          \
197             INCR_NDECODE_DIRTIED(OH)                                          \
198         }                                                                     \
199                                                                               \
200         /* Set the message's "shared info", if it's shareable */	      \
201         if((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) {                           \
202             HDassert(msg_type->share_flags & H5O_SHARE_IS_SHARABLE);          \
203             H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, (MSG)->crt_idx, (OH)->chunk[0].addr) \
204         } /* end if */                                                        \
205                                                                               \
206         /* Set the message's "creation index", if it has one */		      \
207         if(msg_type->set_crt_index) {				      	      \
208             /* Set the creation index for the message */		      \
209             if((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0)  \
210                 HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \
211         } /* end if */							      \
212     } /* end if */
213 
214 /* Flags for a message class's "sharability" */
215 #define H5O_SHARE_IS_SHARABLE   0x01
216 #define H5O_SHARE_IN_OHDR       0x02
217 
218 /* Set the object header size to speculatively read in */
219 /* (needs to be more than the object header prefix size to work at all and
220  *      should be larger than the largest object type's default object header
221  *      size to save the extra I/O operations) */
222 #define H5O_SPEC_READ_SIZE 512
223 
224 
225 /* The "message class" type */
226 struct H5O_msg_class_t {
227     unsigned	id;				/*message type ID on disk   */
228     const char	*name;				/*for debugging             */
229     size_t	native_size;			/*size of native message    */
230     unsigned    share_flags;			/* Message sharing settings */
231     void	*(*decode)(H5F_t *, hid_t, H5O_t *, unsigned, unsigned *, const uint8_t *);
232     herr_t	(*encode)(H5F_t *, hbool_t, uint8_t *, const void *);
233     void	*(*copy)(const void *, void *);	/*copy native value         */
234     size_t	(*raw_size)(const H5F_t *, hbool_t, const void *);/*sizeof encoded message	*/
235     herr_t	(*reset)(void *);		/*free nested data structs  */
236     herr_t	(*free)(void *);		/*free main data struct  */
237     herr_t	(*del)(H5F_t *, hid_t, H5O_t *, void *);    /* Delete space in file referenced by this message */
238     herr_t	(*link)(H5F_t *, hid_t, H5O_t *, void *);   /* Increment any links in file reference by this message */
239     herr_t	(*set_share)(void*, const H5O_shared_t*);   /* Set shared information */
240     htri_t	(*can_share)(const void *);	/* Is message allowed to be shared? */
241     herr_t	(*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
242     void	*(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, unsigned *, H5O_copy_t *, void *, hid_t); /*copy native value to file */
243     herr_t	(*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, unsigned *, hid_t, H5O_copy_t *); /*"post copy" action when copying native value to file */
244     herr_t      (*get_crt_index)(const void *, H5O_msg_crt_idx_t *);	/* Get message's creation index */
245     herr_t      (*set_crt_index)(void *, H5O_msg_crt_idx_t);	/* Set message's creation index */
246     herr_t	(*debug)(H5F_t*, hid_t, const void*, FILE*, int, int);
247 };
248 
249 struct H5O_mesg_t {
250     const H5O_msg_class_t	*type;	/*type of message		     */
251     hbool_t		dirty;		/*raw out of date wrt native	     */
252     uint8_t		flags;		/*message flags			     */
253     H5O_msg_crt_idx_t   crt_idx;        /*message creation index	     */
254     unsigned		chunkno;	/*chunk number for this mesg	     */
255     void		*native;	/*native format message		     */
256     uint8_t		*raw;		/*ptr to raw data		     */
257     size_t		raw_size;	/*size with alignment		     */
258 };
259 
260 /* Struct for storing information about "best" message to move to new chunk */
261 typedef struct H5O_msg_alloc_info_t {
262     int msgno;                      /* Index in message array */
263     unsigned id;		    /* Message type ID on disk */
264     unsigned chunkno;               /* Index in chunk array */
265     size_t gap_size;                /* Size of any "gap" in the chunk immediately after message */
266     size_t null_size;               /* Size of any null message in the chunk immediately after message */
267     size_t total_size;              /* Total size of "available" space around message */
268     unsigned null_msgno;            /* Message index of null message immediately after message */
269 } H5O_msg_alloc_info_t;
270 
271 typedef struct H5O_chunk_t {
272     haddr_t	addr;			/*chunk file address		     */
273     size_t	size;			/*chunk size			     */
274     size_t	gap;			/*space at end of chunk too small for null message */
275     uint8_t	*image;			/*image of file			     */
276     struct H5O_chunk_proxy_t *chunk_proxy;    /* Pointer to a chunk's proxy when chunk protected */
277 } H5O_chunk_t;
278 
279 struct H5O_t {
280     H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */
281                             /* first field in structure */
282 
283     /* File-specific information (not stored) */
284     size_t      sizeof_size;            /* Size of file sizes 		     */
285     size_t      sizeof_addr;            /* Size of file addresses	     */
286     hbool_t     swmr_write;             /* Whether we are doing SWMR writes  */
287 
288     /* Debugging information (not stored) */
289 #ifdef H5O_ENABLE_BAD_MESG_COUNT
290     hbool_t     store_bad_mesg_count;   /* Flag to indicate that a bad message count should be stored */
291                                         /* (This is to simulate a bug in earlier
292                                          *      versions of the library)
293                                          */
294 #endif /* H5O_ENABLE_BAD_MESG_COUNT */
295 #ifndef NDEBUG
296     size_t      ndecode_dirtied;        /* Number of messages dirtied by decoding */
297 #endif /* NDEBUG */
298 
299     /* Chunk management information (not stored) */
300     size_t      rc;                     /* Reference count of [continuation] chunks using this structure */
301 
302     /* Object information (stored) */
303     hbool_t     has_refcount_msg;       /* Whether the object has a ref. count message */
304     unsigned	nlink;			/*link count			     */
305     uint8_t	version;		/*version number		     */
306     uint8_t	flags;			/*flags				     */
307 
308     /* Time information (stored, for versions > 1 & H5O_HDR_STORE_TIMES flag set) */
309     time_t      atime;                  /*access time 			     */
310     time_t      mtime;                  /*modification time 		     */
311     time_t      ctime;                  /*change time 			     */
312     time_t      btime;                  /*birth time 			     */
313 
314     /* Attribute information (stored, for versions > 1) */
315     unsigned	max_compact;		/* Maximum # of compact attributes   */
316     unsigned	min_dense;		/* Minimum # of "dense" attributes   */
317 
318     /* Message management (stored, encoded in chunks) */
319     size_t	nmesgs;			/*number of messages		     */
320     size_t	alloc_nmesgs;		/*number of message slots	     */
321     H5O_mesg_t	*mesg;			/*array of messages		     */
322     size_t      link_msgs_seen;         /* # of link messages seen when loading header */
323     size_t      attr_msgs_seen;         /* # of attribute messages seen when loading header */
324 
325     /* Chunk management (not stored) */
326     size_t	nchunks;		/*number of chunks		     */
327     size_t	alloc_nchunks;		/*chunks allocated		     */
328     H5O_chunk_t *chunk;			/*array of chunks		     */
329     hbool_t     chunks_pinned;          /* Whether chunks are pinned from ohdr protect */
330 
331     /* Object header proxy information (not stored) */
332     H5AC_proxy_entry_t *proxy;          /* Proxy cache entry for all ohdr entries */
333 };
334 
335 /* Class for types of objects in file */
336 typedef struct H5O_obj_class_t {
337     H5O_type_t	type;				/*object type on disk	     */
338     const char	*name;				/*for debugging		     */
339     void       *(*get_copy_file_udata)(void);	/*retrieve user data for 'copy file' operation */
340     void	(*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */
341     htri_t	(*isa)(H5O_t *);		/*if a header matches an object class */
342     hid_t	(*open)(const H5G_loc_t *, hid_t, hid_t, hbool_t );	/*open an object of this class */
343     void	*(*create)(H5F_t *, void *, H5G_loc_t *, hid_t );	/*create an object of this class */
344     H5O_loc_t	*(*get_oloc)(hid_t );		/*get the object header location for an object */
345     herr_t      (*bh_info)(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */
346     herr_t      (*flush)(void *obj_ptr, hid_t dxpl_id); /*flush an opened object of this class */
347 } H5O_obj_class_t;
348 
349 /* Node in skip list to map addresses from one file to another during object header copy */
350 typedef struct H5O_addr_map_t {
351     H5_obj_t    src_obj_pos;            /* Location of source object */
352     haddr_t     dst_addr;               /* Address of object in destination file */
353     hbool_t     is_locked;              /* Indicate that the destination object is locked currently */
354     hsize_t     inc_ref_count;          /* Number of deferred increments to reference count */
355     const H5O_obj_class_t *obj_class;   /* Object class */
356     void        *udata;                 /* Object class copy file udata */
357 } H5O_addr_map_t;
358 
359 /* Stack of continuation messages to interpret */
360 typedef struct H5O_cont_msgs_t {
361     size_t      nmsgs;                  /* Number of continuation messages found so far */
362     size_t	alloc_nmsgs;		/* Continuation messages allocated */
363     H5O_cont_t *msgs;			/* Array of continuation messages */
364 } H5O_cont_msgs_t;
365 
366 /* Common callback information for loading object header prefix from disk */
367 typedef struct H5O_common_cache_ud_t {
368     H5F_t *f;                           /* Pointer to file for object header/chunk */
369     hid_t dxpl_id;                      /* DXPL for operation */
370     unsigned file_intent;               /* Read/write intent for file */
371     unsigned merged_null_msgs;          /* Number of null messages merged together */
372     H5O_cont_msgs_t *cont_msg_info;     /* Pointer to continuation messages to work on */
373     haddr_t addr;                       /* Address of the prefix or chunk */
374 } H5O_common_cache_ud_t;
375 
376 /* Callback information for loading object header prefix from disk */
377 typedef struct H5O_cache_ud_t {
378     hbool_t made_attempt;               /* Whether the deserialize routine was already attempted */
379     unsigned v1_pfx_nmesgs;             /* Number of messages from v1 prefix header */
380     size_t chunk0_size;                 /* Size of serialized first chunk    */
381     H5O_t *oh;                          /* Partially deserialized object header, for later use */
382     H5O_common_cache_ud_t common;       /* Common object header cache callback info */
383 } H5O_cache_ud_t;
384 
385 /* Structure representing each chunk in the cache */
386 typedef struct H5O_chunk_proxy_t {
387     H5AC_info_t cache_info;    /* Information for metadata cache functions, _must_ be */
388                                 /* first field in structure */
389 
390     H5F_t *f;                           /* Pointer to file for object header/chunk */
391     H5O_t       *oh;                    /* Object header for this chunk */
392     unsigned    chunkno;                /* Chunk number for this chunk */
393     unsigned    cont_chunkno;           /* Chunk number for the chunk containing the continuation message that points to this chunk */
394 
395     /* Flush depencency parent information (not stored)
396      *
397      * The following field is used to store a pointer
398      * to the in-core representation of the chunk proxy's flush dependency
399      * parent -- if it exists.  If it does not exist, this field will
400      * contain NULL.
401      *
402      * If the file is opened in SWMR write mode, the flush dependency
403      * parent of the chunk proxy will be either its object header
404      * (if cont_chunkno == 0) or the chunk proxy indicated by the
405      * cont_chunkno field (if cont_chunkno > 0).
406      */
407     void *parent;                       /* Pointer to flush dependency parent */
408 } H5O_chunk_proxy_t;
409 
410 /* Callback information for loading object header chunk from disk */
411 typedef struct H5O_chk_cache_ud_t {
412     hbool_t decoding;                   /* Whether the object header is being decoded */
413     H5O_t *oh;                          /* Object header for this chunk */
414     unsigned chunkno;                   /* Index of chunk being brought in (for re-loads) */
415     size_t size;                        /* Size of chunk in the file */
416     H5O_common_cache_ud_t common;       /* Common object header cache callback info */
417 } H5O_chk_cache_ud_t;
418 
419 
420 /* Header message ID to class mapping */
421 H5_DLLVAR const H5O_msg_class_t *const H5O_msg_class_g[H5O_MSG_TYPES];
422 
423 /* Declare external the free list for H5O_t's */
424 H5FL_EXTERN(H5O_t);
425 
426 /* Declare external the free list for H5O_mesg_t sequences */
427 H5FL_SEQ_EXTERN(H5O_mesg_t);
428 
429 /* Declare external the free list for H5O_chunk_t sequences */
430 H5FL_SEQ_EXTERN(H5O_chunk_t);
431 
432 /* Declare external the free list for chunk_image blocks */
433 H5FL_BLK_EXTERN(chunk_image);
434 
435 /*
436  * Object header messages
437  */
438 
439 /* Null Message. (0x0000) */
440 H5_DLLVAR const H5O_msg_class_t H5O_MSG_NULL[1];
441 
442 /* Simple Dataspace Message. (0x0001) */
443 H5_DLLVAR const H5O_msg_class_t H5O_MSG_SDSPACE[1];
444 
445 /* Link Information Message. (0x0002) */
446 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LINFO[1];
447 
448 /* Datatype Message. (0x0003) */
449 H5_DLLVAR const H5O_msg_class_t H5O_MSG_DTYPE[1];
450 
451 /* Old Fill Value Message. (0x0004) */
452 H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL[1];
453 
454 /* New Fill Value Message. (0x0005) */
455 /*
456  * The new fill value message is fill value plus
457  * space allocation time and fill value writing time and whether fill
458  * value is defined.
459  */
460 H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL_NEW[1];
461 
462 /* Link Message. (0x0006) */
463 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LINK[1];
464 
465 /* External File List Message. (0x0007) */
466 H5_DLLVAR const H5O_msg_class_t H5O_MSG_EFL[1];
467 
468 /* Data Layout Message. (0x0008) */
469 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LAYOUT[1];
470 
471 #ifdef H5O_ENABLE_BOGUS
472 /* "Bogus valid" Message. (0x0009) */
473 /* "Bogus invalid" Message. (0x0019) */
474 /*
475  * Used for debugging - should never be found in valid HDF5 file.
476  */
477 H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1];
478 H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1];
479 #endif /* H5O_ENABLE_BOGUS */
480 
481 /* Group Information Message. (0x000a) */
482 H5_DLLVAR const H5O_msg_class_t H5O_MSG_GINFO[1];
483 
484 /* Filter pipeline message. (0x000b) */
485 H5_DLLVAR const H5O_msg_class_t H5O_MSG_PLINE[1];
486 
487 /* Attribute Message. (0x000c) */
488 H5_DLLVAR const H5O_msg_class_t H5O_MSG_ATTR[1];
489 
490 /* Object name message. (0x000d) */
491 H5_DLLVAR const H5O_msg_class_t H5O_MSG_NAME[1];
492 
493 /* Modification Time Message. (0x000e) */
494 /*
495  * The message is just a `time_t'.
496  * (See also the "new" modification time message)
497  */
498 H5_DLLVAR const H5O_msg_class_t H5O_MSG_MTIME[1];
499 
500 /* Shared Message information message (0x000f)
501  * A message for the superblock extension, holding information about
502  * the file-wide shared message "SOHM" table
503  */
504 H5_DLLVAR const H5O_msg_class_t H5O_MSG_SHMESG[1];
505 
506 /* Object Header Continuation Message. (0x0010) */
507 H5_DLLVAR const H5O_msg_class_t H5O_MSG_CONT[1];
508 
509 /* Symbol Table Message. (0x0011) */
510 H5_DLLVAR const H5O_msg_class_t H5O_MSG_STAB[1];
511 
512 /* New Modification Time Message. (0x0012) */
513 /*
514  * The message is just a `time_t'.
515  */
516 H5_DLLVAR const H5O_msg_class_t H5O_MSG_MTIME_NEW[1];
517 
518 /* v1 B-tree 'K' value message (0x0013)
519  * A message for the superblock extension, holding information about
520  * the file-wide v1 B-tree 'K' values.
521  */
522 H5_DLLVAR const H5O_msg_class_t H5O_MSG_BTREEK[1];
523 
524 /* Driver info message (0x0014)
525  * A message for the superblock extension, holding information about
526  * the file driver settings
527  */
528 H5_DLLVAR const H5O_msg_class_t H5O_MSG_DRVINFO[1];
529 
530 /* Attribute Information Message. (0x0015) */
531 H5_DLLVAR const H5O_msg_class_t H5O_MSG_AINFO[1];
532 
533 /* Reference Count Message. (0x0016) */
534 H5_DLLVAR const H5O_msg_class_t H5O_MSG_REFCOUNT[1];
535 
536 /* Free-space Manager Info message. (0x0017) */
537 H5_DLLVAR const H5O_msg_class_t H5O_MSG_FSINFO[1];
538 
539 /* Metadata Cache Image message. (0x0018) */
540 H5_DLLVAR const H5O_msg_class_t H5O_MSG_MDCI[1];
541 
542 /* Placeholder for unknown message. (0x0019) */
543 H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1];
544 
545 
546 /*
547  * Object header "object" types
548  */
549 
550 /* Group Object. (H5O_TYPE_GROUP - 0) */
551 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_GROUP[1];
552 
553 /* Dataset Object. (H5O_TYPE_DATASET - 1) */
554 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATASET[1];
555 
556 /* Datatype Object. (H5O_TYPE_NAMED_DATATYPE - 2) */
557 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1];
558 
559 
560 /* Package-local function prototypes */
561 H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg);
562 H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh);
563 H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref);
564 H5_DLL herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5O_mesg_t *mesg);
565 H5_DLL const H5O_obj_class_t * H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id);
566 H5_DLL int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted);
567 H5_DLL herr_t H5O_inc_rc(H5O_t *oh);
568 H5_DLL herr_t H5O_dec_rc(H5O_t *oh);
569 H5_DLL herr_t H5O__free(H5O_t *oh);
570 
571 /* Object header message routines */
572 H5_DLL herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
573     const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg,
574     size_t *mesg_idx);
575 H5_DLL herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
576     const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags,
577     void *mesg);
578 H5_DLL herr_t H5O_msg_write_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
579     const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags,
580     void *mesg);
581 H5_DLL void *H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg);
582 H5_DLL herr_t H5O_msg_free_mesg(H5O_mesg_t *mesg);
583 H5_DLL unsigned H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type);
584 H5_DLL herr_t H5O_msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
585     int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
586 H5_DLL void *H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src,
587     void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size,
588     unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
589 H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
590     const H5O_mesg_operator_t *op, void *op_data, hid_t dxpl_id);
591 
592 /* Object header chunk routines */
593 H5_DLL herr_t H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
594     unsigned cont_chunkno);
595 H5_DLL H5O_chunk_proxy_t *H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
596     unsigned idx);
597 H5_DLL herr_t H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id,
598     H5O_chunk_proxy_t *chk_proxy, hbool_t chk_dirtied);
599 H5_DLL herr_t H5O_chunk_update_idx(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx);
600 H5_DLL herr_t H5O_chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy);
601 H5_DLL herr_t H5O_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx);
602 H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy);
603 
604 /* Collect storage info for btree and heap */
605 H5_DLL herr_t H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
606     H5_ih_info_t *bh_info);
607 
608 /* Object header allocation routines */
609 H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc);
610 H5_DLL herr_t H5O__alloc_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size,
611     size_t found_null, const H5O_msg_alloc_info_t *found_msg, size_t *new_idx);
612 H5_DLL herr_t  H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
613     const H5O_msg_class_t *type, const void *mesg, size_t *mesg_idx);
614 H5_DLL herr_t H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id);
615 H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
616     H5O_mesg_t *mesg, hbool_t adj_link);
617 
618 /* Shared object operators */
619 H5_DLL void * H5O_shared_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
620     unsigned *ioflags, const uint8_t *buf, const H5O_msg_class_t *type);
621 H5_DLL herr_t H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg);
622 H5_DLL size_t H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg);
623 H5_DLL herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
624     const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg);
625 H5_DLL herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
626     const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg);
627 H5_DLL herr_t H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst,
628     const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
629     hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info,
630     void *udata, hid_t dxpl_id);
631 H5_DLL herr_t H5O_shared_post_copy_file (H5F_t *f,
632     const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src,
633     H5O_shared_t *shared_dst, unsigned *mesg_flags, hid_t dxpl_id,
634     H5O_copy_t *cpy_info);
635 H5_DLL herr_t H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream,
636     int indent, int fwidth);
637 
638 /* Attribute message operators */
639 H5_DLL herr_t H5O_attr_reset(void *_mesg);
640 H5_DLL herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg);
641 H5_DLL herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg);
642 H5_DLL herr_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
643     hsize_t *nattrs);
644 
645 /* Testing functions */
646 #ifdef H5O_TESTING
647 H5_DLL htri_t H5O_is_attr_empty_test(hid_t oid);
648 H5_DLL htri_t H5O_is_attr_dense_test(hid_t oid);
649 H5_DLL herr_t H5O_num_attrs_test(hid_t oid, hsize_t *nattrs);
650 H5_DLL herr_t H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count);
651 H5_DLL herr_t H5O_check_msg_marked_test(hid_t oid, hbool_t flag_val);
652 H5_DLL herr_t H5O_expunge_chunks_test(const H5O_loc_t *oloc, hid_t dxpl_id);
653 H5_DLL herr_t H5O_get_rc(const H5O_loc_t *oloc, hid_t dxpl_id, unsigned *rc);
654 H5_DLL herr_t H5O_msg_get_chunkno_test(hid_t oid, unsigned msg_type,
655     unsigned *chunk_num);
656 H5_DLL herr_t H5O_msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type);
657 #endif /* H5O_TESTING */
658 
659 /* Object header debugging routines */
660 #ifdef H5O_DEBUG
661 H5_DLL herr_t H5O_assert(const H5O_t *oh);
662 #endif /* H5O_DEBUG */
663 H5_DLL herr_t H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth);
664 
665 #endif /* _H5Opkg_H */
666 
667