Coverage Report

Created: 2026-01-17 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5VLnative.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*
14
 * Purpose:     The native VOL connector where access is to a single HDF5 file
15
 *              using HDF5 VFDs.
16
 */
17
18
/****************/
19
/* Module Setup */
20
/****************/
21
22
#define H5VL_FRIEND /* Suppress error about including H5VLpkg   */
23
24
/***********/
25
/* Headers */
26
/***********/
27
28
#include "H5private.h"  /* Generic Functions                        */
29
#include "H5Aprivate.h" /* Attributes                               */
30
#include "H5Dprivate.h" /* Datasets                                 */
31
#include "H5Eprivate.h" /* Error handling                           */
32
#include "H5Fprivate.h" /* Files                                    */
33
#include "H5Gprivate.h" /* Groups                                   */
34
#include "H5Iprivate.h" /* IDs                                      */
35
#include "H5Oprivate.h" /* Object headers                           */
36
#include "H5Pprivate.h" /* Property lists                           */
37
#include "H5Tprivate.h" /* Datatypes                                */
38
#include "H5VLpkg.h"    /* Virtual Object Layer                     */
39
40
#include "H5VLnative_private.h" /* Native VOL connector                     */
41
42
/* The native VOL connector */
43
hid_t             H5VL_NATIVE_g      = H5I_INVALID_HID;
44
H5VL_connector_t *H5VL_NATIVE_conn_g = NULL;
45
46
#define H5VL_NATIVE_CAP_FLAGS                                                                                \
47
    (H5VL_CAP_FLAG_NATIVE_FILES | H5VL_CAP_FLAG_ATTR_BASIC | H5VL_CAP_FLAG_ATTR_MORE |                       \
48
     H5VL_CAP_FLAG_DATASET_BASIC | H5VL_CAP_FLAG_DATASET_MORE | H5VL_CAP_FLAG_FILE_BASIC |                   \
49
     H5VL_CAP_FLAG_FILE_MORE | H5VL_CAP_FLAG_GROUP_BASIC | H5VL_CAP_FLAG_GROUP_MORE |                        \
50
     H5VL_CAP_FLAG_LINK_BASIC | H5VL_CAP_FLAG_LINK_MORE | H5VL_CAP_FLAG_OBJECT_BASIC |                       \
51
     H5VL_CAP_FLAG_OBJECT_MORE | H5VL_CAP_FLAG_REF_BASIC | H5VL_CAP_FLAG_REF_MORE | H5VL_CAP_FLAG_OBJ_REF |  \
52
     H5VL_CAP_FLAG_REG_REF | H5VL_CAP_FLAG_ATTR_REF | H5VL_CAP_FLAG_STORED_DATATYPES |                       \
53
     H5VL_CAP_FLAG_CREATION_ORDER | H5VL_CAP_FLAG_ITERATE | H5VL_CAP_FLAG_STORAGE_SIZE |                     \
54
     H5VL_CAP_FLAG_BY_IDX | H5VL_CAP_FLAG_GET_PLIST | H5VL_CAP_FLAG_FLUSH_REFRESH |                          \
55
     H5VL_CAP_FLAG_EXTERNAL_LINKS | H5VL_CAP_FLAG_HARD_LINKS | H5VL_CAP_FLAG_SOFT_LINKS |                    \
56
     H5VL_CAP_FLAG_UD_LINKS | H5VL_CAP_FLAG_TRACK_TIMES | H5VL_CAP_FLAG_MOUNT | H5VL_CAP_FLAG_FILTERS |      \
57
     H5VL_CAP_FLAG_FILL_VALUES)
58
59
/* Native VOL connector class struct */
60
static const H5VL_class_t H5VL_native_cls_g = {
61
    H5VL_VERSION,          /* VOL class struct version */
62
    H5VL_NATIVE_VALUE,     /* value        */
63
    H5VL_NATIVE_NAME,      /* name         */
64
    H5VL_NATIVE_VERSION,   /* connector version */
65
    H5VL_NATIVE_CAP_FLAGS, /* capability flags */
66
    NULL,                  /* initialize   */
67
    NULL,                  /* terminate    */
68
    {
69
        /* info_cls */
70
        (size_t)0, /* info size    */
71
        NULL,      /* info copy    */
72
        NULL,      /* info compare */
73
        NULL,      /* info free    */
74
        NULL,      /* info to str  */
75
        NULL       /* str to info  */
76
    },
77
    {
78
        /* wrap_cls */
79
        NULL, /* get_object   */
80
        NULL, /* get_wrap_ctx */
81
        NULL, /* wrap_object  */
82
        NULL, /* unwrap_object */
83
        NULL  /* free_wrap_ctx */
84
    },
85
    {
86
        /* attribute_cls */
87
        H5VL__native_attr_create,   /* create       */
88
        H5VL__native_attr_open,     /* open         */
89
        H5VL__native_attr_read,     /* read         */
90
        H5VL__native_attr_write,    /* write        */
91
        H5VL__native_attr_get,      /* get          */
92
        H5VL__native_attr_specific, /* specific     */
93
        H5VL__native_attr_optional, /* optional     */
94
        H5VL__native_attr_close     /* close        */
95
    },
96
    {
97
        /* dataset_cls */
98
        H5VL__native_dataset_create,   /* create       */
99
        H5VL__native_dataset_open,     /* open         */
100
        H5VL__native_dataset_read,     /* read         */
101
        H5VL__native_dataset_write,    /* write        */
102
        H5VL__native_dataset_get,      /* get          */
103
        H5VL__native_dataset_specific, /* specific     */
104
        H5VL__native_dataset_optional, /* optional     */
105
        H5VL__native_dataset_close     /* close        */
106
    },
107
    {
108
        /* datatype_cls */
109
        H5VL__native_datatype_commit,   /* commit       */
110
        H5VL__native_datatype_open,     /* open         */
111
        H5VL__native_datatype_get,      /* get          */
112
        H5VL__native_datatype_specific, /* specific     */
113
        NULL,                           /* optional     */
114
        H5VL__native_datatype_close     /* close        */
115
    },
116
    {
117
        /* file_cls */
118
        H5VL__native_file_create,   /* create       */
119
        H5VL__native_file_open,     /* open         */
120
        H5VL__native_file_get,      /* get          */
121
        H5VL__native_file_specific, /* specific     */
122
        H5VL__native_file_optional, /* optional     */
123
        H5VL__native_file_close     /* close        */
124
    },
125
    {
126
        /* group_cls */
127
        H5VL__native_group_create,   /* create       */
128
        H5VL__native_group_open,     /* open         */
129
        H5VL__native_group_get,      /* get          */
130
        H5VL__native_group_specific, /* specific     */
131
        H5VL__native_group_optional, /* optional     */
132
        H5VL__native_group_close     /* close        */
133
    },
134
    {
135
        /* link_cls */
136
        H5VL__native_link_create,   /* create       */
137
        H5VL__native_link_copy,     /* copy         */
138
        H5VL__native_link_move,     /* move         */
139
        H5VL__native_link_get,      /* get          */
140
        H5VL__native_link_specific, /* specific     */
141
        NULL                        /* optional     */
142
    },
143
    {
144
        /* object_cls */
145
        H5VL__native_object_open,     /* open         */
146
        H5VL__native_object_copy,     /* copy         */
147
        H5VL__native_object_get,      /* get          */
148
        H5VL__native_object_specific, /* specific     */
149
        H5VL__native_object_optional  /* optional     */
150
    },
151
    {
152
        /* introspect_cls */
153
        H5VL__native_introspect_get_conn_cls,  /* get_conn_cls */
154
        H5VL__native_introspect_get_cap_flags, /* get_cap_flags */
155
        H5VL__native_introspect_opt_query,     /* opt_query    */
156
    },
157
    {
158
        /* request_cls */
159
        NULL, /* wait         */
160
        NULL, /* notify       */
161
        NULL, /* cancel       */
162
        NULL, /* specific     */
163
        NULL, /* optional     */
164
        NULL  /* free         */
165
    },
166
    {
167
        /* blob_cls */
168
        H5VL__native_blob_put,      /* put */
169
        H5VL__native_blob_get,      /* get */
170
        H5VL__native_blob_specific, /* specific */
171
        NULL                        /* optional */
172
    },
173
    {
174
        /* token_cls */
175
        H5VL__native_token_cmp,    /* cmp            */
176
        H5VL__native_token_to_str, /* to_str         */
177
        H5VL__native_str_to_token  /* from_str       */
178
    },
179
    NULL /* optional     */
180
};
181
182
/*-------------------------------------------------------------------------
183
 * Function:    H5VL__native_register
184
 *
185
 * Purpose:     Register the native VOL connector and set up an ID for it.
186
 *
187
 * Return:      SUCCEED/FAIL
188
 *
189
 *-------------------------------------------------------------------------
190
 */
191
herr_t
192
H5VL__native_register(void)
193
2
{
194
2
    herr_t ret_value = SUCCEED; /* Return value */
195
196
2
    FUNC_ENTER_PACKAGE
197
198
    /* Register the native VOL connector, if it isn't already */
199
2
    if (NULL == H5VL_NATIVE_conn_g)
200
2
        if (NULL ==
201
2
            (H5VL_NATIVE_conn_g = H5VL__register_connector(&H5VL_native_cls_g, H5P_VOL_INITIALIZE_DEFAULT)))
202
0
            HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register native VOL connector");
203
204
    /* Get ID for connector */
205
2
    if (H5I_VOL != H5I_get_type(H5VL_NATIVE_g)) {
206
2
        if ((H5VL_NATIVE_g = H5I_register(H5I_VOL, H5VL_NATIVE_conn_g, false)) < 0)
207
0
            HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't create ID for native VOL connector");
208
209
        /* ID is holding a reference to the connector */
210
2
        H5VL_conn_inc_rc(H5VL_NATIVE_conn_g);
211
2
    }
212
213
2
done:
214
2
    FUNC_LEAVE_NOAPI(ret_value)
215
2
} /* end H5VL__native_register() */
216
217
/*---------------------------------------------------------------------------
218
 * Function:    H5VL__native_unregister
219
 *
220
 * Purpose:     Shut down the native VOL
221
 *
222
 * Returns:     SUCCEED (Can't fail)
223
 *
224
 *---------------------------------------------------------------------------
225
 */
226
herr_t
227
H5VL__native_unregister(void)
228
2
{
229
2
    FUNC_ENTER_PACKAGE_NOERR
230
231
    /* Reset VOL connector info */
232
2
    H5VL_NATIVE_g      = H5I_INVALID_HID;
233
2
    H5VL_NATIVE_conn_g = NULL;
234
235
2
    FUNC_LEAVE_NOAPI(SUCCEED)
236
2
} /* end H5VL__native_unregister() */
237
238
/*---------------------------------------------------------------------------
239
 * Function:    H5VL__native_introspect_get_conn_cls
240
 *
241
 * Purpose:     Query the connector class.
242
 *
243
 * Note:        This routine is in this file so that it can return the address
244
 *              of the statically declared class struct.
245
 *
246
 * Returns:     SUCCEED (Can't fail)
247
 *
248
 *---------------------------------------------------------------------------
249
 */
250
herr_t
251
H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, H5VL_get_conn_lvl_t H5_ATTR_UNUSED lvl,
252
                                     const H5VL_class_t **conn_cls)
253
0
{
254
0
    FUNC_ENTER_PACKAGE_NOERR
255
256
    /* Sanity check */
257
0
    assert(conn_cls);
258
259
    /* Retrieve the native VOL connector class */
260
0
    *conn_cls = &H5VL_native_cls_g;
261
262
0
    FUNC_LEAVE_NOAPI(SUCCEED)
263
0
} /* end H5VL__native_introspect_get_conn_cls() */
264
265
/*---------------------------------------------------------------------------
266
 * Function:    H5VL__native_introspect_get_cap_flags
267
 *
268
 * Purpose:     Query the capability flags for this connector.
269
 *
270
 * Note:        This routine is in this file so that it can return the field
271
 *              from the statically declared class struct.
272
 *
273
 * Returns:     SUCCEED (Can't fail)
274
 *
275
 *---------------------------------------------------------------------------
276
 */
277
herr_t
278
H5VL__native_introspect_get_cap_flags(const void H5_ATTR_UNUSED *info, uint64_t *cap_flags)
279
0
{
280
0
    FUNC_ENTER_PACKAGE_NOERR
281
282
    /* Sanity check */
283
0
    assert(cap_flags);
284
285
    /* Set the flags from the connector's field */
286
0
    *cap_flags = H5VL_native_cls_g.cap_flags;
287
288
0
    FUNC_LEAVE_NOAPI(SUCCEED)
289
0
} /* end H5VL__native_introspect_get_cap_flags() */
290
291
/*-------------------------------------------------------------------------
292
 * Function:    H5VL_native_get_file_addr_len
293
 *
294
 * Purpose:     Convenience function to get a file's address length from a
295
 *              location ID. Useful when you have to encode/decode addresses
296
 *              to/from tokens.
297
 *
298
 * Return:      SUCCEED/FAIL
299
 *
300
 *-------------------------------------------------------------------------
301
 */
302
herr_t
303
H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len)
304
0
{
305
0
    H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */
306
0
    void      *vol_obj      = NULL;      /* VOL Object of loc_id */
307
0
    herr_t     ret_value    = SUCCEED;   /* Return value */
308
309
0
    FUNC_ENTER_NOAPI(FAIL)
310
311
    /* check arguments */
312
0
    assert(addr_len);
313
314
    /* Get object type */
315
0
    if ((vol_obj_type = H5I_get_type(loc_id)) < 0)
316
0
        HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier");
317
318
    /* Retrieve underlying VOL object */
319
0
    if (NULL == (vol_obj = H5VL_object(loc_id)))
320
0
        HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier");
321
322
    /* Retrieve file address length */
323
0
    if (H5VL__native_get_file_addr_len(vol_obj, vol_obj_type, addr_len) < 0)
324
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get file address length");
325
326
0
done:
327
0
    FUNC_LEAVE_NOAPI(ret_value)
328
0
} /* end H5VL_native_get_file_addr_len() */
329
330
/*-------------------------------------------------------------------------
331
 * Function:    H5VL__native_get_file_addr_len
332
 *
333
 * Purpose:     Convenience function to get a file's address length from a
334
 *              VOL object. Useful when you have to encode/decode addresses
335
 *              to/from tokens.
336
 *
337
 * Return:      SUCCEED/FAIL
338
 *
339
 *-------------------------------------------------------------------------
340
 */
341
herr_t
342
H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len)
343
0
{
344
0
    H5F_t *file      = NULL; /* File struct pointer */
345
0
    herr_t ret_value = SUCCEED;
346
347
0
    FUNC_ENTER_PACKAGE
348
349
    /* check arguments */
350
0
    assert(obj);
351
0
    assert(addr_len);
352
353
    /* Retrieve file from the VOL object */
354
0
    if (H5VL_native_get_file_struct(obj, obj_type, &file) < 0)
355
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get file from VOL object");
356
357
    /* Get the length of an address in this file */
358
0
    *addr_len = H5F_SIZEOF_ADDR(file);
359
360
0
done:
361
0
    FUNC_LEAVE_NOAPI(ret_value)
362
0
} /* end H5VL__native_get_file_addr_len() */
363
364
/*-------------------------------------------------------------------------
365
 * Function:    H5VLnative_addr_to_token
366
 *
367
 * Purpose:     Converts a native VOL haddr_t address to an abstract VOL token.
368
 *
369
 * Return:      SUCCEED/FAIL
370
 *
371
 *-------------------------------------------------------------------------
372
 */
373
herr_t
374
H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token)
375
0
{
376
0
    H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */
377
0
    void      *vol_obj      = NULL;      /* VOL Object of loc_id */
378
0
    herr_t     ret_value    = SUCCEED;   /* Return value         */
379
380
0
    FUNC_ENTER_API(FAIL)
381
382
    /* Check args */
383
0
    if (NULL == token)
384
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "token pointer can't be NULL");
385
386
    /* Get object type */
387
0
    if ((vol_obj_type = H5I_get_type(loc_id)) < 0)
388
0
        HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier");
389
390
    /* Retrieve underlying VOL object */
391
0
    if (NULL == (vol_obj = H5VL_object(loc_id)))
392
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object");
393
394
#ifndef NDEBUG
395
    {
396
        H5VL_object_t *vol_obj_container;
397
        bool           is_native_vol_obj;
398
399
        /* Get the location object */
400
        if (NULL == (vol_obj_container = H5VL_vol_object(loc_id)))
401
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");
402
403
        /* Make sure that the VOL object is a native connector object */
404
        if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0)
405
            HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL,
406
                        "can't determine if VOL object is native connector object");
407
408
        assert(is_native_vol_obj && "not a native VOL connector object");
409
    }
410
#endif
411
412
    /* Convert the haddr_t to an object token */
413
0
    if (H5VL_native_addr_to_token(vol_obj, vol_obj_type, addr, token) < 0)
414
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "couldn't serialize haddr_t into object token");
415
416
0
done:
417
0
    FUNC_LEAVE_API(ret_value)
418
0
} /* end H5VLnative_addr_to_token() */
419
420
/*-------------------------------------------------------------------------
421
 * Function:    H5VL_native_addr_to_token
422
 *
423
 * Purpose:     Converts a native VOL haddr_t address to an abstract VOL token.
424
 *
425
 * Return:      SUCCEED/FAIL
426
 *
427
 *-------------------------------------------------------------------------
428
 */
429
herr_t
430
H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token)
431
0
{
432
0
    uint8_t *p;
433
0
    size_t   addr_len  = 0; /* Size of haddr_t      */
434
0
    herr_t   ret_value = SUCCEED;
435
436
0
    FUNC_ENTER_NOAPI(FAIL)
437
438
    /* Check args */
439
0
    assert(obj);
440
0
    assert(token);
441
442
    /* Get the length of an haddr_t in the file */
443
0
    if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0)
444
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object");
445
446
    /* Ensure that token is initialized */
447
0
    memset(token, 0, sizeof(H5O_token_t));
448
449
    /* Encode token */
450
0
    p = (uint8_t *)token;
451
0
    H5F_addr_encode_len(addr_len, &p, addr);
452
453
0
done:
454
0
    FUNC_LEAVE_NOAPI(ret_value)
455
0
} /* end H5VL_native_addr_to_token() */
456
457
/*-------------------------------------------------------------------------
458
 * Function:    H5VLnative_token_to_addr
459
 *
460
 * Purpose:     Converts an abstract VOL token to a native VOL haddr_t address.
461
 *
462
 * Return:      SUCCEED/FAIL
463
 *
464
 *-------------------------------------------------------------------------
465
 */
466
herr_t
467
H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr)
468
0
{
469
0
    H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */
470
0
    void      *vol_obj      = NULL;      /* VOL Object of loc_id */
471
0
    herr_t     ret_value    = SUCCEED;   /* Return value         */
472
473
0
    FUNC_ENTER_API(FAIL)
474
475
    /* Check args */
476
0
    if (NULL == addr)
477
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr pointer can't be NULL");
478
479
    /* Get object type */
480
0
    if ((vol_obj_type = H5I_get_type(loc_id)) < 0)
481
0
        HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier");
482
483
    /* Retrieve underlying VOL object */
484
0
    if (NULL == (vol_obj = H5VL_object(loc_id)))
485
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object");
486
487
#ifndef NDEBUG
488
    {
489
        H5VL_object_t *vol_obj_container;
490
        bool           is_native_vol_obj;
491
492
        /* Get the location object */
493
        if (NULL == (vol_obj_container = H5VL_vol_object(loc_id)))
494
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");
495
496
        /* Make sure that the VOL object is a native connector object */
497
        if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0)
498
            HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL,
499
                        "can't determine if VOL object is native connector object");
500
501
        assert(is_native_vol_obj && "not a native VOL connector object");
502
    }
503
#endif
504
505
    /* Convert the object token to an haddr_t */
506
0
    if (H5VL_native_token_to_addr(vol_obj, vol_obj_type, token, addr) < 0)
507
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "couldn't deserialize object token into haddr_t");
508
509
0
done:
510
0
    FUNC_LEAVE_API(ret_value)
511
0
} /* end H5VLnative_token_to_addr() */
512
513
/*-------------------------------------------------------------------------
514
 * Function:    H5VL_native_token_to_addr
515
 *
516
 * Purpose:     Converts an abstract VOL token to a native VOL haddr_t address.
517
 *
518
 * Return:      SUCCEED/FAIL
519
 *
520
 *-------------------------------------------------------------------------
521
 */
522
herr_t
523
H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr)
524
0
{
525
0
    const uint8_t *p;
526
0
    size_t         addr_len  = 0; /* Size of haddr_t      */
527
0
    herr_t         ret_value = SUCCEED;
528
529
0
    FUNC_ENTER_NOAPI(FAIL)
530
531
    /* Check args */
532
0
    assert(obj);
533
0
    assert(addr);
534
535
    /* Get the length of an haddr_t in the file */
536
0
    if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0)
537
0
        HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object");
538
539
    /* Decode token */
540
0
    p = (const uint8_t *)&token;
541
0
    H5F_addr_decode_len(addr_len, &p, addr);
542
543
0
done:
544
0
    FUNC_LEAVE_NOAPI(ret_value)
545
0
} /* end H5VL_native_token_to_addr() */
546
547
/*---------------------------------------------------------------------------
548
 * Function:    H5VL_native_get_file_struct
549
 *
550
 * Purpose:     Utility routine to get file struct for an object
551
 *
552
 * Returns:     SUCCEED/FAIL
553
 *
554
 *---------------------------------------------------------------------------
555
 */
556
herr_t
557
H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file)
558
0
{
559
0
    H5O_loc_t *oloc      = NULL;    /* Object location for ID   */
560
0
    herr_t     ret_value = SUCCEED; /* Return value             */
561
562
0
    FUNC_ENTER_NOAPI(FAIL)
563
564
0
    *file = NULL;
565
566
0
    switch (type) {
567
0
        case H5I_FILE:
568
0
            *file = (H5F_t *)obj;
569
0
            break;
570
571
0
        case H5I_GROUP:
572
0
            oloc = H5G_oloc((H5G_t *)obj);
573
0
            break;
574
575
0
        case H5I_DATATYPE:
576
0
            oloc = H5T_oloc((H5T_t *)obj);
577
0
            break;
578
579
0
        case H5I_DATASET:
580
0
            oloc = H5D_oloc((H5D_t *)obj);
581
0
            break;
582
583
0
        case H5I_ATTR:
584
0
            oloc = H5A_oloc((H5A_t *)obj);
585
0
            break;
586
587
0
        case H5I_MAP:
588
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector");
589
590
0
        case H5I_UNINIT:
591
0
        case H5I_BADID:
592
0
        case H5I_DATASPACE:
593
0
        case H5I_VFL:
594
0
        case H5I_VOL:
595
0
        case H5I_GENPROP_CLS:
596
0
        case H5I_GENPROP_LST:
597
0
        case H5I_ERROR_CLASS:
598
0
        case H5I_ERROR_MSG:
599
0
        case H5I_ERROR_STACK:
600
0
        case H5I_SPACE_SEL_ITER:
601
0
        case H5I_EVENTSET:
602
0
        case H5I_NTYPES:
603
0
        default:
604
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object");
605
0
    } /* end switch */
606
607
    /* Set return value for objects (not files) */
608
0
    if (oloc)
609
0
        *file = oloc->file;
610
611
    /* Couldn't find a file struct */
612
0
    if (!*file)
613
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file");
614
615
0
done:
616
0
    FUNC_LEAVE_NOAPI(ret_value)
617
0
} /* H5VL_native_get_file_struct */