Line | Count | Source (jump to first uncovered line) |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the 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: H5O.c |
16 | | * |
17 | | * Purpose: Public object header routines |
18 | | * |
19 | | *------------------------------------------------------------------------- |
20 | | */ |
21 | | |
22 | | /****************/ |
23 | | /* Module Setup */ |
24 | | /****************/ |
25 | | |
26 | | #include "H5Omodule.h" /* This source code file is part of the H5O module */ |
27 | | |
28 | | /***********/ |
29 | | /* Headers */ |
30 | | /***********/ |
31 | | #include "H5private.h" /* Generic Functions */ |
32 | | #include "H5CXprivate.h" /* API Contexts */ |
33 | | #include "H5Eprivate.h" /* Error handling */ |
34 | | #include "H5ESprivate.h" /* Event Sets */ |
35 | | #include "H5Iprivate.h" /* IDs */ |
36 | | #include "H5Lprivate.h" /* Links */ |
37 | | #include "H5Opkg.h" /* Object headers */ |
38 | | |
39 | | #include "H5VLnative_private.h" /* Native VOL connector */ |
40 | | |
41 | | /****************/ |
42 | | /* Local Macros */ |
43 | | /****************/ |
44 | | |
45 | | /******************/ |
46 | | /* Local Typedefs */ |
47 | | /******************/ |
48 | | |
49 | | /********************/ |
50 | | /* Package Typedefs */ |
51 | | /********************/ |
52 | | |
53 | | /********************/ |
54 | | /* Local Prototypes */ |
55 | | /********************/ |
56 | | |
57 | | /* Helper routines for sync/async API calls */ |
58 | | static hid_t H5O__open_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token_ptr, |
59 | | H5VL_object_t **_vol_obj_ptr); |
60 | | static hid_t H5O__open_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type, |
61 | | H5_iter_order_t order, hsize_t n, hid_t lapl_id, void **token_ptr, |
62 | | H5VL_object_t **_vol_obj_ptr); |
63 | | static herr_t H5O__get_info_by_name_api_common(hid_t loc_id, const char *name, H5O_info2_t *oinfo /*out*/, |
64 | | unsigned fields, hid_t lapl_id, void **token_ptr, |
65 | | H5VL_object_t **_vol_obj_ptr); |
66 | | static herr_t H5O__copy_api_common(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, |
67 | | const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, void **token_ptr, |
68 | | H5VL_object_t **_vol_obj_ptr); |
69 | | static herr_t H5O__flush_api_common(hid_t obj_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); |
70 | | static herr_t H5O__refresh_api_common(hid_t oid, void **token_ptr, H5VL_object_t **_vol_obj_ptr); |
71 | | static htri_t H5O__close_check_type(hid_t object_id); |
72 | | |
73 | | /*********************/ |
74 | | /* Package Variables */ |
75 | | /*********************/ |
76 | | |
77 | | /*****************************/ |
78 | | /* Library Private Variables */ |
79 | | /*****************************/ |
80 | | |
81 | | /*******************/ |
82 | | /* Local Variables */ |
83 | | /*******************/ |
84 | | |
85 | | /*------------------------------------------------------------------------- |
86 | | * Function: H5O__open_api_common |
87 | | * |
88 | | * Purpose: This is the common function for opening an object |
89 | | * |
90 | | * Return: Success: An open object identifier |
91 | | * Failure: H5I_INVALID_HID |
92 | | * |
93 | | *------------------------------------------------------------------------- |
94 | | */ |
95 | | static hid_t |
96 | | H5O__open_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token_ptr, |
97 | | H5VL_object_t **_vol_obj_ptr) |
98 | 0 | { |
99 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
100 | 0 | H5VL_object_t **vol_obj_ptr = |
101 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
102 | 0 | H5I_type_t opened_type; |
103 | 0 | void *opened_obj = NULL; |
104 | 0 | H5VL_loc_params_t loc_params; |
105 | 0 | hid_t ret_value = H5I_INVALID_HID; |
106 | |
|
107 | 0 | FUNC_ENTER_PACKAGE |
108 | | |
109 | | /* Check args */ |
110 | | |
111 | | /* name is checked in this H5VL_setup_name_args() */ |
112 | | /* Set up object access arguments */ |
113 | 0 | if (H5VL_setup_name_args(loc_id, name, false, lapl_id, vol_obj_ptr, &loc_params) < 0) |
114 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments"); |
115 | | |
116 | | /* Open the object */ |
117 | 0 | if (NULL == (opened_obj = H5VL_object_open(*vol_obj_ptr, &loc_params, &opened_type, |
118 | 0 | H5P_DATASET_XFER_DEFAULT, token_ptr))) |
119 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); |
120 | | |
121 | | /* Get an atom for the object */ |
122 | 0 | if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) |
123 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle"); |
124 | | |
125 | 0 | done: |
126 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
127 | 0 | } /* H5O__open_api_common() */ |
128 | | |
129 | | /*------------------------------------------------------------------------- |
130 | | * Function: H5Oopen |
131 | | * |
132 | | * Purpose: Opens an object within an HDF5 file. |
133 | | * |
134 | | * This function opens an object in the same way that H5Gopen2, |
135 | | * H5Topen2, and H5Dopen2 do. However, H5Oopen doesn't require |
136 | | * the type of object to be known beforehand. This can be |
137 | | * useful in user-defined links, for instance, when only a |
138 | | * path is known. |
139 | | * |
140 | | * The opened object should be closed again with H5Oclose |
141 | | * or H5Gclose, H5Tclose, or H5Dclose. |
142 | | * |
143 | | * Return: Success: An open object identifier |
144 | | * |
145 | | * Failure: H5I_INVALID_HID |
146 | | * |
147 | | *------------------------------------------------------------------------- |
148 | | */ |
149 | | hid_t |
150 | | H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) |
151 | 0 | { |
152 | 0 | hid_t ret_value = H5I_INVALID_HID; |
153 | |
|
154 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
155 | | |
156 | | /* Open the object synchronously */ |
157 | 0 | if ((ret_value = H5O__open_api_common(loc_id, name, lapl_id, NULL, NULL)) < 0) |
158 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to synchronously open object"); |
159 | | |
160 | 0 | done: |
161 | 0 | FUNC_LEAVE_API(ret_value) |
162 | 0 | } /* end H5Oopen() */ |
163 | | |
164 | | /*------------------------------------------------------------------------- |
165 | | * Function: H5Oopen_async |
166 | | * |
167 | | * Purpose: Asynchronous version of H5Oopen |
168 | | * |
169 | | * Return: Success: An open object identifier |
170 | | * Failure: H5I_INVALID_HID |
171 | | * |
172 | | *------------------------------------------------------------------------- |
173 | | */ |
174 | | hid_t |
175 | | H5Oopen_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, const char *name, |
176 | | hid_t lapl_id, hid_t es_id) |
177 | 0 | { |
178 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
179 | 0 | void *token = NULL; /* Request token for async operation */ |
180 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
181 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
182 | |
|
183 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
184 | | |
185 | | /* Set up request token pointer for asynchronous operation */ |
186 | 0 | if (H5ES_NONE != es_id) |
187 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
188 | | |
189 | | /* Open the object asynchronously */ |
190 | 0 | if ((ret_value = H5O__open_api_common(loc_id, name, lapl_id, token_ptr, &vol_obj)) < 0) |
191 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to asynchronously open object"); |
192 | | |
193 | | /* If a token was created, add the token to the event set */ |
194 | 0 | if (NULL != token) |
195 | | /* clang-format off */ |
196 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
197 | 0 | H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id)) < 0) { |
198 | | /* clang-format on */ |
199 | 0 | if (H5I_dec_app_ref_always_close(ret_value) < 0) |
200 | 0 | HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID"); |
201 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); |
202 | 0 | } |
203 | | |
204 | 0 | done: |
205 | 0 | FUNC_LEAVE_API(ret_value) |
206 | 0 | } /* end H5Oopen_async() */ |
207 | | |
208 | | /*------------------------------------------------------------------------- |
209 | | * Function: H5O__open_by_idx_api_common |
210 | | * |
211 | | * Purpose: This is the common function for opening an object within an index |
212 | | * |
213 | | * Return: Success: An open object identifier |
214 | | * Failure: H5I_INVALID_HID |
215 | | * |
216 | | *------------------------------------------------------------------------- |
217 | | */ |
218 | | static hid_t |
219 | | H5O__open_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, |
220 | | hsize_t n, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
221 | 0 | { |
222 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
223 | 0 | H5VL_object_t **vol_obj_ptr = |
224 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
225 | 0 | H5I_type_t opened_type; |
226 | 0 | void *opened_obj = NULL; |
227 | 0 | H5VL_loc_params_t loc_params; |
228 | 0 | hid_t ret_value = H5I_INVALID_HID; |
229 | |
|
230 | 0 | FUNC_ENTER_PACKAGE |
231 | | |
232 | | /* Check args */ |
233 | | /* group_name, idx_type, order are checked in H5VL_setup_idx-args() */ |
234 | | /* Set up object access arguments */ |
235 | 0 | if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, false, lapl_id, vol_obj_ptr, |
236 | 0 | &loc_params) < 0) |
237 | 0 | HGOTO_ERROR(H5E_LINK, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments"); |
238 | | |
239 | | /* Open the object */ |
240 | 0 | if (NULL == (opened_obj = H5VL_object_open(*vol_obj_ptr, &loc_params, &opened_type, |
241 | 0 | H5P_DATASET_XFER_DEFAULT, token_ptr))) |
242 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); |
243 | | |
244 | | /* Get an ID for the object */ |
245 | 0 | if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) |
246 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); |
247 | | |
248 | 0 | done: |
249 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
250 | 0 | } /* H5O__open_by_idx_api_common() */ |
251 | | |
252 | | /*------------------------------------------------------------------------- |
253 | | * Function: H5Oopen_by_idx |
254 | | * |
255 | | * Purpose: Opens an object within an HDF5 file, according to the offset |
256 | | * within an index. |
257 | | * |
258 | | * This function opens an object in the same way that H5Gopen, |
259 | | * H5Topen, and H5Dopen do. However, H5Oopen doesn't require |
260 | | * the type of object to be known beforehand. This can be |
261 | | * useful in user-defined links, for instance, when only a |
262 | | * path is known. |
263 | | * |
264 | | * The opened object should be closed again with H5Oclose |
265 | | * or H5Gclose, H5Tclose, or H5Dclose. |
266 | | * |
267 | | * Return: Success: An open object identifier |
268 | | * Failure: H5I_INVALID_HID |
269 | | * |
270 | | *------------------------------------------------------------------------- |
271 | | */ |
272 | | hid_t |
273 | | H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, |
274 | | hid_t lapl_id) |
275 | 0 | { |
276 | 0 | hid_t ret_value = H5I_INVALID_HID; |
277 | |
|
278 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
279 | | |
280 | | /* Open the object synchronously */ |
281 | 0 | if ((ret_value = |
282 | 0 | H5O__open_by_idx_api_common(loc_id, group_name, idx_type, order, n, lapl_id, NULL, NULL)) < 0) |
283 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to synchronously open object"); |
284 | | |
285 | 0 | done: |
286 | 0 | FUNC_LEAVE_API(ret_value) |
287 | 0 | } /* end H5Oopen_by_idx() */ |
288 | | |
289 | | /*------------------------------------------------------------------------- |
290 | | * Function: H5Oopen_by_idx_async |
291 | | * |
292 | | * Purpose: Asynchronous version of H5Oopen_by_idx |
293 | | * |
294 | | * Return: Success: An open object identifier |
295 | | * Failure: H5I_INVALID_HID |
296 | | * |
297 | | *------------------------------------------------------------------------- |
298 | | */ |
299 | | hid_t |
300 | | H5Oopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, |
301 | | const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, |
302 | | hid_t lapl_id, hid_t es_id) |
303 | 0 | { |
304 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
305 | 0 | void *token = NULL; /* Request token for async operation */ |
306 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
307 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
308 | |
|
309 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
310 | | |
311 | | /* Set up request token pointer for asynchronous operation */ |
312 | 0 | if (H5ES_NONE != es_id) |
313 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
314 | | |
315 | | /* Open the object asynchronously */ |
316 | 0 | if ((ret_value = H5O__open_by_idx_api_common(loc_id, group_name, idx_type, order, n, lapl_id, token_ptr, |
317 | 0 | &vol_obj)) < 0) |
318 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to asynchronously open object"); |
319 | | |
320 | | /* If a token was created, add the token to the event set */ |
321 | 0 | if (NULL != token) |
322 | | /* clang-format off */ |
323 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
324 | 0 | H5ARG_TRACE10(__func__, "*s*sIui*sIiIohii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, lapl_id, es_id)) < 0) { |
325 | | /* clang-format on */ |
326 | 0 | if (H5I_dec_app_ref_always_close(ret_value) < 0) |
327 | 0 | HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID"); |
328 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); |
329 | 0 | } |
330 | | |
331 | 0 | done: |
332 | 0 | FUNC_LEAVE_API(ret_value) |
333 | 0 | } /* end H5Oopen_by_idx_async() */ |
334 | | |
335 | | /*------------------------------------------------------------------------- |
336 | | * Function: H5Oopen_by_token |
337 | | * |
338 | | * Purpose: Same as H5Oopen_by_addr, but uses VOL-independent tokens. |
339 | | * |
340 | | * Return: Success: An open object identifier |
341 | | * Failure: H5I_INVALID_HID |
342 | | * |
343 | | *------------------------------------------------------------------------- |
344 | | */ |
345 | | hid_t |
346 | | H5Oopen_by_token(hid_t loc_id, H5O_token_t token) |
347 | 0 | { |
348 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
349 | 0 | H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ |
350 | 0 | H5I_type_t opened_type; /* Opened object type */ |
351 | 0 | void *opened_obj = NULL; /* Opened object */ |
352 | 0 | H5VL_loc_params_t loc_params; /* Location parameters */ |
353 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
354 | |
|
355 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
356 | | |
357 | | /* Check args */ |
358 | 0 | if (H5O_IS_TOKEN_UNDEF(token)) |
359 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "can't open H5O_TOKEN_UNDEF"); |
360 | | |
361 | | /* Get the location object */ |
362 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
363 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier"); |
364 | | |
365 | | /* Get object type */ |
366 | 0 | if ((vol_obj_type = H5I_get_type(loc_id)) < 0) |
367 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier"); |
368 | | |
369 | 0 | loc_params.type = H5VL_OBJECT_BY_TOKEN; |
370 | 0 | loc_params.loc_data.loc_by_token.token = &token; |
371 | 0 | loc_params.obj_type = vol_obj_type; |
372 | | |
373 | | /* Open the object */ |
374 | 0 | if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, |
375 | 0 | H5_REQUEST_NULL))) |
376 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); |
377 | | |
378 | | /* Register the object's ID */ |
379 | 0 | if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) |
380 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); |
381 | | |
382 | 0 | done: |
383 | 0 | FUNC_LEAVE_API(ret_value) |
384 | 0 | } /* end H5Oopen_by_token() */ |
385 | | |
386 | | /*------------------------------------------------------------------------- |
387 | | * Function: H5O__copy_api_common |
388 | | * |
389 | | * Purpose: This is the common function for copying an object. |
390 | | * |
391 | | * Return: SUCCEED/FAIL |
392 | | * |
393 | | *------------------------------------------------------------------------- |
394 | | */ |
395 | | static herr_t |
396 | | H5O__copy_api_common(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, |
397 | | hid_t ocpypl_id, hid_t lcpl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
398 | 0 | { |
399 | | /* dst_id */ |
400 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
401 | 0 | H5VL_object_t **vol_obj_ptr = |
402 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
403 | 0 | H5VL_loc_params_t loc_params2; |
404 | | |
405 | | /* src_id */ |
406 | 0 | H5VL_object_t *vol_obj1 = NULL; /* object of src_id */ |
407 | 0 | H5VL_loc_params_t loc_params1; |
408 | |
|
409 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
410 | |
|
411 | 0 | FUNC_ENTER_PACKAGE |
412 | | |
413 | | /* Check arguments */ |
414 | 0 | if (!src_name || !*src_name) |
415 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified"); |
416 | 0 | if (!dst_name || !*dst_name) |
417 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified"); |
418 | | |
419 | | /* Get correct property lists */ |
420 | 0 | if (H5P_DEFAULT == lcpl_id) |
421 | 0 | lcpl_id = H5P_LINK_CREATE_DEFAULT; |
422 | 0 | else if (true != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) |
423 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list"); |
424 | | |
425 | | /* Get object copy property list */ |
426 | 0 | if (H5P_DEFAULT == ocpypl_id) |
427 | 0 | ocpypl_id = H5P_OBJECT_COPY_DEFAULT; |
428 | 0 | else if (true != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) |
429 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list"); |
430 | | |
431 | | /* Set the LCPL for the API context */ |
432 | 0 | H5CX_set_lcpl(lcpl_id); |
433 | | |
434 | | /* Setup and check args */ |
435 | 0 | if (H5VL_setup_loc_args(src_loc_id, &vol_obj1, &loc_params1) < 0) |
436 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments"); |
437 | | |
438 | | /* get the object */ |
439 | 0 | if (NULL == (*vol_obj_ptr = H5VL_vol_object(dst_loc_id))) |
440 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
441 | 0 | loc_params2.type = H5VL_OBJECT_BY_SELF; |
442 | 0 | loc_params2.obj_type = H5I_get_type(dst_loc_id); |
443 | | |
444 | | /* Copy the object */ |
445 | 0 | if (H5VL_object_copy(vol_obj1, &loc_params1, src_name, *vol_obj_ptr, &loc_params2, dst_name, ocpypl_id, |
446 | 0 | lcpl_id, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) |
447 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object"); |
448 | | |
449 | 0 | done: |
450 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
451 | 0 | } /* H5O__copy_api_common() */ |
452 | | |
453 | | /*------------------------------------------------------------------------- |
454 | | * Function: H5Ocopy |
455 | | * |
456 | | * Purpose: Copy an object (group or dataset) to destination location |
457 | | * within a file or cross files. PLIST_ID is a property list |
458 | | * which is used to pass user options and properties to the |
459 | | * copy. The name, dst_name, must not already be taken by some |
460 | | * other object in the destination group. |
461 | | * |
462 | | * H5Ocopy() will fail if the name of the destination object |
463 | | * exists in the destination group. For example, |
464 | | * H5Ocopy(fid_src, "/dset", fid_dst, "/dset", ...) |
465 | | * will fail if "/dset" exists in the destination file |
466 | | * |
467 | | * OPTIONS THAT HAVE BEEN IMPLEMENTED. |
468 | | * H5O_COPY_SHALLOW_HIERARCHY_FLAG |
469 | | * If this flag is specified, only immediate members of |
470 | | * the group are copied. Otherwise (default), it will |
471 | | * recursively copy all objects below the group |
472 | | * H5O_COPY_EXPAND_SOFT_LINK_FLAG |
473 | | * If this flag is specified, it will copy the objects |
474 | | * pointed by the soft links. Otherwise (default), it |
475 | | * will copy the soft link as they are |
476 | | * H5O_COPY_WITHOUT_ATTR_FLAG |
477 | | * If this flag is specified, it will copy object without |
478 | | * copying attributes. Otherwise (default), it will |
479 | | * copy object along with all its attributes |
480 | | * H5O_COPY_EXPAND_REFERENCE_FLAG |
481 | | * 1) Copy object between two different files: |
482 | | * When this flag is specified, it will copy objects that |
483 | | * are pointed by the references and update the values of |
484 | | * references in the destination file. Otherwise (default) |
485 | | * the values of references in the destination will set to |
486 | | * zero |
487 | | * The current implementation does not handle references |
488 | | * inside of other datatype structure. For example, if |
489 | | * a member of compound datatype is reference, H5Ocopy() |
490 | | * will copy that field as it is. It will not set the |
491 | | * value to zero as default is used nor copy the object |
492 | | * pointed by that field the flag is set |
493 | | * 2) Copy object within the same file: |
494 | | * This flag does not have any effect to the H5Ocopy(). |
495 | | * Datasets or attributes of references are copied as they |
496 | | * are, i.e. values of references of the destination object |
497 | | * are the same as the values of the source object |
498 | | * |
499 | | * OPTIONS THAT MAY APPLY TO COPY IN THE FUTURE. |
500 | | * H5O_COPY_EXPAND_EXT_LINK_FLAG |
501 | | * If this flag is specified, it will expand the external links |
502 | | * into new objects, Otherwise (default), it will keep external |
503 | | * links as they are (default) |
504 | | * |
505 | | * PROPERTIES THAT MAY APPLY TO COPY IN FUTURE |
506 | | * Change data layout such as chunk size |
507 | | * Add filter such as data compression. |
508 | | * Add an attribute to the copied object(s) that say the date/time |
509 | | * for the copy or other information about the source file. |
510 | | * |
511 | | * The intermediate group creation property should be passed in |
512 | | * using the lcpl instead of the ocpypl. |
513 | | * |
514 | | * Usage: H5Ocopy(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id) |
515 | | * hid_t src_loc_id IN: Source file or group identifier. |
516 | | * const char *src_name IN: Name of the source object to be copied |
517 | | * hid_t dst_loc_id IN: Destination file or group identifier |
518 | | * const char *dst_name IN: Name of the destination object |
519 | | * hid_t ocpypl_id IN: Properties which apply to the copy |
520 | | * hid_t lcpl_id IN: Properties which apply to the new hard link |
521 | | * |
522 | | * |
523 | | * Return: SUCCEED/FAIL |
524 | | * |
525 | | *------------------------------------------------------------------------- |
526 | | */ |
527 | | herr_t |
528 | | H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, |
529 | | hid_t lcpl_id) |
530 | 0 | { |
531 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
532 | |
|
533 | 0 | FUNC_ENTER_API(FAIL) |
534 | | |
535 | | /* To copy an object synchronously */ |
536 | 0 | if (H5O__copy_api_common(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, NULL, NULL) < 0) |
537 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to synchronously copy object"); |
538 | | |
539 | 0 | done: |
540 | 0 | FUNC_LEAVE_API(ret_value) |
541 | 0 | } /* end H5Ocopy() */ |
542 | | |
543 | | /*------------------------------------------------------------------------- |
544 | | * Function: H5Ocopy_async |
545 | | * |
546 | | * Purpose: Asynchronous version of H5Ocopy |
547 | | * |
548 | | * Return: SUCCEED/FAIL |
549 | | * |
550 | | *------------------------------------------------------------------------- |
551 | | */ |
552 | | herr_t |
553 | | H5Ocopy_async(const char *app_file, const char *app_func, unsigned app_line, hid_t src_loc_id, |
554 | | const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, |
555 | | hid_t es_id) |
556 | 0 | { |
557 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
558 | 0 | void *token = NULL; /* Request token for async operation */ |
559 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
560 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
561 | |
|
562 | 0 | FUNC_ENTER_API(FAIL) |
563 | | |
564 | | /* Set up request token pointer for asynchronous operation */ |
565 | 0 | if (H5ES_NONE != es_id) |
566 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
567 | | |
568 | | /* To copy an object asynchronously */ |
569 | 0 | if (H5O__copy_api_common(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, token_ptr, |
570 | 0 | &vol_obj) < 0) |
571 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to asynchronously copy object"); |
572 | | |
573 | | /* If a token was created, add the token to the event set */ |
574 | 0 | if (NULL != token) |
575 | | /* clang-format off */ |
576 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
577 | 0 | H5ARG_TRACE10(__func__, "*s*sIui*si*siii", app_file, app_func, app_line, src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, es_id)) < 0) |
578 | | /* clang-format on */ |
579 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
580 | | |
581 | 0 | done: |
582 | 0 | FUNC_LEAVE_API(ret_value) |
583 | 0 | } /* H5Ocopy_async() */ |
584 | | |
585 | | /*------------------------------------------------------------------------- |
586 | | * Function: H5O__flush_api_common |
587 | | * |
588 | | * Purpose: This is the common function for flushing an object. |
589 | | * |
590 | | * Return: SUCCEED/FAIL |
591 | | * |
592 | | *------------------------------------------------------------------------- |
593 | | */ |
594 | | static herr_t |
595 | | H5O__flush_api_common(hid_t obj_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
596 | 0 | { |
597 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
598 | 0 | H5VL_object_t **vol_obj_ptr = |
599 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
600 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
601 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
602 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
603 | |
|
604 | 0 | FUNC_ENTER_PACKAGE |
605 | | |
606 | | /* Setup and check args */ |
607 | 0 | if (H5VL_setup_loc_args(obj_id, vol_obj_ptr, &loc_params) < 0) |
608 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments"); |
609 | | |
610 | | /* Set up VOL callback arguments */ |
611 | 0 | vol_cb_args.op_type = H5VL_OBJECT_FLUSH; |
612 | 0 | vol_cb_args.args.flush.obj_id = obj_id; |
613 | | |
614 | | /* Flush the object */ |
615 | 0 | if (H5VL_object_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < |
616 | 0 | 0) |
617 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object"); |
618 | | |
619 | 0 | done: |
620 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
621 | 0 | } /* H5O__flush_api_common() */ |
622 | | |
623 | | /*------------------------------------------------------------------------- |
624 | | * Function: H5Oflush |
625 | | * |
626 | | * Purpose: Flushes all buffers associated with an object to disk. |
627 | | * |
628 | | * Return: Non-negative on success, negative on failure |
629 | | * |
630 | | *------------------------------------------------------------------------- |
631 | | */ |
632 | | herr_t |
633 | | H5Oflush(hid_t obj_id) |
634 | 0 | { |
635 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
636 | |
|
637 | 0 | FUNC_ENTER_API(FAIL) |
638 | | |
639 | | /* To flush an object synchronously */ |
640 | 0 | if (H5O__flush_api_common(obj_id, NULL, NULL) < 0) |
641 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to synchronously flush object"); |
642 | | |
643 | 0 | done: |
644 | 0 | FUNC_LEAVE_API(ret_value) |
645 | 0 | } /* end H5Oflush() */ |
646 | | |
647 | | /*------------------------------------------------------------------------- |
648 | | * Function: H5Oflush_async |
649 | | * |
650 | | * Purpose: Asynchronous version of H5Oflush |
651 | | * |
652 | | * Return: SUCCEED/FAIL |
653 | | * |
654 | | *------------------------------------------------------------------------- |
655 | | */ |
656 | | herr_t |
657 | | H5Oflush_async(const char *app_file, const char *app_func, unsigned app_line, hid_t obj_id, hid_t es_id) |
658 | 0 | { |
659 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
660 | 0 | void *token = NULL; /* Request token for async operation */ |
661 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
662 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
663 | |
|
664 | 0 | FUNC_ENTER_API(FAIL) |
665 | | |
666 | | /* Set up request token pointer for asynchronous operation */ |
667 | 0 | if (H5ES_NONE != es_id) |
668 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
669 | | |
670 | | /* Flush an object asynchronously */ |
671 | 0 | if (H5O__flush_api_common(obj_id, token_ptr, &vol_obj) < 0) |
672 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to asynchronously flush object"); |
673 | | |
674 | | /* If a token was created, add the token to the event set */ |
675 | 0 | if (NULL != token) |
676 | | /* clang-format off */ |
677 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
678 | 0 | H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, obj_id, es_id)) < 0) |
679 | | /* clang-format on */ |
680 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
681 | | |
682 | 0 | done: |
683 | 0 | FUNC_LEAVE_API(ret_value) |
684 | 0 | } /* H5Oflush_async() */ |
685 | | |
686 | | /*------------------------------------------------------------------------- |
687 | | * Function: H5O__refresh_api_common |
688 | | * |
689 | | * Purpose: This is the common function for refreshing an object. |
690 | | * |
691 | | * Return: SUCCEED/FAIL |
692 | | * |
693 | | *------------------------------------------------------------------------- |
694 | | */ |
695 | | static herr_t |
696 | | H5O__refresh_api_common(hid_t oid, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
697 | 0 | { |
698 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
699 | 0 | H5VL_object_t **vol_obj_ptr = |
700 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
701 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
702 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
703 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
704 | |
|
705 | 0 | FUNC_ENTER_PACKAGE |
706 | | |
707 | | /* Setup and check args */ |
708 | 0 | if (H5VL_setup_loc_args(oid, vol_obj_ptr, &loc_params) < 0) |
709 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments"); |
710 | | |
711 | | /* Set up VOL callback arguments */ |
712 | 0 | vol_cb_args.op_type = H5VL_OBJECT_REFRESH; |
713 | 0 | vol_cb_args.args.refresh.obj_id = oid; |
714 | | |
715 | | /* Refresh the object */ |
716 | 0 | if (H5VL_object_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < |
717 | 0 | 0) |
718 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object"); |
719 | | |
720 | 0 | done: |
721 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
722 | 0 | } /* H5O__refresh_api_common() */ |
723 | | |
724 | | /*------------------------------------------------------------------------- |
725 | | * Function: H5Orefresh |
726 | | * |
727 | | * Purpose: Refreshes all buffers associated with an object. |
728 | | * |
729 | | * Return: Non-negative on success, negative on failure |
730 | | * |
731 | | *------------------------------------------------------------------------- |
732 | | */ |
733 | | herr_t |
734 | | H5Orefresh(hid_t oid) |
735 | 0 | { |
736 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
737 | |
|
738 | 0 | FUNC_ENTER_API(FAIL) |
739 | | |
740 | | /* To refresh an object synchronously */ |
741 | 0 | if (H5O__refresh_api_common(oid, NULL, NULL) < 0) |
742 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to synchronously refresh object"); |
743 | | |
744 | 0 | done: |
745 | 0 | FUNC_LEAVE_API(ret_value) |
746 | 0 | } /* end H5Orefresh() */ |
747 | | |
748 | | /*------------------------------------------------------------------------- |
749 | | * Function: H5Orefresh_async |
750 | | * |
751 | | * Purpose: Asynchronous version of H5Orefresh |
752 | | * |
753 | | * Return: SUCCEED/FAIL |
754 | | * |
755 | | *------------------------------------------------------------------------- |
756 | | */ |
757 | | herr_t |
758 | | H5Orefresh_async(const char *app_file, const char *app_func, unsigned app_line, hid_t oid, hid_t es_id) |
759 | 0 | { |
760 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
761 | 0 | void *token = NULL; /* Request token for async operation */ |
762 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
763 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
764 | |
|
765 | 0 | FUNC_ENTER_API(FAIL) |
766 | | |
767 | | /* Set up request token pointer for asynchronous operation */ |
768 | 0 | if (H5ES_NONE != es_id) |
769 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
770 | | |
771 | | /* Refresh an object asynchronously */ |
772 | 0 | if (H5O__refresh_api_common(oid, token_ptr, &vol_obj) < 0) |
773 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to asynchronously refresh object"); |
774 | | |
775 | | /* If a token was created, add the token to the event set */ |
776 | 0 | if (NULL != token) |
777 | | /* clang-format off */ |
778 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
779 | 0 | H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, oid, es_id)) < 0) |
780 | | /* clang-format on */ |
781 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
782 | | |
783 | 0 | done: |
784 | 0 | FUNC_LEAVE_API(ret_value) |
785 | 0 | } /* H5Orefresh_async() */ |
786 | | |
787 | | /*------------------------------------------------------------------------- |
788 | | * Function: H5Olink |
789 | | * |
790 | | * Purpose: Creates a hard link from NEW_NAME to the object specified |
791 | | * by OBJ_ID using properties defined in the Link Creation |
792 | | * Property List LCPL. |
793 | | * |
794 | | * This function should be used to link objects that have just |
795 | | * been created. |
796 | | * |
797 | | * NEW_NAME is interpreted relative to |
798 | | * NEW_LOC_ID, which is either a file ID or a |
799 | | * group ID. |
800 | | * |
801 | | * Return: Non-negative on success/Negative on failure |
802 | | * |
803 | | *------------------------------------------------------------------------- |
804 | | */ |
805 | | herr_t |
806 | | H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) |
807 | 0 | { |
808 | 0 | H5VL_object_t *vol_obj1 = NULL; /* object of obj_id */ |
809 | 0 | H5VL_object_t *vol_obj2 = NULL; /* object of new_loc_id */ |
810 | 0 | H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ |
811 | 0 | H5VL_loc_params_t new_loc_params; |
812 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
813 | |
|
814 | 0 | FUNC_ENTER_API(FAIL) |
815 | | |
816 | | /* Check arguments */ |
817 | 0 | if (new_loc_id == H5L_SAME_LOC) |
818 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, |
819 | 0 | "cannot use H5L_SAME_LOC when only one location is specified"); |
820 | 0 | if (!new_name || !*new_name) |
821 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); |
822 | | /* Avoid compiler warning on 32-bit machines */ |
823 | 0 | #if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T |
824 | 0 | if (strlen(new_name) > H5L_MAX_LINK_NAME_LEN) |
825 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "name too long"); |
826 | 0 | #endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ |
827 | 0 | if (lcpl_id != H5P_DEFAULT && (true != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) |
828 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list"); |
829 | | |
830 | | /* Get the link creation property list */ |
831 | 0 | if (H5P_DEFAULT == lcpl_id) |
832 | 0 | lcpl_id = H5P_LINK_CREATE_DEFAULT; |
833 | | |
834 | | /* Set the LCPL for the API context */ |
835 | 0 | H5CX_set_lcpl(lcpl_id); |
836 | | |
837 | | /* Verify access property list and set up collective metadata if appropriate */ |
838 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, true) < 0) |
839 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
840 | | |
841 | | /* Set up new location struct */ |
842 | 0 | new_loc_params.type = H5VL_OBJECT_BY_NAME; |
843 | 0 | new_loc_params.obj_type = H5I_get_type(new_loc_id); |
844 | 0 | new_loc_params.loc_data.loc_by_name.name = new_name; |
845 | 0 | new_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
846 | | |
847 | | /* Get the first location object */ |
848 | 0 | if (NULL == (vol_obj1 = H5VL_vol_object(obj_id))) |
849 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
850 | 0 | if (H5L_SAME_LOC != new_loc_id) |
851 | | /* get the location object */ |
852 | 0 | if (NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) |
853 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
854 | | |
855 | | /* Make sure that the VOL connectors are the same */ |
856 | 0 | if (vol_obj1 && vol_obj2) { |
857 | 0 | htri_t same_connector; |
858 | | |
859 | | /* Check if both objects are associated with the same VOL connector */ |
860 | 0 | if ((same_connector = |
861 | 0 | H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(vol_obj1), H5VL_OBJ_CONNECTOR(vol_obj2))) < 0) |
862 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); |
863 | 0 | if (!same_connector) |
864 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, |
865 | 0 | "Objects are accessed through different VOL connectors and can't be linked"); |
866 | 0 | } /* end if */ |
867 | | |
868 | | /* Set up VOL callback arguments */ |
869 | 0 | vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; |
870 | 0 | vol_cb_args.args.hard.curr_obj = H5VL_OBJ_DATA(vol_obj1); |
871 | 0 | vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_SELF; |
872 | 0 | vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(obj_id); |
873 | | |
874 | | /* Create a link to the object */ |
875 | 0 | if (H5VL_link_create(&vol_cb_args, vol_obj2, &new_loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, |
876 | 0 | H5_REQUEST_NULL) < 0) |
877 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link"); |
878 | | |
879 | 0 | done: |
880 | 0 | FUNC_LEAVE_API(ret_value) |
881 | 0 | } /* end H5Olink() */ |
882 | | |
883 | | /*------------------------------------------------------------------------- |
884 | | * Function: H5Oincr_refcount |
885 | | * |
886 | | * Purpose: Warning! This function is EXTREMELY DANGEROUS! |
887 | | * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, |
888 | | * and other VERY BAD THINGS! |
889 | | * |
890 | | * This function increments the "hard link" reference count |
891 | | * for an object. It should be used when a user-defined link |
892 | | * that references an object by address is created. When the |
893 | | * link is deleted, H5Odecr_refcount should be used. |
894 | | * |
895 | | * Return: Success: Non-negative |
896 | | * Failure: Negative |
897 | | * |
898 | | *------------------------------------------------------------------------- |
899 | | */ |
900 | | herr_t |
901 | | H5Oincr_refcount(hid_t object_id) |
902 | 0 | { |
903 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
904 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
905 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
906 | 0 | herr_t ret_value = SUCCEED; |
907 | |
|
908 | 0 | FUNC_ENTER_API(FAIL) |
909 | |
|
910 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
911 | 0 | loc_params.obj_type = H5I_get_type(object_id); |
912 | | |
913 | | /* Get the location object */ |
914 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
915 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
916 | | |
917 | | /* Set up collective metadata if appropriate */ |
918 | 0 | if (H5CX_set_loc(object_id) < 0) |
919 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
920 | | |
921 | | /* Set up VOL callback arguments */ |
922 | 0 | vol_cb_args.op_type = H5VL_OBJECT_CHANGE_REF_COUNT; |
923 | 0 | vol_cb_args.args.change_rc.delta = 1; |
924 | | |
925 | | /* Change the object's reference count */ |
926 | 0 | if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
927 | 0 | 0) |
928 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed"); |
929 | | |
930 | 0 | done: |
931 | 0 | FUNC_LEAVE_API(ret_value) |
932 | 0 | } /* end H5O_incr_refcount() */ |
933 | | |
934 | | /*------------------------------------------------------------------------- |
935 | | * Function: H5Odecr_refcount |
936 | | * |
937 | | * Purpose: Warning! This function is EXTREMELY DANGEROUS! |
938 | | * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, |
939 | | * and other VERY BAD THINGS! |
940 | | * |
941 | | * This function decrements the "hard link" reference count |
942 | | * for an object. It should be used when user-defined links |
943 | | * that reference an object by address are deleted, and only |
944 | | * after H5Oincr_refcount has already been used. |
945 | | * |
946 | | * Return: Success: Non-negative |
947 | | * Failure: Negative |
948 | | * |
949 | | *------------------------------------------------------------------------- |
950 | | */ |
951 | | herr_t |
952 | | H5Odecr_refcount(hid_t object_id) |
953 | 0 | { |
954 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
955 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
956 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
957 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
958 | |
|
959 | 0 | FUNC_ENTER_API(FAIL) |
960 | |
|
961 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
962 | 0 | loc_params.obj_type = H5I_get_type(object_id); |
963 | | |
964 | | /* Get the location object */ |
965 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
966 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
967 | | |
968 | | /* Set up collective metadata if appropriate */ |
969 | 0 | if (H5CX_set_loc(object_id) < 0) |
970 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
971 | | |
972 | | /* Set up VOL callback arguments */ |
973 | 0 | vol_cb_args.op_type = H5VL_OBJECT_CHANGE_REF_COUNT; |
974 | 0 | vol_cb_args.args.change_rc.delta = -1; |
975 | | |
976 | | /* Change the object's reference count */ |
977 | 0 | if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
978 | 0 | 0) |
979 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed"); |
980 | | |
981 | 0 | done: |
982 | 0 | FUNC_LEAVE_API(ret_value) |
983 | 0 | } /* end H5Odecr_refcount() */ |
984 | | |
985 | | /*------------------------------------------------------------------------- |
986 | | * Function: H5Oexists_by_name |
987 | | * |
988 | | * Purpose: Determine if a linked-to object exists |
989 | | * |
990 | | * Return: Success: true/false |
991 | | * Failure: FAIL |
992 | | * |
993 | | *------------------------------------------------------------------------- |
994 | | */ |
995 | | htri_t |
996 | | H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) |
997 | 0 | { |
998 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
999 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
1000 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
1001 | 0 | bool obj_exists = false; /* Whether object exists */ |
1002 | 0 | htri_t ret_value = FAIL; /* Return value */ |
1003 | |
|
1004 | 0 | FUNC_ENTER_API(FAIL) |
1005 | | |
1006 | | /* Check args */ |
1007 | 0 | if (!name) |
1008 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL"); |
1009 | 0 | if (!*name) |
1010 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string"); |
1011 | | |
1012 | | /* Verify access property list and set up collective metadata if appropriate */ |
1013 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1014 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1015 | | |
1016 | | /* Get the location object */ |
1017 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1018 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1019 | | |
1020 | | /* Set the location struct fields */ |
1021 | 0 | loc_params.type = H5VL_OBJECT_BY_NAME; |
1022 | 0 | loc_params.loc_data.loc_by_name.name = name; |
1023 | 0 | loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
1024 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1025 | | |
1026 | | /* Set up VOL callback arguments */ |
1027 | 0 | vol_cb_args.op_type = H5VL_OBJECT_EXISTS; |
1028 | 0 | vol_cb_args.args.exists.exists = &obj_exists; |
1029 | | |
1030 | | /* Check if the object exists */ |
1031 | 0 | if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1032 | 0 | 0) |
1033 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name); |
1034 | | |
1035 | | /* Set return value */ |
1036 | 0 | ret_value = (htri_t)obj_exists; |
1037 | |
|
1038 | 0 | done: |
1039 | 0 | FUNC_LEAVE_API(ret_value) |
1040 | 0 | } /* end H5Oexists_by_name() */ |
1041 | | |
1042 | | /*------------------------------------------------------------------------- |
1043 | | * Function: H5Oget_info3 |
1044 | | * |
1045 | | * Purpose: Retrieve information about an object. |
1046 | | * |
1047 | | * Return: SUCCEED/FAIL |
1048 | | * |
1049 | | *------------------------------------------------------------------------- |
1050 | | */ |
1051 | | herr_t |
1052 | | H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo /*out*/, unsigned fields) |
1053 | 0 | { |
1054 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1055 | 0 | H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
1056 | 0 | H5VL_loc_params_t loc_params; |
1057 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1058 | |
|
1059 | 0 | FUNC_ENTER_API(FAIL) |
1060 | | |
1061 | | /* Check args */ |
1062 | 0 | if (!oinfo) |
1063 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL"); |
1064 | 0 | if (fields & ~H5O_INFO_ALL) |
1065 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1066 | | |
1067 | | /* Set location struct fields */ |
1068 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
1069 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1070 | | |
1071 | | /* Get the location object */ |
1072 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1073 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1074 | | |
1075 | | /* Set up VOL callback arguments */ |
1076 | 0 | vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; |
1077 | 0 | vol_cb_args.args.get_info.oinfo = oinfo; |
1078 | 0 | vol_cb_args.args.get_info.fields = fields; |
1079 | | |
1080 | | /* Retrieve the object's information */ |
1081 | 0 | if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
1082 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object"); |
1083 | | |
1084 | 0 | done: |
1085 | 0 | FUNC_LEAVE_API(ret_value) |
1086 | 0 | } /* end H5Oget_info3() */ |
1087 | | |
1088 | | /*------------------------------------------------------------------------- |
1089 | | * Function: H5O__get_info_by_name_api_common |
1090 | | * |
1091 | | * Purpose: This is the common function for retrieving information |
1092 | | * about an object. |
1093 | | * |
1094 | | * Return: SUCCEED/FAIL |
1095 | | * |
1096 | | *------------------------------------------------------------------------- |
1097 | | */ |
1098 | | static herr_t |
1099 | | H5O__get_info_by_name_api_common(hid_t loc_id, const char *name, H5O_info2_t *oinfo /*out*/, unsigned fields, |
1100 | | hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
1101 | 0 | { |
1102 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
1103 | 0 | H5VL_object_t **vol_obj_ptr = |
1104 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
1105 | 0 | H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
1106 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
1107 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1108 | |
|
1109 | 0 | FUNC_ENTER_PACKAGE |
1110 | | |
1111 | | /* Check args */ |
1112 | 0 | if (!oinfo) |
1113 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL"); |
1114 | 0 | if (fields & ~H5O_INFO_ALL) |
1115 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1116 | | |
1117 | | /* "name" is checked in H5VL_setup_name_args() */ |
1118 | | /* Set up object access arguments */ |
1119 | 0 | if (H5VL_setup_name_args(loc_id, name, false, lapl_id, vol_obj_ptr, &loc_params) < 0) |
1120 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments"); |
1121 | | |
1122 | | /* Set up VOL callback arguments */ |
1123 | 0 | vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; |
1124 | 0 | vol_cb_args.args.get_info.oinfo = oinfo; |
1125 | 0 | vol_cb_args.args.get_info.fields = fields; |
1126 | | |
1127 | | /* Retrieve the object's information */ |
1128 | 0 | if (H5VL_object_get(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) |
1129 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object"); |
1130 | | |
1131 | 0 | done: |
1132 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1133 | 0 | } /* H5O__get_info_by_name_api_common() */ |
1134 | | |
1135 | | /*------------------------------------------------------------------------- |
1136 | | * Function: H5Oget_info_by_name3 |
1137 | | * |
1138 | | * Purpose: Retrieve information about an object |
1139 | | * |
1140 | | * Return: SUCCEED/FAIL |
1141 | | * |
1142 | | *------------------------------------------------------------------------- |
1143 | | */ |
1144 | | herr_t |
1145 | | H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo /*out*/, unsigned fields, |
1146 | | hid_t lapl_id) |
1147 | 0 | { |
1148 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1149 | |
|
1150 | 0 | FUNC_ENTER_API(FAIL) |
1151 | | |
1152 | | /* Retrieve object information synchronously */ |
1153 | 0 | if (H5O__get_info_by_name_api_common(loc_id, name, oinfo, fields, lapl_id, NULL, NULL) < 0) |
1154 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't synchronously retrieve object info"); |
1155 | | |
1156 | 0 | done: |
1157 | 0 | FUNC_LEAVE_API(ret_value) |
1158 | 0 | } /* end H5Oget_info_by_name3() */ |
1159 | | |
1160 | | /*------------------------------------------------------------------------- |
1161 | | * Function: H5Oget_info_by_name_async |
1162 | | * |
1163 | | * Purpose: Asynchronous version of H5Oget_info_by_name3 |
1164 | | * |
1165 | | * Return: SUCCEED/FAIL |
1166 | | * |
1167 | | *------------------------------------------------------------------------- |
1168 | | */ |
1169 | | herr_t |
1170 | | H5Oget_info_by_name_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, |
1171 | | const char *name, H5O_info2_t *oinfo /*out*/, unsigned fields, hid_t lapl_id, |
1172 | | hid_t es_id) |
1173 | 0 | { |
1174 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
1175 | 0 | void *token = NULL; /* Request token for async operation */ |
1176 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
1177 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1178 | |
|
1179 | 0 | FUNC_ENTER_API(FAIL) |
1180 | | |
1181 | | /* Set up request token pointer for asynchronous operation */ |
1182 | 0 | if (H5ES_NONE != es_id) |
1183 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
1184 | | |
1185 | | /* Retrieve group information asynchronously */ |
1186 | 0 | if (H5O__get_info_by_name_api_common(loc_id, name, oinfo, fields, lapl_id, token_ptr, &vol_obj) < 0) |
1187 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't asynchronously retrieve object info"); |
1188 | | |
1189 | | /* If a token was created, add the token to the event set */ |
1190 | 0 | if (NULL != token) |
1191 | | /* clang-format off */ |
1192 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
1193 | 0 | H5ARG_TRACE9(__func__, "*s*sIui*s*!Iuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, es_id)) < 0) |
1194 | | /* clang-format on */ |
1195 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
1196 | | |
1197 | 0 | done: |
1198 | 0 | FUNC_LEAVE_API(ret_value) |
1199 | 0 | } /* H5Oget_info_by_name_async() */ |
1200 | | |
1201 | | /*------------------------------------------------------------------------- |
1202 | | * Function: H5Oget_info_by_idx3 |
1203 | | * |
1204 | | * Purpose: Retrieve information about an object, according to |
1205 | | * the order of an index. |
1206 | | * |
1207 | | * Return: Success: Non-negative |
1208 | | * Failure: Negative |
1209 | | * |
1210 | | *------------------------------------------------------------------------- |
1211 | | */ |
1212 | | herr_t |
1213 | | H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, |
1214 | | hsize_t n, H5O_info2_t *oinfo /*out*/, unsigned fields, hid_t lapl_id) |
1215 | 0 | { |
1216 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1217 | 0 | H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
1218 | 0 | H5VL_loc_params_t loc_params; |
1219 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1220 | |
|
1221 | 0 | FUNC_ENTER_API(FAIL) |
1222 | | |
1223 | | /* Check args */ |
1224 | 0 | if (!group_name || !*group_name) |
1225 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); |
1226 | 0 | if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) |
1227 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified"); |
1228 | 0 | if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) |
1229 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified"); |
1230 | 0 | if (!oinfo) |
1231 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct"); |
1232 | 0 | if (fields & ~H5O_INFO_ALL) |
1233 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1234 | | |
1235 | | /* Verify access property list and set up collective metadata if appropriate */ |
1236 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1237 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1238 | | |
1239 | | /* Set location struct fields */ |
1240 | 0 | loc_params.type = H5VL_OBJECT_BY_IDX; |
1241 | 0 | loc_params.loc_data.loc_by_idx.name = group_name; |
1242 | 0 | loc_params.loc_data.loc_by_idx.idx_type = idx_type; |
1243 | 0 | loc_params.loc_data.loc_by_idx.order = order; |
1244 | 0 | loc_params.loc_data.loc_by_idx.n = n; |
1245 | 0 | loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; |
1246 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1247 | | |
1248 | | /* Get the location object */ |
1249 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1250 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1251 | | |
1252 | | /* Set up VOL callback arguments */ |
1253 | 0 | vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; |
1254 | 0 | vol_cb_args.args.get_info.oinfo = oinfo; |
1255 | 0 | vol_cb_args.args.get_info.fields = fields; |
1256 | | |
1257 | | /* Retrieve the object's information */ |
1258 | 0 | if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
1259 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object"); |
1260 | | |
1261 | 0 | done: |
1262 | 0 | FUNC_LEAVE_API(ret_value) |
1263 | 0 | } /* end H5Oget_info_by_idx3() */ |
1264 | | |
1265 | | /*------------------------------------------------------------------------- |
1266 | | * Function: H5Oget_native_info |
1267 | | * |
1268 | | * Purpose: Retrieve native file format information about an object. |
1269 | | * |
1270 | | * Return: SUCCEED/FAIL |
1271 | | * |
1272 | | *------------------------------------------------------------------------- |
1273 | | */ |
1274 | | herr_t |
1275 | | H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo /*out*/, unsigned fields) |
1276 | 0 | { |
1277 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1278 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1279 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1280 | 0 | H5VL_loc_params_t loc_params; |
1281 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1282 | |
|
1283 | 0 | FUNC_ENTER_API(FAIL) |
1284 | | |
1285 | | /* Check args */ |
1286 | 0 | if (!oinfo) |
1287 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL"); |
1288 | 0 | if (fields & ~H5O_NATIVE_INFO_ALL) |
1289 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1290 | | |
1291 | | /* Set location struct fields */ |
1292 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
1293 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1294 | | |
1295 | | /* Get the location object */ |
1296 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1297 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1298 | | |
1299 | | /* Set up VOL callback arguments */ |
1300 | 0 | obj_opt_args.get_native_info.fields = fields; |
1301 | 0 | obj_opt_args.get_native_info.ninfo = oinfo; |
1302 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; |
1303 | 0 | vol_cb_args.args = &obj_opt_args; |
1304 | | |
1305 | | /* Retrieve the object's information */ |
1306 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1307 | 0 | 0) |
1308 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object"); |
1309 | | |
1310 | 0 | done: |
1311 | 0 | FUNC_LEAVE_API(ret_value) |
1312 | 0 | } /* end H5Oget_native_info() */ |
1313 | | |
1314 | | /*------------------------------------------------------------------------- |
1315 | | * Function: H5Oget_native_info_by_name |
1316 | | * |
1317 | | * Purpose: Retrieve native file format information about an object |
1318 | | * |
1319 | | * Return: SUCCEED/FAIL |
1320 | | * |
1321 | | *------------------------------------------------------------------------- |
1322 | | */ |
1323 | | herr_t |
1324 | | H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo /*out*/, unsigned fields, |
1325 | | hid_t lapl_id) |
1326 | 0 | { |
1327 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1328 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1329 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1330 | 0 | H5VL_loc_params_t loc_params; |
1331 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1332 | |
|
1333 | 0 | FUNC_ENTER_API(FAIL) |
1334 | | |
1335 | | /* Check args */ |
1336 | 0 | if (!name) |
1337 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL"); |
1338 | 0 | if (!*name) |
1339 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string"); |
1340 | 0 | if (!oinfo) |
1341 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL"); |
1342 | 0 | if (fields & ~H5O_NATIVE_INFO_ALL) |
1343 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1344 | | |
1345 | | /* Verify access property list and set up collective metadata if appropriate */ |
1346 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1347 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1348 | | |
1349 | | /* Fill out location struct */ |
1350 | 0 | loc_params.type = H5VL_OBJECT_BY_NAME; |
1351 | 0 | loc_params.loc_data.loc_by_name.name = name; |
1352 | 0 | loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
1353 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1354 | | |
1355 | | /* Get the location object */ |
1356 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1357 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1358 | | |
1359 | | /* Set up VOL callback arguments */ |
1360 | 0 | obj_opt_args.get_native_info.fields = fields; |
1361 | 0 | obj_opt_args.get_native_info.ninfo = oinfo; |
1362 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; |
1363 | 0 | vol_cb_args.args = &obj_opt_args; |
1364 | | |
1365 | | /* Retrieve the object's information */ |
1366 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1367 | 0 | 0) |
1368 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object: '%s'", name); |
1369 | | |
1370 | 0 | done: |
1371 | 0 | FUNC_LEAVE_API(ret_value) |
1372 | 0 | } /* end H5Oget_native_info_by_name() */ |
1373 | | |
1374 | | /*------------------------------------------------------------------------- |
1375 | | * Function: H5Oget_native_info_by_idx |
1376 | | * |
1377 | | * Purpose: Retrieve native file format information about an object, |
1378 | | * according to the order of an index. |
1379 | | * |
1380 | | * Return: Success: Non-negative |
1381 | | * Failure: Negative |
1382 | | * |
1383 | | *------------------------------------------------------------------------- |
1384 | | */ |
1385 | | herr_t |
1386 | | H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, |
1387 | | hsize_t n, H5O_native_info_t *oinfo /*out*/, unsigned fields, hid_t lapl_id) |
1388 | 0 | { |
1389 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1390 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1391 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1392 | 0 | H5VL_loc_params_t loc_params; |
1393 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1394 | |
|
1395 | 0 | FUNC_ENTER_API(FAIL) |
1396 | | |
1397 | | /* Check args */ |
1398 | 0 | if (!group_name || !*group_name) |
1399 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); |
1400 | 0 | if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) |
1401 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified"); |
1402 | 0 | if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) |
1403 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified"); |
1404 | 0 | if (!oinfo) |
1405 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct"); |
1406 | 0 | if (fields & ~H5O_NATIVE_INFO_ALL) |
1407 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1408 | | |
1409 | | /* Verify access property list and set up collective metadata if appropriate */ |
1410 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1411 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1412 | | |
1413 | | /* Set location struct fields */ |
1414 | 0 | loc_params.type = H5VL_OBJECT_BY_IDX; |
1415 | 0 | loc_params.loc_data.loc_by_idx.name = group_name; |
1416 | 0 | loc_params.loc_data.loc_by_idx.idx_type = idx_type; |
1417 | 0 | loc_params.loc_data.loc_by_idx.order = order; |
1418 | 0 | loc_params.loc_data.loc_by_idx.n = n; |
1419 | 0 | loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; |
1420 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1421 | | |
1422 | | /* Get the location object */ |
1423 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1424 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1425 | | |
1426 | | /* Set up VOL callback arguments */ |
1427 | 0 | obj_opt_args.get_native_info.fields = fields; |
1428 | 0 | obj_opt_args.get_native_info.ninfo = oinfo; |
1429 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; |
1430 | 0 | vol_cb_args.args = &obj_opt_args; |
1431 | | |
1432 | | /* Retrieve the object's information */ |
1433 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1434 | 0 | 0) |
1435 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object"); |
1436 | | |
1437 | 0 | done: |
1438 | 0 | FUNC_LEAVE_API(ret_value) |
1439 | 0 | } /* end H5Oget_native_info_by_idx() */ |
1440 | | |
1441 | | /*------------------------------------------------------------------------- |
1442 | | * Function: H5Oset_comment |
1443 | | * |
1444 | | * Purpose: Gives the specified object a comment. The COMMENT string |
1445 | | * should be a null terminated string. An object can have only |
1446 | | * one comment at a time. Passing NULL for the COMMENT argument |
1447 | | * will remove the comment property from the object. |
1448 | | * |
1449 | | * Note: Deprecated in favor of using attributes on objects |
1450 | | * |
1451 | | * Return: SUCCEED/FAIL |
1452 | | * |
1453 | | *------------------------------------------------------------------------- |
1454 | | */ |
1455 | | herr_t |
1456 | | H5Oset_comment(hid_t obj_id, const char *comment) |
1457 | 0 | { |
1458 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1459 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1460 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1461 | 0 | H5VL_loc_params_t loc_params; |
1462 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1463 | |
|
1464 | 0 | FUNC_ENTER_API(FAIL) |
1465 | | |
1466 | | /* Get the location object */ |
1467 | 0 | if (NULL == (vol_obj = H5VL_vol_object(obj_id))) |
1468 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1469 | | |
1470 | | /* Set up collective metadata if appropriate */ |
1471 | 0 | if (H5CX_set_loc(obj_id) < 0) |
1472 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info"); |
1473 | | |
1474 | | /* Fill in location struct fields */ |
1475 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
1476 | 0 | loc_params.obj_type = H5I_get_type(obj_id); |
1477 | | |
1478 | | /* Set up VOL callback arguments */ |
1479 | 0 | obj_opt_args.set_comment.comment = comment; |
1480 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_SET_COMMENT; |
1481 | 0 | vol_cb_args.args = &obj_opt_args; |
1482 | | |
1483 | | /* (Re)set the object's comment */ |
1484 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1485 | 0 | 0) |
1486 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object"); |
1487 | | |
1488 | 0 | done: |
1489 | 0 | FUNC_LEAVE_API(ret_value) |
1490 | 0 | } /* end H5Oset_comment() */ |
1491 | | |
1492 | | /*------------------------------------------------------------------------- |
1493 | | * Function: H5Oset_comment_by_name |
1494 | | * |
1495 | | * Purpose: Gives the specified object a comment. The COMMENT string |
1496 | | * should be a null terminated string. An object can have only |
1497 | | * one comment at a time. Passing NULL for the COMMENT argument |
1498 | | * will remove the comment property from the object. |
1499 | | * |
1500 | | * Note: Deprecated in favor of using attributes on objects |
1501 | | * |
1502 | | * Return: SUCCEED/FAIL |
1503 | | * |
1504 | | *------------------------------------------------------------------------- |
1505 | | */ |
1506 | | herr_t |
1507 | | H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) |
1508 | 0 | { |
1509 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1510 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1511 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1512 | 0 | H5VL_loc_params_t loc_params; |
1513 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1514 | |
|
1515 | 0 | FUNC_ENTER_API(FAIL) |
1516 | | |
1517 | | /* Check args */ |
1518 | 0 | if (!name || !*name) |
1519 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); |
1520 | | |
1521 | | /* Verify access property list and set up collective metadata if appropriate */ |
1522 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, true) < 0) |
1523 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1524 | | |
1525 | | /* Fill in location struct fields */ |
1526 | 0 | loc_params.type = H5VL_OBJECT_BY_NAME; |
1527 | 0 | loc_params.loc_data.loc_by_name.name = name; |
1528 | 0 | loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
1529 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1530 | | |
1531 | | /* Get the location object */ |
1532 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1533 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1534 | | |
1535 | | /* Set up VOL callback arguments */ |
1536 | 0 | obj_opt_args.set_comment.comment = comment; |
1537 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_SET_COMMENT; |
1538 | 0 | vol_cb_args.args = &obj_opt_args; |
1539 | | |
1540 | | /* (Re)set the object's comment */ |
1541 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1542 | 0 | 0) |
1543 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name); |
1544 | | |
1545 | 0 | done: |
1546 | 0 | FUNC_LEAVE_API(ret_value) |
1547 | 0 | } /* end H5Oset_comment_by_name() */ |
1548 | | |
1549 | | /*------------------------------------------------------------------------- |
1550 | | * Function: H5Oget_comment |
1551 | | * |
1552 | | * Purpose: Retrieve comment for an object. |
1553 | | * |
1554 | | * Return: Success: Number of bytes in the comment excluding the |
1555 | | * null terminator. Zero if the object has no |
1556 | | * comment. |
1557 | | * |
1558 | | * Failure: -1 |
1559 | | * |
1560 | | *------------------------------------------------------------------------- |
1561 | | */ |
1562 | | ssize_t |
1563 | | H5Oget_comment(hid_t obj_id, char *comment /*out*/, size_t bufsize) |
1564 | 0 | { |
1565 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1566 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1567 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1568 | 0 | H5VL_loc_params_t loc_params; |
1569 | 0 | size_t comment_len = 0; /* Length of comment string */ |
1570 | 0 | ssize_t ret_value = -1; /* Return value */ |
1571 | |
|
1572 | 0 | FUNC_ENTER_API((-1)) |
1573 | | |
1574 | | /* Get the object */ |
1575 | 0 | if (NULL == (vol_obj = H5VL_vol_object(obj_id))) |
1576 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier"); |
1577 | | |
1578 | | /* Set fields in the location struct */ |
1579 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
1580 | 0 | loc_params.obj_type = H5I_get_type(obj_id); |
1581 | | |
1582 | | /* Set up VOL callback arguments */ |
1583 | 0 | obj_opt_args.get_comment.buf = comment; |
1584 | 0 | obj_opt_args.get_comment.buf_size = bufsize; |
1585 | 0 | obj_opt_args.get_comment.comment_len = &comment_len; |
1586 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_COMMENT; |
1587 | 0 | vol_cb_args.args = &obj_opt_args; |
1588 | | |
1589 | | /* Retrieve the object's comment */ |
1590 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1591 | 0 | 0) |
1592 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object"); |
1593 | | |
1594 | | /* Set return value */ |
1595 | 0 | ret_value = (ssize_t)comment_len; |
1596 | |
|
1597 | 0 | done: |
1598 | 0 | FUNC_LEAVE_API(ret_value) |
1599 | 0 | } /* end H5Oget_comment() */ |
1600 | | |
1601 | | /*------------------------------------------------------------------------- |
1602 | | * Function: H5Oget_comment_by_name |
1603 | | * |
1604 | | * Purpose: Retrieve comment for an object. |
1605 | | * |
1606 | | * Return: Success: Number of bytes in the comment excluding the |
1607 | | * null terminator. Zero if the object has no |
1608 | | * comment. |
1609 | | * |
1610 | | * Failure: -1 |
1611 | | * |
1612 | | *------------------------------------------------------------------------- |
1613 | | */ |
1614 | | ssize_t |
1615 | | H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment /*out*/, size_t bufsize, hid_t lapl_id) |
1616 | 0 | { |
1617 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1618 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
1619 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
1620 | 0 | H5VL_loc_params_t loc_params; |
1621 | 0 | size_t comment_len = 0; /* Length of comment string */ |
1622 | 0 | ssize_t ret_value = -1; /* Return value */ |
1623 | |
|
1624 | 0 | FUNC_ENTER_API((-1)) |
1625 | | |
1626 | | /* Check args */ |
1627 | 0 | if (!name || !*name) |
1628 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name"); |
1629 | | |
1630 | | /* Verify access property list and set up collective metadata if appropriate */ |
1631 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1632 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, (-1), "can't set access property list info"); |
1633 | | |
1634 | | /* Fill in location struct fields */ |
1635 | 0 | loc_params.type = H5VL_OBJECT_BY_NAME; |
1636 | 0 | loc_params.loc_data.loc_by_name.name = name; |
1637 | 0 | loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
1638 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1639 | | |
1640 | | /* Get the location object */ |
1641 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1642 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier"); |
1643 | | |
1644 | | /* Set up VOL callback arguments */ |
1645 | 0 | obj_opt_args.get_comment.buf = comment; |
1646 | 0 | obj_opt_args.get_comment.buf_size = bufsize; |
1647 | 0 | obj_opt_args.get_comment.comment_len = &comment_len; |
1648 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_COMMENT; |
1649 | 0 | vol_cb_args.args = &obj_opt_args; |
1650 | | |
1651 | | /* Retrieve the object's comment */ |
1652 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
1653 | 0 | 0) |
1654 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name); |
1655 | | |
1656 | | /* Set return value */ |
1657 | 0 | ret_value = (ssize_t)comment_len; |
1658 | |
|
1659 | 0 | done: |
1660 | 0 | FUNC_LEAVE_API(ret_value) |
1661 | 0 | } /* end H5Oget_comment_by_name() */ |
1662 | | |
1663 | | /*------------------------------------------------------------------------- |
1664 | | * Function: H5Ovisit3 |
1665 | | * |
1666 | | * Purpose: Recursively visit an object and all the objects reachable |
1667 | | * from it. If the starting object is a group, all the objects |
1668 | | * linked to from that group will be visited. Links within |
1669 | | * each group are visited according to the order within the |
1670 | | * specified index (unless the specified index does not exist for |
1671 | | * a particular group, then the "name" index is used). |
1672 | | * |
1673 | | * NOTE: Soft links and user-defined links are ignored during |
1674 | | * this operation. |
1675 | | * |
1676 | | * NOTE: Each _object_ reachable from the initial group will only |
1677 | | * be visited once. If multiple hard links point to the same |
1678 | | * object, the first link to the object's path (according to the |
1679 | | * iteration index and iteration order given) will be used to in |
1680 | | * the callback about the object. |
1681 | | * |
1682 | | * NOTE: Add a parameter "fields" to indicate selection of |
1683 | | * object info to be retrieved to the callback "op". |
1684 | | * |
1685 | | * Return: Success: The return value of the first operator that |
1686 | | * returns non-zero, or zero if all members were |
1687 | | * processed with no operator returning non-zero. |
1688 | | * |
1689 | | * Failure: Negative if something goes wrong within the |
1690 | | * library, or the negative value returned by one |
1691 | | * of the operators. |
1692 | | * |
1693 | | *------------------------------------------------------------------------- |
1694 | | */ |
1695 | | herr_t |
1696 | | H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, |
1697 | | unsigned fields) |
1698 | 0 | { |
1699 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1700 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
1701 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
1702 | 0 | herr_t ret_value; /* Return value */ |
1703 | |
|
1704 | 0 | FUNC_ENTER_API(FAIL) |
1705 | | |
1706 | | /* Check args */ |
1707 | 0 | if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) |
1708 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified"); |
1709 | 0 | if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) |
1710 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified"); |
1711 | 0 | if (!op) |
1712 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified"); |
1713 | 0 | if (fields & ~H5O_INFO_ALL) |
1714 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1715 | | |
1716 | | /* Get the location object */ |
1717 | 0 | if (NULL == (vol_obj = H5VL_vol_object(obj_id))) |
1718 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1719 | | |
1720 | | /* Set location parameters */ |
1721 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
1722 | 0 | loc_params.obj_type = H5I_get_type(obj_id); |
1723 | | |
1724 | | /* Set up VOL callback arguments */ |
1725 | 0 | vol_cb_args.op_type = H5VL_OBJECT_VISIT; |
1726 | 0 | vol_cb_args.args.visit.idx_type = idx_type; |
1727 | 0 | vol_cb_args.args.visit.order = order; |
1728 | 0 | vol_cb_args.args.visit.op = op; |
1729 | 0 | vol_cb_args.args.visit.op_data = op_data; |
1730 | 0 | vol_cb_args.args.visit.fields = fields; |
1731 | | |
1732 | | /* Visit the objects */ |
1733 | 0 | if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, |
1734 | 0 | H5_REQUEST_NULL)) < 0) |
1735 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed"); |
1736 | | |
1737 | 0 | done: |
1738 | 0 | FUNC_LEAVE_API(ret_value) |
1739 | 0 | } /* end H5Ovisit3() */ |
1740 | | |
1741 | | /*------------------------------------------------------------------------- |
1742 | | * Function: H5Ovisit_by_name3 |
1743 | | * |
1744 | | * Purpose: Recursively visit an object and all the objects reachable |
1745 | | * from it. If the starting object is a group, all the objects |
1746 | | * linked to from that group will be visited. Links within |
1747 | | * each group are visited according to the order within the |
1748 | | * specified index (unless the specified index does not exist for |
1749 | | * a particular group, then the "name" index is used). |
1750 | | * |
1751 | | * NOTE: Soft links and user-defined links are ignored during |
1752 | | * this operation. |
1753 | | * |
1754 | | * NOTE: Each _object_ reachable from the initial group will only |
1755 | | * be visited once. If multiple hard links point to the same |
1756 | | * object, the first link to the object's path (according to the |
1757 | | * iteration index and iteration order given) will be used to in |
1758 | | * the callback about the object. |
1759 | | * |
1760 | | * NOTE: Add a parameter "fields" to indicate selection of |
1761 | | * object info to be retrieved to the callback "op". |
1762 | | * |
1763 | | * Return: Success: The return value of the first operator that |
1764 | | * returns non-zero, or zero if all members were |
1765 | | * processed with no operator returning non-zero. |
1766 | | * |
1767 | | * Failure: Negative if something goes wrong within the |
1768 | | * library, or the negative value returned by one |
1769 | | * of the operators. |
1770 | | * |
1771 | | *------------------------------------------------------------------------- |
1772 | | */ |
1773 | | herr_t |
1774 | | H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, |
1775 | | H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) |
1776 | 0 | { |
1777 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
1778 | 0 | H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
1779 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
1780 | 0 | herr_t ret_value; /* Return value */ |
1781 | |
|
1782 | 0 | FUNC_ENTER_API(FAIL) |
1783 | | |
1784 | | /* Check args */ |
1785 | 0 | if (!obj_name) |
1786 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL"); |
1787 | 0 | if (!*obj_name) |
1788 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string"); |
1789 | 0 | if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) |
1790 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified"); |
1791 | 0 | if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) |
1792 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified"); |
1793 | 0 | if (!op) |
1794 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified"); |
1795 | 0 | if (fields & ~H5O_INFO_ALL) |
1796 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields"); |
1797 | | |
1798 | | /* Verify access property list and set up collective metadata if appropriate */ |
1799 | 0 | if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, false) < 0) |
1800 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info"); |
1801 | | |
1802 | | /* Get the location object */ |
1803 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
1804 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
1805 | | |
1806 | | /* Set location parameters */ |
1807 | 0 | loc_params.type = H5VL_OBJECT_BY_NAME; |
1808 | 0 | loc_params.loc_data.loc_by_name.name = obj_name; |
1809 | 0 | loc_params.loc_data.loc_by_name.lapl_id = lapl_id; |
1810 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
1811 | | |
1812 | | /* Set up VOL callback arguments */ |
1813 | 0 | vol_cb_args.op_type = H5VL_OBJECT_VISIT; |
1814 | 0 | vol_cb_args.args.visit.idx_type = idx_type; |
1815 | 0 | vol_cb_args.args.visit.order = order; |
1816 | 0 | vol_cb_args.args.visit.op = op; |
1817 | 0 | vol_cb_args.args.visit.op_data = op_data; |
1818 | 0 | vol_cb_args.args.visit.fields = fields; |
1819 | | |
1820 | | /* Visit the objects */ |
1821 | 0 | if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, |
1822 | 0 | H5_REQUEST_NULL)) < 0) |
1823 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed"); |
1824 | | |
1825 | 0 | done: |
1826 | 0 | FUNC_LEAVE_API(ret_value) |
1827 | 0 | } /* end H5Ovisit_by_name3() */ |
1828 | | |
1829 | | /*------------------------------------------------------------------------- |
1830 | | * Function: H5O__close_check_type |
1831 | | * |
1832 | | * Purpose: This is the common function to validate an object |
1833 | | * before closing it. |
1834 | | * |
1835 | | * Return: true/false/FAIL |
1836 | | * |
1837 | | *------------------------------------------------------------------------- |
1838 | | */ |
1839 | | static htri_t |
1840 | | H5O__close_check_type(hid_t object_id) |
1841 | 0 | { |
1842 | 0 | htri_t ret_value = true; /* Return value */ |
1843 | |
|
1844 | 0 | FUNC_ENTER_PACKAGE |
1845 | | |
1846 | | /* Check for closeable object */ |
1847 | 0 | switch (H5I_get_type(object_id)) { |
1848 | 0 | case H5I_GROUP: |
1849 | 0 | case H5I_DATATYPE: |
1850 | 0 | case H5I_DATASET: |
1851 | 0 | case H5I_MAP: |
1852 | 0 | if (H5I_object(object_id) == NULL) |
1853 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object"); |
1854 | 0 | break; |
1855 | | |
1856 | 0 | case H5I_UNINIT: |
1857 | 0 | case H5I_BADID: |
1858 | 0 | case H5I_FILE: |
1859 | 0 | case H5I_DATASPACE: |
1860 | 0 | case H5I_ATTR: |
1861 | 0 | case H5I_VFL: |
1862 | 0 | case H5I_VOL: |
1863 | 0 | case H5I_GENPROP_CLS: |
1864 | 0 | case H5I_GENPROP_LST: |
1865 | 0 | case H5I_ERROR_CLASS: |
1866 | 0 | case H5I_ERROR_MSG: |
1867 | 0 | case H5I_ERROR_STACK: |
1868 | 0 | case H5I_SPACE_SEL_ITER: |
1869 | 0 | case H5I_EVENTSET: |
1870 | 0 | case H5I_NTYPES: |
1871 | 0 | default: |
1872 | 0 | HGOTO_DONE(false); |
1873 | 0 | break; |
1874 | 0 | } /* end switch */ |
1875 | | |
1876 | 0 | done: |
1877 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1878 | 0 | } /* H5O__close_check_type() */ |
1879 | | |
1880 | | /*------------------------------------------------------------------------- |
1881 | | * Function: H5Oclose |
1882 | | * |
1883 | | * Purpose: Close an open file object. |
1884 | | * |
1885 | | * This is the companion to H5Oopen. It is used to close any |
1886 | | * open object in an HDF5 file (but not IDs are that not file |
1887 | | * objects, such as property lists and dataspaces). It has |
1888 | | * the same effect as calling H5Gclose, H5Dclose, or H5Tclose. |
1889 | | * |
1890 | | * Return: SUCCEED/FAIL |
1891 | | * |
1892 | | *------------------------------------------------------------------------- |
1893 | | */ |
1894 | | herr_t |
1895 | | H5Oclose(hid_t object_id) |
1896 | 0 | { |
1897 | 0 | herr_t ret_value = SUCCEED; |
1898 | |
|
1899 | 0 | FUNC_ENTER_API(FAIL) |
1900 | | |
1901 | | /* Validate the object type before closing */ |
1902 | 0 | if (H5O__close_check_type(object_id) <= 0) |
1903 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "not a valid object"); |
1904 | | |
1905 | 0 | if (H5I_dec_app_ref(object_id) < 0) |
1906 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object"); |
1907 | | |
1908 | 0 | done: |
1909 | 0 | FUNC_LEAVE_API(ret_value) |
1910 | 0 | } /* end H5Oclose() */ |
1911 | | |
1912 | | /*------------------------------------------------------------------------- |
1913 | | * Function: H5Oclose_async |
1914 | | * |
1915 | | * Purpose: Asynchronous version of H5Oclose |
1916 | | * |
1917 | | * Return: SUCCEED/FAIL |
1918 | | * |
1919 | | *------------------------------------------------------------------------- |
1920 | | */ |
1921 | | herr_t |
1922 | | H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t object_id, hid_t es_id) |
1923 | 0 | { |
1924 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
1925 | 0 | H5VL_connector_t *connector = NULL; /* VOL connector */ |
1926 | 0 | void *token = NULL; /* Request token for async operation */ |
1927 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
1928 | 0 | herr_t ret_value = SUCCEED; |
1929 | |
|
1930 | 0 | FUNC_ENTER_API(FAIL) |
1931 | | |
1932 | | /* Validate the object type before closing */ |
1933 | 0 | if (H5O__close_check_type(object_id) <= 0) |
1934 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "not a valid object"); |
1935 | | |
1936 | | /* Prepare for possible asynchronous operation */ |
1937 | 0 | if (H5ES_NONE != es_id) { |
1938 | | /* Get file object's connector */ |
1939 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
1940 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get VOL object for object"); |
1941 | | |
1942 | | /* Increase connector's refcount, so it doesn't get closed if closing |
1943 | | * this object ID closes the file */ |
1944 | 0 | connector = H5VL_OBJ_CONNECTOR(vol_obj); |
1945 | 0 | H5VL_conn_inc_rc(connector); |
1946 | | |
1947 | | /* Point at token for operation to set up */ |
1948 | 0 | token_ptr = &token; |
1949 | 0 | } /* end if */ |
1950 | | |
1951 | | /* Asynchronously decrement reference count on ID. |
1952 | | * When it reaches zero the object will be closed. |
1953 | | */ |
1954 | 0 | if (H5I_dec_app_ref_async(object_id, token_ptr) < 0) |
1955 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "decrementing object ID failed"); |
1956 | | |
1957 | | /* If a token was created, add the token to the event set */ |
1958 | 0 | if (NULL != token) |
1959 | | /* clang-format off */ |
1960 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
1961 | 0 | H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, object_id, es_id)) < 0) |
1962 | | /* clang-format on */ |
1963 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
1964 | | |
1965 | 0 | done: |
1966 | 0 | if (connector && H5VL_conn_dec_rc(connector) < 0) |
1967 | 0 | HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); |
1968 | |
|
1969 | 0 | FUNC_LEAVE_API(ret_value) |
1970 | 0 | } /* end H5Oclose_async() */ |
1971 | | |
1972 | | /*------------------------------------------------------------------------- |
1973 | | * Function: H5O__disable_mdc_flushes |
1974 | | * |
1975 | | * Purpose: Private version of the metadata cache cork function. |
1976 | | * |
1977 | | * Return: SUCCEED/FAIL |
1978 | | * |
1979 | | *------------------------------------------------------------------------- |
1980 | | */ |
1981 | | herr_t |
1982 | | H5O__disable_mdc_flushes(H5O_loc_t *oloc) |
1983 | 0 | { |
1984 | 0 | herr_t ret_value = SUCCEED; |
1985 | |
|
1986 | 0 | FUNC_ENTER_PACKAGE |
1987 | |
|
1988 | 0 | if (H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) |
1989 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); |
1990 | | |
1991 | 0 | done: |
1992 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1993 | 0 | } /* H5O__disable_mdc_flushes() */ |
1994 | | |
1995 | | /*------------------------------------------------------------------------- |
1996 | | * Function: H5Odisable_mdc_flushes |
1997 | | * |
1998 | | * Purpose: "Cork" an object, keeping dirty entries associated with the |
1999 | | * object in the metadata cache. |
2000 | | * |
2001 | | * Return: Success: Non-negative |
2002 | | * Failure: Negative |
2003 | | * |
2004 | | *------------------------------------------------------------------------- |
2005 | | */ |
2006 | | herr_t |
2007 | | H5Odisable_mdc_flushes(hid_t object_id) |
2008 | 0 | { |
2009 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
2010 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
2011 | 0 | H5VL_loc_params_t loc_params; /* Location parameters */ |
2012 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2013 | |
|
2014 | 0 | FUNC_ENTER_API(FAIL) |
2015 | | |
2016 | | /* Make sure the ID is a file object */ |
2017 | 0 | if (H5I_is_file_object(object_id) != true) |
2018 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); |
2019 | | |
2020 | | /* Get the VOL object */ |
2021 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
2022 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); |
2023 | | |
2024 | | /* Fill in location struct fields */ |
2025 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
2026 | 0 | loc_params.obj_type = H5I_get_type(object_id); |
2027 | | |
2028 | | /* Set up VOL callback arguments */ |
2029 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES; |
2030 | 0 | vol_cb_args.args = NULL; |
2031 | | |
2032 | | /* Cork the object */ |
2033 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
2034 | 0 | 0) |
2035 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); |
2036 | | |
2037 | 0 | done: |
2038 | 0 | FUNC_LEAVE_API(ret_value) |
2039 | 0 | } /* H5Odisable_mdc_flushes() */ |
2040 | | |
2041 | | /*------------------------------------------------------------------------- |
2042 | | * Function: H5O__enable_mdc_flushes |
2043 | | * |
2044 | | * Purpose: Private version of the metadata cache uncork function. |
2045 | | * |
2046 | | * Return: SUCCEED/FAIL |
2047 | | * |
2048 | | *------------------------------------------------------------------------- |
2049 | | */ |
2050 | | herr_t |
2051 | | H5O__enable_mdc_flushes(H5O_loc_t *oloc) |
2052 | 0 | { |
2053 | 0 | herr_t ret_value = SUCCEED; |
2054 | |
|
2055 | 0 | FUNC_ENTER_PACKAGE |
2056 | |
|
2057 | 0 | if (H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) |
2058 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); |
2059 | | |
2060 | 0 | done: |
2061 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
2062 | 0 | } /* H5O__enable_mdc_flushes() */ |
2063 | | |
2064 | | /*------------------------------------------------------------------------- |
2065 | | * Function: H5Oenable_mdc_flushes |
2066 | | * |
2067 | | * Purpose: "Uncork" an object, allowing dirty entries associated with |
2068 | | * the object to be flushed. |
2069 | | * |
2070 | | * Return: Success: Non-negative |
2071 | | * Failure: Negative |
2072 | | * |
2073 | | *------------------------------------------------------------------------- |
2074 | | */ |
2075 | | herr_t |
2076 | | H5Oenable_mdc_flushes(hid_t object_id) |
2077 | 0 | { |
2078 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
2079 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
2080 | 0 | H5VL_loc_params_t loc_params; /* Location parameters */ |
2081 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2082 | |
|
2083 | 0 | FUNC_ENTER_API(FAIL) |
2084 | | |
2085 | | /* Make sure the ID is a file object */ |
2086 | 0 | if (H5I_is_file_object(object_id) != true) |
2087 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); |
2088 | | |
2089 | | /* Get the VOL object */ |
2090 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
2091 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); |
2092 | | |
2093 | | /* Fill in location struct fields */ |
2094 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
2095 | 0 | loc_params.obj_type = H5I_get_type(object_id); |
2096 | | |
2097 | | /* Set up VOL callback arguments */ |
2098 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES; |
2099 | 0 | vol_cb_args.args = NULL; |
2100 | | |
2101 | | /* Uncork the object */ |
2102 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
2103 | 0 | 0) |
2104 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); |
2105 | | |
2106 | 0 | done: |
2107 | 0 | FUNC_LEAVE_API(ret_value) |
2108 | 0 | } /* H5Oenable_mdc_flushes() */ |
2109 | | |
2110 | | /*------------------------------------------------------------------------- |
2111 | | * Function: H5O__are_mdc_flushes_disabled |
2112 | | * |
2113 | | * Purpose: Private version of cork status getter |
2114 | | * |
2115 | | * Return: SUCCEED/FAIL |
2116 | | * |
2117 | | *------------------------------------------------------------------------- |
2118 | | */ |
2119 | | herr_t |
2120 | | H5O__are_mdc_flushes_disabled(const H5O_loc_t *oloc, bool *are_disabled) |
2121 | 0 | { |
2122 | 0 | herr_t ret_value = SUCCEED; |
2123 | |
|
2124 | 0 | FUNC_ENTER_PACKAGE |
2125 | |
|
2126 | 0 | assert(are_disabled); |
2127 | |
|
2128 | 0 | if (H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0) |
2129 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); |
2130 | | |
2131 | 0 | done: |
2132 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
2133 | 0 | } /* H5O__are_mdc_flushes_disabled() */ |
2134 | | |
2135 | | /*------------------------------------------------------------------------- |
2136 | | * Function: H5Oare_mdc_flushes_disabled |
2137 | | * |
2138 | | * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled": |
2139 | | * true if mdc flushes for the object is disabled |
2140 | | * false if mdc flushes for the object is not disabled |
2141 | | * |
2142 | | * Return error if the parameter "are_disabled" is not supplied |
2143 | | * |
2144 | | * Return: Success: Non-negative |
2145 | | * Failure: Negative |
2146 | | * |
2147 | | *------------------------------------------------------------------------- |
2148 | | */ |
2149 | | herr_t |
2150 | | H5Oare_mdc_flushes_disabled(hid_t object_id, bool *are_disabled) |
2151 | 0 | { |
2152 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
2153 | 0 | H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ |
2154 | 0 | H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ |
2155 | 0 | H5VL_loc_params_t loc_params; /* Location parameters */ |
2156 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2157 | |
|
2158 | 0 | FUNC_ENTER_API(FAIL) |
2159 | | |
2160 | | /* Sanity check */ |
2161 | 0 | if (!are_disabled) |
2162 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID"); |
2163 | | |
2164 | | /* Make sure the ID is a file object */ |
2165 | 0 | if (H5I_is_file_object(object_id) != true) |
2166 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); |
2167 | | |
2168 | | /* Get the VOL object */ |
2169 | 0 | if (NULL == (vol_obj = H5VL_vol_object(object_id))) |
2170 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); |
2171 | | |
2172 | | /* Fill in location struct fields */ |
2173 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
2174 | 0 | loc_params.obj_type = H5I_get_type(object_id); |
2175 | | |
2176 | | /* Set up VOL callback arguments */ |
2177 | 0 | obj_opt_args.are_mdc_flushes_disabled.flag = are_disabled; |
2178 | 0 | vol_cb_args.op_type = H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED; |
2179 | 0 | vol_cb_args.args = &obj_opt_args; |
2180 | | |
2181 | | /* Get the cork status */ |
2182 | 0 | if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < |
2183 | 0 | 0) |
2184 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); |
2185 | | |
2186 | 0 | done: |
2187 | 0 | FUNC_LEAVE_API(ret_value) |
2188 | 0 | } /* H5Oare_mdc_flushes_disabled() */ |
2189 | | |
2190 | | /*--------------------------------------------------------------------------- |
2191 | | * Function: H5Otoken_cmp |
2192 | | * |
2193 | | * Purpose: Compares two VOL connector object tokens |
2194 | | * |
2195 | | * Note: Both object tokens must be from the same VOL connector class |
2196 | | * |
2197 | | * Return: Success: Non-negative, with *cmp_value set to positive if |
2198 | | * token1 is greater than token2, negative if token2 |
2199 | | * is greater than token1 and zero if token1 and |
2200 | | * token2 are equal. |
2201 | | * Failure: Negative |
2202 | | * |
2203 | | *--------------------------------------------------------------------------- |
2204 | | */ |
2205 | | herr_t |
2206 | | H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) |
2207 | 0 | { |
2208 | 0 | H5VL_object_t *vol_obj; /* VOL object for ID */ |
2209 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2210 | |
|
2211 | 0 | FUNC_ENTER_API(FAIL) |
2212 | | |
2213 | | /* Get the location object */ |
2214 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
2215 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
2216 | 0 | if (NULL == cmp_value) |
2217 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer"); |
2218 | | |
2219 | | /* Compare the two tokens */ |
2220 | 0 | if (H5VL_token_cmp(vol_obj, token1, token2, cmp_value) < 0) |
2221 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTCOMPARE, FAIL, "object token comparison failed"); |
2222 | | |
2223 | 0 | done: |
2224 | 0 | FUNC_LEAVE_API(ret_value) |
2225 | 0 | } /* end H5Otoken_cmp() */ |
2226 | | |
2227 | | /*--------------------------------------------------------------------------- |
2228 | | * Function: H5Otoken_to_str |
2229 | | * |
2230 | | * Purpose: Serialize a connector's object token into a string |
2231 | | * |
2232 | | * Return: Success: Non-negative |
2233 | | * Failure: Negative |
2234 | | * |
2235 | | *--------------------------------------------------------------------------- |
2236 | | */ |
2237 | | herr_t |
2238 | | H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str) |
2239 | 0 | { |
2240 | 0 | H5VL_object_t *vol_obj; /* VOL object for ID */ |
2241 | 0 | H5I_type_t vol_obj_type; /* VOL object's type */ |
2242 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2243 | |
|
2244 | 0 | FUNC_ENTER_API(FAIL) |
2245 | | |
2246 | | /* Get the location object */ |
2247 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
2248 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
2249 | 0 | if (NULL == token) |
2250 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer"); |
2251 | 0 | if (NULL == token_str) |
2252 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer"); |
2253 | | |
2254 | | /* Get object type */ |
2255 | 0 | if ((vol_obj_type = H5I_get_type(loc_id)) < 0) |
2256 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get underlying VOL object type"); |
2257 | | |
2258 | | /* Serialize the token */ |
2259 | 0 | if (H5VL_token_to_str(vol_obj, vol_obj_type, token, token_str) < 0) |
2260 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "object token serialization failed"); |
2261 | | |
2262 | 0 | done: |
2263 | 0 | FUNC_LEAVE_API(ret_value) |
2264 | 0 | } /* end H5Otoken_to_str() */ |
2265 | | |
2266 | | /*--------------------------------------------------------------------------- |
2267 | | * Function: H5Otoken_from_str |
2268 | | * |
2269 | | * Purpose: Deserialize a string into a connector object token |
2270 | | * |
2271 | | * Return: Success: Non-negative |
2272 | | * Failure: Negative |
2273 | | * |
2274 | | *--------------------------------------------------------------------------- |
2275 | | */ |
2276 | | herr_t |
2277 | | H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token) |
2278 | 0 | { |
2279 | 0 | H5VL_object_t *vol_obj; /* VOL object for ID */ |
2280 | 0 | H5I_type_t vol_obj_type; /* VOL object's type */ |
2281 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
2282 | |
|
2283 | 0 | FUNC_ENTER_API(FAIL) |
2284 | | |
2285 | | /* Get the location object */ |
2286 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
2287 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); |
2288 | 0 | if (NULL == token) |
2289 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer"); |
2290 | 0 | if (NULL == token_str) |
2291 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer"); |
2292 | | |
2293 | | /* Get object type */ |
2294 | 0 | if ((vol_obj_type = H5I_get_type(loc_id)) < 0) |
2295 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get underlying VOL object type"); |
2296 | | |
2297 | | /* Deserialize the token */ |
2298 | 0 | if (H5VL_token_from_str(vol_obj, vol_obj_type, token_str, token) < 0) |
2299 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "object token deserialization failed"); |
2300 | | |
2301 | 0 | done: |
2302 | 0 | FUNC_LEAVE_API(ret_value) |
2303 | 0 | } /* end H5Otoken_from_str() */ |