GNU bug report logs - #61050
mv: add support for --one-file-system

Previous Next

Package: coreutils;

Reported by: Mike Frysinger <vapier <at> gentoo.org>

Date: Wed, 25 Jan 2023 01:21:01 UTC

Severity: wishlist

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

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 61050 in the body.
You can then email your comments to 61050 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#61050; Package coreutils. (Wed, 25 Jan 2023 01:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Frysinger <vapier <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 25 Jan 2023 01:21:02 GMT) Full text and rfc822 format available.

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

From: Mike Frysinger <vapier <at> gentoo.org>
To: bug-coreutils <at> gnu.org
Subject: mv: add support for --one-file-system
Date: Tue, 24 Jan 2023 20:20:40 -0500
[Message part 1 (text/plain, inline)]
mv will automatically use rename, but if that fails (e.g. with EXDEV),
it falls back to copying files.  i'd like to require that the mv be
atomic when relocating a directory, and if it isn't, fallback to other
logic.  to that end, it'd be nice if mv supported --one-file-system and
would return an error when hitting EXDEV rather than copying.
-mike
[signature.asc (application/pgp-signature, inline)]

Severity set to 'wishlist' from 'normal' Request was from Mike Frysinger <vapier <at> gentoo.org> to control <at> debbugs.gnu.org. (Wed, 25 Jan 2023 02:28:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#61050; Package coreutils. (Wed, 25 Jan 2023 09:08:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Mike Frysinger <vapier <at> gentoo.org>
Cc: 61050 <at> debbugs.gnu.org
Subject: Re: bug#61050: mv: add support for --one-file-system
Date: Wed, 25 Jan 2023 01:07:48 -0800
[Message part 1 (text/plain, inline)]
On 2023-01-24 17:20, Mike Frysinger wrote:
> i'd like to require that the mv be
> atomic when relocating a directory, and if it isn't, fallback to other
> logic

Calling the new option "--one-file-system" sounds a bit wrong, as 
--one-file-system is for programs like 'du' and 'cp' and causes them to 
not cross a file system boundary when recursing - something that 'mv' 
could also do (when it falls back on copying), but which is a different 
thing than what you're asking for.

How about if we call the new option --no-copy instead? Something like 
the attached incomplete patch, say. (It needs more documentation and 
ideally a test case.)
[no-copy.diff (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#61050; Package coreutils. (Wed, 25 Jan 2023 10:35:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Mike Frysinger <vapier <at> gentoo.org>
Cc: 61050 <at> debbugs.gnu.org
Subject: Re: bug#61050: mv: add support for --one-file-system
Date: Wed, 25 Jan 2023 10:33:56 +0000
On 25/01/2023 09:07, Paul Eggert wrote:
> On 2023-01-24 17:20, Mike Frysinger wrote:
>> i'd like to require that the mv be
>> atomic when relocating a directory, and if it isn't, fallback to other
>> logic
> 
> Calling the new option "--one-file-system" sounds a bit wrong, as
> --one-file-system is for programs like 'du' and 'cp' and causes them to
> not cross a file system boundary when recursing - something that 'mv'
> could also do (when it falls back on copying), but which is a different
> thing than what you're asking for.
> 
> How about if we call the new option --no-copy instead? Something like
> the attached incomplete patch, say. (It needs more documentation and
> ideally a test case.)

--no-copy is better more general naming.
I can see the usefulness of this, so +1 from me.

thanks,
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#61050; Package coreutils. (Wed, 25 Jan 2023 13:35:01 GMT) Full text and rfc822 format available.

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

From: Mike Frysinger <vapier <at> gentoo.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 61050 <at> debbugs.gnu.org
Subject: Re: bug#61050: mv: add support for --one-file-system
Date: Wed, 25 Jan 2023 08:34:45 -0500
On 25 Jan 2023 01:07, Paul Eggert wrote:
> On 2023-01-24 17:20, Mike Frysinger wrote:
> > i'd like to require that the mv be
> > atomic when relocating a directory, and if it isn't, fallback to other
> > logic
> 
> Calling the new option "--one-file-system" sounds a bit wrong, as 
> --one-file-system is for programs like 'du' and 'cp' and causes them to 
> not cross a file system boundary when recursing - something that 'mv' 
> could also do (when it falls back on copying), but which is a different 
> thing than what you're asking for.
> 
> How about if we call the new option --no-copy instead? Something like 
> the attached incomplete patch, say. (It needs more documentation and 
> ideally a test case.)

either works for me, thanks

should there be a `--copy` flag to be able to undo `--no-copy` ?

> --- a/src/copy.c
> +++ b/src/copy.c
> @@ -2617,7 +2617,7 @@ copy_internal (char const *src_name, char const *dst_name,
>           where you'd replace '18' with the integer in parentheses that
>           was output from the perl one-liner above.
>           If necessary, of course, change '/tmp' to some other directory.  */
> -      if (rename_errno != EXDEV)
> +      if (rename_errno != EXDEV || x->no_copy)

personally i always argue against using negative variable names.  it's hard to
reason about, and reads like awkward english which requires multiple scans to
convince myself that it's correct.  but i rarely work on the coreutils code,
so feel free to ignore.
-mike




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Fri, 27 Jan 2023 19:14:02 GMT) Full text and rfc822 format available.

Notification sent to Mike Frysinger <vapier <at> gentoo.org>:
bug acknowledged by developer. (Fri, 27 Jan 2023 19:14:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Mike Frysinger <vapier <at> gentoo.org>
Cc: 61050-done <at> debbugs.gnu.org
Subject: Re: bug#61050: mv: add support for --one-file-system
Date: Fri, 27 Jan 2023 11:13:30 -0800
[Message part 1 (text/plain, inline)]
On 2023-01-25 05:34, Mike Frysinger wrote:
> should there be a `--copy` flag to be able to undo `--no-copy` ?

We can add one if there's a need, but mv doesn't have a --clobber option 
to match its --no-clobber and I'm hoping --no-copy is similar.

> personally i always argue against using negative variable names

Yes, I considered calling it "rename_only" instead of "no_copy", but the 
pull of the --no-copy option's name was too strong. Besides, 
"rename_only" wasn't quite right either as "mv --no-copy" does more than 
just renaming (e.g., if the destination is not writeable).

If we can come up with a better name now's a good time to switch. In the 
meantime I installed the attached coreutils patch.
[0001-mv-new-option-no-copy.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#61050; Package coreutils. (Fri, 27 Jan 2023 19:51:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: 61050 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu, vapier <at> gentoo.org
Subject: Re: bug#61050: mv: add support for --one-file-system
Date: Fri, 27 Jan 2023 19:50:18 +0000
On 27/01/2023 19:13, Paul Eggert wrote:
> On 2023-01-25 05:34, Mike Frysinger wrote:
>> should there be a `--copy` flag to be able to undo `--no-copy` ?
> 
> We can add one if there's a need, but mv doesn't have a --clobber option
> to match its --no-clobber and I'm hoping --no-copy is similar.
> 
>> personally i always argue against using negative variable names
> 
> Yes, I considered calling it "rename_only" instead of "no_copy", but the
> pull of the --no-copy option's name was too strong. Besides,
> "rename_only" wasn't quite right either as "mv --no-copy" does more than
> just renaming (e.g., if the destination is not writeable).
> 
> If we can come up with a better name now's a good time to switch. In the
> meantime I installed the attached coreutils patch.

Looks good. I pushed this tweak.

thanks,
Pádraig

commit 95bc69a7e71dd2a9b2ca11452be19fa856eb2bbf (HEAD -> master)
Author: Pádraig Brady <P <at> draigBrady.com>
Date:   Fri Jan 27 19:46:52 2023 +0000

    tests: ensure we fail if mv --no-copy crashes

    * tests/mv/no-copy.sh: Honor `make syntax` check
    and use the `returns_ 1 ...` pattern.

diff --git a/tests/mv/no-copy.sh b/tests/mv/no-copy.sh
index fba475c03..5a55fdf74 100755
--- a/tests/mv/no-copy.sh
+++ b/tests/mv/no-copy.sh
@@ -25,8 +25,8 @@ mkdir dir || framework_failure_
 > dir/a || framework_failure_
 > file || framework_failure_

-mv --no-copy dir "$other_partition_tmpdir" && fail=1
-mv --no-copy file "$other_partition_tmpdir" && fail=1
+returns_ 1 mv --no-copy dir "$other_partition_tmpdir" || fail=1
+returns_ 1 mv --no-copy file "$other_partition_tmpdir" || fail=1
 mv dir "$other_partition_tmpdir" || fail=1
 mv file "$other_partition_tmpdir" || fail=1





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 Feb 2023 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 111 days ago.

Previous Next


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