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
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: The native VOL driver where access is to a single HDF5 file
* using HDF5 VFDs.
*/
#define H5A_FRIEND /* Suppress error about including H5Apkg */
#define H5D_FRIEND /* Suppress error about including H5Dpkg */
#define H5F_FRIEND /* Suppress error about including H5Fpkg */
#define H5G_FRIEND /* Suppress error about including H5Gpkg */
#define H5L_FRIEND /* Suppress error about including H5Lpkg */
#define H5O_FRIEND /* Suppress error about including H5Opkg */
#define H5R_FRIEND /* Suppress error about including H5Rpkg */
#define H5T_FRIEND /* Suppress error about including H5Tpkg */
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* Files */
#include "H5Gpkg.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Lpkg.h" /* Links */
#include "H5MFprivate.h" /* File memory management */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5Rpkg.h" /* References */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tpkg.h" /* Datatypes */
#include "H5VLprivate.h" /* VOL drivers */
#include "H5VLnative_private.h" /* Native VOL driver */
/*
* The VOL driver identification number.
*/
static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID;
/* Prototypes */
static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type);
static herr_t H5VL__native_term(void);
/* Atrribute callbacks */
static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
static herr_t H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req);
static herr_t H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_attr_close(void *attr, hid_t dxpl_id, void **req);
/* Dataset callbacks */
static void *H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, void **req);
static herr_t H5VL_native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
static herr_t H5VL_native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_dataset_close(void *dset, hid_t dxpl_id, void **req);
/* File callbacks */
static void *H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_file_close(void *file, hid_t dxpl_id, void **req);
/* Group callbacks */
static void *H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_group_specific(void *dset, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_group_close(void *grp, hid_t dxpl_id, void **req);
/* Link callbacks */
static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj,
H5VL_loc_params_t loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1,
void *dst_obj, H5VL_loc_params_t loc_params2,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1,
void *dst_obj, H5VL_loc_params_t loc_params2,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
/* Object callbacks */
static void *H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
static herr_t H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name,
void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name,
hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments);
/* Datatype callbacks */
static void *H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_native_datatype_close(void *dt, hid_t dxpl_id, void **req);
/* Native VOL driver class struct */
static H5VL_class_t H5VL_native_cls_g = {
H5VL_NATIVE_VERSION, /* version */
H5VL_NATIVE_VALUE, /* value */
H5VL_NATIVE_NAME, /* name */
NULL, /* initialize */
NULL, /* terminate */
(size_t)0, /* fapl size */
NULL, /* fapl copy */
NULL, /* fapl free */
{ /* attribute_cls */
H5VL_native_attr_create, /* create */
H5VL_native_attr_open, /* open */
H5VL_native_attr_read, /* read */
H5VL_native_attr_write, /* write */
H5VL_native_attr_get, /* get */
H5VL_native_attr_specific, /* specific */
NULL, /* optional */
H5VL_native_attr_close /* close */
},
{ /* dataset_cls */
H5VL_native_dataset_create, /* create */
H5VL_native_dataset_open, /* open */
H5VL_native_dataset_read, /* read */
H5VL_native_dataset_write, /* write */
H5VL_native_dataset_get, /* get */
H5VL_native_dataset_specific, /* specific */
H5VL_native_dataset_optional, /* optional */
H5VL_native_dataset_close /* close */
},
{ /* datatype_cls */
H5VL_native_datatype_commit, /* commit */
H5VL_native_datatype_open, /* open */
H5VL_native_datatype_get, /* get */
H5VL_native_datatype_specific, /* specific */
NULL, /* optional */
H5VL_native_datatype_close /* close */
},
{ /* file_cls */
H5VL_native_file_create, /* create */
H5VL_native_file_open, /* open */
H5VL_native_file_get, /* get */
H5VL_native_file_specific, /* specific */
H5VL_native_file_optional, /* optional */
H5VL_native_file_close /* close */
},
{ /* group_cls */
H5VL_native_group_create, /* create */
H5VL_native_group_open, /* open */
H5VL_native_group_get, /* get */
H5VL_native_group_specific, /* specific */
NULL, /* optional */
H5VL_native_group_close /* close */
},
{ /* link_cls */
H5VL_native_link_create, /* create */
H5VL_native_link_copy, /* copy */
H5VL_native_link_move, /* move */
H5VL_native_link_get, /* get */
H5VL_native_link_specific, /* specific */
NULL /* optional */
},
{ /* object_cls */
H5VL_native_object_open, /* open */
H5VL_native_object_copy, /* copy */
H5VL_native_object_get, /* get */
H5VL_native_object_specific, /* specific */
H5VL_native_object_optional /* optional */
},
{ /* async_cls */
NULL, /* cancel */
NULL, /* test */
NULL /* wait */
},
NULL /* optional */
};
/*-------------------------------------------------------------------------
* Function: H5VL_native_init
*
* Purpose: Initialize this VOL driver by registering it with the
* library.
*
* Return: Success: The ID for the native driver
* Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5VL_native_init(void)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI(H5I_INVALID_HID)
/* Register the native VOL driver, if it isn't already */
if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL)) {
if((H5VL_NATIVE_ID_g = H5VL_register_driver((const H5VL_class_t *)&H5VL_native_cls_g,
sizeof(H5VL_class_t), TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL driver")
}
/* Set return value */
ret_value = H5VL_NATIVE_ID_g;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_init() */
/* XXX (VOL_MERGE): TEMPORARY */
hid_t
H5VL_native_get_driver_id(void)
{
return H5VL_NATIVE_ID_g;
}
/*---------------------------------------------------------------------------
* Function: H5VL__native_term
*
* Purpose: Shut down the native VOL
*
* Returns: SUCCEED (Can't fail)
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL__native_term(void)
{
FUNC_ENTER_STATIC_NOERR
/* Reset VFL ID */
H5VL_NATIVE_ID_g = H5I_INVALID_HID;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5VL__native_term() */
/*-------------------------------------------------------------------------
* Function: H5Pset_fapl_native
*
* Purpose: Modify the file access property list to use the H5VL_NATIVE
* driver defined in this source file.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_fapl_native(hid_t fapl_id)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", fapl_id);
if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
ret_value = H5P_set_vol(plist, H5VL_NATIVE_ID_g, NULL);
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_fapl_native() */
/*---------------------------------------------------------------------------
* Function: H5VL_native_get_file
*
* Purpose: Utility routine to get file struct for an object via the
* native VOL driver.
*
* Returns: SUCCESS: A pointer to the H5F_t struct for the file
* associated with the object.
* FAILURE: NULL
*
*---------------------------------------------------------------------------
*/
static H5F_t *
H5VL_native_get_file(void *obj, H5I_type_t type)
{
H5F_t *ret_value = NULL; /* File pointer */
H5O_loc_t *oloc = NULL; /* Object location for ID */
FUNC_ENTER_NOAPI_NOINIT
switch(type) {
case H5I_FILE:
ret_value = (H5F_t *)obj;
break;
case H5I_GROUP:
{
H5G_t *grp;
grp = (H5G_t *)obj;
oloc = H5G_oloc(grp);
break;
}
case H5I_DATATYPE:
{
H5T_t *dt;
dt = (H5T_t *)obj;
oloc = H5T_oloc(dt);
break;
}
case H5I_DATASET:
{
H5D_t *dset;
dset = (H5D_t *)obj;
oloc = H5D_oloc(dset);
break;
}
case H5I_ATTR:
{
H5A_t *attr;
attr = (H5A_t *)obj;
oloc = H5A_oloc(attr);
break;
}
case H5I_UNINIT:
case H5I_BADID:
case H5I_DATASPACE:
case H5I_REFERENCE:
case H5I_VFL:
case H5I_VOL:
case H5I_GENPROP_CLS:
case H5I_GENPROP_LST:
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
}
if(!ret_value) {
if (!oloc)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not assocated with a file")
ret_value = oloc->file;
}
if(!ret_value)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5VL_native_get_file */
/*---------------------------------------------------------------------------
* Function: H5VL_native_register
*
* Purpose: Utility routine to register an ID with the native VOL driver
* as an auxilary object.
*
* Returns: Success: An ID for the object
* Failure: H5I_INVALID_HID
*
*---------------------------------------------------------------------------
*/
hid_t
H5VL_native_register(H5I_type_t type, const void *obj, hbool_t app_ref)
{
hid_t ret_value = H5I_INVALID_HID;
FUNC_ENTER_NOAPI_NOINIT
HDassert(obj);
/* If the datatype is already VOL-managed, the datatype's vol_obj
* field will get clobbered later, so disallow this.
*/
if(type == H5I_DATATYPE)
if(((H5T_t *)obj)->vol_obj != NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can only get an ID for an uncommitted datatype")
/* Get an ID for the object */
if((ret_value = H5VL_register_using_vol_id(type, obj, H5VL_NATIVE_ID_g, app_ref)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_register() */
/*---------------------------------------------------------------------------
* Function: H5VL_native_unregister
*
* Purpose: Utility routine to decrement ref count on Native VOL driver
* objects.
*
* Returns: SUCCEED/FAIL
*
*---------------------------------------------------------------------------
*/
herr_t
H5VL_native_unregister(hid_t obj_id)
{
H5VL_object_t *vol_obj = NULL;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT
/* get the driver pointer */
if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid ID")
/* free object */
if(H5VL_free_object(vol_obj) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_unregister() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_create
*
* Purpose: Creates an attribute on an object.
*
* Return: Success: attr id.
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id,
hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Object location */
H5G_loc_t obj_loc; /* Location used to open group */
hbool_t loc_found = FALSE;
H5P_genplist_t *plist; /* Property list pointer */
hid_t type_id, space_id;
H5T_t *type, *dt; /* Datatype to use for attribute */
H5S_t *space; /* Dataspace to use for attribute */
H5A_t *attr = NULL;
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* get creation properties */
if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file")
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype")
/* If this is a named datatype, get the driver pointer to the datatype */
type = H5T_get_actual_type(dt);
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space")
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
/* H5Acreate */
/* Go do the real work for attaching the attribute to the dataset */
if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
/* H5Acreate_by_name */
if(NULL == (attr = H5A__create_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name, type, space, acpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters")
}
ret_value = (void *)attr;
done:
/* Release resources */
if(loc_found && H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_open
*
* Purpose: Opens a attr inside a native h5 file.
*
* Return: Success: attr id.
* Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name,
hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
/* H5Aopen */
/* Open the attribute */
if(NULL == (attr = H5A__open(&loc, attr_name)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name)
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
/* H5Aopen_by_name */
/* Open the attribute on the object header */
if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) {
/* H5Aopen_by_idx */
/* Open the attribute in the object header */
if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order,
loc_params.loc_data.loc_by_idx.n)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters")
}
ret_value = (void *)attr;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_read
*
* Purpose: Reads in data from attribute.
*
* Non-negative on success/Negative on failure
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5T_t *mem_type; /* Memory datatype */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Go write the actual data to the attribute */
if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_read() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_write
*
* Purpose: Writes out data to attribute.
*
* Non-negative on success/Negative on failure
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5T_t *mem_type; /* Memory datatype */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Go write the actual data to the attribute */
if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_write() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_get
*
* Purpose: Gets certain information about an attribute
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(get_type) {
/* H5Aget_space */
case H5VL_ATTR_GET_SPACE:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A_get_space(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute")
break;
}
/* H5Aget_type */
case H5VL_ATTR_GET_TYPE:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A__get_type(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute")
break;
}
/* H5Aget_create_plist */
case H5VL_ATTR_GET_ACPL:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A__get_create_plist(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr")
break;
}
/* H5Aget_name */
case H5VL_ATTR_GET_NAME:
{
H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t);
size_t buf_size = va_arg(arguments, size_t);
char *buf = va_arg(arguments, char *);
ssize_t *ret_val = va_arg(arguments, ssize_t *);
H5A_t *attr = NULL;
if(H5VL_OBJECT_BY_SELF == loc_params.type) {
attr = (H5A_t *)obj;
/* Call private function in turn */
if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name")
}
else if(H5VL_OBJECT_BY_IDX == loc_params.type) {
H5G_loc_t loc;
/* check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Open the attribute on the object header */
if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order,
loc_params.loc_data.loc_by_idx.n)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
/* Get the length of the name */
*ret_val = (ssize_t)HDstrlen(attr->shared->name);
/* Copy the name into the user's buffer, if given */
if(buf) {
HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size));
if((size_t)(*ret_val) >= buf_size)
buf[buf_size - 1]='\0';
} /* end if */
/* Release resources */
if(attr && H5A__close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
}
else
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr")
break;
}
/* H5Aget_info */
case H5VL_ATTR_GET_INFO:
{
H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t);
H5A_info_t *ainfo = va_arg(arguments, H5A_info_t *);
H5A_t *attr = NULL;
if(H5VL_OBJECT_BY_SELF == loc_params.type) {
attr = (H5A_t *)obj;
if(H5A__get_info(attr, ainfo) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info")
}
else if(H5VL_OBJECT_BY_NAME == loc_params.type) {
char *attr_name = va_arg(arguments, char *);
H5G_loc_t loc;
/* check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Open the attribute on the object header */
if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name,
attr_name)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
/* Get the attribute information */
if(H5A__get_info(attr, ainfo) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
/* Release resources */
if(attr && H5A__close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
}
else if(H5VL_OBJECT_BY_IDX == loc_params.type) {
H5G_loc_t loc;
/* check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Open the attribute on the object header */
if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order,
loc_params.loc_data.loc_by_idx.n)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
/* Get the attribute information */
if(H5A__get_info(attr, ainfo) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
/* Release resources */
if(attr && H5A__close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
}
else
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr")
break;
}
case H5VL_ATTR_GET_STORAGE_SIZE:
{
hsize_t *ret = va_arg(arguments, hsize_t *);
H5A_t *attr = (H5A_t *)obj;
/* Set return value */
*ret = attr->shared->data_size;
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_specific
*
* Purpose: Specific operations for attributes
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* August, 2014
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5G_loc_t loc;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Get location for passed-in object */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* XXX: Do I need to clean this up? */
switch(specific_type) {
case H5VL_ATTR_DELETE:
{
char *attr_name = va_arg(arguments, char *);
if(H5VL_OBJECT_BY_SELF == loc_params.type) {
/* H5Adelete */
/* Delete the attribute from the location */
if(H5O__attr_remove(loc.oloc, attr_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
}
else if(H5VL_OBJECT_BY_NAME == loc_params.type) {
/* H5Adelete_by_name */
/* Delete the attribute */
if(H5A__delete_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
}
else if(H5VL_OBJECT_BY_IDX == loc_params.type) {
/* H5Adelete_by_idx */
/* Delete the attribute from the location */
if(H5A__delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
}
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters")
break;
}
case H5VL_ATTR_EXISTS:
{
const char *attr_name = va_arg(arguments, const char *);
htri_t *ret = va_arg(arguments, htri_t *);
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */
/* Check if the attribute exists */
if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */
/* Check if the attribute exists */
if((*ret = H5A__exists_by_name(loc, loc_params.loc_data.loc_by_name.name, attr_name)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists")
}
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters")
break;
}
case H5VL_ATTR_ITER:
{
H5_index_t idx_type = va_arg(arguments, H5_index_t);
H5_iter_order_t order = va_arg(arguments, H5_iter_order_t);
hsize_t *idx = va_arg(arguments, hsize_t *);
H5A_operator2_t op = va_arg(arguments, H5A_operator2_t);
void *op_data = va_arg(arguments, void *);
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */
/* Iterate over attributes */
if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */
/* Iterate over attributes by name */
if((ret_value = H5A__iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed");
}
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters")
break;
}
/* H5Arename/rename_by_name */
case H5VL_ATTR_RENAME:
{
const char *old_name = va_arg(arguments, const char *);
const char *new_name = va_arg(arguments, const char *);
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Arename */
/* Call attribute rename routine */
if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */
/* Call attribute rename routine */
if(H5A__rename_by_name(loc, loc_params.loc_data.loc_by_name.name, old_name, new_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
}
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_close
*
* Purpose: Closes an attribute.
*
* Return: Success: 0
* Failure: -1, attr not closed.
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5A__close((H5A_t*)attr) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_close() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_create
*
* Purpose: Creates a dataset in a native HDF5 file
*
* Return: Success: Pointer to a dataset struct
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id,
hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Object location to insert dataset into */
hid_t type_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t lcpl_id = H5I_INVALID_HID;
H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* Get creation properties */
if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
/* Check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID")
if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID")
/* H5Dcreate_anon */
if(NULL == name) {
/* build and open the new dataset */
if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
}
/* H5Dcreate2 */
else {
/* Create the new dataset & get its ID */
if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id,
dcpl_id, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
}
ret_value = (void *)dset;
done:
if(NULL == name) {
/* Release the dataset's object header, if it was created */
if(dset) {
H5O_loc_t *oloc; /* Object location for dataset */
/* Get the new dataset's object location */
if(NULL == (oloc = H5D_oloc(dset)))
HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset")
/* Decrement refcount on dataset's object header in memory */
if(H5O_dec_rc_by_loc(oloc) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
}
}
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_open
*
* Purpose: Opens a dataset in a native HDF5 file.
*
* Return: Success: Pointer to a dataset struct
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = NULL;
H5G_loc_t loc; /* Object location of group */
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Open the dataset */
if(NULL == (dset = H5D__open_name(&loc, name, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset")
ret_value = (void *)dset;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_read
*
* Purpose: Reads raw data from a dataset into a buffer.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Check arguments */
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
/* Get validated dataspace pointers */
if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id")
if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id")
/* Read raw data */
if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_read() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_write
*
* Purpose: Writes raw data from a buffer into a dataset.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
/* Get validated dataspace pointers */
if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id")
if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id")
/* Write the data */
if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_write() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_get
*
* Purpose: Gets certain information about a dataset
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id,
void H5_ATTR_UNUSED **req, va_list arguments)
{
H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(get_type) {
/* H5Dget_space */
case H5VL_DATASET_GET_SPACE:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
if((*ret_id = H5D__get_space(dset)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset")
break;
}
/* H5Dget_space_statuc */
case H5VL_DATASET_GET_SPACE_STATUS:
{
H5D_space_status_t *allocation = va_arg(arguments, H5D_space_status_t *);
/* Read data space address and return */
if(H5D__get_space_status(dset, allocation) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status")
break;
}
/* H5Dget_type */
case H5VL_DATASET_GET_TYPE:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
if((*ret_id = H5D__get_type(dset)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset")
break;
}
/* H5Dget_create_plist */
case H5VL_DATASET_GET_DCPL:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
if((*ret_id = H5D_get_create_plist(dset)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset")
break;
}
/* H5Dget_access_plist */
case H5VL_DATASET_GET_DAPL:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
if((*ret_id = H5D_get_access_plist(dset)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset")
break;
}
/* H5Dget_storage_size */
case H5VL_DATASET_GET_STORAGE_SIZE:
{
hsize_t *ret = va_arg(arguments, hsize_t *);
/* Set return value */
if(H5D__get_storage_size(dset, ret) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage")
break;
}
/* H5Dget_offset */
case H5VL_DATASET_GET_OFFSET:
{
haddr_t *ret = va_arg(arguments, haddr_t *);
/* Set return value */
*ret = H5D__get_offset(dset);
if(!H5F_addr_defined(*ret))
*ret = HADDR_UNDEF;
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_specific
*
* Purpose: Specific operations for datasets
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(specific_type) {
/* H5Dspecific_space */
case H5VL_DATASET_SET_EXTENT:
{
const hsize_t *size = va_arg(arguments, const hsize_t *);
if(H5D__set_extent(dset, size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset")
break;
}
case H5VL_DATASET_FLUSH:
{
hid_t dset_id = va_arg(arguments, hid_t);
/* Flush the dataset */
if(H5D__flush(dset, dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset")
break;
}
case H5VL_DATASET_REFRESH:
{
hid_t dset_id = va_arg(arguments, hid_t);
/* Refresh the dataset */
if((H5D__refresh(dset_id, dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_optional
*
* Purpose: Perform a driver specific operation on a native dataset
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5D_t *dset = NULL; /* Dataset */
H5VL_dataset_optional_t optional_type = va_arg(arguments, H5VL_dataset_optional_t);
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(optional_type) {
case H5VL_DATASET_FORMAT_CONVERT:
{
dset = (H5D_t *)obj;
switch(dset->shared->layout.type) {
case H5D_CHUNKED:
/* Convert the chunk indexing type to version 1 B-tree if not */
if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE)
if((H5D__format_convert(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset")
break;
case H5D_CONTIGUOUS:
case H5D_COMPACT:
/* Downgrade the layout version to 3 if greater than 3 */
if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT)
if((H5D__format_convert(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset")
break;
case H5D_VIRTUAL:
/* Nothing to do even though layout is version 4 */
break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type")
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type")
} /* end switch */
break;
}
case H5VL_DATASET_GET_CHUNK_INDEX_TYPE:
{
H5D_chunk_index_t *idx_type = va_arg(arguments, H5D_chunk_index_t *);
dset = (H5D_t *)obj;
/* Make sure the dataset is chunked */
if(H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Get the chunk indexing type */
*idx_type = dset->shared->layout.u.chunk.idx_type;
break;
}
case H5VL_DATASET_GET_CHUNK_STORAGE_SIZE:
{
hsize_t *offset = va_arg(arguments, hsize_t *);
hsize_t *chunk_nbytes = va_arg(arguments, hsize_t *);
dset = (H5D_t *)obj;
/* Make sure the dataset is chunked */
if(H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk")
break;
}
case H5VL_DATASET_CHUNK_READ:
{
const hsize_t *offset = va_arg(arguments, hsize_t *);
uint32_t *filters = va_arg(arguments, uint32_t *);
void *buf = va_arg(arguments, void *);
hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */
dset = (H5D_t *)obj;
/* Check arguments */
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
if(H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Copy the user's offset array so we can be sure it's terminated properly.
* (we don't want to mess with the user's buffer).
*/
if(H5D__get_offset_copy(dset, offset, offset_copy) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array")
/* Read the raw chunk */
if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data")
break;
}
case H5VL_DATASET_CHUNK_WRITE:
{
uint32_t filters = va_arg(arguments, uint32_t);
const hsize_t *offset = va_arg(arguments, const hsize_t *);
uint32_t data_size_32 = va_arg(arguments, uint32_t);
const void *buf = va_arg(arguments, const void *);
hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */
dset = (H5D_t *)obj;
/* Check arguments */
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
if(H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Copy the user's offset array so we can be sure it's terminated properly.
* (we don't want to mess with the user's buffer).
*/
if(H5D__get_offset_copy(dset, offset, offset_copy) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array")
/* Write chunk */
if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_optional() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_dataset_close
*
* Purpose: Closes a dataset.
*
* Return: Success: SUCCEED
* Failure: FAIL (dataset will not be closed)
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5D_close((H5D_t*)dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_close() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_create
*
* Purpose: Creates a file as a native HDF5 file.
*
* Return: Success: A pointer to an H5F_t file struct
*
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5F_t *new_file = NULL;
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
/* Adjust bit flags by turning on the creation bit and making sure that
* the EXCL or TRUNC bit is set. All newly-created files are opened for
* reading and writing.
*/
if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)))
flags |= H5F_ACC_EXCL; /*default*/
flags |= H5F_ACC_RDWR | H5F_ACC_CREAT;
/* Create the file */
if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file")
new_file->id_exists = TRUE;
ret_value = (void *)new_file;
done:
if(NULL == ret_value && new_file)
if(H5F__close(new_file) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_open
*
* Purpose: Opens a file as a native HDF5 file.
*
* Return: Success: A pointer to an H5F_t file struct
*
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5F_t *new_file = NULL;
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
/* Open the file */
if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
new_file->id_exists = TRUE;
ret_value = (void *)new_file;
done:
if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_get
*
* Purpose: Gets certain data about a file
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5F_t *f = NULL; /* File struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(get_type) {
/* H5Fget_access_plist */
case H5VL_FILE_GET_FAPL:
{
H5P_genplist_t *new_plist; /* New property list */
hid_t *plist_id = va_arg(arguments, hid_t *);
f = (H5F_t *)obj;
/* Retrieve the file's access property list */
if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
break;
}
/* H5Fget_create_plist */
case H5VL_FILE_GET_FCPL:
{
H5P_genplist_t *plist; /* Property list */
hid_t *plist_id = va_arg(arguments, hid_t *);
f = (H5F_t *)obj;
if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Create the property list object to return */
if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties")
break;
}
/* H5Fget_obj_count */
case H5VL_FILE_GET_OBJ_COUNT:
{
unsigned types = va_arg(arguments, unsigned);
ssize_t *ret = va_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
/* H5Fget_obj_ids */
case H5VL_FILE_GET_OBJ_IDS:
{
unsigned types = va_arg(arguments, unsigned);
size_t max_objs = va_arg(arguments, size_t);
hid_t *oid_list = va_arg(arguments, hid_t *);
ssize_t *ret = va_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
/* H5Fget_intent */
case H5VL_FILE_GET_INTENT:
{
unsigned *intent_flags = va_arg(arguments, unsigned *);
f = (H5F_t *)obj;
/* HDF5 uses some flags internally that users don't know about.
* Simplify things for them so that they only get either H5F_ACC_RDWR
* or H5F_ACC_RDONLY and any SWMR flags.
*/
if(H5F_INTENT(f) & H5F_ACC_RDWR) {
*intent_flags = H5F_ACC_RDWR;
/* Check for SWMR write access on the file */
if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)
*intent_flags |= H5F_ACC_SWMR_WRITE;
}
else {
*intent_flags = H5F_ACC_RDONLY;
/* Check for SWMR read access on the file */
if(H5F_INTENT(f) & H5F_ACC_SWMR_READ)
*intent_flags |= H5F_ACC_SWMR_READ;
}
break;
}
/* H5Fget_name */
case H5VL_FILE_GET_NAME:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
size_t size = va_arg(arguments, size_t);
char *name = va_arg(arguments, char *);
ssize_t *ret = va_arg(arguments, ssize_t *);
size_t len;
if(NULL == (f = H5VL_native_get_file(obj, type)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
len = HDstrlen(H5F_OPEN_NAME(f));
if(name) {
HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size));
if(len >= size)
name[size-1]='\0';
}
/* Set the return value for the API call */
*ret = (ssize_t)len;
break;
}
/* H5Iget_file_id */
case H5VL_OBJECT_GET_FILE:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
void **ret = va_arg(arguments, void **);
if(NULL == (f = H5VL_native_get_file(obj, type)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
f->id_exists = TRUE;
*ret = (void*)f;
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information")
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_specific
*
* Purpose: Perform an operation
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id,
void H5_ATTR_UNUSED **req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(specific_type) {
/* H5Fflush */
case H5VL_FILE_FLUSH:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
H5F_scope_t scope = va_arg(arguments, H5F_scope_t);
H5F_t *f = NULL; /* File to flush */
/* Get the file for the object */
if(NULL == (f = H5VL_native_get_file(obj, type)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Nothing to do if the file is read only. This determination is
* made at the shared open(2) flags level, implying that opening a
* file twice, once for read-only and once for read-write, and then
* calling H5Fflush() with the read-only handle, still causes data
* to be flushed.
*/
if(H5F_ACC_RDWR & H5F_INTENT(f)) {
/* Flush other files, depending on scope */
if(H5F_SCOPE_GLOBAL == scope) {
/* Call the flush routine for mounted file hierarchies */
if(H5F_flush_mounts(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy")
}
else {
/* Call the flush routine, for this file */
if(H5F__flush(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
}
}
break;
}
/* H5Fmount */
case H5VL_FILE_MOUNT:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
const char *name = va_arg(arguments, const char *);
H5F_t *child = va_arg(arguments, H5F_t *);
hid_t plist_id = va_arg(arguments, hid_t);
H5G_loc_t loc;
if(H5G_loc_real(obj, type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Do the mount */
if(H5F__mount(&loc, name, child, plist_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file")
break;
}
/* H5Funmount */
case H5VL_FILE_UNMOUNT:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
const char *name = va_arg(arguments, const char *);
H5G_loc_t loc;
if(H5G_loc_real(obj, type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Unmount */
if(H5F__unmount(&loc, name) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file")
break;
}
/* H5Fis_accessible */
case H5VL_FILE_IS_ACCESSIBLE:
{
hid_t fapl_id = va_arg(arguments, hid_t);
const char *name = va_arg(arguments, const char *);
htri_t *ret = va_arg(arguments, htri_t *);
/* Call private routine */
if((*ret = H5F__is_hdf5(name, fapl_id)) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_optional
*
* Purpose: Perform a driver specific operation on a native file
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5F_t *f = NULL; /* File */
H5VL_file_optional_t optional_type = va_arg(arguments, H5VL_file_optional_t);
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(optional_type) {
/* H5Fget_filesize */
case H5VL_FILE_GET_SIZE:
{
haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
haddr_t base_addr; /* Base address for the file */
hsize_t *size = va_arg(arguments, hsize_t *);
f = (H5F_t *)obj;
/* Go get the actual file size */
if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
base_addr = H5FD_get_base_addr(f->shared->lf);
if(size)
*size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */
break;
}
/* H5Fget_file_image */
case H5VL_FILE_GET_FILE_IMAGE:
{
void *buf_ptr = va_arg(arguments, void *);
ssize_t *ret = va_arg(arguments, ssize_t *);
size_t buf_len = va_arg(arguments, size_t );
f = (H5F_t *)obj;
/* Do the actual work */
if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed")
break;
}
/* H5Fget_freespace */
case H5VL_FILE_GET_FREE_SPACE:
{
hsize_t tot_space; /* Amount of free space in the file */
hssize_t *ret = va_arg(arguments, hssize_t *);
f = (H5F_t *)obj;
/* Go get the actual amount of free space in the file */
if(H5MF_get_freespace(f, &tot_space, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
*ret = (hssize_t)tot_space;
break;
}
case H5VL_FILE_GET_FREE_SECTIONS:
{
H5F_sect_info_t *sect_info = va_arg(arguments, H5F_sect_info_t *);
ssize_t *ret = va_arg(arguments, ssize_t *);
H5F_mem_t type = va_arg(arguments, H5F_mem_t);
size_t nsects = va_arg(arguments, size_t);
f = (H5F_t *)obj;
/* Go get the free-space section information in the file */
if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
break;
}
/* H5Fget_info2 */
case H5VL_FILE_GET_INFO:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
H5F_info2_t *finfo = va_arg(arguments, H5F_info2_t *);
/* Get the file struct. This call is careful to not return the file pointer
* for the top file in a mount hierarchy.
*/
if(NULL == (f = H5VL_native_get_file(obj, type)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct")
/* Get the file info */
if(H5F__get_info(f, finfo) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info")
break;
}
/* H5Fget_mdc_config */
case H5VL_FILE_GET_MDC_CONF:
{
H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *);
f = (H5F_t *)obj;
/* Go get the resize configuration */
if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.")
break;
}
/* H5Fget_mdc_hit_rate */
case H5VL_FILE_GET_MDC_HR:
{
double *hit_rate_ptr = va_arg(arguments, double *);
f = (H5F_t *)obj;
/* Go get the current hit rate */
if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.")
break;
}
/* H5Fget_mdc_size */
case H5VL_FILE_GET_MDC_SIZE:
{
size_t *max_size_ptr = va_arg(arguments, size_t *);
size_t *min_clean_size_ptr = va_arg(arguments, size_t *);
size_t *cur_size_ptr = va_arg(arguments, size_t *);
int *cur_num_entries_ptr = va_arg(arguments, int *);
uint32_t cur_num_entries;
f = (H5F_t *)obj;
/* Go get the size data */
if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr,
cur_size_ptr, &cur_num_entries) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.")
if(cur_num_entries_ptr != NULL)
*cur_num_entries_ptr = (int)cur_num_entries;
break;
}
/* H5Fget_vfd_handle */
case H5VL_FILE_GET_VFD_HANDLE:
{
void **file_handle = va_arg(arguments, void **);
hid_t fapl_id = va_arg(arguments, hid_t);
f = (H5F_t *)obj;
/* Retrieve the VFD handle for the file */
if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle")
break;
}
/* H5Fclear_elink_file_cache */
case H5VL_FILE_CLEAR_ELINK_CACHE:
{
f = (H5F_t *)obj;
/* Release the EFC */
if(f->shared->efc)
if(H5F__efc_release(f->shared->efc) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache")
break;
}
/* H5Freopen */
case H5VL_FILE_REOPEN:
{
void **ret = va_arg(arguments, void **);
H5F_t *new_file = NULL;
f = (H5F_t *)obj;
/* Reopen the file through the VOL driver */
if(NULL == (new_file = H5F__reopen(f)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
new_file->id_exists = TRUE;
*ret = (void *)new_file;
break;
}
/* H5Freset_mdc_hit_rate_stats */
case H5VL_FILE_RESET_MDC_HIT_RATE:
{
f = (H5F_t *)obj;
/* Reset the hit rate statistic */
if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate")
break;
}
case H5VL_FILE_SET_MDC_CONFIG:
{
H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *);
f = (H5F_t *)obj;
/* set the resize configuration */
if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed")
break;
}
case H5VL_FILE_GET_METADATA_READ_RETRY_INFO:
{
H5F_retry_info_t *info = va_arg(arguments, H5F_retry_info_t *);
f = (H5F_t *)obj;
if(H5F_get_metadata_read_retry_info(f, info) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info")
break;
}
case H5VL_FILE_START_SWMR_WRITE:
{
f = (H5F_t *)obj;
if(H5F__start_swmr_write(f) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write")
break;
}
case H5VL_FILE_START_MDC_LOGGING:
{
f = (H5F_t *)obj;
/* Call mdc logging function */
if(H5C_start_logging(f->shared->cache) < 0)
HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging")
break;
}
case H5VL_FILE_STOP_MDC_LOGGING:
{
f = (H5F_t *)obj;
/* Call mdc logging function */
if(H5C_stop_logging(f->shared->cache) < 0)
HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging")
break;
}
case H5VL_FILE_GET_MDC_LOGGING_STATUS:
{
hbool_t *is_enabled = va_arg(arguments, hbool_t *);
hbool_t *is_currently_logging = va_arg(arguments, hbool_t *);
f = (H5F_t *)obj;
/* Call mdc logging function */
if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0)
HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status")
break;
}
case H5VL_FILE_SET_LATEST_FORMAT:
{
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
break;
}
case H5VL_FILE_FORMAT_CONVERT:
{
f = (H5F_t *)obj;
/* Convert the format */
if(H5F__format_convert(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format")
break;
}
case H5VL_FILE_RESET_PAGE_BUFFERING_STATS:
{
f = (H5F_t *)obj;
/* Sanity check */
if(NULL == f->shared->page_buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file")
/* Reset the statistics */
if (H5PB_reset_stats(f->shared->page_buf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering")
break;
}
case H5VL_FILE_GET_PAGE_BUFFERING_STATS:
{
unsigned *accesses = va_arg(arguments, unsigned *);
unsigned *hits = va_arg(arguments, unsigned *);
unsigned *misses = va_arg(arguments, unsigned *);
unsigned *evictions = va_arg(arguments, unsigned *);
unsigned *bypasses = va_arg(arguments, unsigned *);
f = (H5F_t *)obj;
/* Sanity check */
if(NULL == f->shared->page_buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file")
/* Get the statistics */
if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering")
break;
}
case H5VL_FILE_GET_MDC_IMAGE_INFO:
{
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_optional() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_file_close
*
* Purpose: Closes a file.
*
* Return: SUCCEED/FAIL (the file will not be closed on failure)
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
int nref;
H5F_t *f = (H5F_t *)file;
hid_t file_id = H5I_INVALID_HID;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* This routine should only be called when a file ID's ref count drops to zero */
HDassert(H5F_ID_EXISTS(f));
/* Flush file if this is the last reference to this id and we have write
* intent, unless it will be flushed by the "shared" file being closed.
* This is only necessary to replicate previous behaviour, and could be
* disabled by an option/property to improve performance.
*/
if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) {
/* Get the file ID corresponding to the H5F_t struct */
if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom")
/* Get the number of references outstanding for this file ID */
if((nref = H5I_get_ref(file_id, FALSE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count")
if(nref == 1)
if(H5F__flush(f) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
}
/* Close the file */
if(H5F__close(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_close() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_group_create
*
* Purpose: Creates a group inside a native h5 file.
*
* Return: Success: Pointer to a group struct
*
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id,
hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Location to create group */
H5G_t *grp = NULL; /* New group created */
hid_t lcpl_id;
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Get the property list structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* Get creation properties */
if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
/* Set up the location */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* if name is NULL then this is from H5Gcreate_anon */
if(name == NULL) {
H5G_obj_create_t gcrt_info; /* Information for group creation */
/* Set up group creation info */
gcrt_info.gcpl_id = gcpl_id;
gcrt_info.cache_type = H5G_NOTHING_CACHED;
HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache));
/* Create the new group & get its ID */
if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group")
}
/* otherwise it's from H5Gcreate */
else {
/* Create the new group & get its ID */
if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group")
}
ret_value = (void *)grp;
done:
if(name == NULL) {
/* Release the group's object header, if it was created */
if(grp) {
H5O_loc_t *oloc; /* Object location for group */
/* Get the new group's object location */
if(NULL == (oloc = H5G_oloc(grp)))
HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group")
/* Decrement refcount on group's object header in memory */
if(H5O_dec_rc_by_loc(oloc) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
}
}
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_group_open
*
* Purpose: Opens a group inside a native h5 file.
*
* Return: Success: Pointer to a group struct
*
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Location to open group */
H5G_t *grp = NULL; /* New group opend */
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Set up the location */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Open the group */
if((grp = H5G__open_name(&loc, name)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group")
ret_value = (void *)grp;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_group_get
*
* Purpose: Gets data about a group
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(get_type) {
/* H5Gget_create_plist */
case H5VL_GROUP_GET_GCPL:
{
hid_t *new_gcpl_id = va_arg(arguments, hid_t *);
H5G_t *grp = (H5G_t *)obj;
if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group")
break;
}
/* H5Gget_info */
case H5VL_GROUP_GET_INFO:
{
H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t);
H5G_info_t *group_info = va_arg(arguments, H5G_info_t *);
H5G_loc_t loc;
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
/* H5Gget_info */
/* Retrieve the group's information */
if(H5G__obj_info(loc.oloc, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")
}
else if (loc_params.type == H5VL_OBJECT_BY_NAME) {
/* H5Gget_info_by_name */
/* Retrieve the group's information */
if(H5G__get_info_by_name(&loc, loc_params.loc_data.loc_by_name.name, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) {
/* H5Gget_info_by_idx */
/* Retrieve the group's information */
if(H5G__get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, group_info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters")
}
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_group_specific
*
* Purpose: Specific operations for groups
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_group_specific(void *obj, H5VL_group_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5G_t *grp = (H5G_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(specific_type) {
case H5VL_GROUP_FLUSH:
{
hid_t group_id = va_arg(arguments, hid_t);
/* Flush object's metadata to file */
if(H5O_flush_common(&grp->oloc, group_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group")
break;
}
case H5VL_GROUP_REFRESH:
{
hid_t group_id = va_arg(arguments, hid_t);
/* Call private function to refresh group object */
if((H5O_refresh_metadata(group_id, grp->oloc)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_group_close
*
* Purpose: Closes a group.
*
* Return: SUCCEED/FAIL (the group will not be closed on failure)
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5G_close((H5G_t *)grp) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_close() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_link_create
*
* Purpose: Creates an hard/soft/UD/external links.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params,
hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
switch(create_type) {
case H5VL_LINK_CREATE_HARD:
{
H5G_loc_t cur_loc;
H5G_loc_t link_loc;
void *cur_obj;
H5VL_loc_params_t cur_params;
if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id")
if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name")
if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(NULL != obj && H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* H5Lcreate_hard */
if(H5VL_OBJECT_BY_NAME == cur_params.type) {
H5G_loc_t *cur_loc_p, *link_loc_p;
/* Set up current & new location pointers */
cur_loc_p = &cur_loc;
link_loc_p = &link_loc;
if(NULL == cur_obj)
cur_loc_p = link_loc_p;
else if(NULL == obj)
link_loc_p = cur_loc_p;
else if(cur_loc_p->oloc->file != link_loc_p->oloc->file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.")
/* Create the link */
if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name,
link_loc_p, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
}
else { /* H5Olink */
/* Link to the object */
if(H5L_link(&link_loc, loc_params.loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link")
}
break;
}
case H5VL_LINK_CREATE_SOFT:
{
char *target_name;
H5G_loc_t link_loc; /* Group location for new link */
if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name")
/* Create the link */
if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
break;
}
case H5VL_LINK_CREATE_UD:
{
H5G_loc_t link_loc; /* Group location for new link */
H5L_type_t link_type;
void *udata;
size_t udata_size;
if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type")
if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata")
if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size")
/* Create link */
if(H5L__create_ud(&link_loc, loc_params.loc_data.loc_by_name.name, udata, udata_size,
link_type, lcpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
break;
}
default:
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_link_copy
*
* Purpose: Renames an object within an HDF5 file and copies 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
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1,
void *dst_obj, H5VL_loc_params_t loc_params2,
hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t src_loc, *src_loc_p;
H5G_loc_t dst_loc, *dst_loc_p;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Set up src & dst location pointers */
src_loc_p = &src_loc;
dst_loc_p = &dst_loc;
if(NULL == src_obj)
src_loc_p = dst_loc_p;
else if(NULL == dst_obj)
dst_loc_p = src_loc_p;
/* Copy the link */
if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name,
dst_loc_p, loc_params2.loc_data.loc_by_name.name,
TRUE, lcpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_copy() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_link_move
*
* 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
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1,
void *dst_obj, H5VL_loc_params_t loc_params2,
hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t src_loc, *src_loc_p;
H5G_loc_t dst_loc, *dst_loc_p;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Set up src & dst location pointers */
src_loc_p = &src_loc;
dst_loc_p = &dst_loc;
if(NULL == src_obj)
src_loc_p = dst_loc_p;
else if(NULL == dst_obj)
dst_loc_p = src_loc_p;
/* Move the link */
if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name,
dst_loc_p, loc_params2.loc_data.loc_by_name.name,
FALSE, lcpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_move() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_link_get
*
* Purpose: Gets certain data about a link
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5G_loc_t loc;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch(get_type) {
/* H5Lget_info/H5Lget_info_by_idx */
case H5VL_LINK_GET_INFO:
{
H5L_info_t *linfo = va_arg(arguments, H5L_info_t *);
/* Get the link information */
if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */
if(H5L_get_info(&loc, loc_params.loc_data.loc_by_name.name, linfo) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */
if(H5L_get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, linfo) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info")
}
else
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info")
break;
}
/* H5Lget_name_by_idx */
case H5VL_LINK_GET_NAME:
{
char *name = va_arg(arguments, char *);
size_t size = va_arg(arguments, size_t);
ssize_t *ret = va_arg(arguments, ssize_t *);
/* Get the link name */
if((*ret = H5L_get_name_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, name, size)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info")
break;
}
/* H5Lget_val/H5Lget_val_by_idx */
case H5VL_LINK_GET_VAL:
{
void *buf = va_arg(arguments, void *);
size_t size = va_arg(arguments, size_t);
/* Get the link information */
if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */
if(H5L_get_val(&loc, loc_params.loc_data.loc_by_name.name, buf, size) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */
if(H5L_get_val_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, buf, size) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val")
}
else
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_link_specific
*
* Purpose: Specific operations with links
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(specific_type) {
case H5VL_LINK_EXISTS:
{
htri_t *ret = va_arg(arguments, htri_t *);
H5G_loc_t loc;
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Check for the existence of the link */
if((*ret = H5L_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info")
break;
}
case H5VL_LINK_ITER:
{
H5G_loc_t loc;
hbool_t recursive = va_arg(arguments, int);
H5_index_t idx_type = va_arg(arguments, H5_index_t);
H5_iter_order_t order = va_arg(arguments, H5_iter_order_t);
hsize_t *idx_p = va_arg(arguments, hsize_t *);
H5L_iterate_t op = va_arg(arguments, H5L_iterate_t);
void *op_data = va_arg(arguments, void *);
/* Get the location */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
/* Visit or iterate over the links */
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
if(recursive) {
/* H5Lvisit */
if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed")
}
else {
/* H5Literate */
if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links")
}
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
if(recursive) {
/* H5Lvisit_by_name */
if((ret_value = H5G_visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed")
}
else {
/* H5Literate_by_name */
if((ret_value = H5L_iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links")
}
}
else{
HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params")
}
break;
}
case H5VL_LINK_DELETE:
{
H5G_loc_t loc;
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Unlink */
if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */
if(H5L_delete(&loc, loc_params.loc_data.loc_by_name.name) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */
if(H5L_delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
}
else
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_open
*
* Purpose: Opens a object inside a native h5 file.
*
* Return: Success: object id.
* Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc;
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
switch(loc_params.type) {
case H5VL_OBJECT_BY_NAME:
{
/* Open the object */
if(NULL == (ret_value = H5O_open_name(&loc, loc_params.loc_data.loc_by_name.name, opened_type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name")
break;
}
case H5VL_OBJECT_BY_IDX:
{
/* Open the object */
if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, opened_type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index")
break;
}
case H5VL_OBJECT_BY_ADDR:
{
/* Open the object */
if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params.loc_data.loc_by_addr.addr, opened_type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address")
break;
}
case H5VL_OBJECT_BY_REF:
{
hid_t temp_id = H5I_INVALID_HID;
H5F_t *file = NULL;
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Create reference */
if((temp_id = H5R__dereference(file, loc_params.loc_data.loc_by_ref.lapl_id,
loc_params.loc_data.loc_by_ref.ref_type,
loc_params.loc_data.loc_by_ref._ref)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object")
*opened_type = H5I_get_type(temp_id);
if(NULL == (ret_value = H5I_remove(temp_id)))
HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
break;
}
case H5VL_OBJECT_BY_SELF:
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_copy
*
* Purpose: Copys a object inside a native h5 file.
*
* Return: Success: object id.
* Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name,
void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name,
hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t src_loc; /* Source object group location */
H5G_loc_t dst_loc; /* Destination group location */
herr_t ret_value = FAIL;
FUNC_ENTER_NOAPI_NOINIT
/* get location for objects */
if(H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Open the object */
if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_copy() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_get
*
* Purpose: Gets certain data about an object
*
* Return: SUCCEED/FAIL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
H5G_loc_t loc; /* Location of group */
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch(get_type) {
/* H5Rget_region */
case H5VL_REF_GET_REGION:
{
hid_t *ret = va_arg(arguments, hid_t *);
H5R_type_t H5_ATTR_UNUSED ref_type = va_arg(arguments, H5R_type_t);
void *ref = va_arg(arguments, void *);
H5S_t *space = NULL; /* Dataspace object */
/* Get the dataspace with the correct region selected */
if((space = H5R__get_region(loc.oloc->file, ref)) == NULL)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region")
/* Atomize */
if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
break;
}
/* H5Rget_obj_type2 */
case H5VL_REF_GET_TYPE:
{
H5O_type_t *obj_type = va_arg(arguments, H5O_type_t *);
H5R_type_t ref_type = va_arg(arguments, H5R_type_t);
void *ref = va_arg(arguments, void *);
/* Get the object information */
if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type")
break;
}
/* H5Rget_name */
case H5VL_REF_GET_NAME:
{
ssize_t *ret = va_arg(arguments, ssize_t *);
char *name = va_arg(arguments, char *);
size_t size = va_arg(arguments, size_t);
H5R_type_t ref_type = va_arg(arguments, H5R_type_t);
void *ref = va_arg(arguments, void *);
/* Get name */
if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_specific
*
* Purpose: Perform a driver specific operation for an objectibute
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5G_loc_t loc;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch(specific_type) {
/* H5Oincr_refcount / H5Odecr_refcount */
case H5VL_OBJECT_CHANGE_REF_COUNT:
{
int update_ref = va_arg(arguments, int);
H5O_loc_t *oloc = loc.oloc;
if(H5O_link(oloc, update_ref) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed")
break;
}
/* H5Oexists_by_name */
case H5VL_OBJECT_EXISTS:
{
htri_t *ret = va_arg(arguments, htri_t *);
if(loc_params.type == H5VL_OBJECT_BY_NAME) {
/* Check if the object exists */
if((*ret = H5G_loc_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists",
loc_params.loc_data.loc_by_name.name)
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters")
}
break;
}
case H5VL_OBJECT_VISIT:
{
H5_index_t idx_type = va_arg(arguments, H5_index_t);
H5_iter_order_t order = va_arg(arguments, H5_iter_order_t);
H5O_iterate_t op = va_arg(arguments, H5O_iterate_t);
void *op_data = va_arg(arguments, void *);
unsigned fields = va_arg(arguments, unsigned);
/* Call internal object visitation routine */
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
/* H5Ovisit */
if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
/* H5Ovisit_by_name */
if((ret_value = H5O__visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
}
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params");
break;
}
case H5VL_OBJECT_FLUSH:
{
hid_t oid = va_arg(arguments, hid_t);
/* Flush the object's metadata */
if(H5O_flush(loc.oloc, oid) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
break;
}
case H5VL_OBJECT_REFRESH:
{
hid_t oid = va_arg(arguments, hid_t);
H5O_loc_t *oloc = loc.oloc;
/* Refresh the metadata */
if(H5O_refresh_metadata(oid, *oloc) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
break;
}
case H5VL_REF_CREATE:
{
void *ref = va_arg(arguments, void *);
const char *name = va_arg(arguments, char *);
H5R_type_t ref_type = va_arg(arguments, H5R_type_t);
hid_t space_id = va_arg(arguments, hid_t);
H5S_t *space = NULL; /* Pointer to dataspace containing region */
if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Create reference */
if(H5R__create(ref, &loc, name, ref_type, space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_optional
*
* Purpose: Perform a driver specific operation for an objectibute
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5VL_object_optional_t optional_type = va_arg(arguments, H5VL_object_optional_t);
H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t);
H5G_loc_t loc; /* Location of group */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch(optional_type) {
/* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */
case H5VL_OBJECT_GET_INFO:
{
H5O_info_t *obj_info = va_arg(arguments, H5O_info_t *);
unsigned fields = va_arg(arguments, unsigned);
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */
/* Retrieve the object's information */
if(H5G_loc_info(&loc, ".", obj_info, fields) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */
/* Retrieve the object's information */
if(H5G_loc_info(&loc, loc_params.loc_data.loc_by_name.name, obj_info, fields) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */
H5G_loc_t obj_loc; /* Location used to open group */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
H5G_loc_reset(&obj_loc);
/* Find the object's location, according to the order in the index */
if(H5G_loc_find_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
loc_params.loc_data.loc_by_idx.idx_type,
loc_params.loc_data.loc_by_idx.order,
loc_params.loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found")
/* Retrieve the object's information */
if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) {
H5G_loc_free(&obj_loc);
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info")
}
/* Release the object location */
if(H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters")
}
break;
}
/* H5Oget_comment / H5Oget_comment_by_name */
case H5VL_OBJECT_GET_COMMENT:
{
char *comment = va_arg(arguments, char *);
size_t bufsize = va_arg(arguments, size_t);
ssize_t *ret = va_arg(arguments, ssize_t *);
/* Retrieve the object's comment */
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */
if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */
if((*ret = H5G_loc_get_comment(&loc, loc_params.loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters")
}
break;
}
/* H5Oset_comment */
case H5VL_OBJECT_SET_COMMENT:
{
const char *comment = va_arg(arguments, char *);
if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */
/* (Re)set the object's comment */
if(H5G_loc_set_comment(&loc, ".", comment) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */
/* (Re)set the object's comment */
if(H5G_loc_set_comment(&loc, loc_params.loc_data.loc_by_name.name, comment) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
}
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters")
}
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object");
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_optional() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_datatype_commit
*
* Purpose: Commits a datatype inside a native h5 file.
*
* Return: Success: datatype id.
* Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id,
hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Location to commit datatype */
H5T_t *dt; /* Datatype for ID */
H5T_t *type = NULL; /* copy of the original type which will be committed */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype")
/* Check arguments. We cannot commit an immutable type because H5Tclose()
* normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing
* a named type should always succeed.
*/
if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed")
if(H5T_STATE_IMMUTABLE == dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable")
/* Check for a "sensible" datatype to store on disk */
if(H5T_is_sensible(dt) <= 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible")
/* Copy the datatype - the copied one will be the type that is
* committed, and attached to original datatype above the VOL
* layer
*/
if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy");
/* Commit the datatype */
if(NULL != name) {
/* H5Tcommit */
if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype")
}
else {
/* H5Tcommit_anon */
if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype")
}
ret_value = (void *)type;
done:
if(NULL == ret_value && type)
H5T_close(type);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_commit() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_datatype_open
*
* Purpose: Opens a named datatype inside a native h5 file.
*
* Return: Success: datatype pointer
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5T_t *type = NULL; /* Datatype opened in file */
H5G_loc_t loc; /* Group location of object to open */
void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Open the datatype */
if(NULL == (type = H5T__open_name(&loc, name)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
type->vol_obj = NULL;
ret_value = (void *)type;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_datatype_get
*
* Purpose: Gets certain information about a datatype
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Mohamad Chaarawi
* June, 2013
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_datatype_get(void *obj, H5VL_datatype_get_t get_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5T_t *dt = (H5T_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch (get_type) {
case H5VL_DATATYPE_GET_BINARY:
{
ssize_t *nalloc = va_arg(arguments, ssize_t *);
void *buf = va_arg(arguments, void *);
size_t size = va_arg(arguments, size_t);
if(H5T_encode(dt, (unsigned char *)buf, &size) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype")
*nalloc = (ssize_t) size;
break;
}
/* H5Tget_create_plist */
case H5VL_DATATYPE_GET_TCPL:
{
hid_t *ret_id = va_arg(arguments, hid_t *);
if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info");
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_datatype_specific
*
* Purpose: Specific operations for datatype
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments)
{
H5T_t *dt = (H5T_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch(specific_type) {
case H5VL_DATATYPE_FLUSH:
{
hid_t type_id = va_arg(arguments, hid_t);
/* To flush metadata and invoke flush callback if there is */
if (H5O_flush_common(&dt->oloc, type_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype")
break;
}
case H5VL_DATATYPE_REFRESH:
{
hid_t type_id = va_arg(arguments, hid_t);
/* Call private function to refresh datatype object */
if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_native_datatype_close
*
* Purpose: Closes an datatype.
*
* Return: Success: 0
* Failure: -1, datatype not closed.
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
if(H5T_close((H5T_t*)dt) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_close() */
|