GNU bug report logs - #20091
mv command

Previous Next

Package: coreutils;

Reported by: "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>

Date: Wed, 11 Mar 2015 22:38:02 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20091 in the body.
You can then email your comments to 20091 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#20091; Package coreutils. (Wed, 11 Mar 2015 22:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 11 Mar 2015 22:38:02 GMT) Full text and rfc822 format available.

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

From: "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: mv  command
Date: Wed, 11 Mar 2015 21:02:14 +0000
[Message part 1 (text/plain, inline)]
Is it ever possible for the mv command  ( without using the -u option )  to
leave the  file(s)  in the source directory, while also copying to the
destination directory?

We were experiencing this under  zsh   and  GNU/Linux  2.6.32-358.18.1.el6.x86_64.

Any  comments appreciated!


thanks!

Charles Rogers


[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20091; Package coreutils. (Wed, 11 Mar 2015 23:23:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>, 
 20091 <at> debbugs.gnu.org
Subject: Re: bug#20091: mv  command
Date: Wed, 11 Mar 2015 23:22:29 +0000
On 11/03/15 21:02, Rogers, Charles (MAN-Corporate-CON) wrote:
> Is it ever possible for the mv command  ( without using the –u option )  to
> 
> leave the  file(s)  in the source directory, while also copying to the
> 
> destination directory?
> 
>  
> 
> We were experiencing this under  zsh   and  GNU/Linux  2.6.32-358.18.1.el6.x86_64.
> 
>  
> 
> Any  comments appreciated!

this is mv --version 8.4 right?
How reproducible is this?
Could you send an strace from this smallest reproducer?

thanks,
Pádraig.





Information forwarded to bug-coreutils <at> gnu.org:
bug#20091; Package coreutils. (Thu, 12 Mar 2015 17:46:01 GMT) Full text and rfc822 format available.

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

From: Bob Proulx <bob <at> proulx.com>
To: Charles Rogers <Charles.Rogers <at> DealShield.com>, 20091 <at> debbugs.gnu.org
Subject: Re: bug#20091: mv  command
Date: Thu, 12 Mar 2015 11:45:49 -0600
Pádraig Brady wrote:
> Charles Rogers wrote:
> > Is it ever possible for the mv command ( without using the –u
> > option ) to leave the file(s) in the source directory, while also
> > copying to the destination directory?
> >...
> > Any  comments appreciated!

Your description implies that your destination is on a different file
system from your source.  Is this one one source directory or multiple
source directories being copied at one time?

In order for mv to decide it needs to copy a file it would need to
detect that the destination directory is on a different file system
from the source directory.  If so then mv will copy the file to the
destination location and remove the file from the source location.
The mv documentation describes this in some detail.

       ‘mv’ can move any type of file from one file system to another.
    Prior to version ‘4.0’ of the fileutils, ‘mv’ could move only
    regular files between file systems.  For example, now ‘mv’ can
    move an entire directory hierarchy including special device files
    from one partition to another.  It first uses some of the same
    code that’s used by ‘cp -a’ to copy the requested directories and
    files, then (assuming the copy succeeded) it removes the
    originals.  If the copy fails, then the part that was copied to
    the destination partition is removed.  If you were to copy three
    directories from one partition to another and the copy of the
    first directory succeeded, but the second didn’t, the first would
    be left on the destination partition and the second and third
    would be left on the original partition.

Copying files across file systems and removing them from the source is
a non-atomic operation.  There is always the possibility that the
process will be stopped (possibly by being killed or other
possibilities) after it has copied a file to the destination but
before it has removed the file from the source location.  It is not
possible to perform an atomic move across different file systems.  Any
of those possibilities should result in mv exiting non-zero and
returning an error status to the caller.  Most possibilities (not
SIGKILL which cannot be trapped) will result in mv printing an error
message to stderr.  Generally if mv has an error there should be an
error message and a non-zero exit status returned to the caller.

Bob




Information forwarded to bug-coreutils <at> gnu.org:
bug#20091; Package coreutils. (Thu, 12 Mar 2015 22:11:02 GMT) Full text and rfc822 format available.

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

From: "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>
To: Bob Proulx <bob <at> proulx.com>, "20091 <at> debbugs.gnu.org"
 <20091 <at> debbugs.gnu.org>, "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Cc: "Karciauskaite,
 Renata \(DealShield\)" <Renata.Karciauskaite <at> DealShield.com>
Subject: RE: bug#20091: mv  command
Date: Thu, 12 Mar 2015 22:10:22 +0000
[Message part 1 (text/plain, inline)]
Thank you all so much for the explanation.   It is as you describe.



1.  We had insufficient permissions on the source directory

2.  The destination directory was indeed on a different file system



So, our question is answered, and again thanks.



Charles Rogers          (  on behalf of  Renata Karciauskaite )







-----Original Message-----
From: Bob Proulx [mailto:bob <at> proulx.com]
Sent: Thursday, March 12, 2015 1:46 PM
To: Rogers, Charles (MAN-Corporate-CON); 20091 <at> debbugs.gnu.org
Subject: Re: bug#20091: mv command



Pádraig Brady wrote:

> Charles Rogers wrote:

> > Is it ever possible for the mv command ( without using the –u

> >option ) to leave the file(s) in the source directory, while also

> >copying to the destination directory?

> >...

> > Any  comments appreciated!



Your description implies that your destination is on a different file system from your source.  Is this one one source directory or multiple source directories being copied at one time?



In order for mv to decide it needs to copy a file it would need to detect that the destination directory is on a different file system from the source directory.  If so then mv will copy the file to the destination location and remove the file from the source location.

The mv documentation describes this in some detail.



       ‘mv’ can move any type of file from one file system to another.

    Prior to version ‘4.0’ of the fileutils, ‘mv’ could move only

    regular files between file systems.  For example, now ‘mv’ can

    move an entire directory hierarchy including special device files

    from one partition to another.  It first uses some of the same

    code that’s used by ‘cp -a’ to copy the requested directories and

    files, then (assuming the copy succeeded) it removes the

    originals.  If the copy fails, then the part that was copied to

    the destination partition is removed.  If you were to copy three

    directories from one partition to another and the copy of the

    first directory succeeded, but the second didn’t, the first would

    be left on the destination partition and the second and third

    would be left on the original partition.



Copying files across file systems and removing them from the source is a non-atomic operation.  There is always the possibility that the process will be stopped (possibly by being killed or other

possibilities) after it has copied a file to the destination but before it has removed the file from the source location.  It is not possible to perform an atomic move across different file systems.  Any of those possibilities should result in mv exiting non-zero and returning an error status to the caller.  Most possibilities (not SIGKILL which cannot be trapped) will result in mv printing an error message to stderr.  Generally if mv has an error there should be an error message and a non-zero exit status returned to the caller.



Bob
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20091; Package coreutils. (Thu, 12 Mar 2015 22:27:02 GMT) Full text and rfc822 format available.

Reply sent to Bob Proulx <bob <at> proulx.com>:
You have taken responsibility. (Thu, 12 Mar 2015 22:31:02 GMT) Full text and rfc822 format available.

Notification sent to "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>:
bug acknowledged by developer. (Thu, 12 Mar 2015 22:31:02 GMT) Full text and rfc822 format available.

Message #22 received at 20091-done <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: "Rogers, Charles (MAN-Corporate-CON)" <Charles.Rogers <at> DealShield.com>
Cc: 20091-done <at> debbugs.gnu.org, "Karciauskaite,
 Renata \(DealShield\)" <Renata.Karciauskaite <at> DealShield.com>
Subject: Re: bug#20091: mv  command
Date: Thu, 12 Mar 2015 16:29:58 -0600
Rogers, Charles (MAN-Corporate-CON) wrote:
> Thank you all so much for the explanation.   It is as you describe.
> 
> 1.  We had insufficient permissions on the source directory
> 2.  The destination directory was indeed on a different file system

Ah!  All is explained.

> So, our question is answered, and again thanks.

Very good.  I am glad it worked out for you.  I will close this bug
ticket with this message then.

Bob




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 10 Apr 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 68 days ago.

Previous Next


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