File sharing fixes.
This commit is contained in:
parent
23b06a8f18
commit
a370ab4eb7
13
files/file.c
13
files/file.c
|
@ -603,8 +603,13 @@ HFILE32 FILE_OpenUnixFile( const char *name, int mode )
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* FILE_Open
|
* FILE_Open
|
||||||
|
*
|
||||||
|
* path[I] name of file to open
|
||||||
|
* mode[I] mode how to open, in unix notation
|
||||||
|
* shareMode[I] the sharing mode in the win OpenFile notation
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
HFILE32 FILE_Open( LPCSTR path, INT32 mode )
|
HFILE32 FILE_Open( LPCSTR path, INT32 mode, INT32 shareMode )
|
||||||
{
|
{
|
||||||
DOS_FULL_NAME full_name;
|
DOS_FULL_NAME full_name;
|
||||||
const char *unixName;
|
const char *unixName;
|
||||||
|
@ -640,7 +645,7 @@ HFILE32 FILE_Open( LPCSTR path, INT32 mode )
|
||||||
unixName = full_name.long_name;
|
unixName = full_name.long_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
dosMode = FILE_UnixToDosMode(mode);
|
dosMode = FILE_UnixToDosMode(mode)| shareMode;
|
||||||
fileInUse = FILE_InUse(full_name.long_name,&oldMode);
|
fileInUse = FILE_InUse(full_name.long_name,&oldMode);
|
||||||
if(fileInUse)
|
if(fileInUse)
|
||||||
{
|
{
|
||||||
|
@ -1409,9 +1414,7 @@ HFILE32 WINAPI _lopen32( LPCSTR path, INT32 mode )
|
||||||
TRACE(file, "('%s',%04x)\n", path, mode );
|
TRACE(file, "('%s',%04x)\n", path, mode );
|
||||||
|
|
||||||
unixMode= FILE_DOSToUnixMode(mode);
|
unixMode= FILE_DOSToUnixMode(mode);
|
||||||
unixMode |= (mode &0x70); /* transfer the OF_SHARE options to handle
|
return FILE_Open( path, unixMode , (mode & 0x70));
|
||||||
them in FILE_Open*/
|
|
||||||
return FILE_Open( path, unixMode );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ extern HFILE32 FILE_DupUnixHandle( int fd );
|
||||||
extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
|
extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
|
||||||
extern HFILE32 FILE_Dup( HFILE32 hFile );
|
extern HFILE32 FILE_Dup( HFILE32 hFile );
|
||||||
extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
|
extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
|
||||||
extern HFILE32 FILE_Open( LPCSTR path, INT32 mode );
|
extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode);
|
||||||
extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
|
extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
|
||||||
extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
|
extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
|
||||||
extern LPVOID FILE_mmap( HFILE32 hFile, LPVOID start,
|
extern LPVOID FILE_mmap( HFILE32 hFile, LPVOID start,
|
||||||
|
|
|
@ -295,7 +295,7 @@ DWORD __cdecl CRTDLL_fopen(LPCSTR path, LPCSTR mode)
|
||||||
else if (strchr(mode,'b'))
|
else if (strchr(mode,'b'))
|
||||||
TRACE(crtdll, "%s in BINARY mode\n",path);
|
TRACE(crtdll, "%s in BINARY mode\n",path);
|
||||||
|
|
||||||
dos_fildes=FILE_Open(path, flagmode);
|
dos_fildes=FILE_Open(path, flagmode,0);
|
||||||
unix_fildes=FILE_GetUnixHandle(dos_fildes);
|
unix_fildes=FILE_GetUnixHandle(dos_fildes);
|
||||||
file = fdopen(unix_fildes,mode);
|
file = fdopen(unix_fildes,mode);
|
||||||
|
|
||||||
|
@ -1199,7 +1199,7 @@ HFILE32 __cdecl CRTDLL__open(LPCSTR path,INT32 flags)
|
||||||
TRACE(crtdll,"CRTDLL_open file unsupported flags 0x%04x\n",flags);
|
TRACE(crtdll,"CRTDLL_open file unsupported flags 0x%04x\n",flags);
|
||||||
/* End Fixme */
|
/* End Fixme */
|
||||||
|
|
||||||
ret = FILE_Open(path,wineflags);
|
ret = FILE_Open(path,wineflags,0);
|
||||||
TRACE(crtdll,"CRTDLL_open file %s mode 0x%04x (lccmode 0x%04x) got dfh %d\n",
|
TRACE(crtdll,"CRTDLL_open file %s mode 0x%04x (lccmode 0x%04x) got dfh %d\n",
|
||||||
path,wineflags,flags,ret);
|
path,wineflags,flags,ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -607,7 +607,7 @@ void VXD_Win32s( CONTEXT *context )
|
||||||
IMAGE_NT_HEADERS *nt_header = PE_HEADER(module->baseAddr);
|
IMAGE_NT_HEADERS *nt_header = PE_HEADER(module->baseAddr);
|
||||||
IMAGE_SECTION_HEADER *pe_seg = PE_SECTIONS(module->baseAddr);
|
IMAGE_SECTION_HEADER *pe_seg = PE_SECTIONS(module->baseAddr);
|
||||||
|
|
||||||
HFILE32 image = FILE_Open(module->pathName, O_RDONLY);
|
HFILE32 image = FILE_Open(module->pathName, O_RDONLY,0);
|
||||||
BOOL32 error = (image == INVALID_HANDLE_VALUE32);
|
BOOL32 error = (image == INVALID_HANDLE_VALUE32);
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
|
||||||
|
|
31
win32/file.c
31
win32/file.c
|
@ -27,6 +27,7 @@ DWORD ErrnoToLastError(int errno_num);
|
||||||
|
|
||||||
static int TranslateCreationFlags(DWORD create_flags);
|
static int TranslateCreationFlags(DWORD create_flags);
|
||||||
static int TranslateAccessFlags(DWORD access_flags);
|
static int TranslateAccessFlags(DWORD access_flags);
|
||||||
|
static int TranslateShareFlags(DWORD share_flags);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* WriteFile (KERNEL32.578)
|
* WriteFile (KERNEL32.578)
|
||||||
|
@ -129,13 +130,14 @@ HFILE32 WINAPI CreateFile32A(LPCSTR filename, DWORD access, DWORD sharing,
|
||||||
LPSECURITY_ATTRIBUTES security, DWORD creation,
|
LPSECURITY_ATTRIBUTES security, DWORD creation,
|
||||||
DWORD attributes, HANDLE32 template)
|
DWORD attributes, HANDLE32 template)
|
||||||
{
|
{
|
||||||
int access_flags, create_flags;
|
int access_flags, create_flags, share_flags;
|
||||||
HFILE32 to_dup = HFILE_ERROR32; /* handle to dup */
|
HFILE32 to_dup = HFILE_ERROR32; /* handle to dup */
|
||||||
|
|
||||||
/* Translate the various flags to Unix-style.
|
/* Translate the various flags to Unix-style.
|
||||||
*/
|
*/
|
||||||
access_flags = TranslateAccessFlags(access);
|
access_flags = TranslateAccessFlags(access);
|
||||||
create_flags = TranslateCreationFlags(creation);
|
create_flags = TranslateCreationFlags(creation);
|
||||||
|
share_flags = TranslateShareFlags(sharing);
|
||||||
|
|
||||||
if(template)
|
if(template)
|
||||||
FIXME(file, "template handles not supported.\n");
|
FIXME(file, "template handles not supported.\n");
|
||||||
|
@ -183,7 +185,7 @@ HFILE32 WINAPI CreateFile32A(LPCSTR filename, DWORD access, DWORD sharing,
|
||||||
handle = HFILE_ERROR32;
|
handle = HFILE_ERROR32;
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
return FILE_Open( filename, access_flags | create_flags );
|
return FILE_Open( filename, access_flags | create_flags,share_flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,8 +254,29 @@ static int TranslateCreationFlags(DWORD create_flags)
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
static int TranslateShareFlags(DWORD share_flags)
|
||||||
|
/*
|
||||||
|
OPEN_SHARE_DENYNONE FILE_SHARE_READ | FILE_SHARE_WRITE
|
||||||
|
OPEN_SHARE_DENYREAD FILE_SHARE_WRITE
|
||||||
|
OPEN_SHARE_DENYREADWRITE 0
|
||||||
|
OPEN_SHARE_DENYWRITE FILE_SHARE_READ
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
switch(share_flags)
|
||||||
|
{
|
||||||
|
case FILE_SHARE_READ | FILE_SHARE_WRITE:
|
||||||
|
return OF_SHARE_DENY_NONE;
|
||||||
|
case FILE_SHARE_WRITE:
|
||||||
|
return OF_SHARE_DENY_READ;
|
||||||
|
case FILE_SHARE_READ:
|
||||||
|
return OF_SHARE_DENY_WRITE;
|
||||||
|
case 0:
|
||||||
|
return OF_SHARE_EXCLUSIVE;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
FIXME(file,"unknown sharing flags 0x%04lx\n",share_flags);
|
||||||
|
return OF_SHARE_EXCLUSIVE;
|
||||||
|
}
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* SetFileAttributes16 (KERNEL.421)
|
* SetFileAttributes16 (KERNEL.421)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue