* 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.
This commit is contained in:
Corinna Vinschen
2002-02-25 17:47:51 +00:00
parent 5a909729b1
commit acb5617538
24 changed files with 433 additions and 238 deletions

View File

@@ -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;