Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the share mode for fopen()?

2,572 views
Skip to first unread message

Rover

unread,
Nov 2, 2009, 7:30:01 PM11/2/09
to
Hi all,

I know there is a function called _fsopen() that allows one to specify the
file sharing mode.

Does anyone know what is the assumed file sharing mode when one calls
fopen()? What is the equivalent to CreateFile's share mode value?

My experiments allow me to open two files at the same time in two different
process irrespective of reading or writing. But I have not tried to write or
read from them.

Thanks.

Rover

Alex Blekhman

unread,
Nov 3, 2009, 4:40:59 AM11/3/09
to
"Rover" wrote:
> I know there is a function called _fsopen() that allows one to
> specify the file sharing mode.
>
> Does anyone know what is the assumed file sharing mode when one
> calls fopen()? What is the equivalent to CreateFile's share mode
> value?

You could just debug the `fopen' call. VS ships with the source
code for CRT library. `fopen' is a mere wrapper over _fsopen(...,
_SH_DENYNO) call.

Alex

Leon

unread,
Nov 15, 2009, 12:43:35 AM11/15/09
to
Hi Alex,

Thanks for the advice.

So without proper concurrency control and file locking, multiple users of a
file can use fopen() to open the file but their access will corrupt the file
or retrieving corrupted data much like failure to control access to a share
resource in MT programming. Is that what will happen?

Leon

"Alex Blekhman" <tkfx....@yahoo.com> wrote in message
news:uTMrBnGX...@TK2MSFTNGP06.phx.gbl...

Alex Blekhman

unread,
Nov 15, 2009, 7:02:30 AM11/15/09
to
"Leon" wrote:
> So without proper concurrency control and file locking, multiple
> users of a file can use fopen() to open the file but their
> access will corrupt the file or retrieving corrupted data much
> like failure to control access to a share resource in MT
> programming. Is that what will happen?

Exactly. SH_DENYNO flag permits read and write access to a file.
Without proper synchronization you'll corrupt a file.

Alex

0 new messages