Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Anyone interested in implementing O_NOCLOBBER ?



POSIX are considering this:

    O_NOCLOBBER

        If O_CREAT and O_NOCLOBBER are set, open() shall fail if the file
	exists and is either a regular file or a symbolic link that resolves
	to a regular file. The check for the existence and type of the file
	and the creation of the file if it does not exist shall be atomic
	with respect to other threads executing open() naming the same
	filename in the same directory with O_NOCLOBBER and O_CREAT set
	or with O_EXCL and O_CREAT set. If O_NOCLOBBER and O_CREAT are set,
	and the file exists and is either a non-regular file or a symbolic
	link that resolves to a non-regular file, the file shall be opened
	as if neither flag was set. If O_NOCLOBBER and O_CREAT are set,
	and path names a symbolic link that does not resolve to an existing
	file, an empty file shall be created such that path resolves to the
	newly created file. If O_NOCLOBBER is set and O_CREAT is not set,
	the result is undefined.

but only if there are implementation(s).

Anyone care to add this to NetBSD?

Its main purpose would be to implement noclobber mode (set -C) in sh
(and one presumes, the similar thing in csh).

See https://austingroupbugs.net/view.php?id=1016 for more info, and the
alternative if O_NOCLOBBER mode isn't implemented by anyone.

O_NOCLOBBER|O_CREAT is intended to be the same as O_EXCL|O_CREAT when the
file named is a regular file, but unlike the O_EXCL variant, succeed if
the file is a special file (like /dev/ttyN) which exists already.

kre



Home | Main Index | Thread Index | Old Index