Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2017 15:54:38 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        rgrimes@freebsd.org, cem@freebsd.org, Eitan Adler <eadler@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r326554 - in head: . usr.bin/sponge usr.bin/sponge/tests usr.bin/tee
Message-ID:  <5bd30132-aac7-e636-04c5-e57cbd65c54b@selasky.org>
In-Reply-To: <20171205134409.GV2272@kib.kiev.ua>
References:  <201712051258.vB5CwjQN051356@pdx.rh.CN85.dnsmgr.net> <22918eec-4c98-01e4-4c63-e145fbc6eab9@selasky.org> <20171205134409.GV2272@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/05/17 14:44, Konstantin Belousov wrote:
> On Tue, Dec 05, 2017 at 02:00:00PM +0100, Hans Petter Selasky wrote:
>> On 12/05/17 13:58, Rodney W. Grimes wrote:
>>> Further more, why does freebsd need this in base?
>> Hi,
>>
>> I think this is useful. It could replace the "-i " (intermediate) option
>> for "sed" for example. It avoids creating temporary files when filtering
>> files, right?

Hi,

> No, if process fails during the operation, user data is destroyed
> irretrievable.

It depends what you are doing. If the compiler crashes while outputting 
an object file and the atexit() hooks fail to remove the object file and 
you re-run the build, bad things can still happen and nobody will notice.

 From what I can see users must be aware of the limitations of any 
command they use in a script. Should probably be noted in the sponge 
manual page.

sponge could also have an atexit() hook to remove the processed file 
upon failure. Typically when patching files in packages, it is a waste 
of system resources to have a three step procedure, mv-process-mv, 
because when the build is complete the files will be deleted anyway ....

 >The usual trick of creating temporary file and renaming
> ensure that old file is around until all data for new file is written
> into buffer cache. With some existing filesystem support, it also
> guarantees that the old file is around in case of the system crash.

This process could also be automated with sponge. If some option XXX is 
set, backup the file first in a safe way, before writing it new. Further 
because sponge is a single utility, it can lock the files in question 
through the whole procedure to make the operation atomic w.r.t. the file 
system. Can you lock files from scripts? And what about performance and 
complexity?

> 
> All this assuming the tool' code matches its description, which is not.

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5bd30132-aac7-e636-04c5-e57cbd65c54b>