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
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/cygwin/fhandler.cc
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/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc91
1 files changed, 25 insertions, 66 deletions
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;