Thread: Mac - File locking with fcntl() fails on shared volumes!?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    142
    I take it the suggested workarounds in your link is no good for some reason?
    Suggested workarounds?

    This one: "to create a "lockfile" in the same directory as the file being opened."

    They actually recommend fcntl() and say: "By using advisory locking, your application will be able to work in a cooperative manner with Carbon, Classic, and other applications in the future."

    I tried adding O_EXLOCK + O_NONBLOCK to open() but it didn't help.

    Anything else that I missed? Is this how it works only on BSD or can I expect problems on Linux? I see "Kernel hacker" beside your name...

    Ah, and I have this book by Arnold Robbins, Linux Programming by Example where he covers on pg 532 flock(), fcntl() and lockf().
    Maybe I should try my luck with flock() or lockf()?

    And even in Beginning Linux Programming, by Neil Matthew & Richard Stones they use fcntl() without any warnings about "shared volumes".
    Last edited by idelovski; 11-10-2008 at 04:19 PM. Reason: These Books by Robbins & others

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    142
    Coolest sentence on that document above:

    AppleShare servers and Personal File Sharing on Mac OS X do enforce exclusive file access
    and range locking for volumes accessed over the network. However, this functionality is only
    available when accessing files over a networked file sharing connection and is not available to
    applications running on the server itself.
    And it is in total opposition to what I'm experiencing here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM