Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file locking problem about smb sharing network file



freelucas <email@hidden> wrote:

>... The file located in a sharing
>directory of a smb server mounted to a local file system. I use the
>mac os X 10.3.3.
>The souce code showed as following:
>    RandomAccessFile raf =
>        new RandomAccessFile(parametersPath+"lock.dat", "rw");
>    FileChannel channel = raf.getChannel();
>    FileLock lock = channel.lock();
>When program executed to channel.lock(), java throw a IOException:
>Operation not supported.
>I never met the problem when i run the codes on the windows or linux.

Was the server mounted via SMB on those platforms?


>And it never happended when i lock a local file!

Locking a local file is different from locking a networked file.

Read FileLock's API docs, the section titled "Platform dependencies".  It
discusses how locks are dependent on platform implementations, OS,
filesystem, etc.  The closing sentence sums up with:
  In general, great care should be taken when locking
  files that reside on network filesystems.

And even more generally, you have to be prepared for a NIO operation not
being supported.


>So i think it is a
>java problem of file locking on network filesystem of Mac OS.

Locks might not be implemented at all on a networked SMB filesystem,
regardless of whether it's Java or C or ObjC that's trying to get the lock.


>I have
>found some document about the smb file lock on Mac OS X. But they are
>not relevant to java.

Which documents did you find, and why did you conclude they aren't relevant
to Java?

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.