1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/****************/
/* Module Setup */
/****************/
#include "H5Lmodule.h" /* This source code file is part of the H5L module */
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5ESprivate.h" /* Event Sets */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Lpkg.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* Virtual Object Layer */
#include "H5VLnative_private.h" /* Native VOL */
/****************/
/* Local Macros */
/****************/
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Local Prototypes */
/********************/
static herr_t H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const char *link_name,
hid_t lcpl_id, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
static herr_t H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id,
const char *new_name, hid_t lcpl_id, hid_t lapl_id,
void **token_ptr, H5VL_object_t **_vol_obj_ptr);
static herr_t H5L__delete_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
static herr_t H5L__delete_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
static herr_t H5L__exists_api_common(hid_t loc_id, const char *name, hbool_t *exists, hid_t lapl_id,
void **token_ptr, H5VL_object_t **_vol_obj_ptr);
static herr_t H5L__iterate_api_common(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *idx_p, H5L_iterate2_t op, void *op_data, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
/*********************/
/* Package Variables */
/*********************/
/*****************************/
/* Library Private Variables */
/*****************************/
/*******************/
/* Local Variables */
/*******************/
/*-------------------------------------------------------------------------
* Function: H5Lmove
*
* Purpose: Renames an object within an HDF5 file and moves it to a new
* group. The original name SRC is unlinked from the group graph
* and then inserted with the new name DST (which can specify a
* new path for the object) as an atomic operation. The names
* are interpreted relative to SRC_LOC_ID and DST_LOC_ID,
* which are either file IDs or group ID.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id,
hid_t lapl_id)
{
H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */
H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
H5VL_object_t tmp_vol_obj; /* Temporary object */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id);
/* Check arguments */
if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC")
if (!src_name || !*src_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
if (!dst_name || !*dst_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
/* Check the link create property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) <
0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set location parameter for source object */
loc_params1.type = H5VL_OBJECT_BY_NAME;
loc_params1.loc_data.loc_by_name.name = src_name;
loc_params1.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params1.obj_type = H5I_get_type(src_loc_id);
/* Set location parameter for destination object */
loc_params2.type = H5VL_OBJECT_BY_NAME;
loc_params2.loc_data.loc_by_name.name = dst_name;
loc_params2.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params2.obj_type = H5I_get_type(dst_loc_id);
if (H5L_SAME_LOC != src_loc_id)
/* Get the location object */
if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
if (H5L_SAME_LOC != dst_loc_id)
/* Get the location object */
if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Make sure that the VOL connectors are the same */
if (vol_obj1 && vol_obj2) {
int same_connector = 0;
/* Check if both objects are associated with the same VOL connector */
if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes")
if (same_connector)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"Objects are accessed through different VOL connectors and can't be linked")
}
/* Construct a temporary source VOL object */
if (vol_obj1) {
tmp_vol_obj.connector = vol_obj1->connector;
tmp_vol_obj.data = vol_obj1->data;
}
else {
if (NULL == vol_obj2)
HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object")
tmp_vol_obj.connector = vol_obj2->connector;
tmp_vol_obj.data = NULL;
}
/* Move the link */
if (H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id,
H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lmove() */
/*-------------------------------------------------------------------------
* Function: H5Lcopy
*
* Purpose: Creates an identical copy of a link with the same creation
* time and target. The new link can have a different name
* and be in a different location than the original.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id,
hid_t lapl_id)
{
H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */
H5VL_loc_params_t loc_params1;
H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */
H5VL_loc_params_t loc_params2;
H5VL_object_t tmp_vol_obj; /* Temporary object */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id);
/* Check arguments */
if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC")
if (!src_name || !*src_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
if (!dst_name || !*dst_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
/* Check the link create property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) <
0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set location parameter for source object */
loc_params1.type = H5VL_OBJECT_BY_NAME;
loc_params1.loc_data.loc_by_name.name = src_name;
loc_params1.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params1.obj_type = H5I_get_type(src_loc_id);
/* Set location parameter for destination object */
loc_params2.type = H5VL_OBJECT_BY_NAME;
loc_params2.loc_data.loc_by_name.name = dst_name;
loc_params2.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params2.obj_type = H5I_get_type(dst_loc_id);
if (H5L_SAME_LOC != src_loc_id)
/* Get the location object */
if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
if (H5L_SAME_LOC != dst_loc_id)
/* Get the location object */
if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Make sure that the VOL connectors are the same */
if (vol_obj1 && vol_obj2) {
int same_connector = 0;
/* Check if both objects are associated with the same VOL connector */
if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes")
if (same_connector)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"Objects are accessed through different VOL connectors and can't be linked")
} /* end if */
/* Construct a temporary source VOL object */
if (vol_obj1) {
tmp_vol_obj.connector = vol_obj1->connector;
tmp_vol_obj.data = vol_obj1->data;
} /* end if */
else {
if (NULL == vol_obj2)
HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object pointer")
tmp_vol_obj.connector = vol_obj2->connector;
tmp_vol_obj.data = NULL;
} /* end else */
/* Copy the link */
if (H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id,
H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lcopy() */
/*-------------------------------------------------------------------------
* Function: H5L__create_soft_api_common
*
* Purpose: This is the common function for creating a soft link
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id,
hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */
H5VL_object_t **vol_obj_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */
H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
if (link_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link location id should not be H5L_SAME_LOC")
if (!link_target)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be NULL")
if (!*link_target)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be an empty string")
if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
/* link_name is verified in H5VL_setup_name_args() */
/* Get the link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up object access arguments */
if (H5VL_setup_name_args(link_loc_id, link_name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_CREATE_SOFT;
vol_cb_args.args.soft.target = link_target;
/* Create the link */
if (H5VL_link_create(&vol_cb_args, *vol_obj_ptr, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT,
token_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__create_soft_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_soft
*
* Purpose: Creates a soft link from LINK_NAME to LINK_TARGET.
*
* LINK_TARGET can be anything and is interpreted at lookup
* time relative to the group which contains the final component
* of LINK_NAME. For instance, if LINK_TARGET is `./foo' and
* LINK_NAME is `./x/y/bar' and a request is made for `./x/y/bar'
* then the actual object looked up is `./x/y/./foo'.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id,
hid_t lapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "*si*sii", link_target, link_loc_id, link_name, lcpl_id, lapl_id);
/* Creates a soft link synchronously */
if (H5L__create_soft_api_common(link_target, link_loc_id, link_name, lcpl_id, lapl_id, NULL, NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to synchronously create soft link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lcreate_soft() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_soft_async
*
* Purpose: Asynchronous version of H5Lcreate_soft
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_soft_async(const char *app_file, const char *app_func, unsigned app_line, const char *link_target,
hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE9("e", "*s*sIu*si*siii", app_file, app_func, app_line, link_target, link_loc_id, link_name,
lcpl_id, lapl_id, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Creates a soft link asynchronously */
if (H5L__create_soft_api_common(link_target, link_loc_id, link_name, lcpl_id, lapl_id, token_ptr,
&vol_obj) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to asynchronously create soft link")
/* If a token was created, add the token to the event set */
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE9(__func__, "*s*sIu*si*siii", app_file, app_func, app_line, link_target, link_loc_id, link_name, lcpl_id, lapl_id, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Lcreate_soft_async() */
/*-------------------------------------------------------------------------
* Function: H5L__create_hard_api_common
*
* Purpose: This is the common function for creating a hard link
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_loc_id, const char *link_name,
hid_t lcpl_id, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *curr_vol_obj = NULL; /* Object of cur_loc_id */
H5VL_object_t *link_vol_obj = NULL; /* Object of link_loc_id */
H5VL_object_t tmp_vol_obj; /* Temporary object */
H5VL_object_t *tmp_vol_obj_ptr = &tmp_vol_obj; /* Ptr to temporary object */
H5VL_object_t **tmp_vol_obj_ptr_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj_ptr); /* Ptr to ptr to temporary object */
H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t link_loc_params; /* Location parameters for link_loc_id object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
if (cur_loc_id == H5L_SAME_LOC && link_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC")
if (!cur_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be NULL")
if (!*cur_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be an empty string")
if (!link_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be NULL")
if (!*link_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be an empty string")
if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
/* Check the link create property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up new location struct */
link_loc_params.type = H5VL_OBJECT_BY_NAME;
link_loc_params.obj_type = H5I_get_type(link_loc_id);
link_loc_params.loc_data.loc_by_name.name = link_name;
link_loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
if (H5L_SAME_LOC != cur_loc_id)
/* Get the current location object */
if (NULL == (curr_vol_obj = (H5VL_object_t *)H5VL_vol_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
if (H5L_SAME_LOC != link_loc_id)
/* Get the new location object */
if (NULL == (link_vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Make sure that the VOL connectors are the same */
if (curr_vol_obj && link_vol_obj) {
int same_connector = 0;
/* Check if both objects are associated with the same VOL connector */
if (H5VL_cmp_connector_cls(&same_connector, curr_vol_obj->connector->cls,
link_vol_obj->connector->cls) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes")
if (same_connector)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"Objects are accessed through different VOL connectors and can't be linked")
} /* end if */
/* Construct a temporary VOL object */
if (curr_vol_obj)
(*tmp_vol_obj_ptr_ptr)->connector = curr_vol_obj->connector;
else {
if (NULL == link_vol_obj)
HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object pointer")
(*tmp_vol_obj_ptr_ptr)->connector = link_vol_obj->connector;
} /* end else */
if (link_vol_obj)
(*tmp_vol_obj_ptr_ptr)->data = link_vol_obj->data;
else
(*tmp_vol_obj_ptr_ptr)->data = NULL;
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_CREATE_HARD;
vol_cb_args.args.hard.curr_obj = (curr_vol_obj ? curr_vol_obj->data : NULL);
vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME;
vol_cb_args.args.hard.curr_loc_params.obj_type =
(H5L_SAME_LOC != cur_loc_id ? H5I_get_type(cur_loc_id) : H5I_BADID);
vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name;
vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
/* Create the link */
if (H5VL_link_create(&vol_cb_args, *tmp_vol_obj_ptr_ptr, &link_loc_params, lcpl_id, lapl_id,
H5P_DATASET_XFER_DEFAULT, token_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__create_hard_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_hard
*
* Purpose: Creates a hard link from NEW_NAME to CUR_NAME.
*
* CUR_NAME must name an existing object. CUR_NAME and
* NEW_NAME are interpreted relative to CUR_LOC_ID and
* NEW_LOC_ID, which are either file IDs or group IDs.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
hid_t lapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id);
/* Creates a hard link synchronously */
if (H5L__create_hard_api_common(cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, NULL,
NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to synchronously create hard link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lcreate_hard() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_hard_async
*
* Purpose: Asynchronous version of H5Lcreate_hard
*
* Note: The implementation for this routine is different from other
* _async operations, as the 'api_common' routine needs a "real"
* H5VL_object_t to point at, which is usually provided by the
* loc_id, but isn't here.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_hard_async(const char *app_file, const char *app_func, unsigned app_line, hid_t cur_loc_id,
const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
hid_t lapl_id, hid_t es_id)
{
H5VL_object_t vol_obj; /* Object for loc_id */
H5VL_object_t *vol_obj_ptr = &vol_obj; /* Pointer to object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE10("e", "*s*sIui*si*siii", app_file, app_func, app_line, cur_loc_id, cur_name, new_loc_id,
new_name, lcpl_id, lapl_id, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Creates a hard link asynchronously */
if (H5L__create_hard_api_common(cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, token_ptr,
&vol_obj_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to asynchronously create hard link")
/* If a token was created, add the token to the event set */
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj_ptr->connector, token,
H5ARG_TRACE10(__func__, "*s*sIui*si*siii", app_file, app_func, app_line, cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Lcreate_hard_async() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_external
*
* Purpose: Creates an external link from LINK_NAME to OBJ_NAME.
*
* External links are links to objects in other HDF5 files. They
* are allowed to "dangle" like soft links internal to a file.
* FILE_NAME is the name of the file that OBJ_NAME is contained
* within. If OBJ_NAME is given as a relative path name, the
* path will be relative to the root group of FILE_NAME.
* LINK_NAME is interpreted relative to LINK_LOC_ID, which is
* either a file ID or a group ID.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name,
hid_t lcpl_id, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* Object of loc_id */
H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
char *norm_obj_name = NULL; /* Pointer to normalized current name */
void *ext_link_buf = NULL; /* Buffer to contain external link */
size_t buf_size; /* Size of buffer to hold external link */
size_t file_name_len; /* Length of file name string */
size_t norm_obj_name_len; /* Length of normalized object name string */
uint8_t *p; /* Pointer into external link buffer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id);
/* Check arguments */
if (!file_name || !*file_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified")
if (!obj_name || !*obj_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified")
if (!link_name || !*link_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified")
/* Get the link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Get normalized copy of the link target */
if (NULL == (norm_obj_name = H5G_normalize(obj_name)))
HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize object name")
/* Combine the filename and link name into a single buffer to give to the UD link */
file_name_len = HDstrlen(file_name) + 1;
norm_obj_name_len = HDstrlen(norm_obj_name) + 1;
buf_size = 1 + file_name_len + norm_obj_name_len;
if (NULL == (ext_link_buf = H5MM_malloc(buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer")
/* Encode the external link information */
p = (uint8_t *)ext_link_buf;
*p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */
HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */
p += file_name_len;
HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = link_name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params.obj_type = H5I_get_type(link_loc_id);
/* get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_CREATE_UD;
vol_cb_args.args.ud.type = H5L_TYPE_EXTERNAL;
vol_cb_args.args.ud.buf = ext_link_buf;
vol_cb_args.args.ud.buf_size = buf_size;
/* Create an external link */
if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT,
H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link")
done:
H5MM_xfree(ext_link_buf);
H5MM_xfree(norm_obj_name);
FUNC_LEAVE_API(ret_value)
} /* end H5Lcreate_external() */
/*-------------------------------------------------------------------------
* Function: H5Lcreate_ud
*
* Purpose: Creates a user-defined link of type LINK_TYPE named LINK_NAME
* with user-specified data UDATA.
*
* The format of the information pointed to by UDATA is
* defined by the user. UDATA_SIZE holds the size of this buffer.
*
* LINK_NAME is interpreted relative to LINK_LOC_ID.
*
* The property list specified by LCPL_ID holds properties used
* to create the link.
*
* The link class of the new link must already be registered
* with the library.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata,
size_t udata_size, hid_t lcpl_id, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* Object of loc_id */
H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, udata_size, lcpl_id, lapl_id);
/* Check arguments */
if (!link_name || !*link_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified")
if (link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class")
if (!udata && udata_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero")
/* Get the link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = link_name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
loc_params.obj_type = H5I_get_type(link_loc_id);
/* get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_CREATE_UD;
vol_cb_args.args.ud.type = link_type;
vol_cb_args.args.ud.buf = udata;
vol_cb_args.args.ud.buf_size = udata_size;
/* Create user-defined link */
if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT,
H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lcreate_ud() */
/*-------------------------------------------------------------------------
* Function: H5L__delete_api_common
*
* Purpose: This is the common function for deleting a link
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5L__delete_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */
H5VL_object_t **vol_obj_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
/* name is verified in H5VL_setup_name_args() */
/* Set up object access arguments */
if (H5VL_setup_name_args(loc_id, name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_DELETE;
/* Delete link */
if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__delete_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Ldelete
*
* Purpose: Removes the specified NAME from the group graph and
* decrements the link count for the object to which NAME
* points. If the link count reaches zero then all file-space
* associated with the object will be reclaimed (but if the
* object is open, then the reclamation of the file space is
* delayed until all handles to the object are closed).
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*si", loc_id, name, lapl_id);
/* Delete a link synchronously */
if (H5L__delete_api_common(loc_id, name, lapl_id, NULL, NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to synchronously delete link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Ldelete() */
/*-------------------------------------------------------------------------
* Function: H5Ldelete_async
*
* Purpose: Asynchronous version of H5Ldelete
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Ldelete_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, const char *name,
hid_t lapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("e", "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Delete a link asynchronously */
if (H5L__delete_api_common(loc_id, name, lapl_id, token_ptr, &vol_obj) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to asynchronously delete link")
/* If a token was created, add the token to the event set */
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Ldelete_async() */
/*-------------------------------------------------------------------------
* Function: H5L__delete_by_idx_api_common
*
* Purpose: This is the common function for deleting a link
* according to the order within an index.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5L__delete_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */
H5VL_object_t **vol_obj_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
if (!group_name || !*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
/* Set up object access arguments */
if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, TRUE, lapl_id, vol_obj_ptr, &loc_params) <
0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_DELETE;
/* Delete the link */
if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__delete_by_idx_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Ldelete_by_idx
*
* Purpose: Removes the specified link from the group graph and
* decrements the link count for the object to which it
* points, according to the order within an index.
*
* If the link count reaches zero then all file-space
* associated with the object will be reclaimed (but if the
* object is open, then the reclamation of the file space is
* delayed until all handles to the object are closed).
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
hid_t lapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id);
/* Delete a link synchronously */
if (H5L__delete_by_idx_api_common(loc_id, group_name, idx_type, order, n, lapl_id, NULL, NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to synchronously delete link")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Ldelete_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5Ldelete_by_idx_async
*
* Purpose: Asynchronous version of H5Ldelete_by_idx
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Ldelete_by_idx_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id,
const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
hid_t lapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE10("e", "*s*sIui*sIiIohii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n,
lapl_id, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Delete a link asynchronously */
if (H5L__delete_by_idx_api_common(loc_id, group_name, idx_type, order, n, lapl_id, token_ptr, &vol_obj) <
0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to asynchronously delete link")
/* If a token was created, add the token to the event set */
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
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)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Ldelete_by_idx_async() */
/*-------------------------------------------------------------------------
* Function: H5Lget_val
*
* Purpose: Returns the link value of a link whose name is NAME. For
* symbolic links, this is the path to which the link points,
* including the null terminator. For user-defined links, it
* is the link buffer.
*
* At most SIZE bytes are copied to the BUF result buffer.
*
* Return: Success: Non-negative with the link value in BUF.
*
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id);
/* Check arguments */
if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
/* Get the VOL object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_GET_VAL;
vol_cb_args.args.get_val.buf = buf;
vol_cb_args.args.get_val.buf_size = size;
/* Get the link value */
if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_val() */
/*-------------------------------------------------------------------------
* Function: H5Lget_val_by_idx
*
* Purpose: Returns the link value of a link, according to the order of
* an index. For symbolic links, this is the path to which the
* link points, including the null terminator. For user-defined
* links, it is the link buffer.
*
* At most SIZE bytes are copied to the BUF result buffer.
*
* Return: Success: Non-negative with the link value in BUF.
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
void *buf /*out*/, size_t size, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE8("e", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, buf, size, lapl_id);
/* Check arguments */
if (!group_name || !*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_IDX;
loc_params.loc_data.loc_by_idx.name = group_name;
loc_params.loc_data.loc_by_idx.idx_type = idx_type;
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.lapl_id = lapl_id;
loc_params.obj_type = H5I_get_type(loc_id);
/* Get the VOL object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_GET_VAL;
vol_cb_args.args.get_val.buf = buf;
vol_cb_args.args.get_val.buf_size = size;
/* Get the link value */
if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_val_by_idx() */
/*--------------------------------------------------------------------------
* NAME
* H5L__exists_api_common
* PURPOSE
* Common helper routine for sync/async check if an attribute exists
* RETURNS
* Non-negative on success/Negative on failure
*
*--------------------------------------------------------------------------*/
static herr_t
H5L__exists_api_common(hid_t loc_id, const char *name, hbool_t *exists, hid_t lapl_id, void **token_ptr,
H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */
H5VL_object_t **vol_obj_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
/* name is verified in H5VL_setup_name_args() */
if (NULL == exists)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer for link existence")
/* Set up object access arguments */
if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_EXISTS;
vol_cb_args.args.exists.exists = exists;
/* Check for the existence of the link */
if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__exists_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Lexists
*
* Purpose: Checks if a link of a given name exists in a group
*
* Return: Success: TRUE/FALSE/FAIL
*
*-------------------------------------------------------------------------
*/
htri_t
H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id)
{
hbool_t exists; /* Flag to indicate if link exists */
htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("t", "i*si", loc_id, name, lapl_id);
/* Synchronously check if a link exists */
exists = FALSE;
if (H5L__exists_api_common(loc_id, name, &exists, lapl_id, NULL, NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to synchronously check link existence")
/* Set return value */
ret_value = (htri_t)exists;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lexists() */
/*--------------------------------------------------------------------------
* Function: H5Lexists_async
*
* Purpose: Asynchronous version of H5Lexists
*
* Return: Success: TRUE/FALSE/FAIL
*
*--------------------------------------------------------------------------*/
herr_t
H5Lexists_async(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, const char *name,
hbool_t *exists, hid_t lapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE8("e", "*s*sIui*s*bii", app_file, app_func, app_line, loc_id, name, exists, lapl_id, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Asynchronously check if a link exists */
if (H5L__exists_api_common(loc_id, name, exists, lapl_id, token_ptr, &vol_obj) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to asynchronously check link existence")
/* If a token was created, add the token to the event set */
if (NULL != token)
if (H5ES_insert(es_id, vol_obj->connector, token,
/* clang-format off */
H5ARG_TRACE8(__func__, "*s*sIui*s*bii", app_file, app_func, app_line, loc_id, name, exists, lapl_id, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Lexists_async() */
/*-------------------------------------------------------------------------
* Function: H5Lget_info2
*
* Purpose: Gets metadata for a link.
*
* Return: Success: Non-negative with information in LINFO
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id);
/* Check arguments */
if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_GET_INFO;
vol_cb_args.args.get_info.linfo = linfo;
/* Get the link information */
if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_info2() */
/*-------------------------------------------------------------------------
* Function: H5Lget_info_by_idx2
*
* Purpose: Gets metadata for a link, according to the order within an
* index.
*
* Return: Success: Non-negative with information in LINFO
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order,
hsize_t n, H5L_info2_t *linfo /*out*/, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id);
/* Check arguments */
if (!group_name || !*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_IDX;
loc_params.loc_data.loc_by_idx.name = group_name;
loc_params.loc_data.loc_by_idx.idx_type = idx_type;
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.lapl_id = lapl_id;
loc_params.obj_type = H5I_get_type(loc_id);
/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_GET_INFO;
vol_cb_args.args.get_info.linfo = linfo;
/* Get the link information */
if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_info_by_idx2() */
/*-------------------------------------------------------------------------
* Function: H5Lregister
*
* Purpose: Registers a class of user-defined links, or changes the
* behavior of an existing class.
*
* The link class passed in will override any existing link
* class for the specified link class ID. It must at least
* include a H5L_class_t version (which should be
* H5L_LINK_CLASS_T_VERS), a link class ID, and a traversal
* function.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lregister(const H5L_class_t *cls)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "*#", cls);
/* Check args */
if (cls == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class")
/* Check H5L_class_t version number; this is where a function to convert
* from an outdated version should be called.
*
* v0 of the H5L_class_t is only different in the parameters to the
* traversal callback, which is handled in H5G_traverse_ud()
* (in src/H5Gtraverse.c), so it's allowed to to pass through here. - QAK, 2018/02/06
*/
if (cls->version > H5L_LINK_CLASS_T_VERS)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number")
#ifdef H5_NO_DEPRECATED_SYMBOLS
if (cls->version < H5L_LINK_CLASS_T_VERS)
HGOTO_ERROR(
H5E_ARGS, H5E_BADVALUE, FAIL,
"deprecated H5L_class_t version number (%d) and library built without deprecated symbol support",
cls->version)
#endif /* H5_NO_DEPRECATED_SYMBOLS */
if (cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link identification number")
if (cls->trav_func == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no traversal function specified")
/* Do it */
if (H5L_register(cls) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register link type")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lregister() */
/*-------------------------------------------------------------------------
* Function: H5Lunregister
*
* Purpose: Unregisters a class of user-defined links, preventing them
* from being traversed, queried, moved, etc.
*
* A link class can be re-registered using H5Lregister().
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lunregister(H5L_type_t id)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "Ll", id);
/* Check args */
if (id < 0 || id > H5L_TYPE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type")
/* Do it */
if (H5L_unregister(id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to unregister link type")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lunregister() */
/*-------------------------------------------------------------------------
* Function: H5Lis_registered
*
* Purpose: Tests whether a user-defined link class has been registered
* or not.
*
* Return: TRUE if the link class has been registered
* FALSE if it is unregistered
* FAIL on error (if the class is not a valid UD class ID)
*
*-------------------------------------------------------------------------
*/
htri_t
H5Lis_registered(H5L_type_t id)
{
hbool_t is_registered = FALSE;
htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("t", "Ll", id);
/* Check args */
if (id < 0 || id > H5L_TYPE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type id number")
/* Is the link class already registered? */
if (H5L_is_registered(id, &is_registered) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "could not determine registration status of UD link type")
ret_value = is_registered ? TRUE : FALSE;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lis_registered() */
/*-------------------------------------------------------------------------
* Function: H5Lget_name_by_idx
*
* Purpose: Gets name for a link, according to the order within an
* index.
*
* Same pattern of behavior as H5Iget_name.
*
* Return: Success: Non-negative length of name, with information
* in NAME buffer
*
* Failure: -1
*
*-------------------------------------------------------------------------
*/
ssize_t
H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order,
hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
size_t link_name_len = 0; /* Length of the link name string */
ssize_t ret_value = -1; /* Return value */
FUNC_ENTER_API((-1))
H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, lapl_id);
/* Check arguments */
if (!group_name || !*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name specified")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid iteration order specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, (-1), "can't set access property list info")
/* Set up location struct */
loc_params.type = H5VL_OBJECT_BY_IDX;
loc_params.loc_data.loc_by_idx.name = group_name;
loc_params.loc_data.loc_by_idx.idx_type = idx_type;
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.lapl_id = lapl_id;
loc_params.obj_type = H5I_get_type(loc_id);
/* Get the VOL object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_GET_NAME;
vol_cb_args.args.get_name.name_size = size;
vol_cb_args.args.get_name.name = name;
vol_cb_args.args.get_name.name_len = &link_name_len;
/* Get the link information */
if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name")
/* Set the return value */
ret_value = (ssize_t)link_name_len;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_name_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5L__iterate_api_common
*
* Purpose: This is the common function for iterating over links
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5L__iterate_api_common(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p,
H5L_iterate2_t op, void *op_data, void **token_ptr, H5VL_object_t **_vol_obj_ptr)
{
H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */
H5VL_object_t **vol_obj_ptr =
(_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
H5I_type_t id_type; /* Type of ID */
herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
id_type = H5I_get_type(group_id);
if (!(H5I_GROUP == id_type || H5I_FILE == id_type))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Set up object access arguments */
if (H5VL_setup_self_args(group_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_ITER;
vol_cb_args.args.iterate.recursive = FALSE;
vol_cb_args.args.iterate.idx_type = idx_type;
vol_cb_args.args.iterate.order = order;
vol_cb_args.args.iterate.idx_p = idx_p;
vol_cb_args.args.iterate.op = op;
vol_cb_args.args.iterate.op_data = op_data;
/* Iterate over the links */
if ((ret_value = H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT,
token_ptr)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__iterate_api_common() */
/*-------------------------------------------------------------------------
* Function: H5Literate2
*
* Purpose: Iterates over links in a group, with user callback routine,
* according to the order within an index.
*
* Same pattern of behavior as H5Giterate.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op,
void *op_data)
{
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "iIiIo*hLI*x", group_id, idx_type, order, idx_p, op, op_data);
/* Iterate over links synchronously */
if ((ret_value = H5L__iterate_api_common(group_id, idx_type, order, idx_p, op, op_data, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "synchronous link iteration failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Literate2() */
/*-------------------------------------------------------------------------
* Function: H5Literate_async
*
* Purpose: Asynchronous version of H5Literate2
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Literate_async(const char *app_file, const char *app_func, unsigned app_line, hid_t group_id,
H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data,
hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void *token = NULL; /* Request token for async operation */
void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE10("e", "*s*sIuiIiIo*hLI*xi", app_file, app_func, app_line, group_id, idx_type, order, idx_p, op,
op_data, es_id);
/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Iterate over links asynchronously */
if ((ret_value =
H5L__iterate_api_common(group_id, idx_type, order, idx_p, op, op_data, token_ptr, &vol_obj)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "asynchronous link iteration failed")
/* If a token was created, add the token to the event set */
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE10(__func__, "*s*sIuiIiIo*hLI*xi", app_file, app_func, app_line, group_id, idx_type, order, idx_p, op, op_data, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Literate_async() */
/*-------------------------------------------------------------------------
* Function: H5Literate_by_name2
*
* Purpose: Iterates over links in a group, with user callback routine,
* according to the order within an index.
*
* Same pattern of behavior as H5Giterate.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *idx_p, H5L_iterate2_t op, void *op_data, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* Object of loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE8("e", "i*sIiIo*hLI*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id);
/* Check arguments */
if (!group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL")
if (!*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set location struct fields */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
loc_params.loc_data.loc_by_name.name = group_name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_ITER;
vol_cb_args.args.iterate.recursive = FALSE;
vol_cb_args.args.iterate.idx_type = idx_type;
vol_cb_args.args.iterate.order = order;
vol_cb_args.args.iterate.idx_p = idx_p;
vol_cb_args.args.iterate.op = op;
vol_cb_args.args.iterate.op_data = op_data;
/* Iterate over the links */
if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT,
H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Literate_by_name() */
/*-------------------------------------------------------------------------
* Function: H5Lvisit2
*
* Purpose: Recursively visit all the links in a group and all
* the groups that are linked to from that group. Links within
* each group are visited according to the order within the
* specified index (unless the specified index does not exist for
* a particular group, then the "name" index is used).
*
* NOTE: Each _link_ reachable from the initial group will only be
* visited once. However, because an object may be reached from
* more than one link, the visitation may call the application's
* callback with more than one link that points to a particular
* _object_.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data)
{
H5VL_object_t *vol_obj = NULL; /* Object of loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
H5I_type_t id_type; /* Type of ID */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "iIiIoLI*x", group_id, idx_type, order, op, op_data);
/* Check args */
id_type = H5I_get_type(group_id);
if (!(H5I_GROUP == id_type || H5I_FILE == id_type))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
/* Set location struct fields */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(group_id);
/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_ITER;
vol_cb_args.args.iterate.recursive = TRUE;
vol_cb_args.args.iterate.idx_type = idx_type;
vol_cb_args.args.iterate.order = order;
vol_cb_args.args.iterate.idx_p = NULL;
vol_cb_args.args.iterate.op = op;
vol_cb_args.args.iterate.op_data = op_data;
/* Iterate over the links */
if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT,
H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lvisit2() */
/*-------------------------------------------------------------------------
* Function: H5Lvisit_by_name2
*
* Purpose: Recursively visit all the links in a group and all
* the groups that are linked to from that group. Links within
* each group are visited according to the order within the
* specified index (unless the specified index does not exist for
* a particular group, then the "name" index is used).
*
* NOTE: Each _link_ reachable from the initial group will only be
* visited once. However, because an object may be reached from
* more than one link, the visitation may call the application's
* callback with more than one link that points to a particular
* _object_.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order,
H5L_iterate2_t op, void *op_data, hid_t lapl_id)
{
H5VL_object_t *vol_obj = NULL; /* Object of loc_id */
H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_loc_params_t loc_params; /* Location parameters for object access */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("e", "i*sIiIoLI*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id);
/* Check args */
if (!group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL")
if (!*group_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
/* Verify access property list and set up collective metadata if appropriate */
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info")
/* get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set location struct fields */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
loc_params.loc_data.loc_by_name.name = group_name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_LINK_ITER;
vol_cb_args.args.iterate.recursive = TRUE;
vol_cb_args.args.iterate.idx_type = idx_type;
vol_cb_args.args.iterate.order = order;
vol_cb_args.args.iterate.idx_p = NULL;
vol_cb_args.args.iterate.op = op;
vol_cb_args.args.iterate.op_data = op_data;
/* Visit the links */
if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT,
H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lvisit_by_name2() */
/*-------------------------------------------------------------------------
* Function: H5Lunpack_elink_val
*
* Purpose: Given a buffer holding the "link value" from an external link,
* gets pointers to the information within the link value buffer.
*
* External link link values contain some flags and
* two NULL-terminated strings, one after the other.
*
* The FLAGS value will be filled in and FILENAME and
* OBJ_PATH will be set to pointers within ext_linkval (unless
* any of these values is NULL).
*
* Using this function on strings that aren't external link
* udata buffers can result in segmentation faults.
*
* Return: Non-negative on success/ Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, const char **filename,
const char **obj_path)
{
const uint8_t *ext_linkval = (const uint8_t *)_ext_linkval; /* Pointer to the link value */
unsigned lnk_version; /* External link format version */
unsigned lnk_flags; /* External link flags */
size_t len; /* Length of the filename in the linkval*/
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, obj_path);
/* Sanity check external link buffer */
if (ext_linkval == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an external link linkval buffer")
lnk_version = (*ext_linkval >> 4) & 0x0F;
lnk_flags = *ext_linkval & 0x0F;
if (lnk_version > H5L_EXT_VERSION)
HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link")
if (lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL)
HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link")
if (link_size <= 2)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid external link buffer")
/* Try to do some error checking. If the last character in the linkval
* (the last character of obj_path) isn't NULL, then something's wrong.
*/
if (ext_linkval[link_size - 1] != '\0')
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer is not NULL-terminated")
/* We're now guaranteed that HDstrlen won't segfault, since the buffer has
* at least one NULL in it.
*/
len = HDstrlen((const char *)ext_linkval + 1);
/* If the first NULL we found was at the very end of the buffer, then
* this external link value has no object name and is invalid.
*/
if ((len + 1) >= (link_size - 1))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer doesn't contain an object path")
/* If we got here then the buffer contains (at least) two strings packed
* in the correct way. Assume it's correct and return pointers to the
* filename and object path.
*/
if (filename)
*filename = (const char *)ext_linkval + 1;
if (obj_path)
*obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */
/* Set the flags to return */
if (flags)
*flags = lnk_flags;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lunpack_elink_val() */
|