Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /*------------------------------------------------------------------------- |
14 | | * |
15 | | * Created: H5G.c |
16 | | * |
17 | | * Purpose: Symbol table functions. The functions that begin with |
18 | | * 'H5G_stab_' don't understand the naming system; they operate |
19 | | * on a single symbol table at a time. |
20 | | * |
21 | | * The functions that begin with 'H5G_node_' operate on the leaf |
22 | | * nodes of a symbol table B-tree. They should be defined in |
23 | | * the H5Gnode.c file. |
24 | | * |
25 | | * The remaining functions know how to traverse the group |
26 | | * directed graph. |
27 | | * |
28 | | * Names: Object names are a slash-separated list of components. If |
29 | | * the name begins with a slash then it's absolute, otherwise |
30 | | * it's relative ("/foo/bar" is absolute while "foo/bar" is |
31 | | * relative). Multiple consecutive slashes are treated as |
32 | | * single slashes and trailing slashes are ignored. The special |
33 | | * case `/' is the root group. Every file has a root group. |
34 | | * |
35 | | * API functions that look up names take a location ID and a |
36 | | * name. The location ID can be a file ID or a group ID and the |
37 | | * name can be relative or absolute. |
38 | | * |
39 | | * +--------------+----------- +--------------------------------+ |
40 | | * | Location ID | Name | Meaning | |
41 | | * +--------------+------------+--------------------------------+ |
42 | | * | File ID | "/foo/bar" | Find 'foo' within 'bar' within | |
43 | | * | | | the root group of the specified| |
44 | | * | | | file. | |
45 | | * +--------------+------------+--------------------------------+ |
46 | | * | File ID | "foo/bar" | Find 'foo' within 'bar' within | |
47 | | * | | | the root group of the specified| |
48 | | * | | | file. | |
49 | | * +--------------+------------+--------------------------------+ |
50 | | * | File ID | "/" | The root group of the specified| |
51 | | * | | | file. | |
52 | | * +--------------+------------+--------------------------------+ |
53 | | * | File ID | "." | The root group of the specified| |
54 | | * | | | the specified file. | |
55 | | * +--------------+------------+--------------------------------+ |
56 | | * | Group ID | "/foo/bar" | Find 'foo' within 'bar' within | |
57 | | * | | | the root group of the file | |
58 | | * | | | containing the specified group.| |
59 | | * +--------------+------------+--------------------------------+ |
60 | | * | Group ID | "foo/bar" | File 'foo' within 'bar' within | |
61 | | * | | | the specified group. | |
62 | | * +--------------+------------+--------------------------------+ |
63 | | * | Group ID | "/" | The root group of the file | |
64 | | * | | | containing the specified group.| |
65 | | * +--------------+------------+--------------------------------+ |
66 | | * | Group ID | "." | The specified group. | |
67 | | * +--------------+------------+--------------------------------+ |
68 | | * |
69 | | * |
70 | | *------------------------------------------------------------------------- |
71 | | */ |
72 | | |
73 | | /****************/ |
74 | | /* Module Setup */ |
75 | | /****************/ |
76 | | |
77 | | #include "H5Gmodule.h" /* This source code file is part of the H5G module */ |
78 | | |
79 | | /***********/ |
80 | | /* Headers */ |
81 | | /***********/ |
82 | | #include "H5private.h" /* Generic Functions */ |
83 | | #include "H5CXprivate.h" /* API Contexts */ |
84 | | #include "H5Eprivate.h" /* Error handling */ |
85 | | #include "H5ESprivate.h" /* Event Sets */ |
86 | | #include "H5Gpkg.h" /* Groups */ |
87 | | #include "H5Iprivate.h" /* IDs */ |
88 | | #include "H5Pprivate.h" /* Property lists */ |
89 | | #include "H5VLprivate.h" /* Virtual Object Layer */ |
90 | | |
91 | | /****************/ |
92 | | /* Local Macros */ |
93 | | /****************/ |
94 | | |
95 | | /******************/ |
96 | | /* Local Typedefs */ |
97 | | /******************/ |
98 | | |
99 | | /********************/ |
100 | | /* Package Typedefs */ |
101 | | /********************/ |
102 | | |
103 | | /********************/ |
104 | | /* Local Prototypes */ |
105 | | /********************/ |
106 | | |
107 | | /* Helper routines for sync/async API calls */ |
108 | | static hid_t H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, |
109 | | hid_t gapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); |
110 | | static hid_t H5G__open_api_common(hid_t loc_id, const char *name, hid_t gapl_id, void **token_ptr, |
111 | | H5VL_object_t **_vol_obj_ptr); |
112 | | static herr_t H5G__get_info_api_common(hid_t loc_id, H5G_info_t *group_info /*out*/, void **token_ptr, |
113 | | H5VL_object_t **_vol_obj_ptr); |
114 | | static herr_t H5G__get_info_by_name_api_common(hid_t loc_id, const char *name, H5G_info_t *group_info /*out*/, |
115 | | hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); |
116 | | static herr_t H5G__get_info_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type, |
117 | | H5_iter_order_t order, hsize_t n, |
118 | | H5G_info_t *group_info /*out*/, hid_t lapl_id, void **token_ptr, |
119 | | H5VL_object_t **_vol_obj_ptr); |
120 | | |
121 | | /*********************/ |
122 | | /* Package Variables */ |
123 | | /*********************/ |
124 | | |
125 | | /*****************************/ |
126 | | /* Library Private Variables */ |
127 | | /*****************************/ |
128 | | |
129 | | /*******************/ |
130 | | /* Local Variables */ |
131 | | /*******************/ |
132 | | |
133 | | /*------------------------------------------------------------------------- |
134 | | * Function: H5G__create_api_common |
135 | | * |
136 | | * Purpose: This is the common function for creating HDF5 groups. |
137 | | * |
138 | | * Return: Success: A group ID |
139 | | * Failure: H5I_INVALID_HID |
140 | | * |
141 | | *------------------------------------------------------------------------- |
142 | | */ |
143 | | static hid_t |
144 | | H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, |
145 | | void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
146 | 0 | { |
147 | 0 | void *grp = NULL; /* Structure for new group */ |
148 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
149 | 0 | H5VL_object_t **vol_obj_ptr = |
150 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
151 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
152 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
153 | |
|
154 | 0 | FUNC_ENTER_PACKAGE |
155 | | |
156 | | /* Check arguments */ |
157 | 0 | if (!name) |
158 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL"); |
159 | 0 | if (!*name) |
160 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string"); |
161 | | |
162 | | /* Set up object access arguments */ |
163 | 0 | if (H5VL_setup_acc_args(loc_id, H5P_CLS_GACC, true, &gapl_id, vol_obj_ptr, &loc_params) < 0) |
164 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments"); |
165 | | |
166 | | /* Check link creation property list */ |
167 | 0 | if (H5P_DEFAULT == lcpl_id) |
168 | 0 | lcpl_id = H5P_LINK_CREATE_DEFAULT; |
169 | 0 | else if (true != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) |
170 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a link creation property list"); |
171 | | |
172 | | /* Check group creation property list */ |
173 | 0 | if (H5P_DEFAULT == gcpl_id) |
174 | 0 | gcpl_id = H5P_GROUP_CREATE_DEFAULT; |
175 | 0 | else if (true != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) |
176 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group creation property list"); |
177 | | |
178 | | /* Set the LCPL for the API context */ |
179 | 0 | H5CX_set_lcpl(lcpl_id); |
180 | | |
181 | | /* Create the group */ |
182 | 0 | if (NULL == (grp = H5VL_group_create(*vol_obj_ptr, &loc_params, name, lcpl_id, gcpl_id, gapl_id, |
183 | 0 | H5P_DATASET_XFER_DEFAULT, token_ptr))) |
184 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group"); |
185 | | |
186 | | /* Get an ID for the group */ |
187 | 0 | if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) |
188 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle"); |
189 | | |
190 | 0 | done: |
191 | 0 | if (H5I_INVALID_HID == ret_value) |
192 | 0 | if (grp && H5VL_group_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
193 | 0 | HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); |
194 | |
|
195 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
196 | 0 | } /* end H5G__create_api_common() */ |
197 | | |
198 | | /*------------------------------------------------------------------------- |
199 | | * Function: H5Gcreate2 |
200 | | * |
201 | | * Purpose: Creates a new group relative to LOC_ID, giving it the |
202 | | * specified creation property list GCPL_ID and access |
203 | | * property list GAPL_ID. The link to the new group is |
204 | | * created with the LCPL_ID. |
205 | | * |
206 | | * Usage: H5Gcreate2(loc_id, char *name, lcpl_id, gcpl_id, gapl_id) |
207 | | * hid_t loc_id; IN: File or group identifier |
208 | | * const char *name; IN: Absolute or relative name of the new group |
209 | | * hid_t lcpl_id; IN: Property list for link creation |
210 | | * hid_t gcpl_id; IN: Property list for group creation |
211 | | * hid_t gapl_id; IN: Property list for group access |
212 | | * |
213 | | * Return: Success: The object ID of a new, empty group open for |
214 | | * writing. Call H5Gclose() when finished with |
215 | | * the group. |
216 | | * |
217 | | * Failure: H5I_INVALID_HID |
218 | | * |
219 | | *------------------------------------------------------------------------- |
220 | | */ |
221 | | hid_t |
222 | | H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) |
223 | 0 | { |
224 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
225 | |
|
226 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
227 | | |
228 | | /* Create the group synchronously */ |
229 | 0 | if ((ret_value = H5G__create_api_common(loc_id, name, lcpl_id, gcpl_id, gapl_id, NULL, NULL)) < 0) |
230 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to synchronously create group"); |
231 | | |
232 | 0 | done: |
233 | 0 | FUNC_LEAVE_API(ret_value) |
234 | 0 | } /* end H5Gcreate2() */ |
235 | | |
236 | | /*------------------------------------------------------------------------- |
237 | | * Function: H5Gcreate_async |
238 | | * |
239 | | * Purpose: Asynchronous version of H5Gcreate |
240 | | * |
241 | | * Return: Success: A group ID |
242 | | * Failure: H5I_INVALID_HID |
243 | | * |
244 | | *------------------------------------------------------------------------- |
245 | | */ |
246 | | hid_t |
247 | | H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, const char *name, |
248 | | hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t es_id) |
249 | 0 | { |
250 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
251 | 0 | void *token = NULL; /* Request token for async operation */ |
252 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
253 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
254 | |
|
255 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
256 | | |
257 | | /* Set up request token pointer for asynchronous operation */ |
258 | 0 | if (H5ES_NONE != es_id) |
259 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
260 | | |
261 | | /* Create the group asynchronously */ |
262 | 0 | if ((ret_value = H5G__create_api_common(loc_id, name, lcpl_id, gcpl_id, gapl_id, token_ptr, &vol_obj)) < |
263 | 0 | 0) |
264 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to asynchronously create group"); |
265 | | |
266 | | /* If a token was created, add the token to the event set */ |
267 | 0 | if (NULL != token) |
268 | | /* clang-format off */ |
269 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
270 | 0 | H5ARG_TRACE9(__func__, "*s*sIui*siiii", app_file, app_func, app_line, loc_id, name, lcpl_id, gcpl_id, gapl_id, es_id)) < 0) { |
271 | | /* clang-format on */ |
272 | 0 | if (H5I_dec_app_ref_always_close(ret_value) < 0) |
273 | 0 | HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID"); |
274 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); |
275 | 0 | } /* end if */ |
276 | | |
277 | 0 | done: |
278 | 0 | FUNC_LEAVE_API(ret_value) |
279 | 0 | } /* end H5Gcreate_async() */ |
280 | | |
281 | | /*------------------------------------------------------------------------- |
282 | | * Function: H5Gcreate_anon |
283 | | * |
284 | | * Purpose: Creates a new group relative to LOC_ID, giving it the |
285 | | * specified creation property list GCPL_ID and access |
286 | | * property list GAPL_ID. |
287 | | * |
288 | | * The resulting ID should be linked into the file with |
289 | | * H5Olink or it will be deleted when closed. |
290 | | * |
291 | | * Given the default setting, H5Gcreate_anon() followed by |
292 | | * H5Olink() will have the same function as H5Gcreate2(). |
293 | | * |
294 | | * Usage: H5Gcreate_anon(loc_id, char *name, gcpl_id, gapl_id) |
295 | | * hid_t loc_id; IN: File or group identifier |
296 | | * const char *name; IN: Absolute or relative name of the new group |
297 | | * hid_t gcpl_id; IN: Property list for group creation |
298 | | * hid_t gapl_id; IN: Property list for group access |
299 | | * |
300 | | * Example: To create missing groups "A" and "B01" along the given path "/A/B01/grp" |
301 | | * hid_t create_id = H5Pcreate(H5P_GROUP_CREATE); |
302 | | * int status = H5Pset_create_intermediate_group(create_id, true); |
303 | | * hid_t gid = H5Gcreate_anon(file_id, "/A/B01/grp", create_id, H5P_DEFAULT); |
304 | | * |
305 | | * Return: Success: The object ID of a new, empty group open for |
306 | | * writing. Call H5Gclose() when finished with |
307 | | * the group. |
308 | | * |
309 | | * Failure: H5I_INVALID_HID |
310 | | * |
311 | | *------------------------------------------------------------------------- |
312 | | */ |
313 | | hid_t |
314 | | H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) |
315 | 0 | { |
316 | 0 | void *grp = NULL; /* Structure for new group */ |
317 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
318 | 0 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
319 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
320 | |
|
321 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
322 | | |
323 | | /* Check group property list */ |
324 | 0 | if (H5P_DEFAULT == gcpl_id) |
325 | 0 | gcpl_id = H5P_GROUP_CREATE_DEFAULT; |
326 | 0 | else if (true != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) |
327 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list"); |
328 | | |
329 | 0 | if (H5P_DEFAULT == gapl_id) |
330 | 0 | gapl_id = H5P_GROUP_ACCESS_DEFAULT; |
331 | 0 | else if (true != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) |
332 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group access property list"); |
333 | | |
334 | | /* Verify access property list and set up collective metadata if appropriate */ |
335 | 0 | if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, true) < 0) |
336 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info"); |
337 | | |
338 | | /* Set location struct fields */ |
339 | 0 | loc_params.type = H5VL_OBJECT_BY_SELF; |
340 | 0 | loc_params.obj_type = H5I_get_type(loc_id); |
341 | | |
342 | | /* Get the location object */ |
343 | 0 | if (NULL == (vol_obj = H5VL_vol_object(loc_id))) |
344 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier"); |
345 | | |
346 | | /* Create the group */ |
347 | 0 | if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl_id, |
348 | 0 | gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) |
349 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group"); |
350 | | |
351 | | /* Get an ID for the group */ |
352 | 0 | if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) |
353 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle"); |
354 | | |
355 | 0 | done: |
356 | | /* Cleanup on failure */ |
357 | 0 | if (H5I_INVALID_HID == ret_value) |
358 | 0 | if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
359 | 0 | HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); |
360 | |
|
361 | 0 | FUNC_LEAVE_API(ret_value) |
362 | 0 | } /* end H5Gcreate_anon() */ |
363 | | |
364 | | /*------------------------------------------------------------------------- |
365 | | * Function: H5G__open_api_common |
366 | | * |
367 | | * Purpose: This is the common function for opening HDF5 groups. |
368 | | * |
369 | | * Return: Success: A group ID |
370 | | * Failure: H5I_INVALID_HID |
371 | | * |
372 | | *------------------------------------------------------------------------- |
373 | | */ |
374 | | static hid_t |
375 | | H5G__open_api_common(hid_t loc_id, const char *name, hid_t gapl_id, void **token_ptr, |
376 | | H5VL_object_t **_vol_obj_ptr) |
377 | 494 | { |
378 | 494 | void *grp = NULL; /* Group opened */ |
379 | 494 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
380 | 494 | H5VL_object_t **vol_obj_ptr = |
381 | 494 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
382 | 494 | H5VL_loc_params_t loc_params; /* Location parameters for object access */ |
383 | 494 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
384 | | |
385 | 494 | FUNC_ENTER_PACKAGE |
386 | | |
387 | | /* Check args */ |
388 | 494 | if (!name) |
389 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL"); |
390 | 494 | if (!*name) |
391 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string"); |
392 | | |
393 | | /* Set up object access arguments */ |
394 | 494 | if (H5VL_setup_acc_args(loc_id, H5P_CLS_GACC, false, &gapl_id, vol_obj_ptr, &loc_params) < 0) |
395 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments"); |
396 | | |
397 | 494 | if (NULL == (grp = H5VL_group_open(*vol_obj_ptr, &loc_params, name, gapl_id, H5P_DATASET_XFER_DEFAULT, |
398 | 494 | token_ptr))) |
399 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group"); |
400 | | |
401 | | /* Register an ID for the group */ |
402 | 494 | if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) |
403 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group"); |
404 | | |
405 | 494 | done: |
406 | 494 | if (H5I_INVALID_HID == ret_value) |
407 | 0 | if (grp && H5VL_group_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
408 | 0 | HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); |
409 | | |
410 | 494 | FUNC_LEAVE_NOAPI(ret_value) |
411 | 494 | } /* H5G__open_api_common() */ |
412 | | |
413 | | /*------------------------------------------------------------------------- |
414 | | * Function: H5Gopen2 |
415 | | * |
416 | | * Purpose: Opens an existing group for modification. When finished, |
417 | | * call H5Gclose() to close it and release resources. |
418 | | * |
419 | | * This function allows the user the pass in a Group Access |
420 | | * Property List, which H5Gopen1() does not. |
421 | | * |
422 | | * Return: Success: Object ID of the group |
423 | | * |
424 | | * Failure: H5I_INVALID_HID |
425 | | * |
426 | | *------------------------------------------------------------------------- |
427 | | */ |
428 | | hid_t |
429 | | H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) |
430 | 494 | { |
431 | 494 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
432 | | |
433 | 988 | FUNC_ENTER_API(H5I_INVALID_HID) |
434 | | |
435 | | /* Open the group synchronously */ |
436 | 988 | if ((ret_value = H5G__open_api_common(loc_id, name, gapl_id, NULL, NULL)) < 0) |
437 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to synchronously open group"); |
438 | | |
439 | 494 | done: |
440 | 494 | FUNC_LEAVE_API(ret_value) |
441 | 988 | } /* end H5Gopen2() */ |
442 | | |
443 | | /*------------------------------------------------------------------------- |
444 | | * Function: H5Gopen_async |
445 | | * |
446 | | * Purpose: Asynchronous version of H5Gopen2 |
447 | | * |
448 | | * Return: Success: A group ID |
449 | | * Failure: H5I_INVALID_HID |
450 | | * |
451 | | *------------------------------------------------------------------------- |
452 | | */ |
453 | | hid_t |
454 | | H5Gopen_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, const char *name, |
455 | | hid_t gapl_id, hid_t es_id) |
456 | 0 | { |
457 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
458 | 0 | void *token = NULL; /* Request token for async operation */ |
459 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
460 | 0 | hid_t ret_value = H5I_INVALID_HID; /* Return value */ |
461 | |
|
462 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
463 | | |
464 | | /* Set up request token pointer for asynchronous operation */ |
465 | 0 | if (H5ES_NONE != es_id) |
466 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
467 | | |
468 | | /* Open the group asynchronously */ |
469 | 0 | if ((ret_value = H5G__open_api_common(loc_id, name, gapl_id, token_ptr, &vol_obj)) < 0) |
470 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to asynchronously open group"); |
471 | | |
472 | | /* If a token was created, add the token to the event set */ |
473 | 0 | if (NULL != token) |
474 | | /* clang-format off */ |
475 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
476 | 0 | H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, gapl_id, es_id)) < 0) { |
477 | | /* clang-format on */ |
478 | 0 | if (H5I_dec_app_ref_always_close(ret_value) < 0) |
479 | 0 | HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID"); |
480 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); |
481 | 0 | } /* end if */ |
482 | | |
483 | 0 | done: |
484 | 0 | FUNC_LEAVE_API(ret_value) |
485 | 0 | } /* end H5Gopen_async() */ |
486 | | |
487 | | /*------------------------------------------------------------------------- |
488 | | * Function: H5Gget_create_plist |
489 | | * |
490 | | * Purpose: Returns a copy of the group creation property list. |
491 | | * |
492 | | * Return: Success: ID for a copy of the group creation |
493 | | * property list. The property list ID should be |
494 | | * released by calling H5Pclose(). |
495 | | * |
496 | | * Failure: H5I_INVALID_HID |
497 | | * |
498 | | *------------------------------------------------------------------------- |
499 | | */ |
500 | | hid_t |
501 | | H5Gget_create_plist(hid_t group_id) |
502 | 0 | { |
503 | 0 | H5VL_object_t *vol_obj; /* Object for loc_id */ |
504 | 0 | H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
505 | 0 | hid_t ret_value = H5I_INVALID_HID; |
506 | |
|
507 | 0 | FUNC_ENTER_API(H5I_INVALID_HID) |
508 | | |
509 | | /* Check args */ |
510 | 0 | if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP))) |
511 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID"); |
512 | | |
513 | | /* Set up VOL callback arguments */ |
514 | 0 | vol_cb_args.op_type = H5VL_GROUP_GET_GCPL; |
515 | 0 | vol_cb_args.args.get_gcpl.gcpl_id = H5I_INVALID_HID; |
516 | | |
517 | | /* Get the group creation property list for the group */ |
518 | 0 | if (H5VL_group_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
519 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list"); |
520 | | |
521 | | /* Set the return value */ |
522 | 0 | ret_value = vol_cb_args.args.get_gcpl.gcpl_id; |
523 | |
|
524 | 0 | done: |
525 | 0 | FUNC_LEAVE_API(ret_value) |
526 | 0 | } /* end H5Gget_create_plist() */ |
527 | | |
528 | | /*------------------------------------------------------------------------- |
529 | | * Function: H5G__get_info_api_common |
530 | | * |
531 | | * Purpose: This is the common function for retrieving information |
532 | | * about a group. |
533 | | * |
534 | | * Return: SUCCEED/FAIL |
535 | | * |
536 | | *------------------------------------------------------------------------- |
537 | | */ |
538 | | static herr_t |
539 | | H5G__get_info_api_common(hid_t loc_id, H5G_info_t *group_info /*out*/, void **token_ptr, |
540 | | H5VL_object_t **_vol_obj_ptr) |
541 | 91 | { |
542 | 91 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
543 | 91 | H5VL_object_t **vol_obj_ptr = |
544 | 91 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
545 | 91 | H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
546 | 91 | H5I_type_t id_type; /* Type of ID */ |
547 | 91 | herr_t ret_value = SUCCEED; /* Return value */ |
548 | | |
549 | 91 | FUNC_ENTER_PACKAGE |
550 | | |
551 | | /* Check args */ |
552 | 91 | id_type = H5I_get_type(loc_id); |
553 | 91 | if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) |
554 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID"); |
555 | 91 | if (!group_info) |
556 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL"); |
557 | | |
558 | | /* Set up VOL callback & object access arguments */ |
559 | 91 | vol_cb_args.op_type = H5VL_GROUP_GET_INFO; |
560 | 91 | if (H5VL_setup_self_args(loc_id, vol_obj_ptr, &vol_cb_args.args.get_info.loc_params) < 0) |
561 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments"); |
562 | 91 | vol_cb_args.args.get_info.ginfo = group_info; |
563 | | |
564 | | /* Retrieve group information */ |
565 | 91 | if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) |
566 | 11 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info"); |
567 | | |
568 | 91 | done: |
569 | 91 | FUNC_LEAVE_NOAPI(ret_value) |
570 | 91 | } /* H5G__get_info_api_common() */ |
571 | | |
572 | | /*------------------------------------------------------------------------- |
573 | | * Function: H5Gget_info |
574 | | * |
575 | | * Purpose: Retrieve information about a group. |
576 | | * |
577 | | * Return: SUCCEED/FAIL |
578 | | * |
579 | | *------------------------------------------------------------------------- |
580 | | */ |
581 | | herr_t |
582 | | H5Gget_info(hid_t loc_id, H5G_info_t *group_info /*out*/) |
583 | 91 | { |
584 | 91 | herr_t ret_value = SUCCEED; /* Return value */ |
585 | | |
586 | 182 | FUNC_ENTER_API(FAIL) |
587 | | |
588 | | /* Retrieve group information synchronously */ |
589 | 182 | if (H5G__get_info_api_common(loc_id, group_info, NULL, NULL) < 0) |
590 | 11 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to synchronously get group info"); |
591 | | |
592 | 91 | done: |
593 | 91 | FUNC_LEAVE_API(ret_value) |
594 | 182 | } /* end H5Gget_info() */ |
595 | | |
596 | | /*------------------------------------------------------------------------- |
597 | | * Function: H5Gget_info_async |
598 | | * |
599 | | * Purpose: Asynchronous version of H5Gget_info |
600 | | * |
601 | | * Return: SUCCEED/FAIL |
602 | | * |
603 | | *------------------------------------------------------------------------- |
604 | | */ |
605 | | herr_t |
606 | | H5Gget_info_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, |
607 | | H5G_info_t *group_info /*out*/, hid_t es_id) |
608 | 0 | { |
609 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
610 | 0 | void *token = NULL; /* Request token for async operation */ |
611 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
612 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
613 | |
|
614 | 0 | FUNC_ENTER_API(FAIL) |
615 | | |
616 | | /* Set up request token pointer for asynchronous operation */ |
617 | 0 | if (H5ES_NONE != es_id) |
618 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
619 | | |
620 | | /* Retrieve group information asynchronously */ |
621 | 0 | if (H5G__get_info_api_common(loc_id, group_info, token_ptr, &vol_obj) < 0) |
622 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to asynchronously get group info"); |
623 | | |
624 | | /* If a token was created, add the token to the event set */ |
625 | 0 | if (NULL != token) |
626 | | /* clang-format off */ |
627 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
628 | 0 | H5ARG_TRACE6(__func__, "*s*sIui*GIi", app_file, app_func, app_line, loc_id, group_info, es_id)) < 0) |
629 | | /* clang-format on */ |
630 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
631 | | |
632 | 0 | done: |
633 | 0 | FUNC_LEAVE_API(ret_value) |
634 | 0 | } /* H5Gget_info_async() */ |
635 | | |
636 | | /*------------------------------------------------------------------------- |
637 | | * Function: H5G__get_info_by_name_api_common |
638 | | * |
639 | | * Purpose: This is the common function for retrieving information |
640 | | * about a group. |
641 | | * |
642 | | * Return: SUCCEED/FAIL |
643 | | * |
644 | | *------------------------------------------------------------------------- |
645 | | */ |
646 | | static herr_t |
647 | | H5G__get_info_by_name_api_common(hid_t loc_id, const char *name, H5G_info_t *group_info /*out*/, |
648 | | hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
649 | 0 | { |
650 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
651 | 0 | H5VL_object_t **vol_obj_ptr = |
652 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
653 | 0 | H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
654 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
655 | |
|
656 | 0 | FUNC_ENTER_PACKAGE |
657 | | |
658 | | /* Check args */ |
659 | 0 | if (!group_info) |
660 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL"); |
661 | | |
662 | | /* Set up VOL callback & object access arguments */ |
663 | 0 | vol_cb_args.op_type = H5VL_GROUP_GET_INFO; |
664 | 0 | if (H5VL_setup_name_args(loc_id, name, false, lapl_id, vol_obj_ptr, |
665 | 0 | &vol_cb_args.args.get_info.loc_params) < 0) |
666 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments"); |
667 | 0 | vol_cb_args.args.get_info.ginfo = group_info; |
668 | | |
669 | | /* Retrieve group information */ |
670 | 0 | if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) |
671 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info"); |
672 | | |
673 | 0 | done: |
674 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
675 | 0 | } /* H5G__get_info_by_name_api_common() */ |
676 | | |
677 | | /*------------------------------------------------------------------------- |
678 | | * Function: H5Gget_info_by_name |
679 | | * |
680 | | * Purpose: Retrieve information about a group, where the group is |
681 | | * identified by name instead of ID. |
682 | | * |
683 | | * Return: SUCCEED/FAIL |
684 | | * |
685 | | *------------------------------------------------------------------------- |
686 | | */ |
687 | | herr_t |
688 | | H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info /*out*/, hid_t lapl_id) |
689 | 0 | { |
690 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
691 | |
|
692 | 0 | FUNC_ENTER_API(FAIL) |
693 | | |
694 | | /* Retrieve group information synchronously */ |
695 | 0 | if (H5G__get_info_by_name_api_common(loc_id, name, group_info, lapl_id, NULL, NULL) < 0) |
696 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't synchronously retrieve group info"); |
697 | | |
698 | 0 | done: |
699 | 0 | FUNC_LEAVE_API(ret_value) |
700 | 0 | } /* end H5Gget_info_by_name() */ |
701 | | |
702 | | /*------------------------------------------------------------------------- |
703 | | * Function: H5Gget_info_by_name_async |
704 | | * |
705 | | * Purpose: Asynchronous version of H5Gget_info_by_name |
706 | | * |
707 | | * Return: SUCCEED/FAIL |
708 | | * |
709 | | *------------------------------------------------------------------------- |
710 | | */ |
711 | | herr_t |
712 | | H5Gget_info_by_name_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, |
713 | | const char *name, H5G_info_t *group_info /*out*/, hid_t lapl_id, hid_t es_id) |
714 | 0 | { |
715 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
716 | 0 | void *token = NULL; /* Request token for async operation */ |
717 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
718 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
719 | |
|
720 | 0 | FUNC_ENTER_API(FAIL) |
721 | | |
722 | | /* Set up request token pointer for asynchronous operation */ |
723 | 0 | if (H5ES_NONE != es_id) |
724 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
725 | | |
726 | | /* Retrieve group information asynchronously */ |
727 | 0 | if (H5G__get_info_by_name_api_common(loc_id, name, group_info, lapl_id, token_ptr, &vol_obj) < 0) |
728 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't asynchronously retrieve group info"); |
729 | | |
730 | | /* If a token was created, add the token to the event set */ |
731 | 0 | if (NULL != token) |
732 | | /* clang-format off */ |
733 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
734 | 0 | H5ARG_TRACE8(__func__, "*s*sIui*s*GIii", app_file, app_func, app_line, loc_id, name, group_info, lapl_id, es_id)) < 0) |
735 | | /* clang-format on */ |
736 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
737 | | |
738 | 0 | done: |
739 | 0 | FUNC_LEAVE_API(ret_value) |
740 | 0 | } /* H5Gget_info_by_name_async() */ |
741 | | |
742 | | /*------------------------------------------------------------------------- |
743 | | * Function: H5G__get_info_by_idx_api_common |
744 | | * |
745 | | * Purpose: This is the common function for retrieving information |
746 | | * about a group. |
747 | | * |
748 | | * Return: SUCCEED/FAIL |
749 | | * |
750 | | *------------------------------------------------------------------------- |
751 | | */ |
752 | | static herr_t |
753 | | H5G__get_info_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type, |
754 | | H5_iter_order_t order, hsize_t n, H5G_info_t *group_info /*out*/, |
755 | | hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) |
756 | 0 | { |
757 | 0 | H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ |
758 | 0 | H5VL_object_t **vol_obj_ptr = |
759 | 0 | (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ |
760 | 0 | H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ |
761 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
762 | |
|
763 | 0 | FUNC_ENTER_PACKAGE |
764 | | |
765 | | /* Check args */ |
766 | 0 | if (!group_info) |
767 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL"); |
768 | | |
769 | | /* Set up VOL callback & object access arguments */ |
770 | 0 | vol_cb_args.op_type = H5VL_GROUP_GET_INFO; |
771 | 0 | if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, false, lapl_id, vol_obj_ptr, |
772 | 0 | &vol_cb_args.args.get_info.loc_params) < 0) |
773 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments"); |
774 | 0 | vol_cb_args.args.get_info.ginfo = group_info; |
775 | | |
776 | | /* Retrieve group information */ |
777 | 0 | if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) |
778 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info"); |
779 | | |
780 | 0 | done: |
781 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
782 | 0 | } /* H5G__get_info_by_idx_api_common() */ |
783 | | |
784 | | /*------------------------------------------------------------------------- |
785 | | * Function: H5Gget_info_by_idx |
786 | | * |
787 | | * Purpose: Retrieve information about a group, according to the order |
788 | | * of an index. |
789 | | * |
790 | | * Return: SUCCEED/FAIL |
791 | | * |
792 | | *------------------------------------------------------------------------- |
793 | | */ |
794 | | herr_t |
795 | | H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, |
796 | | hsize_t n, H5G_info_t *group_info /*out*/, hid_t lapl_id) |
797 | 0 | { |
798 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
799 | |
|
800 | 0 | FUNC_ENTER_API(FAIL) |
801 | | |
802 | | /* Retrieve group information synchronously */ |
803 | 0 | if (H5G__get_info_by_idx_api_common(loc_id, group_name, idx_type, order, n, group_info, lapl_id, NULL, |
804 | 0 | NULL) < 0) |
805 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't synchronously retrieve group info"); |
806 | | |
807 | 0 | done: |
808 | 0 | FUNC_LEAVE_API(ret_value) |
809 | 0 | } /* end H5Gget_info_by_idx() */ |
810 | | |
811 | | /*------------------------------------------------------------------------- |
812 | | * Function: H5Gget_info_by_idx_async |
813 | | * |
814 | | * Purpose: Asynchronous version of H5Gget_info_by_idx |
815 | | * |
816 | | * Return: SUCCEED/FAIL |
817 | | * |
818 | | *------------------------------------------------------------------------- |
819 | | */ |
820 | | herr_t |
821 | | H5Gget_info_by_idx_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, |
822 | | const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, |
823 | | H5G_info_t *group_info /*out*/, hid_t lapl_id, hid_t es_id) |
824 | 0 | { |
825 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
826 | 0 | void *token = NULL; /* Request token for async operation */ |
827 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
828 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
829 | |
|
830 | 0 | FUNC_ENTER_API(FAIL) |
831 | | |
832 | | /* Set up request token pointer for asynchronous operation */ |
833 | 0 | if (H5ES_NONE != es_id) |
834 | 0 | token_ptr = &token; /* Point at token for VOL connector to set up */ |
835 | | |
836 | | /* Retrieve group information asynchronously */ |
837 | 0 | if (H5G__get_info_by_idx_api_common(loc_id, group_name, idx_type, order, n, group_info, lapl_id, |
838 | 0 | token_ptr, &vol_obj) < 0) |
839 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't asynchronously retrieve group info"); |
840 | | |
841 | | /* If a token was created, add the token to the event set */ |
842 | 0 | if (NULL != token) |
843 | | /* clang-format off */ |
844 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
845 | 0 | H5ARG_TRACE11(__func__, "*s*sIui*sIiIoh*GIii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, group_info, lapl_id, es_id)) < 0) |
846 | | /* clang-format on */ |
847 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
848 | | |
849 | 0 | done: |
850 | 0 | FUNC_LEAVE_API(ret_value) |
851 | 0 | } /* H5Gget_info_by_idx_async() */ |
852 | | |
853 | | /*------------------------------------------------------------------------- |
854 | | * Function: H5Gclose |
855 | | * |
856 | | * Purpose: Closes the specified group. The group ID will no longer be |
857 | | * valid for accessing the group. |
858 | | * |
859 | | * Return: SUCCEED/FAIL |
860 | | * |
861 | | *------------------------------------------------------------------------- |
862 | | */ |
863 | | herr_t |
864 | | H5Gclose(hid_t group_id) |
865 | 1.10k | { |
866 | 1.10k | herr_t ret_value = SUCCEED; /* Return value */ |
867 | | |
868 | 2.21k | FUNC_ENTER_API(FAIL) |
869 | | |
870 | | /* Check arguments */ |
871 | 2.21k | if (H5I_GROUP != H5I_get_type(group_id)) |
872 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID"); |
873 | | |
874 | | /* Decrement the counter on the group ID. It will be freed if the count |
875 | | * reaches zero. |
876 | | */ |
877 | 1.10k | if (H5I_dec_app_ref(group_id) < 0) |
878 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "decrementing group ID failed"); |
879 | | |
880 | 1.10k | done: |
881 | 1.10k | FUNC_LEAVE_API(ret_value) |
882 | 1.10k | } /* end H5Gclose() */ |
883 | | |
884 | | /*------------------------------------------------------------------------- |
885 | | * Function: H5Gclose_async |
886 | | * |
887 | | * Purpose: Asynchronous version of H5Gclose |
888 | | * |
889 | | * Return: SUCCEED/FAIL |
890 | | * |
891 | | *------------------------------------------------------------------------- |
892 | | */ |
893 | | herr_t |
894 | | H5Gclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t group_id, hid_t es_id) |
895 | 0 | { |
896 | 0 | H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ |
897 | 0 | H5VL_connector_t *connector = NULL; /* VOL connector */ |
898 | 0 | void *token = NULL; /* Request token for async operation */ |
899 | 0 | void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ |
900 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
901 | |
|
902 | 0 | FUNC_ENTER_API(FAIL) |
903 | | |
904 | | /* Check arguments */ |
905 | 0 | if (H5I_GROUP != H5I_get_type(group_id)) |
906 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID"); |
907 | | |
908 | | /* Prepare for possible asynchronous operation */ |
909 | 0 | if (H5ES_NONE != es_id) { |
910 | | /* Get group object's connector */ |
911 | 0 | if (NULL == (vol_obj = H5VL_vol_object(group_id))) |
912 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get VOL object for group"); |
913 | | |
914 | | /* Increase connector's refcount, so it doesn't get closed if closing |
915 | | * the group closes the file */ |
916 | 0 | connector = H5VL_OBJ_CONNECTOR(vol_obj); |
917 | 0 | H5VL_conn_inc_rc(connector); |
918 | | |
919 | | /* Point at token for operation to set up */ |
920 | 0 | token_ptr = &token; |
921 | 0 | } /* end if */ |
922 | | |
923 | | /* Decrement the counter on the group ID. It will be freed if the count |
924 | | * reaches zero. |
925 | | */ |
926 | 0 | if (H5I_dec_app_ref_async(group_id, token_ptr) < 0) |
927 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "decrementing group ID failed"); |
928 | | |
929 | | /* If a token was created, add the token to the event set */ |
930 | 0 | if (NULL != token) |
931 | | /* clang-format off */ |
932 | 0 | if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, |
933 | 0 | H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, group_id, es_id)) < 0) |
934 | | /* clang-format on */ |
935 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); |
936 | | |
937 | 0 | done: |
938 | 0 | if (connector && H5VL_conn_dec_rc(connector) < 0) |
939 | 0 | HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); |
940 | |
|
941 | 0 | FUNC_LEAVE_API(ret_value) |
942 | 0 | } /* end H5Gclose_async() */ |
943 | | |
944 | | /*------------------------------------------------------------------------- |
945 | | * Function: H5Gflush |
946 | | * |
947 | | * Purpose: Flushes all buffers associated with a group to disk. |
948 | | * |
949 | | * Return: Non-negative on success, negative on failure |
950 | | * |
951 | | *------------------------------------------------------------------------- |
952 | | */ |
953 | | herr_t |
954 | | H5Gflush(hid_t group_id) |
955 | 0 | { |
956 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
957 | 0 | H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
958 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
959 | |
|
960 | 0 | FUNC_ENTER_API(FAIL) |
961 | | |
962 | | /* Check args */ |
963 | 0 | if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP))) |
964 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID"); |
965 | | |
966 | | /* Set up collective metadata if appropriate */ |
967 | 0 | if (H5CX_set_loc(group_id) < 0) |
968 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); |
969 | | |
970 | | /* Set up VOL callback arguments */ |
971 | 0 | vol_cb_args.op_type = H5VL_GROUP_FLUSH; |
972 | 0 | vol_cb_args.args.flush.grp_id = group_id; |
973 | | |
974 | | /* Flush group's metadata to file */ |
975 | 0 | if (H5VL_group_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
976 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group"); |
977 | | |
978 | 0 | done: |
979 | 0 | FUNC_LEAVE_API(ret_value) |
980 | 0 | } /* H5Gflush */ |
981 | | |
982 | | /*------------------------------------------------------------------------- |
983 | | * Function: H5Grefresh |
984 | | * |
985 | | * Purpose: Refreshes all buffers associated with a group. |
986 | | * |
987 | | * Return: Non-negative on success, negative on failure |
988 | | * |
989 | | *------------------------------------------------------------------------- |
990 | | */ |
991 | | herr_t |
992 | | H5Grefresh(hid_t group_id) |
993 | 0 | { |
994 | 0 | H5VL_object_t *vol_obj; /* Object of loc_id */ |
995 | 0 | H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ |
996 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
997 | |
|
998 | 0 | FUNC_ENTER_API(FAIL) |
999 | | |
1000 | | /* Check args */ |
1001 | 0 | if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP))) |
1002 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID"); |
1003 | | |
1004 | | /* Set up collective metadata if appropriate */ |
1005 | 0 | if (H5CX_set_loc(group_id) < 0) |
1006 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); |
1007 | | |
1008 | | /* Set up VOL callback arguments */ |
1009 | 0 | vol_cb_args.op_type = H5VL_GROUP_REFRESH; |
1010 | 0 | vol_cb_args.args.refresh.grp_id = group_id; |
1011 | | |
1012 | | /* Refresh group's metadata */ |
1013 | 0 | if (H5VL_group_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) |
1014 | 0 | HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group"); |
1015 | | |
1016 | 0 | done: |
1017 | | FUNC_LEAVE_API(ret_value) |
1018 | 0 | } /* H5Grefresh */ |