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 /* Module Setup */
16 /****************/
17
18 #include "H5Fmodule.h" /* This source code file is part of the H5F module */
19
20
21 /***********/
22 /* Headers */
23 /***********/
24 #include "H5private.h" /* Generic Functions */
25 #include "H5Aprivate.h" /* Attributes */
26 #include "H5ACprivate.h" /* Metadata cache */
27 #include "H5CXprivate.h" /* API Contexts */
28 #include "H5Dprivate.h" /* Datasets */
29 #include "H5Eprivate.h" /* Error handling */
30 #include "H5Fpkg.h" /* File access */
31 #include "H5FDprivate.h" /* File drivers */
32 #include "H5Gprivate.h" /* Groups */
33 #include "H5Iprivate.h" /* IDs */
34 #include "H5MFprivate.h" /* File memory management */
35 #include "H5MMprivate.h" /* Memory management */
36 #include "H5Pprivate.h" /* Property lists */
37 #include "H5Tprivate.h" /* Datatypes */
38
39
40 /****************/
41 /* Local Macros */
42 /****************/
43
44 /******************/
45 /* Local Typedefs */
46 /******************/
47
48
49 /********************/
50 /* Package Typedefs */
51 /********************/
52
53
54 /********************/
55 /* Local Prototypes */
56 /********************/
57
58
59 /*********************/
60 /* Package Variables */
61 /*********************/
62
63 /* Package initialization variable */
64 hbool_t H5_PKG_INIT_VAR = FALSE;
65
66
67 /*****************************/
68 /* Library Private Variables */
69 /*****************************/
70
71
72 /*******************/
73 /* Local Variables */
74 /*******************/
75
76
77 /* File ID class */
78 static const H5I_class_t H5I_FILE_CLS[1] = {{
79 H5I_FILE, /* ID class value */
80 0, /* Class flags */
81 0, /* # of reserved IDs for class */
82 (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */
83 }};
84
85
86 /*--------------------------------------------------------------------------
87 NAME
88 H5F__init_package -- Initialize interface-specific information
89 USAGE
90 herr_t H5F__init_package()
91 RETURNS
92 Non-negative on success/Negative on failure
93 DESCRIPTION
94 Initializes any interface-specific data or routines.
95
96 --------------------------------------------------------------------------*/
97 herr_t
H5F__init_package(void)98 H5F__init_package(void)
99 {
100 herr_t ret_value = SUCCEED; /* Return value */
101
102 FUNC_ENTER_PACKAGE
103
104 /*
105 * Initialize the atom group for the file IDs.
106 */
107 if(H5I_register_type(H5I_FILE_CLS) < 0)
108 HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
109
110 done:
111 FUNC_LEAVE_NOAPI(ret_value)
112 } /* H5F__init_package() */
113
114
115 /*-------------------------------------------------------------------------
116 * Function: H5F_term_package
117 *
118 * Purpose: Terminate this interface: free all memory and reset global
119 * variables to their initial values. Release all ID groups
120 * associated with this interface.
121 *
122 * Return: Success: Positive if anything was done that might
123 * have affected other interfaces;
124 * zero otherwise.
125 * Failure: Never fails.
126 *-------------------------------------------------------------------------
127 */
128 int
H5F_term_package(void)129 H5F_term_package(void)
130 {
131 int n = 0;
132
133 FUNC_ENTER_NOAPI_NOINIT_NOERR
134
135 if(H5_PKG_INIT_VAR) {
136 if(H5I_nmembers(H5I_FILE) > 0) {
137 (void)H5I_clear_type(H5I_FILE, FALSE, FALSE);
138 n++; /*H5I*/
139 } /* end if */
140 else {
141 /* Make certain we've cleaned up all the shared file objects */
142 H5F_sfile_assert_num(0);
143
144 /* Destroy the file object id group */
145 n += (H5I_dec_type_ref(H5I_FILE) > 0);
146
147 /* Mark closed */
148 if(0 == n)
149 H5_PKG_INIT_VAR = FALSE;
150 } /* end else */
151 } /* end if */
152
153 FUNC_LEAVE_NOAPI(n)
154 } /* end H5F_term_package() */
155
156
157 /*-------------------------------------------------------------------------
158 * Function: H5Fget_create_plist
159 *
160 * Purpose: Get an atom for a copy of the file-creation property list for
161 * this file. This function returns an atom with a copy of the
162 * properties used to create a file.
163 *
164 * Return: Success: template ID
165 * Failure: FAIL
166 *-------------------------------------------------------------------------
167 */
168 hid_t
H5Fget_create_plist(hid_t file_id)169 H5Fget_create_plist(hid_t file_id)
170 {
171 H5F_t *file; /* File info */
172 H5P_genplist_t *plist; /* Property list */
173 hid_t ret_value; /* Return value */
174
175 FUNC_ENTER_API(FAIL)
176 H5TRACE1("i", "i", file_id);
177
178 /* check args */
179 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
180 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
181 if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id)))
182 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
183
184 /* Create the property list object to return */
185 if((ret_value = H5P_copy_plist(plist, TRUE)) < 0)
186 HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties")
187
188 done:
189 FUNC_LEAVE_API(ret_value)
190 } /* end H5Fget_create_plist() */
191
192
193 /*-------------------------------------------------------------------------
194 * Function: H5Fget_access_plist
195 *
196 * Purpose: Returns a copy of the file access property list of the
197 * specified file.
198 *
199 * NOTE: Make sure that, if you are going to overwrite
200 * information in the copied property list that was
201 * previously opened and assigned to the property list, then
202 * you must close it before overwriting the values.
203 *
204 * Return: Success: Object ID for a copy of the file access
205 * property list.
206 * Failure: FAIL
207 *-------------------------------------------------------------------------
208 */
209 hid_t
H5Fget_access_plist(hid_t file_id)210 H5Fget_access_plist(hid_t file_id)
211 {
212 H5F_t *f; /* File info */
213 hid_t ret_value; /* Return value */
214
215 FUNC_ENTER_API(FAIL)
216 H5TRACE1("i", "i", file_id);
217
218 /* Check args */
219 if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
220 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
221
222 /* Retrieve the file's access property list */
223 if((ret_value = H5F_get_access_plist(f, TRUE)) < 0)
224 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list")
225
226 done:
227 FUNC_LEAVE_API(ret_value)
228 } /* end H5Fget_access_plist() */
229
230
231 /*-------------------------------------------------------------------------
232 * Function: H5Fget_obj_count
233 *
234 * Purpose: Public function returning the number of opened object IDs
235 * (files, datasets, groups and datatypes) in the same file.
236 *
237 * Return: Non-negative on success; negative on failure.
238 *-------------------------------------------------------------------------
239 */
240 ssize_t
H5Fget_obj_count(hid_t file_id,unsigned types)241 H5Fget_obj_count(hid_t file_id, unsigned types)
242 {
243 H5F_t *f = NULL; /* File to query */
244 size_t obj_count = 0; /* Number of opened objects */
245 ssize_t ret_value; /* Return value */
246
247 FUNC_ENTER_API(FAIL)
248 H5TRACE2("Zs", "iIu", file_id, types);
249
250 /* Check arguments */
251 if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))))
252 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id")
253 if(0 == (types & H5F_OBJ_ALL))
254 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type")
255
256 /* Perform the query */
257 if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
258 HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
259
260 /* Set the return value */
261 ret_value = (ssize_t)obj_count;
262
263 done:
264 FUNC_LEAVE_API(ret_value)
265 } /* end H5Fget_obj_count() */
266
267
268 /*-------------------------------------------------------------------------
269 * Function: H5Fget_object_ids
270 *
271 * Purpose: Public function to return a list of opened object IDs.
272 *
273 * Return: Non-negative on success; negative on failure.
274 *-------------------------------------------------------------------------
275 */
276 ssize_t
H5Fget_obj_ids(hid_t file_id,unsigned types,size_t max_objs,hid_t * oid_list)277 H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list)
278 {
279 H5F_t *f = NULL; /* File to query */
280 size_t obj_id_count = 0; /* Number of open objects */
281 ssize_t ret_value; /* Return value */
282
283 FUNC_ENTER_API(FAIL)
284 H5TRACE4("Zs", "iIuz*i", file_id, types, max_objs, oid_list);
285
286 /* Check arguments */
287 if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))))
288 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id")
289 if(0 == (types & H5F_OBJ_ALL))
290 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type")
291 if(!oid_list)
292 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "object ID list is NULL")
293
294 /* Perform the query */
295 if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_id_count) < 0)
296 HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed")
297
298 /* Set the return value */
299 ret_value = (ssize_t)obj_id_count;
300
301 done:
302 FUNC_LEAVE_API(ret_value)
303 } /* end H5Fget_obj_ids() */
304
305
306 /*-------------------------------------------------------------------------
307 * Function: H5Fget_vfd_handle
308 *
309 * Purpose: Returns a pointer to the file handle of the low-level file
310 * driver.
311 *
312 * Return: Success: non-negative value.
313 * Failure: negative.
314 *-------------------------------------------------------------------------
315 */
316 herr_t
H5Fget_vfd_handle(hid_t file_id,hid_t fapl,void ** file_handle)317 H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle)
318 {
319 H5F_t *file; /* File to query */
320 herr_t ret_value = SUCCEED; /* Return value */
321
322 FUNC_ENTER_API(FAIL)
323 H5TRACE3("e", "ii**x", file_id, fapl, file_handle);
324
325 /* Check args */
326 if(!file_handle)
327 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer")
328
329 /* Get the file */
330 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
331 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id")
332
333 /* Retrieve the VFD handle for the file */
334 if(H5F_get_vfd_handle(file, fapl, file_handle) < 0)
335 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle")
336
337 done:
338 FUNC_LEAVE_API(ret_value)
339 } /* end H5Fget_vfd_handle() */
340
341
342 /*-------------------------------------------------------------------------
343 * Function: H5Fis_hdf5
344 *
345 * Purpose: Check the file signature to detect an HDF5 file.
346 *
347 * Bugs: This function is not robust: it only uses the default file
348 * driver when attempting to open the file when in fact it
349 * should use all known file drivers.
350 *
351 * Return: Success: TRUE/FALSE
352 * Failure: Negative
353 *-------------------------------------------------------------------------
354 */
355 htri_t
H5Fis_hdf5(const char * name)356 H5Fis_hdf5(const char *name)
357 {
358 htri_t ret_value; /* Return value */
359
360 FUNC_ENTER_API(FAIL)
361 H5TRACE1("t", "*s", name);
362
363 /* Check args and all the boring stuff. */
364 if(!name || !*name)
365 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
366
367 /* call the private is_HDF5 function */
368 /* (Should not trigger raw data I/O - QAK, 2018/01/03) */
369 if((ret_value = H5F__is_hdf5(name)) < 0)
370 HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable open file")
371
372 done:
373 FUNC_LEAVE_API(ret_value)
374 } /* end H5Fis_hdf5() */
375
376
377 /*-------------------------------------------------------------------------
378 * Function: H5Fcreate
379 *
380 * Purpose: This is the primary function for creating HDF5 files . The
381 * flags parameter determines whether an existing file will be
382 * overwritten or not. All newly created files are opened for
383 * both reading and writing. All flags may be combined with the
384 * bit-wise OR operator (`|') to change the behavior of the file
385 * create call.
386 *
387 * The more complex behaviors of a file's creation and access
388 * are controlled through the file-creation and file-access
389 * property lists. The value of H5P_DEFAULT for a template
390 * value indicates that the library should use the default
391 * values for the appropriate template.
392 *
393 * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for
394 * the list of file creation and file access properties.
395 *
396 * Return: Success: A file ID
397 * Failure: FAIL
398 *-------------------------------------------------------------------------
399 */
400 hid_t
H5Fcreate(const char * filename,unsigned flags,hid_t fcpl_id,hid_t fapl_id)401 H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
402 {
403 H5F_t *new_file = NULL; /* file struct for new file */
404 hid_t ret_value; /* return value */
405
406 FUNC_ENTER_API(H5I_INVALID_HID)
407 H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id);
408
409 /* Check/fix arguments */
410 if (!filename || !*filename)
411 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name")
412
413 /* In this routine, we only accept the following flags:
414 * H5F_ACC_EXCL, H5F_ACC_TRUNC and H5F_ACC_SWMR_WRITE
415 */
416 if (flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE))
417 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid flags")
418
419 /* The H5F_ACC_EXCL and H5F_ACC_TRUNC flags are mutually exclusive */
420 if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC))
421 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "mutually exclusive flags for file creation")
422
423 /* Check file creation property list */
424 if (H5P_DEFAULT == fcpl_id)
425 fcpl_id = H5P_FILE_CREATE_DEFAULT;
426 else
427 if (TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE))
428 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list")
429
430 /* Verify access property list and set up collective metadata if appropriate */
431 if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
432 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
433
434 /* Adjust bit flags by turning on the creation bit and making sure that
435 * the EXCL or TRUNC bit is set. All newly-created files are opened for
436 * reading and writing.
437 */
438 if (0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC)))
439 flags |= H5F_ACC_EXCL; /*default*/
440 flags |= H5F_ACC_RDWR | H5F_ACC_CREAT;
441
442 /* Create a new file or truncate an existing file. */
443 if (NULL == (new_file = H5F__create(filename, flags, fcpl_id, fapl_id)))
444 HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file")
445
446 /* Get an atom for the file */
447 if ((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
448 HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file")
449
450 /* Keep this ID in file object structure */
451 new_file->file_id = ret_value;
452
453 done:
454 if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0)
455 HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file")
456
457 FUNC_LEAVE_API(ret_value)
458 } /* end H5Fcreate() */
459
460
461 /*-------------------------------------------------------------------------
462 * Function: H5Fopen
463 *
464 * Purpose: This is the primary function for accessing existing HDF5
465 * files. The FLAGS argument determines whether writing to an
466 * existing file will be allowed or not. All flags may be
467 * combined with the bit-wise OR operator (`|') to change the
468 * behavior of the file open call. The more complex behaviors
469 * of a file's access are controlled through the file-access
470 * property list.
471 *
472 * See Also: H5Fpublic.h for a list of possible values for FLAGS.
473 *
474 * Return: Success: A file ID
475 *
476 * Failure: FAIL
477 *
478 *-------------------------------------------------------------------------
479 */
480 hid_t
H5Fopen(const char * filename,unsigned flags,hid_t fapl_id)481 H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
482 {
483 H5F_t *new_file = NULL; /* file struct for new file */
484 hid_t ret_value; /* return value */
485
486 FUNC_ENTER_API(H5I_INVALID_HID)
487 H5TRACE3("i", "*sIui", filename, flags, fapl_id);
488
489 /* Check/fix arguments. */
490 if(!filename || !*filename)
491 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name")
492 /* Reject undefined flags (~H5F_ACC_PUBLIC_FLAGS) and the H5F_ACC_TRUNC & H5F_ACC_EXCL flags */
493 if((flags & ~H5F_ACC_PUBLIC_FLAGS) ||
494 (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL))
495 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags")
496 /* Asking for SWMR write access on a read-only file is invalid */
497 if((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR))
498 HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR write access on a file open for read-only access is not allowed")
499 /* Asking for SWMR read access on a non-read-only file is invalid */
500 if((flags & H5F_ACC_SWMR_READ) && (flags & H5F_ACC_RDWR))
501 HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR read access on a file open for read-write access is not allowed")
502
503 /* Verify access property list and set up collective metadata if appropriate */
504 if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
505 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
506
507 /* Open the file */
508 if(NULL == (new_file = H5F__open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id)))
509 HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file")
510
511 /* Get an atom for the file */
512 if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
513 HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle")
514
515 /* Keep this ID in file object structure */
516 new_file->file_id = ret_value;
517
518 done:
519 if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0)
520 HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file")
521
522 FUNC_LEAVE_API(ret_value)
523 } /* end H5Fopen() */
524
525
526 /*-------------------------------------------------------------------------
527 * Function: H5Fflush
528 *
529 * Purpose: Flushes all outstanding buffers of a file to disk but does
530 * not remove them from the cache. The OBJECT_ID can be a file,
531 * dataset, group, attribute, or named data type.
532 *
533 * Return: Non-negative on success/Negative on failure
534 *-------------------------------------------------------------------------
535 */
536 herr_t
H5Fflush(hid_t object_id,H5F_scope_t scope)537 H5Fflush(hid_t object_id, H5F_scope_t scope)
538 {
539 H5F_t *f = NULL; /* File to flush */
540 H5O_loc_t *oloc = NULL; /* Object location for ID */
541 herr_t ret_value = SUCCEED; /* Return value */
542
543 FUNC_ENTER_API(FAIL)
544 H5TRACE2("e", "iFs", object_id, scope);
545
546 switch(H5I_get_type(object_id)) {
547 case H5I_FILE:
548 if(NULL == (f = (H5F_t *)H5I_object(object_id)))
549 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
550 break;
551
552 case H5I_GROUP:
553 {
554 H5G_t *grp;
555
556 if(NULL == (grp = (H5G_t *)H5I_object(object_id)))
557 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
558 oloc = H5G_oloc(grp);
559 }
560 break;
561
562 case H5I_DATATYPE:
563 {
564 H5T_t *type;
565
566 if(NULL == (type = (H5T_t *)H5I_object(object_id)))
567 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier")
568 oloc = H5T_oloc(type);
569 }
570 break;
571
572 case H5I_DATASET:
573 {
574 H5D_t *dset;
575
576 if(NULL == (dset = (H5D_t *)H5I_object(object_id)))
577 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
578 oloc = H5D_oloc(dset);
579 }
580 break;
581
582 case H5I_ATTR:
583 {
584 H5A_t *attr;
585
586 if(NULL == (attr = (H5A_t *)H5I_object(object_id)))
587 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
588 oloc = H5A_oloc(attr);
589 }
590 break;
591
592 case H5I_UNINIT:
593 case H5I_BADID:
594 case H5I_DATASPACE:
595 case H5I_REFERENCE:
596 case H5I_VFL:
597 case H5I_GENPROP_CLS:
598 case H5I_GENPROP_LST:
599 case H5I_ERROR_CLASS:
600 case H5I_ERROR_MSG:
601 case H5I_ERROR_STACK:
602 case H5I_NTYPES:
603 default:
604 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
605 } /* end switch */
606
607 if(!f) {
608 if(!oloc)
609 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file")
610 f = oloc->file;
611 } /* end if */
612 if(!f)
613 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file")
614
615 /* Flush the file */
616 /*
617 * Nothing to do if the file is read only. This determination is
618 * made at the shared open(2) flags level, implying that opening a
619 * file twice, once for read-only and once for read-write, and then
620 * calling H5Fflush() with the read-only handle, still causes data
621 * to be flushed.
622 */
623 if(H5F_ACC_RDWR & H5F_INTENT(f)) {
624 hid_t fapl_id = H5P_DEFAULT; /* FAPL to use */
625
626 /* Verify access property list and set up collective metadata if appropriate */
627 if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, object_id, TRUE) < 0)
628 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access property list info")
629
630 /* Flush the file */
631 if(H5F__flush(f, scope) < 0)
632 HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
633 } /* end if */
634
635 done:
636 FUNC_LEAVE_API(ret_value)
637 } /* end H5Fflush() */
638
639
640 /*-------------------------------------------------------------------------
641 * Function: H5Fclose
642 *
643 * Purpose: This function closes the file specified by FILE_ID by
644 * flushing all data to storage, and terminating access to the
645 * file through FILE_ID. If objects (e.g., datasets, groups,
646 * etc.) are open in the file then the underlying storage is not
647 * closed until those objects are closed; however, all data for
648 * the file and the open objects is flushed.
649 *
650 * Return: Success: Non-negative
651 * Failure: Negative
652 *-------------------------------------------------------------------------
653 */
654 herr_t
H5Fclose(hid_t file_id)655 H5Fclose(hid_t file_id)
656 {
657 herr_t ret_value = SUCCEED;
658
659 FUNC_ENTER_API(FAIL)
660 H5TRACE1("e", "i", file_id);
661
662 /* Check arguments */
663 if(H5I_FILE != H5I_get_type(file_id))
664 HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file ID")
665
666 /* Close the file */
667 if(H5F__close(file_id) < 0)
668 HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "closing file ID failed")
669
670 done:
671 FUNC_LEAVE_API(ret_value)
672 } /* end H5Fclose() */
673
674
675 /*-------------------------------------------------------------------------
676 * Function: H5Freopen
677 *
678 * Purpose: Reopen a file. The new file handle which is returned points
679 * to the same file as the specified file handle. Both handles
680 * share caches and other information. The only difference
681 * between the handles is that the new handle is not mounted
682 * anywhere and no files are mounted on it.
683 *
684 * Return: Success: New file ID
685 * Failure: FAIL
686 *-------------------------------------------------------------------------
687 */
688 hid_t
H5Freopen(hid_t file_id)689 H5Freopen(hid_t file_id)
690 {
691 H5F_t *old_file = NULL;
692 H5F_t *new_file = NULL;
693 hid_t ret_value;
694
695 FUNC_ENTER_API(FAIL)
696 H5TRACE1("i", "i", file_id);
697
698 /* Check arguments */
699 if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
700 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
701
702 /* Get a new "top level" file struct, sharing the same "low level" file struct */
703 if(NULL == (new_file = H5F__new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL)))
704 HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
705
706 /* Duplicate old file's names */
707 new_file->open_name = H5MM_xstrdup(old_file->open_name);
708 new_file->actual_name = H5MM_xstrdup(old_file->actual_name);
709 new_file->extpath = H5MM_xstrdup(old_file->extpath);
710
711 if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
712 HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
713
714 /* Keep this ID in file object structure */
715 new_file->file_id = ret_value;
716
717 done:
718 if(ret_value < 0 && new_file)
719 if(H5F__dest(new_file, FALSE) < 0)
720 HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
721
722 FUNC_LEAVE_API(ret_value)
723 } /* end H5Freopen() */
724
725
726 /*-------------------------------------------------------------------------
727 * Function: H5Fget_intent
728 *
729 * Purpose: Public API to retrieve the file's 'intent' flags passed
730 * during H5Fopen()
731 *
732 * Return: Non-negative on success/negative on failure
733 *-------------------------------------------------------------------------
734 */
735 herr_t
H5Fget_intent(hid_t file_id,unsigned * intent_flags)736 H5Fget_intent(hid_t file_id, unsigned *intent_flags)
737 {
738 herr_t ret_value = SUCCEED;
739
740 FUNC_ENTER_API(FAIL)
741 H5TRACE2("e", "i*Iu", file_id, intent_flags);
742
743 /* If no intent flags were passed in, exit quietly */
744 if(intent_flags) {
745 H5F_t *file; /* Pointer to file structure */
746
747 /* Get the internal file structure */
748 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
749 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
750
751 /* HDF5 uses some flags internally that users don't know about.
752 * Simplify things for them so that they only get either H5F_ACC_RDWR
753 * or H5F_ACC_RDONLY.
754 */
755 if(H5F_INTENT(file) & H5F_ACC_RDWR) {
756 *intent_flags = H5F_ACC_RDWR;
757
758 /* Check for SWMR write access on the file */
759 if(H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)
760 *intent_flags |= H5F_ACC_SWMR_WRITE;
761 } /* end if */
762 else {
763 *intent_flags = H5F_ACC_RDONLY;
764
765 /* Check for SWMR read access on the file */
766 if(H5F_INTENT(file) & H5F_ACC_SWMR_READ)
767 *intent_flags |= H5F_ACC_SWMR_READ;
768 } /* end else */
769 } /* end if */
770
771 done:
772 FUNC_LEAVE_API(ret_value)
773 } /* end H5Fget_intent() */
774
775
776 /*-------------------------------------------------------------------------
777 * Function: H5Fget_freespace
778 *
779 * Purpose: Retrieves the amount of free space in the file.
780 *
781 * Return: Success: Amount of free space for type
782 * Failure: Negative
783 *-------------------------------------------------------------------------
784 */
785 hssize_t
H5Fget_freespace(hid_t file_id)786 H5Fget_freespace(hid_t file_id)
787 {
788 H5F_t *file; /* File object for file ID */
789 hsize_t tot_space; /* Amount of free space in the file */
790 hssize_t ret_value; /* Return value */
791
792 FUNC_ENTER_API(FAIL)
793 H5TRACE1("Hs", "i", file_id);
794
795 /* Check args */
796 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
797 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
798
799 /* Get the free space in the file */
800 if(H5F__get_freespace(file, &tot_space) < 0)
801 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
802
803 ret_value = (hssize_t)tot_space;
804
805 done:
806 FUNC_LEAVE_API(ret_value)
807 } /* end H5Fget_freespace() */
808
809
810 /*-------------------------------------------------------------------------
811 * Function: H5Fget_filesize
812 *
813 * Purpose: Retrieves the file size of the HDF5 file. This function
814 * is called after an existing file is opened in order
815 * to learn the true size of the underlying file.
816 *
817 * Return: Success: Non-negative
818 * Failure: Negative
819 *-------------------------------------------------------------------------
820 */
821 herr_t
H5Fget_filesize(hid_t file_id,hsize_t * size)822 H5Fget_filesize(hid_t file_id, hsize_t *size)
823 {
824 H5F_t *file; /* File object for file ID */
825 haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
826 haddr_t base_addr; /* Base address for the file */
827 herr_t ret_value = SUCCEED; /* Return value */
828
829 FUNC_ENTER_API(FAIL)
830 H5TRACE2("e", "i*h", file_id, size);
831
832 /* Check args */
833 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
834 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
835
836 /* Go get the actual file size */
837 if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
838 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
839
840 base_addr = H5FD_get_base_addr(file->shared->lf);
841
842 if(size)
843 *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */
844
845 done:
846 FUNC_LEAVE_API(ret_value)
847 } /* end H5Fget_filesize() */
848
849
850 /*-------------------------------------------------------------------------
851 * Function: H5Fget_file_image
852 *
853 * Purpose: If a buffer is provided (via the buf_ptr argument) and is
854 * big enough (size in buf_len argument), load *buf_ptr with
855 * an image of the open file whose ID is provided in the
856 * file_id parameter, and return the number of bytes copied
857 * to the buffer.
858 *
859 * If the buffer exists, but is too small to contain an image
860 * of the indicated file, return a negative number.
861 *
862 * Finally, if no buffer is provided, return the size of the
863 * buffer needed. This value is simply the eoa of the target
864 * file.
865 *
866 * Note that any user block is skipped.
867 *
868 * Also note that the function may not be used on files
869 * opened with either the split/multi file driver or the
870 * family file driver.
871 *
872 * In the former case, the sparse address space makes the
873 * get file image operation impractical, due to the size of
874 * the image typically required.
875 *
876 * In the case of the family file driver, the problem is
877 * the driver message in the super block, which will prevent
878 * the image being opened with any driver other than the
879 * family file driver -- which negates the purpose of the
880 * operation. This can be fixed, but no resources for
881 * this now.
882 *
883 * Return: Success: Bytes copied / number of bytes needed.
884 * Failure: negative value
885 *-------------------------------------------------------------------------
886 */
887 ssize_t
H5Fget_file_image(hid_t file_id,void * buf_ptr,size_t buf_len)888 H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len)
889 {
890 H5F_t *file; /* File object for file ID */
891 ssize_t ret_value; /* Return value */
892
893 FUNC_ENTER_API(FAIL)
894 H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len);
895
896 /* Check args */
897 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
898 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
899
900 /* call private get_file_image function */
901 /* (Should not trigger raw data I/O - QAK, 2018/01/03) */
902 if((ret_value = H5F__get_file_image(file, buf_ptr, buf_len)) < 0)
903 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file image")
904
905 done:
906 FUNC_LEAVE_API(ret_value)
907 } /* H5Fget_file_image() */
908
909
910 /*-------------------------------------------------------------------------
911 * Function: H5Fget_mdc_config
912 *
913 * Purpose: Retrieves the current automatic cache resize configuration
914 * from the metadata cache, and return it in *config_ptr.
915 *
916 * Note that the version field of *config_Ptr must be correctly
917 * filled in by the caller. This allows us to adapt for
918 * obsolete versions of the structure.
919 *
920 * Return: Success: SUCCEED
921 * Failure: FAIL
922 *-------------------------------------------------------------------------
923 */
924 herr_t
H5Fget_mdc_config(hid_t file_id,H5AC_cache_config_t * config_ptr)925 H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr)
926 {
927 H5F_t *file; /* File object for file ID */
928 herr_t ret_value = SUCCEED; /* Return value */
929
930 FUNC_ENTER_API(FAIL)
931 H5TRACE2("e", "i*x", file_id, config_ptr);
932
933 /* Check args */
934 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
935 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
936 if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION))
937 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr")
938
939 /* Go get the resize configuration */
940 if(H5AC_get_cache_auto_resize_config(file->shared->cache, config_ptr) < 0)
941 HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.")
942
943 done:
944 FUNC_LEAVE_API(ret_value)
945 } /* H5Fget_mdc_config() */
946
947
948 /*-------------------------------------------------------------------------
949 * Function: H5Fset_mdc_config
950 *
951 * Purpose: Sets the current metadata cache automatic resize
952 * configuration, using the contents of the instance of
953 * H5AC_cache_config_t pointed to by config_ptr.
954 *
955 * Return: Success: SUCCEED
956 * Failure: FAIL
957 *-------------------------------------------------------------------------
958 */
959 herr_t
H5Fset_mdc_config(hid_t file_id,H5AC_cache_config_t * config_ptr)960 H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr)
961 {
962 H5F_t *file; /* File object for file ID */
963 herr_t ret_value = SUCCEED; /* Return value */
964
965 FUNC_ENTER_API(FAIL)
966 H5TRACE2("e", "i*x", file_id, config_ptr);
967
968 /* Check args */
969 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
970 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
971
972 /* set the resize configuration */
973 if(H5AC_set_cache_auto_resize_config(file->shared->cache, config_ptr) < 0)
974 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed.")
975
976 done:
977 FUNC_LEAVE_API(ret_value)
978 } /* H5Fset_mdc_config() */
979
980
981 /*-------------------------------------------------------------------------
982 * Function: H5Fget_mdc_hit_rate
983 *
984 * Purpose: Retrieves the current hit rate from the metadata cache.
985 * This rate is the overall hit rate since the last time
986 * the hit rate statistics were reset either manually or
987 * automatically.
988 *
989 * Return: Success: SUCCEED
990 * Failure: FAIL
991 *-------------------------------------------------------------------------
992 */
993 herr_t
H5Fget_mdc_hit_rate(hid_t file_id,double * hit_rate_ptr)994 H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr)
995 {
996 H5F_t *file; /* File object for file ID */
997 herr_t ret_value = SUCCEED; /* Return value */
998
999 FUNC_ENTER_API(FAIL)
1000 H5TRACE2("e", "i*d", file_id, hit_rate_ptr);
1001
1002 /* Check args */
1003 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1004 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1005
1006 if(NULL == hit_rate_ptr)
1007 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer")
1008
1009 /* Go get the current hit rate */
1010 if(H5AC_get_cache_hit_rate(file->shared->cache, hit_rate_ptr) < 0)
1011 HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.")
1012
1013 done:
1014 FUNC_LEAVE_API(ret_value)
1015 } /* H5Fget_mdc_hit_rate() */
1016
1017
1018 /*-------------------------------------------------------------------------
1019 * Function: H5Fget_mdc_size
1020 *
1021 * Purpose: Retrieves the maximum size, minimum clean size, current
1022 * size, and current number of entries from the metadata
1023 * cache associated with the specified file. If any of
1024 * the ptr parameters are NULL, the associated datum is
1025 * not returned.
1026 *
1027 * Return: Success: SUCCEED
1028 * Failure: FAIL
1029 *-------------------------------------------------------------------------
1030 */
1031 herr_t
H5Fget_mdc_size(hid_t file_id,size_t * max_size_ptr,size_t * min_clean_size_ptr,size_t * cur_size_ptr,int * cur_num_entries_ptr)1032 H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr,
1033 size_t *cur_size_ptr, int *cur_num_entries_ptr)
1034 {
1035 H5F_t *file; /* File object for file ID */
1036 uint32_t cur_num_entries;
1037 herr_t ret_value = SUCCEED; /* Return value */
1038
1039 FUNC_ENTER_API(FAIL)
1040 H5TRACE5("e", "i*z*z*z*Is", file_id, max_size_ptr, min_clean_size_ptr,
1041 cur_size_ptr, cur_num_entries_ptr);
1042
1043 /* Check args */
1044 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1045 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1046
1047 /* Go get the size data */
1048 if(H5AC_get_cache_size(file->shared->cache, max_size_ptr,
1049 min_clean_size_ptr, cur_size_ptr, &cur_num_entries) < 0)
1050 HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.")
1051
1052 if(cur_num_entries_ptr != NULL)
1053 *cur_num_entries_ptr = (int)cur_num_entries;
1054
1055 done:
1056 FUNC_LEAVE_API(ret_value)
1057 } /* H5Fget_mdc_size() */
1058
1059
1060 /*-------------------------------------------------------------------------
1061 * Function: H5Freset_mdc_hit_rate_stats
1062 *
1063 * Purpose: Reset the hit rate statistic whose current value can
1064 * be obtained via the H5Fget_mdc_hit_rate() call. Note
1065 * that this statistic will also be reset once per epoch
1066 * by the automatic cache resize code if it is enabled.
1067 *
1068 * It is probably a bad idea to call this function unless
1069 * you are controlling cache size from your program instead
1070 * of using our cache size control code.
1071 *
1072 * Return: Success: SUCCEED
1073 * Failure: FAIL
1074 *-------------------------------------------------------------------------
1075 */
1076 herr_t
H5Freset_mdc_hit_rate_stats(hid_t file_id)1077 H5Freset_mdc_hit_rate_stats(hid_t file_id)
1078 {
1079 H5F_t *file; /* File object for file ID */
1080 herr_t ret_value = SUCCEED; /* Return value */
1081
1082 FUNC_ENTER_API(FAIL)
1083 H5TRACE1("e", "i", file_id);
1084
1085 /* Check args */
1086 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1087 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1088
1089 /* Reset the hit rate statistic */
1090 if(H5AC_reset_cache_hit_rate_stats(file->shared->cache) < 0)
1091 HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate")
1092
1093 done:
1094 FUNC_LEAVE_API(ret_value)
1095 } /* H5Freset_mdc_hit_rate_stats() */
1096
1097
1098 /*-------------------------------------------------------------------------
1099 * Function: H5Fget_name
1100 *
1101 * Purpose: Gets the name of the file to which object OBJ_ID belongs.
1102 * If `name' is non-NULL then write up to `size' bytes into that
1103 * buffer and always return the length of the entry name.
1104 * Otherwise `size' is ignored and the function does not store the name,
1105 * just returning the number of characters required to store the name.
1106 * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL)
1107 * is unchanged and the function returns a negative value.
1108 *
1109 * Note: This routine returns the name that was used to open the file,
1110 * not the actual name after resolving symlinks, etc.
1111 *
1112 * Return: Success: The length of the file name
1113 * Failure: Negative
1114 *-------------------------------------------------------------------------
1115 */
1116 ssize_t
H5Fget_name(hid_t obj_id,char * name,size_t size)1117 H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size)
1118 {
1119 H5F_t *f; /* Top file in mount hierarchy */
1120 size_t len;
1121 ssize_t ret_value;
1122
1123 FUNC_ENTER_API(FAIL)
1124 H5TRACE3("Zs", "ixz", obj_id, name, size);
1125
1126 /* For file IDs, get the file object directly */
1127 /* (This prevents the H5G_loc() call from returning the file pointer for
1128 * the top file in a mount hierarchy)
1129 */
1130 if(H5I_get_type(obj_id) == H5I_FILE ) {
1131 if(NULL == (f = (H5F_t *)H5I_object(obj_id)))
1132 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
1133 } /* end if */
1134 else {
1135 H5G_loc_t loc; /* Object location */
1136
1137 /* Get symbol table entry */
1138 if(H5G_loc(obj_id, &loc) < 0)
1139 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
1140 f = loc.oloc->file;
1141 } /* end else */
1142
1143 len = HDstrlen(H5F_OPEN_NAME(f));
1144
1145 if(name) {
1146 HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size));
1147 if(len >= size)
1148 name[size-1]='\0';
1149 } /* end if */
1150
1151 /* Set return value */
1152 ret_value = (ssize_t)len;
1153
1154 done:
1155 FUNC_LEAVE_API(ret_value)
1156 } /* end H5Fget_name() */
1157
1158
1159 /*-------------------------------------------------------------------------
1160 * Function: H5Fget_info2
1161 *
1162 * Purpose: Gets general information about the file, including:
1163 * 1. Get storage size for superblock extension if there is one.
1164 * 2. Get the amount of btree and heap storage for entries
1165 * in the SOHM table if there is one.
1166 * 3. The amount of free space tracked in the file.
1167 *
1168 * Return: Success: non-negative on success
1169 * Failure: Negative
1170 *-------------------------------------------------------------------------
1171 */
1172 herr_t
H5Fget_info2(hid_t obj_id,H5F_info2_t * finfo)1173 H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo)
1174 {
1175 H5F_t *f; /* Top file in mount hierarchy */
1176 herr_t ret_value = SUCCEED; /* Return value */
1177
1178 FUNC_ENTER_API(FAIL)
1179 H5TRACE2("e", "i*x", obj_id, finfo);
1180
1181 /* Check args */
1182 if(!finfo)
1183 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
1184
1185 /* For file IDs, get the file object directly */
1186 /* (This prevents the H5G_loc() call from returning the file pointer for
1187 * the top file in a mount hierarchy)
1188 */
1189 if(H5I_get_type(obj_id) == H5I_FILE ) {
1190 if(NULL == (f = (H5F_t *)H5I_object(obj_id)))
1191 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
1192 } /* end if */
1193 else {
1194 H5G_loc_t loc; /* Object location */
1195
1196 /* Get symbol table entry */
1197 if(H5G_loc(obj_id, &loc) < 0)
1198 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
1199 f = loc.oloc->file;
1200 } /* end else */
1201 HDassert(f->shared);
1202
1203 /* Get the file info */
1204 if(H5F__get_info(f, finfo) < 0)
1205 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info")
1206
1207 done:
1208 FUNC_LEAVE_API(ret_value)
1209 } /* end H5Fget_info2() */
1210
1211
1212 /*-------------------------------------------------------------------------
1213 * Function: H5Fget_metadata_read_retry_info
1214 *
1215 * Purpose: To retrieve the collection of read retries for metadata items with checksum.
1216 *
1217 * Return: Success: non-negative on success
1218 * Failure: Negative
1219 *-------------------------------------------------------------------------
1220 */
1221 herr_t
H5Fget_metadata_read_retry_info(hid_t file_id,H5F_retry_info_t * info)1222 H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info)
1223 {
1224 H5F_t *file; /* File object for file ID */
1225 herr_t ret_value = SUCCEED; /* Return value */
1226
1227 FUNC_ENTER_API(FAIL)
1228 H5TRACE2("e", "i*x", file_id, info);
1229
1230 /* Check args */
1231 if (!info)
1232 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
1233
1234 /* Get the file pointer */
1235 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1236 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1237
1238 /* Get the retry info */
1239 if(H5F__get_metadata_read_retry_info(file, info) < 0)
1240 HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info")
1241
1242 done:
1243 FUNC_LEAVE_API(ret_value)
1244 } /* end H5Fget_metadata_read_retry_info() */
1245
1246
1247 /*-------------------------------------------------------------------------
1248 * Function: H5Fget_free_sections
1249 *
1250 * Purpose: To get free-space section information for free-space manager with
1251 * TYPE that is associated with file FILE_ID.
1252 * If SECT_INFO is null, this routine returns the total # of free-space
1253 * sections.
1254 *
1255 * Return: Success: non-negative, the total # of free space sections
1256 * Failure: negative
1257 *-------------------------------------------------------------------------
1258 */
1259 ssize_t
H5Fget_free_sections(hid_t file_id,H5F_mem_t type,size_t nsects,H5F_sect_info_t * sect_info)1260 H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects,
1261 H5F_sect_info_t *sect_info/*out*/)
1262 {
1263 H5F_t *file; /* Top file in mount hierarchy */
1264 ssize_t ret_value; /* Return value */
1265
1266 FUNC_ENTER_API(FAIL)
1267 H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info);
1268
1269 /* Check args */
1270 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1271 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1272 if(sect_info && nsects == 0)
1273 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0")
1274
1275 /* Get the free-space section information in the file */
1276 if((ret_value = H5F__get_free_sections(file, type, nsects, sect_info)) < 0)
1277 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
1278
1279 done:
1280 FUNC_LEAVE_API(ret_value)
1281 } /* end H5Fget_free_sections() */
1282
1283
1284 /*-------------------------------------------------------------------------
1285 * Function: H5Fclear_elink_file_cache
1286 *
1287 * Purpose: Releases the external file cache associated with the
1288 * provided file, potentially closing any cached files
1289 * unless they are held open from somewhere\ else.
1290 *
1291 * Return: Success: non-negative
1292 * Failure: negative
1293 *-------------------------------------------------------------------------
1294 */
1295 herr_t
H5Fclear_elink_file_cache(hid_t file_id)1296 H5Fclear_elink_file_cache(hid_t file_id)
1297 {
1298 H5F_t *file; /* File */
1299 herr_t ret_value = SUCCEED; /* Return value */
1300
1301 FUNC_ENTER_API(FAIL)
1302 H5TRACE1("e", "i", file_id);
1303
1304 /* Check args */
1305 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1306 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1307
1308 /* See if there's an EFC */
1309 if(file->shared->efc)
1310 /* Release the EFC */
1311 if(H5F__efc_release(file->shared->efc) < 0)
1312 HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache")
1313
1314 done:
1315 FUNC_LEAVE_API(ret_value)
1316 } /* end H5Fclear_elink_file_cache() */
1317
1318
1319 /*-------------------------------------------------------------------------
1320 * Function: H5Fstart_swmr_write
1321 *
1322 * Purpose: To enable SWMR writing mode for the file
1323 *
1324 * Return: Non-negative on success/negative on failure
1325 *
1326 *-------------------------------------------------------------------------
1327 */
1328 herr_t
H5Fstart_swmr_write(hid_t file_id)1329 H5Fstart_swmr_write(hid_t file_id)
1330 {
1331 H5F_t *file = NULL; /* File info */
1332 herr_t ret_value = SUCCEED; /* Return value */
1333
1334 FUNC_ENTER_API(FAIL)
1335 H5TRACE1("e", "i", file_id);
1336
1337 /* check args */
1338 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1339 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
1340
1341 /* Set up collective metadata if appropriate */
1342 if(H5CX_set_loc(file_id) < 0)
1343 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
1344
1345 /* Call the internal routine */
1346 if(H5F__start_swmr_write(file) < 0)
1347 HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "unable to convert file format")
1348
1349 done:
1350 FUNC_LEAVE_API(ret_value)
1351 } /* end H5Fstart_swmr_write() */
1352
1353
1354 /*-------------------------------------------------------------------------
1355 * Function: H5Fstart_mdc_logging
1356 *
1357 * Purpose: Start metadata cache logging operations for a file.
1358 * - Logging must have been set up via the fapl.
1359 *
1360 * Return: Non-negative on success/Negative on errors
1361 *-------------------------------------------------------------------------
1362 */
1363 herr_t
H5Fstart_mdc_logging(hid_t file_id)1364 H5Fstart_mdc_logging(hid_t file_id)
1365 {
1366 H5F_t *file; /* File info */
1367 herr_t ret_value = SUCCEED; /* Return value */
1368
1369 FUNC_ENTER_API(FAIL)
1370 H5TRACE1("e", "i", file_id);
1371
1372 /* Sanity check */
1373 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1374 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
1375
1376 /* Call mdc logging function */
1377 if(H5C_start_logging(file->shared->cache) < 0)
1378 HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging")
1379
1380 done:
1381 FUNC_LEAVE_API(ret_value)
1382 } /* H5Fstart_mdc_logging() */
1383
1384
1385 /*-------------------------------------------------------------------------
1386 * Function: H5Fstop_mdc_logging
1387 *
1388 * Purpose: Stop metadata cache logging operations for a file.
1389 * - Does not close the log file.
1390 * - Logging must have been set up via the fapl.
1391 *
1392 * Return: Non-negative on success/Negative on errors
1393 *-------------------------------------------------------------------------
1394 */
1395 herr_t
H5Fstop_mdc_logging(hid_t file_id)1396 H5Fstop_mdc_logging(hid_t file_id)
1397 {
1398 H5F_t *file; /* File info */
1399 herr_t ret_value = SUCCEED; /* Return value */
1400
1401 FUNC_ENTER_API(FAIL)
1402 H5TRACE1("e", "i", file_id);
1403
1404 /* Sanity check */
1405 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1406 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
1407
1408 /* Call mdc logging function */
1409 if(H5C_stop_logging(file->shared->cache) < 0)
1410 HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging")
1411
1412 done:
1413 FUNC_LEAVE_API(ret_value)
1414 } /* H5Fstop_mdc_logging() */
1415
1416
1417 /*-------------------------------------------------------------------------
1418 * Function: H5Fget_mdc_logging_status
1419 *
1420 * Purpose: Get the logging flags. is_enabled determines if logging was
1421 * set up via the fapl. is_currently_logging determines if
1422 * log messages are being recorded at this time.
1423 *
1424 * Return: Non-negative on success/Negative on errors
1425 *-------------------------------------------------------------------------
1426 */
1427 herr_t
H5Fget_mdc_logging_status(hid_t file_id,hbool_t * is_enabled,hbool_t * is_currently_logging)1428 H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled,
1429 hbool_t *is_currently_logging)
1430 {
1431 H5F_t *file; /* File info */
1432 herr_t ret_value = SUCCEED; /* Return value */
1433
1434 FUNC_ENTER_API(FAIL)
1435 H5TRACE3("e", "i*b*b", file_id, is_enabled, is_currently_logging);
1436
1437 /* Sanity check */
1438 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1439 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
1440
1441 /* Call mdc logging function */
1442 if(H5C_get_logging_status(file->shared->cache, is_enabled, is_currently_logging) < 0)
1443 HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status")
1444
1445 done:
1446 FUNC_LEAVE_API(ret_value)
1447 } /* H5Fget_mdc_logging_status() */
1448
1449
1450 /*-------------------------------------------------------------------------
1451 * Function: H5Fset_libver_bounds
1452 *
1453 * Purpose: Set to a different low and high bounds while a file is open.
1454 * This public routine is introduced in place of
1455 * H5Fset_latest_format() starting release 1.10.2.
1456 * See explanation for H5Fset_latest_format() in H5Fdeprec.c.
1457 *
1458 * Return: Non-negative on success/Negative on failure
1459 *-------------------------------------------------------------------------
1460 */
1461 herr_t
H5Fset_libver_bounds(hid_t file_id,H5F_libver_t low,H5F_libver_t high)1462 H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high)
1463 {
1464 H5F_t *f; /* File */
1465 herr_t ret_value = SUCCEED; /* Return value */
1466
1467 FUNC_ENTER_API(FAIL)
1468 H5TRACE3("e", "iFvFv", file_id, low, high);
1469
1470 /* Check args */
1471 if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1472 HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID")
1473
1474 /* Set up collective metadata if appropriate */
1475 if(H5CX_set_loc(file_id) < 0)
1476 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
1477
1478 /* Call internal set_libver_bounds function */
1479 if(H5F__set_libver_bounds(f, low, high) < 0)
1480 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds")
1481
1482 done:
1483 FUNC_LEAVE_API(ret_value)
1484 } /* end H5Fset_libver_bounds() */
1485
1486
1487 /*-------------------------------------------------------------------------
1488 * Function: H5Fformat_convert
1489 *
1490 * Purpose: Downgrade the superblock version to v2 and
1491 * downgrade persistent file space to non-persistent
1492 * for 1.8 library.
1493 *
1494 * Return: Non-negative on success/Negative on failure
1495 *-------------------------------------------------------------------------
1496 */
1497 herr_t
H5Fformat_convert(hid_t fid)1498 H5Fformat_convert(hid_t fid)
1499 {
1500 H5F_t *f; /* File to flush */
1501 herr_t ret_value = SUCCEED; /* Return value */
1502
1503 FUNC_ENTER_API(FAIL)
1504 H5TRACE1("e", "i", fid);
1505
1506 if(H5I_FILE != H5I_get_type(fid))
1507 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
1508
1509 /* Get file object */
1510 if(NULL == (f = (H5F_t *)H5I_object(fid)))
1511 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
1512
1513 /* Set up collective metadata if appropriate */
1514 if(H5CX_set_loc(fid) < 0)
1515 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
1516
1517 /* Call the internal routine */
1518 if(H5F__format_convert(f) < 0)
1519 HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "unable to convert file format")
1520
1521 done:
1522 FUNC_LEAVE_API(ret_value)
1523 } /* end H5Fformat_convert() */
1524
1525
1526 /*-------------------------------------------------------------------------
1527 * Function: H5Freset_page_buffering_stats
1528 *
1529 * Purpose: Resets statistics for the page buffer layer.
1530 *
1531 * Return: Success: SUCCEED
1532 * Failure: FAIL
1533 *-------------------------------------------------------------------------
1534 */
1535 herr_t
H5Freset_page_buffering_stats(hid_t file_id)1536 H5Freset_page_buffering_stats(hid_t file_id)
1537 {
1538 H5F_t *file; /* File to reset stats on */
1539 herr_t ret_value = SUCCEED; /* Return value */
1540
1541 FUNC_ENTER_API(FAIL)
1542 H5TRACE1("e", "i", file_id);
1543
1544 /* Check args */
1545 if(NULL == (file = (H5F_t *)H5I_object(file_id)))
1546 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
1547 if(NULL == file->shared->page_buf)
1548 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file")
1549
1550 /* Reset the statistics */
1551 if(H5PB_reset_stats(file->shared->page_buf) < 0)
1552 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering")
1553
1554 done:
1555 FUNC_LEAVE_API(ret_value)
1556 } /* H5Freset_page_buffering_stats() */
1557
1558
1559 /*-------------------------------------------------------------------------
1560 * Function: H5Fget_page_buffering_stats
1561 *
1562 * Purpose: Retrieves statistics for the page buffer layer.
1563 *
1564 * Return: Success: SUCCEED
1565 * Failure: FAIL
1566 *-------------------------------------------------------------------------
1567 */
1568 herr_t
H5Fget_page_buffering_stats(hid_t file_id,unsigned accesses[2],unsigned hits[2],unsigned misses[2],unsigned evictions[2],unsigned bypasses[2])1569 H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2],
1570 unsigned misses[2], unsigned evictions[2], unsigned bypasses[2])
1571 {
1572 H5F_t *file; /* File object for file ID */
1573 herr_t ret_value = SUCCEED; /* Return value */
1574
1575 FUNC_ENTER_API(FAIL)
1576 H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions,
1577 bypasses);
1578
1579 /* Check args */
1580 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1581 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1582 if(NULL == file->shared->page_buf)
1583 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file")
1584 if(NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses)
1585 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats")
1586
1587 /* Get the statistics */
1588 if(H5PB_get_stats(file->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0)
1589 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering")
1590
1591 done:
1592 FUNC_LEAVE_API(ret_value)
1593 } /* H5Fget_page_buffering_stats() */
1594
1595
1596 /*-------------------------------------------------------------------------
1597 * Function: H5Fget_mdc_image_info
1598 *
1599 * Purpose: Retrieves the image_addr and image_len for the cache image in the file.
1600 * image_addr: --base address of the on disk metadata cache image
1601 * --HADDR_UNDEF if no cache image
1602 * image_len: --size of the on disk metadata cache image
1603 * --zero if no cache image
1604 *
1605 * Return: Success: SUCCEED
1606 * Failure: FAIL
1607 *-------------------------------------------------------------------------
1608 */
1609 herr_t
H5Fget_mdc_image_info(hid_t file_id,haddr_t * image_addr,hsize_t * image_len)1610 H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len)
1611 {
1612 H5F_t *file; /* File object for file ID */
1613 herr_t ret_value = SUCCEED; /* Return value */
1614
1615 FUNC_ENTER_API(FAIL)
1616 H5TRACE3("e", "i*a*h", file_id, image_addr, image_len);
1617
1618 /* Check args */
1619 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1620 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
1621 if(NULL == image_addr || NULL == image_len)
1622 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL image addr or image len")
1623
1624 /* Go get the address and size of the cache image */
1625 if(H5AC_get_mdc_image_info(file->shared->cache, image_addr, image_len) < 0)
1626 HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't retrieve cache image info")
1627
1628 done:
1629 FUNC_LEAVE_API(ret_value)
1630 } /* H5Fget_mdc_image_info() */
1631
1632
1633 /*-------------------------------------------------------------------------
1634 * Function: H5Fget_eoa
1635 *
1636 * Purpose: Returns the address of the first byte after the last
1637 * allocated memory in the file.
1638 * (See H5FDget_eoa() in H5FD.c)
1639 *
1640 * Return: Success: First byte after allocated memory.
1641 * Failure: HADDR_UNDEF
1642 *
1643 * Return: Non-negative on success/Negative on errors
1644 *-------------------------------------------------------------------------
1645 */
1646 herr_t
H5Fget_eoa(hid_t file_id,haddr_t * eoa)1647 H5Fget_eoa(hid_t file_id, haddr_t *eoa)
1648 {
1649 H5F_t *file; /* File object for file ID */
1650 haddr_t rel_eoa; /* Relative address of EOA */
1651 herr_t ret_value = SUCCEED; /* Return value */
1652
1653 FUNC_ENTER_API(FAIL)
1654 H5TRACE2("e", "i*a", file_id, eoa);
1655
1656 /* Check args */
1657 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1658 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
1659
1660 /* This public routine will work only for drivers with this feature enabled.*/
1661 /* We might introduce a new feature flag in the future */
1662 if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
1663 HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
1664
1665 /* The real work */
1666 if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
1667 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed")
1668
1669 /* (Note compensating for base address subtraction in internal routine) */
1670 if(eoa)
1671 *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf);
1672 done:
1673 FUNC_LEAVE_API(ret_value)
1674 } /* H5Fget_eoa() */
1675
1676
1677 /*-------------------------------------------------------------------------
1678 * Function: H5Fincrement_filesize
1679 *
1680 * Purpose: Set the EOA for the file to the maximum of (EOA, EOF) + increment
1681 *
1682 * Return: Non-negative on success/Negative on errors
1683 *-------------------------------------------------------------------------
1684 */
1685 herr_t
H5Fincrement_filesize(hid_t file_id,hsize_t increment)1686 H5Fincrement_filesize(hid_t file_id, hsize_t increment)
1687 {
1688 H5F_t *file; /* File object for file ID */
1689 haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */
1690 herr_t ret_value = SUCCEED; /* Return value */
1691
1692 FUNC_ENTER_API(FAIL)
1693 H5TRACE2("e", "ih", file_id, increment);
1694
1695 /* Check args */
1696 if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
1697 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
1698
1699 /* This public routine will work only for drivers with this feature enabled.*/
1700 /* We might introduce a new feature flag in the future */
1701 if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
1702 HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
1703
1704 /* Get the maximum of EOA and EOF */
1705 if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
1706 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
1707
1708 /* Set EOA to the maximum value + increment */
1709 /* H5FD_set_eoa() will add base_addr to max_eof_eoa */
1710 if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0)
1711 HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
1712
1713 done:
1714 FUNC_LEAVE_API(ret_value)
1715 } /* H5Fincrement_filesize() */
1716