help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: command for swapping of two files or two dirs?


From: Eli Schwartz
Subject: Re: command for swapping of two files or two dirs?
Date: Fri, 26 Mar 2021 17:34:16 -0400

On 3/26/21 5:21 PM, Peng Yu wrote:
> The problem is that the swap based on multiple commands is not atomic.
> 
> With multiple commands, wouldn't it cause complications for error
> recovery? Also, is it safe? If there is any malicious program delete
> some files during the process?


If you feel the need for "atomic" swapping, then rename/renameat being
run three times very fast in a single command written in C, will still
not be atomic -- merely fast.

You're going to need to figure out how to implement this at the
filesystem or kernel level, not as a "well-maintained command".

Or, you may give up on formally guaranteed atomicity, and use 'mv' three
times fast.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]