summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Defl.c4
-rw-r--r--src/H5FDcore.c6
-rw-r--r--src/H5FDdirect.c2
-rw-r--r--src/H5FDlog.c2
-rw-r--r--src/H5FDsec2.c2
-rw-r--r--src/H5private.h18
-rw-r--r--src/H5win32defs.h3
7 files changed, 28 insertions, 9 deletions
diff --git a/src/H5Defl.c b/src/H5Defl.c
index 5536ba3..93bf2b2 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, 0)) < 0)
+ if((fd = HDopen(full_name, O_RDONLY, H5_POSIX_OPEN_MODE_0000)) < 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, 0666)) < 0) {
+ if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_OPEN_MODE_0666)) < 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 d100a8b..6c22f69 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -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, 0666) >= 0)
+ if(HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666) >= 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, 0666)) < 0)
+ if((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 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, 0666)) < 0)
+ if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 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 1487cda..79a5e8a 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, 0666))<0)
+ if ((fd=HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666))<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 75333c2..6e5a57b 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, 0666)) < 0) {
+ if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 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 26913e2..71657b6 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, 0666)) < 0) {
+ if((fd = HDopen(name, o_flags, H5_POSIX_OPEN_MODE_0666)) < 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 c588154..fc15e99 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -495,6 +495,24 @@
# define H5_POSIX_MAX_IO_BYTES SSIZET_MAX
#endif
+/* POSIX I/O mode used as the fourth 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
+#else
+# define H5_POSIX_OPEN_MODE_0666 0666
+# define H5_POSIX_OPEN_MODE_0644 0644
+# define H5_POSIX_OPEN_MODE_0000 0000
+#endif
+
/*
* A macro to portably increment enumerated types.
*/
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 0149faa..771b6fc 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -48,7 +48,8 @@ typedef __int64 h5_stat_size_t;
#define HDnanosleep(N, O) Wnanosleep(N, O)
#define HDoff_t __int64
/* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL
- * transformations when performing I/O.
+ * transformations when performing I/O. Note that this will
+ * produce Unix-style text files, though.
*/
#define HDopen(S,F,M) _open(S,F|_O_BINARY,M)
#define HDread(F,M,Z) _read(F,M,Z)