Commit 3f1ed52d authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Implemented 64bit file size handling.

Removed several unneeded sys/stat.h includes.
parent 5920737f
...@@ -757,6 +757,8 @@ AC_CHECK_FUNCS(\ ...@@ -757,6 +757,8 @@ AC_CHECK_FUNCS(\
ecvt \ ecvt \
finite \ finite \
fpclass \ fpclass \
fstat64 \
ftruncate64 \
getnetbyaddr \ getnetbyaddr \
getnetbyname \ getnetbyname \
getpagesize \ getpagesize \
...@@ -766,7 +768,9 @@ AC_CHECK_FUNCS(\ ...@@ -766,7 +768,9 @@ AC_CHECK_FUNCS(\
getservbyport \ getservbyport \
getsockopt \ getsockopt \
inet_network \ inet_network \
lseek64 \
lstat \ lstat \
lstat64 \
memmove \ memmove \
mmap \ mmap \
rfork \ rfork \
...@@ -774,6 +778,7 @@ AC_CHECK_FUNCS(\ ...@@ -774,6 +778,7 @@ AC_CHECK_FUNCS(\
sendmsg \ sendmsg \
settimeofday \ settimeofday \
sigaltstack \ sigaltstack \
stat64 \
statfs \ statfs \
strcasecmp \ strcasecmp \
strerror \ strerror \
...@@ -850,6 +855,43 @@ AC_C_INLINE() ...@@ -850,6 +855,43 @@ AC_C_INLINE()
AC_TYPE_SIZE_T() AC_TYPE_SIZE_T()
AC_CHECK_SIZEOF(long long,0) AC_CHECK_SIZEOF(long long,0)
AC_CACHE_CHECK("for off64_t",
wine_cv_off64_t,
AC_TRY_COMPILE([
#define _LARGEFILE64_SOURCE
#include <sys/types.h>
],[
off64_t testoffset;
],
wine_cv_off64_t="yes",
wine_cv_off64_t="no",
wine_cv_off64_t="yes"
)
)
if test "$wine_cv_off64_t" = "yes"
then
AC_DEFINE(HAVE_OFF64_T)
fi
AC_CACHE_CHECK("for struct stat64",
wine_cv_struct_stat64,
AC_TRY_COMPILE([
#define _LARGEFILE64_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
],[
struct stat64 tst64;
],
wine_cv_struct_stat64="yes",
wine_cv_struct_stat64="no",
wine_cv_struct_stat64="yes"
)
)
if test "$wine_cv_struct_stat64" = "yes"
then
AC_DEFINE(HAVE_STRUCT_STAT64)
fi
AC_CACHE_CHECK("whether linux/input.h is for real", AC_CACHE_CHECK("whether linux/input.h is for real",
wine_cv_linux_input_h, wine_cv_linux_input_h,
AC_TRY_COMPILE([ AC_TRY_COMPILE([
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
......
...@@ -25,7 +25,6 @@ HKEY_DYN_DATA ...@@ -25,7 +25,6 @@ HKEY_DYN_DATA
*/ */
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <memory.h> #include <memory.h>
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <memory.h> #include <memory.h>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/exception.h" #include "wine/exception.h"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> /* qsort() & bsearch() */ #include <stdlib.h> /* qsort() & bsearch() */
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <limits.h> /* INT_MIN */ #include <limits.h> /* INT_MIN */
#include <float.h> /* FLT_MAX */ #include <float.h> /* FLT_MAX */
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#ifdef HAVE_NETINET_IN_SYSTM_H #ifdef HAVE_NETINET_IN_SYSTM_H
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
...@@ -36,7 +37,6 @@ ...@@ -36,7 +37,6 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/port.h"
#include "drive.h" #include "drive.h"
#include "file.h" #include "file.h"
#include "heap.h" #include "heap.h"
...@@ -491,7 +491,7 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing, ...@@ -491,7 +491,7 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
* *
* Fill a file information from a struct stat. * Fill a file information from a struct stat.
*/ */
static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info ) static void FILE_FillInfo( struct stat64 *st, BY_HANDLE_FILE_INFORMATION *info )
{ {
if (S_ISDIR(st->st_mode)) if (S_ISDIR(st->st_mode))
info->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; info->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
...@@ -506,7 +506,11 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info ) ...@@ -506,7 +506,11 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info )
info->dwVolumeSerialNumber = 0; /* FIXME */ info->dwVolumeSerialNumber = 0; /* FIXME */
info->nFileSizeHigh = 0; info->nFileSizeHigh = 0;
info->nFileSizeLow = S_ISDIR(st->st_mode) ? 0 : st->st_size; info->nFileSizeLow = 0;
if (!S_ISDIR(st->st_mode)) {
info->nFileSizeHigh = st->st_size >> 32;
info->nFileSizeLow = st->st_size & 0xffffffff;
}
info->nNumberOfLinks = st->st_nlink; info->nNumberOfLinks = st->st_nlink;
info->nFileIndexHigh = 0; info->nFileIndexHigh = 0;
info->nFileIndexLow = st->st_ino; info->nFileIndexLow = st->st_ino;
...@@ -520,9 +524,9 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info ) ...@@ -520,9 +524,9 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info )
*/ */
BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
{ {
struct stat st; struct stat64 st;
if (lstat( unixName, &st ) == -1) if (lstat64( unixName, &st ) == -1)
{ {
FILE_SetDosError(); FILE_SetDosError();
return FALSE; return FALSE;
...@@ -532,7 +536,7 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) ...@@ -532,7 +536,7 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
{ {
/* do a "real" stat to find out /* do a "real" stat to find out
about the type of the symlink destination */ about the type of the symlink destination */
if (stat( unixName, &st ) == -1) if (stat64( unixName, &st ) == -1)
{ {
FILE_SetDosError(); FILE_SetDosError();
return FALSE; return FALSE;
...@@ -1644,17 +1648,8 @@ DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword, ...@@ -1644,17 +1648,8 @@ DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
{ {
DWORD ret = 0xffffffff; DWORD ret = 0xffffffff;
if (highword && TRACE("handle %d offset %ld high %ld origin %ld\n",
((distance >= 0 && *highword != 0) || (distance < 0 && *highword != -1))) hFile, distance, highword?*highword:0, method );
{
FIXME("64-bit offsets not supported yet\n"
"SetFilePointer(%08x,%08lx,%08lx,%08lx)\n",
hFile,distance,*highword,method);
SetLastError( ERROR_INVALID_PARAMETER );
return ret;
}
TRACE("handle %d offset %ld origin %ld\n",
hFile, distance, method );
SERVER_START_REQ( set_file_pointer ) SERVER_START_REQ( set_file_pointer )
{ {
...@@ -2015,7 +2010,10 @@ BOOL WINAPI MoveFileExW( LPCWSTR fn1, LPCWSTR fn2, DWORD flag ) ...@@ -2015,7 +2010,10 @@ BOOL WINAPI MoveFileExW( LPCWSTR fn1, LPCWSTR fn2, DWORD flag )
BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 ) BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 )
{ {
DOS_FULL_NAME full_name1, full_name2; DOS_FULL_NAME full_name1, full_name2;
struct stat fstat; /* Even though we do not need the size, stat will fail for large files,
* so we need to use stat64 here. */
struct stat64 fstat;
TRACE("(%s,%s)\n", fn1, fn2 ); TRACE("(%s,%s)\n", fn1, fn2 );
...@@ -2035,7 +2033,7 @@ BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 ) ...@@ -2035,7 +2033,7 @@ BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 )
} }
else return TRUE; else return TRUE;
else /*copy */ { else /*copy */ {
if (stat( full_name1.long_name, &fstat )) if (stat64( full_name1.long_name, &fstat ))
{ {
WARN("Invalid source file %s\n", WARN("Invalid source file %s\n",
full_name1.long_name); full_name1.long_name);
......
...@@ -19,10 +19,8 @@ ...@@ -19,10 +19,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <math.h> #include <math.h>
#include <assert.h>
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "wingdi.h"
......
...@@ -122,3 +122,9 @@ ...@@ -122,3 +122,9 @@
/* Define if we have CUPS */ /* Define if we have CUPS */
#undef HAVE_CUPS #undef HAVE_CUPS
/* Define if we have 64 bit file offsets */
#undef HAVE_OFF64_T
/* Define if we have struct stat64 */
#undef HAVE_STRUCT_STAT64
...@@ -154,6 +154,12 @@ ...@@ -154,6 +154,12 @@
/* Define if we have CUPS */ /* Define if we have CUPS */
#undef HAVE_CUPS #undef HAVE_CUPS
/* Define if we have 64 bit file offsets */
#undef HAVE_OFF64_T
/* Define if we have struct stat64 */
#undef HAVE_STRUCT_STAT64
/* The number of bytes in a long long. */ /* The number of bytes in a long long. */
#undef SIZEOF_LONG_LONG #undef SIZEOF_LONG_LONG
...@@ -181,6 +187,12 @@ ...@@ -181,6 +187,12 @@
/* Define if you have the fpclass function. */ /* Define if you have the fpclass function. */
#undef HAVE_FPCLASS #undef HAVE_FPCLASS
/* Define if you have the fstat64 function. */
#undef HAVE_FSTAT64
/* Define if you have the ftruncate64 function. */
#undef HAVE_FTRUNCATE64
/* Define if you have the gethostbyname function. */ /* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME #undef HAVE_GETHOSTBYNAME
...@@ -214,9 +226,15 @@ ...@@ -214,9 +226,15 @@
/* Define if you have the iswalnum function. */ /* Define if you have the iswalnum function. */
#undef HAVE_ISWALNUM #undef HAVE_ISWALNUM
/* Define if you have the lseek64 function. */
#undef HAVE_LSEEK64
/* Define if you have the lstat function. */ /* Define if you have the lstat function. */
#undef HAVE_LSTAT #undef HAVE_LSTAT
/* Define if you have the lstat64 function. */
#undef HAVE_LSTAT64
/* Define if you have the memmove function. */ /* Define if you have the memmove function. */
#undef HAVE_MEMMOVE #undef HAVE_MEMMOVE
...@@ -241,6 +259,9 @@ ...@@ -241,6 +259,9 @@
/* Define if you have the sigaltstack function. */ /* Define if you have the sigaltstack function. */
#undef HAVE_SIGALTSTACK #undef HAVE_SIGALTSTACK
/* Define if you have the stat64 function. */
#undef HAVE_STAT64
/* Define if you have the statfs function. */ /* Define if you have the statfs function. */
#undef HAVE_STATFS #undef HAVE_STATFS
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
#ifndef __WINE_WINE_PORT_H #ifndef __WINE_WINE_PORT_H
#define __WINE_WINE_PORT_H #define __WINE_WINE_PORT_H
#define _LARGEFILE64_SOURCE /* for glibc 64 bit file functions */
#include "config.h" #include "config.h"
#include "winnt.h" #include "winnt.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -131,6 +132,57 @@ int lstat(const char *file_name, struct stat *buf); ...@@ -131,6 +132,57 @@ int lstat(const char *file_name, struct stat *buf);
#define S_ISLNK(mod) (0) #define S_ISLNK(mod) (0)
#endif /* S_ISLNK */ #endif /* S_ISLNK */
#ifndef HAVE_OFF64_T
# if SIZEOF_LONG_LONG > 0
typedef long long off64_t;
# else
typedef long off64_t;
# endif
#endif
#ifndef HAVE_STRUCT_STAT64
/* This does not convert all struct members to 64bit, only size. */
struct stat64 {
dev_t st_dev; /* device */
ino_t st_ino; /* inode */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device type (if inode device) */
off64_t st_size; /* total size, in bytes */
unsigned long st_blksize; /* blocksize for filesystem I/O */
unsigned long st_blocks; /* number of blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last change */
};
#endif
#ifndef HAVE_LSEEK64
extern off64_t lseek64(int fildes, off64_t offset, int whence);
#endif
#ifndef HAVE_STAT64
extern int stat64(const char *file_name, struct stat64 *buf);
#endif
#ifndef HAVE_LSTAT64
extern int lstat64(const char *file_name, struct stat64 *buf);
#endif
#ifndef HAVE_FSTAT64
extern int fstat64(int fd, struct stat64 *buf);
#endif
#ifndef HAVE_FTRUNCATE64
extern int ftruncate64(int fd, off64_t offset);
#endif
#ifndef O_LARGEFILE
# define O_LARGEFILE 0
#endif
extern void *wine_dlopen( const char *filename, int flag, char *error, int errorsize ); extern void *wine_dlopen( const char *filename, int flag, char *error, int errorsize );
extern void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize ); extern void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize );
extern int wine_dlclose( void *handle, char *error, int errorsize ); extern int wine_dlclose( void *handle, char *error, int errorsize );
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
#include "winnt.h" #include "winnt.h"
#include "wine/library.h" #include "wine/library.h"
#include "wine/port.h"
#define MAX_DLLS 100 #define MAX_DLLS 100
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#ifdef __BEOS__ #ifdef __BEOS__
#include <be/kernel/fs_info.h> #include <be/kernel/fs_info.h>
...@@ -43,7 +44,6 @@ ...@@ -43,7 +44,6 @@
# include <dlfcn.h> # include <dlfcn.h>
#endif #endif
#include "wine/port.h"
/*********************************************************************** /***********************************************************************
* usleep * usleep
...@@ -389,8 +389,94 @@ int lstat(const char *file_name, struct stat *buf) ...@@ -389,8 +389,94 @@ int lstat(const char *file_name, struct stat *buf)
} }
#endif /* HAVE_LSTAT */ #endif /* HAVE_LSTAT */
static void
_convert_stat_stat64(struct stat64 *stto,struct stat *stfrom)
{
stto->st_dev = stfrom->st_dev;
stto->st_ino = stfrom->st_ino;
stto->st_mode = stfrom->st_mode;
stto->st_nlink = stfrom->st_nlink;
stto->st_uid = stfrom->st_uid;
stto->st_gid = stfrom->st_gid;
stto->st_rdev = stfrom->st_rdev;
stto->st_blksize = stfrom->st_blksize;
stto->st_blocks = stfrom->st_blocks;
stto->st_atime = stfrom->st_atime;
stto->st_mtime = stfrom->st_mtime;
stto->st_ctime = stfrom->st_ctime;
stto->st_size = (off64_t)stfrom->st_size;
}
/***********************************************************************
* stat64
*/
#ifndef HAVE_STAT64
int stat64(const char *file_name, struct stat64 *buf)
{
struct stat stbuf;
int res = stat(file_name,&stbuf);
_convert_stat_stat64(buf,&stbuf);
return res;
}
#endif /* HAVE_STAT64 */
/***********************************************************************
* lstat64
*/
#ifndef HAVE_LSTAT64
int lstat64(const char *file_name, struct stat64 *buf)
{
struct stat stbuf;
int res = lstat(file_name,&stbuf);
_convert_stat_stat64(buf,&stbuf);
return res;
}
#endif /* HAVE_LSTAT64 */
/*********************************************************************** /***********************************************************************
* fstat64
*/
#ifndef HAVE_FSTAT64
int fstat64(int fd, struct stat64 *buf)
{
struct stat stbuf;
int res = fstat(fd,&stbuf);
_convert_stat_stat64(buf,&stbuf);
return res;
}
#endif /* HAVE_FSTAT */
/***********************************************************************
* lseek64
*/
#ifndef HAVE_LSEEK64
off64_t lseek64(int fd, off64_t where, int whence)
{
off_t res;
if ((where >= 0x8000000LL) || ( where <= -0x7fffffffLL)) {
errno = EFBIG; /* FIXME: hack */
return -1;
}
res = lseek(fd,(off_t)where,whence);
return (off64_t)res;
}
#endif /* HAVE_LSEEK64 */
/***********************************************************************
* ftruncate64
*/
#ifndef HAVE_FTRUNCATE64
int ftruncate64(int fd, off64_t where)
{
if ((where >= 0x8000000LL) || ( where <= -0x7fffffffLL)) {
errno = EFBIG; /* FIXME: hack */
return -1;
}
return ftruncate(fd,(off_t)where);
}
#endif /* HAVE_LSEEK64 */
/***********************************************************************
* getrlimit * getrlimit
*/ */
#ifndef HAVE_GETRLIMIT #ifndef HAVE_GETRLIMIT
......
...@@ -21,7 +21,6 @@ asm(".org 0x110000"); ...@@ -21,7 +21,6 @@ asm(".org 0x110000");
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h> # include <sys/mman.h>
#endif #endif
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include "windef.h" #include "windef.h"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
......
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef linux #ifdef linux
#include <linux/fd.h> # include <linux/fd.h>
#endif #endif
#include "miscemu.h" #include "miscemu.h"
/* #define DEBUG_INT */ /* #define DEBUG_INT */
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# include <sys/file.h> # include <sys/file.h>
#endif #endif
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -152,7 +153,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a ...@@ -152,7 +153,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a
} }
/* FIXME: should set error to STATUS_OBJECT_NAME_COLLISION if file existed before */ /* FIXME: should set error to STATUS_OBJECT_NAME_COLLISION if file existed before */
if ((fd = open( name, flags | O_NONBLOCK, if ((fd = open( name, flags | O_NONBLOCK | O_LARGEFILE,
(attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666 )) == -1) (attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666 )) == -1)
goto file_error; goto file_error;
/* refuse to open a directory */ /* refuse to open a directory */
...@@ -161,7 +162,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a ...@@ -161,7 +162,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a
{ {
set_error( STATUS_ACCESS_DENIED ); set_error( STATUS_ACCESS_DENIED );
goto error; goto error;
} }
if (!(file = create_file_for_fd( fd, access, sharing, attrs ))) if (!(file = create_file_for_fd( fd, access, sharing, attrs )))
{ {
...@@ -258,11 +259,11 @@ static int file_flush( struct object *obj ) ...@@ -258,11 +259,11 @@ static int file_flush( struct object *obj )
static int file_get_info( struct object *obj, struct get_file_info_request *req ) static int file_get_info( struct object *obj, struct get_file_info_request *req )
{ {
struct stat st; struct stat64 st;
struct file *file = (struct file *)obj; struct file *file = (struct file *)obj;
assert( obj->ops == &file_ops ); assert( obj->ops == &file_ops );
if (fstat( file->obj.fd, &st ) == -1) if (fstat64( file->obj.fd, &st ) == -1)
{ {
file_set_error(); file_set_error();
return 0; return 0;
...@@ -275,8 +276,16 @@ static int file_get_info( struct object *obj, struct get_file_info_request *req ...@@ -275,8 +276,16 @@ static int file_get_info( struct object *obj, struct get_file_info_request *req
if (!(st.st_mode & S_IWUSR)) req->attr |= FILE_ATTRIBUTE_READONLY; if (!(st.st_mode & S_IWUSR)) req->attr |= FILE_ATTRIBUTE_READONLY;
req->access_time = st.st_atime; req->access_time = st.st_atime;
req->write_time = st.st_mtime; req->write_time = st.st_mtime;
req->size_high = 0; if (S_ISDIR(st.st_mode))
req->size_low = S_ISDIR(st.st_mode) ? 0 : st.st_size; {
req->size_high = 0;
req->size_low = 0;
}
else
{
req->size_high = st.st_size >> 32;
req->size_low = st.st_size & 0xffffffff;
}
req->links = st.st_nlink; req->links = st.st_nlink;
req->index_high = st.st_dev; req->index_high = st.st_dev;
req->index_low = st.st_ino; req->index_low = st.st_ino;
...@@ -331,21 +340,15 @@ struct file *get_file_obj( struct process *process, handle_t handle, unsigned in ...@@ -331,21 +340,15 @@ struct file *get_file_obj( struct process *process, handle_t handle, unsigned in
return (struct file *)get_handle_obj( process, handle, access, &file_ops ); return (struct file *)get_handle_obj( process, handle, access, &file_ops );
} }
static int set_file_pointer( handle_t handle, int *low, int *high, int whence ) static int set_file_pointer( handle_t handle, unsigned int *low, int *high, int whence )
{ {
struct file *file; struct file *file;
int result; off64_t result,xto;
if ((*low >= 0 && *high != 0) || (*low < 0 && *high != -1))
{
fprintf( stderr, "set_file_pointer: offset > 2Gb not supported yet\n" );
set_error( STATUS_INVALID_PARAMETER );
return 0;
}
xto = *low+((off64_t)*high<<32);
if (!(file = get_file_obj( current->process, handle, 0 ))) if (!(file = get_file_obj( current->process, handle, 0 )))
return 0; return 0;
if ((result = lseek( file->obj.fd, *low, whence )) == -1) if ((result = lseek64(file->obj.fd,xto,whence))==-1)
{ {
/* Check for seek before start of file */ /* Check for seek before start of file */
...@@ -358,7 +361,8 @@ static int set_file_pointer( handle_t handle, int *low, int *high, int whence ) ...@@ -358,7 +361,8 @@ static int set_file_pointer( handle_t handle, int *low, int *high, int whence )
release_object( file ); release_object( file );
return 0; return 0;
} }
*low = result; *low = result & 0xffffffff;
*high = result >> 32;
release_object( file ); release_object( file );
return 1; return 1;
} }
...@@ -366,12 +370,12 @@ static int set_file_pointer( handle_t handle, int *low, int *high, int whence ) ...@@ -366,12 +370,12 @@ static int set_file_pointer( handle_t handle, int *low, int *high, int whence )
static int truncate_file( handle_t handle ) static int truncate_file( handle_t handle )
{ {
struct file *file; struct file *file;
int result; off64_t result;
if (!(file = get_file_obj( current->process, handle, GENERIC_WRITE ))) if (!(file = get_file_obj( current->process, handle, GENERIC_WRITE )))
return 0; return 0;
if (((result = lseek( file->obj.fd, 0, SEEK_CUR )) == -1) || if (((result = lseek64( file->obj.fd, 0, SEEK_CUR )) == -1) ||
(ftruncate( file->obj.fd, result ) == -1)) (ftruncate64( file->obj.fd, result ) == -1))
{ {
file_set_error(); file_set_error();
release_object( file ); release_object( file );
...@@ -384,20 +388,16 @@ static int truncate_file( handle_t handle ) ...@@ -384,20 +388,16 @@ static int truncate_file( handle_t handle )
/* try to grow the file to the specified size */ /* try to grow the file to the specified size */
int grow_file( struct file *file, int size_high, int size_low ) int grow_file( struct file *file, int size_high, int size_low )
{ {
struct stat st; struct stat64 st;
off64_t size = size_low + (((off64_t)size_high)<<32);
if (size_high) if (fstat64( file->obj.fd, &st ) == -1)
{
set_error( STATUS_INVALID_PARAMETER );
return 0;
}
if (fstat( file->obj.fd, &st ) == -1)
{ {
file_set_error(); file_set_error();
return 0; return 0;
} }
if (st.st_size >= size_low) return 1; /* already large enough */ if (st.st_size >= size) return 1; /* already large enough */
if (ftruncate( file->obj.fd, size_low ) != -1) return 1; if (ftruncate64( file->obj.fd, size ) != -1) return 1;
file_set_error(); file_set_error();
return 0; return 0;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h> #include <sys/errno.h>
#endif #endif
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h> #include <sys/errno.h>
#endif #endif
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
# include <sys/errno.h> # include <sys/errno.h>
#endif #endif
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
......
...@@ -9,16 +9,9 @@ ...@@ -9,16 +9,9 @@
#include "config.h" #include "config.h"
#include <errno.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#include <fcntl.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <errno.h> #include <errno.h>
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
...@@ -56,7 +57,7 @@ BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes ) ...@@ -56,7 +57,7 @@ BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
*/ */
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes) BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
{ {
struct stat buf; struct stat64 buf;
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name )) if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
...@@ -69,7 +70,7 @@ BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes) ...@@ -69,7 +70,7 @@ BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n", FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
lpFileName,attributes); lpFileName,attributes);
} }
if(stat(full_name.long_name,&buf)==-1) if(stat64(full_name.long_name,&buf)==-1)
{ {
FILE_SetDosError(); FILE_SetDosError();
return FALSE; return FALSE;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment