[sheepdog] [PATCH 2/3] util:add a new API atomic_create_and_write()

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Apr 17 08:00:57 CEST 2013

At Wed, 17 Apr 2013 13:55:09 +0800,
Liu Yuan wrote:
> On 04/17/2013 01:45 PM, Hitoshi Mitake wrote:
> > +	if (!access(tmp_path, F_OK))
> > +		panic("temporal file: %s exists, this implies invalid usage of"
> > +			" atomic_create_and_write() of sheepdog", tmp_path);
> panic() is too stringent and not necessary. open(2) will return error if
> it has any problem with the tmp_path. So I'd suggest remove this if clause.

I admit the access(2) is unnecesary because open(2) can fail with
EEXIST. But I believe this panic() is required because existing
temporal files imply misuage of the API. I believe we should employ
defensive way.

How do you think?


More information about the sheepdog mailing list