Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jan 2003 14:04:23 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        rsharpe@richardsharpe.com
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: What prevents there from being a race with open(...,O_CREAT | O_EXCL,...)
Message-ID:  <20030111.140423.14801122.imp@bsdimp.com>
In-Reply-To: <Pine.LNX.4.33.0301101437330.2747-100000@ns.aus.com>
References:  <Pine.LNX.4.33.0301101437330.2747-100000@ns.aus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <Pine.LNX.4.33.0301101437330.2747-100000@ns.aus.com>
            Richard Sharpe <rsharpe@richardsharpe.com> writes:
: Hi,
: 
: In looking at vn_open, I see that it calls namei and then a little while 
: later calls VOP_CREATE.
: 
: If the user did open(..., ... O_CREAT | O_EXCL, ...), what prevents a race 
: where one process discovers that the name doesn't already exist but 
: another gets in and creates the name?

The kernel locks out such possibilities.  The 'create on open' stuff
is an atomic operation.  The O_EXCL precludes others from opening the
file as well as forcing an error to be returned if someone else had
just created the file an instance before the open happened.

Warner

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111.140423.14801122.imp>