Discussion:
How to open a file in share mode
(too old to reply)
Anjina Murthy
2004-07-08 09:49:28 UTC
Permalink
Hello,

How to open a file in share mode in linux ( in 'C' ).

Thanks in advance.
Ilja Tabachnik
2004-07-08 10:14:18 UTC
Permalink
Post by Anjina Murthy
Hello,
How to open a file in share mode in linux ( in 'C' ).
Hmmm... what do you mean by "share mode" ?
--
Ilja.
Grant Edwards
2004-07-08 14:44:39 UTC
Permalink
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
1) Quit multi-posting.

2) What is "share mode"?
--
Grant Edwards grante Yow! What a
at COINCIDENCE! I'm an
visi.com authorized "SNOOTS OF THE
STARS" dealer!!
David Schwartz
2004-07-08 22:18:10 UTC
Permalink
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?

DS
Anjina Murthy
2004-07-24 06:32:43 UTC
Permalink
Share mode means, when a file is opened by one process for writing or
reading the same file must be able to open by one more process for
reading.

We specify FILE_SHARE_READ and FILE_SHARE_WRITE flag in win32
CreateFile function ,is there anything similar to that.

Anjan
Post by David Schwartz
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?
DS
Larry I Smith
2004-07-24 15:08:43 UTC
Permalink
Post by Anjina Murthy
Share mode means, when a file is opened by one process for writing or
reading the same file must be able to open by one more process for
reading.
We specify FILE_SHARE_READ and FILE_SHARE_WRITE flag in win32
CreateFile function ,is there anything similar to that.
Anjan
Post by David Schwartz
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?
DS
Well, under unix and linux many things are handled automatically
by the kernel and the security system. For example a process
may or may not have permission to read/write to a file depending
on the file's permissions setup when the file was created.

If a process opens a file and starts writing to it, other
processes may read from it (assuming the file's security
settings allow it). The 'tail' command demonstrates this;
you can start a process that writes to a file (say 'junk.txt')
then run 'tail -f junk.txt' and 'tail' will continuosly show
the last few lines in the file as it is extended by the original
program.

There are many sophisticted file monitoring and access features
available under unix and linux. So, if you provide a little
more detail about what you need to do, we can probably
provide more detailed answers.

Regards,
Larry
--
Anti-spam address, change each 'X' to '.' to reply directly.
Ian Hilliard
2004-07-24 17:03:13 UTC
Permalink
Post by Anjina Murthy
Share mode means, when a file is opened by one process for writing or
reading the same file must be able to open by one more process for
reading.
We specify FILE_SHARE_READ and FILE_SHARE_WRITE flag in win32 CreateFile
function ,is there anything similar to that.
Anjan
Post by David Schwartz
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?
DS
Unix and Linux use cooperative locking of files. The files are not locked
by the OS. As such, there is no need to set any flags in order to be able
to share files. That is why it is possible to tail a file and not have the
file locked. If the file is deleted while open for reading or writing, the
OS will not fail, only the read or write attempt.

I will not get on my soap box, but I will say, "Windows is a prime example
of how an OS should NOT be built." A friend of mine likes to say, "You
just have to look at the Win32 API's to know that the Coke machines in
Redmond had the Real Thing."

Ian
Mikko Rauhala
2004-07-24 17:57:57 UTC
Permalink
Post by Ian Hilliard
If the file is deleted while open for reading or writing, the
OS will not fail, only the read or write attempt.
I'd like to chime in here with a "not quite". An *nix OS will not
delete an open file, but simply unlink it from the filesystem.
A file is deleted only when no links point to it _and_ no process
has it open.
--
Mikko Rauhala - ***@iki.fi - <URL:http://www.iki.fi/mjr/>
Transhumanist - WTA member - <URL:http://www.transhumanism.org/>
Singularitarian - SIAI supporter - <URL:http://www.singinst.org/>
Ian Hilliard
2004-07-24 19:13:58 UTC
Permalink
Post by Mikko Rauhala
Post by Ian Hilliard
If the file is deleted while open for reading or writing, the
OS will not fail, only the read or write attempt.
I'd like to chime in here with a "not quite". An *nix OS will not
delete an open file, but simply unlink it from the filesystem.
A file is deleted only when no links point to it _and_ no process
has it open.
On the other hand, you can rename or delete a file which is being
monitored with tail -f, under Unix. That is not possible under Windows.

Ian

John Hasler
2004-07-24 17:40:15 UTC
Permalink
Post by Ian Hilliard
Unix and Linux use cooperative locking of files. The files are not locked
by the OS.
Madatory locking is available. See
/usr/src/linux/Documentation/mandatory.txt.
--
John Hasler
***@dhh.gt.org
Dancing Horse Hill
Elmwood, Wisconsin
David Schwartz
2004-07-24 17:52:09 UTC
Permalink
Post by Anjina Murthy
Share mode means, when a file is opened by one process for writing or
reading the same file must be able to open by one more process for
reading.
It is.
Post by Anjina Murthy
We specify FILE_SHARE_READ and FILE_SHARE_WRITE flag in win32
CreateFile function ,is there anything similar to that.
There is nothing special you need to do. UNIX doesn't normally have any
kind of implicit locking (except for executables while they're running).

DS
Anjina Murthy
2004-07-24 06:32:56 UTC
Permalink
Share mode means, when a file is opened by one process for writing or
reading the same file must be able to open by one more process for
reading.

We specify FILE_SHARE_READ and FILE_SHARE_WRITE flag in win32
CreateFile function ,is there anything similar to that.

Anjan
Post by David Schwartz
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?
DS
Anjina Murthy
2004-07-24 06:40:55 UTC
Permalink
share mode means when a file is opened either in read or write mode by
one process the same file must be opened by other process.

In win32 CreateFile method we have FILE_SHARE_READ nad
FILE_SHARE_WRITE flags is there any thing similar to that

Thanks in advance

Anjan
Post by David Schwartz
Post by Anjina Murthy
How to open a file in share mode in linux ( in 'C' ).
Umm, what is "share mode"?
DS
Last2Know
2004-07-09 02:55:24 UTC
Permalink
Post by Anjina Murthy
Hello,
How to open a file in share mode in linux ( in 'C' ).
If "share mode" has something to do with file permissions
then look at the manual page for "umask". If it is
something to do with sharing files between computers,
then that is a system administration question about NFS
or Samba, relevant to some other group (and not something
normally to be done from a C language program).
Continue reading on narkive:
Loading...