Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-02-25 20:47:51 +0300
committerCorinna Vinschen <corinna@vinschen.de>2002-02-25 20:47:51 +0300
commitacb5617538e84e84825b6a4b917e07efc98187f9 (patch)
tree26f7ce6ed7a35c321ea6f9c716b17b0bdebe6167 /winsup
parent5a909729b1740fa96cf736db19b2cd6d80739244 (diff)
* cygwin.din (fstat64): New symbol.
(ftruncate64): Ditto. (lseek64): Ditto. (lstat64): Ditto. (mmap64): Ditto. (seekdir64): Ditto. (stat64): Ditto. (telldir64): Ditto. (truncate64): Ditto. * dir.cc (telldir64): New function. (telldir): Call telldir64(). (seekdir64): New function. (seekdir): Call seekdir64(). * fhandler.h: Redefine all methods using __off32_t to use __off64_t. * fhandler.cc: Use __off64_t and struct __stat64 throughout. * fhandler_clipboard.cc: Ditto. * fhandler_disk_file.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_floppy.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_socket.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_zero.cc: Ditto. * pipe.cc: Ditto. * glob.c: Ditto, call lstat64 and stat64 in Cygwin. * mmap.cc: Use __off64_t throughout. (mmap64): New function. * sec_acl.cc (acl_worker): Use struct __stat64, call stat64 and lstat64. * syscalls.cc (lseek64): New function. (stat64_to_stat32): Ditto. (fstat64): Ditto. (stat64): Ditto. (lstat64): Ditto. (ftruncate64): Ditto. (truncate64): Ditto. (_fstat): Call fstat64. (_stat): Call stat64. (cygwin_lstat): Rename to avoid declaration problem. Call lstat64. (stat_worker): Use struct __stat64. (access): Ditto. (ftruncate): Call ftruncate64. (truncate): Call truncate64. * wincap.cc: Set flag has_64bit_file_access appropriately. * wincap.h: Add flag has_64bit_file_access. * winsup.h (ILLEGAL_SEEK): Define as __off64_t. (stat_dev): Declare using struct __stat64. (stat_worker): Ditto. * include/cygwin/stat.h (struct __stat32): Define if compiling Cygwin. (struct __stat64): Ditto. (struct stat): Revert definition with explicitly sized datatypes. Eliminate sized field names. * include/cygwin/types.h (blksize_t): New type. (__blkcnt32_t): Ditto. (__blkcnt64_t): Ditto. (blkcnt_t): Ditto.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog59
-rw-r--r--winsup/cygwin/cygwin.din13
-rw-r--r--winsup/cygwin/dir.cc22
-rw-r--r--winsup/cygwin/fhandler.cc91
-rw-r--r--winsup/cygwin/fhandler.h64
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc4
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc52
-rw-r--r--winsup/cygwin/fhandler_dsp.cc4
-rw-r--r--winsup/cygwin/fhandler_floppy.cc38
-rw-r--r--winsup/cygwin/fhandler_mem.cc12
-rw-r--r--winsup/cygwin/fhandler_random.cc4
-rw-r--r--winsup/cygwin/fhandler_socket.cc2
-rw-r--r--winsup/cygwin/fhandler_tape.cc6
-rw-r--r--winsup/cygwin/fhandler_zero.cc4
-rw-r--r--winsup/cygwin/glob.c12
-rw-r--r--winsup/cygwin/include/cygwin/stat.h95
-rw-r--r--winsup/cygwin/include/cygwin/types.h10
-rw-r--r--winsup/cygwin/mmap.cc48
-rw-r--r--winsup/cygwin/pipe.cc4
-rw-r--r--winsup/cygwin/sec_acl.cc6
-rw-r--r--winsup/cygwin/syscalls.cc102
-rw-r--r--winsup/cygwin/wincap.cc11
-rw-r--r--winsup/cygwin/wincap.h2
-rw-r--r--winsup/cygwin/winsup.h6
24 files changed, 433 insertions, 238 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7b5ad1c2c..fab0f335c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,62 @@
+2002-02-23 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygwin.din (fstat64): New symbol.
+ (ftruncate64): Ditto.
+ (lseek64): Ditto.
+ (lstat64): Ditto.
+ (mmap64): Ditto.
+ (seekdir64): Ditto.
+ (stat64): Ditto.
+ (telldir64): Ditto.
+ (truncate64): Ditto.
+ * dir.cc (telldir64): New function.
+ (telldir): Call telldir64().
+ (seekdir64): New function.
+ (seekdir): Call seekdir64().
+ * fhandler.h: Redefine all methods using __off32_t to use __off64_t.
+ * fhandler.cc: Use __off64_t and struct __stat64 throughout.
+ * fhandler_clipboard.cc: Ditto.
+ * fhandler_disk_file.cc: Ditto.
+ * fhandler_dsp.cc: Ditto.
+ * fhandler_floppy.cc: Ditto.
+ * fhandler_mem.cc: Ditto.
+ * fhandler_random.cc: Ditto.
+ * fhandler_socket.cc: Ditto.
+ * fhandler_tape.cc: Ditto.
+ * fhandler_zero.cc: Ditto.
+ * pipe.cc: Ditto.
+ * glob.c: Ditto, call lstat64 and stat64 in Cygwin.
+ * mmap.cc: Use __off64_t throughout.
+ (mmap64): New function.
+ * sec_acl.cc (acl_worker): Use struct __stat64, call stat64 and lstat64.
+ * syscalls.cc (lseek64): New function.
+ (stat64_to_stat32): Ditto.
+ (fstat64): Ditto.
+ (stat64): Ditto.
+ (lstat64): Ditto.
+ (ftruncate64): Ditto.
+ (truncate64): Ditto.
+ (_fstat): Call fstat64.
+ (_stat): Call stat64.
+ (cygwin_lstat): Rename to avoid declaration problem. Call lstat64.
+ (stat_worker): Use struct __stat64.
+ (access): Ditto.
+ (ftruncate): Call ftruncate64.
+ (truncate): Call truncate64.
+ * wincap.cc: Set flag has_64bit_file_access appropriately.
+ * wincap.h: Add flag has_64bit_file_access.
+ * winsup.h (ILLEGAL_SEEK): Define as __off64_t.
+ (stat_dev): Declare using struct __stat64.
+ (stat_worker): Ditto.
+ * include/cygwin/stat.h (struct __stat32): Define if compiling Cygwin.
+ (struct __stat64): Ditto.
+ (struct stat): Revert definition with explicitly sized datatypes.
+ Eliminate sized field names.
+ * include/cygwin/types.h (blksize_t): New type.
+ (__blkcnt32_t): Ditto.
+ (__blkcnt64_t): Ditto.
+ (blkcnt_t): Ditto.
+
2002-02-22 Christopher Faylor <cgf@redhat.com>
* sync.h (new_muto): Just accept an argument which denotes the name of
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 4f98f2828..e2bf1fa43 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -304,6 +304,7 @@ fsetpos
_fsetpos = fsetpos
fstat
_fstat = fstat
+fstat64
fstatfs
_fstatfs = fstatfs
fsync
@@ -318,6 +319,7 @@ ftime
_ftime = ftime
ftruncate
_ftruncate = ftruncate
+ftruncate64
fwrite
_fwrite = fwrite
gamma
@@ -510,8 +512,10 @@ longjmp
_longjmp = longjmp
lseek
_lseek = lseek
-lstat
-_lstat = lstat
+lseek64
+lstat = cygwin_lstat
+_lstat = cygwin_lstat
+lstat64
malloc = export_malloc
_malloc = export_malloc
matherr
@@ -544,6 +548,7 @@ _mktemp = mktemp
mktime
_mktime = mktime
mmap
+mmap64
mprotect
msync
munmap
@@ -646,6 +651,7 @@ _scanf_r
scanf_r = _scanf_r
seekdir
_seekdir = seekdir
+seekdir64
setbuf
_setbuf = setbuf
setdtablesize
@@ -745,6 +751,7 @@ _sscanf_r
sscanf_r = _sscanf_r
stat
_stat = stat
+stat64
statfs
_statfs = statfs
strcasecmp
@@ -841,6 +848,7 @@ tcsetpgrp
_tcsetpgrp = tcsetpgrp
telldir
_telldir = telldir
+telldir64
tempnam
_tempnam = tempnam
time
@@ -860,6 +868,7 @@ toupper
_toupper = toupper
truncate
_truncate = truncate
+truncate64
ttyname
_ttyname = ttyname
tzset
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index e3fd896dc..0294c09ca 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -118,9 +118,8 @@ readdir (DIR *dir)
return ((fhandler_base *) dir->__d_u.__d_data.__fh)->readdir (dir);
}
-/* telldir */
-extern "C" __off32_t
-telldir (DIR *dir)
+extern "C" __off64_t
+telldir64 (DIR *dir)
{
if (check_null_invalid_struct_errno (dir))
return -1;
@@ -130,9 +129,15 @@ telldir (DIR *dir)
return ((fhandler_base *) dir->__d_u.__d_data.__fh)->telldir (dir);
}
-/* seekdir */
+/* telldir */
+extern "C" __off32_t
+telldir (DIR *dir)
+{
+ return telldir64 (dir);
+}
+
extern "C" void
-seekdir (DIR *dir, __off32_t loc)
+seekdir64 (DIR *dir, __off64_t loc)
{
if (check_null_invalid_struct_errno (dir))
return;
@@ -142,6 +147,13 @@ seekdir (DIR *dir, __off32_t loc)
return ((fhandler_base *) dir->__d_u.__d_data.__fh)->seekdir (dir, loc);
}
+/* seekdir */
+extern "C" void
+seekdir (DIR *dir, __off32_t loc)
+{
+ seekdir64 (dir, (__off64_t)loc);
+}
+
/* rewinddir: POSIX 5.1.2.1 */
extern "C" void
rewinddir (DIR *dir)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index b458049ba..cb74ffa28 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -27,6 +27,7 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include <assert.h>
+#include <limits.h>
static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */
@@ -693,10 +694,22 @@ fhandler_base::write (const void *ptr, size_t len)
return res;
}
-__off32_t
-fhandler_base::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_base::lseek (__off64_t offset, int whence)
{
- __off32_t res;
+ __off64_t res;
+
+ /* 9x/Me doesn't support 64bit offsets. We trap that here and return
+ EINVAL. It doesn't make sense to simulate bigger offsets by a
+ SetFilePointer sequence since FAT and FAT32 don't support file
+ size >= 4GB anyway. */
+ if (!wincap.has_64bit_file_access ()
+ && (offset < LONG_MIN || offset > LONG_MAX))
+ {
+ debug_printf ("Win9x, offset not 32 bit.");
+ set_errno (EINVAL);
+ return (__off64_t)-1;
+ }
/* Seeks on text files is tough, we rewind and read till we get to the
right place. */
@@ -708,70 +721,16 @@ fhandler_base::lseek (__off32_t offset, int whence)
set_readahead_valid (0);
}
- debug_printf ("lseek (%s, %d, %d)", unix_path_name, offset, whence);
-
-#if 0 /* lseek has no business messing about with text-mode stuff */
-
- if (!get_r_binary ())
- {
- int newplace;
-
- if (whence == 0)
- {
- newplace = offset;
- }
- else if (whence ==1)
- {
- newplace = rpos + offset;
- }
- else
- {
- /* Seek from the end of a file.. */
- if (rsize == -1)
- {
- /* Find the size of the file by reading till the end */
-
- char b[CHUNK_SIZE];
- while (read (b, sizeof (b)) > 0)
- ;
- rsize = rpos;
- }
- newplace = rsize + offset;
- }
-
- if (rpos > newplace)
- {
- SetFilePointer (handle, 0, 0, 0);
- rpos = 0;
- }
-
- /* You can never shrink something more than 50% by turning CRLF into LF,
- so we binary chop looking for the right place */
-
- while (rpos < newplace)
- {
- char b[CHUNK_SIZE];
- size_t span = (newplace - rpos) / 2;
- if (span == 0)
- span = 1;
- if (span > sizeof (b))
- span = sizeof (b);
-
- debug_printf ("lseek (%s, %d, %d) span %d, rpos %d newplace %d",
- name, offset, whence,span,rpos, newplace);
- read (b, span);
- }
-
- debug_printf ("Returning %d", newplace);
- return newplace;
- }
-#endif /* end of deleted code dealing with text mode */
+ debug_printf ("lseek (%s, %D, %d)", unix_path_name, offset, whence);
DWORD win32_whence = whence == SEEK_SET ? FILE_BEGIN
: (whence == SEEK_CUR ? FILE_CURRENT : FILE_END);
- res = SetFilePointer (get_handle(), offset, 0, win32_whence);
- if (res == -1)
+ LONG off_low = offset & 0xffffffff;
+ LONG off_high = wincap.has_64bit_file_access () ? offset >> 32 : 0;
+
+ res = SetFilePointer (get_handle(), off_low, &off_high, win32_whence);
+ if (res == INVALID_SET_FILE_POINTER && GetLastError ())
{
__seterrno ();
}
@@ -862,7 +821,7 @@ rootdir(char *full_path)
}
int __stdcall
-fhandler_base::fstat (struct stat *buf, path_conv *)
+fhandler_base::fstat (struct __stat64 *buf, path_conv *)
{
switch (get_device ())
{
@@ -1181,7 +1140,7 @@ fhandler_base::readdir (DIR *)
return NULL;
}
-__off32_t
+__off64_t
fhandler_base::telldir (DIR *)
{
set_errno (ENOTDIR);
@@ -1189,7 +1148,7 @@ fhandler_base::telldir (DIR *)
}
void
-fhandler_base::seekdir (DIR *, __off32_t)
+fhandler_base::seekdir (DIR *, __off64_t)
{
set_errno (ENOTDIR);
return;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index e9080ea80..7a94f04b3 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -282,19 +282,19 @@ class fhandler_base
virtual int open (path_conv * real_path, int flags, mode_t mode = 0);
virtual int close ();
- virtual int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
+ virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
virtual int ioctl (unsigned int cmd, void *);
virtual int fcntl (int cmd, void *);
virtual char const * ttyname () { return get_name(); }
virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
virtual int write (const void *ptr, size_t len);
- virtual __off32_t lseek (__off32_t offset, int whence);
+ virtual __off64_t lseek (__off64_t offset, int whence);
virtual int lock (int, struct flock *);
virtual void dump ();
virtual int dup (fhandler_base *child);
virtual HANDLE mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, __off32_t off);
+ int flags, __off64_t off);
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
virtual BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
@@ -347,8 +347,8 @@ class fhandler_base
virtual void set_eof () {}
virtual DIR *opendir (path_conv& pc);
virtual dirent *readdir (DIR *);
- virtual __off32_t telldir (DIR *);
- virtual void seekdir (DIR *, __off32_t);
+ virtual __off64_t telldir (DIR *);
+ virtual void seekdir (DIR *, __off64_t);
virtual void rewinddir (DIR *);
virtual int closedir (DIR *);
};
@@ -382,7 +382,7 @@ class fhandler_socket: public fhandler_base
int ioctl (unsigned int cmd, void *);
int fcntl (int cmd, void *);
- __off32_t lseek (__off32_t, int) { return 0; }
+ __off64_t lseek (__off64_t, int) { return 0; }
int close ();
void hclose (HANDLE) {close ();}
int dup (fhandler_base *child);
@@ -405,7 +405,7 @@ class fhandler_socket: public fhandler_base
int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL);
void signal_secret_event ();
void close_secret_event ();
- int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
};
class fhandler_pipe: public fhandler_base
@@ -417,7 +417,7 @@ class fhandler_pipe: public fhandler_base
unsigned id;
public:
fhandler_pipe (DWORD devtype);
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
@@ -489,7 +489,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw
virtual int open (path_conv *, int flags, mode_t mode = 0);
virtual int close (void);
- virtual __off32_t lseek (__off32_t offset, int whence);
+ virtual __off64_t lseek (__off64_t offset, int whence);
virtual int ioctl (unsigned int cmd, void *buf);
};
@@ -512,9 +512,9 @@ class fhandler_dev_tape: public fhandler_dev_raw
int open (path_conv *, int flags, mode_t mode = 0);
int close (void);
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
- int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
int dup (fhandler_base *child);
@@ -545,18 +545,18 @@ class fhandler_disk_file: public fhandler_base
int close ();
int lock (int, struct flock *);
BOOL is_device () { return FALSE; }
- int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
- int __stdcall fstat_helper (struct stat *buf) __attribute__ ((regparm (2)));
+ int __stdcall fstat (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3)));
+ int __stdcall fstat_helper (struct __stat64 *buf) __attribute__ ((regparm (2)));
- HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off32_t off);
+ HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off64_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
DWORD size, void *address);
DIR *opendir (path_conv& pc);
struct dirent *readdir (DIR *);
- __off32_t telldir (DIR *);
- void seekdir (DIR *, __off32_t);
+ __off64_t telldir (DIR *);
+ void seekdir (DIR *, __off64_t);
void rewinddir (DIR *);
int closedir (DIR *);
};
@@ -572,11 +572,11 @@ class fhandler_cygdrive: public fhandler_disk_file
fhandler_cygdrive (int unit);
DIR *opendir (path_conv& pc);
struct dirent *readdir (DIR *);
- __off32_t telldir (DIR *);
- void seekdir (DIR *, __off32_t);
+ __off64_t telldir (DIR *);
+ void seekdir (DIR *, __off64_t);
void rewinddir (DIR *);
int closedir (DIR *);
- int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
+ int __stdcall fstat (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3)));
};
class fhandler_serial: public fhandler_base
@@ -606,7 +606,7 @@ class fhandler_serial: public fhandler_base
int tcflow (int);
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
- __off32_t lseek (__off32_t, int) { return 0; }
+ __off64_t lseek (__off64_t, int) { return 0; }
int tcflush (int);
void dump ();
int is_tty () { return 1; }
@@ -837,7 +837,7 @@ class fhandler_tty_slave: public fhandler_tty_common
int tcflush (int);
int ioctl (unsigned int cmd, void *);
- __off32_t lseek (__off32_t, int) { return 0; }
+ __off64_t lseek (__off64_t, int) { return 0; }
select_record *select_read (select_record *s);
int ready_for_read (int fd, DWORD howlong);
};
@@ -864,7 +864,7 @@ class fhandler_pty_master: public fhandler_tty_common
int tcflush (int);
int ioctl (unsigned int cmd, void *);
- __off32_t lseek (__off32_t, int) { return 0; }
+ __off64_t lseek (__off64_t, int) { return 0; }
char *ptsname ();
void set_close_on_exec (int val);
@@ -903,7 +903,7 @@ class fhandler_dev_zero: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
int close (void);
void dump ();
@@ -926,7 +926,7 @@ class fhandler_dev_random: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
int close (void);
int dup (fhandler_base *child);
@@ -938,7 +938,7 @@ class fhandler_dev_mem: public fhandler_base
protected:
int unit;
DWORD mem_size;
- DWORD pos;
+ __off64_t pos;
public:
fhandler_dev_mem (int unit);
@@ -947,12 +947,12 @@ class fhandler_dev_mem: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t ulen);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
int close (void);
- int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
+ int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
int dup (fhandler_base *child);
- HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off32_t off);
+ HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off64_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
@@ -969,7 +969,7 @@ class fhandler_dev_clipboard: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- __off32_t lseek (__off32_t offset, int whence);
+ __off64_t lseek (__off64_t offset, int whence);
int close (void);
int dup (fhandler_base *child);
@@ -977,7 +977,7 @@ class fhandler_dev_clipboard: public fhandler_base
void dump ();
private:
- __off32_t pos;
+ __off64_t pos;
void *membuffer;
size_t msize;
bool eof;
@@ -995,7 +995,7 @@ class fhandler_windows: public fhandler_base
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
- __off32_t lseek (__off32_t, int) { return 0; }
+ __off64_t lseek (__off64_t, int) { return 0; }
int close (void) { return 0; }
void set_close_on_exec (int val);
@@ -1021,7 +1021,7 @@ class fhandler_dev_dsp : public fhandler_base
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
- __off32_t lseek (__off32_t, int);
+ __off64_t lseek (__off64_t, int);
int close (void);
int dup (fhandler_base * child);
void dump (void);
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index b095107fe..266114fe3 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -246,8 +246,8 @@ fhandler_dev_clipboard::read (void *ptr, size_t len)
}
}
-__off32_t
-fhandler_dev_clipboard::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_dev_clipboard::lseek (__off64_t offset, int whence)
{
/* On reads we check this at read time, not seek time.
* On writes we use this to decide how to write - empty and write, or open, copy, empty
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 4f14aad33..c251ed3cf 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -61,7 +61,7 @@ num_entries (const char *win32_name)
}
int
-fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
+fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc)
{
int res = -1;
int oret;
@@ -132,17 +132,17 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
buf->st_mode = S_IFREG;
if (!pc->has_acls ()
|| get_file_attribute (TRUE, pc->get_win32 (),
- &buf->st_mode,
- &buf->st_uid, &buf->st_gid))
+ &buf->st_mode, &uid, &gid))
{
buf->st_mode |= STD_RBITS | STD_XBITS;
if (!(pc->has_attribute (FILE_ATTRIBUTE_READONLY)))
buf->st_mode |= STD_WBITS;
if (pc->issymlink ())
buf->st_mode |= S_IRWXU | S_IRWXG | S_IRWXO;
- get_file_attribute (FALSE, pc->get_win32 (),
- NULL, &buf->st_uid, &buf->st_gid);
+ get_file_attribute (FALSE, pc->get_win32 (), NULL, &uid, &gid);
}
+ buf->st_uid = uid;
+ buf->st_gid = gid;
if ((handle = FindFirstFile (pc->get_win32 (), &wfd))
!= INVALID_HANDLE_VALUE)
{
@@ -158,9 +158,10 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
buf->st_mtime = to_time_t (&wfd.ftLastWriteTime);
buf->st_ctime = to_time_t (&wfd.ftCreationTime);
buf->st_size = wfd.nFileSizeLow;
+ buf->st_size = ((__off64_t)wfd.nFileSizeHigh << 32)
+ + wfd.nFileSizeLow;
buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = ((unsigned long) buf->st_size +
- S_BLKSIZE-1) / S_BLKSIZE;
+ buf->st_blocks = (buf->st_size + S_BLKSIZE-1) / S_BLKSIZE;
FindClose (handle);
}
res = 0;
@@ -170,7 +171,7 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
}
int
-fhandler_disk_file::fstat_helper (struct stat *buf)
+fhandler_disk_file::fstat_helper (struct __stat64 *buf)
{
int res = 0; // avoid a compiler warning
BY_HANDLE_FILE_INFORMATION local;
@@ -200,7 +201,7 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
if (lsize == 0xffffffff && GetLastError () != NO_ERROR)
buf->st_mode = S_IFCHR;
else
- buf->st_size = lsize;
+ buf->st_size = ((__off64_t)hsize << 32) + lsize;
/* We expect these to fail! */
buf->st_mode |= STD_RBITS | STD_WBITS;
buf->st_blksize = S_BLKSIZE;
@@ -228,7 +229,8 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
buf->st_ctime = to_time_t (&local.ftCreationTime);
buf->st_nlink = local.nNumberOfLinks;
buf->st_dev = local.dwVolumeSerialNumber;
- buf->st_size = local.nFileSizeLow;
+ buf->st_size = ((__off64_t)local.nFileSizeHigh << 32)
+ + local.nFileSizeLow;
/* Allocate some place to determine the root directory. Need to allocate
enough so that rootdir can add a trailing slash if path starts with \\. */
@@ -256,7 +258,7 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
}
buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = ((unsigned long) buf->st_size + S_BLKSIZE-1) / S_BLKSIZE;
+ buf->st_blocks = (buf->st_size + S_BLKSIZE-1) / S_BLKSIZE;
buf->st_mode = 0;
/* Using a side effect: get_file_attibutes checks for
@@ -267,8 +269,10 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
buf->st_mode = S_IFLNK;
else if (get_socket_p ())
buf->st_mode = S_IFSOCK;
+ __uid16_t uid;
+ __gid16_t gid;
if (get_file_attribute (has_acls (), get_win32_name (), &buf->st_mode,
- &buf->st_uid, &buf->st_gid) == 0)
+ &uid, &gid) == 0)
{
/* If read-only attribute is set, modify ntsec return value */
if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
@@ -277,6 +281,9 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
if (!(buf->st_mode & S_IFMT))
buf->st_mode |= S_IFREG;
+
+ buf->st_uid = uid;
+ buf->st_gid = gid;
}
else
{
@@ -331,7 +338,7 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
}
}
- syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%d, st_mode=%p, st_ino=%d, sizeof=%d",
+ syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%d, sizeof=%d",
buf, buf->st_atime, buf->st_size, buf->st_mode,
(int) buf->st_ino, sizeof (*buf));
@@ -429,10 +436,10 @@ fhandler_disk_file::close ()
int
fhandler_disk_file::lock (int cmd, struct flock *fl)
{
- int win32_start;
+ __off64_t win32_start;
int win32_len;
DWORD win32_upper;
- DWORD startpos;
+ __off64_t startpos;
/*
* We don't do getlck calls yet.
@@ -455,7 +462,7 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
startpos = 0;
break;
case SEEK_CUR:
- if ((__off32_t) (startpos = lseek (0, SEEK_CUR)) == ILLEGAL_SEEK)
+ if ((startpos = lseek (0, SEEK_CUR)) == ILLEGAL_SEEK)
return -1;
break;
case SEEK_END:
@@ -466,7 +473,8 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
__seterrno ();
return -1;
}
- startpos = finfo.nFileSizeLow; /* Nowhere to keep high word */
+ startpos = ((__off64_t)finfo.nFileSizeHigh << 32)
+ + finfo.nFileSizeLow;
break;
}
default:
@@ -714,14 +722,14 @@ fhandler_disk_file::readdir (DIR *dir)
return res;
}
-__off32_t
+__off64_t
fhandler_disk_file::telldir (DIR *dir)
{
return dir->__d_position;
}
void
-fhandler_disk_file::seekdir (DIR *dir, __off32_t loc)
+fhandler_disk_file::seekdir (DIR *dir, __off64_t loc)
{
rewinddir (dir);
while (loc > dir->__d_position)
@@ -771,7 +779,7 @@ fhandler_cygdrive::set_drives ()
}
int
-fhandler_cygdrive::fstat (struct stat *buf, path_conv *pc)
+fhandler_cygdrive::fstat (struct __stat64 *buf, path_conv *pc)
{
if (!iscygdrive_root ())
return fhandler_disk_file::fstat (buf, pc);
@@ -818,14 +826,14 @@ fhandler_cygdrive::readdir (DIR *dir)
return dir->__d_dirent;
}
-__off32_t
+__off64_t
fhandler_cygdrive::telldir (DIR *dir)
{
return fhandler_disk_file::telldir (dir);
}
void
-fhandler_cygdrive::seekdir (DIR *dir, __off32_t loc)
+fhandler_cygdrive::seekdir (DIR *dir, __off64_t loc)
{
if (!iscygdrive_root ())
return fhandler_disk_file::seekdir (dir, loc);
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index baa998943..6ea8f3cbd 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -482,8 +482,8 @@ fhandler_dev_dsp::read (void *ptr, size_t len)
return len;
}
-__off32_t
-fhandler_dev_dsp::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_dev_dsp::lseek (__off64_t offset, int whence)
{
return 0;
}
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index f03de0230..43daf9d99 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -77,16 +77,16 @@ fhandler_dev_floppy::close (void)
return fhandler_dev_raw::close ();
}
-__off32_t
-fhandler_dev_floppy::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_dev_floppy::lseek (__off64_t offset, int whence)
{
int ret;
char buf[512];
- long long drive_size = 0;
- long long lloffset = offset;
- long long current_position;
- __off32_t sector_aligned_offset;
- __off32_t bytes_left;
+ __off64_t drive_size = 0;
+ __off64_t lloffset = offset;
+ __off64_t current_position;
+ __off64_t sector_aligned_offset;
+ __off64_t bytes_left;
DWORD low;
LONG high = 0;
@@ -117,11 +117,11 @@ fhandler_dev_floppy::lseek (__off32_t offset, int whence)
debug_printf ("partition info: %ld (%ld)",
pi.StartingOffset.LowPart,
pi.PartitionLength.LowPart);
- drive_size = (long long) pi.PartitionLength.QuadPart;
+ drive_size = pi.PartitionLength.QuadPart;
}
else
{
- drive_size = (long long) di.Cylinders.QuadPart * di.TracksPerCylinder *
+ drive_size = di.Cylinders.QuadPart * di.TracksPerCylinder *
di.SectorsPerTrack * di.BytesPerSector;
}
debug_printf ("drive size: %ld", drive_size);
@@ -140,7 +140,7 @@ fhandler_dev_floppy::lseek (__off32_t offset, int whence)
__seterrno ();
return -1;
}
- current_position = (long long) low + ((long long) high << 32);
+ current_position = low + ((__off64_t) high << 32);
if (is_writing)
current_position += devbufend - devbufstart;
else
@@ -156,18 +156,10 @@ fhandler_dev_floppy::lseek (__off32_t offset, int whence)
set_errno (EINVAL);
return -1;
}
- high = lloffset >> 32;
- low = lloffset & 0xffffffff;
- if (high || (__off32_t) low < 0)
- {
- set_errno (EFBIG);
- return -1;
- }
- offset = (__off32_t) low;
/* FIXME: sector can possibly be not 512 bytes long */
- sector_aligned_offset = (offset / 512) * 512;
- bytes_left = offset - sector_aligned_offset;
+ sector_aligned_offset = (lloffset / 512) * 512;
+ bytes_left = lloffset - sector_aligned_offset;
if (whence == SEEK_SET)
{
@@ -177,8 +169,10 @@ fhandler_dev_floppy::lseek (__off32_t offset, int whence)
return ret;
devbufstart = devbufend = 0;
- if (SetFilePointer (get_handle (), sector_aligned_offset, NULL, FILE_BEGIN)
- == INVALID_SET_FILE_POINTER)
+ low = sector_aligned_offset & 0xffffffff;
+ high = sector_aligned_offset >> 32;
+ if (SetFilePointer (get_handle (), low, &high, FILE_BEGIN)
+ == INVALID_SET_FILE_POINTER && GetLastError ())
{
__seterrno ();
return -1;
diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc
index 03fbec97d..e5b99526e 100644
--- a/winsup/cygwin/fhandler_mem.cc
+++ b/winsup/cygwin/fhandler_mem.cc
@@ -231,8 +231,8 @@ fhandler_dev_mem::close (void)
return fhandler_base::close ();
}
-__off32_t
-fhandler_dev_mem::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_dev_mem::lseek (__off64_t offset, int whence)
{
switch (whence)
{
@@ -265,11 +265,11 @@ fhandler_dev_mem::lseek (__off32_t offset, int whence)
HANDLE
fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, __off32_t off)
+ int flags, __off64_t off)
{
- if ((DWORD) off >= mem_size
+ if (off >= mem_size
|| (DWORD) len >= mem_size
- || (DWORD) off + len >= mem_size)
+ || off + len >= mem_size)
{
set_errno (EINVAL);
syscall_printf ("-1 = mmap(): illegal parameter, set EINVAL");
@@ -402,7 +402,7 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
}
int
-fhandler_dev_mem::fstat (struct stat *buf, path_conv *pc)
+fhandler_dev_mem::fstat (struct __stat64 *buf, path_conv *pc)
{
this->fhandler_base::fstat (buf, pc);
buf->st_mode = S_IFCHR;
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc
index 91355c301..33ccaddea 100644
--- a/winsup/cygwin/fhandler_random.cc
+++ b/winsup/cygwin/fhandler_random.cc
@@ -132,8 +132,8 @@ fhandler_dev_random::read (void *ptr, size_t len)
return -1;
}
-__off32_t
-fhandler_dev_random::lseek (__off32_t, int)
+__off64_t
+fhandler_dev_random::lseek (__off64_t, int)
{
return 0;
}
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index c2af990df..cf8ec1c24 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -245,7 +245,7 @@ fhandler_socket::dup (fhandler_base *child)
}
int __stdcall
-fhandler_socket::fstat (struct stat *buf, path_conv *pc)
+fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
{
fhandler_disk_file fh;
fh.set_name (get_name (), get_win32_name ());
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index b4f6d5d1c..6b9bd1f4d 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -147,7 +147,7 @@ fhandler_dev_tape::close (void)
}
int
-fhandler_dev_tape::fstat (struct stat *buf, path_conv *pc)
+fhandler_dev_tape::fstat (struct __stat64 *buf, path_conv *pc)
{
int ret;
@@ -164,8 +164,8 @@ fhandler_dev_tape::fstat (struct stat *buf, path_conv *pc)
return ret;
}
-__off32_t
-fhandler_dev_tape::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_dev_tape::lseek (__off64_t offset, int whence)
{
struct mtop op;
struct mtpos pos;
diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc
index 4c018c90b..50b34abab 100644
--- a/winsup/cygwin/fhandler_zero.cc
+++ b/winsup/cygwin/fhandler_zero.cc
@@ -41,8 +41,8 @@ fhandler_dev_zero::read (void *ptr, size_t len)
return len;
}
-__off32_t
-fhandler_dev_zero::lseek (__off32_t, int)
+__off64_t
+fhandler_dev_zero::lseek (__off64_t, int)
{
return 0;
}
diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c
index c8a6ffbaa..cdb30a855 100644
--- a/winsup/cygwin/glob.c
+++ b/winsup/cygwin/glob.c
@@ -94,8 +94,12 @@ __weak_alias(__globfree13,___globfree13);
#ifdef __LIBC12_SOURCE__
#define STAT stat12
#else
+#if defined (__INSIDE_CYGWIN__)
+#define STAT __stat64
+#else
#define STAT stat
#endif
+#endif
#define DOLLAR '$'
#define DOT '.'
@@ -814,7 +818,11 @@ g_lstat(fn, sb, pglob)
g_Ctoc(fn, buf);
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return((*pglob->gl_lstat)(buf, sb));
+#ifdef __INSIDE_CYGWIN__
+ return(lstat64(buf, sb));
+#else
return(lstat(buf, sb));
+#endif
}
static int
@@ -828,7 +836,11 @@ g_stat(fn, sb, pglob)
g_Ctoc(fn, buf);
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return((*pglob->gl_stat)(buf, sb));
+#ifdef __INSIDE_CYGWIN__
+ return(stat64(buf, sb));
+#else
return(stat(buf, sb));
+#endif
}
static Char *
diff --git a/winsup/cygwin/include/cygwin/stat.h b/winsup/cygwin/include/cygwin/stat.h
index 7385ebc6c..90abc3999 100644
--- a/winsup/cygwin/include/cygwin/stat.h
+++ b/winsup/cygwin/include/cygwin/stat.h
@@ -16,36 +16,75 @@ details. */
extern "C" {
#endif
-struct stat
-{
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- __uid16_t __st_uid16;
- __gid16_t __st_gid16;
- dev_t st_rdev;
- __off32_t __st_size32;
- time_t st_atime;
- __uid32_t __st_uid32;
- time_t st_mtime;
- __uid32_t __st_gid32;
- time_t st_ctime;
- long st_spare3;
- long st_blksize;
- long st_blocks;
- __off64_t __st_size64;
+#ifdef __INSIDE_CYGWIN__
+struct __stat32
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ __uid16_t st_uid;
+ __gid16_t st_gid;
+ dev_t st_rdev;
+ __off32_t st_size;
+ time_t st_atime;
+ long st_spare1;
+ time_t st_mtime;
+ long st_spare2;
+ time_t st_ctime;
+ long st_spare3;
+ blksize_t st_blksize;
+ __blkcnt32_t st_blocks;
+ long st_spare4[2];
+};
+
+struct __stat64
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ __uid32_t st_uid;
+ __gid32_t st_gid;
+ dev_t st_rdev;
+ __off64_t st_size;
+ time_t st_atime;
+ long st_spare1;
+ time_t st_mtime;
+ long st_spare2;
+ time_t st_ctime;
+ long st_spare3;
+ blksize_t st_blksize;
+ __blkcnt64_t st_blocks;
+ long st_spare4[2];
};
-#ifdef __CYGWIN_USE_BIG_TYPES__
-#define st_uid __st_uid32
-#define st_gid __st_gid32
-#define st_size __st_size64
-#else
-#define st_uid __st_uid16
-#define st_gid __st_gid16
-#define st_size __st_size32
-#endif /* __CYGWIN_USE_BIG_TYPES__ */
+extern int fstat64 (int fd, struct __stat64 *buf);
+extern int stat64 (const char *file_name, struct __stat64 *buf);
+extern int lstat64 (const char *file_name, struct __stat64 *buf);
+
+#endif
+
+struct stat
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ long st_spare1;
+ time_t st_mtime;
+ long st_spare2;
+ time_t st_ctime;
+ long st_spare3;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+ long st_spare4[2];
+};
#ifdef __cplusplus
}
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index 585225f41..296a11a9c 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -25,6 +25,16 @@ typedef __off64_t off_t;
typedef __off32_t off_t;
#endif
+typedef long blksize_t;
+
+typedef long __blkcnt32_t;
+typedef long long __blkcnt64_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __blkcnt64_t blkcnt_t;
+#else
+typedef __blkcnt32_t blkcnt_t;
+#endif
+
typedef unsigned short __uid16_t;
typedef unsigned short __gid16_t;
typedef unsigned long __uid32_t;
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index c53272762..57bd82795 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -47,13 +47,13 @@ class mmap_record
HANDLE mapping_handle_;
int devtype_;
DWORD access_mode_;
- DWORD offset_;
+ __off64_t offset_;
DWORD size_to_map_;
caddr_t base_address_;
DWORD *map_map_;
public:
- mmap_record (int fd, HANDLE h, DWORD ac, DWORD o, DWORD s, caddr_t b) :
+ mmap_record (int fd, HANDLE h, DWORD ac, __off64_t o, DWORD s, caddr_t b) :
fdesc_ (fd),
mapping_handle_ (h),
devtype_ (0),
@@ -95,7 +95,7 @@ class mmap_record
void free_map () { if (map_map_) free (map_map_); }
DWORD find_empty (DWORD pages);
- DWORD map_map (DWORD off, DWORD len);
+ __off64_t map_map (__off64_t off, DWORD len);
BOOL unmap_map (caddr_t addr, DWORD len);
void fixup_map (void);
@@ -124,8 +124,8 @@ mmap_record::find_empty (DWORD pages)
return (DWORD)-1;
}
-DWORD
-mmap_record::map_map (DWORD off, DWORD len)
+__off64_t
+mmap_record::map_map (__off64_t off, DWORD len)
{
DWORD prot, old_prot;
switch (access_mode_)
@@ -255,8 +255,8 @@ public:
~list ();
mmap_record *add_record (mmap_record r);
void erase (int i);
- mmap_record *match (DWORD off, DWORD len);
- __off32_t match (caddr_t addr, DWORD len, __off32_t start);
+ mmap_record *match (__off64_t off, DWORD len);
+ long match (caddr_t addr, DWORD len, long start);
};
list::list ()
@@ -287,7 +287,7 @@ list::add_record (mmap_record r)
/* Used in mmap() */
mmap_record *
-list::match (DWORD off, DWORD len)
+list::match (__off64_t off, DWORD len)
{
if (fd == -1 && !off)
{
@@ -307,14 +307,14 @@ list::match (DWORD off, DWORD len)
}
/* Used in munmap() */
-__off32_t
+long
list::match (caddr_t addr, DWORD len, __off32_t start)
{
for (int i = start + 1; i < nrecs; ++i)
if (addr >= recs[i].get_address ()
&& addr + len <= recs[i].get_address () + recs[i].get_size ())
return i;
- return ILLEGAL_SEEK;
+ return -1;
}
void
@@ -400,9 +400,9 @@ static map *mmapped_areas;
extern "C"
caddr_t
-mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
+mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
{
- syscall_printf ("addr %x, len %d, prot %x, flags %x, fd %d, off %d",
+ syscall_printf ("addr %x, len %d, prot %x, flags %x, fd %d, off %D",
addr, len, prot, flags, fd, off);
static DWORD granularity;
@@ -444,7 +444,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
fd = -1;
/* Map always in multipliers of `granularity'-sized chunks. */
- DWORD gran_off = off & ~(granularity - 1);
+ __off64_t gran_off = off & ~(granularity - 1);
DWORD gran_len = howmany (len, granularity) * granularity;
fhandler_base *fh;
@@ -464,7 +464,9 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
fh = cfd;
if (fh->get_device () == FH_DISK)
{
- DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
+ DWORD high;
+ DWORD low = GetFileSize (fh->get_handle (), &high);
+ __off64_t fsiz = ((__off64_t)high << 32) + low;
fsiz -= gran_off;
if (gran_len > fsiz)
gran_len = fsiz;
@@ -554,6 +556,13 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
return ret;
}
+extern "C"
+caddr_t
+mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
+{
+ return mmap64 (addr, len, prot, flags, fd, (__off64_t)off);
+}
+
/* munmap () removes an mmapped area. It insists that base area
requested is the same as that mmapped, error if not. */
@@ -589,7 +598,7 @@ munmap (caddr_t addr, size_t len)
list *l = mmapped_areas->lists[it];
if (l)
{
- __off32_t li = ILLEGAL_SEEK;
+ long li = -1;
if ((li = l->match(addr, len, li)) >= 0)
{
mmap_record *rec = l->recs + li;
@@ -695,7 +704,7 @@ msync (caddr_t addr, size_t len, int flags)
*/
HANDLE
fhandler_base::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, __off32_t off)
+ int flags, __off64_t off)
{
set_errno (ENODEV);
return INVALID_HANDLE_VALUE;
@@ -726,7 +735,7 @@ fhandler_base::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
/* Implementation for disk files. */
HANDLE
fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, __off32_t off)
+ int flags, __off64_t off)
{
DWORD protect;
@@ -769,9 +778,10 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
return INVALID_HANDLE_VALUE;
}
- void *base = MapViewOfFileEx (h, access, 0, off, len,
+ DWORD high = off >> 32, low = off & 0xffffffff;
+ void *base = MapViewOfFileEx (h, access, high, low, len,
(flags & MAP_FIXED) ? *addr : NULL);
- debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%d, len:%d, addr:%x)", base, h, access, off, len, (flags & MAP_FIXED) ? *addr : NULL);
+ debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%D, len:%d, addr:%x)", base, h, access, off, len, (flags & MAP_FIXED) ? *addr : NULL);
if (!base || ((flags & MAP_FIXED) && base != *addr))
{
if (!base)
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index d5cb59a3c..b87080792 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -31,8 +31,8 @@ fhandler_pipe::fhandler_pipe (DWORD devtype)
{
}
-__off32_t
-fhandler_pipe::lseek (__off32_t offset, int whence)
+__off64_t
+fhandler_pipe::lseek (__off64_t offset, int whence)
{
debug_printf ("(%d, %d)", offset, whence);
set_errno (ESPIPE);
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index 7c5bc6303..36c31a840 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -476,7 +476,7 @@ acl_worker (const char *path, int cmd, int nentries, __aclent16_t *aclbufp,
}
if (!real_path.has_acls ())
{
- struct stat st;
+ struct __stat64 st;
int ret = -1;
switch (cmd)
@@ -487,8 +487,8 @@ acl_worker (const char *path, int cmd, int nentries, __aclent16_t *aclbufp,
case GETACL:
if (nentries < 1)
set_errno (EINVAL);
- else if ((nofollow && !lstat (path, &st))
- || (!nofollow && !stat (path, &st)))
+ else if ((nofollow && !lstat64 (path, &st))
+ || (!nofollow && !stat64 (path, &st)))
{
__aclent16_t lacl[4];
if (nentries > 0)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 743dcbcbe..7c0672e44 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -527,10 +527,10 @@ _open (const char *unix_path, int flags, ...)
return res;
}
-extern "C" __off32_t
-_lseek (int fd, __off32_t pos, int dir)
+extern "C" __off64_t
+lseek64 (int fd, __off64_t pos, int dir)
{
- __off32_t res;
+ __off64_t res;
sigframe thisframe (mainthread);
if (dir != SEEK_SET && dir != SEEK_CUR && dir != SEEK_END)
@@ -546,11 +546,17 @@ _lseek (int fd, __off32_t pos, int dir)
else
res = -1;
}
- syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir);
+ syscall_printf ("%d = lseek (%d, %D, %d)", res, fd, pos, dir);
return res;
}
+extern "C" __off32_t
+_lseek (int fd, __off32_t pos, int dir)
+{
+ return lseek64 (fd, (__off64_t) pos, dir);
+}
+
extern "C" int
_close (int fd)
{
@@ -956,8 +962,26 @@ fchmod (int fd, mode_t mode)
return chmod (path, mode);
}
+static void
+stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
+{
+ dst->st_dev = src->st_dev;
+ dst->st_ino = src->st_ino;
+ dst->st_mode = src->st_mode;
+ dst->st_nlink = src->st_nlink;
+ dst->st_uid = src->st_uid;
+ dst->st_gid = src->st_gid;
+ dst->st_rdev = src->st_rdev;
+ dst->st_size = src->st_size;
+ dst->st_atime = src->st_atime;
+ dst->st_mtime = src->st_mtime;
+ dst->st_ctime = src->st_ctime;
+ dst->st_blksize = src->st_blksize;
+ dst->st_blocks = src->st_blocks;
+}
+
extern "C" int
-_fstat (int fd, struct stat *buf)
+fstat64 (int fd, struct __stat64 *buf)
{
int res;
sigframe thisframe (mainthread);
@@ -967,7 +991,7 @@ _fstat (int fd, struct stat *buf)
res = -1;
else
{
- memset (buf, 0, sizeof (struct stat));
+ memset (buf, 0, sizeof (struct __stat64));
res = cfd->fstat (buf, NULL);
}
@@ -975,6 +999,16 @@ _fstat (int fd, struct stat *buf)
return res;
}
+extern "C" int
+_fstat (int fd, struct __stat32 *buf)
+{
+ struct __stat64 buf64;
+ int ret = fstat64 (fd, &buf64);
+ if (!ret)
+ stat64_to_stat32 (&buf64, buf);
+ return ret;
+}
+
/* fsync: P96 6.6.1.1 */
extern "C" int
fsync (int fd)
@@ -1011,7 +1045,8 @@ suffix_info stat_suffixes[] =
/* Cygwin internal */
int __stdcall
-stat_worker (const char *name, struct stat *buf, int nofollow, path_conv *pc)
+stat_worker (const char *name, struct __stat64 *buf, int nofollow,
+ path_conv *pc)
{
int res = -1;
path_conv real_path;
@@ -1038,7 +1073,7 @@ stat_worker (const char *name, struct stat *buf, int nofollow, path_conv *pc)
{
debug_printf ("(%s, %p, %d, %p), file_attributes %d", name, buf, nofollow,
pc, (DWORD) real_path);
- memset (buf, 0, sizeof (struct stat));
+ memset (buf, 0, sizeof (struct __stat64));
res = fh->fstat (buf, pc);
}
@@ -1051,22 +1086,43 @@ stat_worker (const char *name, struct stat *buf, int nofollow, path_conv *pc)
}
extern "C" int
-_stat (const char *name, struct stat *buf)
+stat64 (const char *name, struct __stat64 *buf)
{
sigframe thisframe (mainthread);
syscall_printf ("entering");
return stat_worker (name, buf, 0);
}
+extern "C" int
+_stat (const char *name, struct __stat32 *buf)
+{
+ struct __stat64 buf64;
+ int ret = stat64 (name, &buf64);
+ if (!ret)
+ stat64_to_stat32 (&buf64, buf);
+ return ret;
+}
+
/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
extern "C" int
-lstat (const char *name, struct stat *buf)
+lstat64 (const char *name, struct __stat64 *buf)
{
sigframe thisframe (mainthread);
syscall_printf ("entering");
return stat_worker (name, buf, 1);
}
+/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
+extern "C" int
+cygwin_lstat (const char *name, struct __stat32 *buf)
+{
+ struct __stat64 buf64;
+ int ret = lstat64 (name, &buf64);
+ if (!ret)
+ stat64_to_stat32 (&buf64, buf);
+ return ret;
+}
+
extern int acl_access (const char *, int);
extern "C" int
@@ -1083,7 +1139,7 @@ access (const char *fn, int flags)
if (allow_ntsec)
return acl_access (fn, flags);
- struct stat st;
+ struct __stat64 st;
int r = stat_worker (fn, &st, 0);
if (r)
return -1;
@@ -1607,9 +1663,8 @@ setmode (int fd, int mode)
return res;
}
-/* ftruncate: P96 5.6.7.1 */
extern "C" int
-ftruncate (int fd, __off32_t length)
+ftruncate64 (int fd, __off64_t length)
{
sigframe thisframe (mainthread);
int res = -1;
@@ -1626,7 +1681,7 @@ ftruncate (int fd, __off32_t length)
if (cfd->get_handle ())
{
/* remember curr file pointer location */
- __off32_t prev_loc = cfd->lseek (0, SEEK_CUR);
+ __off64_t prev_loc = cfd->lseek (0, SEEK_CUR);
cfd->lseek (length, SEEK_SET);
if (!SetEndOfFile (h))
@@ -1635,7 +1690,7 @@ ftruncate (int fd, __off32_t length)
res = 0;
/* restore original file pointer location */
- cfd->lseek (prev_loc, 0);
+ cfd->lseek (prev_loc, SEEK_SET);
}
}
}
@@ -1644,9 +1699,16 @@ ftruncate (int fd, __off32_t length)
return res;
}
+/* ftruncate: P96 5.6.7.1 */
+extern "C" int
+ftruncate (int fd, __off32_t length)
+{
+ return ftruncate64 (fd, (__off64_t)length);
+}
+
/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */
extern "C" int
-truncate (const char *pathname, __off32_t length)
+truncate64 (const char *pathname, __off64_t length)
{
sigframe thisframe (mainthread);
int fd;
@@ -1666,6 +1728,13 @@ truncate (const char *pathname, __off32_t length)
return res;
}
+/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */
+extern "C" int
+truncate (const char *pathname, __off32_t length)
+{
+ return truncate64 (pathname, (__off64_t)length);
+}
+
extern "C" long
get_osfhandle (int fd)
{
@@ -2377,6 +2446,7 @@ logout (char *line)
{
struct utmp *ut;
struct utmp ut_buf[100];
+ /* FIXME: utmp file access is not 64 bit clean for now. */
__off32_t pos = 0; /* Position in file */
DWORD rd;
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index dc4a8d266..09e95fba0 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -45,6 +45,7 @@ static NO_COPY wincaps wincap_unknown = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:false,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_95 = {
@@ -81,6 +82,7 @@ static NO_COPY wincaps wincap_95 = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:false,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -117,6 +119,7 @@ static NO_COPY wincaps wincap_95osr2 = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:false,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_98 = {
@@ -153,6 +156,7 @@ static NO_COPY wincaps wincap_98 = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:true,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_98se = {
@@ -189,6 +193,7 @@ static NO_COPY wincaps wincap_98se = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:true,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_me = {
@@ -225,6 +230,7 @@ static NO_COPY wincaps wincap_me = {
has_try_enter_critical_section:false,
has_raw_devices:false,
has_valid_processorlevel:true,
+ has_64bit_file_access:false,
};
static NO_COPY wincaps wincap_nt3 = {
@@ -261,6 +267,7 @@ static NO_COPY wincaps wincap_nt3 = {
has_try_enter_critical_section:false,
has_raw_devices:true,
has_valid_processorlevel:true,
+ has_64bit_file_access:true,
};
static NO_COPY wincaps wincap_nt4 = {
@@ -297,6 +304,7 @@ static NO_COPY wincaps wincap_nt4 = {
has_try_enter_critical_section:true,
has_raw_devices:true,
has_valid_processorlevel:true,
+ has_64bit_file_access:true,
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -333,6 +341,7 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_try_enter_critical_section:true,
has_raw_devices:true,
has_valid_processorlevel:true,
+ has_64bit_file_access:true,
};
static NO_COPY wincaps wincap_2000 = {
@@ -369,6 +378,7 @@ static NO_COPY wincaps wincap_2000 = {
has_try_enter_critical_section:true,
has_raw_devices:true,
has_valid_processorlevel:true,
+ has_64bit_file_access:true,
};
static NO_COPY wincaps wincap_xp = {
@@ -405,6 +415,7 @@ static NO_COPY wincaps wincap_xp = {
has_try_enter_critical_section:true,
has_raw_devices:true,
has_valid_processorlevel:true,
+ has_64bit_file_access:true,
};
wincapc NO_COPY wincap;
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index ad9238611..088907ad2 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -46,6 +46,7 @@ struct wincaps
unsigned has_try_enter_critical_section : 1;
unsigned has_raw_devices : 1;
unsigned has_valid_processorlevel : 1;
+ unsigned has_64bit_file_access : 1;
};
class wincapc
@@ -97,6 +98,7 @@ public:
bool IMPLEMENT (has_try_enter_critical_section)
bool IMPLEMENT (has_raw_devices)
bool IMPLEMENT (has_valid_processorlevel)
+ bool IMPLEMENT (has_64bit_file_access)
#undef IMPLEMENT
};
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 0adbb738c..d3daec259 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -147,7 +147,7 @@ void uinfo_init (void);
#define ILLEGAL_UID ((__uid16_t)-1)
#define ILLEGAL_GID ((__gid16_t)-1)
-#define ILLEGAL_SEEK ((__off32_t)-1)
+#define ILLEGAL_SEEK ((__off64_t)-1)
/* various events */
void events_init (void);
@@ -179,7 +179,7 @@ extern int cygwin_finished_initializing;
void __stdcall set_std_handle (int);
int __stdcall writable_directory (const char *file);
-int __stdcall stat_dev (DWORD, int, unsigned long, struct stat *);
+int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
extern BOOL allow_ntsec;
unsigned long __stdcall hash_path_name (unsigned long hash, const char *name) __attribute__ ((regparm(2)));
@@ -230,7 +230,7 @@ extern "C" void __malloc_lock (struct _reent *);
extern "C" void __malloc_unlock (struct _reent *);
class path_conv;
-int __stdcall stat_worker (const char *name, struct stat *buf, int nofollow,
+int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow,
path_conv *pc = NULL) __attribute__ ((regparm (3)));
/**************************** Exports ******************************/