Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    12

    Question 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
    Code:
    ERROR open_file(char *filename,..., MODE mode, SHARE_MODE sh_mode)
    in the function body the function calls windows API function CreateFile()
    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()
    Code:
    HANDLE CreateFile(
      LPCTSTR lpFileName,
      DWORD dwDesiredAccess,
      DWORD dwShareMode,
      LPSECURITY_ATTRIBUTES lpSecurityAttributes,
      DWORD dwCreationDisposition,
      DWORD dwFlagsAndAttributes,
      HANDLE hTemplateFile
    );
    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)

  2. #2
    Just 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...