aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win32/mingw.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 98254fdbe..4398f5462 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -225,7 +225,7 @@ static int mingw_is_directory(const char *path);
225int mingw_open (const char *filename, int oflags, ...) 225int mingw_open (const char *filename, int oflags, ...)
226{ 226{
227 va_list args; 227 va_list args;
228 unsigned mode; 228 int pmode, mode = 0666;
229 int fd; 229 int fd;
230 int special = (oflags & O_SPECIAL); 230 int special = (oflags & O_SPECIAL);
231 int dev = get_dev_type(filename); 231 int dev = get_dev_type(filename);
@@ -243,7 +243,10 @@ int mingw_open (const char *filename, int oflags, ...)
243 mode = va_arg(args, int); 243 mode = va_arg(args, int);
244 va_end(args); 244 va_end(args);
245 245
246 fd = open(filename, oflags&~O_SPECIAL, mode); 246 pmode = ((mode & S_IWUSR) ? _S_IWRITE : 0) |
247 ((mode & S_IRUSR) ? _S_IREAD : 0);
248
249 fd = open(filename, oflags&~O_SPECIAL, pmode);
247 if (fd >= 0) { 250 if (fd >= 0) {
248 update_special_fd(dev, fd); 251 update_special_fd(dev, fd);
249 } 252 }
@@ -2189,12 +2192,14 @@ size_t FAST_FUNC remove_cr(char *p, size_t len)
2189 2192
2190off_t mingw_lseek(int fd, off_t offset, int whence) 2193off_t mingw_lseek(int fd, off_t offset, int whence)
2191{ 2194{
2195 DWORD ftype;
2192 HANDLE h = (HANDLE)_get_osfhandle(fd); 2196 HANDLE h = (HANDLE)_get_osfhandle(fd);
2193 if (h == INVALID_HANDLE_VALUE) { 2197 if (h == INVALID_HANDLE_VALUE) {
2194 errno = EBADF; 2198 errno = EBADF;
2195 return -1; 2199 return -1;
2196 } 2200 }
2197 if (GetFileType(h) != FILE_TYPE_DISK) { 2201 ftype = GetFileType(h);
2202 if (ftype != FILE_TYPE_DISK && ftype != FILE_TYPE_CHAR) {
2198 errno = ESPIPE; 2203 errno = ESPIPE;
2199 return -1; 2204 return -1;
2200 } 2205 }