From: Ray Strode Subject: Re: RFC: O_PONIES semantics (well O_REWRITE) Date: Fri, 12 Jun 2009 13:06:01 -0400 (EDT) Message-ID: <1489854494.3398231244826361345.JavaMail.root@zmail02.collab.prod.int.phx2.redhat.com> References: <20090612022028.GB19977@parisc-linux.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Jamie Lokier , Rik van Riel , linux-fsdevel , elb@psg.com To: Matthew Wilcox Return-path: Received: from mx2.redhat.com ([66.187.237.31]:36732 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753827AbZFLRGL (ORCPT ); Fri, 12 Jun 2009 13:06:11 -0400 In-Reply-To: <20090612022028.GB19977@parisc-linux.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, > On Fri, Jun 12, 2009 at 03:07:38AM +0100, Jamie Lokier wrote: > > > Some of the common failures are: > > > - program overwrites the old config file > > > - program writes a new file, but forgets to fsync before rename > > > - program writes the new file in /tmp, so the rename fails on > > > some systems > > > - program writes a new file and fsyncs, but forgets to give the > > > new file the same file ownership, permission and/or extended > > > attributes as the old file > > > > It's also really hard to do those things from shell scripts, so they > > are almost never done there. > > That's a good point, but O_(PONIES|REWRITE) doesn't fix that problem, > since shell scripts can't specify it, and shells can't do it automatically > for all files created. Well, it's not really the shells that need to be able to do it, it's the helper utilities that shell scripts use. For instance, sed should use O_REWRITE if -i is passed. Still, you could imagine a new type of redirection operator that exposed O_REWRITE, e.g., cat >>> config-file.cfg << EOF [config] Value=foo EOF --Ray