/src/hdf5/src/H5Ofsinfo.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the COPYING file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /*------------------------------------------------------------------------- |
14 | | * |
15 | | * Created: H5Ofsinfo.c |
16 | | * |
17 | | * Purpose: File space info message |
18 | | * |
19 | | *------------------------------------------------------------------------- |
20 | | */ |
21 | | #define H5F_FRIEND /*suppress error about including H5Fpkg */ |
22 | | #include "H5Omodule.h" /* This source code file is part of the H5O module */ |
23 | | |
24 | | #include "H5private.h" /* Generic Functions */ |
25 | | #include "H5Eprivate.h" /* Error handling */ |
26 | | #include "H5Fpkg.h" /* File access */ |
27 | | #include "H5FLprivate.h" /* Free lists */ |
28 | | #include "H5Opkg.h" /* Object headers */ |
29 | | |
30 | | /* PRIVATE PROTOTYPES */ |
31 | | static void *H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, |
32 | | size_t p_size, const uint8_t *p); |
33 | | static herr_t H5O__fsinfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p, |
34 | | const void *_mesg); |
35 | | static void *H5O__fsinfo_copy(const void *_mesg, void *_dest); |
36 | | static size_t H5O__fsinfo_size(const H5F_t *f, bool disable_shared, const void *_mesg); |
37 | | static herr_t H5O__fsinfo_free(void *mesg); |
38 | | static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); |
39 | | |
40 | | /* This message derives from H5O message class */ |
41 | | const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ |
42 | | H5O_FSINFO_ID, /* message id number */ |
43 | | "fsinfo", /* message name for debugging */ |
44 | | sizeof(H5O_fsinfo_t), /* native message size */ |
45 | | 0, /* messages are shareable? */ |
46 | | H5O__fsinfo_decode, /* decode message */ |
47 | | H5O__fsinfo_encode, /* encode message */ |
48 | | H5O__fsinfo_copy, /* copy the native value */ |
49 | | H5O__fsinfo_size, /* size of free-space manager info message */ |
50 | | NULL, /* default reset method */ |
51 | | H5O__fsinfo_free, /* free method */ |
52 | | NULL, /* file delete method */ |
53 | | NULL, /* link method */ |
54 | | NULL, /* set share method */ |
55 | | NULL, /* can share method */ |
56 | | NULL, /* pre copy native value to file */ |
57 | | NULL, /* copy native value to file */ |
58 | | NULL, /* post copy native value to file */ |
59 | | NULL, /* get creation index */ |
60 | | NULL, /* set creation index */ |
61 | | H5O__fsinfo_debug /* debug the message */ |
62 | | }}; |
63 | | |
64 | | /* Format version bounds for fsinfo message */ |
65 | | /* This message exists starting library release v1.10 */ |
66 | | static const unsigned H5O_fsinfo_ver_bounds[] = { |
67 | | H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ |
68 | | H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ |
69 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ |
70 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V112 */ |
71 | | H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ |
72 | | }; |
73 | | #define N_FSINFO_VERSION_BOUNDS H5F_LIBVER_NBOUNDS |
74 | | |
75 | | /* Declare a free list to manage the H5O_fsinfo_t struct */ |
76 | | H5FL_DEFINE_STATIC(H5O_fsinfo_t); |
77 | | |
78 | | /*------------------------------------------------------------------------- |
79 | | * Function: H5O__fsinfo_decode |
80 | | * |
81 | | * Purpose: Decode a message and return a pointer to a newly allocated one. |
82 | | * |
83 | | * Return: Success: Pointer to new message in native form |
84 | | * Failure: NULL |
85 | | *------------------------------------------------------------------------- |
86 | | */ |
87 | | static void * |
88 | | H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, |
89 | | unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) |
90 | 0 | { |
91 | 0 | H5O_fsinfo_t *fsinfo = NULL; /* File space info message */ |
92 | 0 | H5F_mem_page_t ptype; /* Memory type for iteration */ |
93 | 0 | unsigned vers; /* Message version */ |
94 | 0 | const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ |
95 | 0 | void *ret_value = NULL; |
96 | |
|
97 | 0 | FUNC_ENTER_PACKAGE |
98 | |
|
99 | 0 | assert(f); |
100 | 0 | assert(p); |
101 | | |
102 | | /* Allocate space for message */ |
103 | 0 | if (NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) |
104 | 0 | HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); |
105 | | |
106 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
107 | 0 | fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; |
108 | | |
109 | | /* Version of message */ |
110 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) |
111 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
112 | 0 | vers = *p++; |
113 | |
|
114 | 0 | if (vers == H5O_FSINFO_VERSION_0) { |
115 | 0 | H5F_file_space_type_t strategy; /* Strategy */ |
116 | 0 | hsize_t threshold = 0; /* Threshold */ |
117 | 0 | H5FD_mem_t type; /* Memory type for iteration */ |
118 | |
|
119 | 0 | fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; |
120 | 0 | fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; |
121 | 0 | fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; |
122 | 0 | fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; |
123 | 0 | fsinfo->eoa_pre_fsm_fsalloc = HADDR_UNDEF; |
124 | |
|
125 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 1 + H5F_sizeof_size(f), p_end)) |
126 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
127 | 0 | strategy = (H5F_file_space_type_t)*p++; /* File space strategy */ |
128 | 0 | H5F_DECODE_LENGTH(f, p, threshold); /* Free-space section threshold */ |
129 | | |
130 | | /* Map version 0 (deprecated) to version 1 message */ |
131 | 0 | switch (strategy) { |
132 | 0 | case H5F_FILE_SPACE_ALL_PERSIST: |
133 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; |
134 | 0 | fsinfo->persist = true; |
135 | 0 | fsinfo->threshold = threshold; |
136 | 0 | if (HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) |
137 | 0 | HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file size"); |
138 | 0 | for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { |
139 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
140 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, |
141 | 0 | "ran off end of input buffer while decoding"); |
142 | 0 | H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); |
143 | 0 | } |
144 | 0 | break; |
145 | | |
146 | 0 | case H5F_FILE_SPACE_ALL: |
147 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; |
148 | 0 | fsinfo->threshold = threshold; |
149 | 0 | break; |
150 | | |
151 | 0 | case H5F_FILE_SPACE_AGGR_VFD: |
152 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_AGGR; |
153 | 0 | break; |
154 | | |
155 | 0 | case H5F_FILE_SPACE_VFD: |
156 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_NONE; |
157 | 0 | break; |
158 | | |
159 | 0 | case H5F_FILE_SPACE_NTYPES: |
160 | 0 | case H5F_FILE_SPACE_DEFAULT: |
161 | 0 | default: |
162 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file space strategy"); |
163 | 0 | } |
164 | | |
165 | 0 | fsinfo->version = H5O_FSINFO_VERSION_1; |
166 | 0 | fsinfo->mapped = true; |
167 | 0 | } |
168 | 0 | else { |
169 | 0 | if (vers < H5O_FSINFO_VERSION_1) |
170 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "bad version number"); |
171 | | |
172 | 0 | fsinfo->version = vers; |
173 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 1 + 1, p_end)) |
174 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
175 | 0 | fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ |
176 | 0 | fsinfo->persist = *p++; /* Free-space persist or not */ |
177 | |
|
178 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) |
179 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
180 | 0 | H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ |
181 | | |
182 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) |
183 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
184 | 0 | H5F_DECODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ |
185 | | |
186 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) |
187 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
188 | 0 | UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ |
189 | |
|
190 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
191 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
192 | 0 | H5F_addr_decode(f, &p, |
193 | 0 | &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ |
194 | | |
195 | | /* Decode addresses of free space managers, if persisting */ |
196 | 0 | if (fsinfo->persist) |
197 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { |
198 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
199 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
200 | 0 | H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); |
201 | 0 | } |
202 | 0 | fsinfo->mapped = false; |
203 | 0 | } |
204 | | |
205 | | /* Set return value */ |
206 | 0 | ret_value = fsinfo; |
207 | |
|
208 | 0 | done: |
209 | 0 | if (!ret_value && fsinfo) |
210 | 0 | H5FL_FREE(H5O_fsinfo_t, fsinfo); |
211 | |
|
212 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
213 | 0 | } /* end H5O__fsinfo_decode() */ |
214 | | |
215 | | /*------------------------------------------------------------------------- |
216 | | * Function: H5O__fsinfo_encode |
217 | | * |
218 | | * Purpose: Encodes a message. |
219 | | * |
220 | | * Return: Non-negative on success/Negative on failure |
221 | | * |
222 | | *------------------------------------------------------------------------- |
223 | | */ |
224 | | static herr_t |
225 | | H5O__fsinfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p, |
226 | | const void *_mesg) |
227 | 0 | { |
228 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
229 | 0 | H5F_mem_page_t ptype; /* Memory type for iteration */ |
230 | |
|
231 | 0 | FUNC_ENTER_PACKAGE_NOERR |
232 | | |
233 | | /* check args */ |
234 | 0 | assert(f); |
235 | 0 | assert(p); |
236 | 0 | assert(fsinfo); |
237 | |
|
238 | 0 | *p++ = (uint8_t)fsinfo->version; /* message version */ |
239 | 0 | *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ |
240 | 0 | *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ |
241 | 0 | H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ |
242 | | |
243 | 0 | H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ |
244 | 0 | UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ |
245 | 0 | H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ |
246 | | |
247 | | /* Store addresses of free-space managers, if persisting */ |
248 | 0 | if (fsinfo->persist) |
249 | | /* Addresses of free-space managers */ |
250 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
251 | 0 | H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); |
252 | |
|
253 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
254 | 0 | } /* end H5O__fsinfo_encode() */ |
255 | | |
256 | | /*------------------------------------------------------------------------- |
257 | | * Function: H5O__fsinfo_copy |
258 | | * |
259 | | * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if |
260 | | * necessary. |
261 | | * |
262 | | * Return: Success: Ptr to _DEST |
263 | | * Failure: NULL |
264 | | * |
265 | | *------------------------------------------------------------------------- |
266 | | */ |
267 | | static void * |
268 | | H5O__fsinfo_copy(const void *_mesg, void *_dest) |
269 | 0 | { |
270 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
271 | 0 | H5O_fsinfo_t *dest = (H5O_fsinfo_t *)_dest; |
272 | 0 | void *ret_value = NULL; /* Return value */ |
273 | |
|
274 | 0 | FUNC_ENTER_PACKAGE |
275 | | |
276 | | /* check args */ |
277 | 0 | assert(fsinfo); |
278 | 0 | if (!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) |
279 | 0 | HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); |
280 | | |
281 | | /* copy */ |
282 | 0 | *dest = *fsinfo; |
283 | | |
284 | | /* Set return value */ |
285 | 0 | ret_value = dest; |
286 | |
|
287 | 0 | done: |
288 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
289 | 0 | } /* end H5O__fsinfo_copy() */ |
290 | | |
291 | | /*------------------------------------------------------------------------- |
292 | | * Function: H5O__fsinfo_size |
293 | | * |
294 | | * Purpose: Returns the size of the raw message in bytes not counting |
295 | | * the message type or size fields, but only the data fields. |
296 | | * This function doesn't take into account alignment. |
297 | | * |
298 | | * Return: Success: Message data size in bytes without alignment. |
299 | | * Failure: zero |
300 | | * |
301 | | *------------------------------------------------------------------------- |
302 | | */ |
303 | | static size_t |
304 | | H5O__fsinfo_size(const H5F_t *f, bool H5_ATTR_UNUSED disable_shared, const void *_mesg) |
305 | 0 | { |
306 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
307 | 0 | size_t ret_value = 0; /* Return value */ |
308 | |
|
309 | 0 | FUNC_ENTER_PACKAGE_NOERR |
310 | |
|
311 | 0 | ret_value = 3 /* Version, strategy & persist */ |
312 | | + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ |
313 | | + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ |
314 | 0 | + 2 /* Page end meta threshold */ |
315 | 0 | + (size_t)H5F_SIZEOF_ADDR(f); |
316 | | |
317 | | /* Free-space manager addresses */ |
318 | 0 | if (fsinfo->persist) |
319 | 0 | ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); |
320 | |
|
321 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
322 | 0 | } /* end H5O__fsinfo_size() */ |
323 | | |
324 | | /*------------------------------------------------------------------------- |
325 | | * Function: H5O__fsinfo_free |
326 | | * |
327 | | * Purpose: Frees the message |
328 | | * |
329 | | * Return: Non-negative on success/Negative on failure |
330 | | * |
331 | | *------------------------------------------------------------------------- |
332 | | */ |
333 | | static herr_t |
334 | | H5O__fsinfo_free(void *mesg) |
335 | 0 | { |
336 | 0 | FUNC_ENTER_PACKAGE_NOERR |
337 | |
|
338 | 0 | assert(mesg); |
339 | |
|
340 | 0 | mesg = H5FL_FREE(H5O_fsinfo_t, mesg); |
341 | |
|
342 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
343 | 0 | } /* end H5O__fsinfo_free() */ |
344 | | |
345 | | /*------------------------------------------------------------------------- |
346 | | * Function: H5O__fsinfo_debug |
347 | | * |
348 | | * Purpose: Prints debugging info for a message. |
349 | | * |
350 | | * Return: Non-negative on success/Negative on failure |
351 | | * |
352 | | *------------------------------------------------------------------------- |
353 | | */ |
354 | | static herr_t |
355 | | H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) |
356 | 0 | { |
357 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
358 | 0 | H5F_mem_page_t ptype; /* Free-space types for iteration */ |
359 | |
|
360 | 0 | FUNC_ENTER_PACKAGE_NOERR |
361 | | |
362 | | /* check args */ |
363 | 0 | assert(f); |
364 | 0 | assert(fsinfo); |
365 | 0 | assert(stream); |
366 | 0 | assert(indent >= 0); |
367 | 0 | assert(fwidth >= 0); |
368 | |
|
369 | 0 | fprintf(stream, "%*s%-*s ", indent, "", fwidth, "File space strategy:"); |
370 | 0 | switch (fsinfo->strategy) { |
371 | 0 | case H5F_FSPACE_STRATEGY_FSM_AGGR: |
372 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_FSM_AGGR"); |
373 | 0 | break; |
374 | | |
375 | 0 | case H5F_FSPACE_STRATEGY_PAGE: |
376 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_PAGE"); |
377 | 0 | break; |
378 | | |
379 | 0 | case H5F_FSPACE_STRATEGY_AGGR: |
380 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_AGGR"); |
381 | 0 | break; |
382 | | |
383 | 0 | case H5F_FSPACE_STRATEGY_NONE: |
384 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_NONE"); |
385 | 0 | break; |
386 | | |
387 | 0 | case H5F_FSPACE_STRATEGY_NTYPES: |
388 | 0 | default: |
389 | 0 | fprintf(stream, "%s\n", "unknown"); |
390 | 0 | } /* end switch */ |
391 | | |
392 | 0 | fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, |
393 | 0 | "Free-space persist:", fsinfo->persist ? "TRUE" : "FALSE"); |
394 | |
|
395 | 0 | fprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, |
396 | 0 | "Free-space section threshold:", fsinfo->threshold); |
397 | |
|
398 | 0 | fprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, |
399 | 0 | "File space page size:", fsinfo->page_size); |
400 | |
|
401 | 0 | fprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, |
402 | 0 | "Page end metadata threshold:", fsinfo->pgend_meta_thres); |
403 | |
|
404 | 0 | fprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, |
405 | 0 | "eoa_pre_fsm_fsalloc:", fsinfo->eoa_pre_fsm_fsalloc); |
406 | |
|
407 | 0 | if (fsinfo->persist) { |
408 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
409 | 0 | fprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, |
410 | 0 | "Free space manager address:", fsinfo->fs_addr[ptype - 1]); |
411 | 0 | } /* end if */ |
412 | |
|
413 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
414 | 0 | } /* end H5O__fsinfo_debug() */ |
415 | | |
416 | | /*------------------------------------------------------------------------- |
417 | | * Function: H5O_fsinfo_set_version |
418 | | * |
419 | | * Purpose: Set the version to encode the fsinfo message with. |
420 | | * |
421 | | * Return: SUCCEED/FAIL |
422 | | * |
423 | | *------------------------------------------------------------------------- |
424 | | */ |
425 | | herr_t |
426 | | H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) |
427 | 0 | { |
428 | 0 | unsigned version; /* Message version */ |
429 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
430 | |
|
431 | 0 | FUNC_ENTER_NOAPI(FAIL) |
432 | | |
433 | | /* Sanity check */ |
434 | 0 | HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); |
435 | 0 | assert(fsinfo); |
436 | |
|
437 | 0 | version = H5O_FSINFO_VERSION_1; |
438 | | |
439 | | /* Upgrade to the version indicated by the file's low bound if higher */ |
440 | 0 | if (H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) |
441 | 0 | version = MAX(version, H5O_fsinfo_ver_bounds[low]); |
442 | | |
443 | | /* Version bounds check */ |
444 | 0 | if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) |
445 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); |
446 | | |
447 | | /* Set the message version */ |
448 | 0 | fsinfo->version = version; |
449 | |
|
450 | 0 | done: |
451 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
452 | 0 | } /* end H5O_fsinfo_set_version() */ |
453 | | |
454 | | /*------------------------------------------------------------------------- |
455 | | * Function: H5O_fsinfo_check_version |
456 | | * |
457 | | * Purpose: Validate the fsinfo message version |
458 | | * |
459 | | * Return: SUCCEED/FAIL |
460 | | * |
461 | | *------------------------------------------------------------------------- |
462 | | */ |
463 | | herr_t |
464 | | H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) |
465 | 0 | { |
466 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
467 | |
|
468 | 0 | FUNC_ENTER_NOAPI(FAIL) |
469 | | |
470 | | /* Sanity check */ |
471 | 0 | HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); |
472 | 0 | assert(fsinfo); |
473 | | |
474 | | /* Check the version */ |
475 | 0 | if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) |
476 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); |
477 | | |
478 | 0 | done: |
479 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
480 | 0 | } /* end H5O_fsinfo_check_version() */ |