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 /*-------------------------------------------------------------------------
15  *
16  * Created:             H5Fquery.c
17  *                      Jan 10 2008
18  *                      Quincey Koziol <koziol@hdfgroup.org>
19  *
20  * Purpose:             File structure query routines.
21  *
22  *-------------------------------------------------------------------------
23  */
24 
25 /****************/
26 /* Module Setup */
27 /****************/
28 
29 #include "H5Fmodule.h"        /* This source code file is part of the H5F module */
30 
31 
32 /***********/
33 /* Headers */
34 /***********/
35 #include "H5private.h"          /* Generic Functions                        */
36 #include "H5Eprivate.h"         /* Error handling                           */
37 #include "H5Fpkg.h"             /* File access                              */
38 #include "H5FDprivate.h"        /* File drivers                             */
39 
40 
41 /****************/
42 /* Local Macros */
43 /****************/
44 
45 
46 /******************/
47 /* Local Typedefs */
48 /******************/
49 
50 
51 /********************/
52 /* Package Typedefs */
53 /********************/
54 
55 
56 /********************/
57 /* Local Prototypes */
58 /********************/
59 
60 
61 /*********************/
62 /* Package Variables */
63 /*********************/
64 
65 
66 /*****************************/
67 /* Library Private Variables */
68 /*****************************/
69 
70 
71 /*******************/
72 /* Local Variables */
73 /*******************/
74 
75 
76 
77 /*-------------------------------------------------------------------------
78  * Function: H5F_get_intent
79  *
80  * Purpose:  Quick and dirty routine to retrieve the file's 'intent' flags
81  *           (Mainly added to stop non-file routines from poking about in the
82  *           H5F_t data structure)
83  *
84  * Return:   'intent' on success/abort on failure (shouldn't fail)
85  *-------------------------------------------------------------------------
86  */
87 unsigned
H5F_get_intent(const H5F_t * f)88 H5F_get_intent(const H5F_t *f)
89 {
90     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
91     FUNC_ENTER_NOAPI_NOINIT_NOERR
92 
93     HDassert(f);
94 
95     FUNC_LEAVE_NOAPI(f->shared->flags)
96 } /* end H5F_get_intent() */
97 
98 
99 /*-------------------------------------------------------------------------
100  * Function:    H5F_get_low_bound
101  *
102  * Purpose: Quick and dirty routine to retrieve the file's low_bound.
103  *          (Mainly added to stop non-file routines from poking about in the
104  *          H5F_t data structure)
105  *
106  * Return:  low_bound on success/abort on failure (shouldn't fail)
107  *
108  * Programmer:  Vailin Choi; June 2016
109  *
110  *-------------------------------------------------------------------------
111  */
112 H5F_libver_t
H5F_get_low_bound(const H5F_t * f)113 H5F_get_low_bound(const H5F_t *f)
114 {
115     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
116     FUNC_ENTER_NOAPI_NOINIT_NOERR
117 
118     HDassert(f);
119 
120     FUNC_LEAVE_NOAPI(f->shared->low_bound)
121 } /* end H5F_get_low_bound() */
122 
123 
124 /*-------------------------------------------------------------------------
125  * Function:    H5F_get_high_bound
126  *
127  * Purpose: Quick and dirty routine to retrieve the file's high_bound.
128  *          (Mainly added to stop non-file routines from poking about in the
129  *          H5F_t data structure)
130  *
131  * Return:  high_bound on success/abort on failure (shouldn't fail)
132  *
133  * Programmer:  Vailin Choi; June 2016
134  *
135  *-------------------------------------------------------------------------
136  */
137 H5F_libver_t
H5F_get_high_bound(const H5F_t * f)138 H5F_get_high_bound(const H5F_t *f)
139 {
140     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
141     FUNC_ENTER_NOAPI_NOINIT_NOERR
142 
143     HDassert(f);
144 
145     FUNC_LEAVE_NOAPI(f->shared->high_bound)
146 } /* end H5F_get_high_bound() */
147 
148 
149 /*-------------------------------------------------------------------------
150  * Function: H5F_get_open_name
151  *
152  * Purpose:  Retrieve the name used to open a file.
153  *
154  * Return:   Success:    The name of the file.
155  *           Failure:    ? (should not happen)
156  *-------------------------------------------------------------------------
157  */
158 char *
H5F_get_open_name(const H5F_t * f)159 H5F_get_open_name(const H5F_t *f)
160 {
161     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
162     FUNC_ENTER_NOAPI_NOINIT_NOERR
163 
164     HDassert(f);
165     HDassert(f->open_name);
166 
167     FUNC_LEAVE_NOAPI(f->open_name)
168 } /* end H5F_get_open_name() */
169 
170 
171 /*-------------------------------------------------------------------------
172  * Function: H5F_get_actual_name
173  *
174  * Purpose:  Retrieve the actual name of a file, after resolving symlinks, etc.
175  *
176  * Return:   Success:    The name of the file.
177  *           Failure:    ? (should not happen)
178  *-------------------------------------------------------------------------
179  */
180 char *
H5F_get_actual_name(const H5F_t * f)181 H5F_get_actual_name(const H5F_t *f)
182 {
183     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
184     FUNC_ENTER_NOAPI_NOINIT_NOERR
185 
186     HDassert(f);
187     HDassert(f->actual_name);
188 
189     FUNC_LEAVE_NOAPI(f->actual_name)
190 } /* end H5F_get_actual_name() */
191 
192 
193 /*-------------------------------------------------------------------------
194  * Function: H5F_get_extpath
195  *
196  * Purpose:  Retrieve the file's 'extpath' flags
197  *           This is used by H5L_extern_traverse() and H5D_build_file_prefix() to retrieve the main file's location
198  *           when searching the target file.
199  *
200  * Return:   'extpath' on success/abort on failure (shouldn't fail)
201  *-------------------------------------------------------------------------
202  */
203 char *
H5F_get_extpath(const H5F_t * f)204 H5F_get_extpath(const H5F_t *f)
205 {
206     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
207     FUNC_ENTER_NOAPI_NOINIT_NOERR
208 
209     HDassert(f);
210     HDassert(f->extpath);
211 
212     FUNC_LEAVE_NOAPI(f->extpath)
213 } /* end H5F_get_extpath() */
214 
215 
216 /*-------------------------------------------------------------------------
217  * Function: H5F_get_shared
218  *
219  * Purpose:  Retrieve the file's 'shared' pointer
220  *
221  * Return:   'shared' on success/abort on failure (shouldn't fail)
222  *-------------------------------------------------------------------------
223  */
224 H5F_file_t *
H5F_get_shared(const H5F_t * f)225 H5F_get_shared(const H5F_t *f)
226 {
227     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
228     FUNC_ENTER_NOAPI_NOINIT_NOERR
229 
230     HDassert(f);
231 
232     FUNC_LEAVE_NOAPI(f->shared)
233 } /* end H5F_get_shared() */
234 
235 
236 /*-------------------------------------------------------------------------
237  * Function: H5F_same_shared
238  *
239  * Purpose:  Determine if two files have the same shared file pointer
240  *
241  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
242  *-------------------------------------------------------------------------
243  */
244 hbool_t
H5F_same_shared(const H5F_t * f1,const H5F_t * f2)245 H5F_same_shared(const H5F_t *f1, const H5F_t *f2)
246 {
247     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
248     FUNC_ENTER_NOAPI_NOINIT_NOERR
249 
250     HDassert(f1);
251     HDassert(f1->shared);
252     HDassert(f2);
253     HDassert(f2->shared);
254 
255     FUNC_LEAVE_NOAPI(f1->shared == f2->shared)
256 } /* end H5F_same_shared() */
257 
258 
259 /*-------------------------------------------------------------------------
260  * Function: H5F_get_nopen_objs
261  *
262  * Purpose:  Retrieve the file's 'nopen_objs' value
263  *
264  * Return:   'nopen_objs' on success/abort on failure (shouldn't fail)
265  *-------------------------------------------------------------------------
266  */
267 unsigned
H5F_get_nopen_objs(const H5F_t * f)268 H5F_get_nopen_objs(const H5F_t *f)
269 {
270     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
271     FUNC_ENTER_NOAPI_NOINIT_NOERR
272 
273     HDassert(f);
274 
275     FUNC_LEAVE_NOAPI(f->nopen_objs)
276 } /* end H5F_get_nopen_objs() */
277 
278 
279 /*-------------------------------------------------------------------------
280  * Function: H5F_get_file_id
281  *
282  * Purpose:  Retrieve the file's 'file_id' value
283  *
284  * Return:   'file_id' on success/abort on failure (shouldn't fail)
285  *-------------------------------------------------------------------------
286  */
287 hid_t
H5F_get_file_id(const H5F_t * f)288 H5F_get_file_id(const H5F_t *f)
289 {
290     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
291     FUNC_ENTER_NOAPI_NOINIT_NOERR
292 
293     HDassert(f);
294 
295     FUNC_LEAVE_NOAPI(f->file_id)
296 } /* end H5F_get_file_id() */
297 
298 
299 /*-------------------------------------------------------------------------
300  * Function: H5F_get_parent
301  *
302  * Purpose:  Retrieve the file's 'parent' pointer
303  *
304  * Return:   'parent' on success/abort on failure (shouldn't fail)
305  *-------------------------------------------------------------------------
306  */
307 H5F_t *
H5F_get_parent(const H5F_t * f)308 H5F_get_parent(const H5F_t *f)
309 {
310     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
311     FUNC_ENTER_NOAPI_NOINIT_NOERR
312 
313     HDassert(f);
314 
315     FUNC_LEAVE_NOAPI(f->parent)
316 } /* end H5F_get_parent() */
317 
318 
319 /*-------------------------------------------------------------------------
320  * Function: H5F_get_nmounts
321  *
322  * Purpose:  Retrieve the file's 'nmounts' value
323  *
324  * Return:   'nmounts' on success/abort on failure (shouldn't fail)
325  *-------------------------------------------------------------------------
326  */
327 unsigned
H5F_get_nmounts(const H5F_t * f)328 H5F_get_nmounts(const H5F_t *f)
329 {
330     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
331     FUNC_ENTER_NOAPI_NOINIT_NOERR
332 
333     HDassert(f);
334 
335     FUNC_LEAVE_NOAPI(f->nmounts)
336 } /* end H5F_get_nmounts() */
337 
338 
339 /*-------------------------------------------------------------------------
340  * Function: H5F_get_read_attempts
341  *
342  * Purpose:  Retrieve the file's 'read_attempts' value
343  *
344  * Return:   '# of read attempts' on success/abort on failure (shouldn't fail)
345  *-------------------------------------------------------------------------
346  */
347 unsigned
H5F_get_read_attempts(const H5F_t * f)348 H5F_get_read_attempts(const H5F_t *f)
349 {
350     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
351     FUNC_ENTER_NOAPI_NOINIT_NOERR
352 
353     HDassert(f);
354 
355     FUNC_LEAVE_NOAPI(f->shared->read_attempts)
356 } /* end H5F_get_read_attempts() */
357 
358 
359 /*-------------------------------------------------------------------------
360  * Function: H5F_get_fcpl
361  *
362  * Purpose:  Retrieve the value of a file's FCPL.
363  *
364  * Return:   Success:    The FCPL for the file.
365  *           Failure:    ? (should not happen)
366  *-------------------------------------------------------------------------
367  */
368 hid_t
H5F_get_fcpl(const H5F_t * f)369 H5F_get_fcpl(const H5F_t *f)
370 {
371     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
372     FUNC_ENTER_NOAPI_NOINIT_NOERR
373 
374     HDassert(f);
375     HDassert(f->shared);
376 
377     FUNC_LEAVE_NOAPI(f->shared->fcpl_id)
378 } /* end H5F_get_fcpl() */
379 
380 
381 /*-------------------------------------------------------------------------
382  * Function: H5F_sizeof_addr
383  *
384  * Purpose:  Quick and dirty routine to retrieve the size of the file's size_t
385  *           (Mainly added to stop non-file routines from poking about in the
386  *           H5F_t data structure)
387  *
388  * Return:   'sizeof_addr' on success/abort on failure (shouldn't fail)
389  *-------------------------------------------------------------------------
390  */
391 uint8_t
H5F_sizeof_addr(const H5F_t * f)392 H5F_sizeof_addr(const H5F_t *f)
393 {
394     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
395     FUNC_ENTER_NOAPI_NOINIT_NOERR
396 
397     HDassert(f);
398     HDassert(f->shared);
399 
400     FUNC_LEAVE_NOAPI(f->shared->sizeof_addr)
401 } /* end H5F_sizeof_addr() */
402 
403 
404 /*-------------------------------------------------------------------------
405  * Function: H5F_sizeof_size
406  *
407  * Purpose:  Quick and dirty routine to retrieve the size of the file's off_t
408  *           (Mainly added to stop non-file routines from poking about in the
409  *           H5F_t data structure)
410  *
411  * Return:   'sizeof_size' on success/abort on failure (shouldn't fail)
412  *-------------------------------------------------------------------------
413  */
414 uint8_t
H5F_sizeof_size(const H5F_t * f)415 H5F_sizeof_size(const H5F_t *f)
416 {
417     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
418     FUNC_ENTER_NOAPI_NOINIT_NOERR
419 
420     HDassert(f);
421     HDassert(f->shared);
422 
423     FUNC_LEAVE_NOAPI(f->shared->sizeof_size)
424 } /* H5F_sizeof_size() */
425 
426 
427 /*-------------------------------------------------------------------------
428  * Function: H5F_get_sohm_addr
429  *
430  * Purpose:  Retrieve the file's 'sohm_addr' value
431  *
432  * Return:   'sohm_addr' on success/abort on failure (shouldn't fail)
433  *-------------------------------------------------------------------------
434  */
435 haddr_t
H5F_get_sohm_addr(const H5F_t * f)436 H5F_get_sohm_addr(const H5F_t *f)
437 {
438     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
439     FUNC_ENTER_NOAPI_NOINIT_NOERR
440 
441     HDassert(f);
442     HDassert(f->shared);
443 
444     FUNC_LEAVE_NOAPI(f->shared->sohm_addr)
445 } /* end H5F_get_sohm_addr() */
446 
447 
448 /*-------------------------------------------------------------------------
449  * Function: H5F_get_sohm_vers
450  *
451  * Purpose:  Retrieve the file's 'sohm_vers' value
452  *
453  * Return:   'sohm_vers' on success/abort on failure (shouldn't fail)
454  *-------------------------------------------------------------------------
455  */
456 unsigned
H5F_get_sohm_vers(const H5F_t * f)457 H5F_get_sohm_vers(const H5F_t *f)
458 {
459     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
460     FUNC_ENTER_NOAPI_NOINIT_NOERR
461 
462     HDassert(f);
463     HDassert(f->shared);
464 
465     FUNC_LEAVE_NOAPI(f->shared->sohm_vers)
466 } /* end H5F_get_sohm_vers() */
467 
468 
469 /*-------------------------------------------------------------------------
470  * Function: H5F_get_sohm_nindexes
471  *
472  * Purpose:  Retrieve the file's 'sohm_nindexes' value
473  *
474  * Return:   'sohm_nindexes' on success/abort on failure (shouldn't fail)
475  *-------------------------------------------------------------------------
476  */
477 unsigned
H5F_get_sohm_nindexes(const H5F_t * f)478 H5F_get_sohm_nindexes(const H5F_t *f)
479 {
480     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
481     FUNC_ENTER_NOAPI_NOINIT_NOERR
482 
483     HDassert(f);
484     HDassert(f->shared);
485 
486     FUNC_LEAVE_NOAPI(f->shared->sohm_nindexes)
487 } /* end H5F_get_sohm_nindexes() */
488 
489 
490 /*-------------------------------------------------------------------------
491  * Function: H5F_sym_leaf_k
492  *
493  * Purpose:  Replaced a macro to retrieve the symbol table leaf size,
494  *           now that the generic properties are being used to store
495  *           the values.
496  *
497  * Return:   Success:    Non-negative, and the symbol table leaf size is
498  *                              returned.
499  *           Failure:    Negative (should not happen)
500  *-------------------------------------------------------------------------
501  */
502 unsigned
H5F_sym_leaf_k(const H5F_t * f)503 H5F_sym_leaf_k(const H5F_t *f)
504 {
505     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
506     FUNC_ENTER_NOAPI_NOINIT_NOERR
507 
508     HDassert(f);
509     HDassert(f->shared);
510     HDassert(f->shared->sblock);
511 
512     FUNC_LEAVE_NOAPI(f->shared->sblock->sym_leaf_k)
513 } /* end H5F_sym_leaf_k() */
514 
515 
516 /*-------------------------------------------------------------------------
517  * Function: H5F_get_min_dset_ohdr
518  *
519  * Purpose:  Get the setting flag for minimized dataset object headers
520  *
521  * Return:   TRUE/FALSE as set in file
522  *-------------------------------------------------------------------------
523  */
524 hbool_t
H5F_get_min_dset_ohdr(const H5F_t * f)525 H5F_get_min_dset_ohdr(const H5F_t *f)
526 {
527     FUNC_ENTER_NOAPI_NOINIT_NOERR
528 
529     HDassert(f);
530 
531     FUNC_LEAVE_NOAPI(f->shared->crt_dset_min_ohdr_flag)
532 } /* end H5F_get_min_dset_ohdr */
533 
534 
535 /*-------------------------------------------------------------------------
536  * Function: H5F_Kvalue
537  *
538  * Purpose:  Replaced a macro to retrieve a B-tree key value for a certain
539  *           type, now that the generic properties are being used to store
540  *           the B-tree values.
541  *
542  * Return:   Success:    Non-negative, and the B-tree key value is
543  *                              returned.
544  *           Failure:    Negative (should not happen)
545  *-------------------------------------------------------------------------
546  */
547 unsigned
H5F_Kvalue(const H5F_t * f,const H5B_class_t * type)548 H5F_Kvalue(const H5F_t *f, const H5B_class_t *type)
549 {
550     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
551     FUNC_ENTER_NOAPI_NOINIT_NOERR
552 
553     HDassert(f);
554     HDassert(f->shared);
555     HDassert(f->shared->sblock);
556     HDassert(type);
557 
558     FUNC_LEAVE_NOAPI(f->shared->sblock->btree_k[type->id])
559 } /* end H5F_Kvalue() */
560 
561 
562 /*-------------------------------------------------------------------------
563  * Function: H5F_get_nrefs
564  *
565  * Purpose:  Retrieve the file's 'nrefs' value
566  *
567  * Return:   'nrefs' on success/abort on failure (shouldn't fail)
568  *-------------------------------------------------------------------------
569  */
570 unsigned
H5F_get_nrefs(const H5F_t * f)571 H5F_get_nrefs(const H5F_t *f)
572 {
573     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
574     FUNC_ENTER_NOAPI_NOINIT_NOERR
575 
576     HDassert(f);
577     HDassert(f->shared);
578 
579     FUNC_LEAVE_NOAPI(f->shared->nrefs)
580 } /* end H5F_get_nrefs() */
581 
582 
583 /*-------------------------------------------------------------------------
584  * Function: H5F_rdcc_nslots
585  *
586  * Purpose:  Replaced a macro to retrieve the raw data cache number of slots,
587  *           now that the generic properties are being used to store
588  *           the values.
589  *
590  * Return:   Success:    Non-negative, and the raw data cache number of
591  *                              of slots is returned.
592  *           Failure:    Negative (should not happen)
593  *-------------------------------------------------------------------------
594  */
595 size_t
H5F_rdcc_nslots(const H5F_t * f)596 H5F_rdcc_nslots(const H5F_t *f)
597 {
598     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
599     FUNC_ENTER_NOAPI_NOINIT_NOERR
600 
601     HDassert(f);
602     HDassert(f->shared);
603 
604     FUNC_LEAVE_NOAPI(f->shared->rdcc_nslots)
605 } /* end H5F_rdcc_nelmts() */
606 
607 
608 /*-------------------------------------------------------------------------
609  * Function: H5F_rdcc_nbytes
610  *
611  * Purpose:  Replaced a macro to retrieve the raw data cache number of bytes,
612  *           now that the generic properties are being used to store
613  *           the values.
614  *
615  * Return:   Success:    Non-negative, and the raw data cache number of
616  *                              of bytes is returned.
617  *           Failure:    Negative (should not happen)
618  *-------------------------------------------------------------------------
619  */
620 size_t
H5F_rdcc_nbytes(const H5F_t * f)621 H5F_rdcc_nbytes(const H5F_t *f)
622 {
623     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
624     FUNC_ENTER_NOAPI_NOINIT_NOERR
625 
626     HDassert(f);
627     HDassert(f->shared);
628 
629     FUNC_LEAVE_NOAPI(f->shared->rdcc_nbytes)
630 } /* end H5F_rdcc_nbytes() */
631 
632 
633 /*-------------------------------------------------------------------------
634  * Function: H5F_rdcc_w0
635  *
636  * Purpose:  Replaced a macro to retrieve the raw data cache 'w0' value
637  *           now that the generic properties are being used to store
638  *           the values.
639  *
640  * Return:   Success:    Non-negative, and the raw data cache 'w0' value
641  *                              is returned.
642  *           Failure:    Negative (should not happen)
643  *-------------------------------------------------------------------------
644  */
645 double
H5F_rdcc_w0(const H5F_t * f)646 H5F_rdcc_w0(const H5F_t *f)
647 {
648     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
649     FUNC_ENTER_NOAPI_NOINIT_NOERR
650 
651     HDassert(f);
652     HDassert(f->shared);
653 
654     FUNC_LEAVE_NOAPI(f->shared->rdcc_w0)
655 } /* end H5F_rdcc_w0() */
656 
657 
658 /*-------------------------------------------------------------------------
659  * Function: H5F_get_base_addr
660  *
661  * Purpose:  Quick and dirty routine to retrieve the file's 'base_addr' value
662  *           (Mainly added to stop non-file routines from poking about in the
663  *           H5F_t data structure)
664  *
665  * Return:   Non-negative on success/Negative on failure
666  *-------------------------------------------------------------------------
667  */
668 haddr_t
H5F_get_base_addr(const H5F_t * f)669 H5F_get_base_addr(const H5F_t *f)
670 {
671     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
672     FUNC_ENTER_NOAPI_NOINIT_NOERR
673 
674     HDassert(f);
675     HDassert(f->shared);
676     HDassert(f->shared->sblock);
677 
678     FUNC_LEAVE_NOAPI(f->shared->sblock->base_addr)
679 } /* end H5F_get_base_addr() */
680 
681 
682 /*-------------------------------------------------------------------------
683  * Function: H5F_grp_btree_shared
684  *
685  * Purpose:  Replaced a macro to retrieve the shared B-tree node info
686  *           now that the generic properties are being used to store
687  *           the values.
688  *
689  * Return:   Success:    Non-void, and the shared B-tree node info
690  *                              is returned.
691  *           Failure:    void (should not happen)
692  *-------------------------------------------------------------------------
693  */
694 H5UC_t *
H5F_grp_btree_shared(const H5F_t * f)695 H5F_grp_btree_shared(const H5F_t *f)
696 {
697     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
698     FUNC_ENTER_NOAPI_NOINIT_NOERR
699 
700     HDassert(f);
701     HDassert(f->shared);
702 
703     FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared)
704 } /* end H5F_grp_btree_shared() */
705 
706 
707 /*-------------------------------------------------------------------------
708  * Function: H5F_sieve_buf_size
709  *
710  * Purpose:  Replaced a macro to retrieve the dataset sieve buffer size
711  *           now that the generic properties are being used to store
712  *           the values.
713  *
714  * Return:   Success:    Non-void, and the dataset sieve buffer size
715  *                              is returned.
716  *           Failure:    void (should not happen)
717  *-------------------------------------------------------------------------
718  */
719 size_t
H5F_sieve_buf_size(const H5F_t * f)720 H5F_sieve_buf_size(const H5F_t *f)
721 {
722     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
723     FUNC_ENTER_NOAPI_NOINIT_NOERR
724 
725     HDassert(f);
726     HDassert(f->shared);
727 
728     FUNC_LEAVE_NOAPI(f->shared->sieve_buf_size)
729 } /* end H5F_sieve_buf_size() */
730 
731 
732 /*-------------------------------------------------------------------------
733  * Function: H5F_gc_ref
734  *
735  * Purpose:  Replaced a macro to retrieve the "garbage collect
736  *           references flag" now that the generic properties are being used
737  *           to store the values.
738  *
739  * Return:  Success:    The "garbage collect references flag" is returned.
740  *          Failure:    (should not happen)
741  *
742  * Programmer:  Quincey Koziol
743  *              koziol@ncsa.uiuc.edu
744  *              Jul  8 2005
745  *
746  *-------------------------------------------------------------------------
747  */
748 unsigned
H5F_gc_ref(const H5F_t * f)749 H5F_gc_ref(const H5F_t *f)
750 {
751     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
752     FUNC_ENTER_NOAPI_NOINIT_NOERR
753 
754     HDassert(f);
755     HDassert(f->shared);
756 
757     FUNC_LEAVE_NOAPI(f->shared->gc_ref)
758 } /* end H5F_gc_ref() */
759 
760 
761 /*-------------------------------------------------------------------------
762  * Function: H5F_get_fc_degree
763  *
764  * Purpose:  Retrieve the 'file close degree' for the file.
765  *
766  * Return:   Success:    Non-negative, the 'file close degree'
767  *           Failure:    (can't happen)
768  *-------------------------------------------------------------------------
769  */
770 H5F_close_degree_t
H5F_get_fc_degree(const H5F_t * f)771 H5F_get_fc_degree(const H5F_t *f)
772 {
773     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
774     FUNC_ENTER_NOAPI_NOINIT_NOERR
775 
776     HDassert(f);
777     HDassert(f->shared);
778 
779     FUNC_LEAVE_NOAPI(f->shared->fc_degree)
780 } /* end H5F_get_fc_degree() */
781 
782 
783 /*-------------------------------------------------------------------------
784  * Function:    H5F_get_evict_on_close
785  *
786  * Purpose:     Checks if evict-on-close is desired for objects in the
787  *              file.
788  *
789  * Return:      Success:    Flag indicating whether the evict-on-close
790  *                          property was set for the file.
791  *              Failure:    (can't happen)
792  *-------------------------------------------------------------------------
793  */
794 hbool_t
H5F_get_evict_on_close(const H5F_t * f)795 H5F_get_evict_on_close(const H5F_t *f)
796 {
797     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
798     FUNC_ENTER_NOAPI_NOINIT_NOERR
799 
800     HDassert(f);
801     HDassert(f->shared);
802 
803     FUNC_LEAVE_NOAPI(f->shared->evict_on_close)
804 } /* end H5F_get_evict_on_close() */
805 
806 
807 /*-------------------------------------------------------------------------
808  * Function: H5F_store_msg_crt_idx
809  *
810  * Purpose:  Retrieve the 'store message creation index' flag for the file.
811  *
812  * Return:   Success:    Non-negative, the 'store message creation index' flag
813  *           Failure:    (can't happen)
814  *-------------------------------------------------------------------------
815  */
816 hbool_t
H5F_store_msg_crt_idx(const H5F_t * f)817 H5F_store_msg_crt_idx(const H5F_t *f)
818 {
819     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
820     FUNC_ENTER_NOAPI_NOINIT_NOERR
821 
822     HDassert(f);
823     HDassert(f->shared);
824 
825     FUNC_LEAVE_NOAPI(f->shared->store_msg_crt_idx)
826 } /* end H5F_store_msg_crt_idx() */
827 
828 
829 /*-------------------------------------------------------------------------
830  * Function: H5F_has_feature
831  *
832  * Purpose:  Check if a file has a particular feature enabled
833  *
834  * Return:   Success:    Non-negative - TRUE or FALSE
835  *           Failure:    Negative (should not happen)
836  *-------------------------------------------------------------------------
837  */
838 hbool_t
H5F_has_feature(const H5F_t * f,unsigned feature)839 H5F_has_feature(const H5F_t *f, unsigned feature)
840 {
841     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
842     FUNC_ENTER_NOAPI_NOINIT_NOERR
843 
844     HDassert(f);
845     HDassert(f->shared);
846 
847     FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags&feature))
848 } /* end H5F_has_feature() */
849 
850 
851 /*-------------------------------------------------------------------------
852  * Function: H5F_get_driver_id
853  *
854  * Purpose:  Quick and dirty routine to retrieve the file's 'driver_id' value
855  *           (Mainly added to stop non-file routines from poking about in the
856  *           H5F_t data structure)
857  *
858  * Return:   'driver_id' on success/abort on failure (shouldn't fail)
859  *-------------------------------------------------------------------------
860  */
861 hid_t
H5F_get_driver_id(const H5F_t * f)862 H5F_get_driver_id(const H5F_t *f)
863 {
864     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
865     FUNC_ENTER_NOAPI_NOINIT_NOERR
866 
867     HDassert(f);
868     HDassert(f->shared);
869     HDassert(f->shared->lf);
870 
871     FUNC_LEAVE_NOAPI(f->shared->lf->driver_id)
872 } /* end H5F_get_driver_id() */
873 
874 
875 /*-------------------------------------------------------------------------
876  * Function: H5F_get_fileno
877  *
878  * Purpose:  Quick and dirty routine to retrieve the file's 'fileno' value
879  *           (Mainly added to stop non-file routines from poking about in the
880  *           H5F_t data structure)
881  *
882  * Return:   Non-negative on success/Negative on failure
883  *-------------------------------------------------------------------------
884  */
885 herr_t
H5F_get_fileno(const H5F_t * f,unsigned long * filenum)886 H5F_get_fileno(const H5F_t *f, unsigned long *filenum)
887 {
888     herr_t    ret_value = SUCCEED;
889 
890     FUNC_ENTER_NOAPI(FAIL)
891 
892     HDassert(f);
893     HDassert(f->shared);
894     HDassert(f->shared->lf);
895     HDassert(filenum);
896 
897     /* Retrieve the file's serial number */
898     if(H5FD_get_fileno(f->shared->lf, filenum) < 0)
899     HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno")
900 
901 done:
902     FUNC_LEAVE_NOAPI(ret_value)
903 } /* end H5F_get_fileno() */
904 
905 
906 /*-------------------------------------------------------------------------
907  * Function: H5F_get_eoa
908  *
909  * Purpose:  Quick and dirty routine to retrieve the file's 'eoa' value
910  *
911  * Return:   Non-negative on success/Negative on failure
912  *-------------------------------------------------------------------------
913  */
914 haddr_t
H5F_get_eoa(const H5F_t * f,H5FD_mem_t type)915 H5F_get_eoa(const H5F_t *f, H5FD_mem_t type)
916 {
917     haddr_t    ret_value = HADDR_UNDEF;        /* Return value */
918 
919     FUNC_ENTER_NOAPI(HADDR_UNDEF)
920 
921     HDassert(f);
922     HDassert(f->shared);
923 
924     /* Dispatch to driver */
925     if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type)))
926     HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
927 
928 done:
929     FUNC_LEAVE_NOAPI(ret_value)
930 } /* end H5F_get_eoa() */
931 
932 
933 /*-------------------------------------------------------------------------
934  * Function:    H5F_get_vfd_handle
935  *
936  * Purpose:     Returns a pointer to the file handle of the low-level file
937  *              driver.  This is the private function for H5Fget_vfd_handle.
938  *
939  * Return:      Success:        Non-negative.
940  *              Failure:        negative.
941  *-------------------------------------------------------------------------
942  */
943 herr_t
H5F_get_vfd_handle(const H5F_t * file,hid_t fapl,void ** file_handle)944 H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle)
945 {
946     herr_t ret_value = SUCCEED;         /* Return value */
947 
948     FUNC_ENTER_NOAPI(FAIL)
949 
950     /* Sanity check */
951     HDassert(file);
952     HDassert(file_handle);
953 
954     /* Get the VFD handle */
955     if(H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0)
956         HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver")
957 
958 done:
959     FUNC_LEAVE_NOAPI(ret_value)
960 } /* end H5F_get_vfd_handle() */
961 
962 
963 /*-------------------------------------------------------------------------
964  * Function: H5F_is_tmp_addr
965  *
966  * Purpose:  Quick and dirty routine to determine if an address is in
967  *           the 'temporary' file space.
968  *           (Mainly added to stop non-file routines from poking about in the
969  *           H5F_t data structure)
970  *
971  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
972  *-------------------------------------------------------------------------
973  */
974 hbool_t
H5F_is_tmp_addr(const H5F_t * f,haddr_t addr)975 H5F_is_tmp_addr(const H5F_t *f, haddr_t addr)
976 {
977     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
978     FUNC_ENTER_NOAPI_NOINIT_NOERR
979 
980     HDassert(f);
981     HDassert(f->shared);
982 
983     FUNC_LEAVE_NOAPI(H5F_addr_le(f->shared->tmp_addr, addr))
984 } /* end H5F_is_tmp_addr() */
985 
986 
987 /*-------------------------------------------------------------------------
988  * Function: H5F_use_tmp_space
989  *
990  * Purpose:  Quick and dirty routine to determine if using temporary
991  *           file space is allowed for this file.
992  *           (Mainly added to stop non-file routines from poking about in the
993  *           H5F_t data structure)
994  *
995  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
996  *-------------------------------------------------------------------------
997  */
998 hbool_t
H5F_use_tmp_space(const H5F_t * f)999 H5F_use_tmp_space(const H5F_t *f)
1000 {
1001     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1002     FUNC_ENTER_NOAPI_NOINIT_NOERR
1003 
1004     HDassert(f);
1005     HDassert(f->shared);
1006 
1007     FUNC_LEAVE_NOAPI(f->shared->use_tmp_space)
1008 } /* end H5F_use_tmp_space() */
1009 
1010 #ifdef H5_HAVE_PARALLEL
1011 
1012 /*-------------------------------------------------------------------------
1013  * Function: H5F_coll_md_read
1014  *
1015  * Purpose:  Retrieve the 'collective metadata reads' flag for the file.
1016  *
1017  * Return:   Success:    Non-negative, the 'collective metadata reads' flag
1018  *           Failure:    (can't happen)
1019  *-------------------------------------------------------------------------
1020  */
1021 H5P_coll_md_read_flag_t
H5F_coll_md_read(const H5F_t * f)1022 H5F_coll_md_read(const H5F_t *f)
1023 {
1024     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1025     FUNC_ENTER_NOAPI_NOINIT_NOERR
1026 
1027     HDassert(f);
1028 
1029     FUNC_LEAVE_NOAPI(f->coll_md_read)
1030 } /* end H5F_coll_md_read() */
1031 #endif /* H5_HAVE_PARALLEL */
1032 
1033 
1034 /*-------------------------------------------------------------------------
1035  * Function: H5F_use_mdc_logging
1036  *
1037  * Purpose:  Quick and dirty routine to determine if using MDC logging
1038  *           is enabled for this file.
1039  *           (Mainly added to stop non-file routines from poking about in the
1040  *           H5F_t data structure)
1041  *
1042  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
1043  *-------------------------------------------------------------------------
1044  */
1045 hbool_t
H5F_use_mdc_logging(const H5F_t * f)1046 H5F_use_mdc_logging(const H5F_t *f)
1047 {
1048     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1049     FUNC_ENTER_NOAPI_NOINIT_NOERR
1050 
1051     HDassert(f);
1052     HDassert(f->shared);
1053 
1054     FUNC_LEAVE_NOAPI(f->shared->use_mdc_logging)
1055 } /* end H5F_use_mdc_logging() */
1056 
1057 
1058 /*-------------------------------------------------------------------------
1059  * Function: H5F_start_mdc_log_on_access
1060  *
1061  * Purpose:  Quick and dirty routine to determine if we should start MDC
1062  *           logging on access for this file.
1063  *           (Mainly added to stop non-file routines from poking about in the
1064  *           H5F_t data structure)
1065  *
1066  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
1067  *-------------------------------------------------------------------------
1068  */
1069 hbool_t
H5F_start_mdc_log_on_access(const H5F_t * f)1070 H5F_start_mdc_log_on_access(const H5F_t *f)
1071 {
1072     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1073     FUNC_ENTER_NOAPI_NOINIT_NOERR
1074 
1075     HDassert(f);
1076     HDassert(f->shared);
1077 
1078     FUNC_LEAVE_NOAPI(f->shared->start_mdc_log_on_access)
1079 } /* end H5F_start_mdc_log_on_access() */
1080 
1081 
1082 /*-------------------------------------------------------------------------
1083  * Function: H5F_mdc_log_location
1084  *
1085  * Purpose:  Quick and dirty routine to retrieve the MDC log location
1086  *           for this file.
1087  *           (Mainly added to stop non-file routines from poking about in the
1088  *           H5F_t data structure)
1089  *
1090  * Return:   TRUE/FALSE on success/abort on failure (shouldn't fail)
1091  *-------------------------------------------------------------------------
1092  */
1093 char *
H5F_mdc_log_location(const H5F_t * f)1094 H5F_mdc_log_location(const H5F_t *f)
1095 {
1096     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1097     FUNC_ENTER_NOAPI_NOINIT_NOERR
1098 
1099     HDassert(f);
1100     HDassert(f->shared);
1101 
1102     FUNC_LEAVE_NOAPI(f->shared->mdc_log_location)
1103 } /* end H5F_mdc_log_location() */
1104 
1105 
1106 /*-------------------------------------------------------------------------
1107  * Function: H5F_get_alignment
1108  *
1109  * Purpose:  Retrieve the 'alignment' for the file.
1110  *
1111  * Return:   Success:    Non-negative, the 'alignment'
1112  *           Failure:    (can't happen)
1113  *-------------------------------------------------------------------------
1114  */
1115 hsize_t
H5F_get_alignment(const H5F_t * f)1116 H5F_get_alignment(const H5F_t *f)
1117 {
1118     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1119     FUNC_ENTER_NOAPI_NOINIT_NOERR
1120 
1121     HDassert(f);
1122     HDassert(f->shared);
1123 
1124     FUNC_LEAVE_NOAPI(f->shared->alignment)
1125 } /* end H5F_get_alignment() */
1126 
1127 
1128 /*-------------------------------------------------------------------------
1129  * Function: H5F_get_threshold
1130  *
1131  * Purpose:  Retrieve the 'threshold' for alignment in the file.
1132  *
1133  * Return:   Success:    Non-negative, the 'threshold'
1134  *           Failure:    (can't happen)
1135  *-------------------------------------------------------------------------
1136  */
1137 hsize_t
H5F_get_threshold(const H5F_t * f)1138 H5F_get_threshold(const H5F_t *f)
1139 {
1140     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1141     FUNC_ENTER_NOAPI_NOINIT_NOERR
1142 
1143     HDassert(f);
1144     HDassert(f->shared);
1145 
1146     FUNC_LEAVE_NOAPI(f->shared->threshold)
1147 } /* end H5F_get_threshold() */
1148 
1149 
1150 /*-------------------------------------------------------------------------
1151  * Function: H5F_get_pgend_meta_thres
1152  *
1153  * Purpose:  Retrieve the 'page end meta threshold size' for the file.
1154  *
1155  * Return:   Success:    Non-negative, the 'pgend_meta_thres'
1156  *           Failure:    (can't happen)
1157  *-------------------------------------------------------------------------
1158  */
1159 hsize_t
H5F_get_pgend_meta_thres(const H5F_t * f)1160 H5F_get_pgend_meta_thres(const H5F_t *f)
1161 {
1162     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1163     FUNC_ENTER_NOAPI_NOINIT_NOERR
1164 
1165     HDassert(f);
1166     HDassert(f->shared);
1167 
1168     FUNC_LEAVE_NOAPI(f->shared->pgend_meta_thres)
1169 } /* end H5F_get_pgend_meta_thres() */
1170 
1171 
1172 /*-------------------------------------------------------------------------
1173  * Function: H5F_get_point_of_no_return
1174  *
1175  * Purpose:  Retrieve the 'point of no return' value for the file.
1176  *
1177  * Return:   Success:    Non-negative, the 'point_of_no_return'
1178  *           Failure:    (can't happen)
1179  *-------------------------------------------------------------------------
1180  */
1181 hbool_t
H5F_get_point_of_no_return(const H5F_t * f)1182 H5F_get_point_of_no_return(const H5F_t *f)
1183 {
1184     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1185     FUNC_ENTER_NOAPI_NOINIT_NOERR
1186 
1187     HDassert(f);
1188     HDassert(f->shared);
1189 
1190     FUNC_LEAVE_NOAPI(f->shared->point_of_no_return)
1191 } /* end H5F_get_point_of_no_return() */
1192 
1193 
1194 /*-------------------------------------------------------------------------
1195  * Function: H5F_get_first_alloc_dealloc
1196  *
1197  * Purpose:  Retrieve the 'first alloc / dealloc' value for the file.
1198  *
1199  * Return:   Success:    Non-negative, the 'first_alloc_dealloc'
1200  *           Failure:    (can't happen)
1201  *-------------------------------------------------------------------------
1202  */
1203 hbool_t
H5F_get_first_alloc_dealloc(const H5F_t * f)1204 H5F_get_first_alloc_dealloc(const H5F_t *f)
1205 {
1206     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1207     FUNC_ENTER_NOAPI_NOINIT_NOERR
1208 
1209     HDassert(f);
1210     HDassert(f->shared);
1211 
1212     FUNC_LEAVE_NOAPI(f->shared->first_alloc_dealloc)
1213 } /* end H5F_get_first_alloc_dealloc() */
1214 
1215 
1216 /*-------------------------------------------------------------------------
1217  * Function: H5F_get_eoa_pre_fsm_fsalloc
1218  *
1219  * Purpose:  Retrieve the 'EOA pre-FSM fsalloc' value for the file.
1220  *
1221  * Return:   Success:    Non-negative, the 'EOA pre-FSM fsalloc'
1222  *           Failure:    (can't happen)
1223  *-------------------------------------------------------------------------
1224  */
1225 haddr_t
H5F_get_eoa_pre_fsm_fsalloc(const H5F_t * f)1226 H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f)
1227 {
1228     /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
1229     FUNC_ENTER_NOAPI_NOINIT_NOERR
1230 
1231     HDassert(f);
1232     HDassert(f->shared);
1233 
1234     FUNC_LEAVE_NOAPI(f->shared->eoa_pre_fsm_fsalloc)
1235 } /* end H5F_get_eoa_pre_fsm_fsalloc() */
1236 
1237