Coverage Report

Created: 2026-10-28 18:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5Pfapl.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*-------------------------------------------------------------------------
14
 *
15
 * Created:        H5Pfapl.c
16
 *
17
 * Purpose:        File access property list class routines
18
 *
19
 *-------------------------------------------------------------------------
20
 */
21
22
/****************/
23
/* Module Setup */
24
/****************/
25
26
#include "H5Pmodule.h" /* This source code file is part of the H5P module */
27
28
/***********/
29
/* Headers */
30
/***********/
31
#include "H5private.h"   /* Generic Functions                        */
32
#include "H5ACprivate.h" /* Metadata cache                           */
33
#include "H5Eprivate.h"  /* Error handling                           */
34
#include "H5Fprivate.h"  /* Files                                    */
35
#include "H5FDprivate.h" /* File drivers                             */
36
#include "H5Iprivate.h"  /* IDs                                      */
37
#include "H5MMprivate.h" /* Memory Management                        */
38
#include "H5Ppkg.h"      /* Property lists                           */
39
#include "H5PBprivate.h" /* Page Buffer                              */
40
#include "H5VLprivate.h" /* Virtual Object Layer                     */
41
#include "H5VMprivate.h" /* Vector Functions                         */
42
43
/* Includes needed to set default file driver */
44
#include "H5FDsec2.h" /* POSIX unbuffered I/O                     */
45
#include "H5FDcore.h"
46
#include "H5FDlog.h"
47
#include "H5FDfamily.h"
48
#include "H5FDmulti.h"
49
#include "H5FDstdio.h" /* Standard C buffered I/O                  */
50
#include "H5FDsplitter.h"
51
#ifdef H5_HAVE_PARALLEL
52
#include "H5FDmpio.h"
53
#endif
54
#ifdef H5_HAVE_DIRECT
55
#include "H5FDdirect.h"
56
#endif
57
#ifdef H5_HAVE_MIRROR_VFD
58
#include "H5FDmirror.h"
59
#endif
60
#ifdef H5_HAVE_LIBHDFS
61
#include "H5FDhdfs.h"
62
#endif
63
#ifdef H5_HAVE_ROS3_VFD
64
#include "H5FDros3.h"
65
#endif
66
#ifdef H5_HAVE_SUBFILING_VFD
67
#include "H5FDsubfiling.h"
68
#endif
69
#ifdef H5_HAVE_WINDOWS
70
#include "H5FDwindows.h" /* Win32 I/O                                */
71
#endif
72
73
/* Includes needed to set default VOL connector */
74
#include "H5VLnative_private.h" /* Native VOL connector                     */
75
76
/****************/
77
/* Local Macros */
78
/****************/
79
80
/* ========= File Access properties ============ */
81
/* Definitions for the initial metadata cache resize configuration */
82
6
#define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t)
83
#define H5F_ACS_META_CACHE_INIT_CONFIG_DEF  H5AC__DEFAULT_CACHE_CONFIG
84
6
#define H5F_ACS_META_CACHE_INIT_CONFIG_ENC  H5P__facc_cache_config_enc
85
6
#define H5F_ACS_META_CACHE_INIT_CONFIG_DEC  H5P__facc_cache_config_dec
86
6
#define H5F_ACS_META_CACHE_INIT_CONFIG_CMP  H5P__facc_cache_config_cmp
87
/* Definitions for size of raw data chunk cache(slots) */
88
6
#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t)
89
#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF  8191
90
6
#define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC  H5P__encode_size_t
91
6
#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC  H5P__decode_size_t
92
/* Definition for size of raw data chunk cache(bytes) */
93
6
#define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t)
94
#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF  (8 * 1024 * 1024)
95
6
#define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC  H5P__encode_size_t
96
6
#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC  H5P__decode_size_t
97
/* Definition for preemption read chunks first */
98
6
#define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double)
99
#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF  0.75
100
6
#define H5F_ACS_PREEMPT_READ_CHUNKS_ENC  H5P__encode_double
101
6
#define H5F_ACS_PREEMPT_READ_CHUNKS_DEC  H5P__decode_double
102
/* Definition for threshold for alignment */
103
6
#define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t)
104
#define H5F_ACS_ALIGN_THRHD_DEF  H5F_ALIGN_THRHD_DEF
105
6
#define H5F_ACS_ALIGN_THRHD_ENC  H5P__encode_hsize_t
106
6
#define H5F_ACS_ALIGN_THRHD_DEC  H5P__decode_hsize_t
107
/* Definition for alignment */
108
6
#define H5F_ACS_ALIGN_SIZE sizeof(hsize_t)
109
#define H5F_ACS_ALIGN_DEF  H5F_ALIGN_DEF
110
6
#define H5F_ACS_ALIGN_ENC  H5P__encode_hsize_t
111
6
#define H5F_ACS_ALIGN_DEC  H5P__decode_hsize_t
112
/* Definition for minimum metadata allocation block size (when
113
   aggregating metadata allocations. */
114
6
#define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t)
115
#define H5F_ACS_META_BLOCK_SIZE_DEF  H5F_META_BLOCK_SIZE_DEF
116
6
#define H5F_ACS_META_BLOCK_SIZE_ENC  H5P__encode_hsize_t
117
6
#define H5F_ACS_META_BLOCK_SIZE_DEC  H5P__decode_hsize_t
118
/* Definition for maximum sieve buffer size (when data sieving
119
   is allowed by file driver */
120
6
#define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t)
121
#define H5F_ACS_SIEVE_BUF_SIZE_DEF  (64 * 1024)
122
6
#define H5F_ACS_SIEVE_BUF_SIZE_ENC  H5P__encode_size_t
123
6
#define H5F_ACS_SIEVE_BUF_SIZE_DEC  H5P__decode_size_t
124
/* Definition for minimum "small data" allocation block size (when
125
   aggregating "small" raw data allocations. */
126
6
#define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t)
127
#define H5F_ACS_SDATA_BLOCK_SIZE_DEF  H5F_SDATA_BLOCK_SIZE_DEF
128
6
#define H5F_ACS_SDATA_BLOCK_SIZE_ENC  H5P__encode_hsize_t
129
6
#define H5F_ACS_SDATA_BLOCK_SIZE_DEC  H5P__decode_hsize_t
130
/* Definition for garbage-collect references */
131
6
#define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned)
132
#define H5F_ACS_GARBG_COLCT_REF_DEF  0
133
6
#define H5F_ACS_GARBG_COLCT_REF_ENC  H5P__encode_unsigned
134
6
#define H5F_ACS_GARBG_COLCT_REF_DEC  H5P__decode_unsigned
135
/* Definition for file driver ID & info */
136
6
#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t)
137
#define H5F_ACS_FILE_DRV_DEF                                                                                 \
138
6
    {                                                                                                        \
139
6
        H5_DEFAULT_VFD, NULL, NULL                                                                           \
140
6
    }
141
6
#define H5F_ACS_FILE_DRV_CRT   H5P__facc_file_driver_create
142
6
#define H5F_ACS_FILE_DRV_SET   H5P__facc_file_driver_set
143
6
#define H5F_ACS_FILE_DRV_GET   H5P__facc_file_driver_get
144
6
#define H5F_ACS_FILE_DRV_DEL   H5P__facc_file_driver_del
145
6
#define H5F_ACS_FILE_DRV_COPY  H5P__facc_file_driver_copy
146
6
#define H5F_ACS_FILE_DRV_CMP   H5P__facc_file_driver_cmp
147
6
#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close
148
/* Definition for file close degree */
149
6
#define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t)
150
#define H5F_CLOSE_DEGREE_DEF  H5F_CLOSE_DEFAULT
151
6
#define H5F_CLOSE_DEGREE_ENC  H5P__facc_fclose_degree_enc
152
6
#define H5F_CLOSE_DEGREE_DEC  H5P__facc_fclose_degree_dec
153
/* Definition for offset position in file for family file driver */
154
6
#define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t)
155
#define H5F_ACS_FAMILY_OFFSET_DEF  0
156
6
#define H5F_ACS_FAMILY_OFFSET_ENC  H5P__encode_hsize_t
157
6
#define H5F_ACS_FAMILY_OFFSET_DEC  H5P__decode_hsize_t
158
/* Definition for new member size of family driver. It's private
159
 * property only used by h5repart */
160
6
#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t)
161
#define H5F_ACS_FAMILY_NEWSIZE_DEF  0
162
/* Definition for whether to convert family to a single-file driver.
163
 * It's a private property only used by h5repart.
164
 */
165
6
#define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(bool)
166
#define H5F_ACS_FAMILY_TO_SINGLE_DEF  false
167
/* Definition for data type in multi file driver */
168
6
#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t)
169
#define H5F_ACS_MULTI_TYPE_DEF  H5FD_MEM_DEFAULT
170
6
#define H5F_ACS_MULTI_TYPE_ENC  H5P__facc_multi_type_enc
171
6
#define H5F_ACS_MULTI_TYPE_DEC  H5P__facc_multi_type_dec
172
173
/* Definition for "low" bound of library format versions */
174
6
#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t)
175
#define H5F_ACS_LIBVER_LOW_BOUND_DEF  H5F_LIBVER_V18
176
6
#define H5F_ACS_LIBVER_LOW_BOUND_ENC  H5P__facc_libver_type_enc
177
6
#define H5F_ACS_LIBVER_LOW_BOUND_DEC  H5P__facc_libver_type_dec
178
179
/* Definition for "high" bound of library format versions */
180
6
#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t)
181
#define H5F_ACS_LIBVER_HIGH_BOUND_DEF  H5F_LIBVER_LATEST
182
6
#define H5F_ACS_LIBVER_HIGH_BOUND_ENC  H5P__facc_libver_type_enc
183
6
#define H5F_ACS_LIBVER_HIGH_BOUND_DEC  H5P__facc_libver_type_dec
184
185
/* Definition for whether to query the file descriptor from the core VFD
186
 * instead of the memory address.  (Private to library)
187
 */
188
6
#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(bool)
189
#define H5F_ACS_WANT_POSIX_FD_DEF  false
190
/* Definition for external file cache size */
191
6
#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned)
192
#define H5F_ACS_EFC_SIZE_DEF  0
193
6
#define H5F_ACS_EFC_SIZE_ENC  H5P__encode_unsigned
194
6
#define H5F_ACS_EFC_SIZE_DEC  H5P__decode_unsigned
195
/* Definition of pointer to initial file image info */
196
6
#define H5F_ACS_FILE_IMAGE_INFO_SIZE  sizeof(H5FD_file_image_info_t)
197
#define H5F_ACS_FILE_IMAGE_INFO_DEF   H5FD_DEFAULT_FILE_IMAGE_INFO
198
6
#define H5F_ACS_FILE_IMAGE_INFO_SET   H5P__facc_file_image_info_set
199
6
#define H5F_ACS_FILE_IMAGE_INFO_GET   H5P__facc_file_image_info_get
200
6
#define H5F_ACS_FILE_IMAGE_INFO_DEL   H5P__facc_file_image_info_del
201
6
#define H5F_ACS_FILE_IMAGE_INFO_COPY  H5P__facc_file_image_info_copy
202
6
#define H5F_ACS_FILE_IMAGE_INFO_CMP   H5P__facc_file_image_info_cmp
203
6
#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close
204
/* Definition for # of metadata read attempts */
205
6
#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned)
206
0
#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF  0
207
6
#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC  H5P__encode_unsigned
208
6
#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC  H5P__decode_unsigned
209
/* Definition for object flush callback */
210
6
#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t)
211
#define H5F_ACS_OBJECT_FLUSH_CB_DEF                                                                          \
212
    {                                                                                                        \
213
        NULL, NULL                                                                                           \
214
    }
215
/* Definition for status_flags in the superblock */
216
6
#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(bool)
217
#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF  false
218
219
/* Definition for dropping free-space to the floor when reading in the superblock */
220
6
#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(bool)
221
#define H5F_ACS_NULL_FSM_ADDR_DEF  false
222
/* Definition for skipping EOF check when reading in the superblock */
223
6
#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(bool)
224
#define H5F_ACS_SKIP_EOF_CHECK_DEF  false
225
226
/* Definition for 'use metadata cache logging' flag */
227
6
#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(bool)
228
#define H5F_ACS_USE_MDC_LOGGING_DEF  false
229
6
#define H5F_ACS_USE_MDC_LOGGING_ENC  H5P__encode_bool
230
6
#define H5F_ACS_USE_MDC_LOGGING_DEC  H5P__decode_bool
231
/* Definition for 'mdc log location' flag */
232
6
#define H5F_ACS_MDC_LOG_LOCATION_SIZE  sizeof(char *)
233
#define H5F_ACS_MDC_LOG_LOCATION_DEF   NULL /* default is no log location */
234
6
#define H5F_ACS_MDC_LOG_LOCATION_ENC   H5P__facc_mdc_log_location_enc
235
6
#define H5F_ACS_MDC_LOG_LOCATION_DEC   H5P__facc_mdc_log_location_dec
236
6
#define H5F_ACS_MDC_LOG_LOCATION_DEL   H5P__facc_mdc_log_location_del
237
6
#define H5F_ACS_MDC_LOG_LOCATION_COPY  H5P__facc_mdc_log_location_copy
238
6
#define H5F_ACS_MDC_LOG_LOCATION_CMP   H5P__facc_mdc_log_location_cmp
239
6
#define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P__facc_mdc_log_location_close
240
/* Definition for 'start metadata cache logging on access' flag */
241
6
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(bool)
242
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF  false
243
6
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC  H5P__encode_bool
244
6
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC  H5P__decode_bool
245
/* Definition for evict on close property */
246
6
#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(bool)
247
#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF  false
248
6
#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC  H5P__encode_bool
249
6
#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC  H5P__decode_bool
250
#ifdef H5_HAVE_PARALLEL
251
/* Definition of collective metadata read mode flag */
252
#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t)
253
#define H5F_ACS_COLL_MD_READ_FLAG_DEF  H5P_USER_FALSE
254
#define H5F_ACS_COLL_MD_READ_FLAG_ENC  H5P__encode_coll_md_read_flag_t
255
#define H5F_ACS_COLL_MD_READ_FLAG_DEC  H5P__decode_coll_md_read_flag_t
256
/* Definition of collective metadata write mode flag */
257
#define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(bool)
258
#define H5F_ACS_COLL_MD_WRITE_FLAG_DEF  false
259
#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC  H5P__encode_bool
260
#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC  H5P__decode_bool
261
/* Definition for the file's MPI communicator */
262
#define H5F_ACS_MPI_PARAMS_COMM_SIZE  sizeof(MPI_Comm)
263
#define H5F_ACS_MPI_PARAMS_COMM_DEF   MPI_COMM_NULL
264
#define H5F_ACS_MPI_PARAMS_COMM_SET   H5P__facc_mpi_comm_set
265
#define H5F_ACS_MPI_PARAMS_COMM_GET   H5P__facc_mpi_comm_get
266
#define H5F_ACS_MPI_PARAMS_COMM_DEL   H5P__facc_mpi_comm_del
267
#define H5F_ACS_MPI_PARAMS_COMM_COPY  H5P__facc_mpi_comm_copy
268
#define H5F_ACS_MPI_PARAMS_COMM_CMP   H5P__facc_mpi_comm_cmp
269
#define H5F_ACS_MPI_PARAMS_COMM_CLOSE H5P__facc_mpi_comm_close
270
/* Definition for the file's MPI info */
271
#define H5F_ACS_MPI_PARAMS_INFO_SIZE  sizeof(MPI_Info)
272
#define H5F_ACS_MPI_PARAMS_INFO_DEF   MPI_INFO_NULL
273
#define H5F_ACS_MPI_PARAMS_INFO_SET   H5P__facc_mpi_info_set
274
#define H5F_ACS_MPI_PARAMS_INFO_GET   H5P__facc_mpi_info_get
275
#define H5F_ACS_MPI_PARAMS_INFO_DEL   H5P__facc_mpi_info_del
276
#define H5F_ACS_MPI_PARAMS_INFO_COPY  H5P__facc_mpi_info_copy
277
#define H5F_ACS_MPI_PARAMS_INFO_CMP   H5P__facc_mpi_info_cmp
278
#define H5F_ACS_MPI_PARAMS_INFO_CLOSE H5P__facc_mpi_info_close
279
#endif /* H5_HAVE_PARALLEL */
280
/* Definitions for the initial metadata cache image configuration */
281
6
#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE sizeof(H5AC_cache_image_config_t)
282
#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF  H5AC__DEFAULT_CACHE_IMAGE_CONFIG
283
6
#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC  H5P__facc_cache_image_config_enc
284
6
#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC  H5P__facc_cache_image_config_dec
285
6
#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP  H5P__facc_cache_image_config_cmp
286
/* Definition for total size of page buffer(bytes) */
287
6
#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t)
288
#define H5F_ACS_PAGE_BUFFER_SIZE_DEF  H5F_PAGE_BUFFER_SIZE_DEFAULT
289
6
#define H5F_ACS_PAGE_BUFFER_SIZE_ENC  H5P__facc_page_buffer_size_enc
290
6
#define H5F_ACS_PAGE_BUFFER_SIZE_DEC  H5P__facc_page_buffer_size_dec
291
/* Definition for minimum metadata size of page buffer(bytes) */
292
6
#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned)
293
#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF  0
294
6
#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC  H5P__encode_unsigned
295
6
#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC  H5P__decode_unsigned
296
/* Definition for minimum raw data size of page buffer(bytes) */
297
6
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned)
298
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF  0
299
6
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC  H5P__encode_unsigned
300
6
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC  H5P__decode_unsigned
301
/* Definition for file VOL connector properties (ID, etc.) */
302
6
#define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t)
303
#define H5F_ACS_VOL_CONN_DEF                                                                                 \
304
6
    {                                                                                                        \
305
6
        H5_DEFAULT_VOL, NULL                                                                                 \
306
6
    }
307
6
#define H5F_ACS_VOL_CONN_CRT   H5P__facc_vol_create
308
6
#define H5F_ACS_VOL_CONN_SET   H5P__facc_vol_set
309
6
#define H5F_ACS_VOL_CONN_GET   H5P__facc_vol_get
310
6
#define H5F_ACS_VOL_CONN_DEL   H5P__facc_vol_del
311
6
#define H5F_ACS_VOL_CONN_COPY  H5P__facc_vol_copy
312
6
#define H5F_ACS_VOL_CONN_CMP   H5P__facc_vol_cmp
313
6
#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close
314
/* Definition for using file locking or not. The default is set
315
 * via the configure step.
316
 */
317
6
#define H5F_ACS_USE_FILE_LOCKING_SIZE sizeof(bool)
318
#if defined H5_USE_FILE_LOCKING && H5_USE_FILE_LOCKING
319
#define H5F_ACS_USE_FILE_LOCKING_DEF true
320
#else
321
#define H5F_ACS_USE_FILE_LOCKING_DEF false
322
#endif
323
6
#define H5F_ACS_USE_FILE_LOCKING_ENC H5P__encode_bool
324
6
#define H5F_ACS_USE_FILE_LOCKING_DEC H5P__decode_bool
325
/* Definition for whether we ignore file locking errors when we can
326
 * tell that file locking has been disabled on the file system.
327
 * The default is set via the configure step.
328
 */
329
6
#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE sizeof(bool)
330
#if defined H5_IGNORE_DISABLED_FILE_LOCKS && H5_IGNORE_DISABLED_FILE_LOCKS
331
#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF true
332
#else
333
#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF false
334
#endif
335
6
#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC H5P__encode_bool
336
6
#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC H5P__decode_bool
337
/* Definition for 'rfic' flags */
338
6
#define H5F_ACS_RFIC_FLAGS_SIZE sizeof(uint64_t)
339
#define H5F_ACS_RFIC_FLAGS_DEF  0
340
6
#define H5F_ACS_RFIC_FLAGS_ENC  H5P__encode_uint64_t
341
6
#define H5F_ACS_RFIC_FLAGS_DEC  H5P__decode_uint64_t
342
343
/******************/
344
/* Local Typedefs */
345
/******************/
346
347
/********************/
348
/* Package Typedefs */
349
/********************/
350
351
/********************/
352
/* Local Prototypes */
353
/********************/
354
355
/* Property class callbacks */
356
static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass);
357
358
/* File driver ID & info property callbacks */
359
static herr_t H5P__facc_file_driver_create(const char *name, size_t size, void *value);
360
static herr_t H5P__facc_file_driver_set(hid_t prop_id, const char *name, size_t size, void *value);
361
static herr_t H5P__facc_file_driver_get(hid_t prop_id, const char *name, size_t size, void *value);
362
static herr_t H5P__facc_file_driver_del(hid_t prop_id, const char *name, size_t size, void *value);
363
static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *value);
364
static int    H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size);
365
static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value);
366
367
/* File image info property callbacks */
368
static herr_t H5P__file_image_info_copy(void *value);
369
static herr_t H5P__file_image_info_free(void *value);
370
static herr_t H5P__facc_file_image_info_set(hid_t prop_id, const char *name, size_t size, void *value);
371
static herr_t H5P__facc_file_image_info_get(hid_t prop_id, const char *name, size_t size, void *value);
372
static herr_t H5P__facc_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value);
373
static herr_t H5P__facc_file_image_info_copy(const char *name, size_t size, void *value);
374
static int    H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size);
375
static herr_t H5P__facc_file_image_info_close(const char *name, size_t size, void *value);
376
377
/* encode & decode callbacks */
378
static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size);
379
static herr_t H5P__facc_cache_config_dec(const void **_pp, void *value);
380
static int    H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size);
381
static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size);
382
static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value);
383
static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size);
384
static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value);
385
static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size);
386
static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value);
387
static herr_t H5P__facc_page_buffer_size_enc(const void *value, void **_pp, size_t *size);
388
static herr_t H5P__facc_page_buffer_size_dec(const void **_pp, void *value);
389
390
/* Metadata cache log location property callbacks */
391
static herr_t H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size);
392
static herr_t H5P__facc_mdc_log_location_dec(const void **_pp, void *value);
393
static herr_t H5P__facc_mdc_log_location_del(hid_t prop_id, const char *name, size_t size, void *value);
394
static herr_t H5P__facc_mdc_log_location_copy(const char *name, size_t size, void *value);
395
static int    H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t size);
396
static herr_t H5P__facc_mdc_log_location_close(const char *name, size_t size, void *value);
397
398
/* Metadata cache image property callbacks */
399
static int    H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2,
400
                                               size_t H5_ATTR_UNUSED size);
401
static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size);
402
static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value);
403
404
/* VOL connector callbacks */
405
static herr_t H5P__facc_vol_create(const char *name, size_t size, void *value);
406
static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, void *value);
407
static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value);
408
static herr_t H5P__facc_vol_del(hid_t prop_id, const char *name, size_t size, void *value);
409
static herr_t H5P__facc_vol_copy(const char *name, size_t size, void *value);
410
static int    H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size);
411
static herr_t H5P__facc_vol_close(const char *name, size_t size, void *value);
412
413
#ifdef H5_HAVE_PARALLEL
414
/* MPI communicator callbacks */
415
static herr_t H5P__facc_mpi_comm_set(hid_t prop_id, const char *name, size_t size, void *value);
416
static herr_t H5P__facc_mpi_comm_get(hid_t prop_id, const char *name, size_t size, void *value);
417
static herr_t H5P__facc_mpi_comm_del(hid_t prop_id, const char *name, size_t size, void *value);
418
static herr_t H5P__facc_mpi_comm_copy(const char *name, size_t size, void *value);
419
static int    H5P__facc_mpi_comm_cmp(const void *value1, const void *value2, size_t size);
420
static herr_t H5P__facc_mpi_comm_close(const char *name, size_t size, void *value);
421
422
/* MPI info callbacks */
423
static herr_t H5P__facc_mpi_info_set(hid_t prop_id, const char *name, size_t size, void *value);
424
static herr_t H5P__facc_mpi_info_get(hid_t prop_id, const char *name, size_t size, void *value);
425
static herr_t H5P__facc_mpi_info_del(hid_t prop_id, const char *name, size_t size, void *value);
426
static herr_t H5P__facc_mpi_info_copy(const char *name, size_t size, void *value);
427
static int    H5P__facc_mpi_info_cmp(const void *value1, const void *value2, size_t size);
428
static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *value);
429
#endif /* H5_HAVE_PARALLEL */
430
431
/* Internal routines */
432
static herr_t H5P__facc_set_def_driver_check_predefined(const char *driver_name, hid_t *driver_id);
433
434
/*********************/
435
/* Package Variables */
436
/*********************/
437
438
/* File access property list class library initialization object */
439
const H5P_libclass_t H5P_CLS_FACC[1] = {{
440
    "file access",        /* Class name for debugging     */
441
    H5P_TYPE_FILE_ACCESS, /* Class type                   */
442
443
    &H5P_CLS_ROOT_g,           /* Parent class                 */
444
    &H5P_CLS_FILE_ACCESS_g,    /* Pointer to class             */
445
    &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID          */
446
    &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */
447
    H5P__facc_reg_prop,        /* Default property registration routine */
448
449
    NULL, /* Class creation callback      */
450
    NULL, /* Class creation callback info */
451
    NULL, /* Class copy callback          */
452
    NULL, /* Class copy callback info     */
453
    NULL, /* Class close callback         */
454
    NULL  /* Class close callback info    */
455
}};
456
457
/*****************************/
458
/* Library Private Variables */
459
/*****************************/
460
461
/*******************/
462
/* Local Variables */
463
/*******************/
464
465
/* Property value defaults */
466
static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g =
467
    H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */
468
static const size_t H5F_def_rdcc_nslots_g =
469
    H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */
470
static const size_t H5F_def_rdcc_nbytes_g =
471
    H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */
472
static const double H5F_def_rdcc_w0_g =
473
    H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */
474
static const hsize_t H5F_def_threshold_g =
475
    H5F_ACS_ALIGN_THRHD_DEF;                                  /* Default allocation alignment threshold */
476
static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */
477
static const hsize_t H5F_def_meta_block_size_g =
478
    H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */
479
static const size_t H5F_def_sieve_buf_size_g =
480
    H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */
481
static const hsize_t H5F_def_sdata_block_size_g =
482
    H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */
483
static const unsigned H5F_def_gc_ref_g =
484
    H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */
485
static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */
486
static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */
487
static const hsize_t H5F_def_family_newsize_g =
488
    H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */
489
static const bool H5F_def_family_to_single_g = H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */
490
static const H5FD_mem_t H5F_def_mem_type_g =
491
    H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */
492
493
static const H5F_libver_t H5F_def_libver_low_bound_g =
494
    H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */
495
static const H5F_libver_t H5F_def_libver_high_bound_g =
496
    H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */
497
498
static const bool H5F_def_want_posix_fd_g =
499
    H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */
500
static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */
501
static const H5FD_file_image_info_t H5F_def_file_image_info_g =
502
    H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */
503
static const unsigned H5F_def_metadata_read_attempts_g =
504
    H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */
505
static const H5F_object_flush_t H5F_def_object_flush_cb_g =
506
    H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */
507
static const bool H5F_def_clear_status_flags_g =
508
    H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */
509
static const bool H5F_def_skip_eof_check_g =
510
    H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */
511
static const bool H5F_def_null_fsm_addr_g =
512
    H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */
513
514
static const bool H5F_def_use_mdc_logging_g =
515
    H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */
516
static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */
517
static const bool  H5F_def_start_mdc_log_on_access_g =
518
    H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */
519
static const bool H5F_def_evict_on_close_flag_g =
520
    H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */
521
#ifdef H5_HAVE_PARALLEL
522
static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g =
523
    H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */
524
static const bool H5F_def_coll_md_write_flag_g =
525
    H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */
526
static const MPI_Comm H5F_def_mpi_params_comm_g = H5F_ACS_MPI_PARAMS_COMM_DEF; /* Default MPI communicator */
527
static const MPI_Info H5F_def_mpi_params_info_g = H5F_ACS_MPI_PARAMS_INFO_DEF; /* Default MPI info struct */
528
#endif                                                                         /* H5_HAVE_PARALLEL */
529
static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g =
530
    H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */
531
static const size_t   H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */
532
static const unsigned H5F_def_page_buf_min_meta_perc_g =
533
    H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */
534
static const unsigned H5F_def_page_buf_min_raw_perc_g =
535
    H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer minimum raw data size */
536
static const bool H5F_def_use_file_locking_g =
537
    H5F_ACS_USE_FILE_LOCKING_DEF; /* Default use file locking flag */
538
static const bool H5F_def_ignore_disabled_file_locks_g =
539
    H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */
540
static const uint64_t H5F_def_rfic_flags_g = H5F_ACS_RFIC_FLAGS_DEF; /* Default 'rfic' flags */
541
542
/*-------------------------------------------------------------------------
543
 * Function:    H5P__facc_reg_prop
544
 *
545
 * Purpose:     Register the file access property list class's properties
546
 *
547
 * Return:      Non-negative on success/Negative on failure
548
 *
549
 *-------------------------------------------------------------------------
550
 */
551
static herr_t
552
H5P__facc_reg_prop(H5P_genclass_t *pclass)
553
6
{
554
6
    const H5FD_driver_prop_t def_driver_prop =
555
6
        H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */
556
6
    const H5VL_connector_prop_t def_vol_prop =
557
6
        H5F_ACS_VOL_CONN_DEF;   /* Default VOL connector ID & info (initialized from a variable) */
558
6
    herr_t ret_value = SUCCEED; /* Return value */
559
560
6
    FUNC_ENTER_PACKAGE
561
562
    /* Register the initial metadata cache resize configuration */
563
6
    if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE,
564
6
                           &H5F_def_mdc_initCacheCfg_g, NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC,
565
6
                           H5F_ACS_META_CACHE_INIT_CONFIG_DEC, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP,
566
6
                           NULL) < 0)
567
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
568
569
    /* Register the size of raw data chunk cache (elements) */
570
6
    if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE,
571
6
                           &H5F_def_rdcc_nslots_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC,
572
6
                           H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0)
573
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
574
575
    /* Register the size of raw data chunk cache(bytes) */
576
6
    if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE,
577
6
                           &H5F_def_rdcc_nbytes_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC,
578
6
                           H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
579
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
580
581
    /* Register the preemption for reading chunks */
582
6
    if (H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE,
583
6
                           &H5F_def_rdcc_w0_g, NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC,
584
6
                           H5F_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0)
585
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
586
587
    /* Register the threshold for alignment */
588
6
    if (H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g,
589
6
                           NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, NULL, NULL,
590
6
                           NULL, NULL) < 0)
591
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
592
593
    /* Register the alignment */
594
6
    if (H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, NULL, NULL,
595
6
                           NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, NULL, NULL, NULL, NULL) < 0)
596
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
597
598
    /* Register the minimum metadata allocation block size */
599
6
    if (H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE,
600
6
                           &H5F_def_meta_block_size_g, NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC,
601
6
                           H5F_ACS_META_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
602
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
603
604
    /* Register the maximum sieve buffer size */
605
6
    if (H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE,
606
6
                           &H5F_def_sieve_buf_size_g, NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC,
607
6
                           H5F_ACS_SIEVE_BUF_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
608
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
609
610
    /* Register the minimum "small data" allocation block size */
611
6
    if (H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE,
612
6
                           &H5F_def_sdata_block_size_g, NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC,
613
6
                           H5F_ACS_SDATA_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
614
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
615
616
    /* Register the garbage collection reference */
617
6
    if (H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE,
618
6
                           &H5F_def_gc_ref_g, NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC,
619
6
                           H5F_ACS_GARBG_COLCT_REF_DEC, NULL, NULL, NULL, NULL) < 0)
620
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
621
622
    /* Register the file driver ID & info */
623
    /* (Note: this property should not have an encode/decode callback -QAK) */
624
6
    if (H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop,
625
6
                           H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL,
626
6
                           H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP,
627
6
                           H5F_ACS_FILE_DRV_CLOSE) < 0)
628
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
629
630
    /* Register the file close degree */
631
6
    if (H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g,
632
6
                           NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, NULL, NULL, NULL,
633
6
                           NULL) < 0)
634
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
635
636
    /* Register the offset of family driver info */
637
6
    if (H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE,
638
6
                           &H5F_def_family_offset_g, NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC,
639
6
                           H5F_ACS_FAMILY_OFFSET_DEC, NULL, NULL, NULL, NULL) < 0)
640
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
641
642
    /* Register the private property of new family file size. It's used by h5repart only. */
643
    /* (Note: this property should not have an encode/decode callback -QAK) */
644
6
    if (H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE,
645
6
                           &H5F_def_family_newsize_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
646
6
                           NULL) < 0)
647
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
648
649
    /* Register the private property of whether convert family to a single-file driver. It's used by h5repart
650
     * only. */
651
    /* (Note: this property should not have an encode/decode callback -QAK) */
652
6
    if (H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE,
653
6
                           &H5F_def_family_to_single_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
654
6
                           NULL) < 0)
655
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
656
657
    /* Register the data type of multi driver info */
658
6
    if (H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g,
659
6
                           NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, NULL, NULL, NULL,
660
6
                           NULL) < 0)
661
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
662
663
    /* Register the 'low' bound of library format versions */
664
6
    if (H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE,
665
6
                           &H5F_def_libver_low_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC,
666
6
                           H5F_ACS_LIBVER_LOW_BOUND_DEC, NULL, NULL, NULL, NULL) < 0)
667
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
668
669
    /* Register the 'high' bound of library format versions */
670
6
    if (H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE,
671
6
                           &H5F_def_libver_high_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC,
672
6
                           H5F_ACS_LIBVER_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0)
673
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
674
675
    /* Register the private property of whether to retrieve the file descriptor from the core VFD */
676
    /* (used internally to the library only) */
677
    /* (Note: this property should not have an encode/decode callback -QAK) */
678
6
    if (H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE,
679
6
                           &H5F_def_want_posix_fd_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
680
6
                           NULL) < 0)
681
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
682
683
    /* Register the external file cache size */
684
6
    if (H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, NULL,
685
6
                           NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, NULL, NULL, NULL,
686
6
                           NULL) < 0)
687
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
688
689
    /* Register the initial file image info */
690
    /* (Note: this property should not have an encode/decode callback -QAK) */
691
6
    if (H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE,
692
6
                           &H5F_def_file_image_info_g, NULL, H5F_ACS_FILE_IMAGE_INFO_SET,
693
6
                           H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, H5F_ACS_FILE_IMAGE_INFO_DEL,
694
6
                           H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP,
695
6
                           H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0)
696
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
697
698
    /* Register the # of read attempts */
699
6
    if (H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE,
700
6
                           &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL,
701
6
                           H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, NULL, NULL,
702
6
                           NULL, NULL) < 0)
703
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
704
705
    /* Register object flush callback */
706
    /* (Note: this property should not have an encode/decode callback -QAK) */
707
6
    if (H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE,
708
6
                           &H5F_def_object_flush_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
709
6
                           NULL) < 0)
710
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
711
712
    /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear
713
     * only. */
714
6
    if (H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE,
715
6
                           &H5F_def_clear_status_flags_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
716
6
                           NULL) < 0)
717
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
718
719
    /* Register the private property of whether to skip EOF check. It's used by h5clear only. */
720
6
    if (H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE,
721
6
                           &H5F_def_skip_eof_check_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
722
6
                           NULL) < 0)
723
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
724
725
    /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */
726
6
    if (H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE,
727
6
                           &H5F_def_null_fsm_addr_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
728
6
                           NULL) < 0)
729
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
730
731
    /* Register the metadata cache logging flag. */
732
6
    if (H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE,
733
6
                           &H5F_def_use_mdc_logging_g, NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC,
734
6
                           H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0)
735
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
736
737
    /* Register the metadata cache log location. */
738
6
    if (H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE,
739
6
                           &H5F_def_mdc_log_location_g, NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC,
740
6
                           H5F_ACS_MDC_LOG_LOCATION_DEC, H5F_ACS_MDC_LOG_LOCATION_DEL,
741
6
                           H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP,
742
6
                           H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0)
743
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
744
745
    /* Register the flag that indicates whether mdc logging starts on file access. */
746
6
    if (H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE,
747
6
                           &H5F_def_start_mdc_log_on_access_g, NULL, NULL, NULL,
748
6
                           H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL,
749
6
                           NULL, NULL, NULL) < 0)
750
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
751
752
    /* Register the evict on close flag */
753
6
    if (H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE,
754
6
                           &H5F_def_evict_on_close_flag_g, NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC,
755
6
                           H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
756
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
757
758
#ifdef H5_HAVE_PARALLEL
759
    /* Register the metadata collective read flag */
760
    if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE,
761
                           &H5F_def_coll_md_read_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC,
762
                           H5F_ACS_COLL_MD_READ_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
763
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
764
765
    /* Register the metadata collective write flag */
766
    if (H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE,
767
                           &H5F_def_coll_md_write_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC,
768
                           H5F_ACS_COLL_MD_WRITE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
769
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
770
771
    /* Register the MPI communicator */
772
    if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_COMM_NAME, H5F_ACS_MPI_PARAMS_COMM_SIZE,
773
                           &H5F_def_mpi_params_comm_g, NULL, H5F_ACS_MPI_PARAMS_COMM_SET,
774
                           H5F_ACS_MPI_PARAMS_COMM_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_COMM_DEL,
775
                           H5F_ACS_MPI_PARAMS_COMM_COPY, H5F_ACS_MPI_PARAMS_COMM_CMP,
776
                           H5F_ACS_MPI_PARAMS_COMM_CLOSE) < 0)
777
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
778
779
    /* Register the MPI info struct */
780
    if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_INFO_NAME, H5F_ACS_MPI_PARAMS_INFO_SIZE,
781
                           &H5F_def_mpi_params_info_g, NULL, H5F_ACS_MPI_PARAMS_INFO_SET,
782
                           H5F_ACS_MPI_PARAMS_INFO_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_INFO_DEL,
783
                           H5F_ACS_MPI_PARAMS_INFO_COPY, H5F_ACS_MPI_PARAMS_INFO_CMP,
784
                           H5F_ACS_MPI_PARAMS_INFO_CLOSE) < 0)
785
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
786
787
#endif /* H5_HAVE_PARALLEL */
788
789
    /* Register the initial metadata cache image configuration */
790
6
    if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME,
791
6
                           H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, NULL,
792
6
                           NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC,
793
6
                           H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, NULL, NULL,
794
6
                           H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0)
795
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
796
797
    /* Register the size of the page buffer size */
798
6
    if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE,
799
6
                           &H5F_def_page_buf_size_g, NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC,
800
6
                           H5F_ACS_PAGE_BUFFER_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
801
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
802
803
    /* Register the size of the page buffer minimum metadata size */
804
6
    if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME,
805
6
                           H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, NULL,
806
6
                           NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC,
807
6
                           H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, NULL, NULL, NULL, NULL) < 0)
808
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
809
810
    /* Register the size of the page buffer minimum raw data size */
811
6
    if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME,
812
6
                           H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, NULL,
813
6
                           NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC,
814
6
                           H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, NULL, NULL, NULL, NULL) < 0)
815
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
816
817
    /* Register the file VOL connector ID & info */
818
    /* (Note: this property should not have an encode/decode callback -QAK) */
819
6
    if (H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop,
820
6
                           H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL,
821
6
                           H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP,
822
6
                           H5F_ACS_VOL_CONN_CLOSE) < 0)
823
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
824
825
    /* Register the use file locking flag */
826
6
    if (H5P__register_real(pclass, H5F_ACS_USE_FILE_LOCKING_NAME, H5F_ACS_USE_FILE_LOCKING_SIZE,
827
6
                           &H5F_def_use_file_locking_g, NULL, NULL, NULL, H5F_ACS_USE_FILE_LOCKING_ENC,
828
6
                           H5F_ACS_USE_FILE_LOCKING_DEC, NULL, NULL, NULL, NULL) < 0)
829
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
830
831
    /* Register the ignore disabled file locks flag */
832
6
    if (H5P__register_real(pclass, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME,
833
6
                           H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE, &H5F_def_ignore_disabled_file_locks_g,
834
6
                           NULL, NULL, NULL, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC,
835
6
                           H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0)
836
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
837
838
    /* Register the 'rfic' flags. */
839
6
    if (H5P__register_real(pclass, H5F_ACS_RFIC_FLAGS_NAME, H5F_ACS_RFIC_FLAGS_SIZE, &H5F_def_rfic_flags_g,
840
6
                           NULL, NULL, NULL, H5F_ACS_RFIC_FLAGS_ENC, H5F_ACS_RFIC_FLAGS_DEC, NULL, NULL, NULL,
841
6
                           NULL) < 0)
842
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
843
844
6
done:
845
6
    FUNC_LEAVE_NOAPI(ret_value)
846
6
} /* end H5P__facc_reg_prop() */
847
848
/*-------------------------------------------------------------------------
849
 * Function:    H5P__facc_set_def_driver
850
 *
851
 * Purpose:     Parses a string that contains the name of the default VFL
852
 *              driver for the default FAPL.
853
 *
854
 * Return:      Non-negative on success/Negative on failure
855
 *
856
 *-------------------------------------------------------------------------
857
 */
858
herr_t
859
H5P__facc_set_def_driver(void)
860
6
{
861
6
    const char *driver_env_var;
862
6
    bool        driver_ref_inc = false;
863
6
    hid_t       driver_id      = H5I_INVALID_HID; /* VFL driver ID */
864
6
    herr_t      ret_value      = SUCCEED;
865
866
6
    FUNC_ENTER_PACKAGE
867
868
    /* Check if VFL driver environment variable is set */
869
6
    driver_env_var = getenv(HDF5_DRIVER);
870
871
    /* Only parse VFL driver string if it's set */
872
6
    if (driver_env_var && *driver_env_var) {
873
0
        H5FD_driver_prop_t driver_prop;
874
0
        H5P_genplist_t    *def_fapl;     /* Default file access property list */
875
0
        H5P_genclass_t    *def_fapclass; /* Default file access property class */
876
0
        const char        *driver_config_env_var;
877
0
        htri_t             driver_is_registered;
878
879
        /* Check to see if the driver is already registered */
880
0
        if ((driver_is_registered = H5FD_is_driver_registered_by_name(driver_env_var, &driver_id)) < 0)
881
0
            HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFL driver is already registered");
882
0
        if (driver_is_registered) {
883
0
            assert(driver_id >= 0);
884
885
0
            if (H5I_inc_ref(driver_id, true) < 0)
886
0
                HGOTO_ERROR(H5E_VFL, H5E_CANTINC, FAIL, "unable to increment ref count on VFD");
887
0
            driver_ref_inc = true;
888
0
        } /* end else-if */
889
0
        else {
890
            /* Check for VFL drivers that ship with the library */
891
0
            if (H5P__facc_set_def_driver_check_predefined(driver_env_var, &driver_id) < 0)
892
0
                HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check for predefined VFL driver name");
893
0
            else if (driver_id > 0) {
894
0
                if (H5I_inc_ref(driver_id, true) < 0)
895
0
                    HGOTO_ERROR(H5E_VFL, H5E_CANTINC, FAIL, "can't increment VFL driver refcount");
896
0
                driver_ref_inc = true;
897
0
            }
898
0
            else {
899
                /* Register the VFL driver */
900
0
                if ((driver_id = H5FD_register_driver_by_name(driver_env_var, true)) < 0)
901
0
                    HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "can't register VFL driver");
902
0
                driver_ref_inc = true;
903
0
            } /* end else */
904
0
        }     /* end else */
905
906
        /* Retrieve driver configuration string from environment variable, if set. */
907
0
        driver_config_env_var = getenv(HDF5_DRIVER_CONFIG);
908
909
0
        driver_prop.driver_id         = driver_id;
910
0
        driver_prop.driver_info       = NULL;
911
0
        driver_prop.driver_config_str = driver_config_env_var;
912
913
        /* Get default file access pclass */
914
0
        if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS)))
915
0
            HGOTO_ERROR(H5E_VFL, H5E_BADID, FAIL,
916
0
                        "can't find object for default file access property class ID");
917
918
        /* Set new default VFL driver for default file access pclass */
919
0
        if (H5P__class_set(def_fapclass, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
920
0
            HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL,
921
0
                        "can't set default VFL driver for default file access property list class");
922
923
        /* Get default file access plist */
924
0
        if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT)))
925
0
            HGOTO_ERROR(H5E_VFL, H5E_BADID, FAIL, "can't find object for default fapl ID");
926
927
        /* Set new default VFL driver for default FAPL */
928
0
        if (H5P_set_driver(def_fapl, driver_prop.driver_id, driver_prop.driver_info,
929
0
                           driver_prop.driver_config_str) < 0)
930
0
            HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default VFL driver for default FAPL");
931
0
    }
932
933
6
done:
934
    /* Clean up on error */
935
6
    if (ret_value < 0) {
936
0
        if (driver_id >= 0 && driver_ref_inc && H5I_dec_app_ref(driver_id) < 0)
937
0
            HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "unable to unregister VFL driver");
938
0
    } /* end if */
939
940
6
    FUNC_LEAVE_NOAPI(ret_value)
941
6
} /* end H5P__facc_set_def_driver() */
942
943
/*-------------------------------------------------------------------------
944
 * Function:    H5P__facc_set_def_driver_check_predefined
945
 *
946
 * Purpose:     Checks a given driver name against a list of predefined
947
 *              names for VFL drivers that are internal to HDF5. If a name
948
 *              is matched, the ID for that driver is returned through
949
 *              `driver_id`. Otherwise, `driver_id` is set to
950
 *              H5I_INVALID_HID.
951
 *
952
 * Return:      Non-negative on success/Negative on failure
953
 *
954
 *-------------------------------------------------------------------------
955
 */
956
static herr_t
957
H5P__facc_set_def_driver_check_predefined(const char *driver_name, hid_t *driver_id)
958
0
{
959
0
    herr_t ret_value = SUCCEED;
960
961
0
    FUNC_ENTER_PACKAGE
962
963
0
    assert(driver_name);
964
0
    assert(driver_id);
965
966
0
    if (!strcmp(driver_name, "sec2")) {
967
0
        if ((*driver_id = H5FD_SEC2) < 0)
968
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize sec2 VFD");
969
0
    }
970
0
    else if (!strcmp(driver_name, "core") || !strcmp(driver_name, "core_paged")) {
971
0
        if ((*driver_id = H5FD_CORE) < 0)
972
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize core VFD");
973
0
    }
974
0
    else if (!strcmp(driver_name, "log")) {
975
0
        if ((*driver_id = H5FD_LOG) < 0)
976
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize log VFD");
977
0
    }
978
0
    else if (!strcmp(driver_name, "family")) {
979
0
        if ((*driver_id = H5FD_FAMILY) < 0)
980
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize family VFD");
981
0
    }
982
0
    else if (!strcmp(driver_name, "multi") || !strcmp(driver_name, "split")) {
983
0
        if ((*driver_id = H5FD_MULTI) < 0)
984
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize multi VFD");
985
0
    }
986
0
    else if (!strcmp(driver_name, "stdio")) {
987
0
        if ((*driver_id = H5FD_STDIO) < 0)
988
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize stdio VFD");
989
0
    }
990
0
    else if (!strcmp(driver_name, "splitter")) {
991
0
        if ((*driver_id = H5FD_SPLITTER) < 0)
992
0
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize splitter VFD");
993
0
    }
994
0
    else if (!strcmp(driver_name, "mpio")) {
995
#ifdef H5_HAVE_PARALLEL
996
        if ((*driver_id = H5FD_MPIO) < 0)
997
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize MPI I/O VFD");
998
#else
999
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "MPI-I/O VFD is not enabled");
1000
0
#endif
1001
0
    }
1002
0
    else if (!strcmp(driver_name, "direct")) {
1003
#ifdef H5_HAVE_DIRECT
1004
        if ((*driver_id = H5FD_DIRECT) < 0)
1005
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize Direct I/O VFD");
1006
#else
1007
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Direct I/O VFD is not enabled");
1008
0
#endif
1009
0
    }
1010
0
    else if (!strcmp(driver_name, "mirror")) {
1011
#ifdef H5_HAVE_MIRROR_VFD
1012
        if ((*driver_id = H5FD_MIRROR) < 0)
1013
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize mirror VFD");
1014
#else
1015
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Mirror VFD is not enabled");
1016
0
#endif
1017
0
    }
1018
0
    else if (!strcmp(driver_name, "hdfs")) {
1019
#ifdef H5_HAVE_LIBHDFS
1020
        if ((*driver_id = H5FD_HDFS) < 0)
1021
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize HDFS VFD");
1022
#else
1023
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "HDFS VFD is not enabled");
1024
0
#endif
1025
0
    }
1026
0
    else if (!strcmp(driver_name, "ros3")) {
1027
#ifdef H5_HAVE_ROS3_VFD
1028
        if ((*driver_id = H5FD_ROS3) < 0)
1029
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize ROS3 VFD");
1030
#else
1031
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "ROS3 VFD is not enabled");
1032
0
#endif
1033
0
    }
1034
0
    else if (!strcmp(driver_name, "subfiling")) {
1035
#ifdef H5_HAVE_SUBFILING_VFD
1036
        if ((*driver_id = H5FD_SUBFILING) < 0)
1037
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize Subfiling VFD");
1038
#else
1039
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Subfiling VFD is not enabled");
1040
0
#endif
1041
0
    }
1042
0
    else if (!strcmp(driver_name, "windows")) {
1043
#ifdef H5_HAVE_WINDOWS
1044
        if ((*driver_id = H5FD_WINDOWS) < 0)
1045
            HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize Windows VFD");
1046
#else
1047
0
        HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Windows VFD is not enabled");
1048
0
#endif
1049
0
    }
1050
0
    else {
1051
0
        *driver_id = H5I_INVALID_HID;
1052
0
    }
1053
1054
0
done:
1055
0
    FUNC_LEAVE_NOAPI(ret_value)
1056
0
} /* end H5P__facc_set_def_driver_check_predefined() */
1057
1058
/*-------------------------------------------------------------------------
1059
 * Function:    H5Pset_alignment
1060
 *
1061
 * Purpose:    Sets the alignment properties of a file access property list
1062
 *        so that any file object >= THRESHOLD bytes will be aligned on
1063
 *        an address which is a multiple of ALIGNMENT.  The addresses
1064
 *        are relative to the end of the user block; the alignment is
1065
 *        calculated by subtracting the user block size from the
1066
 *        absolute file address and then adjusting the address to be a
1067
 *        multiple of ALIGNMENT.
1068
 *
1069
 *        Default values for THRESHOLD and ALIGNMENT are one, implying
1070
 *        no alignment.  Generally the default values will result in
1071
 *        the best performance for single-process access to the file.
1072
 *        For MPI-IO and other parallel systems, choose an alignment
1073
 *        which is a multiple of the disk block size.
1074
 *
1075
 * Return:    Non-negative on success/Negative on failure
1076
 *
1077
 *-------------------------------------------------------------------------
1078
 */
1079
herr_t
1080
H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment)
1081
0
{
1082
0
    H5P_genplist_t *plist;               /* Property list pointer */
1083
0
    herr_t          ret_value = SUCCEED; /* return value */
1084
1085
0
    FUNC_ENTER_API(FAIL)
1086
1087
    /* Check args */
1088
0
    if (alignment < 1)
1089
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "alignment must be positive");
1090
1091
    /* Get the plist structure */
1092
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, false)))
1093
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1094
1095
    /* Set values */
1096
0
    if (H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0)
1097
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set threshold");
1098
0
    if (H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0)
1099
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment");
1100
1101
0
done:
1102
0
    FUNC_LEAVE_API(ret_value)
1103
0
}
1104
1105
/*-------------------------------------------------------------------------
1106
 * Function:    H5Pget_alignment
1107
 *
1108
 * Purpose:    Returns the current settings for alignment properties from a
1109
 *        file access property list.  The THRESHOLD and/or ALIGNMENT
1110
 *        pointers may be null pointers.
1111
 *
1112
 * Return:    Non-negative on success/Negative on failure
1113
 *
1114
 *-------------------------------------------------------------------------
1115
 */
1116
herr_t
1117
H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/)
1118
0
{
1119
0
    H5P_genplist_t *plist;               /* Property list pointer */
1120
0
    herr_t          ret_value = SUCCEED; /* Return value */
1121
1122
0
    FUNC_ENTER_API(FAIL)
1123
1124
    /* Get the plist structure */
1125
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
1126
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1127
1128
    /* Get values */
1129
0
    if (threshold)
1130
0
        if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0)
1131
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get threshold");
1132
0
    if (alignment)
1133
0
        if (H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0)
1134
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment");
1135
1136
0
done:
1137
0
    FUNC_LEAVE_API(ret_value)
1138
0
} /* end H5Pget_alignment() */
1139
1140
/*-------------------------------------------------------------------------
1141
 * Function:   H5P_set_driver
1142
 *
1143
 * Purpose:    Set the file driver (NEW_DRIVER_ID) for a file access
1144
 *             property list (PLIST). A struct (NEW_DRIVER_INFO) or string
1145
 *             (NEW_DRIVER_CONFIG_STR) containing the driver-specific
1146
 *             properties can optionally be supplied. The driver properties
1147
 *             (struct or string) will be copied into the property list and
1148
 *             the reference count on the driver will be incremented,
1149
 *             allowing the caller to close the driver ID but still use the
1150
 *             property list.
1151
 *
1152
 * Note:       Only one of either NEW_DRIVER_INFO or NEW_DRIVER_CONFIG_STR
1153
 *             should be specified, but not both.
1154
 *
1155
 * Return:     Non-negative on success/Negative on failure
1156
 *
1157
 *-------------------------------------------------------------------------
1158
 */
1159
herr_t
1160
H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info,
1161
               const char *new_driver_config_str)
1162
0
{
1163
0
    herr_t ret_value = SUCCEED; /* Return value */
1164
1165
0
    FUNC_ENTER_NOAPI(FAIL)
1166
1167
    /* If VFD configuration information is supplied, ensure that either binary
1168
     * configuration data or a configuration string is supplied, but not both.
1169
     */
1170
0
    assert(!new_driver_info || !new_driver_config_str);
1171
1172
0
    if (NULL == H5I_object_verify(new_driver_id, H5I_VFL))
1173
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID");
1174
1175
0
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1176
0
        H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & config. string */
1177
1178
        /* Prepare the driver property */
1179
0
        driver_prop.driver_id         = new_driver_id;
1180
0
        driver_prop.driver_info       = new_driver_info;
1181
0
        driver_prop.driver_config_str = new_driver_config_str;
1182
1183
        /* Set the driver ID, info & config. string property */
1184
0
        if (H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1185
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info");
1186
0
    } /* end if */
1187
0
    else
1188
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
1189
1190
0
done:
1191
0
    FUNC_LEAVE_NOAPI(ret_value)
1192
0
} /* end H5P_set_driver() */
1193
1194
/*-------------------------------------------------------------------------
1195
 * Function:    H5Pset_driver
1196
 *
1197
 * Purpose:    Set the file driver (DRIVER_ID) for a file access
1198
 *        property list (PLIST_ID) and supply an optional
1199
 *        struct containing the driver-specific properties
1200
 *        (DRIVER_INFO).  The driver properties will be copied into the
1201
 *        property list and the reference count on the driver will be
1202
 *        incremented, allowing the caller to close the driver ID but
1203
 *        still use the property list.
1204
 *
1205
 * Return:    Success:    Non-negative
1206
 *        Failure:    Negative
1207
 *
1208
 *-------------------------------------------------------------------------
1209
 */
1210
herr_t
1211
H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info)
1212
0
{
1213
0
    H5P_genplist_t *plist;               /* Property list pointer */
1214
0
    herr_t          ret_value = SUCCEED; /* Return value */
1215
1216
0
    FUNC_ENTER_API(FAIL)
1217
1218
    /* Check arguments */
1219
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1220
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1221
0
    if (NULL == H5I_object_verify(new_driver_id, H5I_VFL))
1222
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID");
1223
1224
    /* Set the driver */
1225
0
    if (H5P_set_driver(plist, new_driver_id, new_driver_info, NULL) < 0)
1226
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info");
1227
1228
0
done:
1229
0
    FUNC_LEAVE_API(ret_value)
1230
0
} /* end H5Pset_driver() */
1231
1232
/*-------------------------------------------------------------------------
1233
 * Function:    H5P_set_driver_by_name
1234
 *
1235
 * Purpose:     Set the file driver name (DRIVER_NAME) for a file access
1236
 *              property list (PLIST) and supply an optional string
1237
 *              containing the driver-specific properties (DRIVER_CONFIG).
1238
 *              The driver properties string will be copied into the
1239
 *              property list.
1240
 *
1241
 *              If the file driver specified by DRIVER_NAME is not
1242
 *              currently registered, an attempt will be made to load the
1243
 *              driver as a plugin.
1244
 *
1245
 * Return:      Non-negative on success/Negative on failure
1246
 *
1247
 *-------------------------------------------------------------------------
1248
 */
1249
herr_t
1250
H5P_set_driver_by_name(H5P_genplist_t *plist, const char *driver_name, const char *driver_config,
1251
                       bool app_ref)
1252
0
{
1253
0
    hid_t  new_driver_id = H5I_INVALID_HID;
1254
0
    herr_t ret_value     = SUCCEED;
1255
1256
0
    FUNC_ENTER_NOAPI(FAIL)
1257
1258
0
    assert(plist);
1259
0
    assert(driver_name);
1260
1261
    /* Register the driver */
1262
0
    if ((new_driver_id = H5FD_register_driver_by_name(driver_name, app_ref)) < 0)
1263
0
        HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register VFD");
1264
1265
    /* Set the driver */
1266
0
    if (H5P_set_driver(plist, new_driver_id, NULL, driver_config) < 0)
1267
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info");
1268
1269
0
done:
1270
0
    if (ret_value < 0) {
1271
0
        if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0)
1272
0
            HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID");
1273
0
    }
1274
1275
0
    FUNC_LEAVE_NOAPI(ret_value)
1276
0
} /* end H5P_set_driver_by_name() */
1277
1278
/*-------------------------------------------------------------------------
1279
 * Function:    H5Pset_driver_by_name
1280
 *
1281
 * Purpose:     Set the file driver name (DRIVER_NAME) for a file access
1282
 *              property list (PLIST_ID) and supply an optional string
1283
 *              containing the driver-specific properties (DRIVER_CONFIG).
1284
 *              The driver properties string will be copied into the
1285
 *              property list.
1286
 *
1287
 *              If the file driver specified by DRIVER_NAME is not
1288
 *              currently registered, an attempt will be made to load the
1289
 *              driver as a plugin.
1290
 *
1291
 * Return:      Non-negative on success/Negative on failure
1292
 *
1293
 *-------------------------------------------------------------------------
1294
 */
1295
herr_t
1296
H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *driver_config)
1297
0
{
1298
0
    H5P_genplist_t *plist;               /* Property list pointer */
1299
0
    herr_t          ret_value = SUCCEED; /* Return value */
1300
1301
0
    FUNC_ENTER_API(FAIL)
1302
1303
    /* Check arguments */
1304
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1305
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1306
0
    if (!driver_name)
1307
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "driver_name parameter cannot be NULL");
1308
0
    if (!*driver_name)
1309
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "driver_name parameter cannot be an empty string");
1310
1311
    /* Set the driver */
1312
0
    if (H5P_set_driver_by_name(plist, driver_name, driver_config, true) < 0)
1313
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info");
1314
1315
0
done:
1316
0
    FUNC_LEAVE_API(ret_value)
1317
0
} /* end H5Pset_driver_by_name() */
1318
1319
/*-------------------------------------------------------------------------
1320
 * Function:    H5P_set_driver_by_value
1321
 *
1322
 * Purpose:     Set the file driver value (DRIVER_VALUE) for a file access
1323
 *              property list (PLIST) and supply an optional string
1324
 *              containing the driver-specific properties (DRIVER_CONFIG).
1325
 *              The driver properties string will be copied into the
1326
 *              property list.
1327
 *
1328
 *              If the file driver specified by DRIVER_VALUE is not
1329
 *              currently registered, an attempt will be made to load the
1330
 *              driver as a plugin.
1331
 *
1332
 * Return:      Non-negative on success/Negative on failure
1333
 *
1334
 *-------------------------------------------------------------------------
1335
 */
1336
herr_t
1337
H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, const char *driver_config,
1338
                        bool app_ref)
1339
0
{
1340
0
    hid_t  new_driver_id = H5I_INVALID_HID;
1341
0
    herr_t ret_value     = SUCCEED;
1342
1343
0
    FUNC_ENTER_NOAPI(FAIL)
1344
1345
0
    assert(plist);
1346
0
    assert(driver_value >= 0);
1347
1348
    /* Register the driver */
1349
0
    if ((new_driver_id = H5FD_register_driver_by_value(driver_value, app_ref)) < 0)
1350
0
        HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register VFD");
1351
1352
    /* Set the driver */
1353
0
    if (H5P_set_driver(plist, new_driver_id, NULL, driver_config) < 0)
1354
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info");
1355
1356
0
done:
1357
0
    if (ret_value < 0) {
1358
0
        if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0)
1359
0
            HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID");
1360
0
    }
1361
1362
0
    FUNC_LEAVE_NOAPI(ret_value)
1363
0
} /* end H5P_set_driver_by_value() */
1364
1365
/*-------------------------------------------------------------------------
1366
 * Function:    H5Pset_driver_by_value
1367
 *
1368
 * Purpose:     Set the file driver value (DRIVER_VALUE) for a file access
1369
 *              property list (PLIST_ID) and supply an optional string
1370
 *              containing the driver-specific properties (DRIVER_CONFIG).
1371
 *              The driver properties string will be copied into the
1372
 *              property list.
1373
 *
1374
 *              If the file driver specified by DRIVER_VALUE is not
1375
 *              currently registered, an attempt will be made to load the
1376
 *              driver as a plugin.
1377
 *
1378
 * Return:      Non-negative on success/Negative on failure
1379
 *
1380
 *-------------------------------------------------------------------------
1381
 */
1382
herr_t
1383
H5Pset_driver_by_value(hid_t plist_id, H5FD_class_value_t driver_value, const char *driver_config)
1384
0
{
1385
0
    H5P_genplist_t *plist;               /* Property list pointer */
1386
0
    herr_t          ret_value = SUCCEED; /* Return value */
1387
1388
0
    FUNC_ENTER_API(FAIL)
1389
1390
    /* Check arguments */
1391
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1392
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1393
0
    if (driver_value < 0)
1394
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative VFD value is disallowed");
1395
1396
    /* Set the driver */
1397
0
    if (H5P_set_driver_by_value(plist, driver_value, driver_config, true) < 0)
1398
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info");
1399
1400
0
done:
1401
0
    FUNC_LEAVE_API(ret_value)
1402
0
} /* end H5Pset_driver_by_value() */
1403
1404
/*-------------------------------------------------------------------------
1405
 * Function:    H5P_peek_driver
1406
 *
1407
 * Purpose:    Return the ID of the low-level file driver.  PLIST_ID should
1408
 *        be a file access property list.
1409
 *
1410
 * Return:    Success:    A low-level driver ID which is the same ID
1411
 *                used when the driver was set for the property
1412
 *                list. The driver ID is only valid as long as
1413
 *                the file driver remains registered.
1414
 *
1415
 *        Failure:    Negative
1416
 *
1417
 *-------------------------------------------------------------------------
1418
 */
1419
hid_t
1420
H5P_peek_driver(H5P_genplist_t *plist)
1421
0
{
1422
0
    hid_t ret_value = FAIL; /* Return value */
1423
1424
0
    FUNC_ENTER_NOAPI(FAIL)
1425
1426
    /* Get the current driver ID */
1427
0
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1428
0
        H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */
1429
1430
0
        if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1431
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID");
1432
0
        ret_value = driver_prop.driver_id;
1433
0
    } /* end if */
1434
0
    else
1435
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list");
1436
1437
0
    if (H5FD_VFD_DEFAULT == ret_value)
1438
0
        ret_value = H5_DEFAULT_VFD;
1439
1440
0
done:
1441
0
    FUNC_LEAVE_NOAPI(ret_value)
1442
0
} /* end H5P_peek_driver() */
1443
1444
/*-------------------------------------------------------------------------
1445
 * Function:    H5Pget_driver
1446
 *
1447
 * Purpose:    Return the ID of the low-level file driver.  PLIST_ID should
1448
 *        be a file access property list.
1449
 *
1450
 * Note:    The ID returned should not be closed.
1451
 *
1452
 * Return:    Success:    A low-level driver ID which is the same ID
1453
 *                used when the driver was set for the property
1454
 *                list. The driver ID is only valid as long as
1455
 *                the file driver remains registered.
1456
 *
1457
 *        Failure:    Negative
1458
 *
1459
 *-------------------------------------------------------------------------
1460
 */
1461
hid_t
1462
H5Pget_driver(hid_t plist_id)
1463
0
{
1464
0
    H5P_genplist_t *plist;     /* Property list pointer */
1465
0
    hid_t           ret_value; /* Return value */
1466
1467
0
    FUNC_ENTER_API(H5I_INVALID_HID)
1468
1469
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1470
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list");
1471
1472
    /* Get the driver */
1473
0
    if ((ret_value = H5P_peek_driver(plist)) < 0)
1474
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get driver");
1475
1476
0
done:
1477
0
    FUNC_LEAVE_API(ret_value)
1478
0
} /* end H5Pget_driver() */
1479
1480
/*-------------------------------------------------------------------------
1481
 * Function:    H5P_peek_driver_info
1482
 *
1483
 * Purpose:     Returns a pointer directly to the file driver-specific
1484
 *              information of a file access.
1485
 *
1486
 * Return:      Success:    Pointer to *uncopied* driver-specific data
1487
 *                          structure, if any.
1488
 *
1489
 *              Failure:    NULL. NULL is also returned if the driver has
1490
 *                          not registered any driver-specific properties
1491
 *                          although no error is pushed on the stack in
1492
 *                          this case.
1493
 *-------------------------------------------------------------------------
1494
 */
1495
const void *
1496
H5P_peek_driver_info(H5P_genplist_t *plist)
1497
0
{
1498
0
    const void *ret_value = NULL;
1499
1500
0
    FUNC_ENTER_NOAPI(NULL)
1501
1502
    /* Get the current driver info */
1503
0
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1504
0
        H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */
1505
1506
0
        if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1507
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info");
1508
0
        ret_value = driver_prop.driver_info;
1509
0
    }
1510
0
    else
1511
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a file access property list");
1512
1513
0
done:
1514
0
    FUNC_LEAVE_NOAPI(ret_value)
1515
0
} /* end H5P_peek_driver_info() */
1516
1517
/*-------------------------------------------------------------------------
1518
 * Function:    H5Pget_driver_info
1519
 *
1520
 * Purpose:    Returns a pointer directly to the file driver-specific
1521
 *        information of a file access.
1522
 *
1523
 * Return:    Success:    Ptr to *uncopied* driver specific data
1524
 *                structure if any.
1525
 *
1526
 *        Failure:    NULL. Null is also returned if the driver has
1527
 *                not registered any driver-specific properties
1528
 *                although no error is pushed on the stack in
1529
 *                this case.
1530
 *
1531
 *-------------------------------------------------------------------------
1532
 */
1533
const void *
1534
H5Pget_driver_info(hid_t plist_id)
1535
0
{
1536
0
    H5P_genplist_t *plist     = NULL; /* Property list pointer            */
1537
0
    const void     *ret_value = NULL; /* Return value                     */
1538
1539
0
    FUNC_ENTER_API(NULL)
1540
1541
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1542
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list");
1543
1544
    /* Get the driver info */
1545
0
    if (NULL == (ret_value = (const void *)H5P_peek_driver_info(plist)))
1546
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info");
1547
1548
0
done:
1549
0
    FUNC_LEAVE_API(ret_value)
1550
0
} /* end H5Pget_driver_info() */
1551
1552
/*-------------------------------------------------------------------------
1553
 * Function:   H5P_peek_driver_config_str
1554
 *
1555
 * Purpose:    Returns a pointer directly to the file driver configuration
1556
 *             string of a file access property list.
1557
 *
1558
 * Return:     Success: Ptr to *uncopied* driver configuration string, if
1559
 *                      any.
1560
 *
1561
 *             Failure: NULL. NULL is also returned if the driver has not
1562
 *                      been configured with a driver configuration string.
1563
 *
1564
 *-------------------------------------------------------------------------
1565
 */
1566
const char *
1567
H5P_peek_driver_config_str(H5P_genplist_t *plist)
1568
6
{
1569
6
    const char *ret_value = NULL; /* Return value */
1570
1571
6
    FUNC_ENTER_NOAPI(NULL)
1572
1573
    /* Get the current driver configuration string */
1574
6
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1575
6
        H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */
1576
1577
6
        if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1578
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver configuration string");
1579
6
        ret_value = driver_prop.driver_config_str;
1580
6
    } /* end if */
1581
0
    else
1582
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a file access property list");
1583
1584
6
done:
1585
6
    FUNC_LEAVE_NOAPI(ret_value)
1586
6
} /* end H5P_peek_driver_config_str() */
1587
1588
/*-------------------------------------------------------------------------
1589
 * Function:    H5Pget_driver_config_str
1590
 *
1591
 * Purpose:     Retrieves a string representation of the configuration for
1592
 *              the driver set on the given FAPL. The returned string can
1593
 *              be used to configure the same driver in an identical way.
1594
 *
1595
 *              `config_buf` may be NULL, in which case the length of the
1596
 *              driver configuration string is simply returned. The caller
1597
 *              can then allocate a buffer of the appropriate size and call
1598
 *              this routine again.
1599
 *
1600
 * Return:      Length of the driver configuration string on success (not
1601
 *                  including the NUL terminator)
1602
 *              Negative on failure
1603
 *
1604
 *-------------------------------------------------------------------------
1605
 */
1606
ssize_t
1607
H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size)
1608
0
{
1609
0
    H5P_genplist_t *plist; /* Property list pointer */
1610
0
    const char     *config_str = NULL;
1611
0
    ssize_t         ret_value  = -1;
1612
1613
0
    FUNC_ENTER_API((-1))
1614
1615
    /* Check arguments */
1616
0
    if (!config_buf && buf_size)
1617
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "config_buf cannot be NULL if buf_size is non-zero");
1618
1619
    /* Get the plist structure */
1620
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
1621
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, (-1), "can't find object for ID");
1622
1623
    /* Retrieve configuration string property */
1624
0
    if ((config_str = H5P_peek_driver_config_str(plist))) {
1625
0
        size_t config_str_len = strlen(config_str);
1626
1627
0
        if (config_buf) {
1628
0
            strncpy(config_buf, config_str, buf_size);
1629
0
            if (config_str_len >= buf_size)
1630
0
                config_buf[buf_size - 1] = '\0';
1631
0
        }
1632
1633
0
        ret_value = (ssize_t)config_str_len;
1634
0
    }
1635
0
    else
1636
0
        ret_value = 0;
1637
1638
0
done:
1639
0
    FUNC_LEAVE_API(ret_value)
1640
0
} /* H5Pget_driver_config_str() */
1641
1642
/*-------------------------------------------------------------------------
1643
 * Function:    H5P__file_driver_copy
1644
 *
1645
 * Purpose:     Copy file driver ID & info.
1646
 *
1647
 * Note:        This is an "in-place" copy, since this routine gets called
1648
 *              after the top-level copy has been performed and this routine
1649
 *              finishes the "deep" part of the copy.
1650
 *
1651
 * Return:      Success:        Non-negative
1652
 *              Failure:        Negative
1653
 *
1654
 *-------------------------------------------------------------------------
1655
 */
1656
static herr_t
1657
H5P__file_driver_copy(void *value)
1658
36
{
1659
36
    herr_t ret_value = SUCCEED; /* Return value */
1660
1661
36
    FUNC_ENTER_PACKAGE
1662
1663
36
    if (value) {
1664
36
        H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */
1665
1666
        /* Copy the driver & info, if there is one */
1667
36
        if (info->driver_id > 0) {
1668
            /* Increment the reference count on driver and copy driver info */
1669
36
            if (H5I_inc_ref(info->driver_id, false) < 0)
1670
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver");
1671
1672
            /* Copy driver info, if it exists */
1673
36
            if (info->driver_info) {
1674
0
                H5FD_class_t *driver; /* Pointer to driver */
1675
0
                void         *new_pl; /* Copy of driver info */
1676
1677
                /* Retrieve the driver for the ID */
1678
0
                if (NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id)))
1679
0
                    HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID");
1680
1681
                /* Allow the driver to copy or do it ourselves */
1682
0
                if (driver->fapl_copy) {
1683
0
                    if (NULL == (new_pl = (driver->fapl_copy)(info->driver_info)))
1684
0
                        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed");
1685
0
                } /* end if */
1686
0
                else if (driver->fapl_size > 0) {
1687
0
                    if (NULL == (new_pl = H5MM_malloc(driver->fapl_size)))
1688
0
                        HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed");
1689
0
                    H5MM_memcpy(new_pl, info->driver_info, driver->fapl_size);
1690
0
                } /* end else-if */
1691
0
                else
1692
0
                    HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info");
1693
1694
                /* Set the driver info for the copy */
1695
0
                info->driver_info = new_pl;
1696
0
            } /* end if */
1697
1698
            /* Copy driver configuration string, if it exists */
1699
36
            if (info->driver_config_str) {
1700
0
                char *new_config_str = NULL;
1701
1702
0
                if (NULL == (new_config_str = H5MM_strdup(info->driver_config_str)))
1703
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver configuration string copy failed");
1704
0
                info->driver_config_str = new_config_str;
1705
0
            } /* end if */
1706
36
        }     /* end if */
1707
36
    }         /* end if */
1708
1709
36
done:
1710
36
    FUNC_LEAVE_NOAPI(ret_value)
1711
36
} /* end H5P__file_driver_copy() */
1712
1713
/*-------------------------------------------------------------------------
1714
 * Function:    H5P__file_driver_free
1715
 *
1716
 * Purpose:     Free file driver ID & info.
1717
 *
1718
 * Return:      Success:        Non-negative
1719
 *              Failure:        Negative
1720
 *
1721
 *-------------------------------------------------------------------------
1722
 */
1723
static herr_t
1724
H5P__file_driver_free(void *value)
1725
36
{
1726
36
    herr_t ret_value = SUCCEED; /* Return value */
1727
1728
36
    FUNC_ENTER_PACKAGE
1729
1730
36
    if (value) {
1731
36
        H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */
1732
1733
36
        if (info->driver_id > 0) {
1734
1735
            /* Free the driver info, if it exists */
1736
36
            if (info->driver_info)
1737
0
                if (H5FD_free_driver_info(info->driver_id, info->driver_info) < 0)
1738
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed");
1739
1740
            /* Free the driver configuration string, if it exists */
1741
36
            H5MM_xfree_const(info->driver_config_str);
1742
1743
            /* Decrement reference count for driver */
1744
36
            if (H5I_dec_ref(info->driver_id) < 0)
1745
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID");
1746
36
        }
1747
36
    }
1748
1749
36
done:
1750
36
    FUNC_LEAVE_NOAPI(ret_value)
1751
36
} /* end H5P__file_driver_free() */
1752
1753
/*-------------------------------------------------------------------------
1754
 * Function:    H5P__facc_file_driver_create
1755
 *
1756
 * Purpose:     Create callback for the file driver ID & info property.
1757
 *
1758
 * Return:      Success:        Non-negative
1759
 *              Failure:        Negative
1760
 *
1761
 *-------------------------------------------------------------------------
1762
 */
1763
static herr_t
1764
H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1765
12
{
1766
12
    herr_t ret_value = SUCCEED; /* Return value */
1767
1768
12
    FUNC_ENTER_PACKAGE
1769
1770
    /* Make copy of file driver */
1771
12
    if (H5P__file_driver_copy(value) < 0)
1772
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver");
1773
1774
12
done:
1775
12
    FUNC_LEAVE_NOAPI(ret_value)
1776
12
} /* end H5P__facc_file_driver_create() */
1777
1778
/*-------------------------------------------------------------------------
1779
 * Function:    H5P__facc_file_driver_set
1780
 *
1781
 * Purpose:     Copies a file driver property when it's set for a property list
1782
 *
1783
 * Return:      Success:        Non-negative
1784
 *              Failure:        Negative
1785
 *
1786
 *-------------------------------------------------------------------------
1787
 */
1788
static herr_t
1789
H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1790
                          size_t H5_ATTR_UNUSED size, void *value)
1791
6
{
1792
6
    herr_t ret_value = SUCCEED; /* Return value */
1793
1794
6
    FUNC_ENTER_PACKAGE
1795
1796
    /* Sanity check */
1797
6
    assert(value);
1798
1799
    /* Make copy of file driver ID & info */
1800
6
    if (H5P__file_driver_copy(value) < 0)
1801
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver");
1802
1803
6
done:
1804
6
    FUNC_LEAVE_NOAPI(ret_value)
1805
6
} /* end H5P__facc_file_driver_set() */
1806
1807
/*-------------------------------------------------------------------------
1808
 * Function:    H5P__facc_file_driver_get
1809
 *
1810
 * Purpose:     Copies a file driver property when it's retrieved from a property list
1811
 *
1812
 * Return:      Success:        Non-negative
1813
 *              Failure:        Negative
1814
 *
1815
 *-------------------------------------------------------------------------
1816
 */
1817
static herr_t
1818
H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1819
                          size_t H5_ATTR_UNUSED size, void *value)
1820
0
{
1821
0
    herr_t ret_value = SUCCEED; /* Return value */
1822
1823
0
    FUNC_ENTER_PACKAGE
1824
1825
    /* Sanity check */
1826
0
    assert(value);
1827
1828
    /* Make copy of file driver */
1829
0
    if (H5P__file_driver_copy(value) < 0)
1830
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver");
1831
1832
0
done:
1833
0
    FUNC_LEAVE_NOAPI(ret_value)
1834
0
} /* end H5P__facc_file_driver_get() */
1835
1836
/*-------------------------------------------------------------------------
1837
 * Function:    H5P__facc_file_driver_del
1838
 *
1839
 * Purpose:     Frees memory used to store the driver ID & info property
1840
 *
1841
 * Return:      Success:        Non-negative
1842
 *              Failure:        Negative
1843
 *
1844
 *-------------------------------------------------------------------------
1845
 */
1846
static herr_t
1847
H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1848
                          size_t H5_ATTR_UNUSED size, void *value)
1849
6
{
1850
6
    herr_t ret_value = SUCCEED; /* Return value */
1851
1852
6
    FUNC_ENTER_PACKAGE
1853
1854
    /* Free the file driver ID & info */
1855
6
    if (H5P__file_driver_free(value) < 0)
1856
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver");
1857
1858
6
done:
1859
6
    FUNC_LEAVE_NOAPI(ret_value)
1860
6
} /* end H5P__facc_file_driver_del() */
1861
1862
/*-------------------------------------------------------------------------
1863
 * Function:    H5P__facc_file_driver_copy
1864
 *
1865
 * Purpose:     Copy callback for the file driver ID & info property.
1866
 *
1867
 * Return:      Success:        Non-negative
1868
 *              Failure:        Negative
1869
 *
1870
 *-------------------------------------------------------------------------
1871
 */
1872
static herr_t
1873
H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1874
18
{
1875
18
    herr_t ret_value = SUCCEED; /* Return value */
1876
1877
18
    FUNC_ENTER_PACKAGE
1878
1879
    /* Make copy of file driver */
1880
18
    if (H5P__file_driver_copy(value) < 0)
1881
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver");
1882
1883
18
done:
1884
18
    FUNC_LEAVE_NOAPI(ret_value)
1885
18
} /* end H5P__facc_file_driver_copy() */
1886
1887
/*-------------------------------------------------------------------------
1888
 * Function:       H5P__facc_file_driver_cmp
1889
 *
1890
 * Purpose:        Callback routine which is called whenever the file driver ID & info
1891
 *                 property in the file access property list is compared.
1892
 *
1893
 * Return:         positive if VALUE1 is greater than VALUE2, negative if
1894
 *                      VALUE2 is greater than VALUE1 and zero if VALUE1 and
1895
 *                      VALUE2 are equal.
1896
 *
1897
 *-------------------------------------------------------------------------
1898
 */
1899
static int
1900
H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
1901
0
{
1902
0
    const H5FD_driver_prop_t *info1 =
1903
0
                                 (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */
1904
0
        *info2 = (const H5FD_driver_prop_t *)_info2;
1905
0
    H5FD_class_t *cls1, *cls2;   /* Driver class for each property */
1906
0
    int           cmp_value;     /* Value from comparison */
1907
0
    herr_t        ret_value = 0; /* Return value */
1908
1909
0
    FUNC_ENTER_PACKAGE_NOERR
1910
1911
    /* Sanity check */
1912
0
    assert(info1);
1913
0
    assert(info2);
1914
0
    assert(size == sizeof(H5FD_driver_prop_t));
1915
1916
    /* Compare drivers */
1917
0
    if (NULL == (cls1 = H5FD_get_class(info1->driver_id)))
1918
0
        HGOTO_DONE(-1);
1919
0
    if (NULL == (cls2 = H5FD_get_class(info2->driver_id)))
1920
0
        HGOTO_DONE(1);
1921
0
    if (cls1->name == NULL && cls2->name != NULL)
1922
0
        HGOTO_DONE(-1);
1923
0
    if (cls1->name != NULL && cls2->name == NULL)
1924
0
        HGOTO_DONE(1);
1925
0
    if (0 != (cmp_value = strcmp(cls1->name, cls2->name)))
1926
0
        HGOTO_DONE(cmp_value);
1927
1928
    /* Compare driver infos */
1929
0
    if (cls1->fapl_size < cls2->fapl_size)
1930
0
        HGOTO_DONE(-1);
1931
0
    if (cls1->fapl_size > cls2->fapl_size)
1932
0
        HGOTO_DONE(1);
1933
0
    assert(cls1->fapl_size == cls2->fapl_size);
1934
0
    if (info1->driver_info == NULL && info2->driver_info != NULL)
1935
0
        HGOTO_DONE(-1);
1936
0
    if (info1->driver_info != NULL && info2->driver_info == NULL)
1937
0
        HGOTO_DONE(1);
1938
0
    if (info1->driver_info) {
1939
0
        assert(cls1->fapl_size > 0);
1940
0
        if (0 != (cmp_value = memcmp(info1->driver_info, info2->driver_info, cls1->fapl_size)))
1941
0
            HGOTO_DONE(cmp_value);
1942
0
    } /* end if */
1943
1944
    /* Compare driver configuration strings */
1945
0
    if (info1->driver_config_str == NULL && info2->driver_config_str != NULL)
1946
0
        HGOTO_DONE(-1);
1947
0
    if (info1->driver_config_str != NULL && info2->driver_config_str == NULL)
1948
0
        HGOTO_DONE(1);
1949
0
    if (info1->driver_config_str) {
1950
0
        if (0 != (cmp_value = strcmp(info1->driver_config_str, info2->driver_config_str)))
1951
0
            HGOTO_DONE(cmp_value);
1952
0
    }
1953
1954
0
done:
1955
0
    FUNC_LEAVE_NOAPI(ret_value)
1956
0
} /* end H5P__facc_file_driver_cmp() */
1957
1958
/*-------------------------------------------------------------------------
1959
 * Function:    H5P__facc_file_driver_close
1960
 *
1961
 * Purpose:     Close callback for the file driver ID & info property.
1962
 *
1963
 * Return:      Success:        Non-negative
1964
 *              Failure:        Negative
1965
 *
1966
 *-------------------------------------------------------------------------
1967
 */
1968
static herr_t
1969
H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1970
30
{
1971
30
    herr_t ret_value = SUCCEED; /* Return value */
1972
1973
30
    FUNC_ENTER_PACKAGE
1974
1975
    /* Free the file driver */
1976
30
    if (H5P__file_driver_free(value) < 0)
1977
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver");
1978
1979
30
done:
1980
30
    FUNC_LEAVE_NOAPI(ret_value)
1981
30
} /* end H5P__facc_file_driver_close() */
1982
1983
/*-------------------------------------------------------------------------
1984
 * Function:    H5Pset_family_offset
1985
 *
1986
 * Purpose:     Set offset for family driver.  This file access property
1987
 *              list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
1988
 *              to retrieve VFD file handle.
1989
 *
1990
 * Return:      Success:        Non-negative value.
1991
 *              Failure:        Negative value.
1992
 *
1993
 *-------------------------------------------------------------------------
1994
 */
1995
herr_t
1996
H5Pset_family_offset(hid_t fapl_id, hsize_t offset)
1997
0
{
1998
0
    H5P_genplist_t *plist;               /* Property list pointer */
1999
0
    herr_t          ret_value = SUCCEED; /* Return value */
2000
2001
0
    FUNC_ENTER_API(FAIL)
2002
2003
    /* Get the plist structure */
2004
0
    if (H5P_DEFAULT == fapl_id)
2005
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
2006
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, false)))
2007
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2008
2009
    /* Set value */
2010
0
    if (H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0)
2011
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set offset for family file");
2012
2013
0
done:
2014
0
    FUNC_LEAVE_API(ret_value)
2015
0
} /* end H5Pset_family_offset() */
2016
2017
/*-------------------------------------------------------------------------
2018
 * Function:    H5Pget_family_offset
2019
 *
2020
 * Purpose:     Get offset for family driver.  This file access property
2021
 *              list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
2022
 *              to retrieve VFD file handle.
2023
 *
2024
 * Return:      Success:        Non-negative value.
2025
 *              Failure:        Negative value.
2026
 *
2027
 *-------------------------------------------------------------------------
2028
 */
2029
herr_t
2030
H5Pget_family_offset(hid_t fapl_id, hsize_t *offset /*out*/)
2031
0
{
2032
0
    H5P_genplist_t *plist;               /* Property list pointer */
2033
0
    herr_t          ret_value = SUCCEED; /* Return value */
2034
2035
0
    FUNC_ENTER_API(FAIL)
2036
2037
    /* Get the plist structure */
2038
0
    if (H5P_DEFAULT == fapl_id)
2039
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
2040
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
2041
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2042
2043
    /* Get value */
2044
0
    if (offset) {
2045
0
        if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0)
2046
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set offset for family file");
2047
0
    } /* end if */
2048
2049
0
done:
2050
0
    FUNC_LEAVE_API(ret_value)
2051
0
} /* end H5Pget_family_offset() */
2052
2053
/*-------------------------------------------------------------------------
2054
 * Function:    H5Pset_multi_type
2055
 *
2056
 * Purpose:     Set data type for multi driver.  This file access property
2057
 *              list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
2058
 *              to retrieve VFD file handle.
2059
 *
2060
 * Return:      Success:        Non-negative value.
2061
 *              Failure:        Negative value.
2062
 *
2063
 *-------------------------------------------------------------------------
2064
 */
2065
herr_t
2066
H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type)
2067
0
{
2068
0
    H5P_genplist_t *plist;               /* Property list pointer */
2069
0
    herr_t          ret_value = SUCCEED; /* return value */
2070
2071
0
    FUNC_ENTER_API(FAIL)
2072
2073
    /* Get the plist structure */
2074
0
    if (H5P_DEFAULT == fapl_id)
2075
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
2076
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, false)))
2077
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2078
2079
    /* Set value */
2080
0
    if (H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0)
2081
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type for multi driver");
2082
2083
0
done:
2084
0
    FUNC_LEAVE_API(ret_value)
2085
0
} /* end H5Pset_multi_type() */
2086
2087
/*-------------------------------------------------------------------------
2088
 * Function:    H5Pget_multi_type
2089
 *
2090
 * Purpose:     Get data type for multi driver.  This file access property
2091
 *              list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
2092
 *              to retrieve VFD file handle.
2093
 *
2094
 * Return:      Success:        Non-negative value.
2095
 *              Failure:        Negative value.
2096
 *
2097
 *-------------------------------------------------------------------------
2098
 */
2099
herr_t
2100
H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type /*out*/)
2101
0
{
2102
0
    H5P_genplist_t *plist;               /* Property list pointer */
2103
0
    herr_t          ret_value = SUCCEED; /* Return value */
2104
2105
0
    FUNC_ENTER_API(FAIL)
2106
2107
    /* Get the plist structure */
2108
0
    if (H5P_DEFAULT == fapl_id)
2109
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
2110
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
2111
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2112
2113
    /* Get value */
2114
0
    if (type) {
2115
0
        if (H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0)
2116
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get type for multi driver");
2117
0
    } /* end if */
2118
2119
0
done:
2120
0
    FUNC_LEAVE_API(ret_value)
2121
0
} /* end H5Pget_multi_type() */
2122
2123
/*-------------------------------------------------------------------------
2124
 * Function:    H5Pset_cache
2125
 *
2126
 * Purpose:    Set the number of objects in the meta data cache and the
2127
 *        maximum number of chunks and bytes in the raw data chunk
2128
 *        cache.
2129
 *
2130
 *         The RDCC_W0 value should be between 0 and 1 inclusive and
2131
 *        indicates how much chunks that have been fully read or fully
2132
 *        written are favored for preemption.  A value of zero means
2133
 *        fully read or written chunks are treated no differently than
2134
 *        other chunks (the preemption is strictly LRU) while a value
2135
 *        of one means fully read chunks are always preempted before
2136
 *        other chunks.
2137
 *
2138
 * Return:    Non-negative on success/Negative on failure
2139
 *
2140
 *-------------------------------------------------------------------------
2141
 */
2142
herr_t
2143
H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes,
2144
             double rdcc_w0)
2145
0
{
2146
0
    H5P_genplist_t *plist;               /* Property list pointer */
2147
0
    herr_t          ret_value = SUCCEED; /* return value */
2148
2149
0
    FUNC_ENTER_API(FAIL)
2150
2151
    /* Check arguments */
2152
0
    if (rdcc_w0 < 0.0 || rdcc_w0 > 1.0)
2153
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
2154
0
                    "raw data cache w0 value must be between 0.0 and 1.0 inclusive");
2155
2156
    /* Get the plist structure */
2157
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2158
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2159
2160
    /* Set sizes */
2161
0
    if (H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0)
2162
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots");
2163
0
    if (H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0)
2164
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size");
2165
0
    if (H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0)
2166
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks");
2167
2168
0
done:
2169
0
    FUNC_LEAVE_API(ret_value)
2170
0
} /* end H5Pset_cache() */
2171
2172
/*-------------------------------------------------------------------------
2173
 * Function:    H5Pget_cache
2174
 *
2175
 * Purpose:    Retrieves the maximum possible number of elements in the meta
2176
 *        data cache and the maximum possible number of elements and
2177
 *        bytes and the RDCC_W0 value in the raw data chunk cache.  Any
2178
 *        (or all) arguments may be null pointers in which case the
2179
 *        corresponding datum is not returned.
2180
 *
2181
 * Return:    Non-negative on success/Negative on failure
2182
 *
2183
 *-------------------------------------------------------------------------
2184
 */
2185
herr_t
2186
H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nslots /*out*/, size_t *rdcc_nbytes /*out*/,
2187
             double *rdcc_w0 /*out*/)
2188
0
{
2189
0
    H5P_genplist_t *plist;               /* Property list pointer */
2190
0
    herr_t          ret_value = SUCCEED; /* return value */
2191
2192
0
    FUNC_ENTER_API(FAIL)
2193
2194
    /* Get the plist structure */
2195
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2196
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2197
2198
    /* Get sizes */
2199
2200
    /* the mdc_nelmts FAPL entry no longer exists, so just return a constant */
2201
0
    if (mdc_nelmts)
2202
0
        *mdc_nelmts = 0;
2203
2204
0
    if (rdcc_nslots)
2205
0
        if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0)
2206
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots");
2207
0
    if (rdcc_nbytes)
2208
0
        if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0)
2209
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size");
2210
0
    if (rdcc_w0)
2211
0
        if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0)
2212
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks");
2213
2214
0
done:
2215
0
    FUNC_LEAVE_API(ret_value)
2216
0
} /* end H5Pget_cache() */
2217
2218
/*-------------------------------------------------------------------------
2219
 * Function:    H5Pset_mdc_image_config
2220
 *
2221
 * Purpose:    Set the initial metadata cache image configuration in the
2222
 *        target FAPL.
2223
 *
2224
 * Return:    Non-negative on success/Negative on failure
2225
 *
2226
 *-------------------------------------------------------------------------
2227
 */
2228
herr_t
2229
H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr)
2230
0
{
2231
0
    H5P_genplist_t *plist;               /* Property list pointer */
2232
0
    herr_t          ret_value = SUCCEED; /* return value */
2233
2234
0
    FUNC_ENTER_API(FAIL)
2235
2236
    /* Get the plist structure */
2237
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2238
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2239
2240
    /* validate the new configuration */
2241
0
    if (H5AC_validate_cache_image_config(config_ptr) < 0)
2242
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache image configuration");
2243
2244
    /* set the modified metadata cache image config */
2245
2246
    /* If we ever support multiple versions of H5AC_cache_image_config_t, we
2247
     * will have to test the version and do translation here.
2248
     */
2249
2250
0
    if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0)
2251
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache image initial config");
2252
2253
0
done:
2254
0
    FUNC_LEAVE_API(ret_value)
2255
0
} /* H5Pset_mdc_image_config() */
2256
2257
/*-------------------------------------------------------------------------
2258
 * Function:    H5Pget_mdc_image_config
2259
 *
2260
 * Purpose:    Retrieve the metadata cache initial image configuration
2261
 *        from the target FAPL.
2262
 *
2263
 *        Observe that the function will fail if config_ptr is
2264
 *        NULL, or if config_ptr->version specifies an unknown
2265
 *        version of H5AC_cache_image_config_t.
2266
 *
2267
 * Return:    Non-negative on success/Negative on failure
2268
 *
2269
 *-------------------------------------------------------------------------
2270
 */
2271
herr_t
2272
H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config /*out*/)
2273
0
{
2274
0
    H5P_genplist_t *plist;               /* Property list pointer */
2275
0
    herr_t          ret_value = SUCCEED; /* return value */
2276
2277
0
    FUNC_ENTER_API(FAIL)
2278
2279
    /* Get the plist structure */
2280
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2281
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2282
2283
    /* validate the config ptr */
2284
0
    if (config == NULL)
2285
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.");
2286
0
    if (config->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION)
2287
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown image config version.");
2288
2289
    /* If we ever support multiple versions of H5AC_cache_config_t, we
2290
     * will have to get the canonical version here, and then translate
2291
     * to the version of the structure supplied.
2292
     */
2293
2294
    /* Get the current initial metadata cache resize configuration */
2295
0
    if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config) < 0)
2296
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial image config");
2297
2298
0
done:
2299
0
    FUNC_LEAVE_API(ret_value)
2300
0
} /* H5Pget_mdc_image_config() */
2301
2302
/*-------------------------------------------------------------------------
2303
 * Function:    H5Pset_mdc_config
2304
 *
2305
 * Purpose:    Set the initial metadata cache resize configuration in the
2306
 *        target FAPL.
2307
 *
2308
 * Return:    Non-negative on success/Negative on failure
2309
 *
2310
 *-------------------------------------------------------------------------
2311
 */
2312
herr_t
2313
H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr)
2314
0
{
2315
0
    H5P_genplist_t *plist;               /* Property list pointer */
2316
0
    herr_t          ret_value = SUCCEED; /* return value */
2317
2318
0
    FUNC_ENTER_API(FAIL)
2319
2320
    /* Get the plist structure */
2321
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2322
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2323
2324
    /* validate the new configuration */
2325
0
    if (H5AC_validate_config(config_ptr) < 0)
2326
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache configuration");
2327
2328
    /* set the modified config */
2329
2330
    /* If we ever support multiple versions of H5AC_cache_config_t, we
2331
     * will have to test the version and do translation here.
2332
     */
2333
2334
0
    if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0)
2335
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config");
2336
2337
0
done:
2338
0
    FUNC_LEAVE_API(ret_value)
2339
0
} /* H5Pset_mdc_config() */
2340
2341
/*-------------------------------------------------------------------------
2342
 * Function:    H5Pget_mdc_config
2343
 *
2344
 * Purpose:    Retrieve the metadata cache initial resize configuration
2345
 *        from the target FAPL.
2346
 *
2347
 *        Observe that the function will fail if config is
2348
 *        NULL, or if config_ptr->version specifies an unknown
2349
 *        version of H5AC_cache_config_t.
2350
 *
2351
 * Return:    Non-negative on success/Negative on failure
2352
 *
2353
 *-------------------------------------------------------------------------
2354
 */
2355
herr_t
2356
H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config /*out*/)
2357
0
{
2358
0
    H5P_genplist_t *plist;               /* Property list pointer */
2359
0
    herr_t          ret_value = SUCCEED; /* return value */
2360
2361
0
    FUNC_ENTER_API(FAIL)
2362
2363
    /* Get the plist structure */
2364
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2365
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2366
2367
    /* validate the config ptr */
2368
0
    if (config == NULL)
2369
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.");
2370
0
    if (config->version != H5AC__CURR_CACHE_CONFIG_VERSION)
2371
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.");
2372
2373
    /* If we ever support multiple versions of H5AC_cache_config_t, we
2374
     * will have to get the canonical version here, and then translate
2375
     * to the version of the structure supplied.
2376
     */
2377
2378
    /* Get the current initial metadata cache resize configuration */
2379
0
    if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config) < 0)
2380
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial resize config");
2381
2382
0
done:
2383
0
    FUNC_LEAVE_API(ret_value)
2384
0
} /* H5Pget_mdc_config() */
2385
2386
/*-------------------------------------------------------------------------
2387
 * Function:    H5Pset_gc_references
2388
 *
2389
 * Purpose:    Sets the flag for garbage collecting references for the file.
2390
 *        Dataset region references (and other reference types
2391
 *        probably) use space in the file heap.  If garbage collection
2392
 *        is on and the user passes in an uninitialized value in a
2393
 *        reference structure, the heap might get corrupted.  When
2394
 *        garbage collection is off however and the user reuses a
2395
 *        reference, the previous heap block will be orphaned and not
2396
 *        returned to the free heap space.  When garbage collection is
2397
 *        on, the user must initialize the reference structures to 0 or
2398
 *        risk heap corruption.
2399
 *
2400
 *        Default value for garbage collecting references is off, just
2401
 *        to be on the safe side.
2402
 *
2403
 * Return:    Non-negative on success/Negative on failure
2404
 *
2405
 *-------------------------------------------------------------------------
2406
 */
2407
herr_t
2408
H5Pset_gc_references(hid_t plist_id, unsigned gc_ref)
2409
0
{
2410
0
    H5P_genplist_t *plist;               /* Property list pointer */
2411
0
    herr_t          ret_value = SUCCEED; /* return value */
2412
2413
0
    FUNC_ENTER_API(FAIL)
2414
2415
    /* Get the plist structure */
2416
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2417
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2418
2419
    /* Set values */
2420
0
    if (H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0)
2421
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference");
2422
2423
0
done:
2424
0
    FUNC_LEAVE_API(ret_value)
2425
0
}
2426
2427
/*-------------------------------------------------------------------------
2428
 * Function:    H5Pget_gc_references
2429
 *
2430
 * Purpose:    Returns the current setting for the garbage collection
2431
 *        references property from a file access property list.
2432
 *
2433
 * Return:    Non-negative on success/Negative on failure
2434
 *
2435
 *-------------------------------------------------------------------------
2436
 */
2437
herr_t
2438
H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref /*out*/)
2439
0
{
2440
0
    H5P_genplist_t *plist;               /* Property list pointer */
2441
0
    herr_t          ret_value = SUCCEED; /* return value */
2442
2443
0
    FUNC_ENTER_API(FAIL)
2444
2445
    /* Get the plist structure */
2446
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2447
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2448
2449
    /* Get values */
2450
0
    if (gc_ref)
2451
0
        if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0)
2452
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference");
2453
2454
0
done:
2455
0
    FUNC_LEAVE_API(ret_value)
2456
0
}
2457
2458
/*-------------------------------------------------------------------------
2459
 * Function:    H5Pset_fclose_degree
2460
 *
2461
 * Purpose:     Sets the degree for the file close behavior.
2462
 *
2463
 * Return:      Non-negative on success/Negative on failure
2464
 *
2465
 *-------------------------------------------------------------------------
2466
 */
2467
herr_t
2468
H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree)
2469
0
{
2470
0
    H5P_genplist_t *plist;               /* Property list pointer */
2471
0
    herr_t          ret_value = SUCCEED; /* return value */
2472
2473
0
    FUNC_ENTER_API(FAIL)
2474
2475
    /* Get the plist structure */
2476
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2477
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2478
2479
    /* Set values */
2480
0
    if (H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, &degree) < 0)
2481
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree");
2482
2483
0
done:
2484
0
    FUNC_LEAVE_API(ret_value)
2485
0
} /* end H5Pset_fclose_degree() */
2486
2487
/*-------------------------------------------------------------------------
2488
 * Function:    H5Pget_fclose_degree
2489
 *
2490
 * Purpose:     Returns the degree for the file close behavior.
2491
 *
2492
 * Return:      Non-negative on success/Negative on failure
2493
 *
2494
 *-------------------------------------------------------------------------
2495
 */
2496
herr_t
2497
H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree /*out*/)
2498
0
{
2499
0
    H5P_genplist_t *plist;               /* Property list pointer */
2500
0
    herr_t          ret_value = SUCCEED; /* return value */
2501
2502
0
    FUNC_ENTER_API(FAIL)
2503
2504
    /* Get the plist structure */
2505
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2506
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2507
2508
0
    if (degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0)
2509
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree");
2510
2511
0
done:
2512
0
    FUNC_LEAVE_API(ret_value)
2513
0
} /* end H5Pget_fclose_degree() */
2514
2515
/*-------------------------------------------------------------------------
2516
 * Function:    H5Pset_meta_block_size
2517
 *
2518
 * Purpose:    Sets the minimum size of metadata block allocations when
2519
 *      the H5FD_FEAT_AGGREGATE_METADATA is set by a VFL driver.
2520
 *      Each "raw" metadata block is allocated to be this size and then
2521
 *      specific pieces of metadata (object headers, local heaps, B-trees, etc)
2522
 *      are sub-allocated from this block.
2523
 *
2524
 *        The default value is set to 2048 (bytes), indicating that metadata
2525
 *      will be attempted to be bunched together in (at least) 2K blocks in
2526
 *      the file.  Setting the value to 0 with this API function will
2527
 *      turn off the metadata aggregation, even if the VFL driver attempts to
2528
 *      use that strategy.
2529
 *
2530
 * Return:    Non-negative on success/Negative on failure
2531
 *
2532
 *-------------------------------------------------------------------------
2533
 */
2534
herr_t
2535
H5Pset_meta_block_size(hid_t plist_id, hsize_t size)
2536
0
{
2537
0
    H5P_genplist_t *plist;               /* Property list pointer */
2538
0
    herr_t          ret_value = SUCCEED; /* return value */
2539
2540
0
    FUNC_ENTER_API(FAIL)
2541
2542
    /* Get the plist structure */
2543
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2544
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2545
2546
    /* Set values */
2547
0
    if (H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0)
2548
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data block size");
2549
2550
0
done:
2551
0
    FUNC_LEAVE_API(ret_value)
2552
0
}
2553
2554
/*-------------------------------------------------------------------------
2555
 * Function:    H5Pget_meta_block_size
2556
 *
2557
 * Purpose:    Returns the current settings for the metadata block allocation
2558
 *      property from a file access property list.
2559
 *
2560
 * Return:    Non-negative on success/Negative on failure
2561
 *
2562
 *-------------------------------------------------------------------------
2563
 */
2564
herr_t
2565
H5Pget_meta_block_size(hid_t plist_id, hsize_t *size /*out*/)
2566
0
{
2567
0
    H5P_genplist_t *plist;               /* Property list pointer */
2568
0
    herr_t          ret_value = SUCCEED; /* return value */
2569
2570
0
    FUNC_ENTER_API(FAIL)
2571
2572
    /* Get the plist structure */
2573
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2574
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2575
2576
    /* Get values */
2577
0
    if (size) {
2578
0
        if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0)
2579
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get meta data block size");
2580
0
    } /* end if */
2581
2582
0
done:
2583
0
    FUNC_LEAVE_API(ret_value)
2584
0
}
2585
2586
/*-------------------------------------------------------------------------
2587
 * Function:    H5Pset_sieve_buf_size
2588
 *
2589
 * Purpose:    Sets the maximum size of the data sieve buffer used for file
2590
 *      drivers which are capable of using data sieving.  The data sieve
2591
 *      buffer is used when performing I/O on datasets in the file.  Using a
2592
 *      buffer which is large enough to hold several pieces of the dataset
2593
 *      being read in for hyperslab selections boosts performance by quite a
2594
 *      bit.
2595
 *
2596
 *        The default value is set to 64KB, indicating that file I/O for raw data
2597
 *      reads and writes will occur in at least 64KB blocks.
2598
 *      Setting the value to 0 with this API function will turn off the
2599
 *      data sieving, even if the VFL driver attempts to use that strategy.
2600
 *
2601
 * Return:    Non-negative on success/Negative on failure
2602
 *
2603
 *-------------------------------------------------------------------------
2604
 */
2605
herr_t
2606
H5Pset_sieve_buf_size(hid_t plist_id, size_t size)
2607
0
{
2608
0
    H5P_genplist_t *plist;               /* Property list pointer */
2609
0
    herr_t          ret_value = SUCCEED; /* return value */
2610
2611
0
    FUNC_ENTER_API(FAIL)
2612
2613
    /* Get the plist structure */
2614
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2615
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2616
2617
    /* Set values */
2618
0
    if (H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0)
2619
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size");
2620
2621
0
done:
2622
0
    FUNC_LEAVE_API(ret_value)
2623
0
} /* end H5Pset_sieve_buf_size() */
2624
2625
/*-------------------------------------------------------------------------
2626
 * Function:    H5Pget_sieve_buf_size
2627
 *
2628
 * Purpose:    Returns the current settings for the data sieve buffer size
2629
 *      property from a file access property list.
2630
 *
2631
 * Return:    Non-negative on success/Negative on failure
2632
 *
2633
 *-------------------------------------------------------------------------
2634
 */
2635
herr_t
2636
H5Pget_sieve_buf_size(hid_t plist_id, size_t *size /*out*/)
2637
0
{
2638
0
    H5P_genplist_t *plist;               /* Property list pointer */
2639
0
    herr_t          ret_value = SUCCEED; /* return value */
2640
2641
0
    FUNC_ENTER_API(FAIL)
2642
2643
    /* Get the plist structure */
2644
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2645
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2646
2647
    /* Get values */
2648
0
    if (size)
2649
0
        if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0)
2650
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size");
2651
2652
0
done:
2653
0
    FUNC_LEAVE_API(ret_value)
2654
0
} /* end H5Pget_sieve_buf_size() */
2655
2656
/*-------------------------------------------------------------------------
2657
 * Function:    H5Pset_small_data_block_size
2658
 *
2659
 * Purpose:    Sets the minimum size of "small" raw data block allocations
2660
 *      when the H5FD_FEAT_AGGREGATE_SMALLDATA is set by a VFL driver.
2661
 *      Each "small" raw data block is allocated to be this size and then
2662
 *      pieces of raw data which are small enough to fit are sub-allocated from
2663
 *      this block.
2664
 *
2665
 *    The default value is set to 2048 (bytes), indicating that raw data
2666
 *      smaller than this value will be attempted to be bunched together in (at
2667
 *      least) 2K blocks in the file.  Setting the value to 0 with this API
2668
 *      function will turn off the "small" raw data aggregation, even if the
2669
 *      VFL driver attempts to use that strategy.
2670
 *
2671
 * Return:    Non-negative on success/Negative on failure
2672
 *
2673
 *-------------------------------------------------------------------------
2674
 */
2675
herr_t
2676
H5Pset_small_data_block_size(hid_t plist_id, hsize_t size)
2677
0
{
2678
0
    H5P_genplist_t *plist;               /* Property list pointer */
2679
0
    herr_t          ret_value = SUCCEED; /* return value */
2680
2681
0
    FUNC_ENTER_API(FAIL)
2682
2683
    /* Get the plist structure */
2684
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2685
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2686
2687
    /* Set values */
2688
0
    if (H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0)
2689
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' block size");
2690
2691
0
done:
2692
0
    FUNC_LEAVE_API(ret_value)
2693
0
} /* end H5Pset_small_data_block_size() */
2694
2695
/*-------------------------------------------------------------------------
2696
 * Function:    H5Pget_small_data_block_size
2697
 *
2698
 * Purpose:    Returns the current settings for the "small" raw data block
2699
 *      allocation property from a file access property list.
2700
 *
2701
 * Return:    Non-negative on success/Negative on failure
2702
 *
2703
 *-------------------------------------------------------------------------
2704
 */
2705
herr_t
2706
H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/)
2707
0
{
2708
0
    H5P_genplist_t *plist;               /* Property list pointer */
2709
0
    herr_t          ret_value = SUCCEED; /* return value */
2710
2711
0
    FUNC_ENTER_API(FAIL)
2712
2713
    /* Get the plist structure */
2714
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2715
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2716
2717
    /* Get values */
2718
0
    if (size) {
2719
0
        if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0)
2720
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get 'small data' block size");
2721
0
    } /* end if */
2722
2723
0
done:
2724
0
    FUNC_LEAVE_API(ret_value)
2725
0
} /* end H5Pget_small_data_block_size() */
2726
2727
/*-------------------------------------------------------------------------
2728
 * Function:    H5Pset_libver_bounds
2729
 *
2730
 * Purpose:    Indicates which versions of the file format the library should
2731
 *      use when creating objects.  LOW is the earliest version of the HDF5
2732
 *      library that is guaranteed to be able to access the objects created
2733
 *      (the format of some objects in an HDF5 file may not have changed between
2734
 *      versions of the HDF5 library, possibly allowing earlier versions of the
2735
 *      HDF5 library to access those objects) and HIGH is the latest version
2736
 *      of the library required to access the objects created (later versions
2737
 *      of the HDF5 library will also be able to access those objects).
2738
 *
2739
 *      LOW is used to require that objects use a more modern format and HIGH
2740
 *      is used to restrict objects from using a more modern format.
2741
 *
2742
 *      The special values of H5F_FORMAT_EARLIEST and H5F_FORMAT_LATEST can be
2743
 *      used in the following manner:  Setting LOW and HIGH to H5F_FORMAT_LATEST
2744
 *      will produce files whose objects use the latest version of the file
2745
 *      format available in the current HDF5 library for each object created.
2746
 *      Setting LOW and HIGH to H5F_FORMAT_EARLIEST will produce files that that
2747
 *      always require the use of the earliest version of the file format for
2748
 *      each object created. [NOTE!  LOW=HIGH=H5F_FORMAT_EARLIEST is not
2749
 *      implemented as of version 1.8.0 and setting LOW and HIGH to
2750
 *      H5F_FORMAT_EARLIEST will produce an error currently].
2751
 *
2752
 *      Currently, the only two valid combinations for this routine are:
2753
 *      LOW = H5F_FORMAT_EARLIEST and HIGH = H5F_FORMAT_LATEST (the default
2754
 *      setting, which creates objects with the earliest version possible for
2755
 *      each object, but no upper limit on the version allowed to be created if
2756
 *      a newer version of an object's format is required to support a feature
2757
 *      requested with an HDF5 library API routine), and LOW = H5F_FORMAT_LATEST
2758
 *      and HIGH = H5F_FORMAT_LATEST (which is described above).
2759
 *
2760
 *      The LOW and HIGH values set with this routine at imposed with each
2761
 *      HDF5 library API call that creates objects in the file.  API calls that
2762
 *      would violate the LOW or HIGH format bound will fail.
2763
 *
2764
 *      Setting the LOW and HIGH values will not affect reading/writing existing
2765
 *      objects, only the creation of new objects.
2766
 *
2767
 * Note: Eventually we want to add more values to the H5F_libver_t
2768
 *      enumerated type that indicate library release values where the file
2769
 *      format was changed (like "H5F_FORMAT_1_2_0" for the file format changes
2770
 *      in the 1.2.x release branch and possibly even "H5F_FORMAT_1_4_2" for
2771
 *      a change mid-way through the 1.4.x release branch, etc).
2772
 *
2773
 *      Adding more values will allow applications to make settings like the
2774
 *      following:
2775
 *          LOW = H5F_FORMAT_EARLIEST, HIGH = H5F_FORMAT_1_2_0 => Create objects
2776
 *              with the earliest possible format and don't allow any objects
2777
 *              to be created that require a library version greater than 1.2.x
2778
 *              (This is the "make certain that <application> linked with v1.2.x
2779
 *              of the library can read the file produced" use case)
2780
 *
2781
 *          LOW = H5F_FORMAT_1_4_2, HIGH = H5F_FORMAT_LATEST => create objects
2782
 *              with at least the version of their format that the 1.4.2 library
2783
 *              uses and allow any later version of the object's format
2784
 *              necessary to represent features used.
2785
 *              (This is the "make certain to take advantage of <new feature>
2786
 *              in the file format" use case (maybe <new feature> is smaller
2787
 *              or scales better than an earlier version, which would otherwise
2788
 *              be used))
2789
 *
2790
 *         LOW = H5F_FORMAT_1_2_0, HIGH = H5F_FORMAT_1_6_0 => creates objects
2791
 *              with at least the version of their format that the 1.2.x library
2792
 *              uses and don't allow any objects to be created that require a
2793
 *              library version greater than 1.6.x.
2794
 *              (Not certain of a particular use case for these settings,
2795
 *              although its probably just the logical combination of the
2796
 *              previous two; it just falls out as possible/logical (if it turns
2797
 *              out to be hard to implement in some way, we can always disallow
2798
 *              it))
2799
 *
2800
 * Note #2:     We talked about whether to include enum values for only library
2801
 *      versions where the format changed and decided it would be less confusing
2802
 *      for application developers if we include enum values for _all_ library
2803
 *      releases and then map down to the previous actual library release which
2804
 *      had a format change.
2805
 *
2806
 * Note #3: The enumerated define for H5F_libver_t in 1.10 is:
2807
 *      typedef enum H5F_libver_t {
2808
 *          H5F_LIBVER_ERROR = -1,
2809
 *          H5F_LIBVER_EARLIEST = 0,
2810
 *          H5F_LIBVER_V18 = 1,
2811
 *          H5F_LIBVER_V110 = 2,
2812
 *          H5F_LIBVER_NBOUNDS
2813
 *      } H5F_libver_t;
2814
 *      #define H5F_LIBVER_LATEST       H5F_LIBVER_V110
2815
 *
2816
 *      The library supports five pairs of (low, high) combinations via H5Pset_libver_bounds():
2817
 *      1) H5F_LIBVER_EARLIEST, H5F_LIBVER_V18
2818
 *      2) H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST
2819
 *      4) H5F_LIBVER_V18, H5F_LIBVER_V18
2820
 *      4) H5F_LIBVER_V18, H5F_LIBVER_LATEST
2821
 *      5) H5F_LIBVER_LATEST, H5F_LIBVER_LATEST
2822
 *      See detailed description in the RFC: Setting Bounds for Object Creation in HDF5 1.10.0.
2823
 *
2824
 * Return:    Non-negative on success/Negative on failure
2825
 *
2826
 *-------------------------------------------------------------------------
2827
 */
2828
herr_t
2829
H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high)
2830
0
{
2831
0
    H5P_genplist_t *plist;               /* Property list pointer */
2832
0
    herr_t          ret_value = SUCCEED; /* return value */
2833
2834
0
    FUNC_ENTER_API(FAIL)
2835
2836
    /* Check args */
2837
0
    if (low < 0 || low > H5F_LIBVER_LATEST)
2838
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid");
2839
0
    if (high < 0 || high > H5F_LIBVER_LATEST)
2840
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid");
2841
2842
    /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */
2843
0
    if (high == H5F_LIBVER_EARLIEST)
2844
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound");
2845
2846
    /* (latest, v18) is not valid combination */
2847
0
    if (high < low)
2848
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound");
2849
2850
    /* Get the plist structure */
2851
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2852
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2853
2854
    /* Set values */
2855
0
    if (H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0)
2856
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions");
2857
0
    if (H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0)
2858
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions");
2859
0
done:
2860
0
    FUNC_LEAVE_API(ret_value)
2861
0
} /* end H5Pset_libver_bounds() */
2862
2863
/*-------------------------------------------------------------------------
2864
 * Function:    H5Pget_libver_bounds
2865
 *
2866
 * Purpose:     Returns the current settings for the library version format bounds
2867
 *              from a file access property list.
2868
 *
2869
 * Return:      Non-negative on success/Negative on failure
2870
 *
2871
 *-------------------------------------------------------------------------
2872
 */
2873
herr_t
2874
H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low /*out*/, H5F_libver_t *high /*out*/)
2875
0
{
2876
0
    H5P_genplist_t *plist;               /* Property list pointer */
2877
0
    herr_t          ret_value = SUCCEED; /* return value */
2878
2879
0
    FUNC_ENTER_API(FAIL)
2880
2881
    /* Get the plist structure */
2882
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2883
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2884
2885
    /* Get values */
2886
0
    if (low)
2887
0
        if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0)
2888
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions");
2889
2890
0
    if (high)
2891
0
        if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0)
2892
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions");
2893
2894
0
done:
2895
0
    FUNC_LEAVE_API(ret_value)
2896
0
} /* end H5Pget_libver_bounds() */
2897
2898
/*-------------------------------------------------------------------------
2899
 * Function:    H5Pset_elink_file_cache_size
2900
 *
2901
 * Purpose:     Sets the number of files opened through external links
2902
 *              from the file associated with this fapl to be held open
2903
 *              in that file's external file cache.  When the maximum
2904
 *              number of files is reached, the least recently used file
2905
 *              is closed (unless it is opened from somewhere else).
2906
 *
2907
 * Return:      Non-negative on success/Negative on failure
2908
 *
2909
 *-------------------------------------------------------------------------
2910
 */
2911
herr_t
2912
H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size)
2913
0
{
2914
0
    H5P_genplist_t *plist;               /* Property list pointer */
2915
0
    herr_t          ret_value = SUCCEED; /* return value */
2916
2917
0
    FUNC_ENTER_API(FAIL)
2918
2919
    /* Get the plist structure */
2920
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
2921
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2922
2923
    /* Set value */
2924
0
    if (H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0)
2925
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set elink file cache size");
2926
2927
0
done:
2928
0
    FUNC_LEAVE_API(ret_value)
2929
0
} /* end H5Pset_elink_file_cache_size() */
2930
2931
/*-------------------------------------------------------------------------
2932
 * Function:    H5Pget_elink_file_cache_size
2933
 *
2934
 * Purpose:     Gets the number of files opened through external links
2935
 *              from the file associated with this fapl to be held open
2936
 *              in that file's external file cache.  When the maximum
2937
 *              number of files is reached, the least recently used file
2938
 *              is closed (unless it is opened from somewhere else).
2939
 *
2940
 * Return:      Non-negative on success/Negative on failure
2941
 *
2942
 *-------------------------------------------------------------------------
2943
 */
2944
herr_t
2945
H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size /*out*/)
2946
0
{
2947
0
    H5P_genplist_t *plist;               /* Property list pointer */
2948
0
    herr_t          ret_value = SUCCEED; /* return value */
2949
2950
0
    FUNC_ENTER_API(FAIL)
2951
2952
    /* Get the plist structure */
2953
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
2954
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2955
2956
    /* Get value */
2957
0
    if (efc_size)
2958
0
        if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0)
2959
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink file cache size");
2960
2961
0
done:
2962
0
    FUNC_LEAVE_API(ret_value)
2963
0
} /* end H5Pget_elink_file_cache_size() */
2964
2965
/*-------------------------------------------------------------------------
2966
 * Function: H5Pset_file_image
2967
 *
2968
 * Purpose:     Sets the initial file image. Some file drivers can initialize
2969
 *              the starting data in a file from a buffer.
2970
 *
2971
 * Return:      Non-negative on success/Negative on failure
2972
 *
2973
 *-------------------------------------------------------------------------
2974
 */
2975
herr_t
2976
H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len)
2977
0
{
2978
0
    H5P_genplist_t        *fapl;                /* Property list pointer */
2979
0
    H5FD_file_image_info_t image_info;          /* File image info */
2980
0
    herr_t                 ret_value = SUCCEED; /* Return value */
2981
2982
0
    FUNC_ENTER_API(FAIL)
2983
2984
    /* validate parameters */
2985
0
    if (!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0))))
2986
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "inconsistent buf_ptr and buf_len");
2987
2988
    /* Get the plist structure */
2989
0
    if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, false)))
2990
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");
2991
2992
    /* Get old image info */
2993
0
    if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
2994
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image pointer");
2995
2996
    /* Release previous buffer, if it exists */
2997
0
    if (image_info.buffer != NULL) {
2998
0
        if (image_info.callbacks.image_free) {
2999
            /* Prepare & restore library for user callback */
3000
0
            H5_BEFORE_USER_CB(FAIL)
3001
0
                {
3002
0
                    ret_value = image_info.callbacks.image_free(
3003
0
                        image_info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata);
3004
0
                }
3005
0
            H5_AFTER_USER_CB(FAIL)
3006
0
            if (ret_value < 0)
3007
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed");
3008
0
        } /* end if */
3009
0
        else
3010
0
            H5MM_xfree(image_info.buffer);
3011
0
    } /* end if */
3012
3013
    /* Update struct */
3014
0
    if (buf_ptr) {
3015
        /* Allocate memory */
3016
0
        if (image_info.callbacks.image_malloc) {
3017
            /* Prepare & restore library for user callback */
3018
0
            H5_BEFORE_USER_CB(FAIL)
3019
0
                {
3020
0
                    image_info.buffer = image_info.callbacks.image_malloc(
3021
0
                        buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata);
3022
0
                }
3023
0
            H5_AFTER_USER_CB(FAIL)
3024
0
            if (NULL == image_info.buffer)
3025
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed");
3026
0
        } /* end if */
3027
0
        else if (NULL == (image_info.buffer = H5MM_malloc(buf_len)))
3028
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block");
3029
3030
        /* Copy data */
3031
0
        if (image_info.callbacks.image_memcpy) {
3032
0
            void *tmp;
3033
3034
            /* Prepare & restore library for user callback */
3035
0
            H5_BEFORE_USER_CB(FAIL)
3036
0
                {
3037
0
                    tmp = image_info.callbacks.image_memcpy(image_info.buffer, buf_ptr, buf_len,
3038
0
                                                            H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET,
3039
0
                                                            image_info.callbacks.udata);
3040
0
                }
3041
0
            H5_AFTER_USER_CB(FAIL)
3042
0
            if (image_info.buffer != tmp)
3043
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed");
3044
0
        } /* end if */
3045
0
        else
3046
0
            H5MM_memcpy(image_info.buffer, buf_ptr, buf_len);
3047
0
    } /* end if */
3048
0
    else
3049
0
        image_info.buffer = NULL;
3050
3051
0
    image_info.size = buf_len;
3052
3053
    /* Set values */
3054
0
    if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
3055
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info");
3056
3057
0
done:
3058
0
    FUNC_LEAVE_API(ret_value)
3059
0
} /* end H5Pset_file_image() */
3060
3061
/*-------------------------------------------------------------------------
3062
 * Function: H5Pget_file_image
3063
 *
3064
 * Purpose:     If the file image exists and buf is not NULL,
3065
 *        allocate a buffer of the correct size, copy the image into
3066
 *        the new buffer, and return the buffer to the caller in
3067
 *        *buf.  Do this using the file image callbacks
3068
 *        if defined.
3069
 *
3070
 *        NB: It is the responsibility of the caller to free the
3071
 *        buffer whose address is returned in *buf.  Do
3072
 *        this using free if the file image callbacks are not
3073
 *        defined, or with whatever method is appropriate if
3074
 *        the callbacks are defined.
3075
 *
3076
 *              If buf is not NULL, and no image exists, set
3077
 *        *buf to NULL.
3078
 *
3079
 *        If buf_len is not NULL, set *buf_len equal
3080
 *        to the length of the file image if it exists, and
3081
 *        to 0 if it does not.
3082
 *
3083
 * Return:      Non-negative on success/Negative on failure
3084
 *
3085
 *-------------------------------------------------------------------------
3086
 */
3087
herr_t
3088
H5Pget_file_image(hid_t fapl_id, void **buf /*out*/, size_t *buf_len /*out*/)
3089
0
{
3090
0
    H5P_genplist_t        *fapl;                /* Property list pointer */
3091
0
    H5FD_file_image_info_t image_info;          /* File image info */
3092
0
    herr_t                 ret_value = SUCCEED; /* Return value */
3093
3094
0
    FUNC_ENTER_API(FAIL)
3095
3096
    /* Get the plist structure */
3097
0
    if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
3098
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");
3099
3100
    /* Get values */
3101
0
    if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
3102
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info");
3103
3104
    /* verify file image field consistency */
3105
0
    assert(((image_info.buffer != NULL) && (image_info.size > 0)) ||
3106
0
           ((image_info.buffer == NULL) && (image_info.size == 0)));
3107
3108
    /* Set output size */
3109
0
    if (buf_len != NULL)
3110
0
        *buf_len = image_info.size;
3111
3112
    /* Duplicate the image if desired, using callbacks if available */
3113
0
    if (buf != NULL) {
3114
0
        void *copy_ptr = NULL; /* Copy of memory image */
3115
3116
0
        if (image_info.buffer != NULL) {
3117
            /* Allocate memory */
3118
0
            if (image_info.callbacks.image_malloc) {
3119
                /* Prepare & restore library for user callback */
3120
0
                H5_BEFORE_USER_CB(FAIL)
3121
0
                    {
3122
0
                        copy_ptr = image_info.callbacks.image_malloc(image_info.size,
3123
0
                                                                     H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET,
3124
0
                                                                     image_info.callbacks.udata);
3125
0
                    }
3126
0
                H5_AFTER_USER_CB(FAIL)
3127
0
                if (NULL == copy_ptr)
3128
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed");
3129
0
            } /* end if */
3130
0
            else if (NULL == (copy_ptr = H5MM_malloc(image_info.size)))
3131
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate copy");
3132
3133
            /* Copy data */
3134
0
            if (image_info.callbacks.image_memcpy) {
3135
0
                void *tmp;
3136
3137
                /* Prepare & restore library for user callback */
3138
0
                H5_BEFORE_USER_CB(FAIL)
3139
0
                    {
3140
0
                        tmp = image_info.callbacks.image_memcpy(copy_ptr, image_info.buffer, image_info.size,
3141
0
                                                                H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET,
3142
0
                                                                image_info.callbacks.udata);
3143
0
                    }
3144
0
                H5_AFTER_USER_CB(FAIL)
3145
0
                if (copy_ptr != tmp)
3146
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed");
3147
0
            } /* end if */
3148
0
            else
3149
0
                H5MM_memcpy(copy_ptr, image_info.buffer, image_info.size);
3150
0
        } /* end if */
3151
3152
0
        *buf = copy_ptr;
3153
0
    } /* end if */
3154
3155
0
done:
3156
0
    FUNC_LEAVE_API(ret_value)
3157
0
} /* end H5Pget_file_image */
3158
3159
/*-------------------------------------------------------------------------
3160
 * Function: H5Pset_file_image_callbacks
3161
 *
3162
 * Purpose:     Sets the callbacks for file images. Some file drivers allow
3163
 *              the use of user-defined callbacks for allocating, freeing and
3164
 *              copying the drivers internal buffer, potentially allowing a
3165
 *              clever user to do optimizations such as avoiding large mallocs
3166
 *              and memcpys or to perform detailed logging.
3167
 *
3168
 * Return:      Non-negative on success/Negative on failure
3169
 *
3170
 *-------------------------------------------------------------------------
3171
 */
3172
herr_t
3173
H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr)
3174
0
{
3175
0
    H5P_genplist_t        *fapl;                   /* Property list pointer */
3176
0
    H5FD_file_image_info_t info;                   /* File image info */
3177
0
    bool                   copied_udata = false;   /* Whether udata structure was copied */
3178
0
    herr_t                 ret_value    = SUCCEED; /* Return value */
3179
3180
0
    FUNC_ENTER_API(FAIL)
3181
3182
    /* Get the plist structure */
3183
0
    if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, false)))
3184
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");
3185
3186
    /* Get old info */
3187
0
    if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
3188
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image info");
3189
3190
    /* verify file image field consistency */
3191
0
    assert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0)));
3192
3193
    /* Make sure a file image hasn't already been set */
3194
0
    if (info.buffer != NULL || info.size > 0)
3195
0
        HGOTO_ERROR(
3196
0
            H5E_PLIST, H5E_SETDISALLOWED, FAIL,
3197
0
            "setting callbacks when an image is already set is forbidden. It could cause memory leaks.");
3198
3199
    /* verify that callbacks_ptr is not NULL */
3200
0
    if (NULL == callbacks_ptr)
3201
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr");
3202
3203
    /* Make sure udata callbacks are going to be set if udata is going to be set */
3204
0
    if (callbacks_ptr->udata)
3205
0
        if (callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL)
3206
0
            HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "udata callbacks must be set if udata is set");
3207
3208
    /* Release old udata if it exists */
3209
0
    if (info.callbacks.udata != NULL) {
3210
0
        assert(info.callbacks.udata_free);
3211
3212
        /* Prepare & restore library for user callback */
3213
0
        H5_BEFORE_USER_CB(FAIL)
3214
0
            {
3215
0
                ret_value = info.callbacks.udata_free(info.callbacks.udata);
3216
0
            }
3217
0
        H5_AFTER_USER_CB(FAIL)
3218
0
        if (ret_value < 0)
3219
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed");
3220
0
    } /* end if */
3221
3222
    /* Update struct */
3223
0
    info.callbacks = *callbacks_ptr;
3224
3225
0
    if (callbacks_ptr->udata) {
3226
0
        assert(callbacks_ptr->udata_copy);
3227
0
        assert(callbacks_ptr->udata_free);
3228
3229
        /* Prepare & restore library for user callback */
3230
0
        H5_BEFORE_USER_CB(FAIL)
3231
0
            {
3232
0
                info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata);
3233
0
            }
3234
0
        H5_AFTER_USER_CB(FAIL)
3235
0
        if (NULL == info.callbacks.udata)
3236
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy the supplied udata");
3237
0
    } /* end if */
3238
3239
0
    copied_udata = true;
3240
3241
    /* Set values */
3242
0
    if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
3243
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info");
3244
3245
0
done:
3246
0
    if (ret_value < 0) {
3247
0
        if (copied_udata) {
3248
            /* Prepare & restore library for user callback */
3249
0
            H5_BEFORE_USER_CB(FAIL)
3250
0
                {
3251
0
                    ret_value = callbacks_ptr->udata_free(info.callbacks.udata);
3252
0
                }
3253
0
            H5_AFTER_USER_CB(FAIL)
3254
0
            if (ret_value < 0)
3255
0
                HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed");
3256
0
        }
3257
0
    }
3258
3259
0
    FUNC_LEAVE_API(ret_value)
3260
0
} /* end H5Pset_file_image_callbacks() */
3261
3262
/*-------------------------------------------------------------------------
3263
 * Function:    H5Pget_file_image_callbacks
3264
 *
3265
 * Purpose:     Sets the callbacks for file images. Some file drivers allow
3266
 *              the use of user-defined callbacks for allocating, freeing and
3267
 *              copying the drivers internal buffer, potentially allowing a
3268
 *              clever user to do optimizations such as avoiding large mallocs
3269
 *
3270
 * Return:      Non-negative on success/Negative on failure
3271
 *
3272
 *-------------------------------------------------------------------------
3273
 */
3274
herr_t
3275
H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks /*out*/)
3276
0
{
3277
0
    H5P_genplist_t        *fapl;                /* Property list pointer */
3278
0
    H5FD_file_image_info_t info;                /* File image info */
3279
0
    herr_t                 ret_value = SUCCEED; /* Return value */
3280
3281
0
    FUNC_ENTER_API(FAIL)
3282
3283
    /* Get the plist structure */
3284
0
    if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS, true)))
3285
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");
3286
3287
    /* Get old info */
3288
0
    if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
3289
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info");
3290
3291
    /* verify file image field consistency */
3292
0
    assert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0)));
3293
3294
    /* verify that callbacks is not NULL */
3295
0
    if (NULL == callbacks)
3296
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks ptr");
3297
3298
    /* Transfer values to parameters */
3299
0
    *callbacks = info.callbacks;
3300
3301
    /* Copy udata if it exists */
3302
0
    if (info.callbacks.udata != NULL) {
3303
0
        assert(info.callbacks.udata_copy);
3304
3305
        /* Prepare & restore library for user callback */
3306
0
        H5_BEFORE_USER_CB(FAIL)
3307
0
            {
3308
0
                callbacks->udata = info.callbacks.udata_copy(info.callbacks.udata);
3309
0
            }
3310
0
        H5_AFTER_USER_CB(FAIL)
3311
0
        if (NULL == callbacks->udata)
3312
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata");
3313
0
    } /* end if */
3314
3315
0
done:
3316
0
    FUNC_LEAVE_API(ret_value)
3317
0
} /* end H5Pget_file_image_callbacks() */
3318
3319
/*-------------------------------------------------------------------------
3320
 * Function:    H5P__file_image_info_copy
3321
 *
3322
 * Purpose:     Copy file image info. The buffer
3323
 *              and udata may need to be copied, possibly using their
3324
 *              respective callbacks so the default copy won't work.
3325
 *
3326
 * Note:        This is an "in-place" copy, since this routine gets called
3327
 *              after the top-level copy has been performed and this routine
3328
 *        finishes the "deep" part of the copy.
3329
 *
3330
 * Return:      Success:        Non-negative
3331
 *              Failure:        Negative
3332
 *
3333
 *-------------------------------------------------------------------------
3334
 */
3335
static herr_t
3336
H5P__file_image_info_copy(void *value)
3337
18
{
3338
18
    herr_t ret_value = SUCCEED; /* Return value */
3339
3340
18
    FUNC_ENTER_PACKAGE
3341
3342
18
    if (value) {
3343
18
        H5FD_file_image_info_t *info; /* Image info struct */
3344
3345
18
        info = (H5FD_file_image_info_t *)value;
3346
3347
        /* verify file image field consistency */
3348
18
        assert(((info->buffer != NULL) && (info->size > 0)) || ((info->buffer == NULL) && (info->size == 0)));
3349
3350
18
        if (info->buffer && info->size > 0) {
3351
0
            void *old_buffer; /* Pointer to old image buffer */
3352
3353
            /* Store the old buffer */
3354
0
            old_buffer = info->buffer;
3355
3356
            /* Allocate new buffer */
3357
0
            if (info->callbacks.image_malloc) {
3358
                /* Prepare & restore library for user callback */
3359
0
                H5_BEFORE_USER_CB(FAIL)
3360
0
                    {
3361
0
                        info->buffer = info->callbacks.image_malloc(
3362
0
                            info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata);
3363
0
                    }
3364
0
                H5_AFTER_USER_CB(FAIL)
3365
0
                if (NULL == info->buffer)
3366
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed");
3367
0
            } /* end if */
3368
0
            else if (NULL == (info->buffer = H5MM_malloc(info->size)))
3369
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block");
3370
3371
            /* Copy data to new buffer */
3372
0
            if (info->callbacks.image_memcpy) {
3373
0
                void *tmp;
3374
3375
                /* Prepare & restore library for user callback */
3376
0
                H5_BEFORE_USER_CB(FAIL)
3377
0
                    {
3378
0
                        tmp = info->callbacks.image_memcpy(info->buffer, old_buffer, info->size,
3379
0
                                                           H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY,
3380
0
                                                           info->callbacks.udata);
3381
0
                    }
3382
0
                H5_AFTER_USER_CB(FAIL)
3383
0
                if (info->buffer != tmp)
3384
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed");
3385
0
            } /* end if */
3386
0
            else
3387
0
                H5MM_memcpy(info->buffer, old_buffer, info->size);
3388
0
        } /* end if */
3389
3390
        /* Copy udata if it exists */
3391
18
        if (info->callbacks.udata) {
3392
0
            void *old_udata = info->callbacks.udata;
3393
3394
0
            if (NULL == info->callbacks.udata_copy)
3395
0
                HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_copy not defined");
3396
3397
            /* Prepare & restore library for user callback */
3398
0
            H5_BEFORE_USER_CB(FAIL)
3399
0
                {
3400
0
                    info->callbacks.udata = info->callbacks.udata_copy(old_udata);
3401
0
                }
3402
0
            H5_AFTER_USER_CB(FAIL)
3403
0
        } /* end if */
3404
18
    }     /* end if */
3405
3406
18
done:
3407
18
    FUNC_LEAVE_NOAPI(ret_value)
3408
18
} /* end H5P__file_image_info_copy() */
3409
3410
/*-------------------------------------------------------------------------
3411
 * Function:    H5P__file_image_info_free
3412
 *
3413
 * Purpose:     Free file image info.  The buffer and udata may need to be
3414
 *        freed, possibly using their respective callbacks, so the
3415
 *        default free won't work.
3416
 *
3417
 * Return:      Success:        Non-negative
3418
 *              Failure:        Negative
3419
 *
3420
 *-------------------------------------------------------------------------
3421
 */
3422
static herr_t
3423
H5P__file_image_info_free(void *value)
3424
30
{
3425
30
    herr_t ret_value = SUCCEED; /* Return value */
3426
3427
30
    FUNC_ENTER_PACKAGE
3428
3429
30
    if (value) {
3430
30
        H5FD_file_image_info_t *info; /* Image info struct */
3431
3432
30
        info = (H5FD_file_image_info_t *)value;
3433
3434
        /* Verify file image field consistency */
3435
30
        assert(((info->buffer != NULL) && (info->size > 0)) || ((info->buffer == NULL) && (info->size == 0)));
3436
3437
        /* Free buffer */
3438
30
        if (info->buffer != NULL && info->size > 0) {
3439
0
            if (info->callbacks.image_free) {
3440
                /* Prepare & restore library for user callback */
3441
0
                H5_BEFORE_USER_CB(FAIL)
3442
0
                    {
3443
0
                        ret_value = (*info->callbacks.image_free)(
3444
0
                            info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, info->callbacks.udata);
3445
0
                    }
3446
0
                H5_AFTER_USER_CB(FAIL)
3447
0
                if (ret_value < 0)
3448
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed");
3449
0
            } /* end if */
3450
0
            else
3451
0
                H5MM_xfree(info->buffer);
3452
0
        } /* end if */
3453
3454
        /* Free udata if it exists */
3455
30
        if (info->callbacks.udata) {
3456
0
            if (NULL == info->callbacks.udata_free)
3457
0
                HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_free not defined");
3458
            /* Prepare & restore library for user callback */
3459
0
            H5_BEFORE_USER_CB(FAIL)
3460
0
                {
3461
0
                    ret_value = (*info->callbacks.udata_free)(info->callbacks.udata);
3462
0
                }
3463
0
            H5_AFTER_USER_CB(FAIL)
3464
0
            if (ret_value < 0)
3465
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed");
3466
0
        } /* end if */
3467
30
    }     /* end if */
3468
3469
30
done:
3470
30
    FUNC_LEAVE_NOAPI(ret_value)
3471
30
} /* end H5P__file_image_info_free() */
3472
3473
/*-------------------------------------------------------------------------
3474
 * Function: H5P__facc_cache_image_config_cmp
3475
 *
3476
 * Purpose: Compare two cache image configurations.
3477
 *
3478
 * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
3479
 *        greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
3480
 *
3481
 *-------------------------------------------------------------------------
3482
 */
3483
static int
3484
H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size)
3485
0
{
3486
0
    const H5AC_cache_image_config_t *config1 =
3487
0
        (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */
3488
0
    const H5AC_cache_image_config_t *config2 =
3489
0
        (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */
3490
0
    int ret_value = 0;                               /* Return value */
3491
3492
0
    FUNC_ENTER_PACKAGE_NOERR
3493
3494
    /* Check for a property being set */
3495
0
    if (config1 == NULL && config2 != NULL)
3496
0
        HGOTO_DONE(-1);
3497
0
    if (config1 != NULL && config2 == NULL)
3498
0
        HGOTO_DONE(1);
3499
3500
0
    if (config1->version < config2->version)
3501
0
        HGOTO_DONE(-1);
3502
0
    if (config1->version > config2->version)
3503
0
        HGOTO_DONE(1);
3504
3505
0
    if (config1->generate_image < config2->generate_image)
3506
0
        HGOTO_DONE(-1);
3507
0
    if (config1->generate_image > config2->generate_image)
3508
0
        HGOTO_DONE(1);
3509
3510
0
    if (config1->save_resize_status < config2->save_resize_status)
3511
0
        HGOTO_DONE(-1);
3512
0
    if (config1->save_resize_status > config2->save_resize_status)
3513
0
        HGOTO_DONE(1);
3514
3515
0
    if (config1->entry_ageout < config2->entry_ageout)
3516
0
        HGOTO_DONE(-1);
3517
0
    if (config1->entry_ageout > config2->entry_ageout)
3518
0
        HGOTO_DONE(1);
3519
3520
0
done:
3521
0
    FUNC_LEAVE_NOAPI(ret_value)
3522
0
} /* end H5P__facc_cache_image_config_cmp() */
3523
3524
/*-------------------------------------------------------------------------
3525
 * Function: H5P__facc_cache_image_config_enc
3526
 *
3527
 * Purpose:  Callback routine which is called whenever the default
3528
 *           cache image config property in the file creation
3529
 *           property list is encoded.
3530
 *
3531
 * Return:   Success:    Non-negative
3532
 *           Failure:    Negative
3533
 *
3534
 *-------------------------------------------------------------------------
3535
 */
3536
static herr_t
3537
H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size)
3538
0
{
3539
0
    const H5AC_cache_image_config_t *config =
3540
0
        (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */
3541
0
    uint8_t **pp = (uint8_t **)_pp;
3542
3543
0
    FUNC_ENTER_PACKAGE_NOERR
3544
3545
    /* Sanity check */
3546
0
    assert(value);
3547
3548
0
    if (NULL != *pp) {
3549
        /* Encode type sizes (as a safety check) */
3550
0
        *(*pp)++ = (uint8_t)sizeof(unsigned);
3551
3552
0
        INT32ENCODE(*pp, (int32_t)config->version);
3553
0
        H5_ENCODE_UNSIGNED(*pp, config->generate_image);
3554
0
        H5_ENCODE_UNSIGNED(*pp, config->save_resize_status);
3555
0
        INT32ENCODE(*pp, (int32_t)config->entry_ageout);
3556
0
    } /* end if */
3557
3558
    /* Compute encoded size of fixed-size values */
3559
0
    *size += (1 + (2 * sizeof(unsigned)) + (2 * sizeof(int32_t)));
3560
3561
0
    FUNC_LEAVE_NOAPI(SUCCEED)
3562
0
} /* end H5P__facc_cache_image_config_enc() */
3563
3564
/*-------------------------------------------------------------------------
3565
 * Function: H5P__facc_cache_image_config_dec
3566
 *
3567
 * Purpose:  Callback routine which is called whenever the default
3568
 *           cache image config property in the file creation property
3569
 *           list is  decoded.
3570
 *
3571
 * Return:   Success:    Non-negative
3572
 *           Failure:    Negative
3573
 *
3574
 *-------------------------------------------------------------------------
3575
 */
3576
static herr_t
3577
H5P__facc_cache_image_config_dec(const void **_pp, void *_value)
3578
0
{
3579
0
    H5AC_cache_image_config_t *config = (H5AC_cache_image_config_t *)_value;
3580
0
    const uint8_t            **pp     = (const uint8_t **)_pp;
3581
0
    unsigned                   enc_size;
3582
0
    herr_t                     ret_value = SUCCEED; /* Return value */
3583
3584
0
    FUNC_ENTER_PACKAGE
3585
3586
    /* Sanity checks */
3587
0
    assert(pp);
3588
0
    assert(*pp);
3589
0
    assert(config);
3590
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
3591
3592
    /* Set property to default value */
3593
0
    H5MM_memcpy(config, &H5F_def_mdc_initCacheImageCfg_g, sizeof(H5AC_cache_image_config_t));
3594
3595
    /* Decode type sizes */
3596
0
    enc_size = *(*pp)++;
3597
0
    if (enc_size != sizeof(unsigned))
3598
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded");
3599
3600
0
    INT32DECODE(*pp, config->version);
3601
0
    H5_DECODE_UNSIGNED(*pp, config->generate_image);
3602
0
    H5_DECODE_UNSIGNED(*pp, config->save_resize_status);
3603
0
    INT32DECODE(*pp, config->entry_ageout);
3604
3605
0
done:
3606
0
    FUNC_LEAVE_NOAPI(ret_value)
3607
0
} /* end H5P__facc_cache_image_config_dec() */
3608
3609
/*-------------------------------------------------------------------------
3610
 * Function:    H5P__facc_file_image_info_set
3611
 *
3612
 * Purpose:     Copies a file image property when it's set for a property list
3613
 *
3614
 * Return:      Success:        Non-negative
3615
 *              Failure:        Negative
3616
 *
3617
 *-------------------------------------------------------------------------
3618
 */
3619
static herr_t
3620
H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3621
                              size_t H5_ATTR_UNUSED size, void *value)
3622
0
{
3623
0
    herr_t ret_value = SUCCEED; /* Return value */
3624
3625
0
    FUNC_ENTER_PACKAGE
3626
3627
    /* Sanity check */
3628
0
    assert(value);
3629
3630
    /* Make copy of file image info */
3631
0
    if (H5P__file_image_info_copy(value) < 0)
3632
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info");
3633
3634
0
done:
3635
0
    FUNC_LEAVE_NOAPI(ret_value)
3636
0
} /* end H5P__facc_file_image_info_set() */
3637
3638
/*-------------------------------------------------------------------------
3639
 * Function:    H5P__facc_file_image_info_get
3640
 *
3641
 * Purpose:     Copies a file image property when it's retrieved from a property list
3642
 *
3643
 * Return:      Success:        Non-negative
3644
 *              Failure:        Negative
3645
 *
3646
 *-------------------------------------------------------------------------
3647
 */
3648
static herr_t
3649
H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3650
                              size_t H5_ATTR_UNUSED size, void *value)
3651
0
{
3652
0
    herr_t ret_value = SUCCEED; /* Return value */
3653
3654
0
    FUNC_ENTER_PACKAGE
3655
3656
    /* Sanity check */
3657
0
    assert(value);
3658
3659
    /* Make copy of file image info */
3660
0
    if (H5P__file_image_info_copy(value) < 0)
3661
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info");
3662
3663
0
done:
3664
0
    FUNC_LEAVE_NOAPI(ret_value)
3665
0
} /* end H5P__facc_file_image_info_get() */
3666
3667
/*-------------------------------------------------------------------------
3668
 * Function:    H5P__facc_file_image_info_del
3669
 *
3670
 * Purpose:     Delete callback for the file image info property, called
3671
 *              when the property is deleted from the plist. The buffer
3672
 *              and udata may need to be freed, possibly using their
3673
 *              respective callbacks so the default free won't work.
3674
 *
3675
 * Return:      Non-negative on success/Negative on failure
3676
 *
3677
 *-------------------------------------------------------------------------
3678
 */
3679
static herr_t
3680
H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3681
                              size_t H5_ATTR_UNUSED size, void *value)
3682
0
{
3683
0
    herr_t ret_value = SUCCEED; /* Return value */
3684
3685
0
    FUNC_ENTER_PACKAGE
3686
3687
    /* Free the file image info */
3688
0
    if (H5P__file_image_info_free(value) < 0)
3689
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info");
3690
3691
0
done:
3692
0
    FUNC_LEAVE_NOAPI(ret_value)
3693
0
} /* end H5P__facc_file_image_info_del() */
3694
3695
/*-------------------------------------------------------------------------
3696
 * Function:    H5P__facc_file_image_info_copy
3697
 *
3698
 * Purpose:     Copy callback for the file image info property. The buffer
3699
 *              and udata may need to be copied, possibly using their
3700
 *              respective callbacks so the default copy won't work.
3701
 *
3702
 * Return:      Non-negative on success/Negative on failure
3703
 *
3704
 *-------------------------------------------------------------------------
3705
 */
3706
static herr_t
3707
H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
3708
18
{
3709
18
    herr_t ret_value = SUCCEED; /* Return value */
3710
3711
18
    FUNC_ENTER_PACKAGE
3712
3713
    /* Make copy of file image info */
3714
18
    if (H5P__file_image_info_copy(value) < 0)
3715
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info");
3716
3717
18
done:
3718
18
    FUNC_LEAVE_NOAPI(ret_value)
3719
18
} /* end H5P__facc_file_image_info_copy() */
3720
3721
/*-------------------------------------------------------------------------
3722
 * Function:       H5P__facc_file_image_info_cmp
3723
 *
3724
 * Purpose:        Callback routine which is called whenever the file image info
3725
 *                 property in the file access property list is compared.
3726
 *
3727
 * Return:         positive if VALUE1 is greater than VALUE2, negative if
3728
 *                      VALUE2 is greater than VALUE1 and zero if VALUE1 and
3729
 *                      VALUE2 are equal.
3730
 *
3731
 *-------------------------------------------------------------------------
3732
 */
3733
static int
3734
H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
3735
0
{
3736
0
    const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *)
3737
0
                                     _info1, /* Create local aliases for values */
3738
0
        *info2       = (const H5FD_file_image_info_t *)_info2;
3739
0
    herr_t ret_value = 0; /* Return value */
3740
3741
0
    FUNC_ENTER_PACKAGE_NOERR
3742
3743
    /* Sanity check */
3744
0
    assert(info1);
3745
0
    assert(info2);
3746
0
    assert(size == sizeof(H5FD_file_image_info_t));
3747
3748
    /* Check for different buffer sizes */
3749
0
    if (info1->size < info2->size)
3750
0
        HGOTO_DONE(-1);
3751
0
    if (info1->size > info2->size)
3752
0
        HGOTO_DONE(1);
3753
3754
    /* Check for different callbacks */
3755
    /* (Order in memory is fairly meaningless, so just check for equality) */
3756
0
    if (info1->callbacks.image_malloc != info2->callbacks.image_malloc)
3757
0
        HGOTO_DONE(1);
3758
0
    if (info1->callbacks.image_memcpy != info2->callbacks.image_memcpy)
3759
0
        HGOTO_DONE(-1);
3760
0
    if (info1->callbacks.image_realloc != info2->callbacks.image_realloc)
3761
0
        HGOTO_DONE(1);
3762
0
    if (info1->callbacks.image_free != info2->callbacks.image_free)
3763
0
        HGOTO_DONE(-1);
3764
0
    if (info1->callbacks.udata_copy != info2->callbacks.udata_copy)
3765
0
        HGOTO_DONE(1);
3766
0
    if (info1->callbacks.udata_free != info2->callbacks.udata_free)
3767
0
        HGOTO_DONE(-1);
3768
3769
    /* Check for different udata */
3770
    /* (Don't know how big it is, so can't check contents) */
3771
0
    if (info1->callbacks.udata < info2->callbacks.udata)
3772
0
        HGOTO_DONE(-1);
3773
0
    if (info1->callbacks.udata > info2->callbacks.udata)
3774
0
        HGOTO_DONE(1);
3775
3776
    /* Check buffer contents (instead of buffer pointers) */
3777
0
    if (info1->buffer != NULL && info2->buffer == NULL)
3778
0
        HGOTO_DONE(-1);
3779
0
    if (info1->buffer == NULL && info2->buffer != NULL)
3780
0
        HGOTO_DONE(1);
3781
0
    if (info1->buffer != NULL && info2->buffer != NULL)
3782
0
        ret_value = memcmp(info1->buffer, info2->buffer, size);
3783
3784
0
done:
3785
0
    FUNC_LEAVE_NOAPI(ret_value)
3786
0
} /* end H5P__facc_file_image_info_cmp() */
3787
3788
/*-------------------------------------------------------------------------
3789
 * Function:    H5P__facc_file_image_info_close
3790
 *
3791
 * Purpose:     Close callback for the file image info property. The buffer
3792
 *              and udata may need to be freed, possibly using their
3793
 *              respective callbacks so the standard free won't work.
3794
 *
3795
 * Return:      Non-negative on success/Negative on failure
3796
 *
3797
 *-------------------------------------------------------------------------
3798
 */
3799
static herr_t
3800
H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
3801
30
{
3802
30
    herr_t ret_value = SUCCEED; /* Return value */
3803
3804
30
    FUNC_ENTER_PACKAGE
3805
3806
    /* Free the file image info */
3807
30
    if (H5P__file_image_info_free(value) < 0)
3808
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info");
3809
3810
30
done:
3811
30
    FUNC_LEAVE_NOAPI(ret_value)
3812
30
} /* end H5P__facc_file_image_info_close() */
3813
3814
/*-------------------------------------------------------------------------
3815
 * Function: H5P__facc_cache_config_cmp
3816
 *
3817
 * Purpose: Compare two cache configurations.
3818
 *
3819
 * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
3820
 *        greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
3821
 *
3822
 *-------------------------------------------------------------------------
3823
 */
3824
static int
3825
H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size)
3826
0
{
3827
0
    const H5AC_cache_config_t *config1 =
3828
0
        (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */
3829
0
    const H5AC_cache_config_t *config2 =
3830
0
        (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */
3831
0
    int ret_value = 0;                         /* Return value */
3832
3833
0
    FUNC_ENTER_PACKAGE_NOERR
3834
3835
    /* Check for a property being set */
3836
0
    if (config1 == NULL && config2 != NULL)
3837
0
        HGOTO_DONE(-1);
3838
0
    if (config1 != NULL && config2 == NULL)
3839
0
        HGOTO_DONE(1);
3840
3841
0
    if (config1->version < config2->version)
3842
0
        HGOTO_DONE(-1);
3843
0
    if (config1->version > config2->version)
3844
0
        HGOTO_DONE(1);
3845
3846
0
    if (config1->rpt_fcn_enabled < config2->rpt_fcn_enabled)
3847
0
        HGOTO_DONE(-1);
3848
0
    if (config1->rpt_fcn_enabled > config2->rpt_fcn_enabled)
3849
0
        HGOTO_DONE(1);
3850
3851
0
    if (config1->evictions_enabled < config2->evictions_enabled)
3852
0
        HGOTO_DONE(-1);
3853
0
    if (config1->evictions_enabled > config2->evictions_enabled)
3854
0
        HGOTO_DONE(1);
3855
3856
0
    if (config1->set_initial_size < config2->set_initial_size)
3857
0
        HGOTO_DONE(-1);
3858
0
    if (config1->set_initial_size > config2->set_initial_size)
3859
0
        HGOTO_DONE(1);
3860
3861
0
    if (config1->initial_size < config2->initial_size)
3862
0
        HGOTO_DONE(-1);
3863
0
    if (config1->initial_size > config2->initial_size)
3864
0
        HGOTO_DONE(1);
3865
3866
0
    if (config1->min_clean_fraction < config2->min_clean_fraction)
3867
0
        HGOTO_DONE(-1);
3868
0
    if (config1->min_clean_fraction > config2->min_clean_fraction)
3869
0
        HGOTO_DONE(1);
3870
3871
0
    if (config1->max_size < config2->max_size)
3872
0
        HGOTO_DONE(-1);
3873
0
    if (config1->max_size > config2->max_size)
3874
0
        HGOTO_DONE(1);
3875
3876
0
    if (config1->min_size < config2->min_size)
3877
0
        HGOTO_DONE(-1);
3878
0
    if (config1->min_size > config2->min_size)
3879
0
        HGOTO_DONE(1);
3880
3881
0
    if (config1->epoch_length < config2->epoch_length)
3882
0
        HGOTO_DONE(-1);
3883
0
    if (config1->epoch_length > config2->epoch_length)
3884
0
        HGOTO_DONE(1);
3885
3886
0
    if (config1->incr_mode < config2->incr_mode)
3887
0
        HGOTO_DONE(-1);
3888
0
    if (config1->incr_mode > config2->incr_mode)
3889
0
        HGOTO_DONE(1);
3890
3891
0
    if (config1->lower_hr_threshold < config2->lower_hr_threshold)
3892
0
        HGOTO_DONE(-1);
3893
0
    if (config1->lower_hr_threshold > config2->lower_hr_threshold)
3894
0
        HGOTO_DONE(1);
3895
3896
0
    if (config1->increment < config2->increment)
3897
0
        HGOTO_DONE(-1);
3898
0
    if (config1->increment > config2->increment)
3899
0
        HGOTO_DONE(1);
3900
3901
0
    if (config1->apply_max_increment < config2->apply_max_increment)
3902
0
        HGOTO_DONE(-1);
3903
0
    if (config1->apply_max_increment > config2->apply_max_increment)
3904
0
        HGOTO_DONE(1);
3905
3906
0
    if (config1->max_increment < config2->max_increment)
3907
0
        HGOTO_DONE(-1);
3908
0
    if (config1->max_increment > config2->max_increment)
3909
0
        HGOTO_DONE(1);
3910
3911
0
    if (config1->flash_incr_mode < config2->flash_incr_mode)
3912
0
        HGOTO_DONE(-1);
3913
0
    if (config1->flash_incr_mode > config2->flash_incr_mode)
3914
0
        HGOTO_DONE(1);
3915
3916
0
    if (config1->flash_multiple < config2->flash_multiple)
3917
0
        HGOTO_DONE(-1);
3918
0
    if (config1->flash_multiple > config2->flash_multiple)
3919
0
        HGOTO_DONE(1);
3920
3921
0
    if (config1->flash_threshold < config2->flash_threshold)
3922
0
        HGOTO_DONE(-1);
3923
0
    if (config1->flash_threshold > config2->flash_threshold)
3924
0
        HGOTO_DONE(1);
3925
3926
0
    if (config1->decr_mode < config2->decr_mode)
3927
0
        HGOTO_DONE(-1);
3928
0
    if (config1->decr_mode > config2->decr_mode)
3929
0
        HGOTO_DONE(1);
3930
3931
0
    if (config1->upper_hr_threshold < config2->upper_hr_threshold)
3932
0
        HGOTO_DONE(-1);
3933
0
    if (config1->upper_hr_threshold > config2->upper_hr_threshold)
3934
0
        HGOTO_DONE(1);
3935
3936
0
    if (config1->decrement < config2->decrement)
3937
0
        HGOTO_DONE(-1);
3938
0
    if (config1->decrement > config2->decrement)
3939
0
        HGOTO_DONE(1);
3940
3941
0
    if (config1->apply_max_decrement < config2->apply_max_decrement)
3942
0
        HGOTO_DONE(-1);
3943
0
    if (config1->apply_max_decrement > config2->apply_max_decrement)
3944
0
        HGOTO_DONE(1);
3945
3946
0
    if (config1->max_decrement < config2->max_decrement)
3947
0
        HGOTO_DONE(-1);
3948
0
    if (config1->max_decrement > config2->max_decrement)
3949
0
        HGOTO_DONE(1);
3950
3951
0
    if (config1->epochs_before_eviction < config2->epochs_before_eviction)
3952
0
        HGOTO_DONE(-1);
3953
0
    if (config1->epochs_before_eviction > config2->epochs_before_eviction)
3954
0
        HGOTO_DONE(1);
3955
3956
0
    if (config1->apply_empty_reserve < config2->apply_empty_reserve)
3957
0
        HGOTO_DONE(-1);
3958
0
    if (config1->apply_empty_reserve > config2->apply_empty_reserve)
3959
0
        HGOTO_DONE(1);
3960
3961
0
    if (config1->empty_reserve < config2->empty_reserve)
3962
0
        HGOTO_DONE(-1);
3963
0
    if (config1->empty_reserve > config2->empty_reserve)
3964
0
        HGOTO_DONE(1);
3965
3966
0
    if (config1->dirty_bytes_threshold < config2->dirty_bytes_threshold)
3967
0
        HGOTO_DONE(-1);
3968
0
    if (config1->dirty_bytes_threshold > config2->dirty_bytes_threshold)
3969
0
        HGOTO_DONE(1);
3970
3971
0
    if (config1->metadata_write_strategy < config2->metadata_write_strategy)
3972
0
        HGOTO_DONE(-1);
3973
0
    if (config1->metadata_write_strategy > config2->metadata_write_strategy)
3974
0
        HGOTO_DONE(1);
3975
3976
0
done:
3977
0
    FUNC_LEAVE_NOAPI(ret_value)
3978
0
} /* end H5P__facc_cache_config_cmp() */
3979
3980
/*-------------------------------------------------------------------------
3981
 * Function:       H5P__facc_cache_config_enc
3982
 *
3983
 * Purpose:        Callback routine which is called whenever the default
3984
 *                 cache config property in the file creation property list is
3985
 *                 encoded.
3986
 *
3987
 * Return:       Success:    Non-negative
3988
 *           Failure:    Negative
3989
 *
3990
 *-------------------------------------------------------------------------
3991
 */
3992
static herr_t
3993
H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size)
3994
0
{
3995
0
    const H5AC_cache_config_t *config =
3996
0
        (const H5AC_cache_config_t *)value; /* Create local aliases for values */
3997
0
    uint8_t **pp = (uint8_t **)_pp;
3998
0
    unsigned  enc_size;  /* Size of encoded property */
3999
0
    uint64_t  enc_value; /* Property to encode */
4000
4001
0
    FUNC_ENTER_PACKAGE_NOERR
4002
4003
    /* Sanity check */
4004
0
    assert(value);
4005
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4006
4007
0
    if (NULL != *pp) {
4008
        /* Encode type sizes (as a safety check) */
4009
0
        *(*pp)++ = (uint8_t)sizeof(unsigned);
4010
0
        *(*pp)++ = (uint8_t)sizeof(double);
4011
4012
        /* int */
4013
0
        INT32ENCODE(*pp, (int32_t)config->version);
4014
4015
0
        H5_ENCODE_UNSIGNED(*pp, config->rpt_fcn_enabled);
4016
4017
0
        H5_ENCODE_UNSIGNED(*pp, config->open_trace_file);
4018
4019
0
        H5_ENCODE_UNSIGNED(*pp, config->close_trace_file);
4020
4021
0
        H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name),
4022
0
                    (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1));
4023
0
        *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1;
4024
4025
0
        H5_ENCODE_UNSIGNED(*pp, config->evictions_enabled);
4026
4027
0
        H5_ENCODE_UNSIGNED(*pp, config->set_initial_size);
4028
4029
0
        enc_value = (uint64_t)config->initial_size;
4030
0
        enc_size  = H5VM_limit_enc_size(enc_value);
4031
0
        assert(enc_size < 256);
4032
0
        *(*pp)++ = (uint8_t)enc_size;
4033
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4034
4035
0
        H5_ENCODE_DOUBLE(*pp, config->min_clean_fraction);
4036
4037
0
        enc_value = (uint64_t)config->max_size;
4038
0
        enc_size  = H5VM_limit_enc_size(enc_value);
4039
0
        assert(enc_size < 256);
4040
0
        *(*pp)++ = (uint8_t)enc_size;
4041
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4042
4043
0
        enc_value = (uint64_t)config->min_size;
4044
0
        enc_size  = H5VM_limit_enc_size(enc_value);
4045
0
        assert(enc_size < 256);
4046
0
        *(*pp)++ = (uint8_t)enc_size;
4047
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4048
4049
        /* long int */
4050
0
        INT64ENCODE(*pp, (int64_t)config->epoch_length);
4051
4052
        /* enum */
4053
0
        *(*pp)++ = (uint8_t)config->incr_mode;
4054
4055
0
        H5_ENCODE_DOUBLE(*pp, config->lower_hr_threshold);
4056
4057
0
        H5_ENCODE_DOUBLE(*pp, config->increment);
4058
4059
0
        H5_ENCODE_UNSIGNED(*pp, config->apply_max_increment);
4060
4061
0
        enc_value = (uint64_t)config->max_increment;
4062
0
        enc_size  = H5VM_limit_enc_size(enc_value);
4063
0
        assert(enc_size < 256);
4064
0
        *(*pp)++ = (uint8_t)enc_size;
4065
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4066
4067
        /* enum */
4068
0
        *(*pp)++ = (uint8_t)config->flash_incr_mode;
4069
4070
0
        H5_ENCODE_DOUBLE(*pp, config->flash_multiple);
4071
4072
0
        H5_ENCODE_DOUBLE(*pp, config->flash_threshold);
4073
4074
        /* enum */
4075
0
        *(*pp)++ = (uint8_t)config->decr_mode;
4076
4077
0
        H5_ENCODE_DOUBLE(*pp, config->upper_hr_threshold);
4078
4079
0
        H5_ENCODE_DOUBLE(*pp, config->decrement);
4080
4081
0
        H5_ENCODE_UNSIGNED(*pp, config->apply_max_decrement);
4082
4083
0
        enc_value = (uint64_t)config->max_decrement;
4084
0
        enc_size  = H5VM_limit_enc_size(enc_value);
4085
0
        assert(enc_size < 256);
4086
0
        *(*pp)++ = (uint8_t)enc_size;
4087
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4088
4089
        /* int */
4090
0
        INT32ENCODE(*pp, (int32_t)config->epochs_before_eviction);
4091
4092
0
        H5_ENCODE_UNSIGNED(*pp, config->apply_empty_reserve);
4093
4094
0
        H5_ENCODE_DOUBLE(*pp, config->empty_reserve);
4095
4096
        /* unsigned */
4097
0
        UINT32ENCODE(*pp, (uint32_t)config->dirty_bytes_threshold);
4098
4099
        /* int */
4100
0
        INT32ENCODE(*pp, (int32_t)config->metadata_write_strategy);
4101
0
    } /* end if */
4102
4103
    /* Compute encoded size of variably-encoded values */
4104
0
    enc_value = (uint64_t)config->initial_size;
4105
0
    *size += 1 + H5VM_limit_enc_size(enc_value);
4106
0
    enc_value = (uint64_t)config->max_size;
4107
0
    *size += 1 + H5VM_limit_enc_size(enc_value);
4108
0
    enc_value = (uint64_t)config->min_size;
4109
0
    *size += 1 + H5VM_limit_enc_size(enc_value);
4110
0
    enc_value = (uint64_t)config->max_increment;
4111
0
    *size += 1 + H5VM_limit_enc_size(enc_value);
4112
0
    enc_value = (uint64_t)config->max_decrement;
4113
0
    *size += 1 + H5VM_limit_enc_size(enc_value);
4114
4115
    /* Compute encoded size of fixed-size values */
4116
0
    *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + (sizeof(int32_t) * 4) + sizeof(int64_t) +
4117
0
              H5AC__MAX_TRACE_FILE_NAME_LEN + 1);
4118
4119
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4120
0
} /* end H5P__facc_cache_config_enc() */
4121
4122
/*-------------------------------------------------------------------------
4123
 * Function:       H5P__facc_cache_config_dec
4124
 *
4125
 * Purpose:        Callback routine which is called whenever the default
4126
 *                 cache config property in the file creation property list is
4127
 *                 decoded.
4128
 *
4129
 * Return:       Success:    Non-negative
4130
 *           Failure:    Negative
4131
 *
4132
 *-------------------------------------------------------------------------
4133
 */
4134
static herr_t
4135
H5P__facc_cache_config_dec(const void **_pp, void *_value)
4136
0
{
4137
0
    H5AC_cache_config_t *config = (H5AC_cache_config_t *)_value;
4138
0
    const uint8_t      **pp     = (const uint8_t **)_pp;
4139
0
    unsigned             enc_size;
4140
0
    uint64_t             enc_value;
4141
0
    herr_t               ret_value = SUCCEED; /* Return value */
4142
4143
0
    FUNC_ENTER_PACKAGE
4144
4145
    /* Sanity checks */
4146
0
    assert(pp);
4147
0
    assert(*pp);
4148
0
    assert(config);
4149
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4150
4151
    /* Set property to default value */
4152
0
    H5MM_memcpy(config, &H5F_def_mdc_initCacheCfg_g, sizeof(H5AC_cache_config_t));
4153
4154
    /* Decode type sizes */
4155
0
    enc_size = *(*pp)++;
4156
0
    if (enc_size != sizeof(unsigned))
4157
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded");
4158
0
    enc_size = *(*pp)++;
4159
0
    if (enc_size != sizeof(double))
4160
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded");
4161
4162
    /* int */
4163
0
    INT32DECODE(*pp, config->version);
4164
4165
0
    H5_DECODE_UNSIGNED(*pp, config->rpt_fcn_enabled);
4166
4167
0
    H5_DECODE_UNSIGNED(*pp, config->open_trace_file);
4168
4169
0
    H5_DECODE_UNSIGNED(*pp, config->close_trace_file);
4170
4171
0
    strcpy(config->trace_file_name, (const char *)(*pp));
4172
0
    *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1;
4173
4174
0
    H5_DECODE_UNSIGNED(*pp, config->evictions_enabled);
4175
4176
0
    H5_DECODE_UNSIGNED(*pp, config->set_initial_size);
4177
4178
0
    enc_size = *(*pp)++;
4179
0
    assert(enc_size < 256);
4180
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4181
0
    config->initial_size = (size_t)enc_value;
4182
4183
0
    H5_DECODE_DOUBLE(*pp, config->min_clean_fraction);
4184
4185
0
    enc_size = *(*pp)++;
4186
0
    assert(enc_size < 256);
4187
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4188
0
    config->max_size = (size_t)enc_value;
4189
4190
0
    enc_size = *(*pp)++;
4191
0
    assert(enc_size < 256);
4192
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4193
0
    config->min_size = (size_t)enc_value;
4194
4195
    /* long int */
4196
0
    {
4197
0
        int64_t temp;
4198
0
        INT64DECODE(*pp, temp);
4199
0
        config->epoch_length = (long int)temp;
4200
0
    }
4201
    /* enum */
4202
0
    config->incr_mode = (enum H5C_cache_incr_mode) * (*pp)++;
4203
4204
0
    H5_DECODE_DOUBLE(*pp, config->lower_hr_threshold);
4205
4206
0
    H5_DECODE_DOUBLE(*pp, config->increment);
4207
4208
0
    H5_DECODE_UNSIGNED(*pp, config->apply_max_increment);
4209
4210
0
    enc_size = *(*pp)++;
4211
0
    assert(enc_size < 256);
4212
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4213
0
    config->max_increment = (size_t)enc_value;
4214
4215
    /* enum */
4216
0
    config->flash_incr_mode = (enum H5C_cache_flash_incr_mode) * (*pp)++;
4217
4218
0
    H5_DECODE_DOUBLE(*pp, config->flash_multiple);
4219
4220
0
    H5_DECODE_DOUBLE(*pp, config->flash_threshold);
4221
4222
    /* enum */
4223
0
    config->decr_mode = (enum H5C_cache_decr_mode) * (*pp)++;
4224
4225
0
    H5_DECODE_DOUBLE(*pp, config->upper_hr_threshold);
4226
4227
0
    H5_DECODE_DOUBLE(*pp, config->decrement);
4228
4229
0
    H5_DECODE_UNSIGNED(*pp, config->apply_max_decrement);
4230
4231
0
    enc_size = *(*pp)++;
4232
0
    assert(enc_size < 256);
4233
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4234
0
    config->max_decrement = (size_t)enc_value;
4235
4236
    /* int */
4237
0
    INT32DECODE(*pp, config->epochs_before_eviction);
4238
4239
0
    H5_DECODE_UNSIGNED(*pp, config->apply_empty_reserve);
4240
4241
0
    H5_DECODE_DOUBLE(*pp, config->empty_reserve);
4242
4243
    /* unsigned */
4244
0
    UINT32DECODE(*pp, config->dirty_bytes_threshold);
4245
4246
    /* int */
4247
0
    INT32DECODE(*pp, config->metadata_write_strategy);
4248
4249
0
done:
4250
0
    FUNC_LEAVE_NOAPI(ret_value)
4251
0
} /* end H5P__facc_cache_config_dec() */
4252
4253
/*-------------------------------------------------------------------------
4254
 * Function:       H5P__facc_fclose_degree_enc
4255
 *
4256
 * Purpose:        Callback routine which is called whenever the file close
4257
 *                 degree property in the file access property list
4258
 *                 is encoded.
4259
 *
4260
 * Return:       Success:    Non-negative
4261
 *           Failure:    Negative
4262
 *
4263
 *-------------------------------------------------------------------------
4264
 */
4265
static herr_t
4266
H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size)
4267
0
{
4268
0
    const H5F_close_degree_t *fclose_degree =
4269
0
        (const H5F_close_degree_t *)value; /* Create local alias for values */
4270
0
    uint8_t **pp = (uint8_t **)_pp;
4271
4272
0
    FUNC_ENTER_PACKAGE_NOERR
4273
4274
    /* Sanity check */
4275
0
    assert(fclose_degree);
4276
0
    assert(size);
4277
4278
0
    if (NULL != *pp)
4279
        /* Encode file close degree */
4280
0
        *(*pp)++ = (uint8_t)*fclose_degree;
4281
4282
    /* Size of file close degree */
4283
0
    (*size)++;
4284
4285
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4286
0
} /* end H5P__facc_fclose_degree_enc() */
4287
4288
/*-------------------------------------------------------------------------
4289
 * Function:       H5P__facc_fclose_degree_dec
4290
 *
4291
 * Purpose:        Callback routine which is called whenever the file close
4292
 *                 degree property in the file access property list
4293
 *                 is decoded.
4294
 *
4295
 * Return:       Success:    Non-negative
4296
 *           Failure:    Negative
4297
 *
4298
 *-------------------------------------------------------------------------
4299
 */
4300
static herr_t
4301
H5P__facc_fclose_degree_dec(const void **_pp, void *_value)
4302
0
{
4303
0
    H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */
4304
0
    const uint8_t     **pp            = (const uint8_t **)_pp;
4305
4306
0
    FUNC_ENTER_PACKAGE_NOERR
4307
4308
    /* Sanity checks */
4309
0
    assert(pp);
4310
0
    assert(*pp);
4311
0
    assert(fclose_degree);
4312
4313
    /* Decode file close degree */
4314
0
    *fclose_degree = (H5F_close_degree_t) * (*pp)++;
4315
4316
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4317
0
} /* end H5P__facc_fclose_degree_dec() */
4318
4319
/*-------------------------------------------------------------------------
4320
 * Function:       H5P__facc_multi_type_enc
4321
 *
4322
 * Purpose:        Callback routine which is called whenever the multi VFD
4323
 *                 memory type property in the file access property list
4324
 *                 is encoded.
4325
 *
4326
 * Return:       Success:    Non-negative
4327
 *           Failure:    Negative
4328
 *
4329
 *-------------------------------------------------------------------------
4330
 */
4331
static herr_t
4332
H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size)
4333
0
{
4334
0
    const H5FD_mem_t *type = (const H5FD_mem_t *)value; /* Create local alias for values */
4335
0
    uint8_t         **pp   = (uint8_t **)_pp;
4336
4337
0
    FUNC_ENTER_PACKAGE_NOERR
4338
4339
    /* Sanity check */
4340
0
    assert(type);
4341
0
    assert(size);
4342
4343
0
    if (NULL != *pp)
4344
        /* Encode file close degree */
4345
0
        *(*pp)++ = (uint8_t)*type;
4346
4347
    /* Size of multi VFD memory type */
4348
0
    (*size)++;
4349
4350
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4351
0
} /* end H5P__facc_multi_type_enc() */
4352
4353
/*-------------------------------------------------------------------------
4354
 * Function:       H5P__facc_multi_type_dec
4355
 *
4356
 * Purpose:        Callback routine which is called whenever the multi VFD
4357
 *                 memory type property in the file access property list
4358
 *                 is decoded.
4359
 *
4360
 * Return:       Success:    Non-negative
4361
 *           Failure:    Negative
4362
 *
4363
 *-------------------------------------------------------------------------
4364
 */
4365
static herr_t
4366
H5P__facc_multi_type_dec(const void **_pp, void *_value)
4367
0
{
4368
0
    H5FD_mem_t     *type = (H5FD_mem_t *)_value; /* File close degree */
4369
0
    const uint8_t **pp   = (const uint8_t **)_pp;
4370
4371
0
    FUNC_ENTER_PACKAGE_NOERR
4372
4373
    /* Sanity checks */
4374
0
    assert(pp);
4375
0
    assert(*pp);
4376
0
    assert(type);
4377
4378
    /* Decode multi VFD memory type */
4379
0
    *type = (H5FD_mem_t) * (*pp)++;
4380
4381
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4382
0
} /* end H5P__facc_multi_type_dec() */
4383
4384
/*-------------------------------------------------------------------------
4385
 * Function:       H5P__facc_libver_type_enc
4386
 *
4387
 * Purpose:        Callback routine which is called whenever the 'low' or
4388
 *                 'high' bound of library format versions property in the
4389
 *                 file access property list is encoded.
4390
 *
4391
 * Return:       Success:    Non-negative
4392
 *           Failure:    Negative
4393
 *
4394
 *-------------------------------------------------------------------------
4395
 */
4396
static herr_t
4397
H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size)
4398
0
{
4399
0
    const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */
4400
0
    uint8_t           **pp   = (uint8_t **)_pp;
4401
4402
0
    FUNC_ENTER_PACKAGE_NOERR
4403
4404
    /* Sanity check */
4405
0
    assert(type);
4406
0
    assert(size);
4407
4408
    /* Encode */
4409
0
    if (NULL != *pp)
4410
0
        *(*pp)++ = (uint8_t)*type;
4411
4412
    /* Size */
4413
0
    (*size)++;
4414
4415
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4416
0
} /* end H5P__facc_libver_type_enc() */
4417
4418
/*-------------------------------------------------------------------------
4419
 * Function:       H5P__facc_libver_type_dec
4420
 *
4421
 * Purpose:        Callback routine which is called whenever the 'low' or
4422
 *                 'high' bound of library format versions property in the
4423
 *                 file access property list is decoded.
4424
 *
4425
 * Return:       Success:    Non-negative
4426
 *           Failure:    Negative
4427
 *
4428
 *-------------------------------------------------------------------------
4429
 */
4430
static herr_t
4431
H5P__facc_libver_type_dec(const void **_pp, void *_value)
4432
0
{
4433
0
    H5F_libver_t   *type = (H5F_libver_t *)_value;
4434
0
    const uint8_t **pp   = (const uint8_t **)_pp;
4435
4436
0
    FUNC_ENTER_PACKAGE_NOERR
4437
4438
    /* Sanity checks */
4439
0
    assert(pp);
4440
0
    assert(*pp);
4441
0
    assert(type);
4442
4443
    /* Decode */
4444
0
    *type = (H5F_libver_t) * (*pp)++;
4445
4446
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4447
0
} /* end H5P__facc_libver_type_dec() */
4448
4449
/*-------------------------------------------------------------------------
4450
 * Function:    H5Pset_metadata_read_attempts
4451
 *
4452
 * Purpose:    Sets the # of read attempts in the file access property list
4453
 *        when reading metadata with checksum.
4454
 *        The # of read attempts set via this routine will only apply
4455
 *        when opening a file with SWMR access.
4456
 *        The # of read attempts set via this routine does not have
4457
 *        any effect when opening a file with non-SWMR access; for this
4458
 *        case, the # of read attempts will be always be 1.
4459
 *
4460
 * Return:    Non-negative on success/Negative on failure
4461
 *
4462
 *-------------------------------------------------------------------------
4463
 */
4464
herr_t
4465
H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts)
4466
0
{
4467
0
    H5P_genplist_t *plist;               /* Property list pointer */
4468
0
    herr_t          ret_value = SUCCEED; /* return value */
4469
4470
0
    FUNC_ENTER_API(FAIL)
4471
4472
    /* Cannot set the # of attempts to 0 */
4473
0
    if (attempts == 0)
4474
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
4475
0
                    "number of metadatata read attempts must be greater than 0");
4476
4477
    /* Get the plist structure */
4478
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
4479
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4480
4481
    /* Set values */
4482
0
    if (H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0)
4483
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of metadata read attempts");
4484
4485
0
done:
4486
0
    FUNC_LEAVE_API(ret_value)
4487
0
} /* H5Pset_metadata_read_attempts() */
4488
4489
/*-------------------------------------------------------------------------
4490
 * Function:    H5Pget_metadata_read_attempts
4491
 *
4492
 * Purpose:    Returns the # of metadata read attempts set in the file access property list.
4493
 *
4494
 * Return:    Non-negative on success/Negative on failure
4495
 *
4496
 *-------------------------------------------------------------------------
4497
 */
4498
herr_t
4499
H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts /*out*/)
4500
0
{
4501
0
    herr_t ret_value = SUCCEED; /* Return value */
4502
4503
0
    FUNC_ENTER_API(FAIL)
4504
4505
    /* Get values */
4506
0
    if (attempts) {
4507
0
        H5P_genplist_t *plist; /* Property list pointer */
4508
4509
        /* Get the plist structure */
4510
0
        if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
4511
0
            HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4512
4513
        /* Get the # of read attempts set */
4514
0
        if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0)
4515
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get the number of metadata read attempts");
4516
4517
        /* If not set, return the default value */
4518
0
        if (*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */
4519
0
            *attempts = H5F_METADATA_READ_ATTEMPTS;
4520
0
    } /* end if */
4521
4522
0
done:
4523
0
    FUNC_LEAVE_API(ret_value)
4524
0
} /* end H5Pget_metadata_read_attempts() */
4525
4526
/*-------------------------------------------------------------------------
4527
 * Function:    H5Pset_obj_flush_cb
4528
 *
4529
 * Purpose:    Sets the callback function to invoke and the user data when an
4530
 *        object flush occurs in the file.
4531
 *
4532
 * Return:    Non-negative on success/Negative on failure
4533
 *
4534
 *-------------------------------------------------------------------------
4535
 */
4536
herr_t
4537
H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata)
4538
0
{
4539
0
    H5P_genplist_t    *plist; /* Property list pointer */
4540
0
    H5F_object_flush_t flush_info;
4541
0
    herr_t             ret_value = SUCCEED; /* return value */
4542
4543
0
    FUNC_ENTER_API(FAIL)
4544
4545
    /* Check if the callback function is NULL and the user data is non-NULL.
4546
     * This is almost certainly an error as the user data will not be used. */
4547
0
    if (!func && udata)
4548
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not");
4549
4550
    /* Get the plist structure */
4551
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
4552
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4553
4554
    /* Update property list */
4555
0
    flush_info.func  = func;
4556
0
    flush_info.udata = udata;
4557
4558
    /* Set values */
4559
0
    if (H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0)
4560
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback");
4561
4562
0
done:
4563
0
    FUNC_LEAVE_API(ret_value)
4564
0
} /* H5Pset_obj_flush_cb() */
4565
4566
/*-------------------------------------------------------------------------
4567
 * Function:    H5Pget_obj_flush_cb
4568
 *
4569
 * Purpose:    Retrieves the callback function and user data set in the
4570
 *        property list for an object flush.
4571
 *
4572
 * Return:    Non-negative on success/Negative on failure
4573
 *
4574
 *-------------------------------------------------------------------------
4575
 */
4576
herr_t
4577
H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func /*out*/, void **udata /*out*/)
4578
0
{
4579
0
    H5P_genplist_t    *plist; /* Property list pointer */
4580
0
    H5F_object_flush_t flush_info;
4581
0
    herr_t             ret_value = SUCCEED; /* return value */
4582
4583
0
    FUNC_ENTER_API(FAIL)
4584
4585
    /* Get the plist structure */
4586
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
4587
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4588
4589
    /* Retrieve the callback function and user data */
4590
0
    if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0)
4591
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback");
4592
4593
    /* Assign return value */
4594
0
    if (func)
4595
0
        *func = flush_info.func;
4596
0
    if (udata)
4597
0
        *udata = flush_info.udata;
4598
4599
0
done:
4600
0
    FUNC_LEAVE_API(ret_value)
4601
0
} /* H5Pget_obj_flush_cb() */
4602
4603
/*-------------------------------------------------------------------------
4604
 * Function:    H5Pset_mdc_log_options
4605
 *
4606
 * Purpose:    Set metadata cache log options.
4607
 *
4608
 * Return:    Non-negative on success/Negative on failure
4609
 *
4610
 *-------------------------------------------------------------------------
4611
 */
4612
herr_t
4613
H5Pset_mdc_log_options(hid_t plist_id, bool is_enabled, const char *location, bool start_on_access)
4614
0
{
4615
0
    H5P_genplist_t *plist;               /* Property list pointer */
4616
0
    char           *new_location;        /* Working location pointer */
4617
0
    herr_t          ret_value = SUCCEED; /* Return value */
4618
4619
0
    FUNC_ENTER_API(FAIL)
4620
4621
    /* Check arguments */
4622
0
    if (H5P_DEFAULT == plist_id)
4623
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
4624
0
    if (!location)
4625
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "location cannot be NULL");
4626
4627
    /* Get the property list structure */
4628
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
4629
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list");
4630
4631
    /* Make a copy of the passed-in location */
4632
0
    if (NULL == (new_location = H5MM_xstrdup(location)))
4633
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location");
4634
4635
    /* Set values */
4636
0
    if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0)
4637
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag");
4638
0
    if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0)
4639
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location");
4640
0
    if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0)
4641
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag");
4642
4643
0
done:
4644
0
    FUNC_LEAVE_API(ret_value)
4645
0
} /* end H5Pset_mdc_log_options() */
4646
4647
/*-------------------------------------------------------------------------
4648
 * Function:    H5Pget_mdc_log_options
4649
 *
4650
 * Purpose:    Get metadata cache log options.
4651
 *
4652
 * Return:    Non-negative on success/Negative on failure
4653
 *
4654
 *-------------------------------------------------------------------------
4655
 */
4656
herr_t
4657
H5Pget_mdc_log_options(hid_t plist_id, bool *is_enabled /*out*/, char *location /*out*/,
4658
                       size_t *location_size /*out*/, bool *start_on_access /*out*/)
4659
0
{
4660
0
    H5P_genplist_t *plist;                  /* Property list pointer */
4661
0
    char           *location_ptr = NULL;    /* Pointer to location string */
4662
0
    herr_t          ret_value    = SUCCEED; /* Return value */
4663
4664
0
    FUNC_ENTER_API(FAIL)
4665
4666
    /* Get the property list structure */
4667
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
4668
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list");
4669
4670
    /* Get simple values */
4671
0
    if (is_enabled)
4672
0
        if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0)
4673
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location");
4674
0
    if (start_on_access)
4675
0
        if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0)
4676
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get start_on_access flag");
4677
4678
    /* Get the location */
4679
0
    if (location || location_size)
4680
0
        if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0)
4681
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location");
4682
4683
    /* Copy log location to output buffer */
4684
0
    if (location_ptr && location)
4685
0
        H5MM_memcpy(location, location_ptr, *location_size);
4686
4687
    /* Get location size, including terminating NULL */
4688
0
    if (location_size) {
4689
0
        if (location_ptr)
4690
0
            *location_size = strlen(location_ptr) + 1;
4691
0
        else
4692
0
            *location_size = 0;
4693
0
    } /* end if */
4694
4695
0
done:
4696
0
    FUNC_LEAVE_API(ret_value)
4697
0
} /* end H5Pget_mdc_log_options() */
4698
4699
/*-------------------------------------------------------------------------
4700
 * Function:       H5P__facc_mdc_log_location_enc
4701
 *
4702
 * Purpose:        Callback routine which is called whenever the metadata
4703
 *                 cache log location property in the file access property
4704
 *                 list is encoded.
4705
 *
4706
 * Return:         Success:     Non-negative
4707
 *                 Failure:     Negative
4708
 *
4709
 *-------------------------------------------------------------------------
4710
 */
4711
static herr_t
4712
H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size)
4713
0
{
4714
0
    const char *log_location = *(const char *const *)value;
4715
0
    uint8_t   **pp           = (uint8_t **)_pp;
4716
0
    size_t      len          = 0;
4717
0
    uint64_t    enc_value;
4718
0
    unsigned    enc_size;
4719
4720
0
    FUNC_ENTER_PACKAGE_NOERR
4721
4722
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4723
4724
    /* calculate prefix length */
4725
0
    if (NULL != log_location)
4726
0
        len = strlen(log_location);
4727
4728
0
    enc_value = (uint64_t)len;
4729
0
    enc_size  = H5VM_limit_enc_size(enc_value);
4730
0
    assert(enc_size < 256);
4731
4732
0
    if (NULL != *pp) {
4733
        /* encode the length of the prefix */
4734
0
        *(*pp)++ = (uint8_t)enc_size;
4735
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4736
4737
        /* encode the prefix */
4738
0
        if (NULL != log_location) {
4739
0
            H5MM_memcpy(*(char **)pp, log_location, len);
4740
0
            *pp += len;
4741
0
        } /* end if */
4742
0
    }     /* end if */
4743
4744
0
    *size += (1 + enc_size);
4745
0
    if (NULL != log_location)
4746
0
        *size += len;
4747
4748
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4749
0
} /* end H5P__facc_mdc_log_location_enc() */
4750
4751
/*-------------------------------------------------------------------------
4752
 * Function:       H5P__facc_mdc_log_location_dec
4753
 *
4754
 * Purpose:        Callback routine which is called whenever the metadata
4755
 *                 cache log location property in the file access property
4756
 *                 list is decoded.
4757
 *
4758
 * Return:         Success:     Non-negative
4759
 *                 Failure:     Negative
4760
 *
4761
 *-------------------------------------------------------------------------
4762
 */
4763
static herr_t
4764
H5P__facc_mdc_log_location_dec(const void **_pp, void *_value)
4765
0
{
4766
0
    char          **log_location = (char **)_value;
4767
0
    const uint8_t **pp           = (const uint8_t **)_pp;
4768
0
    size_t          len;
4769
0
    uint64_t        enc_value; /* Decoded property value */
4770
0
    unsigned        enc_size;  /* Size of encoded property */
4771
0
    herr_t          ret_value = SUCCEED;
4772
4773
0
    FUNC_ENTER_PACKAGE
4774
4775
0
    assert(pp);
4776
0
    assert(*pp);
4777
0
    assert(log_location);
4778
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4779
4780
    /* Decode the size */
4781
0
    enc_size = *(*pp)++;
4782
0
    assert(enc_size < 256);
4783
4784
    /* Decode the value */
4785
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
4786
0
    len = enc_value;
4787
4788
0
    if (0 != len) {
4789
        /* Make a copy of the user's prefix string */
4790
0
        if (NULL == (*log_location = (char *)H5MM_malloc(len + 1)))
4791
0
            HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix");
4792
0
        strncpy(*log_location, *(const char **)pp, len);
4793
0
        (*log_location)[len] = '\0';
4794
4795
0
        *pp += len;
4796
0
    } /* end if */
4797
0
    else
4798
0
        *log_location = NULL;
4799
4800
0
done:
4801
0
    FUNC_LEAVE_NOAPI(ret_value)
4802
0
} /* end H5P__facc_mdc_log_location_dec() */
4803
4804
/*-------------------------------------------------------------------------
4805
 * Function:    H5P__facc_mdc_log_location_del
4806
 *
4807
 * Purpose:     Frees memory used to store the metadata cache log location.
4808
 *
4809
 * Return:      Non-negative on success/Negative on failure
4810
 *
4811
 *-------------------------------------------------------------------------
4812
 */
4813
static herr_t
4814
H5P__facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
4815
                               size_t H5_ATTR_UNUSED size, void *value)
4816
0
{
4817
0
    FUNC_ENTER_PACKAGE_NOERR
4818
4819
0
    assert(value);
4820
4821
0
    H5MM_xfree(*(void **)value);
4822
4823
0
    FUNC_LEAVE_NOAPI(SUCCEED)
4824
0
} /* end H5P__facc_mdc_log_location_del() */
4825
4826
/*-------------------------------------------------------------------------
4827
 * Function:    H5P__facc_mdc_log_location_copy
4828
 *
4829
 * Purpose:     Creates a copy of the metadata cache log location string.
4830
 *
4831
 * Return:      Non-negative on success/Negative on failure
4832
 *
4833
 *-------------------------------------------------------------------------
4834
 */
4835
static herr_t
4836
H5P__facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
4837
18
{
4838
18
    FUNC_ENTER_PACKAGE_NOERR
4839
4840
18
    assert(value);
4841
4842
18
    *(char **)value = H5MM_xstrdup(*(const char **)value);
4843
4844
18
    FUNC_LEAVE_NOAPI(SUCCEED)
4845
18
} /* end H5P__facc_mdc_log_location_copy() */
4846
4847
/*-------------------------------------------------------------------------
4848
 * Function:       H5P__facc_mdc_log_location_cmp
4849
 *
4850
 * Purpose:        Callback routine which is called whenever the metadata
4851
 *                 cache log location property in the file creation property
4852
 *                 list is compared.
4853
 *
4854
 * Return:         zero if VALUE1 and VALUE2 are equal, non zero otherwise.
4855
 *
4856
 *-------------------------------------------------------------------------
4857
 */
4858
static H5_ATTR_PURE int
4859
H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size)
4860
0
{
4861
0
    const char *pref1     = *(const char *const *)value1;
4862
0
    const char *pref2     = *(const char *const *)value2;
4863
0
    int         ret_value = 0;
4864
4865
0
    FUNC_ENTER_PACKAGE_NOERR
4866
4867
0
    if (NULL == pref1 && NULL != pref2)
4868
0
        HGOTO_DONE(1);
4869
0
    if (NULL != pref1 && NULL == pref2)
4870
0
        HGOTO_DONE(-1);
4871
0
    if (NULL != pref1 && NULL != pref2)
4872
0
        ret_value = strcmp(pref1, pref2);
4873
4874
0
done:
4875
0
    FUNC_LEAVE_NOAPI(ret_value)
4876
0
} /* end H5P__facc_mdc_log_location_cmp() */
4877
4878
/*-------------------------------------------------------------------------
4879
 * Function:    H5P__facc_mdc_log_location_close
4880
 *
4881
 * Purpose:     Frees memory used to store the metadata cache log location
4882
 *              string
4883
 *
4884
 * Return:      Non-negative on success/Negative on failure
4885
 *
4886
 *-------------------------------------------------------------------------
4887
 */
4888
static herr_t
4889
H5P__facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
4890
30
{
4891
30
    FUNC_ENTER_PACKAGE_NOERR
4892
4893
30
    assert(value);
4894
4895
30
    H5MM_xfree(*(void **)value);
4896
4897
30
    FUNC_LEAVE_NOAPI(SUCCEED)
4898
30
} /* end H5P__facc_mdc_log_location_close() */
4899
4900
/*-------------------------------------------------------------------------
4901
 * Function:    H5Pset_evict_on_close
4902
 *
4903
 * Purpose:     Sets the evict_on_close property value.
4904
 *
4905
 *              When this property is set, closing an HDF5 object will
4906
 *              cause the object's metadata cache entries to be flushed
4907
 *              and evicted from the cache.
4908
 *
4909
 *              Currently only implemented for datasets.
4910
 *
4911
 * Return:      SUCCEED/FAIL
4912
 *
4913
 *-------------------------------------------------------------------------
4914
 */
4915
herr_t
4916
H5Pset_evict_on_close(hid_t fapl_id, bool evict_on_close)
4917
0
{
4918
0
    H5P_genplist_t *plist;               /* property list pointer */
4919
0
    herr_t          ret_value = SUCCEED; /* return value */
4920
4921
0
    FUNC_ENTER_API(FAIL)
4922
4923
    /* Compare the property list's class against the other class */
4924
0
    if (true != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4925
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist");
4926
4927
    /* Get the plist structure */
4928
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4929
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4930
4931
    /* Set value */
4932
0
    if (H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0)
4933
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set evict on close property");
4934
4935
0
done:
4936
0
    FUNC_LEAVE_API(ret_value)
4937
0
} /* end H5Pset_evict_on_close() */
4938
4939
/*-------------------------------------------------------------------------
4940
 * Function:    H5Pget_evict_on_close
4941
 *
4942
 * Purpose:     Gets the evict_on_close property value.
4943
 *
4944
 *              When this property is set, closing an HDF5 object will
4945
 *              cause the object's metadata cache entries to be flushed
4946
 *              and evicted from the cache.
4947
 *
4948
 *              Currently only implemented for datasets.
4949
 *
4950
 * Return:      SUCCEED/FAIL
4951
 *
4952
 *-------------------------------------------------------------------------
4953
 */
4954
herr_t
4955
H5Pget_evict_on_close(hid_t fapl_id, bool *evict_on_close /*out*/)
4956
0
{
4957
0
    H5P_genplist_t *plist;               /* property list pointer */
4958
0
    herr_t          ret_value = SUCCEED; /* return value */
4959
4960
0
    FUNC_ENTER_API(FAIL)
4961
4962
    /* Compare the property list's class against the other class */
4963
0
    if (true != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4964
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist");
4965
4966
    /* Get the plist structure */
4967
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4968
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
4969
4970
0
    if (H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0)
4971
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get evict on close property");
4972
4973
0
done:
4974
0
    FUNC_LEAVE_API(ret_value)
4975
0
} /* end H5Pget_evict_on_close() */
4976
4977
/*-------------------------------------------------------------------------
4978
 * Function:    H5Pset_file_locking
4979
 *
4980
 * Purpose:     Sets the file locking property values.
4981
 *
4982
 *              Overrides the default file locking flag setting that was
4983
 *              set when the library was configured.
4984
 *
4985
 *              Can be overridden by the HDF5_USE_FILE_LOCKING environment
4986
 *              variable.
4987
 *
4988
 *              File locking is used when creating/opening a file to prevent
4989
 *              problematic file accesses.
4990
 *
4991
 * Return:      SUCCEED/FAIL
4992
 *
4993
 *-------------------------------------------------------------------------
4994
 */
4995
herr_t
4996
H5Pset_file_locking(hid_t fapl_id, bool use_file_locking, bool ignore_when_disabled)
4997
0
{
4998
0
    H5P_genplist_t *plist;               /* property list pointer */
4999
0
    herr_t          ret_value = SUCCEED; /* return value */
5000
5001
0
    FUNC_ENTER_API(FAIL)
5002
5003
    /* Make sure this is a fapl */
5004
0
    if (true != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
5005
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist");
5006
5007
    /* Get the plist structure */
5008
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
5009
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5010
5011
    /* Set values */
5012
0
    if (H5P_set(plist, H5F_ACS_USE_FILE_LOCKING_NAME, &use_file_locking) < 0)
5013
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set use file locking property");
5014
0
    if (H5P_set(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &ignore_when_disabled) < 0)
5015
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set ignore disabled file locks property");
5016
5017
0
done:
5018
0
    FUNC_LEAVE_API(ret_value)
5019
0
} /* end H5Pset_file_locking() */
5020
5021
/*-------------------------------------------------------------------------
5022
 * Function:    H5Pget_file_locking
5023
 *
5024
 * Purpose:     Gets the file locking property values.
5025
 *
5026
 *              File locking is used when creating/opening a file to prevent
5027
 *              problematic file accesses.
5028
 *
5029
 * Return:      SUCCEED/FAIL
5030
 *
5031
 *-------------------------------------------------------------------------
5032
 */
5033
herr_t
5034
H5Pget_file_locking(hid_t fapl_id, bool *use_file_locking /*out*/, bool *ignore_when_disabled /*out*/)
5035
0
{
5036
0
    H5P_genplist_t *plist;               /* property list pointer */
5037
0
    herr_t          ret_value = SUCCEED; /* return value */
5038
5039
0
    FUNC_ENTER_API(FAIL)
5040
5041
    /* Make sure this is a fapl */
5042
0
    if (H5P_DEFAULT == fapl_id)
5043
0
        fapl_id = H5P_FILE_ACCESS_DEFAULT;
5044
0
    else if (true != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
5045
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist");
5046
5047
    /* Get the plist structure */
5048
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
5049
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5050
5051
    /* Get values */
5052
0
    if (H5P_get(plist, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0)
5053
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get use file locking property");
5054
0
    if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, ignore_when_disabled) < 0)
5055
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get ignore disabled file locks property");
5056
5057
0
done:
5058
0
    FUNC_LEAVE_API(ret_value)
5059
0
} /* end H5Pget_file_locking() */
5060
5061
#ifdef H5_HAVE_PARALLEL
5062
5063
/*-------------------------------------------------------------------------
5064
 * Function:       H5P__encode_coll_md_read_flag_t
5065
 *
5066
 * Purpose:        Callback routine which is called whenever the collective
5067
 *                 metadata read flag property in the file creation property list is
5068
 *                 encoded.
5069
 *
5070
 * Return:       Success:    Non-negative
5071
 *           Failure:    Negative
5072
 *
5073
 *-------------------------------------------------------------------------
5074
 */
5075
herr_t
5076
H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size)
5077
{
5078
    const H5P_coll_md_read_flag_t *coll_md_read_flag = (const H5P_coll_md_read_flag_t *)value;
5079
    uint8_t                      **pp                = (uint8_t **)_pp;
5080
5081
    FUNC_ENTER_PACKAGE_NOERR
5082
5083
    /* Sanity checks */
5084
    assert(coll_md_read_flag);
5085
    assert(size);
5086
5087
    if (NULL != *pp) {
5088
        /* Encode the value */
5089
        H5MM_memcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t));
5090
        *pp += sizeof(H5P_coll_md_read_flag_t);
5091
    } /* end if */
5092
5093
    /* Set size needed for encoding */
5094
    *size += sizeof(H5P_coll_md_read_flag_t);
5095
5096
    FUNC_LEAVE_NOAPI(SUCCEED)
5097
} /* end H5P__encode_coll_md_read_flag_t() */
5098
5099
/*-------------------------------------------------------------------------
5100
 * Function:       H5P__decode_coll_md_read_flag_t
5101
 *
5102
 * Purpose:        Callback routine which is called whenever the collective
5103
 *                 metadata read flag property in the file creation property list is
5104
 *                 decoded.
5105
 *
5106
 * Return:       Success:    Non-negative
5107
 *           Failure:    Negative
5108
 *
5109
 *-------------------------------------------------------------------------
5110
 */
5111
herr_t
5112
H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value)
5113
{
5114
    H5P_coll_md_read_flag_t *coll_md_read_flag = (H5P_coll_md_read_flag_t *)_value; /* File close degree */
5115
    const uint8_t          **pp                = (const uint8_t **)_pp;
5116
5117
    FUNC_ENTER_PACKAGE_NOERR
5118
5119
    /* Sanity checks */
5120
    assert(pp);
5121
    assert(*pp);
5122
    assert(coll_md_read_flag);
5123
5124
    /* Decode metadata read flag */
5125
    *coll_md_read_flag = (H5P_coll_md_read_flag_t) * (*pp);
5126
    *pp += sizeof(H5P_coll_md_read_flag_t);
5127
5128
    FUNC_LEAVE_NOAPI(SUCCEED)
5129
} /* end H5P__decode_coll_md_read_flag_t() */
5130
5131
/*-------------------------------------------------------------------------
5132
 * Function:    H5Pset_all_coll_metadata_ops
5133
 *
5134
 * Purpose:    Tell the library whether the metadata read operations will
5135
 *             be done collectively (1) or not (0). Default is independent.
5136
 *             With collective mode, the library will optimize access to
5137
 *             metadata operations on the file.
5138
 *
5139
 * Note:    This routine accepts file access property lists, link
5140
 *          access property lists, attribute access property lists,
5141
 *          dataset access property lists, group access property lists
5142
 *          and named datatype access property lists.
5143
 *
5144
 * Return:    Non-negative on success/Negative on failure
5145
 *
5146
 *-------------------------------------------------------------------------
5147
 */
5148
herr_t
5149
H5Pset_all_coll_metadata_ops(hid_t plist_id, bool is_collective)
5150
{
5151
    H5P_genplist_t         *plist;               /* Property list pointer */
5152
    H5P_coll_md_read_flag_t coll_meta_read;      /* Property value */
5153
    herr_t                  ret_value = SUCCEED; /* return value */
5154
5155
    FUNC_ENTER_API(FAIL)
5156
5157
    /* Compare the property list's class against the other class */
5158
    /* (Dataset, group, attribute, and named datatype access property lists
5159
     *  are sub-classes of link access property lists -QAK)
5160
     */
5161
    if (true != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5162
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist");
5163
5164
    /* set property to either true if > 0, or false otherwise */
5165
    if (is_collective)
5166
        coll_meta_read = H5P_USER_TRUE;
5167
    else
5168
        coll_meta_read = H5P_USER_FALSE;
5169
5170
    /* Get the plist structure */
5171
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5172
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5173
5174
    /* Set values */
5175
    if (H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0)
5176
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata read flag");
5177
5178
done:
5179
    FUNC_LEAVE_API(ret_value)
5180
} /* end H5Pset_all_coll_metadata_ops() */
5181
5182
/*-------------------------------------------------------------------------
5183
 * Function:    H5Pget_all_coll_metadata_ops
5184
 *
5185
 * Purpose:    Gets information about collective metadata read mode.
5186
 *
5187
 * Note:    This routine accepts file access property lists, link
5188
 *          access property lists, attribute access property lists,
5189
 *          dataset access property lists, group access property lists,
5190
 *          and named datatype access property lists.
5191
 *
5192
 * Return:    Non-negative on success/Negative on failure
5193
 *
5194
 *-------------------------------------------------------------------------
5195
 */
5196
herr_t
5197
H5Pget_all_coll_metadata_ops(hid_t plist_id, bool *is_collective /*out*/)
5198
{
5199
    herr_t ret_value = SUCCEED; /* return value */
5200
5201
    FUNC_ENTER_API(FAIL)
5202
5203
    /* Compare the property list's class against the other class */
5204
    /* (Dataset, group, attribute, and named datatype access property lists
5205
     *  are sub-classes of link access property lists -QAK)
5206
     */
5207
    if (true != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5208
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist");
5209
5210
    /* Get value */
5211
    if (is_collective) {
5212
        H5P_coll_md_read_flag_t
5213
                        internal_flag; /* property setting. we need to convert to either true or false */
5214
        H5P_genplist_t *plist;         /* Property list pointer */
5215
5216
        /* Get the plist structure */
5217
        if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5218
            HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5219
5220
        if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0)
5221
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core collective metadata read flag");
5222
5223
        if (internal_flag < 0)
5224
            *is_collective = false;
5225
        else
5226
            *is_collective = (bool)internal_flag;
5227
    } /* end if */
5228
5229
done:
5230
    FUNC_LEAVE_API(ret_value)
5231
} /* H5Pget_all_coll_metadata_ops */
5232
5233
/*-------------------------------------------------------------------------
5234
 * Function:    H5Pset_coll_metadata_write
5235
 *
5236
 * Purpose:    Tell the library whether the metadata write operations will
5237
 *             be done collectively (1) or not (0). Default is independent.
5238
 *
5239
 * Return:    Non-negative on success/Negative on failure
5240
 *
5241
 *-------------------------------------------------------------------------
5242
 */
5243
herr_t
5244
H5Pset_coll_metadata_write(hid_t plist_id, bool is_collective)
5245
{
5246
    H5P_genplist_t *plist;               /* Property list pointer */
5247
    herr_t          ret_value = SUCCEED; /* return value */
5248
5249
    FUNC_ENTER_API(FAIL)
5250
5251
    /* Compare the property list's class against the other class */
5252
    if (true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5253
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist");
5254
5255
    /* Get the plist structure */
5256
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5257
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5258
5259
    /* Set values */
5260
    if (H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0)
5261
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata write flag");
5262
5263
done:
5264
    FUNC_LEAVE_API(ret_value)
5265
} /* end H5Pset_coll_metadata_write() */
5266
5267
/*-------------------------------------------------------------------------
5268
 * Function:    H5Pget_mpi_params
5269
 *
5270
 * Purpose:     Gets the MPI communicator and info stored in the fapl.
5271
 *
5272
 * Return:      Non-negative on success/Negative on failure
5273
 *
5274
 *-------------------------------------------------------------------------
5275
 */
5276
herr_t
5277
H5Pget_mpi_params(hid_t plist_id, MPI_Comm *comm /*out*/, MPI_Info *info /*out*/)
5278
{
5279
    H5P_genplist_t *plist;               /* Property list pointer */
5280
    herr_t          ret_value = SUCCEED; /* return value */
5281
5282
    FUNC_ENTER_API(FAIL)
5283
5284
    /* Make sure that the property list is a fapl */
5285
    if (true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5286
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist");
5287
5288
    /* Get the plist structure */
5289
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5290
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5291
5292
    /* Get the properties */
5293
    if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0)
5294
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator from plist");
5295
    if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0)
5296
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info from plist");
5297
5298
done:
5299
    FUNC_LEAVE_API(ret_value)
5300
} /* end H5Pget_mpi_params() */
5301
5302
/*-------------------------------------------------------------------------
5303
 * Function:    H5Pset_mpi_params
5304
 *
5305
 * Purpose:     Set the MPI communicator and info
5306
 *
5307
 * Return:      Non-negative on success/Negative on failure
5308
 *
5309
 *-------------------------------------------------------------------------
5310
 */
5311
herr_t
5312
H5Pset_mpi_params(hid_t plist_id, MPI_Comm comm, MPI_Info info)
5313
{
5314
    H5P_genplist_t *plist;               /* Property list pointer */
5315
    herr_t          ret_value = SUCCEED; /* return value */
5316
5317
    FUNC_ENTER_API(FAIL)
5318
5319
    /* Make sure the MPI communicator is valid */
5320
    if (MPI_COMM_NULL == comm)
5321
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "not a valid argument");
5322
5323
    /* Make sure that the property list is a fapl */
5324
    if (true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5325
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist");
5326
5327
    /* Get the plist structure */
5328
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5329
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5330
5331
    /* Set values */
5332
    if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0)
5333
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator");
5334
    if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0)
5335
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object");
5336
5337
done:
5338
    FUNC_LEAVE_API(ret_value)
5339
} /* end H5Pset_mpi_params() */
5340
5341
/*-------------------------------------------------------------------------
5342
 * Function:    H5P__facc_mpi_comm_set
5343
 *
5344
 * Purpose:     Copies an MPI comminicator property when it's set for a property list
5345
 *
5346
 * Return:      Success:        Non-negative
5347
 *              Failure:        Negative
5348
 *
5349
 *-------------------------------------------------------------------------
5350
 */
5351
static herr_t
5352
H5P__facc_mpi_comm_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5353
                       size_t H5_ATTR_UNUSED size, void *value)
5354
{
5355
    MPI_Comm *comm      = (MPI_Comm *)value;
5356
    MPI_Comm  comm_tmp  = MPI_COMM_NULL;
5357
    herr_t    ret_value = SUCCEED;
5358
5359
    FUNC_ENTER_PACKAGE
5360
5361
    /* Make a copy of the MPI communicator */
5362
    if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5363
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator");
5364
5365
done:
5366
    /* Copy the communicator to the in/out parameter */
5367
    if (ret_value != SUCCEED)
5368
        *comm = MPI_COMM_NULL;
5369
    else
5370
        *comm = comm_tmp;
5371
5372
    FUNC_LEAVE_NOAPI(ret_value)
5373
} /* end H5P__facc_mpi_comm_set() */
5374
5375
/*-------------------------------------------------------------------------
5376
 * Function:    H5P__facc_mpi_comm_get
5377
 *
5378
 * Purpose:     Copies an MPI comminicator property when it's retrieved from a property list
5379
 *
5380
 * Return:      Success:        Non-negative
5381
 *              Failure:        Negative
5382
 *
5383
 *-------------------------------------------------------------------------
5384
 */
5385
static herr_t
5386
H5P__facc_mpi_comm_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5387
                       size_t H5_ATTR_UNUSED size, void *value)
5388
{
5389
    MPI_Comm *comm      = (MPI_Comm *)value;
5390
    MPI_Comm  comm_tmp  = MPI_COMM_NULL;
5391
    herr_t    ret_value = SUCCEED;
5392
5393
    FUNC_ENTER_PACKAGE
5394
5395
    /* Make a copy of the MPI communicator */
5396
    if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5397
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator");
5398
5399
done:
5400
    /* Copy the communicator to the out parameter */
5401
    if (ret_value != SUCCEED)
5402
        *comm = MPI_COMM_NULL;
5403
    else
5404
        *comm = comm_tmp;
5405
5406
    FUNC_LEAVE_NOAPI(ret_value)
5407
} /* end H5P__facc_mpi_comm_get() */
5408
5409
/*-------------------------------------------------------------------------
5410
 * Function:    H5P__facc_mpi_comm_del
5411
 *
5412
 * Purpose:     Frees an MPI communicator property
5413
 *
5414
 * Return:      Success:        Non-negative
5415
 *              Failure:        Negative
5416
 *
5417
 *-------------------------------------------------------------------------
5418
 */
5419
static herr_t
5420
H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5421
                       size_t H5_ATTR_UNUSED size, void *value)
5422
{
5423
    MPI_Comm *comm      = (MPI_Comm *)value;
5424
    herr_t    ret_value = SUCCEED;
5425
5426
    FUNC_ENTER_PACKAGE
5427
5428
    /* Free the MPI communicator */
5429
    if (H5_mpi_comm_free(comm) < 0)
5430
        HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator");
5431
5432
done:
5433
    FUNC_LEAVE_NOAPI(ret_value)
5434
} /* end H5P__facc_mpi_comm_del() */
5435
5436
/*-------------------------------------------------------------------------
5437
 * Function:    H5P__facc_mpi_comm_copy
5438
 *
5439
 * Purpose:     Copy callback for the MPI communicator property.
5440
 *
5441
 * Return:      Success:        Non-negative
5442
 *              Failure:        Negative
5443
 *
5444
 *-------------------------------------------------------------------------
5445
 */
5446
static herr_t
5447
H5P__facc_mpi_comm_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5448
{
5449
    MPI_Comm *comm      = (MPI_Comm *)value;
5450
    MPI_Comm  comm_tmp  = MPI_COMM_NULL;
5451
    herr_t    ret_value = SUCCEED;
5452
5453
    FUNC_ENTER_PACKAGE
5454
5455
    /* Make a copy of the MPI communicator */
5456
    if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5457
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator");
5458
5459
done:
5460
    /* Copy the communicator to the in/out parameter */
5461
    if (ret_value != SUCCEED)
5462
        *comm = MPI_COMM_NULL;
5463
    else
5464
        *comm = comm_tmp;
5465
5466
    FUNC_LEAVE_NOAPI(ret_value)
5467
} /* end H5P__facc_mpi_comm_copy() */
5468
5469
/*-------------------------------------------------------------------------
5470
 * Function:       H5P__facc_mpi_comm_cmp
5471
 *
5472
 * Purpose:        Callback routine which is called whenever the MPI
5473
 *                 communicator property in the file access property list
5474
 *                 is compared.
5475
 *
5476
 * Return:         positive if VALUE1 is greater than VALUE2, negative if
5477
 *                 VALUE2 is greater than VALUE1 and zero if VALUE1 and
5478
 *                 VALUE2 are equal.
5479
 *
5480
 *-------------------------------------------------------------------------
5481
 */
5482
static int
5483
H5P__facc_mpi_comm_cmp(const void *_comm1, const void *_comm2, size_t H5_ATTR_UNUSED size)
5484
{
5485
    const MPI_Comm *comm1     = (const MPI_Comm *)_comm1;
5486
    const MPI_Comm *comm2     = (const MPI_Comm *)_comm2;
5487
    int             ret_value = 0;
5488
5489
    FUNC_ENTER_PACKAGE
5490
5491
    /* Compare the MPI communicators */
5492
    if (H5_mpi_comm_cmp(*comm1, *comm2, &ret_value) < 0)
5493
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI communicator");
5494
5495
done:
5496
    FUNC_LEAVE_NOAPI(ret_value)
5497
} /* end H5P__facc_mpi_comm_cmp() */
5498
5499
/*-------------------------------------------------------------------------
5500
 * Function:    H5P__facc_mpi_comm_close
5501
 *
5502
 * Purpose:     Close callback for the MPI communicator property.
5503
 *
5504
 * Return:      Success:        Non-negative
5505
 *              Failure:        Negative
5506
 *
5507
 *-------------------------------------------------------------------------
5508
 */
5509
static herr_t
5510
H5P__facc_mpi_comm_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5511
{
5512
    MPI_Comm *comm      = (MPI_Comm *)value;
5513
    herr_t    ret_value = SUCCEED;
5514
5515
    FUNC_ENTER_PACKAGE
5516
5517
    /* Free the MPI communicator */
5518
    if (H5_mpi_comm_free(comm) < 0)
5519
        HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator");
5520
5521
done:
5522
    FUNC_LEAVE_NOAPI(ret_value)
5523
} /* end H5P__facc_mpi_comm_close() */
5524
5525
/*-------------------------------------------------------------------------
5526
 * Function:    H5P__facc_mpi_info_set
5527
 *
5528
 * Purpose:     Copies an MPI info object property when it's set for a property list
5529
 *
5530
 * Return:      Success:        Non-negative
5531
 *              Failure:        Negative
5532
 *
5533
 *-------------------------------------------------------------------------
5534
 */
5535
static herr_t
5536
H5P__facc_mpi_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5537
                       size_t H5_ATTR_UNUSED size, void *value)
5538
{
5539
    MPI_Info *info      = (MPI_Info *)value;
5540
    MPI_Info  info_tmp  = MPI_INFO_NULL;
5541
    herr_t    ret_value = SUCCEED;
5542
5543
    FUNC_ENTER_PACKAGE
5544
5545
    /* Make a copy of the MPI info object */
5546
    if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5547
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object");
5548
5549
done:
5550
    /* Copy the info object to the in/out parameter */
5551
    if (ret_value != SUCCEED)
5552
        *info = MPI_INFO_NULL;
5553
    else
5554
        *info = info_tmp;
5555
5556
    FUNC_LEAVE_NOAPI(ret_value)
5557
} /* end H5P__facc_mpi_info_set() */
5558
5559
/*-------------------------------------------------------------------------
5560
 * Function:    H5P__facc_mpi_info_get
5561
 *
5562
 * Purpose:     Copies an MPI info object property when it's retrieved from a property list
5563
 *
5564
 * Return:      Success:        Non-negative
5565
 *              Failure:        Negative
5566
 *
5567
 *-------------------------------------------------------------------------
5568
 */
5569
static herr_t
5570
H5P__facc_mpi_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5571
                       size_t H5_ATTR_UNUSED size, void *value)
5572
{
5573
    MPI_Info *info      = (MPI_Info *)value;
5574
    MPI_Info  info_tmp  = MPI_INFO_NULL;
5575
    herr_t    ret_value = SUCCEED;
5576
5577
    FUNC_ENTER_PACKAGE
5578
5579
    /* Make a copy of the MPI communicator */
5580
    if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5581
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object");
5582
5583
done:
5584
    /* Copy the info object to the out parameter */
5585
    if (ret_value != SUCCEED)
5586
        *info = MPI_INFO_NULL;
5587
    else
5588
        *info = info_tmp;
5589
5590
    FUNC_LEAVE_NOAPI(ret_value)
5591
} /* end H5P__facc_mpi_info_get() */
5592
5593
/*-------------------------------------------------------------------------
5594
 * Function:    H5P__facc_mpi_info_del
5595
 *
5596
 * Purpose:     Frees an MPI info object property
5597
 *
5598
 * Return:      Success:        Non-negative
5599
 *              Failure:        Negative
5600
 *
5601
 *-------------------------------------------------------------------------
5602
 */
5603
static herr_t
5604
H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5605
                       size_t H5_ATTR_UNUSED size, void *value)
5606
{
5607
    MPI_Info *info      = (MPI_Info *)value;
5608
    herr_t    ret_value = SUCCEED;
5609
5610
    FUNC_ENTER_PACKAGE
5611
5612
    /* Free the MPI info object */
5613
    if (H5_mpi_info_free(info) < 0)
5614
        HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object");
5615
5616
done:
5617
    FUNC_LEAVE_NOAPI(ret_value)
5618
} /* end H5P__facc_mpi_info_del() */
5619
5620
/*-------------------------------------------------------------------------
5621
 * Function:    H5P__facc_mpi_info_copy
5622
 *
5623
 * Purpose:     Copy callback for the MPI info object property.
5624
 *
5625
 * Return:      Success:        Non-negative
5626
 *              Failure:        Negative
5627
 *
5628
 *-------------------------------------------------------------------------
5629
 */
5630
static herr_t
5631
H5P__facc_mpi_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5632
{
5633
    MPI_Info *info      = (MPI_Info *)value;
5634
    MPI_Info  info_tmp  = MPI_INFO_NULL;
5635
    herr_t    ret_value = SUCCEED;
5636
5637
    FUNC_ENTER_PACKAGE
5638
5639
    /* Make a copy of the MPI info object */
5640
    if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5641
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object");
5642
5643
done:
5644
    /* Copy the info object to the in/out parameter */
5645
    if (ret_value != SUCCEED)
5646
        *info = MPI_INFO_NULL;
5647
    else
5648
        *info = info_tmp;
5649
5650
    FUNC_LEAVE_NOAPI(ret_value)
5651
} /* end H5P__facc_mpi_info_copy() */
5652
5653
/*-------------------------------------------------------------------------
5654
 * Function:       H5P__facc_mpi_info_cmp
5655
 *
5656
 * Purpose:        Callback routine which is called whenever the MPI
5657
 *                 info object property in the file access property list
5658
 *                 is compared.
5659
 *
5660
 * Return:         positive if VALUE1 is greater than VALUE2, negative if
5661
 *                 VALUE2 is greater than VALUE1 and zero if VALUE1 and
5662
 *                 VALUE2 are equal.
5663
 *
5664
 *-------------------------------------------------------------------------
5665
 */
5666
static int
5667
H5P__facc_mpi_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
5668
{
5669
    const MPI_Info *info1     = (const MPI_Info *)_info1;
5670
    const MPI_Info *info2     = (const MPI_Info *)_info2;
5671
    int             ret_value = 0;
5672
5673
    FUNC_ENTER_PACKAGE
5674
5675
    /* Compare the MPI info objects */
5676
    if (H5_mpi_info_cmp(*info1, *info2, &ret_value) < 0)
5677
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI info objects");
5678
5679
done:
5680
    FUNC_LEAVE_NOAPI(ret_value)
5681
} /* end H5P__facc_mpi_info_cmp() */
5682
5683
/*-------------------------------------------------------------------------
5684
 * Function:    H5P__facc_mpi_info_close
5685
 *
5686
 * Purpose:     Close callback for the MPI info object property.
5687
 *
5688
 * Return:      Success:        Non-negative
5689
 *              Failure:        Negative
5690
 *
5691
 *-------------------------------------------------------------------------
5692
 */
5693
static herr_t
5694
H5P__facc_mpi_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5695
{
5696
    MPI_Info *info      = (MPI_Info *)value;
5697
    herr_t    ret_value = SUCCEED;
5698
5699
    FUNC_ENTER_PACKAGE
5700
5701
    /* Free the MPI info object */
5702
    if (H5_mpi_info_free(info) < 0)
5703
        HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object");
5704
5705
done:
5706
    FUNC_LEAVE_NOAPI(ret_value)
5707
} /* end H5P__facc_mpi_info_close() */
5708
5709
/*-------------------------------------------------------------------------
5710
 * Function:    H5Pget_coll_metadata_write
5711
 *
5712
 * Purpose:    Gets information about collective metadata write mode.
5713
 *
5714
 * Return:    Non-negative on success/Negative on failure
5715
 *
5716
 *-------------------------------------------------------------------------
5717
 */
5718
herr_t
5719
H5Pget_coll_metadata_write(hid_t plist_id, bool *is_collective /*out*/)
5720
{
5721
    H5P_genplist_t *plist;               /* Property list pointer */
5722
    herr_t          ret_value = SUCCEED; /* return value */
5723
5724
    FUNC_ENTER_API(FAIL)
5725
5726
    /* Compare the property list's class against the other class */
5727
    if (true != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5728
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist");
5729
5730
    /* Get the plist structure */
5731
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5732
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5733
5734
    if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0)
5735
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get collective metadata write flag");
5736
5737
done:
5738
    FUNC_LEAVE_API(ret_value)
5739
} /* end H5Pget_coll_metadata_write() */
5740
#endif /* H5_HAVE_PARALLEL */
5741
5742
/*-------------------------------------------------------------------------
5743
 * Function:    H5Pset_page_buffer_size
5744
 *
5745
 * Purpose:     Set the maximum page buffering size. This has to be a
5746
 *              multiple of the page allocation size which must be enabled;
5747
 *              otherwise file create/open will fail.
5748
 *
5749
 * Return:    Non-negative on success/Negative on failure
5750
 *
5751
 *-------------------------------------------------------------------------
5752
 */
5753
herr_t
5754
H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc)
5755
0
{
5756
0
    H5P_genplist_t *plist;               /* Property list pointer */
5757
0
    herr_t          ret_value = SUCCEED; /* return value */
5758
5759
0
    FUNC_ENTER_API(FAIL)
5760
5761
    /* Get the plist structure */
5762
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
5763
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5764
5765
0
    if (min_meta_perc > 100)
5766
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5767
0
                    "Minimum metadata fractions must be between 0 and 100 inclusive");
5768
0
    if (min_raw_perc > 100)
5769
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5770
0
                    "Minimum raw data fractions must be between 0 and 100 inclusive");
5771
5772
0
    if (min_meta_perc + min_raw_perc > 100)
5773
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5774
0
                    "Sum of minimum metadata and raw data fractions can't be bigger than 100");
5775
5776
    /* Set size */
5777
0
    if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0)
5778
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set page buffer size");
5779
0
    if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0)
5780
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min metadata entries");
5781
0
    if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0)
5782
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min raw data entries");
5783
5784
0
done:
5785
0
    FUNC_LEAVE_API(ret_value)
5786
0
} /* end H5Pset_page_buffer_size() */
5787
5788
/*-------------------------------------------------------------------------
5789
 * Function:    H5Pget_page_buffer_size
5790
 *
5791
 * Purpose:    Retrieves the maximum page buffer size.
5792
 *
5793
 * Return:    Non-negative on success/Negative on failure
5794
 *
5795
 *-------------------------------------------------------------------------
5796
 */
5797
herr_t
5798
H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size /*out*/, unsigned *min_meta_perc /*out*/,
5799
                        unsigned *min_raw_perc /*out*/)
5800
0
{
5801
0
    H5P_genplist_t *plist;               /* Property list pointer */
5802
0
    herr_t          ret_value = SUCCEED; /* return value */
5803
5804
0
    FUNC_ENTER_API(FAIL)
5805
5806
    /* Get the plist structure */
5807
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
5808
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
5809
5810
    /* Get size */
5811
5812
0
    if (buf_size) {
5813
0
        if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0)
5814
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer size");
5815
0
        if (*buf_size == H5F_PAGE_BUFFER_SIZE_DEFAULT)
5816
0
            *buf_size = H5PB_SIZE_DEFAULT_VALUE;
5817
0
    }
5818
0
    if (min_meta_perc)
5819
0
        if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0)
5820
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum metadata percent");
5821
0
    if (min_raw_perc)
5822
0
        if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0)
5823
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum raw data percent");
5824
5825
0
done:
5826
0
    FUNC_LEAVE_API(ret_value)
5827
0
} /* end H5Pget_page_buffer_size() */
5828
5829
/*-------------------------------------------------------------------------
5830
 * Function:       H5P__facc_page_buffer_size_enc
5831
 *
5832
 * Purpose:        Encode the page buffer size parameter to a serialized
5833
 *                 property list. Similar to H5P__encode_size_t except for
5834
 *                 special handling of the default signifier
5835
 *                 H5F_PAGE_BUFFER_SIZE_DEFAULT and the default value
5836
 *                 H5PB_SIZE_DEFAULT_VALUE. The exact handling of these
5837
 *                 values depends on the encoding format version.
5838
 *
5839
 * Return:         Success:     Non-negative
5840
 *                 Failure:     Negative
5841
 *-------------------------------------------------------------------------
5842
 */
5843
static herr_t
5844
H5P__facc_page_buffer_size_enc(const void *value, void **_pp, size_t *size)
5845
0
{
5846
0
    uint64_t     enc_value = 0; /* Property value to encode */
5847
0
    uint8_t    **pp        = (uint8_t **)_pp;
5848
0
    unsigned     enc_size;            /* Size of encoded property */
5849
0
    H5F_libver_t low_bound;           /* The 'low' bound of library format versions */
5850
0
    H5F_libver_t high_bound;          /* The 'high' bound of library format versions */
5851
0
    herr_t       ret_value = SUCCEED; /* return value */
5852
5853
0
    FUNC_ENTER_PACKAGE
5854
5855
    /* Sanity checks */
5856
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
5857
0
    assert(size);
5858
5859
    /* Get the file's low_bound and high_bound */
5860
0
    if (H5CX_get_libver_bounds(&low_bound, &high_bound) < 0)
5861
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low/high bounds from API context");
5862
5863
    /* Check for low_bound below H5F_LIBVER_V200 */
5864
0
    if (low_bound < H5F_LIBVER_V200) {
5865
        /* If this is the default value, encode the actual default (H5PB_SIZE_DEFAULT_VALUE), since earlier
5866
         * versions of the library don't understand H5F_PAGE_BUFFER_SIZE_DEFAULT */
5867
0
        if (*(const size_t *)value == H5F_PAGE_BUFFER_SIZE_DEFAULT)
5868
0
            enc_value = (uint64_t)H5PB_SIZE_DEFAULT_VALUE;
5869
0
        else
5870
0
            enc_value = (uint64_t) * (const size_t *)value;
5871
5872
        /* Determine encoding size */
5873
0
        enc_size = H5VM_limit_enc_size(enc_value);
5874
0
        assert(enc_size > 0);
5875
0
        *size += (1 + enc_size);
5876
0
    }
5877
0
    else {
5878
        /* If the actual default (H5PB_SIZE_DEFAULT_VALUE) was explicitly encoded, encode enc_size as 0. We
5879
         * must do it this way instead of encoding the implicit default (H5F_PAGE_BUFFER_SIZE_DEFAULT) as
5880
         * enc_size=0 because we need the default in the old format to be decoded to
5881
         * H5F_PAGE_BUFFER_SIZE_DEFAULT, so that the decoded plist matches the original even when using the
5882
         * old format. */
5883
0
        if (*(const size_t *)value == H5PB_SIZE_DEFAULT_VALUE) {
5884
0
            enc_size = 0;
5885
0
            *size += 1;
5886
0
        }
5887
0
        else {
5888
            /* Set enc_value and determine encoding size */
5889
0
            enc_value = (uint64_t) * (const size_t *)value;
5890
0
            enc_size  = H5VM_limit_enc_size(enc_value);
5891
0
            assert(enc_size > 0);
5892
0
            *size += (1 + enc_size);
5893
0
        }
5894
0
    }
5895
5896
0
    assert(enc_size < 256);
5897
5898
0
    if (NULL != *pp) {
5899
        /* Encode the size */
5900
0
        *(*pp)++ = (uint8_t)enc_size;
5901
5902
        /* Encode the value if necessary */
5903
0
        if (enc_size != 0) {
5904
0
            UINT64ENCODE_VAR(*pp, enc_value, enc_size);
5905
0
        } /* end if */
5906
0
    }     /* end if */
5907
5908
0
done:
5909
0
    FUNC_LEAVE_NOAPI(ret_value)
5910
0
} /* end H5P__facc_page_buffer_size_enc() */
5911
5912
/*-------------------------------------------------------------------------
5913
 * Function:       H5P__facc_page_buffer_size_dec
5914
 *
5915
 * Purpose:        Decode the page buffer size parameter from a serialized
5916
 *                 property list. Similar to H5P__decode_size_t except for
5917
 *                 special handling of the default signifier
5918
 *                 H5F_PAGE_BUFFER_SIZE_DEFAULT and the default value
5919
 *                 H5PB_SIZE_DEFAULT_VALUE. The exact handling of these
5920
 *                 values depends on the encoding format version.
5921
 *
5922
 * Return:         Success:     Non-negative
5923
 *                 Failure:     Negative
5924
 *-------------------------------------------------------------------------
5925
 */
5926
static herr_t
5927
H5P__facc_page_buffer_size_dec(const void **_pp, void *_value)
5928
0
{
5929
0
    size_t         *value = (size_t *)_value; /* Property value to return */
5930
0
    const uint8_t **pp    = (const uint8_t **)_pp;
5931
0
    uint64_t        enc_value; /* Decoded property value */
5932
0
    unsigned        enc_size;  /* Size of encoded property */
5933
5934
0
    FUNC_ENTER_PACKAGE_NOERR
5935
5936
    /* Sanity check */
5937
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
5938
0
    assert(pp);
5939
0
    assert(*pp);
5940
0
    assert(value);
5941
5942
    /* Decode the size */
5943
0
    enc_size = *(*pp)++;
5944
0
    assert(enc_size < 256);
5945
5946
    /* Determine if enc_size indicates that this is the default value, in which
5947
     * case set value to H5F_PAGE_BUFFER_SIZE_DEFAULT and return */
5948
0
    if (enc_size == 0)
5949
0
        *value = H5PB_SIZE_DEFAULT_VALUE;
5950
0
    else {
5951
        /* Decode the value */
5952
0
        UINT64DECODE_VAR(*pp, enc_value, enc_size);
5953
5954
        /* If the encoded value matches H5PB_SIZE_DEFAULT_VALUE, set value to H5F_PAGE_BUFFER_SIZE_DEFAULT, so
5955
         * when an implicit default is encoded is is decoded to an implicit default */
5956
0
        if (enc_value == H5PB_SIZE_DEFAULT_VALUE)
5957
0
            *value = H5F_PAGE_BUFFER_SIZE_DEFAULT;
5958
0
        else
5959
0
            H5_CHECKED_ASSIGN(*value, uint64_t, enc_value, size_t);
5960
0
    } /* end else */
5961
5962
0
    FUNC_LEAVE_NOAPI(SUCCEED)
5963
0
} /* end H5P__facc_page_buffer_size_dec() */
5964
5965
/*-------------------------------------------------------------------------
5966
 * Function:    H5P_set_vol
5967
 *
5968
 * Purpose:     Set the VOL connector for a file access property list
5969
 *              (PLIST_ID).  The VOL properties will
5970
 *              be copied into the property list and the reference count on
5971
 *              the VOL will be incremented.
5972
 *
5973
 * Return:      SUCCEED/FAIL
5974
 *
5975
 *-------------------------------------------------------------------------
5976
 */
5977
herr_t
5978
H5P_set_vol(H5P_genplist_t *plist, H5VL_connector_t *connector, const void *vol_info)
5979
6
{
5980
6
    herr_t ret_value = SUCCEED; /* Return value */
5981
5982
6
    FUNC_ENTER_NOAPI(FAIL)
5983
5984
    /* Sanity check */
5985
6
    assert(connector);
5986
5987
6
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
5988
6
        H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */
5989
5990
        /* Prepare the VOL connector property */
5991
6
        vol_prop.connector      = connector;
5992
6
        vol_prop.connector_info = vol_info;
5993
5994
        /* Set the connector ID & info property */
5995
6
        if (H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0)
5996
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info");
5997
6
    } /* end if */
5998
0
    else
5999
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
6000
6001
6
done:
6002
6
    FUNC_LEAVE_NOAPI(ret_value)
6003
6
} /* end H5P_set_vol() */
6004
6005
/*-------------------------------------------------------------------------
6006
 * Function:    H5P_reset_vol_class
6007
 *
6008
 * Purpose:     Change the VOL connector for a file access property class.
6009
 *
6010
 * Note:  The VOL property will be copied into the property list and
6011
 *    the reference count on the previous VOL will _NOT_ be decremented.
6012
 *    The reference count on the new VOL will _NOT_ be incremented.
6013
 *
6014
 * Return:      SUCCEED/FAIL
6015
 *
6016
 *-------------------------------------------------------------------------
6017
 */
6018
herr_t
6019
H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *vol_prop)
6020
6
{
6021
6
    H5VL_connector_prop_t old_vol_prop;        /* Previous VOL connector property */
6022
6
    herr_t                ret_value = SUCCEED; /* Return value */
6023
6024
6
    FUNC_ENTER_NOAPI(FAIL)
6025
6026
    /* Get the connector ID & info property */
6027
6
    if (H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0)
6028
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector ID & info");
6029
6030
    /* Set the new connector ID & info property */
6031
6
    if (H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0)
6032
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info");
6033
6034
6
done:
6035
6
    FUNC_LEAVE_NOAPI(ret_value)
6036
6
} /* end H5P_set_vol_class() */
6037
6038
/*-------------------------------------------------------------------------
6039
 * Function:    H5Pset_vol
6040
 *
6041
 * Purpose:     Set the file VOL connector (VOL_ID) for a file access
6042
 *              property list (PLIST_ID)
6043
 *
6044
 * Return:      Success:    Non-negative
6045
 *              Failure:    Negative
6046
 *
6047
 *-------------------------------------------------------------------------
6048
 */
6049
herr_t
6050
H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info)
6051
0
{
6052
0
    H5P_genplist_t   *plist;               /* Property list pointer */
6053
0
    H5VL_connector_t *connector;           /* VOL connector */
6054
0
    herr_t            ret_value = SUCCEED; /* Return value */
6055
6056
0
    FUNC_ENTER_API(FAIL)
6057
6058
    /* Check arguments */
6059
0
    if (NULL == (plist = (H5P_genplist_t *)H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
6060
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
6061
0
    if (NULL == (connector = H5I_object_verify(new_vol_id, H5I_VOL)))
6062
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID");
6063
6064
    /* Set the VOL */
6065
0
    if (H5P_set_vol(plist, connector, new_vol_info) < 0)
6066
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL");
6067
6068
0
done:
6069
0
    FUNC_LEAVE_API(ret_value)
6070
0
} /* end H5Pset_vol() */
6071
6072
/*-------------------------------------------------------------------------
6073
 * Function:    H5Pget_vol_id
6074
 *
6075
 * Purpose:     Returns the ID of the current VOL connector.
6076
 *              This ID should be closed with H5VLclose().
6077
 *
6078
 * Return:      Success:        Non-negative
6079
 *              Failure:        Negative
6080
 *
6081
 *-------------------------------------------------------------------------
6082
 */
6083
herr_t
6084
H5Pget_vol_id(hid_t plist_id, hid_t *vol_id /*out*/)
6085
0
{
6086
0
    H5P_genplist_t *plist;               /* Property list pointer */
6087
0
    herr_t          ret_value = SUCCEED; /* Return value */
6088
6089
0
    FUNC_ENTER_API(FAIL)
6090
6091
0
    if (H5P_DEFAULT == plist_id)
6092
0
        plist_id = H5P_FILE_ACCESS_DEFAULT;
6093
6094
    /* Get property list for ID */
6095
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
6096
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
6097
6098
    /* Get the current VOL ID */
6099
0
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
6100
0
        H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
6101
6102
        /* Get the connector property */
6103
0
        if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
6104
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info");
6105
6106
        /* Register an ID for the connector */
6107
0
        if ((*vol_id = H5VL_conn_register(connector_prop.connector)) < 0)
6108
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector");
6109
0
    } /* end if */
6110
0
    else
6111
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
6112
6113
0
done:
6114
0
    FUNC_LEAVE_API(ret_value)
6115
0
} /* end H5Pget_vol_id() */
6116
6117
/*-------------------------------------------------------------------------
6118
 * Function:    H5Pget_vol_info
6119
 *
6120
 * Purpose:     Returns a copy of the VOL info for a connector.
6121
 *              This information should be freed with H5VLfree_connector_info.
6122
 *
6123
 * Return:      Success:        Non-negative
6124
 *              Failure:        Negative
6125
 *
6126
 *-------------------------------------------------------------------------
6127
 */
6128
herr_t
6129
H5Pget_vol_info(hid_t plist_id, void **vol_info /*out*/)
6130
0
{
6131
0
    H5P_genplist_t *plist;               /* Property list pointer */
6132
0
    herr_t          ret_value = SUCCEED; /* Return value */
6133
6134
0
    FUNC_ENTER_API(FAIL)
6135
6136
    /* Get property list for ID */
6137
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
6138
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
6139
6140
    /* Get the current VOL info */
6141
0
    if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
6142
0
        void                 *new_connector_info = NULL; /* Copy of connector info */
6143
0
        H5VL_connector_prop_t connector_prop;            /* Property for VOL connector ID & info */
6144
6145
        /* Get the connector property */
6146
0
        if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
6147
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property");
6148
6149
        /* Copy connector info, if it exists */
6150
0
        if (connector_prop.connector_info)
6151
            /* Allocate and copy connector info */
6152
0
            if (H5VL_copy_connector_info(connector_prop.connector, &new_connector_info,
6153
0
                                         connector_prop.connector_info) < 0)
6154
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed");
6155
6156
        /* Set the connector info */
6157
0
        *vol_info = new_connector_info;
6158
0
    } /* end if */
6159
0
    else
6160
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
6161
6162
0
done:
6163
0
    FUNC_LEAVE_API(ret_value)
6164
0
} /* end H5Pget_vol_info() */
6165
6166
/*-------------------------------------------------------------------------
6167
 * Function:    H5Pget_vol_cap_flags
6168
 *
6169
 * Purpose:     Queries the current VOL connector information for a FAPL to
6170
 *              retrieve the capability flags for the VOL connector stack, as will
6171
 *              be used by a file open or create operation that uses this FAPL.
6172
 *
6173
 *              Current capability flags are:
6174
 *                  H5VL_CAP_FLAG_THREADSAFE   - Connector is threadsafe
6175
 *                  H5VL_CAP_FLAG_ASYNC        - Connector performs operations asynchronously
6176
 *                  H5VL_CAP_FLAG_NATIVE_FILES - Connector produces native file format
6177
 *
6178
 * Note:        This routine supports the use of the HDF5_VOL_CONNECTOR environment
6179
 *              environment variable to override the VOL connector set programmatically
6180
 *              for the FAPL (with H5Pset_vol).
6181
 *
6182
 * Note:        The H5VL_CAP_FLAG_ASYNC flag can be checked to see if asynchronous
6183
 *              operations are supported by the VOL connector stack.
6184
 *
6185
 * Return:      Success:        Non-negative
6186
 *              Failure:        Negative
6187
 *
6188
 *-------------------------------------------------------------------------
6189
 */
6190
herr_t
6191
H5Pget_vol_cap_flags(hid_t plist_id, uint64_t *cap_flags)
6192
0
{
6193
0
    herr_t ret_value = SUCCEED; /* Return value */
6194
6195
0
    FUNC_ENTER_API(FAIL)
6196
6197
    /* Get the 'cap_flags' from the connector */
6198
0
    if (cap_flags) {
6199
0
        if (H5P_DEFAULT == plist_id)
6200
0
            plist_id = H5P_FILE_ACCESS_DEFAULT;
6201
6202
0
        if (true == H5P_isa_class(plist_id, H5P_FILE_ACCESS)) {
6203
0
            H5P_genplist_t       *plist;          /* Property list pointer */
6204
0
            H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
6205
6206
            /* Get property list for ID */
6207
0
            if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
6208
0
                HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
6209
6210
            /* Get the connector property */
6211
0
            if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
6212
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property");
6213
6214
            /* Query the capability flags */
6215
0
            if (H5VL_conn_prop_get_cap_flags(&connector_prop, cap_flags) < 0)
6216
0
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector capability flags");
6217
0
        }
6218
0
        else
6219
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
6220
0
    }
6221
6222
0
done:
6223
0
    FUNC_LEAVE_API(ret_value)
6224
0
} /* end H5Pget_vol_cap_flags() */
6225
6226
/*-------------------------------------------------------------------------
6227
 * Function:    H5P__facc_vol_create
6228
 *
6229
 connectorose:     Create callback for the VOL connector ID & info property.
6230
 *
6231
 * Return:      Success:        Non-negative
6232
 *              Failure:        Negative
6233
 *
6234
 *-------------------------------------------------------------------------
6235
 */
6236
static herr_t
6237
H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
6238
12
{
6239
12
    herr_t ret_value = SUCCEED; /* Return value */
6240
6241
12
    FUNC_ENTER_PACKAGE
6242
6243
    /* Make copy of the VOL connector property */
6244
12
    if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0)
6245
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector");
6246
6247
12
done:
6248
12
    FUNC_LEAVE_NOAPI(ret_value)
6249
12
} /* end H5P__facc_vol_create() */
6250
6251
/*-------------------------------------------------------------------------
6252
 * Function:    H5P__facc_vol_set
6253
 *
6254
 * Purpose:     Copies a VOL connector property when it's set for a property list
6255
 *
6256
 * Return:      Success:        Non-negative
6257
 *              Failure:        Negative
6258
 *
6259
 *-------------------------------------------------------------------------
6260
 */
6261
static herr_t
6262
H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
6263
                  void *value)
6264
12
{
6265
12
    herr_t ret_value = SUCCEED; /* Return value */
6266
6267
12
    FUNC_ENTER_PACKAGE
6268
6269
    /* Sanity check */
6270
12
    assert(value);
6271
6272
    /* Make copy of VOL connector property */
6273
12
    if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0)
6274
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector");
6275
6276
12
done:
6277
12
    FUNC_LEAVE_NOAPI(ret_value)
6278
12
} /* end H5P__facc_vol_set() */
6279
6280
/*-------------------------------------------------------------------------
6281
 * Function:    H5P__facc_vol_get
6282
 *
6283
 * Purpose:     Copies a VOL connector property when it's retrieved from a property list
6284
 *
6285
 * Return:      Success:        Non-negative
6286
 *              Failure:        Negative
6287
 *
6288
 *-------------------------------------------------------------------------
6289
 */
6290
static herr_t
6291
H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
6292
                  void *value)
6293
0
{
6294
0
    herr_t ret_value = SUCCEED; /* Return value */
6295
6296
0
    FUNC_ENTER_PACKAGE
6297
6298
    /* Sanity check */
6299
0
    assert(value);
6300
6301
    /* Make copy of VOL connector property */
6302
0
    if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0)
6303
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector");
6304
6305
0
done:
6306
0
    FUNC_LEAVE_NOAPI(ret_value)
6307
0
} /* end H5P__facc_vol_get() */
6308
6309
/*-------------------------------------------------------------------------
6310
 * Function:    H5P__facc_vol_del
6311
 *
6312
 * Purpose:     Frees memory used to store the VOL connector ID & info property
6313
 *
6314
 * Return:      Success:        Non-negative
6315
 *              Failure:        Negative
6316
 *
6317
 *-------------------------------------------------------------------------
6318
 */
6319
static herr_t
6320
H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
6321
                  void *value)
6322
12
{
6323
12
    herr_t ret_value = SUCCEED; /* Return value */
6324
6325
12
    FUNC_ENTER_PACKAGE
6326
6327
    /* Free the VOL connector property */
6328
12
    if (H5VL_conn_prop_free((H5VL_connector_prop_t *)value) < 0)
6329
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector");
6330
6331
12
done:
6332
12
    FUNC_LEAVE_NOAPI(ret_value)
6333
12
} /* end H5P__facc_vol_del() */
6334
6335
/*-------------------------------------------------------------------------
6336
 * Function:    H5P__facc_vol_copy
6337
 *
6338
 * Purpose:     Copy callback for the VOL connector ID & info property.
6339
 *
6340
 * Return:      Success:        Non-negative
6341
 *              Failure:        Negative
6342
 *
6343
 *-------------------------------------------------------------------------
6344
 */
6345
static herr_t
6346
H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
6347
18
{
6348
18
    herr_t ret_value = SUCCEED; /* Return value */
6349
6350
18
    FUNC_ENTER_PACKAGE
6351
6352
    /* Make copy of VOL connector property */
6353
18
    if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0)
6354
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector");
6355
6356
18
done:
6357
18
    FUNC_LEAVE_NOAPI(ret_value)
6358
18
} /* end H5P__facc_vol_copy() */
6359
6360
/*-------------------------------------------------------------------------
6361
 * Function:       H5P__facc_vol_cmp
6362
 *
6363
 * Purpose:        Callback routine which is called whenever the VOL connector
6364
 *                 ID & info property in the file access property list
6365
 *                 is compared.
6366
 *
6367
 * Return:         positive if VALUE1 is greater than VALUE2, negative if
6368
 *                 VALUE2 is greater than VALUE1 and zero if VALUE1 and
6369
 *                 VALUE2 are equal.
6370
 *
6371
 *-------------------------------------------------------------------------
6372
 */
6373
static int
6374
H5P__facc_vol_cmp(const void *_prop1, const void *_prop2, size_t H5_ATTR_UNUSED size)
6375
0
{
6376
0
    const H5VL_connector_prop_t *prop1 =
6377
0
        (const H5VL_connector_prop_t *)_prop1; /* Create local aliases for values */
6378
0
    const H5VL_connector_prop_t *prop2 = (const H5VL_connector_prop_t *)_prop2;
6379
0
    herr_t H5_ATTR_NDEBUG_UNUSED status;        /* Status from info comparison */
6380
0
    int                          ret_value = 0; /* Return value */
6381
6382
0
    FUNC_ENTER_PACKAGE_NOERR
6383
6384
    /* Sanity check */
6385
0
    assert(prop1);
6386
0
    assert(prop2);
6387
0
    assert(size == sizeof(H5VL_connector_prop_t));
6388
6389
    /* Compare properties */
6390
0
    status = H5VL_conn_prop_cmp(&ret_value, prop1, prop2);
6391
0
    assert(status >= 0);
6392
6393
0
    FUNC_LEAVE_NOAPI(ret_value)
6394
0
} /* end H5P__facc_vol_cmp() */
6395
6396
/*-------------------------------------------------------------------------
6397
 * Function:    H5P__facc_vol_close
6398
 *
6399
 * Purpose:     Close callback for the VOL connector ID & info property.
6400
 *
6401
 * Return:      Success:        Non-negative
6402
 *              Failure:        Negative
6403
 *
6404
 *-------------------------------------------------------------------------
6405
 */
6406
static herr_t
6407
H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
6408
30
{
6409
30
    herr_t ret_value = SUCCEED; /* Return value */
6410
6411
30
    FUNC_ENTER_PACKAGE
6412
6413
    /* Free the VOL connector property */
6414
30
    if (H5VL_conn_prop_free((H5VL_connector_prop_t *)value) < 0)
6415
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector");
6416
6417
30
done:
6418
30
    FUNC_LEAVE_NOAPI(ret_value)
6419
30
} /* end H5P__facc_vol_close() */
6420
6421
/*-------------------------------------------------------------------------
6422
 * Function:    H5Pset_relax_file_integrity_checks
6423
 *
6424
 * Purpose:     Relax certain file integrity checks that may issue errors
6425
 *              for valid files that have the potential for incorrect library
6426
 *              behavior when data is incorrect or corrupted.
6427
 *
6428
 * Return:      Non-negative on success/Negative on failure
6429
 *
6430
 *-------------------------------------------------------------------------
6431
 */
6432
herr_t
6433
H5Pset_relax_file_integrity_checks(hid_t plist_id, uint64_t flags)
6434
0
{
6435
0
    H5P_genplist_t *plist;               /* Property list pointer */
6436
0
    herr_t          ret_value = SUCCEED; /* Return value */
6437
6438
0
    FUNC_ENTER_API(FAIL)
6439
6440
    /* Check arguments */
6441
0
    if (H5P_DEFAULT == plist_id)
6442
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list");
6443
0
    if (flags & (uint64_t)~H5F_RFIC_ALL)
6444
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags");
6445
6446
    /* Get the property list structure */
6447
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, false)))
6448
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list");
6449
6450
    /* Set value */
6451
0
    if (H5P_set(plist, H5F_ACS_RFIC_FLAGS_NAME, &flags) < 0)
6452
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set relaxed file integrity check flags");
6453
6454
0
done:
6455
0
    FUNC_LEAVE_API(ret_value)
6456
0
} /* end H5Pset_relax_file_integrity_checks() */
6457
6458
/*-------------------------------------------------------------------------
6459
 * Function:    H5Pget_relax_file_integrity_checks
6460
 *
6461
 * Purpose:     Retrieve relaxed file integrity check flags
6462
 *
6463
 * Return:      Non-negative on success/Negative on failure
6464
 *
6465
 *-------------------------------------------------------------------------
6466
 */
6467
herr_t
6468
H5Pget_relax_file_integrity_checks(hid_t plist_id, uint64_t *flags /*out*/)
6469
0
{
6470
0
    H5P_genplist_t *plist;               /* Property list pointer */
6471
0
    herr_t          ret_value = SUCCEED; /* Return value */
6472
6473
0
    FUNC_ENTER_API(FAIL)
6474
6475
0
    if (H5P_DEFAULT == plist_id)
6476
0
        plist_id = H5P_FILE_ACCESS_DEFAULT;
6477
6478
    /* Get the property list structure */
6479
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS, true)))
6480
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list");
6481
6482
    /* Get value */
6483
0
    if (flags)
6484
0
        if (H5P_get(plist, H5F_ACS_RFIC_FLAGS_NAME, flags) < 0)
6485
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get relaxed file integrity check flags");
6486
6487
0
done:
6488
    FUNC_LEAVE_API(ret_value)
6489
0
} /* end H5Pget_relax_file_integrity_checks() */