From 734aebc39538039c6e81db63edd68eb3a2029cd2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 28 Apr 2017 18:13:22 -0400 Subject: Rework of the POSIX file open permissions and macros to clean up HDopen() calls. Also fixed a minor const warning in the core VFD. --- src/H5Defl.c | 4 ++-- src/H5FDcore.c | 10 +++++----- src/H5FDdirect.c | 2 +- src/H5FDlog.c | 2 +- src/H5FDsec2.c | 2 +- src/H5private.h | 21 ++++----------------- src/H5win32defs.h | 5 ++++- test/big.c | 6 +++--- test/btree2.c | 8 ++++---- test/dsets.c | 4 ++-- test/enc_dec_plist_cross_platform.c | 4 ++-- test/external.c | 8 ++++---- test/file_image.c | 6 +++--- test/fillval.c | 2 +- test/gen_plist.c | 14 +++++++------- test/h5test.c | 4 ++-- test/istore.c | 2 +- test/links.c | 12 ++++++------ test/tfile.c | 8 ++++---- test/twriteorder.c | 12 ++++++------ tools/src/h5jam/h5jam.c | 8 ++++---- tools/src/h5repack/h5repack_copy.c | 6 +++--- tools/src/misc/h5repart.c | 24 ++++++++++++------------ tools/test/h5jam/h5jamgentest.c | 2 +- tools/test/h5repack/h5repacktst.c | 6 +++--- 25 files changed, 86 insertions(+), 96 deletions(-) diff --git a/src/H5Defl.c b/src/H5Defl.c index 93bf2b2..ebe7689 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -288,7 +288,7 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_RDONLY, H5_POSIX_OPEN_MODE_0000)) < 0) + if((fd = HDopen(full_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") @@ -380,7 +380,7 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_OPEN_MODE_0666)) < 0) { + if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { if(HDaccess(full_name, F_OK) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") else diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 6c22f69..43d5894 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -598,7 +598,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr { int o_flags; H5FD_core_t *file = NULL; - H5FD_core_fapl_t *fa = NULL; + const H5FD_core_fapl_t *fa = NULL; H5P_genplist_t *plist; /* Property list pointer */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; @@ -620,7 +620,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr HDassert(H5P_DEFAULT != fapl_id); if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Build the open flags */ @@ -638,7 +638,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); HDmemset(&sb, 0, sizeof(sb)); if((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { - if(HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666) >= 0) + if(HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists") /* If backing store is requested, create and stat the file @@ -646,7 +646,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr * technically an open. */ if(fa->backing_store) { - if((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") @@ -656,7 +656,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr * store is off is when the backing_store flag is off and H5F_ACC_CREAT is * on. */ else if(fa->backing_store || !(H5F_ACC_CREAT & flags)) { - if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 79a5e8a..060947e 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -487,7 +487,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd o_flags |= O_DIRECT; /* Open the file */ - if ((fd=HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666))<0) + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW))<0) HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") if (HDfstat(fd, &sb)<0) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 6e5a57b..bccf3cc 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -520,7 +520,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 0) { + if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 71657b6..3bbf592 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -341,7 +341,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) o_flags |= O_EXCL; /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 0) { + if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ diff --git a/src/H5private.h b/src/H5private.h index fc15e99..ca4ebcf 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -495,22 +495,13 @@ # define H5_POSIX_MAX_IO_BYTES SSIZET_MAX #endif -/* POSIX I/O mode used as the fourth parameter to open/_open +/* POSIX I/O mode used as the third parameter to open/_open * when creating a new file (O_CREAT is set). - * - * It's a little awkward to put the Unix file permissions - * in the symbol name, but that is what is most important - * and we only need the symbol to handle Windows' less-capable - * system. */ #if defined(H5_HAVE_WIN32_API) -# define H5_POSIX_OPEN_MODE_0666 (_S_IREAD | _S_IWRITE) -# define H5_POSIX_OPEN_MODE_0644 _S_IREAD -# define H5_POSIX_OPEN_MODE_0000 0 +# define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE) #else -# define H5_POSIX_OPEN_MODE_0666 0666 -# define H5_POSIX_OPEN_MODE_0644 0644 -# define H5_POSIX_OPEN_MODE_0000 0000 +# define H5_POSIX_CREATE_MODE_RW 0666 #endif /* @@ -1135,11 +1126,7 @@ typedef off_t h5_stat_size_t; #define HDnanosleep(N, O) nanosleep(N, O) #endif /* HDnanosleep */ #ifndef HDopen - #ifdef _O_BINARY - #define HDopen(S,F,M) open(S,F|_O_BINARY,M) - #else - #define HDopen(S,F,M) open(S,F,M) - #endif + #define HDopen(F,...) open(F,__VA_ARGS__) #endif /* HDopen */ #ifndef HDopendir #define HDopendir(S) opendir(S) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 771b6fc..97f7179 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -50,8 +50,11 @@ typedef __int64 h5_stat_size_t; /* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL * transformations when performing I/O. Note that this will * produce Unix-style text files, though. + * + * Also note that the variadic macro is using a VC++ extension + * where the comma is dropped if nothing is passed to the ellipsis. */ -#define HDopen(S,F,M) _open(S,F|_O_BINARY,M) +#define HDopen(S,F,...) _open(S, F | _O_BINARY, __VA_ARGS__) #define HDread(F,M,Z) _read(F,M,Z) #define HDrmdir(S) _rmdir(S) #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) diff --git a/test/big.c b/test/big.c index 274c00b..fe52aef 100644 --- a/test/big.c +++ b/test/big.c @@ -172,7 +172,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; @@ -210,7 +210,7 @@ supports_big(void) int fd = -1; fsizes_t fsize = NO_FILE; - if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write a few byte at the beginning */ @@ -293,7 +293,7 @@ enough_room(hid_t fapl) /* Create files */ for (i=0; ifree_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); /* Create file image buffer */ - fd = HDopen(copied_filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(copied_filename, O_RDONLY); VERIFY(fd > 0, "open failed"); ret = HDfstat(fd, &sb); VERIFY(ret == 0, "fstat failed"); @@ -814,7 +814,7 @@ test_get_file_image(const char * test_banner, HDsnprintf(member_file_name, 1024, file_name, i); /* open the test file using standard I/O calls */ - fd = HDopen(member_file_name, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(member_file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(size_remaining >= FAMILY_SIZE ){ @@ -862,7 +862,7 @@ test_get_file_image(const char * test_banner, VERIFY(file_image_ptr != NULL, "HDmalloc(2) failed."); /* open the test file using standard I/O calls */ - fd = HDopen(file_name, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(user) { diff --git a/test/fillval.c b/test/fillval.c index 8f1f53d..8c8e902 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1890,7 +1890,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) hsize_t nelmts; nelmts = max_size[0]*max_size[1]*max_size[2]*max_size[3]*max_size[4]; - if((fd=HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0 || + if((fd = HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || HDclose(fd) < 0) goto error; if(H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts*sizeof(int)) < 0) goto error; diff --git a/test/gen_plist.c b/test/gen_plist.c index 41f232d..62693bd 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -463,23 +463,23 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil /* Generate filename */ if((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, little_endian ? "le" : "be")) < 0) - assert(ret > 0); + HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); - assert(temp_buf); + HDassert(temp_buf); if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); - fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, 0666); - assert(fd > 0); + fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + HDassert(fd > 0); write_size = HDwrite(fd, temp_buf, temp_size); - assert(write_size == (ssize_t)temp_size); + HDassert(write_size == (ssize_t)temp_size); HDclose(fd); diff --git a/test/h5test.c b/test/h5test.c index a5cd674..8db4388 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1596,9 +1596,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) goto error; /* Copy old file into temporary file */ - if((fd_old = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd_old = HDopen(filename, O_RDONLY)) < 0) goto error; - if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Copy data */ diff --git a/test/istore.c b/test/istore.c index 18cf1de..c401e87 100644 --- a/test/istore.c +++ b/test/istore.c @@ -73,7 +73,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; diff --git a/test/links.c b/test/links.c index 2d1ef03..7b3e37d 100644 --- a/test/links.c +++ b/test/links.c @@ -3730,7 +3730,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout") if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) - TEST_ERROR + TEST_ERROR /* * set up name for main file: @@ -3780,7 +3780,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Create external link to target file: ext_link->extlinks17:/A/Dataset */ if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* create fapl to be a "core" file without backing store */ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) @@ -3793,9 +3793,9 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* try to open the external linked target dataset */ did = H5Dopen2(fid, "ext_link", dapl_id); if(did < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening the target dataset"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening the target dataset"); + goto error; } /* Initialize the dataset */ @@ -3805,7 +3805,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Write the data to the dataset */ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) - TEST_ERROR + TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR diff --git a/test/tfile.c b/test/tfile.c index 2d26874..50e3341 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1611,7 +1611,7 @@ test_file_ishdf5(void) /* Create non-HDF5 file and check it */ - fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd, FAIL, "HDopen"); /* Initialize information to write */ @@ -2657,7 +2657,7 @@ cal_chksum(const char *file, uint32_t *chksum) herr_t ret; /* Generic return value */ /* Open the file */ - fdes = HDopen(file, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + fdes = HDopen(file, O_RDONLY); CHECK(fdes, FAIL, "HDopen"); /* Retrieve the file's size */ @@ -4340,9 +4340,9 @@ test_filespace_compatible(void) const char *filename = H5_get_srcdir_filename(OLD_FILENAME[j]); /* Corrected test file name */ /* Open and copy the test file into a temporary file */ - fd_old = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd_old = HDopen(filename, O_RDONLY); CHECK(fd_old, FAIL, "HDopen"); - fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666); + fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd_new, FAIL, "HDopen"); /* Copy data */ diff --git a/test/twriteorder.c b/test/twriteorder.c index 3ecd3e0..4c86636 100644 --- a/test/twriteorder.c +++ b/test/twriteorder.c @@ -231,9 +231,9 @@ int create_wo_file(void) int ret_code; /* Create the data file */ - if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) { - printf("WRITER: error from open\n"); - return -1; + if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) { + HDprintf("WRITER: error from open\n"); + return -1; } blkaddr=0; /* write it to partition 0 */ @@ -297,9 +297,9 @@ int read_wo_file(void) char buffer[BLOCKSIZE_DFT]; /* Open the data file */ - if ((read_fd = HDopen(DATAFILE, O_RDONLY, H5_POSIX_OPEN_MODE_0000)) < 0) { - printf("READER: error from open\n"); - return -1; + if ((read_fd = HDopen(DATAFILE, O_RDONLY)) < 0) { + HDprintf("READER: error from open\n"); + return -1; } /* keep reading the initial block address until it is non-zero before proceeding. */ while (blkaddr == 0){ diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index f41f8dc..a403cf1 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -292,7 +292,7 @@ main (int argc, const char *argv[]) H5Pclose(plist); H5Fclose(ifile); - ufid = HDopen(ub_file, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + ufid = HDopen(ub_file, O_RDONLY); if(ufid < 0) { error_msg("unable to open user block file \"%s\"\n", ub_file); leave (EXIT_FAILURE); @@ -307,7 +307,7 @@ main (int argc, const char *argv[]) fsize = (off_t)sbuf.st_size; - h5fid = HDopen(input_file, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + h5fid = HDopen(input_file, O_RDONLY); if(h5fid < 0) { error_msg("unable to open HDF5 file for read \"%s\"\n", input_file); HDclose (ufid); @@ -325,7 +325,7 @@ main (int argc, const char *argv[]) h5fsize = (hsize_t)sbuf2.st_size; if (output_file == NULL) { - ofid = HDopen (input_file, O_WRONLY, H5_POSIX_OPEN_MODE_0000); + ofid = HDopen(input_file, O_WRONLY); if (ofid < 0) { error_msg("unable to open output file \"%s\"\n", output_file); @@ -335,7 +335,7 @@ main (int argc, const char *argv[]) } } else { - ofid = HDopen (output_file, O_WRONLY | O_CREAT | O_TRUNC, H5_POSIX_OPEN_MODE_0644); + ofid = HDopen(output_file, O_WRONLY | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); if (ofid < 0) { error_msg("unable to create output file \"%s\"\n", output_file); diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 604e85f..e7c3bfe 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -1471,9 +1471,9 @@ static int copy_user_block(const char *infile, const char *outfile, HDassert(size > 0); /* Open files */ - if ((infid = HDopen(infile, O_RDONLY, 0)) < 0) + if ((infid = HDopen(infile, O_RDONLY)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed"); - if ((outfid = HDopen(outfile, O_WRONLY, 0644)) < 0) + if ((outfid = HDopen(outfile, O_WRONLY)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed"); /* Copy the userblock from the input file to the output file */ @@ -1565,7 +1565,7 @@ void print_user_block(const char *filename, hid_t fid) } /* open file */ - if((fh = HDopen(filename, O_RDONLY, 0)) < 0) { + if((fh = HDopen(filename, O_RDONLY)) < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed"); } diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c index 911e0c6..4432621 100644 --- a/tools/src/misc/h5repart.c +++ b/tools/src/misc/h5repart.c @@ -262,9 +262,9 @@ main (int argc, char *argv[]) sprintf (src_name, src_gen_name, src_membno); src_is_family = strcmp (src_name, src_gen_name); - if ((src=HDopen(src_name, O_RDONLY,0))<0) { - perror (src_name); - exit (EXIT_FAILURE); + if ((src = HDopen(src_name, O_RDONLY)) < 0) { + HDperror(src_name); + HDexit(EXIT_FAILURE); } if (HDfstat(src, &sb)<0) { @@ -282,9 +282,9 @@ main (int argc, char *argv[]) sprintf (dst_name, dst_gen_name, dst_membno); dst_is_family = strcmp (dst_name, dst_gen_name); - if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { - perror (dst_name); - exit (EXIT_FAILURE); + if ((dst = HDopen(dst_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { + HDperror(dst_name); + HDexit(EXIT_FAILURE); } if (verbose) fprintf (stderr, "> %s\n", dst_name); @@ -363,9 +363,9 @@ main (int argc, char *argv[]) break; } sprintf (src_name, src_gen_name, ++src_membno); - if ((src=HDopen (src_name, O_RDONLY,0))<0 && ENOENT==errno) { - dst_offset = dst_offset + (off_t)n; - break; + if ((src = HDopen(src_name, O_RDONLY)) < 0 && ENOENT == errno) { + dst_offset = dst_offset + (off_t)n; + break; } else if (src<0) { perror (src_name); exit (EXIT_FAILURE); @@ -410,9 +410,9 @@ main (int argc, char *argv[]) } HDclose (dst); sprintf (dst_name, dst_gen_name, ++dst_membno); - if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { - perror (dst_name); - exit (EXIT_FAILURE); + if ((dst = HDopen(dst_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { + HDperror(dst_name); + HDexit(EXIT_FAILURE); } dst_offset = 0; need_seek = FALSE; diff --git a/tools/test/h5jam/h5jamgentest.c b/tools/test/h5jam/h5jamgentest.c index 8648f07..d713bb9 100644 --- a/tools/test/h5jam/h5jamgentest.c +++ b/tools/test/h5jam/h5jamgentest.c @@ -277,7 +277,7 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill) HDassert(ub_size <= BUF_SIZE); - fd = HDopen(filename, O_RDWR, 0); + fd = HDopen(filename, O_RDWR); HDassert(fd >= 0); /* fill buf with pattern */ diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index 3b82383..09183f1 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -3755,7 +3755,7 @@ make_userblock(void) ub[u] = (char)('a' + (char)(u % 26)); /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(FNAME16, O_WRONLY, 0644)) < 0) + if((fd = HDopen(FNAME16, O_WRONLY)) < 0) goto out; /* Write userblock data */ @@ -3819,7 +3819,7 @@ verify_userblock( const char* filename) /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) + if((fd = HDopen(filename, O_RDONLY)) < 0) goto out; /* Read userblock data */ @@ -3868,7 +3868,7 @@ make_userblock_file(void) ub[u] = (char)('a' + (char)(u % 26)); /* open file */ - if((fd = HDopen(FNAME_UB,O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0) + if((fd = HDopen(FNAME_UB, O_WRONLY|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto out; /* write userblock data */ -- cgit v0.12