/** \page VFLTN HDF5 Virtual File Layer
Navigate back: \ref index "Main" / \ref TN
| Function |
Description |
static hsize_t sb_size (H5FD_t *file) |
The sb_size function returns the number of bytes necessary to encode
information needed later if the file is reopened. |
static herr_t sb_encode (H5FD_t *file, char *name, unsigned char *buf) |
The sb_encode function encodes information from the file into buffer buf
allocated by the caller. It also writes an 8-character (plus null termination) into
the name argument, which should be a unique identification for the driver. |
static herr_t sb_decode (H5FD_t *file, const char *name, const unsigned char *buf) |
The sb_decode function looks at the name decodes data from the buffer buf and
updates the file argument with the new information, advancing *p in the process. |
The part of this which is somewhat tricky is that the file must be readable before the
superblock information is decoded. File access modes fall outside the scope of the HDF5
file format, but they are placed inside the boot block for convenience.(File access modes
do not describe data, but rather describe how the HDF5 format address space is mapped to
the underlying file(s). Thus, in general the mapping must be known before the file
superblock can be read. However, the user usually knows enough about the mapping for
the superblock to be readable and once the superblock is read the library can fill
in the missing parts of the mapping.)
\section sec_vfl_address Address Space Functions
HDF5 does not assume that a file is a linear address space of bytes. Instead, the library
will call functions to allocate and free portions of the HDF5 format address space, which
in turn map onto functions in the file driver to allocate and free portions of file address
space. The library tells the file driver how much format address space it wants to allocate
and the driver decides what format address to use and how that format address is mapped
onto the file address space. Usually the format address is chosen so that the file address
can be calculated in constant time for data I/O operations (which are always specified by format addresses).
\subsection subsec_vfl_address_blk Userblock and Superblock
The HDF5 format allows an optional userblock to appear before the actual HDF5 data in such
a way that if the userblock is sucked out of the file and everything remaining is
shifted downward in the file address space, then the file is still a valid HDF5 file.
The userblock size can be zero or any multiple of two greater than or equal to 512 and
the file superblock begins immediately after the userblock.
HDF5 allocates space for the userblock and superblock by calling an allocation function
defined below, which must return a chunk of memory at format address zero on the first call.
\subsection subsec_vfl_address_alloc Allocatiion of Format Regions
The library makes many types of allocation requests:
const char *name |
A pointer to a constant, null-terminated driver name to be used for debugging purposes. |
size_t fapl_size |
The size in bytes of the file access mode structure or zero if the driver supplies a copy function
or doesn't define the structure. |
void *(*fapl_copy)(const void *fapl) |
An optional function which copies a driver-defined file access mode structure. This field takes
precedence over fm_size when both are defined. |
void (*fapl_free)(void *fapl) |
An optional function to free the driver-defined file access mode structure. If null, then the
library calls the C free function to free the structure. |
size_t dxpl_size |
The size in bytes of the data transfer mode structure or zero if the driver supplies a copy
function or doesn't define the structure. |
void *(*dxpl_copy)(const void *dxpl) |
An optional function which copies a driver-defined data transfer mode structure. This field
takes precedence over xm_size when both are defined. |
void (*dxpl_free)(void *dxpl) |
An optional function to free the driver-defined data transfer mode structure. If null, then
the library calls the C free function to free the structure. |
H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr) |
The function which opens or creates a new file. |
herr_t (*close)(H5FD_t *file) |
The function which ends access to a file. |
int (*cmp)(const H5FD_t *f1, const H5FD_t *f2) |
An optional function to determine whether two open files have the same key. If this function
is not present then the library assumes that two files will never be the same. |
int (*query)(const H5FD_t *f, unsigned long *flags) |
An optional function to determine which library optimizations a driver can support. |
haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hsize_t size) |
An optional function to allocate space in the file. |
herr_t (*free)(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) |
An optional function to free space in the file. |
haddr_t (*get_eoa)(H5FD_t *file) |
A function to query how much of the format address space has been allocated. |
herr_t (*set_eoa)(H5FD_t *file, haddr_t) |
A function to set the end of address space. |
haddr_t (*get_eof)(H5FD_t *file) |
A function to return the current end-of-file marker value. |
herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, hsize_t size, void *buffer) |
A function to read data from a file. |
herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, hsize_t size, const void *buffer) |
A function to write data to a file. |
herr_t (*flush)(H5FD_t *file) |
A function which flushes cached data to the file. |
H5FD_mem_t fl_map[H5FD_MEM_NTYPES] |
An array which maps a file allocation request type to a free list. |
Example: The sec2 driver would be registered as:
\code
static const H5FD_class_t H5FD_sec2_g = {
"sec2", /*name */
MAXADDR, /*maxaddr */
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
0, /*fapl_size */
NULL, /*fapl_get */
NULL, /*fapl_copy */
NULL, /*fapl_free */
0, /*dxpl_size */
NULL, /*dxpl_copy */
NULL, /*dxpl_free */
H5FD_sec2_open, /*open */
H5FD_sec2_close, /*close */
H5FD_sec2_cmp, /*cmp */
H5FD_sec2_query, /*query */
NULL, /*alloc */
NULL, /*free */
H5FD_sec2_get_eoa, /*get_eoa */
H5FD_sec2_set_eoa, /*set_eoa */
H5FD_sec2_get_eof, /*get_eof */
H5FD_sec2_read, /*read */
H5FD_sec2_write, /*write */
H5FD_sec2_flush, /*flush */
H5FD_FLMAP_SINGLE, /*fl_map */
};
hid_t
H5FD_sec2_init(void)
{
if (!H5FD_SEC2_g) {
H5FD_SEC2_g = H5FDregister(&H5FD_sec2_g);
}
return H5FD_SEC2_g;
}
\endcode
A driver can be removed from the library by unregistering it