From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <49c8e5f6ae1f50391b40e6465b4a8818@plan9.jp> To: 9fans@cse.psu.edu Subject: Re: [9fans] non-truncating create From: Joel “chesky” Salomon Date: Mon, 9 Oct 2006 02:09:54 -0400 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: c75314e2-ead1-11e9-9d60-3106f5b1d025 > Rc just tries the open, and if that fails, tries the create. > It doesn't even bother looking at the error code. > If the open failed due to permissions, so will the create. Drawterm barfed on me and I lost the bit of code this suggested; when I tried to recreate it I ended up checking for OTRUNC a few times. Not pretty. > Or use create with OEXCL if you really care. Sort of the way create(2) calls create(5) first, then open(5) if that failed? My code now looks like: o =3D create(oname, omode|OEXCL, ~0); /* fails if file exists */ if(o < 0) o =3D open(oname, omode); if(o < 0){ complain("can=E2=80=99t open %s for writing: %r", oname); return; } which has no special-case code depending on OTRUNC being set or no. I suppose I ought to look at /sys/src/cmd/rc to see how it=E2=80=99s real= ly done. Ma=C3=B1ana. Thanks for the assist. --Joel