diff options
-rw-r--r-- | MANIFEST | 2 | ||||
-rw-r--r-- | src/H5FD.c | 44 | ||||
-rw-r--r-- | src/H5FDcore.c | 1 | ||||
-rw-r--r-- | src/H5FDdirect.c | 1 | ||||
-rw-r--r-- | src/H5FDfamily.c | 33 | ||||
-rw-r--r-- | src/H5FDlog.c | 1 | ||||
-rw-r--r-- | src/H5FDmpio.c | 1 | ||||
-rw-r--r-- | src/H5FDmpiposix.c | 1 | ||||
-rw-r--r-- | src/H5FDmulti.c | 30 | ||||
-rw-r--r-- | src/H5FDnull.c | 1330 | ||||
-rw-r--r-- | src/H5FDnull.h | 41 | ||||
-rw-r--r-- | src/H5FDprivate.h | 5 | ||||
-rw-r--r-- | src/H5FDpublic.h | 1 | ||||
-rw-r--r-- | src/H5FDsec2.c | 1 | ||||
-rw-r--r-- | src/H5FDstdio.c | 1 | ||||
-rw-r--r-- | src/H5Fsuper_cache.c | 25 | ||||
-rwxr-xr-x | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/Makefile.in | 15 | ||||
-rw-r--r-- | src/hdf5.h | 1 | ||||
-rw-r--r-- | test/vfd.c | 231 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_466.txt | 5 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_467.txt | 3 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_468.txt | 5 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_469.txt | 3 | ||||
-rw-r--r-- | tools/testfiles/tmultifile.ddl | 42 | ||||
-rw-r--r-- | tools/testfiles/tmultifile.ls | 6 | ||||
-rw-r--r-- | tools/testfiles/tqmarkfile.ddl | 83 | ||||
-rw-r--r-- | tools/testfiles/tslink-D.ddl | 30 | ||||
-rw-r--r-- | tools/testfiles/tstarfile.ddl | 89 |
29 files changed, 1743 insertions, 294 deletions
@@ -677,6 +677,8 @@ ./src/H5FDmpiposix.h ./src/H5FDmulti.c ./src/H5FDmulti.h +./src/H5FDnull.c +./src/H5FDnull.h ./src/H5FDpkg.h ./src/H5FDprivate.h ./src/H5FDpublic.h @@ -559,6 +559,50 @@ done: /*------------------------------------------------------------------------- + * Function: H5FD_sb_verify + * + * Purpose: Verify that the driver is compatable with the driver + * that created the file. During file creation, drivers that + * modify the HDF5 file structure when interacting with the + * filesystem identify themselves in the file superblock. + * When the file is reopened, the opening driver must verify + * that it can reconstruct a logical HDF5 file from the + * modified structure in the filesystem. + * + * Return: Success: TRUE if the driver is compatable, else FALSE + * Failure: Negative + * + * Programmer: Jacob Gruber + * Friday, January 13, 2012 + * + *------------------------------------------------------------------------- + */ +htri_t +H5FD_sb_verify(H5FD_t *file, const char *sb_driver_id) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file && file->cls); + + /* Delegate to the driver if possible. If driver doesn't implement + * an sb_verify callback, the default return valyue is used, + * indicating incompatablility. + */ + if(file->cls->sb_verify) { + ret_value = (file->cls->sb_verify)(file, sb_driver_id); + if(ret_value < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_verify request failed") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_sb_verify() */ + + + +/*------------------------------------------------------------------------- * Function: H5FD_pl_copy * * Purpose: Copies the driver-specific part of the a property list. diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 64cb1bb..cced540 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -137,6 +137,7 @@ static const H5FD_class_t H5FD_core_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ sizeof(H5FD_core_fapl_t), /*fapl_size */ H5FD_core_fapl_get, /*fapl_get */ NULL, /*fapl_copy */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 218a1dd..fb4099a 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -181,6 +181,7 @@ static const H5FD_class_t H5FD_direct_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ sizeof(H5FD_direct_fapl_t), /*fapl_size */ H5FD_direct_fapl_get, /*fapl_get */ H5FD_direct_fapl_copy, /*fapl_copy */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 17683ce..f38ec86 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -99,6 +99,7 @@ static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/); static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static htri_t H5FD_family_sb_verify(H5FD_t *_file, const char *driver_id); static H5FD_t *H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_family_close(H5FD_t *_file); @@ -124,6 +125,7 @@ static const H5FD_class_t H5FD_family_g = { H5FD_family_sb_size, /*sb_size */ H5FD_family_sb_encode, /*sb_encode */ H5FD_family_sb_decode, /*sb_decode */ + H5FD_family_sb_verify, /*sb_verify */ sizeof(H5FD_family_fapl_t), /*fapl_size */ H5FD_family_fapl_get, /*fapl_get */ H5FD_family_fapl_copy, /*fapl_copy */ @@ -701,6 +703,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5FD_family_sb_verify + * + * Purpose: Verify that the family driver is compatable with the driver + * that created the file. + * + * Return: Success: TRUE if the driver is compatible, esle FALSE + * Failure: Negative + * + * Programmer: Jacob Gruber + * Friday, January 13, 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5FD_family_sb_verify(H5FD_t UNUSED *_file, const char *sb_driver_id) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check if the suerblock was written by a family driver. */ + if(HDstrncmp(sb_driver_id, "NCSAfami", (size_t)8) == 0) { + ret_value = TRUE; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_family_sb_verify() */ + + +/*------------------------------------------------------------------------- * Function: H5FD_family_open * * Purpose: Creates and/or opens a family of files as an HDF5 file. diff --git a/src/H5FDlog.c b/src/H5FDlog.c index cb5ce3c..db5c8c7 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -209,6 +209,7 @@ static const H5FD_class_t H5FD_log_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ sizeof(H5FD_log_fapl_t), /*fapl_size */ H5FD_log_fapl_get, /*fapl_get */ H5FD_log_fapl_copy, /*fapl_copy */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 6dbe831..d4fdd4d 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -103,6 +103,7 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ sizeof(H5FD_mpio_fapl_t), /*fapl_size */ H5FD_mpio_fapl_get, /*fapl_get */ H5FD_mpio_fapl_copy, /*fapl_copy */ diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index e6c23f0..7fa4d7f 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -212,6 +212,7 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ sizeof(H5FD_mpiposix_fapl_t), /*fapl_size */ H5FD_mpiposix_fapl_get, /*fapl_get */ H5FD_mpiposix_fapl_copy, /*fapl_copy */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 5751596..6e0df1b 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -123,6 +123,7 @@ static herr_t H5FD_multi_sb_encode(H5FD_t *file, char *name/*out*/, unsigned char *buf/*out*/); static herr_t H5FD_multi_sb_decode(H5FD_t *file, const char *name, const unsigned char *buf); +static htri_t H5FD_multi_sb_verify(H5FD_t *file, const char *driver_id); static void *H5FD_multi_fapl_get(H5FD_t *file); static void *H5FD_multi_fapl_copy(const void *_old_fa); static herr_t H5FD_multi_fapl_free(void *_fa); @@ -157,6 +158,7 @@ static const H5FD_class_t H5FD_multi_g = { H5FD_multi_sb_size, /*sb_size */ H5FD_multi_sb_encode, /*sb_encode */ H5FD_multi_sb_decode, /*sb_decode */ + H5FD_multi_sb_verify, /*sb_verify */ sizeof(H5FD_multi_fapl_t), /*fapl_size */ H5FD_multi_fapl_get, /*fapl_get */ H5FD_multi_fapl_copy, /*fapl_copy */ @@ -982,6 +984,34 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) /*------------------------------------------------------------------------- + * Function: H5FD_multi_sb_verify + * + * Purpose: Verify that the multi driver is compatable with the driver + * that created the file. + * + * Return: Success: TRUE if the driver is compatible, else FALSE + * Failure: Negative + * + * Programmer: Jacob Gruber + * Friday, January 13, 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5FD_multi_sb_verify(H5FD_t *_file, const char *sb_driver_id) +{ + static const char *func = "H5FD_multi_sb_verify"; + + /* Check that the superblock was written by the multi driver */ + if(strncmp(sb_driver_id, "NCSAmult", (size_t)8) == 0) { + return 1; + } + + return 0; +} /* end H5FD_family_sb_verify() */ + + +/*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_get * * Purpose: Returns a file access property list which indicates how the diff --git a/src/H5FDnull.c b/src/H5FDnull.c new file mode 100644 index 0000000..c43b3b2 --- /dev/null +++ b/src/H5FDnull.c @@ -0,0 +1,1330 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Purpose: The null file driver is a non-functional stackable driver. All + * calls are delegated to the underlying driver; it provides + * absolutely no new functionality. The main purpose of this driver + * is to serve as a template for future stackable drivers. In + * particular, other transparent drivers (those that add a feature + * that does not affect file structure, like external logging or + * caching) will be easy to build on top of this driver. + */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5FD_null_init_interface + + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDnull.h" /* Null file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ + +/* The driver identification number, initialized at runtime */ +static hid_t H5FD_NULL_g = 0; + +/* The description of a file belonging to this driver. */ +typedef struct H5FD_null_t { + H5FD_t pub; /* public stuff, must be first */ + hid_t inner_fapl_id; /* FAPL of the underlying driver */ + H5FD_t *inner_file; /* Pointer to the underlying file */ +} H5FD_null_t; + +/* Driver-specific file access properties */ +typedef struct H5FD_null_fapl_t { + hid_t inner_fapl_id; /* FAPL of the underlying driver */ +} H5FD_null_fapl_t; + +/* Driver specific data transfer properties */ +typedef struct H5FD_null_dxpl_t { + hid_t inner_dxpl_id; /*data xfer property list of the inner file */ +} H5FD_null_dxpl_t; + +/* Callback prototypes */ +static herr_t H5FD_null_term(void); +static void *H5FD_null_fapl_get(H5FD_t *_file); +static void *H5FD_null_fapl_copy(const void *_old_fa); +static herr_t H5FD_null_fapl_free(void *_fa); +static void *H5FD_null_dxpl_copy(const void *_old_dx); +static herr_t H5FD_null_dxpl_free(void *_dx); +static hsize_t H5FD_null_sb_size(H5FD_t *_file); +static herr_t H5FD_null_sb_encode(H5FD_t *_file, char *name/*out*/, + unsigned char *buf/*out*/); +static herr_t H5FD_null_sb_decode(H5FD_t *_file, const char *name, + const unsigned char *buf); +static htri_t H5FD_null_sb_verify(H5FD_t *_file, const char *sb_driver_id); +static H5FD_t *H5FD_null_open(const char *name, unsigned flags, + hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_null_close(H5FD_t *_file); +static int H5FD_null_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_null_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_null_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); +static haddr_t H5FD_null_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, + hsize_t size); +static herr_t H5FD_null_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, + hsize_t size); +static haddr_t H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); +static haddr_t H5FD_null_get_eof(const H5FD_t *_file); +static herr_t H5FD_null_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); +static herr_t H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, + size_t size, void *_buf/*out*/); +static herr_t H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, + size_t size, const void *_buf); +static herr_t H5FD_null_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); +static herr_t H5FD_null_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing); + +/* The class struct */ +static const H5FD_class_t H5FD_null_g = { + "null", /* name */ + HADDR_MAX, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_null_term, /* terminate */ + H5FD_null_sb_size, /* sb_size */ + H5FD_null_sb_encode, /* sb_encode */ + H5FD_null_sb_decode, /* sb_decode */ + H5FD_null_sb_verify, /* sb_verify */ + sizeof(H5FD_null_fapl_t), /* fapl_size */ + H5FD_null_fapl_get, /* fapl_get */ + H5FD_null_fapl_copy, /* fapl_copy */ + H5FD_null_fapl_free, /* fapl_free */ + sizeof(H5FD_null_dxpl_t), /* dxpl_size */ + H5FD_null_dxpl_copy, /* dxpl_copy */ + H5FD_null_dxpl_free, /* dxpl_free */ + H5FD_null_open, /* open */ + H5FD_null_close, /* close */ + H5FD_null_cmp, /* cmp */ + H5FD_null_query, /* query */ + H5FD_null_get_type_map, /* get_type_map */ + H5FD_null_alloc, /* alloc */ + H5FD_null_free, /* free */ + H5FD_null_get_eoa, /* get_eoa */ + H5FD_null_set_eoa, /* set_eoa */ + H5FD_null_get_eof, /* get_eof */ + H5FD_null_get_handle, /* get_handle */ + H5FD_null_read, /* read */ + H5FD_null_write, /* write */ + H5FD_null_flush, /* flush */ + H5FD_null_truncate, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ + H5FD_FLMAP_SINGLE /* fl_map */ +}; + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_init_interface + * + * Purpose: Initialize interface-specific information + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_init_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + FUNC_LEAVE_NOAPI(H5FD_null_init()) +} /* H5FD_null_init_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_init + * + * Purpose: Initialize this driver by registering the driver with the + * library. + * + * Return: Success: The driver ID for the null driver. + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5FD_null_init(void) +{ + hid_t ret_value=H5FD_NULL_g; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (H5I_VFL!=H5Iget_type(H5FD_NULL_g)) + H5FD_NULL_g = H5FD_register(&H5FD_null_g,sizeof(H5FD_class_t),FALSE); + + /* Set return value */ + ret_value=H5FD_NULL_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_init */ + + +/*--------------------------------------------------------------------------- + * Function: H5FD_null_term + * + * Purpose: Shut down the VFD + * + * Returns: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Reset VFL ID */ + H5FD_NULL_g=0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_null_term() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_null + * + * Purpose: Sets the file access property list FAPL_ID to use the null + * driver. The inner_fapl_id is the FAPL of the underlying + * property list. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_null(hid_t fapl_id, hid_t inner_fapl_id) +{ + herr_t ret_value; + H5FD_null_fapl_t fa={0}; + H5P_genplist_t *plist; /* Property list pointer */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", fapl_id, inner_fapl_id); + + /* Check arguments */ + if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + if(H5P_DEFAULT == inner_fapl_id) + inner_fapl_id = H5P_FILE_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(inner_fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + + /* + * Initialize driver specific information. + */ + fa.inner_fapl_id = inner_fapl_id; + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + ret_value= H5P_set_driver(plist, H5FD_NULL, &fa); + +done: + FUNC_LEAVE_API(ret_value) +} /*H5Pset_fapl_null*/ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_fapl_null + * + * Purpose: Returns information about the null file access property + * list though the function arguments. The inner_fapl_id is a + * pointer to the FAPL of the underlying driver. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_fapl_null(hid_t fapl_id, hid_t *inner_fapl_id/*out*/) +{ + H5FD_null_fapl_t *fa; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ix", fapl_id, inner_fapl_id); + + /* Check arguments */ + if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + if(H5FD_NULL != H5P_get_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if(NULL == (fa = (H5FD_null_fapl_t *)H5P_get_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + if(inner_fapl_id) { + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->inner_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + *inner_fapl_id = H5P_copy_plist(plist, TRUE); + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /*H5Pget_fapl_null*/ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_fapl_get + * + * Purpose: Gets a file access property list which could be used to + * create an identical file. + * + * Return: Success: Ptr to new file access property list. + * Failure: NULL + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_null_fapl_get(H5FD_t *_file) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + H5FD_null_fapl_t *fa = NULL; + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Check agruments */ + if(NULL == (fa = (H5FD_null_fapl_t *)H5MM_calloc(sizeof(H5FD_null_fapl_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->inner_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + fa->inner_fapl_id = H5P_copy_plist(plist, FALSE); + + /* Set return value */ + ret_value=fa; + +done: + if(ret_value==NULL) { + if(fa!=NULL) + H5MM_xfree(fa); + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_fapl_get */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_fapl_copy + * + * Purpose: Copies the null-specific file access properties. + * + * Return: Success: Ptr to a new property list + * Failure: NULL + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_null_fapl_copy(const void *_old_fa) +{ + const H5FD_null_fapl_t *old_fa = (const H5FD_null_fapl_t*)_old_fa; + H5FD_null_fapl_t *new_fa = NULL; + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Allocate memory for copy */ + if(NULL == (new_fa = (H5FD_null_fapl_t *)H5MM_malloc(sizeof(H5FD_null_fapl_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Copy the fields of the structure */ + memcpy(new_fa, old_fa, sizeof(H5FD_null_fapl_t)); + + /* Deep copy the property list objects in the structure */ + if(old_fa->inner_fapl_id==H5P_FILE_ACCESS_DEFAULT) { + if(H5I_inc_ref(new_fa->inner_fapl_id, FALSE)<0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") + } /* end if */ + else { + if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->inner_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + new_fa->inner_fapl_id = H5P_copy_plist(plist, FALSE); + } /* end else */ + + /* Set return value */ + ret_value=new_fa; + +done: + if(ret_value==NULL) { + if(new_fa!=NULL) + H5MM_xfree(new_fa); + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_fapl_copy */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_fapl_free + * + * Purpose: Frees the null-specific file access properties. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_fapl_free(void *_fa) +{ + H5FD_null_fapl_t *fa = (H5FD_null_fapl_t*)_fa; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Free the iner FAPL */ + if(H5I_dec_ref(fa->inner_fapl_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") + H5MM_xfree(fa); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_fapl_free */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_dxpl_copy + * + * Purpose: Copies the null-specific data transfer properties. + * + * Return: Success: Pointertr to the new property list + * Failure: NULL + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_null_dxpl_copy(const void *_old_dx) +{ + const H5FD_null_dxpl_t *old_dx = (const H5FD_null_dxpl_t*)_old_dx; + H5FD_null_dxpl_t *new_dx = NULL; + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Allocate memoryfor copy */ + if(NULL == (new_dx = (H5FD_null_dxpl_t *)H5MM_malloc(sizeof(H5FD_null_dxpl_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Copy the DXPL */ + HDmemcpy(new_dx, old_dx, sizeof(H5FD_null_dxpl_t)); + + if(old_dx->inner_dxpl_id == H5P_DATASET_XFER_DEFAULT) { + if(H5I_inc_ref(new_dx->inner_dxpl_id, FALSE)<0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") + } /* end if */ + else { + if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_dx->inner_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + new_dx->inner_dxpl_id = H5P_copy_plist(plist, FALSE); + } /* end else */ + + /* Set return value */ + ret_value=new_dx; + +done: + if(ret_value==NULL) { + if(new_dx!=NULL) + H5MM_xfree(new_dx); + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_dxpl_copy */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_dxpl_free + * + * Purpose: Frees the null-specific data transfer properties. + * + * Return: Success: 0 + * Failure: -1 + + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_dxpl_free(void *_dx) +{ + H5FD_null_dxpl_t *dx = (H5FD_null_dxpl_t*)_dx; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Free the DXPL */ + if(H5I_dec_ref(dx->inner_dxpl_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") + H5MM_xfree(dx); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_dxpl_free */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_sb_size + * + * Purpose: Returns the size of the private information to be stored + * in the superblock. This function is delegated to the + * inner driver and the result is returned without + * modification. + * + * Return: Success: The super block driver data size. + * Failure: 0 if an error occurs or if the driver has no + * data to store in the superblock. + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static hsize_t +H5FD_null_sb_size(H5FD_t *_file) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + hsize_t ret_value = 0; /*size of header*/ + + FUNC_ENTER_NOAPI(UFAIL) + + HDassert(file); + + /* Delegate to inner file */ + ret_value = H5FD_sb_size(file->inner_file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_sb_size */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_sb_encode + * + * Purpose: Encode driver information for the superblock. This + * is delegated to the inner driver. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to inner file */ + if(H5FD_sb_encode(file->inner_file, name, buf) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner driver sb_encode failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_sb_encode() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_sb_decode + * + * Purpose: Decode the superblock information for this driver. This + * is delegated to the inner driver. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to the inner driver */ + if(H5FD_sb_decode(file->inner_file, name, buf) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner driver sb_decode failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_sb_decode() */ + + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_sb_verify + * + * Purpose: Verify that the inner driver is compatible with the driver + * that created the file. + * + * Return: Success: TRUE if the driver is compatible, else FALSE + * Failure: Negative + * + * Programmer: Jacob Gruber + * Friday, January 13, 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5FD_null_sb_verify(H5FD_t *_file, const char *sb_driver_id) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to the inner driver */ + ret_value = H5FD_sb_verify(file->inner_file, sb_driver_id); + if(ret_value < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner driver sb_verify failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_open + * + * Purpose: Creates and/or opens a file with the null driver. + * + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static H5FD_t * +H5FD_null_open(const char *name, unsigned flags, hid_t fapl_id, + haddr_t maxaddr) +{ + H5FD_null_t *file=NULL; + H5FD_t *ret_value=NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") + if(0 == maxaddr || HADDR_UNDEF == maxaddr) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") + + /* Initialize file from file access properties */ + if(NULL == (file = (H5FD_null_t *)H5MM_calloc(sizeof(H5FD_null_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") + if(H5P_FILE_ACCESS_DEFAULT==fapl_id) { + file->inner_fapl_id = H5P_FILE_ACCESS_DEFAULT; + if(H5I_inc_ref(file->inner_fapl_id, FALSE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") + } /* end if */ + else { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_fapl_t *fa; + + /* Get FAPL */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + fa = (H5FD_null_fapl_t *)H5P_get_driver_info(plist); + HDassert(fa); + + /* Get inner FAPL */ + if(fa->inner_fapl_id==H5P_FILE_ACCESS_DEFAULT) { + if(H5I_inc_ref(fa->inner_fapl_id, FALSE)<0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") + file->inner_fapl_id = fa->inner_fapl_id; + } /* end if */ + else { + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->inner_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + file->inner_fapl_id = H5P_copy_plist(plist, FALSE); + } /* end else */ + } /* end else */ + + /* Open the inner file */ + file->inner_file = H5FD_open(name, flags, file->inner_fapl_id, HADDR_UNDEF); + if(NULL == file->inner_file) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open inner file") + ret_value=(H5FD_t *)file; + +done: + /* Cleanup and fail */ + if(ret_value == NULL && file != NULL) { + + if(file->inner_file) { + if (H5FD_close(file->inner_file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close inner file") + } + + if(H5I_dec_ref(file->inner_fapl_id) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") + H5MM_xfree(file); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_close + * + * Purpose: Closes a file opened through the null driver + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_close(H5FD_t *_file) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Close the inner file */ + if (H5FD_close(file->inner_file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close inner file") + + /* Decrease the reference count on the inner FAPL */ + if(H5I_dec_ref(file->inner_fapl_id) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") + + /* Free the file */ + H5MM_xfree(file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_cmp + * + * Purpose: Compares two null driver files. Delegated to the inner + * driver. + * + * Return: Success: Like strcmp() + * Failure: Never fails (arguments were checked by the caller). + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +H5FD_null_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +{ + const H5FD_null_t *f1 = (const H5FD_null_t*)_f1; + const H5FD_null_t *f2 = (const H5FD_null_t*)_f2; + int ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f1); + HDassert(f2); + + /* Delegate to the inner driver */ + ret_value = H5FDcmp(f1->inner_file, f2->inner_file); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_query + * + * Purpose: Set the flags that this VFL driver is capable of supporting + * (listed in H5FDpublic.h). Delegated to the inner driver. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_query(const H5FD_t * _file, unsigned long *flags /* out */) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Query the inner driver */ + if(flags) { + HDassert(file); + H5FD_query(file->inner_file, flags); + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_null_query() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_get_type_map + * + * Purpose: Get the type mapping of the underlying driver. + * Only used for the multi driver. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + herr_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to the underlying driver */ + ret_value = H5FD_get_fs_type_map(file->inner_file, type_map); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_alloc + * + * Purpose: Allocate file memory in the inner driver. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_null_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null-specific info */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FDalloc(file->inner_file, type, inner_dxpl_id, size); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_free + * + * Purpose: Free file memory in the inner file. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null-specific info */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FDfree(file->inner_file, type, inner_dxpl_id, addr, size); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_get_eoa + * + * Purpose: Returns the end-of-address marker for the inner file. The + * marker is the first address past the last byte allocated in + * the format address space. + * + * Return: Success: The end-of-address-marker + * Failure: HADDR_UNDEF + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + haddr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(HADDR_UNDEF) + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FD_get_eoa(file->inner_file, type); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_set_eoa + * + * Purpose: Set the end-of-address marker for the inner file. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FD_set_eoa(file->inner_file, type, abs_eoa); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_set_eof */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_get_eof + * + * Purpose: Returns the end-of-file marker in the inner file. + * + * Return: Success: End of file address. + * Failure: HADDR_UNDEF + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_null_get_eof(const H5FD_t *_file) +{ + const H5FD_null_t *file = (const H5FD_null_t*)_file; + haddr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(HADDR_UNDEF) + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FD_get_eof(file->inner_file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_get_eof */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_get_handle + * + * Purpose: Returns the file handle of inner file driver. + * + * Returns: Non-negative if succeed or negative if fails. + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) +{ + H5FD_null_t *file = (H5FD_null_t *)_file; + herr_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + + /* Delegate to the inner file */ + ret_value = H5FD_get_vfd_handle(file->inner_file, file->inner_fapl_id, file_handle); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_read + * + * Purpose: Reads from the inner file. + * + * Return: Success: Zero. Result is stored in caller-supplied buffer. + * Failure: -1, contents of buffer BUF are undefined. + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *_buf/*out*/) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + unsigned char *buf = (unsigned char*)_buf; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null-specific info */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + /* Read from inner file */ + if (H5FDread(file->inner_file, type, inner_dxpl_id, addr, size, buf)<0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "inner file read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_read */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_write + * + * Purpose: Writes to the inner file. + * + * Return: Success: Zero + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *_buf) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + const unsigned char *buf = (const unsigned char*)_buf; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null-specific info */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + /* Delegate write to the inner file */ + HDassert(file); + if (H5FDwrite(file->inner_file, type, inner_dxpl_id, addr, size, buf)<0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD_null_write */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_flush + * + * Purpose: Flushes the inner file. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null driver property list */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + /* Delegate to the inner driver */ + HDassert(file); + if (H5FD_flush(file->inner_file, inner_dxpl_id, closing) < 0) + HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush inner file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_null_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_null_truncate + * + * Purpose: Truncates the inner file. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_null_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing) +{ + H5FD_null_t *file = (H5FD_null_t*)_file; + hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* + * Get the inner data transfer property list. + */ + if(H5P_DATASET_XFER_DEFAULT != dxpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_null_dxpl_t *dx; /* Null driver property list */ + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + + dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); + + HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(dx); + inner_dxpl_id = dx->inner_dxpl_id; + } /* end if */ + + /* Delegate to the underlying driver */ + HDassert(file); + if(H5FD_truncate(file->inner_file, inner_dxpl_id, closing) < 0) + HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to truncate inner file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_null_truncate() */ + diff --git a/src/H5FDnull.h b/src/H5FDnull.h new file mode 100644 index 0000000..954cdc5 --- /dev/null +++ b/src/H5FDnull.h @@ -0,0 +1,41 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jacob Gruber + * Thursday, January 5, 2012 + * + * Purpose: The public header file for the null driver. + */ +#ifndef H5FDnull_H +#define H5FDnull_H + +#include "H5Ipublic.h" + +#define H5FD_NULL (H5FD_null_init()) + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5FD_null_init(void); +H5_DLL herr_t H5Pset_fapl_null(hid_t fapl_id, hid_t inner_fapl_id); +H5_DLL herr_t H5Pget_fapl_null(hid_t fapl_id, hid_t *inner_fapl_id/*out*/); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 4f7d059..4234898 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -70,6 +70,7 @@ H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); H5_DLL herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf); +H5_DLL herr_t H5FD_sb_verify(H5FD_t *file, const char *sb_driver_id); H5_DLL void *H5FD_fapl_get(H5FD_t *file); H5_DLL herr_t H5FD_fapl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info); H5_DLL herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl); @@ -105,10 +106,6 @@ H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); -#ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5FD_set_mpio_atomicity(H5FD_t *file, hbool_t flag); -H5_DLL herr_t H5FD_get_mpio_atomicity(H5FD_t *file, hbool_t *flag); -#endif /* H5_HAVE_PARALLEL */ #endif /* !_H5FDprivate_H */ diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index f495e2d..bded08e 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -236,6 +236,7 @@ typedef struct H5FD_class_t { herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/, unsigned char *p/*out*/); herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); + htri_t (*sb_verify)(H5FD_t *file, const char *sb_driver_id); size_t fapl_size; void * (*fapl_get)(H5FD_t *file); void * (*fapl_copy)(const void *fapl); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 6d4a76a..f5b88da 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -167,6 +167,7 @@ static const H5FD_class_t H5FD_sec2_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ 0, /*fapl_size */ NULL, /*fapl_get */ NULL, /*fapl_copy */ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index b67e01e..35c844b 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -189,6 +189,7 @@ static const H5FD_class_t H5FD_stdio_g = { NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ + NULL, /*sb_verify */ 0, /*fapl_size */ NULL, /*fapl_get */ NULL, /*fapl_copy */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index cc1137b..10ee11f 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -128,6 +128,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) uint8_t *p; /* Temporary pointer into encoding buffer */ unsigned super_vers; /* Superblock version */ hbool_t *dirtied = (hbool_t *)_udata; /* Set up dirtied out value */ + htri_t sb_verify_result; /* Result of sb_verify call */ H5F_super_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -360,13 +361,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) drv_name[8] = '\0'; p += 8; /* advance past name/version */ - /* Check if driver matches driver information saved. Unfortunately, we can't push this - * function to each specific driver because we're checking if the driver is correct. - */ - if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used") - if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used") + /* Check if the driver is compatible with the driver information saved. */ + if((sb_verify_result = H5FD_sb_verify(lf, drv_name)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine driver compatability") + else if(sb_verify_result == 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file") /* Read in variable-sized portion of driver info block */ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0) @@ -522,13 +521,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo, dxpl_id)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "driver info message not present") - /* Check if driver matches driver information saved. Unfortunately, we can't push this - * function to each specific driver because we're checking if the driver is correct. - */ - if(!HDstrncmp(drvinfo.name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used") - if(!HDstrncmp(drvinfo.name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used") + /* Check if the driver is compatible with the driver information saved. */ + if((sb_verify_result = H5FD_sb_verify(lf, drvinfo.name)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine driver compatability") + else if(sb_verify_result == 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file") /* Decode driver information */ if(H5FD_sb_decode(lf, drvinfo.name, drvinfo.buf) < 0) diff --git a/src/Makefile.am b/src/Makefile.am index d42af98..46b47b1 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,7 +61,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ - H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ + H5FDmpiposix.c H5FDmulti.c H5FDnull.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c \ H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ @@ -113,8 +113,8 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ - H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ - H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ + H5FDmulti.h H5FDnull.h H5FDsec2.h H5FDstdio.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h diff --git a/src/Makefile.in b/src/Makefile.in index 64e5cdc..36f0755 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -112,10 +112,10 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5FAcache.lo H5FAdbg.lo H5FAdblock.lo H5FAdblkpage.lo \ H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo H5FDcore.lo \ H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo \ - H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \ - H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo \ - H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo \ - H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ + H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDnull.lo \ + H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo \ + H5FScache.lo H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo \ + H5G.lo H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \ H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \ H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \ @@ -520,7 +520,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ - H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ + H5FDmpiposix.c H5FDmulti.c H5FDnull.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c \ H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ @@ -572,8 +572,8 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ - H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ - H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ + H5FDmulti.h H5FDnull.h H5FDsec2.h H5FDstdio.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h @@ -777,6 +777,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDmpio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDmpiposix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDmulti.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDnull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDsec2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDspace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDstdio.Plo@am__quote@ @@ -48,6 +48,7 @@ #include "H5FDmulti.h" /* Usage-partitioned file family */ #include "H5FDsec2.h" /* POSIX unbuffered file I/O */ #include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDnull.h" /* Basic stackable file driver */ #ifdef H5_HAVE_WINDOWS #include "H5FDwindows.h" /* Windows buffered I/O */ #endif @@ -51,6 +51,8 @@ const char *FILENAME[] = { "stdio_file", /*7*/ "windows_file", /*8*/ "new_multi_file_v16",/*9*/ + "null_core_file", /*10*/ + "null_family_file", /*11*/ NULL }; @@ -1294,6 +1296,229 @@ error: /*------------------------------------------------------------------------- + * Function: test_null + * + * Purpose: Tests the file handle interface for the NULL driver. + * The first component of this test is to wrap the null driver + * around the core driver and run the core test suite. + * Since the core driver does not implement all VFD features, + * other drivers need to be tested as well. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Gruber + * Friday, January 5, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_null(void) +{ + hid_t file=(-1), null_fapl, core_fapl, family_fapl; + hid_t null_fapl2=(-1), core_fapl2=(-1), family_fapl2=(-1); + hid_t dset1=(-1), space1=(-1); + char filename[1024]; + void *fhandle=NULL; + hsize_t file_size, dims1[2]; + int i, j, n, *points, *check, *p1, *p2; + + TESTING("NULL file driver"); + + /* Set property list for the CORE driver */ + core_fapl = h5_fileaccess(); + if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) + TEST_ERROR; + + /* Stack the null driver on top of the core driver. */ + null_fapl = h5_fileaccess(); + if(H5Pset_fapl_null(null_fapl, core_fapl) < 0) + TEST_ERROR; + + /* Set the file name in the core driver */ + h5_fixname(FILENAME[10], null_fapl, filename, sizeof filename); + + /* Create the file with the null driver */ + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, null_fapl)) < 0) + TEST_ERROR; + + /* Retrieve the top access property list... */ + if((null_fapl2 = H5Fget_access_plist(file)) < 0) + TEST_ERROR; + + /* Retrieve the bottom access property list */ + if (H5Pget_fapl_null(null_fapl2, &core_fapl2) < 0) + TEST_ERROR; + if (core_fapl2 < 0) + TEST_ERROR; + + + /* Check that the top driver is correct */ + if(H5FD_NULL != H5Pget_driver(null_fapl2)) + TEST_ERROR; + + /* Check that the bottom driver is correct */ + if(H5FD_CORE != H5Pget_driver(core_fapl2)) + TEST_ERROR; + + /* Close the bottom property list */ + if (H5Pclose(core_fapl2) < 0) + TEST_ERROR; + + /* ...and close the top property list */ + if (H5Pclose(null_fapl2) < 0) + TEST_ERROR; + + /* Check the file handle API */ + if(H5Fget_vfd_handle(file, H5P_DEFAULT, &fhandle) < 0) + TEST_ERROR; + if(fhandle == NULL) + TEST_ERROR; + + /* Check file size API */ + if(H5Fget_filesize(file, &file_size) < 0) + TEST_ERROR; + + /* There is no garantee the size of metadata in file is constant. + * Just try to check if it's reasonable. Why is this 4KB? + */ + if(file_size<2*KB || file_size>6*KB) + TEST_ERROR; + + /* Close the file */ + if(H5Fclose(file) < 0) + TEST_ERROR; + + /* Turn off the backing store in the core driver. This is done + * to increase the speed of the test. The nul driver only stores + * a reference to this fapl, so the change is immediately + * recognized. + */ + if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) + TEST_ERROR; + + /* Open the file with the null driver */ + if((file=H5Fopen(filename, H5F_ACC_RDWR, null_fapl)) < 0) + TEST_ERROR; + + /* Allocate memory for data set. */ + points=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int)); + check=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int)); + + /* Initialize the dset1 */ + p1 = points; + for(i = n = 0; i < DSET1_DIM1; i++) + for(j = 0; j < DSET1_DIM2; j++) + *p1++ = n++; + + /* Create the data space1 */ + dims1[0] = DSET1_DIM1; + dims1[1] = DSET1_DIM2; + if((space1 = H5Screate_simple(2, dims1, NULL)) < 0) + TEST_ERROR; + + /* Create the dset1 */ + if((dset1 = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Write the data to the dset1 */ + if(H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + TEST_ERROR; + + /* Close the dset */ + if(H5Dclose(dset1) < 0) + TEST_ERROR; + + /* Reopen the dset */ + if((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Read the data back from dset1 */ + if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + p1 = points; + p2 = check; + for(i = 0; i < DSET1_DIM1; i++) + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ + + /* Clean up */ + if(H5Sclose(space1) < 0) + TEST_ERROR; + if(H5Dclose(dset1) < 0) + TEST_ERROR; + if(H5Fclose(file) < 0) + TEST_ERROR; + if(points) + free(points); + if(check) + free(check); + if(H5Pclose(core_fapl) < 0) + TEST_ERROR; + + h5_cleanup(FILENAME, null_fapl); + + /* Test the superblock fucntions. The superblock is only used when + * testing the compatibility of the family and multi drivers, so + * a separate test is needed. + */ + + /* Set up family FAPL */ + family_fapl = h5_fileaccess(); + if(H5Pset_fapl_family(family_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR; + + /* Wrap null around family driver */ + null_fapl = h5_fileaccess(); + if(H5Pset_fapl_null(null_fapl, family_fapl) < 0) + TEST_ERROR; + + /* Set the file name. Thsi must be done with the family driver so that + * the member numbers are properly set up. + */ + h5_fixname(FILENAME[11], family_fapl, filename, sizeof filename); + + /* Create file with the null driver*/ + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, null_fapl)) < 0) + TEST_ERROR; + + /* close file */ + if(H5Fclose(file) < 0) + TEST_ERROR; + + /* Reopen file, testing suplerblocks for compatability */ + if((file=H5Fopen(filename, H5F_ACC_RDWR, null_fapl)) < 0) + TEST_ERROR; + + /* Cleanup */ + if(H5Fclose(file) < 0) + TEST_ERROR; + + h5_cleanup(FILENAME, family_fapl); + if(H5Pclose(null_fapl) < 0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose (core_fapl); + H5Pclose (null_fapl); + H5Fclose(file); + } H5E_END_TRY; + return -1; +} + + +/*------------------------------------------------------------------------- * Function: test_log * * Purpose: Tests the file handle interface for log driver @@ -1413,6 +1638,11 @@ test_stdio(void) TEST_ERROR; /* Check that the driver is correct */ + /* Retrieve the access property list... */ + if((access_fapl = H5Fget_access_plist(file)) < 0) + TEST_ERROR; + + /* Check that the driver is correct */ if(H5FD_STDIO != H5Pget_driver(access_fapl)) TEST_ERROR; @@ -1573,6 +1803,7 @@ main(void) nerrors += test_family_compat() < 0 ? 1 : 0; nerrors += test_multi() < 0 ? 1 : 0; nerrors += test_multi_compat() < 0 ? 1 : 0; + nerrors += test_null() < 0 ? 1 : 0; nerrors += test_direct() < 0 ? 1 : 0; nerrors += test_log() < 0 ? 1 : 0; nerrors += test_stdio() < 0 ? 1 : 0; diff --git a/tools/h5diff/testfiles/h5diff_466.txt b/tools/h5diff/testfiles/h5diff_466.txt deleted file mode 100644 index 3e00ca3..0000000 --- a/tools/h5diff/testfiles/h5diff_466.txt +++ /dev/null @@ -1,5 +0,0 @@ -obj1 </soft_link1> is a dangling link. -obj2 </soft_link1> is a dangling link. -dangling link: </soft_link1> and </soft_link1> -0 differences found -EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_467.txt b/tools/h5diff/testfiles/h5diff_467.txt deleted file mode 100644 index f5195c0..0000000 --- a/tools/h5diff/testfiles/h5diff_467.txt +++ /dev/null @@ -1,3 +0,0 @@ -obj2 </soft_link2> is a dangling link. -1 differences found -EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_468.txt b/tools/h5diff/testfiles/h5diff_468.txt deleted file mode 100644 index 75b16c6..0000000 --- a/tools/h5diff/testfiles/h5diff_468.txt +++ /dev/null @@ -1,5 +0,0 @@ -obj1 </ext_link4> is a dangling link. -obj2 </ext_link4> is a dangling link. -dangling link: </ext_link4> and </ext_link4> -0 differences found -EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_469.txt b/tools/h5diff/testfiles/h5diff_469.txt deleted file mode 100644 index 594fd80..0000000 --- a/tools/h5diff/testfiles/h5diff_469.txt +++ /dev/null @@ -1,3 +0,0 @@ -obj2 </ext_link2> is a dangling link. -1 differences found -EXIT CODE: 1 diff --git a/tools/testfiles/tmultifile.ddl b/tools/testfiles/tmultifile.ddl deleted file mode 100644 index cf94f2c..0000000 --- a/tools/testfiles/tmultifile.ddl +++ /dev/null @@ -1,42 +0,0 @@ -HDF5 "tarray2.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [3][4][5] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray3.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_ARRAY { [6][3] H5T_STD_I32LE } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray4.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_IEEE_F32LE "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray5.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_ARRAY { [4] H5T_IEEE_F32LE } "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray6.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_STD_U32LE} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray7.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_ARRAY { [4] H5T_STD_U32LE }} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} diff --git a/tools/testfiles/tmultifile.ls b/tools/testfiles/tmultifile.ls deleted file mode 100644 index 3fee937..0000000 --- a/tools/testfiles/tmultifile.ls +++ /dev/null @@ -1,6 +0,0 @@ -dset1 Dataset {5} -g1 Group -g2 Group -g3 Group, same as / -slink1 Soft Link {somevalue} -slink2 Soft Link {linkvalue} diff --git a/tools/testfiles/tqmarkfile.ddl b/tools/testfiles/tqmarkfile.ddl deleted file mode 100644 index e7771cb..0000000 --- a/tools/testfiles/tqmarkfile.ddl +++ /dev/null @@ -1,83 +0,0 @@ -HDF5 "tarray1.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray2.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [3][4][5] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray3.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_ARRAY { [6][3] H5T_STD_I32LE } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray4.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_IEEE_F32LE "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray5.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_ARRAY { [4] H5T_IEEE_F32LE } "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray6.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_STD_U32LE} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray7.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_ARRAY { [4] H5T_STD_U32LE }} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray8.h5" { -} -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found - major: Dataset - minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object 'Dataset1' doesn't exist - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist - major: Symbol table - minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to get link info from "Dataset1" diff --git a/tools/testfiles/tslink-D.ddl b/tools/testfiles/tslink-D.ddl deleted file mode 100644 index a1d999a..0000000 --- a/tools/testfiles/tslink-D.ddl +++ /dev/null @@ -1,30 +0,0 @@ -HDF5 "tslink.h5" { -SOFTLINK "/slink1" { - LINKTARGET "somevalue" -} -} -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found - major: Dataset - minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #004: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link - major: Symbol table - minor: Object not found - #006: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #007: (file name) line (number) in H5G_traverse_slink_cb(): component not found - major: Symbol table - minor: Object not found diff --git a/tools/testfiles/tstarfile.ddl b/tools/testfiles/tstarfile.ddl deleted file mode 100644 index 77b80e0..0000000 --- a/tools/testfiles/tstarfile.ddl +++ /dev/null @@ -1,89 +0,0 @@ -HDF5 "tarray1_big.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [1000] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 2000 ) / ( 2000 ) } -} -} -HDF5 "tarray1.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray2.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [3][4][5] H5T_STD_I32LE } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray3.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_ARRAY { [6][3] H5T_STD_I32LE } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray4.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_IEEE_F32LE "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray5.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_COMPOUND { - H5T_STD_I32LE "i"; - H5T_ARRAY { [4] H5T_IEEE_F32LE } "f"; - } } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray6.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_STD_U32LE} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray7.h5" { -DATASET "Dataset1" { - DATATYPE H5T_ARRAY { [4] H5T_VLEN { H5T_ARRAY { [4] H5T_STD_U32LE }} } - DATASPACE SIMPLE { ( 4 ) / ( 4 ) } -} -} -HDF5 "tarray8.h5" { -} -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found - major: Dataset - minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object 'Dataset1' doesn't exist - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist - major: Symbol table - minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to get link info from "Dataset1" |