GNU bug report logs - #29961
[PATCH] mv: document the missing atomicity of 'mv -n'

Previous Next

Package: coreutils;

Reported by: Kamil Dudka <kdudka <at> redhat.com>

Date: Wed, 3 Jan 2018 15:03:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 29961 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Kamil Dudka <kdudka <at> redhat.com>, 29961 <at> debbugs.gnu.org
Subject: Re: bug#29961: [PATCH] mv: document the missing atomicity of 'mv -n'
Date: Wed, 3 Jan 2018 15:08:51 +0000
On 03/01/18 15:01, Kamil Dudka wrote:
> * 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\

Eep, Seems like we should use RENAME_NOREPLACE in this case,
rather than document the caveat?
This is already used in shred.

cheers,
Pádraig




This bug report was last modified 7 years and 139 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.