[comp.unix.questions] mutual exclusion write access

bause@exunido.uucp (Falko Bause) (07/28/89)

I want to allow only mutually exclusive write-accesses to a certain file.
I've searched through the manual pages and have only found commands
like lockf. But these commands only allow to establish a mutual
exlusive access for sub-processes of some process.

Let's explain, what I want, through an example:

There is a file (e.g.) named   text. I want that the following commands
getting only exclusive write access:
	du > text
	ls -R > text
	myprog > text        etc.


I think that this a basic problem and therefore UNIX should have some 
buildins. E.g. VAX/VMS and Apollo/Aegis support setting some file
attributes and mutual exclusion is performed by the operating system.
But chmod, I think, doesn't has this possibility.

Is there an easy way to perform mutual exclusion?

Thanks in advance

	Falko
	

abcscnge@csuna.csun.edu (Scott "The Pseudo-Hacker" Neugroschl) (07/31/89)

In article <1505@laura.UUCP> bause@exunido.UUCP (Falko Bause) writes:
]
]I want to allow only mutually exclusive write-accesses to a certain file.
]I've searched through the manual pages and have only found commands
]like lockf. But these commands only allow to establish a mutual
]exlusive access for sub-processes of some process.
]
]Let's explain, what I want, through an example:
]
]There is a file (e.g.) named   text. I want that the following commands
]getting only exclusive write access:
]	du > text
]	ls -R > text
]	myprog > text        etc.
]

This is kind of kludgy, but how about:

	( chmod 600 text ; du ) > text

This allows "text" to be writable only by you.  If you don't want yourself
to overwrite your own data:

	( chmod 400 text ; du ) > text

or, if you're REALLY paranoid:

	( chmod 000 text ; du ) > text

The shell creates "text" before executing the subshell commands, thus
the file is ALREADY open, so there is no problem with changing the modes.
Of course, the last is kind of useless, cuz you have to chmod text to some
readable mode.


-- 
Scott "The Pseudo-Hacker" Neugroschl
UUCP:  ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge
-- Beat me, Whip me, make me code in Ada
-- Disclaimers?  We don't need no stinking disclaimers!!!