Subject: bug#29961: closed (Re: bug#29961: [PATCH] mv -n: do not overwrite the destination)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 10 Jan 2018 08:54:02 +0000

Your bug report

#29961: [PATCH] mv: document the missing atomicity of 'mv -n'

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
29961: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29961
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination
From: Paul Eggert <[email-masked]>
To: Pádraig Brady <[email-masked]>, Kamil Dudka <[email-masked]>
Cc: [email-masked]
Date: Wed, 10 Jan 2018 00:53:07 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

No further comment, so I installed the proposed patches and I'm closing this bug 
report.

Subject: [PATCH] mv: document the missing atomicity of 'mv -n'
From: Kamil Dudka <[email-masked]>
To: [email-masked]
Date: Wed, 3 Jan 2018 16:01:47 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

* src/mv.c (usage): Add note about the missing atomicity of 'mv -n'.
* doc/coreutils.texi (mv invocation): Likewise.
---
 doc/coreutils.texi | 3 +++
 src/mv.c           | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 3fa083085..e7ca6a737 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -9660,6 +9660,9 @@ If the response is not affirmative, the file is skipped.
 Do not overwrite an existing file.
 @mvOptsIfn
 This option is mutually exclusive with @option{-b} or @option{--backup} option.
+Note that the operation is not atomic.  If @var{dest} appears after
+@command{mv} has checked its non-existence, it can be overwritten despite
+the @option{-n} option is used.
 
 @item -u
 @itemx --update
diff --git a/src/mv.c b/src/mv.c
index a8df730a7..a08e75649 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -306,6 +306,8 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\
   -i, --interactive            prompt before overwrite\n\
   -n, --no-clobber             do not overwrite an existing file\n\
 If you specify more than one of -i, -f, -n, only the final one takes effect.\n\
+NOTE: The operation is not atomic.  If DEST appears after mv has checked its\n\
+non-existence, it can be overwritten despite the -n option is used.\n\
 "), stdout);
       fputs (_("\
       --strip-trailing-slashes  remove any trailing slashes from each SOURCE\n\
-- 
2.13.6