Coverage Report

Created: 2024-06-18 06:29

/src/hdf5/src/H5FDsec2.c
Line
Count
Source (jump to first uncovered line)
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the COPYING 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 POSIX unbuffered file driver using only the HDF5 public
15
 *          API and with a few optimizations: the lseek() call is made
16
 *          only when the current file position is unknown or needs to be
17
 *          changed based on previous I/O through this driver (don't mix
18
 *          I/O from this driver with I/O from other parts of the
19
 *          application to the same file).
20
 */
21
22
#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */
23
24
#include "H5private.h"   /* Generic Functions        */
25
#include "H5Eprivate.h"  /* Error handling           */
26
#include "H5Fprivate.h"  /* File access              */
27
#include "H5FDprivate.h" /* File drivers             */
28
#include "H5FDsec2.h"    /* Sec2 file driver         */
29
#include "H5FLprivate.h" /* Free Lists               */
30
#include "H5Iprivate.h"  /* IDs                      */
31
#include "H5Pprivate.h"  /* Property lists           */
32
33
/* The driver identification number, initialized at runtime */
34
static hid_t H5FD_SEC2_g = 0;
35
36
/* Whether to ignore file locks when disabled (env var value) */
37
static htri_t ignore_disabled_file_locks_s = FAIL;
38
39
/* The description of a file belonging to this driver. The 'eoa' and 'eof'
40
 * determine the amount of hdf5 address space in use and the high-water mark
41
 * of the file (the current size of the underlying filesystem file). The
42
 * 'pos' value is used to eliminate file position updates when they would be a
43
 * no-op. Unfortunately we've found systems that use separate file position
44
 * indicators for reading and writing so the lseek can only be eliminated if
45
 * the current operation is the same as the previous operation.  When opening
46
 * a file the 'eof' will be set to the current file size, `eoa' will be set
47
 * to zero, 'pos' will be set to H5F_ADDR_UNDEF (as it is when an error
48
 * occurs), and 'op' will be set to H5F_OP_UNKNOWN.
49
 */
50
typedef struct H5FD_sec2_t {
51
    H5FD_t  pub; /* public stuff, must be first      */
52
    int     fd;  /* the filesystem file descriptor   */
53
    haddr_t eoa; /* end of allocated region          */
54
    haddr_t eof; /* end of file; current file size   */
55
#ifndef H5_HAVE_PREADWRITE
56
    haddr_t        pos; /* current file I/O position        */
57
    H5FD_file_op_t op;  /* last operation                   */
58
#endif                  /* H5_HAVE_PREADWRITE */
59
    bool ignore_disabled_file_locks;
60
    char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */
61
#ifndef H5_HAVE_WIN32_API
62
    /* On most systems the combination of device and i-node number uniquely
63
     * identify a file.  Note that Cygwin, MinGW and other Windows POSIX
64
     * environments have the stat function (which fakes inodes)
65
     * and will use the 'device + inodes' scheme as opposed to the
66
     * Windows code further below.
67
     */
68
    dev_t device; /* file device number   */
69
    ino_t inode;  /* file i-node number   */
70
#else
71
    /* Files in windows are uniquely identified by the volume serial
72
     * number and the file index (both low and high parts).
73
     *
74
     * There are caveats where these numbers can change, especially
75
     * on FAT file systems.  On NTFS, however, a file should keep
76
     * those numbers the same until renamed or deleted (though you
77
     * can use ReplaceFile() on NTFS to keep the numbers the same
78
     * while renaming).
79
     *
80
     * See the MSDN "BY_HANDLE_FILE_INFORMATION Structure" entry for
81
     * more information.
82
     *
83
     * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx
84
     */
85
    DWORD nFileIndexLow;
86
    DWORD nFileIndexHigh;
87
    DWORD dwVolumeSerialNumber;
88
89
    HANDLE hFile; /* Native windows file handle */
90
#endif /* H5_HAVE_WIN32_API */
91
92
    /* Information from properties set by 'h5repart' tool
93
     *
94
     * Whether to eliminate the family driver info and convert this file to
95
     * a single file.
96
     */
97
    bool fam_to_single;
98
} H5FD_sec2_t;
99
100
/*
101
 * These macros check for overflow of various quantities.  These macros
102
 * assume that HDoff_t is signed and haddr_t and size_t are unsigned.
103
 *
104
 * ADDR_OVERFLOW:   Checks whether a file address of type `haddr_t'
105
 *                  is too large to be represented by the second argument
106
 *                  of the file seek function.
107
 *
108
 * SIZE_OVERFLOW:   Checks whether a buffer size of type `hsize_t' is too
109
 *                  large to be represented by the `size_t' type.
110
 *
111
 * REGION_OVERFLOW: Checks whether an address and size pair describe data
112
 *                  which can be addressed entirely by the second
113
 *                  argument of the file seek function.
114
 */
115
446
#define MAXADDR          (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1)
116
446
#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR))
117
436
#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR)
118
#define REGION_OVERFLOW(A, Z)                                                                                \
119
218
    (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A))
120
121
/* Prototypes */
122
static herr_t  H5FD__sec2_term(void);
123
static H5FD_t *H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr);
124
static herr_t  H5FD__sec2_close(H5FD_t *_file);
125
static int     H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
126
static herr_t  H5FD__sec2_query(const H5FD_t *_f1, unsigned long *flags);
127
static haddr_t H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
128
static herr_t  H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
129
static haddr_t H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type);
130
static herr_t  H5FD__sec2_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle);
131
static herr_t  H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
132
                               void *buf);
133
static herr_t  H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
134
                                const void *buf);
135
static herr_t  H5FD__sec2_truncate(H5FD_t *_file, hid_t dxpl_id, bool closing);
136
static herr_t  H5FD__sec2_lock(H5FD_t *_file, bool rw);
137
static herr_t  H5FD__sec2_unlock(H5FD_t *_file);
138
static herr_t  H5FD__sec2_delete(const char *filename, hid_t fapl_id);
139
static herr_t  H5FD__sec2_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void *input,
140
                              void **output);
141
142
static const H5FD_class_t H5FD_sec2_g = {
143
    H5FD_CLASS_VERSION,    /* struct version       */
144
    H5FD_SEC2_VALUE,       /* value                */
145
    "sec2",                /* name                 */
146
    MAXADDR,               /* maxaddr              */
147
    H5F_CLOSE_WEAK,        /* fc_degree            */
148
    H5FD__sec2_term,       /* terminate            */
149
    NULL,                  /* sb_size              */
150
    NULL,                  /* sb_encode            */
151
    NULL,                  /* sb_decode            */
152
    0,                     /* fapl_size            */
153
    NULL,                  /* fapl_get             */
154
    NULL,                  /* fapl_copy            */
155
    NULL,                  /* fapl_free            */
156
    0,                     /* dxpl_size            */
157
    NULL,                  /* dxpl_copy            */
158
    NULL,                  /* dxpl_free            */
159
    H5FD__sec2_open,       /* open                 */
160
    H5FD__sec2_close,      /* close                */
161
    H5FD__sec2_cmp,        /* cmp                  */
162
    H5FD__sec2_query,      /* query                */
163
    NULL,                  /* get_type_map         */
164
    NULL,                  /* alloc                */
165
    NULL,                  /* free                 */
166
    H5FD__sec2_get_eoa,    /* get_eoa              */
167
    H5FD__sec2_set_eoa,    /* set_eoa              */
168
    H5FD__sec2_get_eof,    /* get_eof              */
169
    H5FD__sec2_get_handle, /* get_handle           */
170
    H5FD__sec2_read,       /* read                 */
171
    H5FD__sec2_write,      /* write                */
172
    NULL,                  /* read_vector          */
173
    NULL,                  /* write_vector         */
174
    NULL,                  /* read_selection       */
175
    NULL,                  /* write_selection      */
176
    NULL,                  /* flush                */
177
    H5FD__sec2_truncate,   /* truncate             */
178
    H5FD__sec2_lock,       /* lock                 */
179
    H5FD__sec2_unlock,     /* unlock               */
180
    H5FD__sec2_delete,     /* del                  */
181
    H5FD__sec2_ctl,        /* ctl                  */
182
    H5FD_FLMAP_DICHOTOMY   /* fl_map               */
183
};
184
185
/* Declare a free list to manage the H5FD_sec2_t struct */
186
H5FL_DEFINE_STATIC(H5FD_sec2_t);
187
188
/*-------------------------------------------------------------------------
189
 * Function:    H5FD_sec2_init
190
 *
191
 * Purpose:     Initialize this driver by registering the driver with the
192
 *              library.
193
 *
194
 * Return:      Success:    The driver ID for the sec2 driver
195
 *              Failure:    H5I_INVALID_HID
196
 *
197
 *-------------------------------------------------------------------------
198
 */
199
hid_t
200
H5FD_sec2_init(void)
201
2
{
202
2
    char *lock_env_var = NULL;            /* Environment variable pointer */
203
2
    hid_t ret_value    = H5I_INVALID_HID; /* Return value */
204
205
2
    FUNC_ENTER_NOAPI_NOERR
206
207
    /* Check the use disabled file locks environment variable */
208
2
    lock_env_var = getenv(HDF5_USE_FILE_LOCKING);
209
2
    if (lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT"))
210
0
        ignore_disabled_file_locks_s = true; /* Override: Ignore disabled locks */
211
2
    else if (lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1")))
212
0
        ignore_disabled_file_locks_s = false; /* Override: Don't ignore disabled locks */
213
2
    else
214
2
        ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */
215
216
2
    if (H5I_VFL != H5I_get_type(H5FD_SEC2_g))
217
1
        H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), false);
218
219
    /* Set return value */
220
2
    ret_value = H5FD_SEC2_g;
221
222
2
    FUNC_LEAVE_NOAPI(ret_value)
223
2
} /* end H5FD_sec2_init() */
224
225
/*---------------------------------------------------------------------------
226
 * Function:    H5FD__sec2_term
227
 *
228
 * Purpose:     Shut down the VFD
229
 *
230
 * Returns:     SUCCEED (Can't fail)
231
 *
232
 *---------------------------------------------------------------------------
233
 */
234
static herr_t
235
H5FD__sec2_term(void)
236
1
{
237
1
    FUNC_ENTER_PACKAGE_NOERR
238
239
    /* Reset VFL ID */
240
1
    H5FD_SEC2_g = 0;
241
242
1
    FUNC_LEAVE_NOAPI(SUCCEED)
243
1
} /* end H5FD__sec2_term() */
244
245
/*-------------------------------------------------------------------------
246
 * Function:    H5Pset_fapl_sec2
247
 *
248
 * Purpose:     Modify the file access property list to use the H5FD_SEC2
249
 *              driver defined in this source file.  There are no driver
250
 *              specific properties.
251
 *
252
 * Return:      SUCCEED/FAIL
253
 *
254
 *-------------------------------------------------------------------------
255
 */
256
herr_t
257
H5Pset_fapl_sec2(hid_t fapl_id)
258
0
{
259
0
    H5P_genplist_t *plist; /* Property list pointer */
260
0
    herr_t          ret_value;
261
262
0
    FUNC_ENTER_API(FAIL)
263
264
0
    if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
265
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
266
267
0
    ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL, NULL);
268
269
0
done:
270
0
    FUNC_LEAVE_API(ret_value)
271
0
} /* end H5Pset_fapl_sec2() */
272
273
/*-------------------------------------------------------------------------
274
 * Function:    H5FD__sec2_open
275
 *
276
 * Purpose:     Create and/or opens a file as an HDF5 file.
277
 *
278
 * Return:      Success:    A pointer to a new file data structure. The
279
 *                          public fields will be initialized by the
280
 *                          caller, which is always H5FD_open().
281
 *              Failure:    NULL
282
 *
283
 *-------------------------------------------------------------------------
284
 */
285
static H5FD_t *
286
H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
287
10
{
288
10
    H5FD_sec2_t *file = NULL; /* sec2 VFD info            */
289
10
    int          fd   = -1;   /* File descriptor          */
290
10
    int          o_flags;     /* Flags for open() call    */
291
#ifdef H5_HAVE_WIN32_API
292
    struct _BY_HANDLE_FILE_INFORMATION fileinfo;
293
#endif
294
10
    h5_stat_t       sb;
295
10
    H5P_genplist_t *plist;            /* Property list pointer */
296
10
    H5FD_t         *ret_value = NULL; /* Return value */
297
298
10
    FUNC_ENTER_PACKAGE
299
300
    /* Sanity check on file offsets */
301
10
    HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t));
302
303
    /* Check arguments */
304
10
    if (!name || !*name)
305
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
306
10
    if (0 == maxaddr || HADDR_UNDEF == maxaddr)
307
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
308
10
    if (ADDR_OVERFLOW(maxaddr))
309
0
        HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
310
311
    /* Build the open flags */
312
10
    o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
313
10
    if (H5F_ACC_TRUNC & flags)
314
0
        o_flags |= O_TRUNC;
315
10
    if (H5F_ACC_CREAT & flags)
316
0
        o_flags |= O_CREAT;
317
10
    if (H5F_ACC_EXCL & flags)
318
0
        o_flags |= O_EXCL;
319
320
    /* Open the file */
321
10
    if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) {
322
0
        int myerrno = errno;
323
0
        HGOTO_ERROR(
324
0
            H5E_FILE, H5E_CANTOPENFILE, NULL,
325
0
            "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x",
326
0
            name, myerrno, strerror(myerrno), flags, (unsigned)o_flags);
327
0
    } /* end if */
328
329
10
    memset(&sb, 0, sizeof(h5_stat_t));
330
10
    if (HDfstat(fd, &sb) < 0)
331
10
        HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file");
332
333
    /* Create the new file struct */
334
10
    if (NULL == (file = H5FL_CALLOC(H5FD_sec2_t)))
335
0
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
336
337
10
    file->fd = fd;
338
10
    H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t);
339
#ifndef H5_HAVE_PREADWRITE
340
    file->pos = HADDR_UNDEF;
341
    file->op  = OP_UNKNOWN;
342
#endif /* H5_HAVE_PREADWRITE */
343
#ifdef H5_HAVE_WIN32_API
344
    file->hFile = (HANDLE)_get_osfhandle(fd);
345
    if (INVALID_HANDLE_VALUE == file->hFile)
346
        HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle");
347
348
    if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo))
349
        HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information");
350
351
    file->nFileIndexHigh       = fileinfo.nFileIndexHigh;
352
    file->nFileIndexLow        = fileinfo.nFileIndexLow;
353
    file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber;
354
#else  /* H5_HAVE_WIN32_API */
355
10
    file->device = sb.st_dev;
356
10
    file->inode  = sb.st_ino;
357
10
#endif /* H5_HAVE_WIN32_API */
358
359
    /* Get the FAPL */
360
10
    if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
361
0
        HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "not a file access property list");
362
363
    /* Check the file locking flags in the fapl */
364
10
    if (ignore_disabled_file_locks_s != FAIL)
365
        /* The environment variable was set, so use that preferentially */
366
0
        file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
367
10
    else {
368
        /* Use the value in the property list */
369
10
        if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0)
370
0
            HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property");
371
10
    }
372
373
    /* Retain a copy of the name used to open the file, for possible error reporting */
374
10
    strncpy(file->filename, name, sizeof(file->filename) - 1);
375
10
    file->filename[sizeof(file->filename) - 1] = '\0';
376
377
    /* Check for non-default FAPL */
378
10
    if (H5P_FILE_ACCESS_DEFAULT != fapl_id) {
379
380
        /* This step is for h5repart tool only. If user wants to change file driver from
381
         * family to one that uses single files (sec2, etc.) while using h5repart, this
382
         * private property should be set so that in the later step, the library can ignore
383
         * the family driver information saved in the superblock.
384
         */
385
0
        if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0)
386
0
            if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0)
387
0
                HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single");
388
0
    } /* end if */
389
390
    /* Set return value */
391
10
    ret_value = (H5FD_t *)file;
392
393
10
done:
394
10
    if (NULL == ret_value) {
395
0
        if (fd >= 0)
396
0
            HDclose(fd);
397
0
        if (file)
398
0
            file = H5FL_FREE(H5FD_sec2_t, file);
399
0
    } /* end if */
400
401
10
    FUNC_LEAVE_NOAPI(ret_value)
402
10
} /* end H5FD__sec2_open() */
403
404
/*-------------------------------------------------------------------------
405
 * Function:    H5FD__sec2_close
406
 *
407
 * Purpose:     Closes an HDF5 file.
408
 *
409
 * Return:      Success:    SUCCEED
410
 *              Failure:    FAIL, file not closed.
411
 *
412
 *-------------------------------------------------------------------------
413
 */
414
static herr_t
415
H5FD__sec2_close(H5FD_t *_file)
416
10
{
417
10
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file;
418
10
    herr_t       ret_value = SUCCEED; /* Return value */
419
420
10
    FUNC_ENTER_PACKAGE
421
422
    /* Sanity check */
423
10
    assert(file);
424
425
    /* Close the underlying file */
426
10
    if (HDclose(file->fd) < 0)
427
10
        HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
428
429
    /* Release the file info */
430
10
    file = H5FL_FREE(H5FD_sec2_t, file);
431
432
10
done:
433
10
    FUNC_LEAVE_NOAPI(ret_value)
434
10
} /* end H5FD__sec2_close() */
435
436
/*-------------------------------------------------------------------------
437
 * Function:    H5FD__sec2_cmp
438
 *
439
 * Purpose:     Compares two files belonging to this driver using an
440
 *              arbitrary (but consistent) ordering.
441
 *
442
 * Return:      Success:    A value like strcmp()
443
 *              Failure:    never fails (arguments were checked by the
444
 *                          caller).
445
 *
446
 *-------------------------------------------------------------------------
447
 */
448
static int
449
H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
450
0
{
451
0
    const H5FD_sec2_t *f1        = (const H5FD_sec2_t *)_f1;
452
0
    const H5FD_sec2_t *f2        = (const H5FD_sec2_t *)_f2;
453
0
    int                ret_value = 0;
454
455
0
    FUNC_ENTER_PACKAGE_NOERR
456
457
#ifdef H5_HAVE_WIN32_API
458
    if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber)
459
        HGOTO_DONE(-1);
460
    if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber)
461
        HGOTO_DONE(1);
462
463
    if (f1->nFileIndexHigh < f2->nFileIndexHigh)
464
        HGOTO_DONE(-1);
465
    if (f1->nFileIndexHigh > f2->nFileIndexHigh)
466
        HGOTO_DONE(1);
467
468
    if (f1->nFileIndexLow < f2->nFileIndexLow)
469
        HGOTO_DONE(-1);
470
    if (f1->nFileIndexLow > f2->nFileIndexLow)
471
        HGOTO_DONE(1);
472
#else /* H5_HAVE_WIN32_API */
473
0
#ifdef H5_DEV_T_IS_SCALAR
474
0
    if (f1->device < f2->device)
475
0
        HGOTO_DONE(-1);
476
0
    if (f1->device > f2->device)
477
0
        HGOTO_DONE(1);
478
#else  /* H5_DEV_T_IS_SCALAR */
479
    /* If dev_t isn't a scalar value on this system, just use memcmp to
480
     * determine if the values are the same or not.  The actual return value
481
     * shouldn't really matter...
482
     */
483
    if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0)
484
        HGOTO_DONE(-1);
485
    if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0)
486
        HGOTO_DONE(1);
487
#endif /* H5_DEV_T_IS_SCALAR */
488
0
    if (f1->inode < f2->inode)
489
0
        HGOTO_DONE(-1);
490
0
    if (f1->inode > f2->inode)
491
0
        HGOTO_DONE(1);
492
0
#endif /* H5_HAVE_WIN32_API */
493
494
0
done:
495
0
    FUNC_LEAVE_NOAPI(ret_value)
496
0
} /* end H5FD__sec2_cmp() */
497
498
/*-------------------------------------------------------------------------
499
 * Function:    H5FD__sec2_query
500
 *
501
 * Purpose:     Set the flags that this VFL driver is capable of supporting.
502
 *              (listed in H5FDpublic.h)
503
 *
504
 * Return:      SUCCEED (Can't fail)
505
 *
506
 *-------------------------------------------------------------------------
507
 */
508
static herr_t
509
H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */)
510
20
{
511
20
    const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */
512
513
20
    FUNC_ENTER_PACKAGE_NOERR
514
515
    /* Set the VFL feature flags that this driver supports */
516
    /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as
517
     * the underlying driver -- as such, the Mirror VFD implementation copies
518
     * these feature flags as its own. Any modifications made here must be
519
     * reflected in H5FDmirror.c
520
     * -- JOS 2020-01-13
521
     */
522
20
    if (flags) {
523
20
        *flags = 0;
524
20
        *flags |= H5FD_FEAT_AGGREGATE_METADATA;  /* OK to aggregate metadata allocations  */
525
20
        *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
526
20
        *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes    */
527
20
        *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
528
20
        *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */
529
20
        *flags |=
530
20
            H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern   */
531
20
        *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default
532
                                                       VFD      */
533
534
        /* Check for flags that are set by h5repart */
535
20
        if (file && file->fam_to_single)
536
0
            *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which
537
                                                    eliminates it) */
538
20
    }                                            /* end if */
539
540
20
    FUNC_LEAVE_NOAPI(SUCCEED)
541
20
} /* end H5FD__sec2_query() */
542
543
/*-------------------------------------------------------------------------
544
 * Function:    H5FD__sec2_get_eoa
545
 *
546
 * Purpose:     Gets the end-of-address marker for the file. The EOA marker
547
 *              is the first address past the last byte allocated in the
548
 *              format address space.
549
 *
550
 * Return:      The end-of-address marker.
551
 *
552
 *-------------------------------------------------------------------------
553
 */
554
static haddr_t
555
H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type)
556
432
{
557
432
    const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file;
558
559
432
    FUNC_ENTER_PACKAGE_NOERR
560
561
432
    FUNC_LEAVE_NOAPI(file->eoa)
562
432
} /* end H5FD__sec2_get_eoa() */
563
564
/*-------------------------------------------------------------------------
565
 * Function:    H5FD__sec2_set_eoa
566
 *
567
 * Purpose:     Set the end-of-address marker for the file. This function is
568
 *              called shortly after an existing HDF5 file is opened in order
569
 *              to tell the driver where the end of the HDF5 data is located.
570
 *
571
 * Return:      SUCCEED (Can't fail)
572
 *
573
 *-------------------------------------------------------------------------
574
 */
575
static herr_t
576
H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr)
577
72
{
578
72
    H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
579
580
72
    FUNC_ENTER_PACKAGE_NOERR
581
582
72
    file->eoa = addr;
583
584
72
    FUNC_LEAVE_NOAPI(SUCCEED)
585
72
} /* end H5FD__sec2_set_eoa() */
586
587
/*-------------------------------------------------------------------------
588
 * Function:    H5FD__sec2_get_eof
589
 *
590
 * Purpose:     Returns the end-of-file marker, which is the greater of
591
 *              either the filesystem end-of-file or the HDF5 end-of-address
592
 *              markers.
593
 *
594
 * Return:      End of file address, the first address past the end of the
595
 *              "file", either the filesystem file or the HDF5 file.
596
 *
597
 *-------------------------------------------------------------------------
598
 */
599
static haddr_t
600
H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type)
601
37
{
602
37
    const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file;
603
604
37
    FUNC_ENTER_PACKAGE_NOERR
605
606
37
    FUNC_LEAVE_NOAPI(file->eof)
607
37
} /* end H5FD__sec2_get_eof() */
608
609
/*-------------------------------------------------------------------------
610
 * Function:       H5FD__sec2_get_handle
611
 *
612
 * Purpose:        Returns the file handle of sec2 file driver.
613
 *
614
 * Returns:        SUCCEED/FAIL
615
 *
616
 *-------------------------------------------------------------------------
617
 */
618
static herr_t
619
H5FD__sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle)
620
0
{
621
0
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file;
622
0
    herr_t       ret_value = SUCCEED;
623
624
0
    FUNC_ENTER_PACKAGE
625
626
0
    if (!file_handle)
627
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid");
628
629
0
    *file_handle = &(file->fd);
630
631
0
done:
632
0
    FUNC_LEAVE_NOAPI(ret_value)
633
0
} /* end H5FD__sec2_get_handle() */
634
635
/*-------------------------------------------------------------------------
636
 * Function:    H5FD__sec2_read
637
 *
638
 * Purpose:     Reads SIZE bytes of data from FILE beginning at address ADDR
639
 *              into buffer BUF according to data transfer properties in
640
 *              DXPL_ID.
641
 *
642
 * Return:      Success:    SUCCEED. Result is stored in caller-supplied
643
 *                          buffer BUF.
644
 *              Failure:    FAIL, Contents of buffer BUF are undefined.
645
 *
646
 *-------------------------------------------------------------------------
647
 */
648
static herr_t
649
H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr,
650
                size_t size, void *buf /*out*/)
651
218
{
652
218
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file;
653
218
    HDoff_t      offset    = (HDoff_t)addr;
654
218
    herr_t       ret_value = SUCCEED; /* Return value */
655
656
218
    FUNC_ENTER_PACKAGE
657
658
218
    assert(file && file->pub.cls);
659
218
    assert(buf);
660
661
    /* Check for overflow conditions */
662
218
    if (!H5_addr_defined(addr))
663
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr);
664
218
    if (REGION_OVERFLOW(addr, size))
665
0
        HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr);
666
667
#ifndef H5_HAVE_PREADWRITE
668
    /* Seek to the correct location (if we don't have pread) */
669
    if (addr != file->pos || OP_READ != file->op)
670
        if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
671
            HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
672
#endif /* H5_HAVE_PREADWRITE */
673
674
    /* Read data, being careful of interrupted system calls, partial results,
675
     * and the end of the file.
676
     */
677
435
    while (size > 0) {
678
218
        h5_posix_io_t     bytes_in   = 0;  /* # of bytes to read       */
679
218
        h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
680
681
        /* Trying to read more bytes than the return type can handle is
682
         * undefined behavior in POSIX.
683
         */
684
218
        if (size > H5_POSIX_MAX_IO_BYTES)
685
0
            bytes_in = H5_POSIX_MAX_IO_BYTES;
686
218
        else
687
218
            bytes_in = (h5_posix_io_t)size;
688
689
218
        do {
690
218
#ifdef H5_HAVE_PREADWRITE
691
218
            bytes_read = HDpread(file->fd, buf, bytes_in, offset);
692
218
            if (bytes_read > 0)
693
217
                offset += bytes_read;
694
#else
695
            bytes_read  = HDread(file->fd, buf, bytes_in);
696
#endif /* H5_HAVE_PREADWRITE */
697
218
        } while (-1 == bytes_read && EINTR == errno);
698
699
218
        if (-1 == bytes_read) { /* error */
700
0
            int    myerrno = errno;
701
0
            time_t mytime  = time(NULL);
702
703
0
            offset = HDlseek(file->fd, 0, SEEK_CUR);
704
705
0
            HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
706
0
                        "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
707
0
                        "error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, "
708
0
                        "bytes actually read = %llu, offset = %llu",
709
0
                        ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
710
0
                        (unsigned long long)size, (unsigned long long)bytes_in,
711
0
                        (unsigned long long)bytes_read, (unsigned long long)offset);
712
0
        } /* end if */
713
714
218
        if (0 == bytes_read) {
715
            /* end of file but not end of format address space */
716
1
            memset(buf, 0, size);
717
1
            break;
718
1
        } /* end if */
719
720
217
        assert(bytes_read >= 0);
721
217
        assert((size_t)bytes_read <= size);
722
723
217
        size -= (size_t)bytes_read;
724
217
        addr += (haddr_t)bytes_read;
725
217
        buf = (char *)buf + bytes_read;
726
217
    } /* end while */
727
728
#ifndef H5_HAVE_PREADWRITE
729
    /* Update current position */
730
    file->pos = addr;
731
    file->op  = OP_READ;
732
#endif /* H5_HAVE_PREADWRITE */
733
734
218
done:
735
#ifndef H5_HAVE_PREADWRITE
736
    if (ret_value < 0) {
737
        /* Reset last file I/O information */
738
        file->pos = HADDR_UNDEF;
739
        file->op  = OP_UNKNOWN;
740
    }  /* end if */
741
#endif /* H5_HAVE_PREADWRITE */
742
743
218
    FUNC_LEAVE_NOAPI(ret_value)
744
218
} /* end H5FD__sec2_read() */
745
746
/*-------------------------------------------------------------------------
747
 * Function:    H5FD__sec2_write
748
 *
749
 * Purpose:     Writes SIZE bytes of data to FILE beginning at address ADDR
750
 *              from buffer BUF according to data transfer properties in
751
 *              DXPL_ID.
752
 *
753
 * Return:      SUCCEED/FAIL
754
 *
755
 *-------------------------------------------------------------------------
756
 */
757
static herr_t
758
H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr,
759
                 size_t size, const void *buf)
760
0
{
761
0
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file;
762
0
    HDoff_t      offset    = (HDoff_t)addr;
763
0
    herr_t       ret_value = SUCCEED; /* Return value */
764
765
0
    FUNC_ENTER_PACKAGE
766
767
0
    assert(file && file->pub.cls);
768
0
    assert(buf);
769
770
    /* Check for overflow conditions */
771
0
    if (!H5_addr_defined(addr))
772
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr);
773
0
    if (REGION_OVERFLOW(addr, size))
774
0
        HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu",
775
0
                    (unsigned long long)addr, (unsigned long long)size);
776
777
#ifndef H5_HAVE_PREADWRITE
778
    /* Seek to the correct location (if we don't have pwrite) */
779
    if (addr != file->pos || OP_WRITE != file->op)
780
        if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
781
            HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
782
#endif /* H5_HAVE_PREADWRITE */
783
784
    /* Write the data, being careful of interrupted system calls and partial
785
     * results
786
     */
787
0
    while (size > 0) {
788
0
        h5_posix_io_t     bytes_in    = 0;  /* # of bytes to write  */
789
0
        h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written   */
790
791
        /* Trying to write more bytes than the return type can handle is
792
         * undefined behavior in POSIX.
793
         */
794
0
        if (size > H5_POSIX_MAX_IO_BYTES)
795
0
            bytes_in = H5_POSIX_MAX_IO_BYTES;
796
0
        else
797
0
            bytes_in = (h5_posix_io_t)size;
798
799
0
        do {
800
0
#ifdef H5_HAVE_PREADWRITE
801
0
            bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
802
0
            if (bytes_wrote > 0)
803
0
                offset += bytes_wrote;
804
#else
805
            bytes_wrote = HDwrite(file->fd, buf, bytes_in);
806
#endif /* H5_HAVE_PREADWRITE */
807
0
        } while (-1 == bytes_wrote && EINTR == errno);
808
809
0
        if (-1 == bytes_wrote) { /* error */
810
0
            int    myerrno = errno;
811
0
            time_t mytime  = time(NULL);
812
813
0
            offset = HDlseek(file->fd, 0, SEEK_CUR);
814
815
0
            HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
816
0
                        "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
817
0
                        "error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = "
818
0
                        "%llu, bytes actually written = %llu, offset = %llu",
819
0
                        ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
820
0
                        (unsigned long long)size, (unsigned long long)bytes_in,
821
0
                        (unsigned long long)bytes_wrote, (unsigned long long)offset);
822
0
        } /* end if */
823
824
0
        assert(bytes_wrote > 0);
825
0
        assert((size_t)bytes_wrote <= size);
826
827
0
        size -= (size_t)bytes_wrote;
828
0
        addr += (haddr_t)bytes_wrote;
829
0
        buf = (const char *)buf + bytes_wrote;
830
0
    } /* end while */
831
832
    /* Update current position and eof */
833
#ifndef H5_HAVE_PREADWRITE
834
    file->pos = addr;
835
    file->op  = OP_WRITE;
836
#endif /* H5_HAVE_PREADWRITE */
837
0
    if (addr > file->eof)
838
0
        file->eof = addr;
839
840
0
done:
841
#ifndef H5_HAVE_PREADWRITE
842
    if (ret_value < 0) {
843
        /* Reset last file I/O information */
844
        file->pos = HADDR_UNDEF;
845
        file->op  = OP_UNKNOWN;
846
    }  /* end if */
847
#endif /* H5_HAVE_PREADWRITE */
848
849
0
    FUNC_LEAVE_NOAPI(ret_value)
850
0
} /* end H5FD__sec2_write() */
851
852
/*-------------------------------------------------------------------------
853
 * Function:    H5FD__sec2_truncate
854
 *
855
 * Purpose:     Makes sure that the true file size is the same (or larger)
856
 *              than the end-of-address.
857
 *
858
 * Return:      SUCCEED/FAIL
859
 *
860
 *-------------------------------------------------------------------------
861
 */
862
static herr_t
863
H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, bool H5_ATTR_UNUSED closing)
864
0
{
865
0
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file;
866
0
    herr_t       ret_value = SUCCEED; /* Return value */
867
868
0
    FUNC_ENTER_PACKAGE
869
870
0
    assert(file);
871
872
    /* Extend the file to make sure it's large enough */
873
0
    if (!H5_addr_eq(file->eoa, file->eof)) {
874
#ifdef H5_HAVE_WIN32_API
875
        LARGE_INTEGER li;       /* 64-bit (union) integer for SetFilePointer() call */
876
        DWORD         dwPtrLow; /* Low-order pointer bits from SetFilePointer()
877
                                 * Only used as an error code here.
878
                                 */
879
        DWORD dwError;          /* DWORD error code from GetLastError() */
880
        BOOL  bError;           /* Boolean error flag */
881
882
        /* Windows uses this odd QuadPart union for 32/64-bit portability */
883
        li.QuadPart = (LONGLONG)file->eoa;
884
885
        /* Extend the file to make sure it's large enough.
886
         *
887
         * Since INVALID_SET_FILE_POINTER can technically be a valid return value
888
         * from SetFilePointer(), we also need to check GetLastError().
889
         */
890
        dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN);
891
        if (INVALID_SET_FILE_POINTER == dwPtrLow) {
892
            dwError = GetLastError();
893
            if (dwError != NO_ERROR)
894
                HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer");
895
        }
896
897
        bError = SetEndOfFile(file->hFile);
898
        if (0 == bError)
899
            HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
900
#else  /* H5_HAVE_WIN32_API */
901
0
        if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa))
902
0
            HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
903
0
#endif /* H5_HAVE_WIN32_API */
904
905
        /* Update the eof value */
906
0
        file->eof = file->eoa;
907
908
#ifndef H5_HAVE_PREADWRITE
909
        /* Reset last file I/O information */
910
        file->pos = HADDR_UNDEF;
911
        file->op  = OP_UNKNOWN;
912
#endif /* H5_HAVE_PREADWRITE */
913
0
    }  /* end if */
914
915
0
done:
916
0
    FUNC_LEAVE_NOAPI(ret_value)
917
0
} /* end H5FD__sec2_truncate() */
918
919
/*-------------------------------------------------------------------------
920
 * Function:    H5FD__sec2_lock
921
 *
922
 * Purpose:     To place an advisory lock on a file.
923
 *    The lock type to apply depends on the parameter "rw":
924
 *      true--opens for write: an exclusive lock
925
 *      false--opens for read: a shared lock
926
 *
927
 * Return:      SUCCEED/FAIL
928
 *
929
 *-------------------------------------------------------------------------
930
 */
931
static herr_t
932
H5FD__sec2_lock(H5FD_t *_file, bool rw)
933
10
{
934
10
    H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct          */
935
10
    int          lock_flags;                  /* file locking flags       */
936
10
    herr_t       ret_value = SUCCEED;         /* Return value             */
937
938
10
    FUNC_ENTER_PACKAGE
939
940
10
    assert(file);
941
942
    /* Set exclusive or shared lock based on rw status */
943
10
    lock_flags = rw ? LOCK_EX : LOCK_SH;
944
945
    /* Place a non-blocking lock on the file */
946
10
    if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) {
947
0
        if (file->ignore_disabled_file_locks && ENOSYS == errno) {
948
            /* When errno is set to ENOSYS, the file system does not support
949
             * locking, so ignore it.
950
             */
951
0
            errno = 0;
952
0
        }
953
0
        else
954
0
            HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock file");
955
0
    }
956
957
10
done:
958
10
    FUNC_LEAVE_NOAPI(ret_value)
959
10
} /* end H5FD__sec2_lock() */
960
961
/*-------------------------------------------------------------------------
962
 * Function:    H5FD__sec2_unlock
963
 *
964
 * Purpose:     To remove the existing lock on the file
965
 *
966
 * Return:      SUCCEED/FAIL
967
 *
968
 *-------------------------------------------------------------------------
969
 */
970
static herr_t
971
H5FD__sec2_unlock(H5FD_t *_file)
972
0
{
973
0
    H5FD_sec2_t *file      = (H5FD_sec2_t *)_file; /* VFD file struct          */
974
0
    herr_t       ret_value = SUCCEED;              /* Return value             */
975
976
0
    FUNC_ENTER_PACKAGE
977
978
0
    assert(file);
979
980
0
    if (HDflock(file->fd, LOCK_UN) < 0) {
981
0
        if (file->ignore_disabled_file_locks && ENOSYS == errno) {
982
            /* When errno is set to ENOSYS, the file system does not support
983
             * locking, so ignore it.
984
             */
985
0
            errno = 0;
986
0
        }
987
0
        else
988
0
            HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock file");
989
0
    }
990
991
0
done:
992
0
    FUNC_LEAVE_NOAPI(ret_value)
993
0
} /* end H5FD__sec2_unlock() */
994
995
/*-------------------------------------------------------------------------
996
 * Function:    H5FD__sec2_delete
997
 *
998
 * Purpose:     Delete a file
999
 *
1000
 * Return:      SUCCEED/FAIL
1001
 *
1002
 *-------------------------------------------------------------------------
1003
 */
1004
static herr_t
1005
H5FD__sec2_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
1006
0
{
1007
0
    herr_t ret_value = SUCCEED; /* Return value */
1008
1009
0
    FUNC_ENTER_PACKAGE
1010
1011
0
    assert(filename);
1012
1013
0
    if (HDremove(filename) < 0)
1014
0
        HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file");
1015
1016
0
done:
1017
0
    FUNC_LEAVE_NOAPI(ret_value)
1018
0
} /* end H5FD__sec2_delete() */
1019
1020
/*-------------------------------------------------------------------------
1021
 * Function:    H5FD__sec2_ctl
1022
 *
1023
 * Purpose:     Sec2 VFD version of the ctl callback.
1024
 *
1025
 *              The desired operation is specified by the op_code
1026
 *              parameter.
1027
 *
1028
 *              The flags parameter controls management of op_codes that
1029
 *              are unknown to the callback
1030
 *
1031
 *              The input and output parameters allow op_code specific
1032
 *              input and output
1033
 *
1034
 *              At present, no op codes are supported by this VFD.
1035
 *
1036
 * Return:      Non-negative on success/Negative on failure
1037
 *
1038
 *-------------------------------------------------------------------------
1039
 */
1040
static herr_t
1041
H5FD__sec2_ctl(H5FD_t H5_ATTR_UNUSED *_file, uint64_t H5_ATTR_UNUSED op_code, uint64_t flags,
1042
               const void H5_ATTR_UNUSED *input, void H5_ATTR_UNUSED **output)
1043
0
{
1044
0
    herr_t ret_value = SUCCEED;
1045
1046
0
    FUNC_ENTER_PACKAGE
1047
1048
    /* No op codes are understood. */
1049
0
    if (flags & H5FD_CTL_FAIL_IF_UNKNOWN_FLAG)
1050
0
        HGOTO_ERROR(H5E_VFL, H5E_FCNTL, FAIL, "unknown op_code and fail if unknown flag is set");
1051
1052
0
done:
1053
0
    FUNC_LEAVE_NOAPI(ret_value)
1054
0
} /* end H5FD__sec2_ctl() */