Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7E0BE40DEE1 for ; Tue, 16 Nov 2010 14:16:48 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I8XP+6lIek8Q for ; Tue, 16 Nov 2010 14:16:38 -0800 (PST) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by olra.theworths.org (Postfix) with ESMTP id 4467C40DDF7 for ; Tue, 16 Nov 2010 14:16:38 -0800 (PST) Received: by qyk4 with SMTP id 4so1355983qyk.5 for ; Tue, 16 Nov 2010 14:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=N5XOx7UxMxSDd2/C6+5bOuPr51dvItjhawtKsoQo4Vw=; b=kaEGlw1znjeVUwiqjrH+USN9hdfzxPx7uM1jMVVT1AS04FtwULf+A9A1KHVJF87Iok +EmfFhGZmOjR3ilXvpxM9HXpvksgo2pD9ZYFluIHuBWnUlEu/mEuMc4BZ2nlHbLPOGi8 NPNuIB9i6eilWKJwnM1Rw+N0aglxuF9vbRLn4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=ssAnyYVkTQoLsaRD9fqjzSUIB1U3bvaFif92qtqqtCxIvT1U2USDR6UQfF52X2YI9S K8IaHB6wsWvC4UnPEkL1gn/NFnxv9dPAXqe3vFaaAAIT5q36lYCYQgDs7uq7fWiQe4cX E0DDloqmX7zxiu4tHAXnLZeLk+ZI4sh9q5pXs= Received: by 10.229.232.211 with SMTP id jv19mr6794076qcb.28.1289945797700; Tue, 16 Nov 2010 14:16:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.189.17 with HTTP; Tue, 16 Nov 2010 14:16:07 -0800 (PST) In-Reply-To: <4CE2EB89.5040209@fifthhorseman.net> References: <87sjz1dr0j.fsf@yoom.home.cworth.org> <4CE2EB89.5040209@fifthhorseman.net> From: "Ciprian Dorin, Craciun" Date: Wed, 17 Nov 2010 00:16:07 +0200 Message-ID: Subject: Re: `notmuch setup` replaces `~/.notmuch-config` instead of truncating it To: notmuch Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2010 22:16:48 -0000 On Tue, Nov 16, 2010 at 22:37, Daniel Kahn Gillmor wrote: > On 11/16/2010 03:26 PM, Ciprian Dorin, Craciun wrote: >> =C2=A0 =C2=A0 P.S.: I say "pseudo" atomic because only the rename is ato= mic, >> thus in order to override file `a` for the target file `b` which >> exists, we must execute two **non-atomic** operations as a whole, but >> each atomic in part, rename operations: make `b` -> `c`, and then >> rename `a` -> `b`. So there is actually a small time-frame when I can >> be left with two files (`a` and `c`), none of which is my config file >> `b`. (This can be solved when opening the config file by checking if >> there isn't any leftover `c` or `a` file, in which case I take the `a` >> file and complete the rename.) > > There is only one ".notmuch-config" entry in the inode directory that is > your homedir. =C2=A0it points either to the old file, or the new file. = =C2=A0it > cannot point to both, and it will not point to anything but those two > possibilities. =C2=A0This is what the atomicity of the operation is expec= ted > to guarantee. > > =C2=A0 =C2=A0 =C2=A0 =C2=A0--dkg Actually I've been wrong about this... I've thought that the way the file is "overwritten" is actually done by either two `rename` calls or by `link`, followed by another `link`, and then finally an `unlink` (this is what I've tried to explain in my previous email). In fact I've thought that the `rename` OS call can't overwrite a file if it exists. But after reading the man page of `rename(2)` -- quoted below -- I was indeed wrong to call the atomicity as being "pseudo". ~~~~ int rename(const char *oldpath, const char *newpath); ... If newpath already exists it will be atomically replaced (subject to a few conditions; see ERRORS below), so that there is no point at which another process attempting to access newpath will find it missing. ... If newpath exists but the operation fails for some reason rename() guarantees to leave an instance of newpath in place. ~~~~ So indeed the behavior is completely atomic. Ciprian.