diff options
author | julien.pierre.bugs%sun.com <devnull@localhost> | 2005-04-22 21:16:11 +0000 |
---|---|---|
committer | julien.pierre.bugs%sun.com <devnull@localhost> | 2005-04-22 21:16:11 +0000 |
commit | a7ff1abac180ad2485ae09864c901c90988318a5 (patch) | |
tree | b2797ceaff90e1aee4ad4a9eee6289a40cb47f3e | |
parent | 3a9d9d1d2b55f03893975b478d130e065cf16645 (diff) | |
download | nspr-hg-a7ff1abac180ad2485ae09864c901c90988318a5.tar.gz |
Fix for bug 170911 - add support for >2GB files on OS/2. r=mkaply, pedemonteSOFTWARE_UPDATE_20050428_BASE
-rw-r--r-- | pr/include/md/_os2.h | 8 | ||||
-rw-r--r-- | pr/src/md/os2/os2io.c | 252 | ||||
-rw-r--r-- | pr/src/md/os2/os2sock.c | 6 |
3 files changed, 211 insertions, 55 deletions
diff --git a/pr/include/md/_os2.h b/pr/include/md/_os2.h index 3539eb6a..c012e32e 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -38,6 +38,9 @@ #ifndef nspr_os2_defs_h___ #define nspr_os2_defs_h___ +#ifndef NO_LONG_LONG +#define INCL_LONGLONG +#endif #define INCL_DOS #define INCL_DOSPROCESS #define INCL_DOSERRORS @@ -151,7 +154,10 @@ struct _MDSegment { struct _MDDir { HDIR d_hdl; - FILEFINDBUF3 d_entry; + union { + FILEFINDBUF3 small; + FILEFINDBUF3L large; + } d_entry; PRBool firstEntry; /* Is this the entry returned * by FindFirstFile()? */ PRUint32 magic; /* for debugging */ diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index d2e19104..185ba973 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -76,6 +76,55 @@ struct _MDLock _pr_ioq_lock; +static PRBool isWSEB = PR_FALSE; /* whether we are using an OS/2 kernel that supports large files */ + +typedef APIRET (*DosOpenLType)(PSZ pszFileName, PHFILE pHf, PULONG pulAction, + LONGLONG cbFile, ULONG ulAttribute, + ULONG fsOpenFlags, ULONG fsOpenMode, + PEAOP2 peaop2); + +typedef APIRET (*DosSetFileLocksLType)(HFILE hFile, PFILELOCKL pflUnlock, + PFILELOCKL pflLock, ULONG timeout, + ULONG flags); + +typedef APIRET (*DosSetFilePtrLType)(HFILE hFile, LONGLONG ib, ULONG method, + PLONGLONG ibActual); + +DosOpenLType myDosOpenL; +DosSetFileLocksLType myDosSetFileLocksL; +DosSetFilePtrLType myDosSetFilePtrL; + +void +_PR_MD_INIT_IO() +{ + APIRET rc; + HMODULE module; + + sock_init(); + + rc = DosLoadModule(NULL, 0, "DOSCALL1", &module); + if (rc != NO_ERROR) + { + return; + } + rc = DosQueryProcAddr(module, 981, NULL, (PFN*) &myDosOpenL); + if (rc != NO_ERROR) + { + return; + } + rc = DosQueryProcAddr(module, 986, NULL, (PFN*) &myDosSetFileLocksL); + if (rc != NO_ERROR) + { + return; + } + rc = DosQueryProcAddr(module, 988, NULL, (PFN*) &myDosSetFilePtrL); + if (rc != NO_ERROR) + { + return; + } + isWSEB = PR_TRUE; +} + PRStatus _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks) { @@ -180,7 +229,20 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) } do { - rc = DosOpen((char*)name, + if (isWSEB) + { + rc = myDosOpenL((char*)name, + &file, /* file handle if successful */ + &actionTaken, /* reason for failure */ + 0, /* initial size of new file */ + FILE_NORMAL, /* file system attributes */ + flags, /* Open flags */ + access, /* Open mode and rights */ + 0); /* OS/2 Extended Attributes */ + } + else + { + rc = DosOpen((char*)name, &file, /* file handle if successful */ &actionTaken, /* reason for failure */ 0, /* initial size of new file */ @@ -188,6 +250,7 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) flags, /* Open flags */ access, /* Open mode and rights */ 0); /* OS/2 Extended Attributes */ + }; if (rc == ERROR_TOO_MANY_OPEN_FILES) { ULONG CurMaxFH = 0; LONG ReqCount = 20; @@ -297,6 +360,7 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) PRInt32 where, rc, lo = (PRInt32)offset, hi = (PRInt32)(offset >> 32); PRUint64 rv; PRUint32 newLocation, uhi; + PRUint64 newLocationL; switch (whence) { @@ -312,15 +376,26 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) default: PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return -1; -} - - rc = DosSetFilePtr((HFILE)fd->secret->md.osfd, lo, where, (PULONG)&newLocation); + } + if (isWSEB) + { + rc = myDosSetFilePtrL((HFILE)fd->secret->md.osfd, offset, where, (PLONGLONG)&newLocationL); + } + else + { + rc = DosSetFilePtr((HFILE)fd->secret->md.osfd, lo, where, (PULONG)&newLocation); + } if (rc != NO_ERROR) { _PR_MD_MAP_LSEEK_ERROR(rc); return -1; } + if (isWSEB) + { + return newLocationL; + } + uhi = (PRUint32)hi; PR_ASSERT((PRInt32)uhi >= 0); rv = uhi; @@ -360,8 +435,8 @@ _MD_CloseFile(PRInt32 osfd) /* --- DIR IO ------------------------------------------------------------ */ -#define GetFileFromDIR(d) (d)->d_entry.achName -#define GetFileAttr(d) (d)->d_entry.attrFile +#define GetFileFromDIR(d) (isWSEB?(d)->d_entry.large.achName:(d)->d_entry.small.achName) +#define GetFileAttr(d) (isWSEB?(d)->d_entry.large.attrFile:(d)->d_entry.small.attrFile) void FlipSlashes(char *cp, int len) { @@ -414,13 +489,26 @@ _PR_MD_OPEN_DIR(_MDDir *d, const char *name) d->d_hdl = HDIR_CREATE; - rc = DosFindFirst( filename, - &d->d_hdl, - FILE_DIRECTORY | FILE_HIDDEN, - &(d->d_entry), - sizeof(d->d_entry), - &numEntries, - FIL_STANDARD); + if (isWSEB) + { + rc = DosFindFirst( filename, + &d->d_hdl, + FILE_DIRECTORY | FILE_HIDDEN, + &(d->d_entry.large), + sizeof(d->d_entry.large), + &numEntries, + FIL_STANDARDL); + } + else + { + rc = DosFindFirst( filename, + &d->d_hdl, + FILE_DIRECTORY | FILE_HIDDEN, + &(d->d_entry.small), + sizeof(d->d_entry.small), + &numEntries, + FIL_STANDARD); + } if ( rc != NO_ERROR ) { _PR_MD_MAP_OPENDIR_ERROR(rc); return PR_FAILURE; @@ -567,13 +655,34 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) { PRFileInfo info32; PRInt32 rv = _PR_MD_GETFILEINFO(fn, &info32); - if (0 == rv) + if (rv != 0) { - info->type = info32.type; - LL_UI2L(info->size,info32.size); - info->modifyTime = info32.modifyTime; - info->creationTime = info32.creationTime; + return rv; } + info->type = info32.type; + LL_UI2L(info->size,info32.size); + info->modifyTime = info32.modifyTime; + info->creationTime = info32.creationTime; + + if (isWSEB) + { + APIRET rc ; + FILESTATUS3L fstatus; + + rc = DosQueryPathInfo(fn, FIL_STANDARDL, &fstatus, sizeof(fstatus)); + + if (NO_ERROR != rc) + { + _PR_MD_MAP_OPEN_ERROR(rc); + return -1; + } + + if (! (fstatus.attrFile & FILE_DIRECTORY)) + { + info->size = fstatus.cbFile; + } + } + return rv; } @@ -623,17 +732,37 @@ _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info) { - PRFileInfo info32; - PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, &info32); - if (0 == rv) - { + PRFileInfo info32; + PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, &info32); + if (0 == rv) + { info->type = info32.type; LL_UI2L(info->size,info32.size); - + info->modifyTime = info32.modifyTime; info->creationTime = info32.creationTime; - } - return rv; + } + + if (isWSEB) + { + APIRET rc ; + FILESTATUS3L fstatus; + + rc = DosQueryFileInfo(fd->secret->md.osfd, FIL_STANDARDL, &fstatus, sizeof(fstatus)); + + if (NO_ERROR != rc) + { + _PR_MD_MAP_OPEN_ERROR(rc); + return -1; + } + + if (! (fstatus.attrFile & FILE_DIRECTORY)) + { + info->size = fstatus.cbFile; + } + } + + return rv; } @@ -701,25 +830,38 @@ _PR_MD_RMDIR(const char *name) PRStatus _PR_MD_LOCKFILE(PRInt32 f) { - PRInt32 rv; - FILELOCK lock, unlock; - - lock.lOffset = 0; - lock.lRange = 0xffffffff; - unlock.lOffset = 0; - unlock.lRange = 0; - - /* + PRInt32 rv; + FILELOCK lock, unlock; + FILELOCKL lockL, unlockL; + + lock.lOffset = 0; + lockL.lOffset = 0; + lock.lRange = 0xffffffff; + lockL.lRange = 0xffffffffffffffff; + unlock.lOffset = 0; + unlock.lRange = 0; + unlockL.lOffset = 0; + unlockL.lRange = 0; + + /* * loop trying to DosSetFileLocks(), * pause for a few miliseconds when can't get the lock * and try again */ for( rv = FALSE; rv == FALSE; /* do nothing */ ) { - + if (isWSEB) + { + rv = myDosSetFileLocksL( (HFILE) f, + &unlockL, &lockL, + 0, 0); + } + else + { rv = DosSetFileLocks( (HFILE) f, &unlock, &lock, - 0, 0); + 0, 0); + } if ( rv != NO_ERROR ) { DosSleep( 50 ); /* Sleep() a few milisecs and try again. */ @@ -738,25 +880,39 @@ _PR_MD_TLOCKFILE(PRInt32 f) PRStatus _PR_MD_UNLOCKFILE(PRInt32 f) { - PRInt32 rv; - FILELOCK lock, unlock; - - lock.lOffset = 0; - lock.lRange = 0; - unlock.lOffset = 0; - unlock.lRange = 0xffffffff; + PRInt32 rv; + FILELOCK lock, unlock; + FILELOCKL lockL, unlockL; - rv = DosSetFileLocks( (HFILE) f, - &unlock, &lock, - 0, 0); + lock.lOffset = 0; + lockL.lOffset = 0; + lock.lRange = 0; + lockL.lRange = 0; + unlock.lOffset = 0; + unlockL.lOffset = 0; + unlock.lRange = 0xffffffff; + unlockL.lRange = 0xffffffffffffffff; + + if (isWSEB) + { + rv = myDosSetFileLocksL( (HFILE) f, + &unlockL, &lockL, + 0, 0); + } + else + { + rv = DosSetFileLocks( (HFILE) f, + &unlock, &lock, + 0, 0); + } if ( rv != NO_ERROR ) { - return PR_SUCCESS; + return PR_SUCCESS; } else { - return PR_FAILURE; + return PR_FAILURE; } } /* end _PR_MD_UNLOCKFILE() */ diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c index d1b2fdd3..3e8d8286 100644 --- a/pr/src/md/os2/os2sock.c +++ b/pr/src/md/os2/os2sock.c @@ -64,12 +64,6 @@ #define _OS2_IOCTL so_ioctl #endif -void -_PR_MD_INIT_IO() -{ - sock_init(); -} - /* --- SOCKET IO --------------------------------------------------------- */ |