Results 1 to 2 of 2
Hi all
I have a situation where I have a function written in Windows and need to be ported on Linux.
function has prototype something like this
Code:
ERROR open_file(char ...
- 03-19-2008 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 12
Is there File Share Mode in Linux
Hi all
I have a situation where I have a function written in Windows and need to be ported on Linux.
function has prototype something like this
in the function body the function calls windows API function CreateFile()Code:ERROR open_file(char *filename,..., MODE mode, SHARE_MODE sh_mode)
to open the file. CreateFile() also takes a parameter for Share Mode. The effect of share mode is that if we provide 0 value for this argument then while the file handle is open no other process can read or write to this file.
here is the prototype for CreateFile()
My problem is that while I can have found almost all flags for mode and other in Linux open() system call but I found no match for this Share Mode alternative. While my file descriptor is still open other process can access the file and change its contents. Please some one guide me that what is the best possible alternative in Linux to provide complete functionality of this Share Mode option. Windows provides 3 flags FILE_SHARE_CREATE, FILE_SHARE_READ, FILE_SHARE_DELETE and zero(0)Code:HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile );
- 03-19-2008 #2Just Joined!
- Join Date
- Mar 2008
- Posts
- 3
All files in *nix are assumed shared. There are are file locking primitives see: fcntl(3): file control - Linux man page


Reply With Quote