summaryrefslogtreecommitdiffstats
path: root/src/H5FDdirect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FDdirect.c')
-rw-r--r--src/H5FDdirect.c778
1 files changed, 389 insertions, 389 deletions
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 469fe9d..3cd40be 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -17,27 +17,27 @@
* Programmer: Raymond Lu <slu@hdfgroup.uiuc.edu>
* Wednesday, 20 September 2006
*
- * Purpose: The Direct I/O file driver forces the data to be written to
- * the file directly without being copied into system kernel
- * buffer. The main system support this feature is Linux.
+ * Purpose: The Direct I/O file driver forces the data to be written to
+ * the file directly without being copied into system kernel
+ * buffer. The main system support this feature is Linux.
*/
/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5FD_direct_init_interface
+#define H5_INTERFACE_INIT_FUNC H5FD_direct_init_interface
/* For system function posix_memalign - Commented it out because copper isn't able to compile
* this file. */
/* #define _XOPEN_SOURCE 600 */
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5FDdirect.h" /* Direct file driver */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5FDdirect.h" /* Direct file driver */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
#ifdef H5_HAVE_DIRECT
@@ -45,15 +45,15 @@
static hid_t H5FD_DIRECT_g = 0;
/* File operations */
-#define OP_UNKNOWN 0
-#define OP_READ 1
-#define OP_WRITE 2
+#define OP_UNKNOWN 0
+#define OP_READ 1
+#define OP_WRITE 2
/* Driver-specific file access properties */
typedef struct H5FD_direct_fapl_t {
- size_t mboundary; /* Memory boundary for alignment */
- size_t fbsize; /* File system block size */
- size_t cbsize; /* Maximal buffer size for copying user data */
+ size_t mboundary; /* Memory boundary for alignment */
+ size_t fbsize; /* File system block size */
+ size_t cbsize; /* Maximal buffer size for copying user data */
hbool_t must_align; /* Decides if data alignment is required */
} H5FD_direct_fapl_t;
@@ -70,27 +70,27 @@ typedef struct H5FD_direct_fapl_t {
* occurs), and `op' will be set to H5F_OP_UNKNOWN.
*/
typedef struct H5FD_direct_t {
- H5FD_t pub; /*public stuff, must be first */
- int fd; /*the unix file */
- haddr_t eoa; /*end of allocated region */
- haddr_t eof; /*end of file; current file size*/
- haddr_t pos; /*current file I/O position */
- int op; /*last operation */
- H5FD_direct_fapl_t fa; /*file access properties */
-#ifndef _WIN32
+ H5FD_t pub; /*public stuff, must be first */
+ int fd; /*the unix file */
+ haddr_t eoa; /*end of allocated region */
+ haddr_t eof; /*end of file; current file size*/
+ haddr_t pos; /*current file I/O position */
+ int op; /*last operation */
+ H5FD_direct_fapl_t fa; /*file access properties */
+#ifndef H5_HAVE_WIN32_API
/*
* On most systems the combination of device and i-node number uniquely
* identify a file.
*/
- dev_t device; /*file device number */
+ dev_t device; /*file device number */
#ifdef H5_VMS
- ino_t inode[3]; /*file i-node number */
+ ino_t inode[3]; /*file i-node number */
#else
- ino_t inode; /*file i-node number */
+ ino_t inode; /*file i-node number */
#endif /*H5_VMS*/
#else
/*
- * On _WIN32 the low-order word of a unique identifier associated with the
+ * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the
* file and the volume serial number uniquely identify a file. This number
* (which, both? -rpm) may change when the system is restarted or when the
* file is opened. After a process opens a file, the identifier is
@@ -108,58 +108,58 @@ typedef struct H5FD_direct_t {
* some macros here so we don't have to have conditional compilations later
* throughout the code.
*
- * file_offset_t: The datatype for file offsets, the second argument of
- * the lseek() or lseek64() call.
+ * file_offset_t: The datatype for file offsets, the second argument of
+ * the lseek() or lseek64() call.
*
- * file_seek: The function which adjusts the current file position,
- * either lseek() or lseek64().
+ * file_seek: The function which adjusts the current file position,
+ * either lseek() or lseek64().
*/
/* adding for windows NT file system support. */
#ifdef H5_HAVE_LSEEK64
-# define file_offset_t off64_t
-# define file_seek lseek64
-# define file_truncate ftruncate64
-#elif defined (_WIN32)
+# define file_offset_t off64_t
+# define file_seek lseek64
+# define file_truncate ftruncate64
+#elif defined (H5_HAVE_WIN32_API)
# /*MSVC*/
# define file_offset_t __int64
# define file_seek _lseeki64
-# define file_truncate _chsize
+# define file_truncate _chsize
#else
-# define file_offset_t off_t
-# define file_seek lseek
-# define file_truncate HDftruncate
+# define file_offset_t off_t
+# define file_seek lseek
+# define file_truncate HDftruncate
#endif
/*
* These macros check for overflow of various quantities. These macros
* assume that file_offset_t is signed and haddr_t and size_t are unsigned.
*
- * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
- * is too large to be represented by the second argument
- * of the file seek function.
+ * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
+ * is too large to be represented by the second argument
+ * of the file seek function.
*
- * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
- * large to be represented by the `size_t' type.
+ * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
+ * large to be represented by the `size_t' type.
*
- * REGION_OVERFLOW: Checks whether an address and size pair describe data
- * which can be addressed entirely by the second
- * argument of the file seek function.
+ * REGION_OVERFLOW: Checks whether an address and size pair describe data
+ * which can be addressed entirely by the second
+ * argument of the file seek function.
*/
#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1)
-#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \
- ((A) & ~(haddr_t)MAXADDR))
-#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR)
-#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \
- HADDR_UNDEF==(A)+(Z) || \
- (file_offset_t)((A)+(Z))<(file_offset_t)(A))
+#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \
+ ((A) & ~(haddr_t)MAXADDR))
+#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR)
+#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \
+ HADDR_UNDEF==(A)+(Z) || \
+ (file_offset_t)((A)+(Z))<(file_offset_t)(A))
/* Prototypes */
static herr_t H5FD_direct_term(void);
static void *H5FD_direct_fapl_get(H5FD_t *file);
static void *H5FD_direct_fapl_copy(const void *_old_fa);
static H5FD_t *H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr);
+ haddr_t maxaddr);
static herr_t H5FD_direct_close(H5FD_t *_file);
static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags);
@@ -168,44 +168,44 @@ static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
static haddr_t H5FD_direct_get_eof(const H5FD_t *_file);
static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, void *buf);
+ size_t size, void *buf);
static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, const void *buf);
+ size_t size, const void *buf);
static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static const H5FD_class_t H5FD_direct_g = {
- "direct", /*name */
- MAXADDR, /*maxaddr */
- H5F_CLOSE_WEAK, /* fc_degree */
+ "direct", /*name */
+ MAXADDR, /*maxaddr */
+ H5F_CLOSE_WEAK, /* fc_degree */
H5FD_direct_term, /*terminate */
- NULL, /*sb_size */
- NULL, /*sb_encode */
- NULL, /*sb_decode */
- sizeof(H5FD_direct_fapl_t), /*fapl_size */
- H5FD_direct_fapl_get, /*fapl_get */
- H5FD_direct_fapl_copy, /*fapl_copy */
- NULL, /*fapl_free */
- 0, /*dxpl_size */
- NULL, /*dxpl_copy */
- NULL, /*dxpl_free */
- H5FD_direct_open, /*open */
- H5FD_direct_close, /*close */
- H5FD_direct_cmp, /*cmp */
- H5FD_direct_query, /*query */
- NULL, /*get_type_map */
- NULL, /*alloc */
- NULL, /*free */
- H5FD_direct_get_eoa, /*get_eoa */
- H5FD_direct_set_eoa, /*set_eoa */
- H5FD_direct_get_eof, /*get_eof */
+ NULL, /*sb_size */
+ NULL, /*sb_encode */
+ NULL, /*sb_decode */
+ sizeof(H5FD_direct_fapl_t), /*fapl_size */
+ H5FD_direct_fapl_get, /*fapl_get */
+ H5FD_direct_fapl_copy, /*fapl_copy */
+ NULL, /*fapl_free */
+ 0, /*dxpl_size */
+ NULL, /*dxpl_copy */
+ NULL, /*dxpl_free */
+ H5FD_direct_open, /*open */
+ H5FD_direct_close, /*close */
+ H5FD_direct_cmp, /*cmp */
+ H5FD_direct_query, /*query */
+ NULL, /*get_type_map */
+ NULL, /*alloc */
+ NULL, /*free */
+ H5FD_direct_get_eoa, /*get_eoa */
+ H5FD_direct_set_eoa, /*set_eoa */
+ H5FD_direct_get_eof, /*get_eof */
H5FD_direct_get_handle, /*get_handle */
- H5FD_direct_read, /*read */
- H5FD_direct_write, /*write */
- NULL, /*flush */
- H5FD_direct_truncate, /*truncate */
+ H5FD_direct_read, /*read */
+ H5FD_direct_write, /*write */
+ NULL, /*flush */
+ H5FD_direct_truncate, /*truncate */
NULL, /*lock */
NULL, /*unlock */
- H5FD_FLMAP_SINGLE /*fl_map */
+ H5FD_FLMAP_SINGLE /*fl_map */
};
/* Declare a free list to manage the H5FD_direct_t struct */
@@ -235,16 +235,16 @@ H5FD_direct_init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_init
+ * Function: H5FD_direct_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the direct driver.
+ * Return: Success: The driver ID for the direct driver.
*
- * Failure: Negative.
+ * Failure: Negative.
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -270,9 +270,9 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_direct_term
+ * Function: H5FD_direct_term
*
- * Purpose: Shut down the VFD
+ * Purpose: Shut down the VFD
*
* Returns: Non-negative on success or negative on failure
*
@@ -294,16 +294,16 @@ H5FD_direct_term(void)
/*-------------------------------------------------------------------------
- * Function: H5Pset_fapl_direct
+ * Function: H5Pset_fapl_direct
*
- * Purpose: Modify the file access property list to use the H5FD_DIRECT
- * driver defined in this source file. There are no driver
- * specific properties.
+ * Purpose: Modify the file access property list to use the H5FD_DIRECT
+ * driver defined in this source file. There are no driver
+ * specific properties.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Raymond Lu
- * Wednesday, 20 September 2006
+ * Programmer: Raymond Lu
+ * Wednesday, 20 September 2006
*
* Modifications:
*
@@ -312,9 +312,9 @@ H5FD_direct_term(void)
herr_t
H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbuf_size)
{
- H5P_genplist_t *plist; /* Property list pointer */
- H5FD_direct_fapl_t fa;
- herr_t ret_value;
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5FD_direct_fapl_t fa;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_direct, FAIL)
H5TRACE4("e", "izzz", fapl_id, boundary, block_size, cbuf_size);
@@ -323,17 +323,17 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
if(boundary != 0)
- fa.mboundary = boundary;
+ fa.mboundary = boundary;
else
- fa.mboundary = MBOUNDARY_DEF;
+ fa.mboundary = MBOUNDARY_DEF;
if(block_size != 0)
- fa.fbsize = block_size;
+ fa.fbsize = block_size;
else
- fa.fbsize = FBSIZE_DEF;
+ fa.fbsize = FBSIZE_DEF;
if(cbuf_size != 0)
- fa.cbsize = cbuf_size;
+ fa.cbsize = cbuf_size;
else
- fa.cbsize = CBSIZE_DEF;
+ fa.cbsize = CBSIZE_DEF;
/* Set the default to be true for data alignment */
fa.must_align = TRUE;
@@ -350,16 +350,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_fapl_direct
+ * Function: H5Pget_fapl_direct
*
- * Purpose: Returns information about the direct file access property
- * list though the function arguments.
+ * Purpose: Returns information about the direct file access property
+ * list though the function arguments.
*
- * Return: Success: Non-negative
+ * Return: Success: Non-negative
*
- * Failure: Negative
+ * Failure: Negative
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, October 18, 2006
*
* Modifications:
@@ -368,9 +368,9 @@ done:
*/
herr_t
H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*out*/,
- size_t *cbuf_size/*out*/)
+ size_t *cbuf_size/*out*/)
{
- H5FD_direct_fapl_t *fa;
+ H5FD_direct_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* Return value */
@@ -386,9 +386,9 @@ H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*o
if (boundary)
*boundary = fa->mboundary;
if (block_size)
- *block_size = fa->fbsize;
+ *block_size = fa->fbsize;
if (cbuf_size)
- *cbuf_size = fa->cbsize;
+ *cbuf_size = fa->cbsize;
done:
FUNC_LEAVE_API(ret_value)
@@ -396,18 +396,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_fapl_get
+ * Function: H5FD_direct_fapl_get
*
- * Purpose: Returns a file access property list which indicates how the
- * specified file is being accessed. The return list could be
- * used to access another file the same way.
+ * Purpose: Returns a file access property list which indicates how the
+ * specified file is being accessed. The return list could be
+ * used to access another file the same way.
*
- * Return: Success: Ptr to new file access property list with all
- * members copied from the file struct.
+ * Return: Success: Ptr to new file access property list with all
+ * members copied from the file struct.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 18 October 2006
*
* Modifications:
@@ -417,7 +417,7 @@ done:
static void *
H5FD_direct_fapl_get(H5FD_t *_file)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_fapl_get, NULL)
@@ -431,15 +431,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_fapl_copy
+ * Function: H5FD_direct_fapl_copy
*
- * Purpose: Copies the direct-specific file access properties.
+ * Purpose: Copies the direct-specific file access properties.
*
- * Return: Success: Ptr to a new property list
+ * Return: Success: Ptr to a new property list
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 18 October 2006
*
* Modifications:
@@ -469,17 +469,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_open
+ * Function: H5FD_direct_open
*
- * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file.
+ * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file.
*
- * Return: Success: A pointer to a new file data structure. The
- * public fields will be initialized by the
- * caller, which is always H5FD_open().
+ * 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
+ * Failure: NULL
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -489,18 +489,18 @@ done:
static H5FD_t *
H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
- int o_flags;
- int fd=(-1);
- H5FD_direct_t *file=NULL;
- H5FD_direct_fapl_t *fa;
-#ifdef _WIN32
- HFILE filehandle;
+ int o_flags;
+ int fd=(-1);
+ H5FD_direct_t *file=NULL;
+ H5FD_direct_fapl_t *fa;
+#ifdef H5_HAVE_WIN32_API
+ HFILE filehandle;
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
- h5_stat_t sb;
- H5P_genplist_t *plist; /* Property list */
+ h5_stat_t sb;
+ H5P_genplist_t *plist; /* Property list */
int *buf1, *buf2;
- H5FD_t *ret_value;
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_direct_open, NULL)
@@ -544,7 +544,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
H5_ASSIGN_OVERFLOW(file->eof,sb.st_size,h5_stat_size_t,haddr_t);
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
-#ifdef _WIN32
+#ifdef H5_HAVE_WIN32_API
filehandle = _get_osfhandle(fd);
(void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo);
file->fileindexhi = fileinfo.nFileIndexHigh;
@@ -558,7 +558,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
#else
file->inode = sb.st_ino;
#endif /*H5_VMS*/
-#endif /*_WIN32*/
+#endif /*H5_HAVE_WIN32_API*/
file->fa.mboundary = fa->mboundary;
file->fa.fbsize = fa->fbsize;
file->fa.cbsize = fa->cbsize;
@@ -569,7 +569,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
*/
buf1 = (int*)HDmalloc(sizeof(int));
if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed")
if(o_flags & O_CREAT) {
if(write(file->fd, (void*)buf1, sizeof(int))<0) {
@@ -619,15 +619,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_close
+ * Function: H5FD_direct_close
*
- * Purpose: Closes the file.
+ * Purpose: Closes the file.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: -1, file not closed.
+ * Failure: -1, file not closed.
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -637,8 +637,8 @@ done:
static herr_t
H5FD_direct_close(H5FD_t *_file)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_close, FAIL)
@@ -653,17 +653,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_cmp
+ * Function: H5FD_direct_cmp
*
- * Purpose: Compares two files belonging to this driver using an
- * arbitrary (but consistent) ordering.
+ * Purpose: Compares two files belonging to this driver using an
+ * arbitrary (but consistent) ordering.
*
- * Return: Success: A value like strcmp()
+ * Return: Success: A value like strcmp()
*
- * Failure: never fails (arguments were checked by the
- * caller).
+ * Failure: never fails (arguments were checked by the
+ * caller).
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Thursday, 21 September 2006
*
* Modifications:
@@ -673,13 +673,13 @@ done:
static int
H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
- const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1;
- const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2;
+ const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1;
+ const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2;
int ret_value=0;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_direct_cmp)
-#ifdef _WIN32
+#ifdef H5_HAVE_WIN32_API
if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1)
if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1)
@@ -715,16 +715,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_query
+ * Function: H5FD_direct_query
*
- * Purpose: Set the flags that this VFL driver is capable of supporting.
+ * Purpose: Set the flags that this VFL driver is capable of supporting.
* (listed in H5FDpublic.h)
*
- * Return: Success: non-negative
+ * Return: Success: non-negative
*
- * Failure: negative
+ * Failure: negative
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Thursday, 21 September 2006
*
* Modifications:
@@ -753,17 +753,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_get_eoa
+ * Function: H5FD_direct_get_eoa
*
- * Purpose: Gets the end-of-address marker for the file. The EOA marker
- * is the first address past the last byte allocated in the
- * format address space.
+ * Purpose: Gets the end-of-address marker for the file. The EOA marker
+ * is the first address past the last byte allocated in the
+ * format address space.
*
- * Return: Success: The end-of-address marker.
+ * Return: Success: The end-of-address marker.
*
- * Failure: HADDR_UNDEF
+ * Failure: HADDR_UNDEF
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -776,7 +776,7 @@ done:
static haddr_t
H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
{
- const H5FD_direct_t *file = (const H5FD_direct_t*)_file;
+ const H5FD_direct_t *file = (const H5FD_direct_t*)_file;
haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_get_eoa, HADDR_UNDEF)
@@ -790,17 +790,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_set_eoa
+ * Function: H5FD_direct_set_eoa
*
- * Purpose: Set the end-of-address marker for the file. This function is
- * called shortly after an existing HDF5 file is opened in order
- * to tell the driver where the end of the HDF5 data is located.
+ * Purpose: Set the end-of-address marker for the file. This function is
+ * called shortly after an existing HDF5 file is opened in order
+ * to tell the driver where the end of the HDF5 data is located.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -813,7 +813,7 @@ done:
static herr_t
H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_set_eoa, FAIL)
@@ -826,19 +826,19 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_get_eof
+ * Function: H5FD_direct_get_eof
*
- * Purpose: Returns the end-of-file marker, which is the greater of
- * either the Unix end-of-file or the HDF5 end-of-address
- * markers.
+ * Purpose: Returns the end-of-file marker, which is the greater of
+ * either the Unix end-of-file or the HDF5 end-of-address
+ * markers.
*
- * Return: Success: End of file address, the first address past
- * the end of the "file", either the Unix file
- * or the HDF5 file.
+ * Return: Success: End of file address, the first address past
+ * the end of the "file", either the Unix file
+ * or the HDF5 file.
*
- * Failure: HADDR_UNDEF
+ * Failure: HADDR_UNDEF
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
* Modifications:
@@ -848,7 +848,7 @@ done:
static haddr_t
H5FD_direct_get_eof(const H5FD_t *_file)
{
- const H5FD_direct_t *file = (const H5FD_direct_t*)_file;
+ const H5FD_direct_t *file = (const H5FD_direct_t*)_file;
haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_get_eof, HADDR_UNDEF)
@@ -893,18 +893,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_read
+ * Function: H5FD_direct_read
*
- * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
- * into buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
+ * into buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero. Result is stored in caller-supplied
- * buffer BUF.
+ * Return: Success: Zero. Result is stored in caller-supplied
+ * buffer BUF.
*
- * Failure: -1, Contents of buffer BUF are undefined.
+ * Failure: -1, Contents of buffer BUF are undefined.
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Thursday, 21 September 2006
*
* Modifications:
@@ -913,19 +913,19 @@ done:
*/
static herr_t
H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, void *buf/*out*/)
+ size_t size, void *buf/*out*/)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
- ssize_t nbytes;
- hbool_t _must_align = TRUE;
- herr_t ret_value=SUCCEED; /* Return value */
- size_t alloc_size;
- void *copy_buf = NULL, *p2;
- size_t _boundary;
- size_t _fbsize;
- size_t _cbsize;
- haddr_t read_size; /* Size to read into copy buffer */
- size_t copy_size = size; /* Size remaining to read when using copy buffer */
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ ssize_t nbytes;
+ hbool_t _must_align = TRUE;
+ herr_t ret_value=SUCCEED; /* Return value */
+ size_t alloc_size;
+ void *copy_buf = NULL, *p2;
+ size_t _boundary;
+ size_t _fbsize;
+ size_t _cbsize;
+ haddr_t read_size; /* Size to read into copy buffer */
+ size_t copy_size = size; /* Size remaining to read when using copy buffer */
size_t copy_offset; /* Offset into copy buffer of the requested data */
FUNC_ENTER_NOAPI(H5FD_direct_read, FAIL)
@@ -958,44 +958,44 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha
* and aligned data first, then copy the data into memory buffer.
*/
if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) {
- /* Seek to the correct location */
- if ((addr!=file->pos || OP_READ!=file->op) &&
- file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
- HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
- /* Read the aligned data in file first, being careful of interrupted
- * system calls and partial results. */
- while (size>0) {
- do {
- nbytes = HDread(file->fd, buf, size);
- } while (-1==nbytes && EINTR==errno);
- if (-1==nbytes) /* error */
- HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
- if (0==nbytes) {
- /* end of file but not end of format address space */
- HDmemset(buf, 0, size);
- break;
- }
- assert(nbytes>=0);
- assert((size_t)nbytes<=size);
- H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t);
- size -= (size_t)nbytes;
- H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t);
- addr += (haddr_t)nbytes;
- buf = (char*)buf + nbytes;
- }
+ /* Seek to the correct location */
+ if ((addr!=file->pos || OP_READ!=file->op) &&
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
+ HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
+ /* Read the aligned data in file first, being careful of interrupted
+ * system calls and partial results. */
+ while (size>0) {
+ do {
+ nbytes = HDread(file->fd, buf, size);
+ } while (-1==nbytes && EINTR==errno);
+ if (-1==nbytes) /* error */
+ HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
+ if (0==nbytes) {
+ /* end of file but not end of format address space */
+ HDmemset(buf, 0, size);
+ break;
+ }
+ assert(nbytes>=0);
+ assert((size_t)nbytes<=size);
+ H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t);
+ size -= (size_t)nbytes;
+ H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t);
+ addr += (haddr_t)nbytes;
+ buf = (char*)buf + nbytes;
+ }
} else {
/* Calculate where we will begin copying from the copy buffer */
copy_offset = (size_t)(addr % _fbsize);
- /* allocate memory needed for the Direct IO option up to the maximal
- * copy buffer size. Make a bigger buffer for aligned I/O if size is
- * smaller than maximal copy buffer. */
- alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize;
- if(alloc_size > _cbsize)
- alloc_size = _cbsize;
- HDassert(!(alloc_size % _fbsize));
- if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
+ /* allocate memory needed for the Direct IO option up to the maximal
+ * copy buffer size. Make a bigger buffer for aligned I/O if size is
+ * smaller than maximal copy buffer. */
+ alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize;
+ if(alloc_size > _cbsize)
+ alloc_size = _cbsize;
+ HDassert(!(alloc_size % _fbsize));
+ if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
/* look for the aligned position for reading the data */
HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize));
@@ -1003,18 +1003,18 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha
SEEK_SET) < 0)
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
- /*
- * Read the aligned data in file into aligned buffer first, then copy the data
- * into the final buffer. If the data size is bigger than maximal copy buffer
- * size, do the reading by segment (the outer while loop). If not, do one step
- * reading.
- */
- do {
- /* Read the aligned data in file first. Not able to handle interrupted
- * system calls and partial results like sec2 driver does because the
- * data may no longer be aligned. It's expecially true when the data in
- * file is smaller than ALLOC_SIZE. */
- HDmemset(copy_buf, 0, alloc_size);
+ /*
+ * Read the aligned data in file into aligned buffer first, then copy the data
+ * into the final buffer. If the data size is bigger than maximal copy buffer
+ * size, do the reading by segment (the outer while loop). If not, do one step
+ * reading.
+ */
+ do {
+ /* Read the aligned data in file first. Not able to handle interrupted
+ * system calls and partial results like sec2 driver does because the
+ * data may no longer be aligned. It's expecially true when the data in
+ * file is smaller than ALLOC_SIZE. */
+ HDmemset(copy_buf, 0, alloc_size);
/* Calculate how much data we have to read in this iteration
* (including unused parts of blocks) */
@@ -1025,23 +1025,23 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha
read_size = alloc_size;
HDassert(!(read_size % _fbsize));
- do {
- nbytes = HDread(file->fd, copy_buf, read_size);
- } while(-1==nbytes && EINTR==errno);
+ do {
+ nbytes = HDread(file->fd, copy_buf, read_size);
+ } while(-1==nbytes && EINTR==errno);
- if (-1==nbytes) /* error */
- HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
+ if (-1==nbytes) /* error */
+ HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
- /* Copy the needed data from the copy buffer to the output
- * buffer, and update copy_size. If the copy buffer does not
+ /* Copy the needed data from the copy buffer to the output
+ * buffer, and update copy_size. If the copy buffer does not
* contain the rest of the data, just copy what's in the copy
* buffer and also update read_addr and copy_offset to read the
* next section of data. */
- p2 = (unsigned char*)copy_buf + copy_offset;
- if((copy_size + copy_offset) <= alloc_size) {
- HDmemcpy(buf, p2, copy_size);
- buf = (unsigned char *)buf + copy_size;
- copy_size = 0;
+ p2 = (unsigned char*)copy_buf + copy_offset;
+ if((copy_size + copy_offset) <= alloc_size) {
+ HDmemcpy(buf, p2, copy_size);
+ buf = (unsigned char *)buf + copy_size;
+ copy_size = 0;
} /* end if */
else {
HDmemcpy(buf, p2, alloc_size - copy_offset);
@@ -1049,12 +1049,12 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha
copy_size -= alloc_size - copy_offset;
copy_offset = 0;
} /* end else */
- } while (copy_size > 0);
+ } while (copy_size > 0);
- /*Final step: update address*/
- addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize);
+ /*Final step: update address*/
+ addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize);
- if(copy_buf) {
+ if(copy_buf) {
HDfree(copy_buf);
copy_buf = NULL;
} /* end if */
@@ -1079,17 +1079,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_write
+ * Function: H5FD_direct_write
*
- * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
- * from buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
+ * from buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero
+ * Return: Success: Zero
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Thursday, 21 September 2006
*
* Modifications:
@@ -1098,18 +1098,18 @@ done:
*/
static herr_t
H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, const void *buf)
+ size_t size, const void *buf)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
- ssize_t nbytes;
- hbool_t _must_align = TRUE;
- herr_t ret_value=SUCCEED; /* Return value */
- size_t alloc_size;
- void *copy_buf = NULL, *p1;
- const void *p3;
- size_t _boundary;
- size_t _fbsize;
- size_t _cbsize;
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ ssize_t nbytes;
+ hbool_t _must_align = TRUE;
+ herr_t ret_value=SUCCEED; /* Return value */
+ size_t alloc_size;
+ void *copy_buf = NULL, *p1;
+ const void *p3;
+ size_t _boundary;
+ size_t _fbsize;
+ size_t _cbsize;
haddr_t write_addr; /* Address to write copy buffer */
haddr_t write_size; /* Size to write from copy buffer */
haddr_t read_size; /* Size to read into copy buffer */
@@ -1146,49 +1146,49 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
* first, update buffer with user data, then write the data out.
*/
if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) {
- /* Seek to the correct location */
- if ((addr!=file->pos || OP_WRITE!=file->op) &&
- file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
- HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
-
- while (size>0) {
- do {
- nbytes = HDwrite(file->fd, buf, size);
- } while (-1==nbytes && EINTR==errno);
- if (-1==nbytes) /* error */
- HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
- assert(nbytes>0);
- assert((size_t)nbytes<=size);
- H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t);
- size -= (size_t)nbytes;
- H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t);
- addr += (haddr_t)nbytes;
- buf = (const char*)buf + nbytes;
- }
+ /* Seek to the correct location */
+ if ((addr!=file->pos || OP_WRITE!=file->op) &&
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
+ HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
+
+ while (size>0) {
+ do {
+ nbytes = HDwrite(file->fd, buf, size);
+ } while (-1==nbytes && EINTR==errno);
+ if (-1==nbytes) /* error */
+ HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
+ assert(nbytes>0);
+ assert((size_t)nbytes<=size);
+ H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t);
+ size -= (size_t)nbytes;
+ H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t);
+ addr += (haddr_t)nbytes;
+ buf = (const char*)buf + nbytes;
+ }
} else {
/* Calculate where we will begin reading from (on disk) and where we
* will begin copying from the copy buffer */
write_addr = (addr / _fbsize) * _fbsize;
copy_offset = (size_t)(addr % _fbsize);
- /* allocate memory needed for the Direct IO option up to the maximal
- * copy buffer size. Make a bigger buffer for aligned I/O if size is
- * smaller than maximal copy buffer.
- */
- alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize;
+ /* allocate memory needed for the Direct IO option up to the maximal
+ * copy buffer size. Make a bigger buffer for aligned I/O if size is
+ * smaller than maximal copy buffer.
+ */
+ alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize;
if(alloc_size > _cbsize)
alloc_size = _cbsize;
HDassert(!(alloc_size % _fbsize));
- if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
+ if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
/* look for the right position for reading or writing the data */
if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0)
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
- p3 = buf;
- do {
+ p3 = buf;
+ do {
/* Calculate how much data we have to write in this iteration
* (including unused parts of blocks) */
if((copy_size + copy_offset) < alloc_size)
@@ -1197,16 +1197,16 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
else
write_size = alloc_size;
- /*
- * Read the aligned data first if the aligned region doesn't fall
- * entirely in the range to be writen. Not able to handle interrupted
- * system calls and partial results like sec2 driver does because the
- * data may no longer be aligned. It's expecially true when the data in
- * file is smaller than ALLOC_SIZE. Only read the entire section if
+ /*
+ * Read the aligned data first if the aligned region doesn't fall
+ * entirely in the range to be writen. Not able to handle interrupted
+ * system calls and partial results like sec2 driver does because the
+ * data may no longer be aligned. It's expecially true when the data in
+ * file is smaller than ALLOC_SIZE. Only read the entire section if
* both ends are misaligned, otherwise only read the block on the
* misaligned end.
- */
- HDmemset(copy_buf, 0, _fbsize);
+ */
+ HDmemset(copy_buf, 0, _fbsize);
if(copy_offset > 0) {
if((write_addr + write_size) > (addr + size)) {
@@ -1244,14 +1244,14 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
} /* end if */
- /* look for the right position and append or copy the data to be written to
- * the aligned buffer.
- * Consider all possible situations here: file address is not aligned on
- * file block size; the end of data address is not aligned; the end of data
- * address is aligned; data size is smaller or bigger than maximal copy size.
- */
- p1 = (unsigned char *)copy_buf + copy_offset;
- if((copy_size + copy_offset) <= alloc_size) {
+ /* look for the right position and append or copy the data to be written to
+ * the aligned buffer.
+ * Consider all possible situations here: file address is not aligned on
+ * file block size; the end of data address is not aligned; the end of data
+ * address is aligned; data size is smaller or bigger than maximal copy size.
+ */
+ p1 = (unsigned char *)copy_buf + copy_offset;
+ if((copy_size + copy_offset) <= alloc_size) {
HDmemcpy(p1, p3, copy_size);
copy_size = 0;
} /* end if */
@@ -1262,34 +1262,34 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
copy_offset = 0;
} /* end else */
- /*look for the aligned position for writing the data*/
- HDassert(!(write_addr % _fbsize));
- if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0)
- HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
-
- /*
- * Write the data. It doesn't truncate the extra data introduced by
- * alignment because that step is done in H5FD_direct_flush.
- */
- HDassert(!(write_size % _fbsize));
- do {
- nbytes = HDwrite(file->fd, copy_buf, write_size);
- } while (-1==nbytes && EINTR==errno);
-
- if (-1==nbytes) /* error */
- HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
-
- /* update the write address */
- write_addr += write_size;
- } while (copy_size > 0);
-
- /*Update the address and size*/
- addr = write_addr;
- buf = (const char*)buf + size;
-
- if(copy_buf) {
- HDfree(copy_buf);
- copy_buf = NULL;
+ /*look for the aligned position for writing the data*/
+ HDassert(!(write_addr % _fbsize));
+ if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0)
+ HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
+
+ /*
+ * Write the data. It doesn't truncate the extra data introduced by
+ * alignment because that step is done in H5FD_direct_flush.
+ */
+ HDassert(!(write_size % _fbsize));
+ do {
+ nbytes = HDwrite(file->fd, copy_buf, write_size);
+ } while (-1==nbytes && EINTR==errno);
+
+ if (-1==nbytes) /* error */
+ HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
+
+ /* update the write address */
+ write_addr += write_size;
+ } while (copy_size > 0);
+
+ /*Update the address and size*/
+ addr = write_addr;
+ buf = (const char*)buf + size;
+
+ if(copy_buf) {
+ HDfree(copy_buf);
+ copy_buf = NULL;
} /* end if */
}
@@ -1314,16 +1314,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_truncate
+ * Function: H5FD_direct_truncate
*
- * Purpose: Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
+ * Purpose: Makes sure that the true file size is the same (or larger)
+ * than the end-of-address.
*
- * Return: Success: Non-negative
+ * Return: Success: Non-negative
*
- * Failure: Negative
+ * Failure: Negative
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* Thursday, 21 September 2006
*
*-------------------------------------------------------------------------
@@ -1331,8 +1331,8 @@ done:
static herr_t
H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_direct_t *file = (H5FD_direct_t*)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_direct_truncate, FAIL)
@@ -1340,7 +1340,7 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing
/* Extend the file to make sure it's large enough */
if (file->eoa!=file->eof) {
-#ifdef _WIN32
+#ifdef H5_HAVE_WIN32_API
HFILE filehandle; /* Windows file handle */
LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */
@@ -1353,10 +1353,10 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing
(void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN);
if(SetEndOfFile((HANDLE)filehandle)==0)
HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly")
-#else /* _WIN32 */
+#else /* H5_HAVE_WIN32_API */
if (-1==file_truncate(file->fd, (file_offset_t)file->eoa))
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly")
-#endif /* _WIN32 */
+#endif /* H5_HAVE_WIN32_API */
/* Update the eof value */
file->eof = file->eoa;
@@ -1366,9 +1366,9 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing
file->op = OP_UNKNOWN;
}
else if (file->fa.must_align){
- /*Even though eof is equal to eoa, file is still truncated because Direct I/O
- *write introduces some extra data for alignment.
- */
+ /*Even though eof is equal to eoa, file is still truncated because Direct I/O
+ *write introduces some extra data for alignment.
+ */
if (-1==file_truncate(file->fd, (file_offset_t)file->eof))
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly")
}