[jcifs] Read locking / read sharing

Michael B Allen miallen at ioplex.com
Thu Sep 27 15:25:13 GMT 2007


On Thu, 27 Sep 2007 11:05:57 -0400
Jake Goulding <goulding at vivisimo.com> wrote:

> Does jCIFS open a file with the ability for other processes to continue
> reading from the file? If it does, is that by default, or do special
> options need to be set somewhere?

Hi Jake,

There are three types of locking. There are oplocks and byte-range
locks. JCIFS does not support either of these and as such never requests
them.

The third is the SMB_COM_NT_CREATE_ANDX ShareFlags:

  SmbFile.FILE_SHARE_READ
  SmbFile.FILE_SHARE_WRITE
  SmbFile.FILE_SHARE_DELETE

These flags can be set in SmbFile constructors that accept the
'shareAccess' parameter but are otherwise all on by default to indicate
that open files may be shared for read, write and delete (FILE_SHARE_READ
| FILE_SHARE_WRITE | FILE_SHARE_DELETE).

If you do not set one or more of these flags, another process trying to
access the file (inculding JCIFS) may get an error:

  0xC0000043
  NT_STATUS_SHARING_VIOLATION
  The process cannot access the file because it is being used by another
  process.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/


More information about the jcifs mailing list