Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Mtjhw-0002aQ-KU for mharc-grub-devel@gnu.org; Fri, 02 Oct 2009 11:06:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mtjhu-0002XY-UR for grub-devel@gnu.org; Fri, 02 Oct 2009 11:06:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mtjho-0002Nq-6O for grub-devel@gnu.org; Fri, 02 Oct 2009 11:06:04 -0400 Received: from [199.232.76.173] (port=35241 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mtjhn-0002NQ-Sw for grub-devel@gnu.org; Fri, 02 Oct 2009 11:05:59 -0400 Received: from mail-fx0-f205.google.com ([209.85.220.205]:47652) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mtjhn-0005by-CC for grub-devel@gnu.org; Fri, 02 Oct 2009 11:05:59 -0400 Received: by fxm1 with SMTP id 1so1053461fxm.31 for ; Fri, 02 Oct 2009 08:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=w/URXN4nWb2uy1iHjFCjew8jOhnul76zKqwlF6txaTc=; b=BPIZ+Irph3tF6k3ktQD6+DWITELF2eTH73KAzTp/FbI6wdEvIZDDZBYpLHejtLdTrP 5koFpHm800laZ/u+tvCGu5dSCvoapc1z+0AD86yMh3vn5olL42rGqES13teMU/nFVgYV v7osFok6OWHJZZT35hJZ57IAVPwj3qlzQFhEw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=nO/cnAjrxcVg1fiSepWyaod0+gsdC72/XwhqgvXoxpwEQ7ry6VAhCUowuFP0+aA0LP RHeWNU4kq52K+xicEZ0M73m58rzdNKKerDMOX0sd3Bm6qLhm3A2rlSzjaz1RdilhTqrZ 8T1U4c94OjcoKJgbcwoSH/DR6Ddr0F7dmH/iw= MIME-Version: 1.0 Received: by 10.239.144.79 with SMTP id n15mr226480hba.107.1254495958538; Fri, 02 Oct 2009 08:05:58 -0700 (PDT) In-Reply-To: <20091002085314.GD13423@riva.ucam.org> References: <20090930225430.GX13423@riva.ucam.org> <2e59e6970910011931r6e8051a3qd74a316111603e8e@mail.gmail.com> <20091002085314.GD13423@riva.ucam.org> Date: Fri, 2 Oct 2009 10:05:58 -0500 Message-ID: <2e59e6970910020805t92e84bdn49ade2a72de6380f@mail.gmail.com> From: "richardvoigt@gmail.com" To: The development of GRUB 2 Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] Create environment block safely X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2009 15:06:07 -0000 >> You might also need to check for the alternate name, in case the >> operation failed after writing the new content and unlinking the old >> file, but before renaming the new file. > > There is no old file here, or if there is then the user has already > explicitly indicated that they don't care about it. There is no unlink > call in my code (and wouldn't be even if this weren't a create > operation; no need to bother when you're renaming over the top anyway). I guess I didn't look closely enough at the rename docs: The rename() system call causes the link named old to be renamed as new. If new exists, it is first removed. Both old and new must be of the same type (that is, both must be either directories or non-directories) and must reside on the same file system. The rename() system call guarantees that an instance of new will always exist, even if the system should crash in the middle of the operation. So my unease was unfounded.