In smbc_open_ctx(), the call to cli_open() always use the parameter DENY_NONE, which makes possible to an other program to open a writing in progress file, which might result to strange behaviours... Maybe, DENY_DOS should be a better choice: if the file is opened for reading, others can read but cannot write and if the file is opened for writing, others cannot open the file at all.
The libsmbclient library is providing a POSIX-like interface. If the file being opened were a local Unix/Linux file, no automatic locking would occur. This behavior is emulated in smbc_open_ctx(). In fact, changing that now would create backwards compatibility issues. I can see one wanting the behavior you describe, however. As I have some time (probably not in the next few weeks), I'll look into adding an option that allows the user to specify the deny mode for smbc_open_ctx().
The new option "open_share_mode" (as of check-in 18013) may now be used to set the share mode value that will be passed to cli_open(). To use this, after obtaining your context but before issuing the cli_open() call, do: smbc_option_set(context, "open_share_mode", share_mode); where share_mode is one of the values in the enum smbc_share_mode, now in libsmbclient.h. To maintain POSIX functionality and backward compatibility, the default is still DENY_NONE (SMBC_SHAREMODE_DENY_NONE). Please let me know how this works for you. Derrell
No reply from OP. Assuming it's fixed. Closing.