On Tue, 11 Apr 2017 16:54:29 +0200
Ingo Schwarze <[email protected]> wrote:

> Hi,
> 
> [email protected] wrote on Fri, Apr 07, 2017 at 12:25:10PM
> +1000:
> 
> > Although mv(1) will preserve atime and mtime for moved directories
> > if moved to a different file system, it doesn't preserve them when
> > moved in the same file system.  
> 
> Cannot reproduce.
> 
>    $ mkdir Foo
>    $ touch -t 200001010000 Foo 
>    $ ls -dl Foo                
>   drwxr-xr-x  2 schwarze  schwarze  512 Jan  1  2000 Foo
>    $ ls -dlu Foo
>   drwxr-xr-x  2 schwarze  schwarze  512 Jan  1  2000 Foo
>    $ mv Foo Bar
>    $ ls -dl Bar  
>   drwxr-xr-x  2 schwarze  schwarze  512 Jan  1  2000 Bar
>    $ ls -dlu Bar
>   drwxr-xr-x  2 schwarze  schwarze  512 Jan  1  2000 Bar

I can:

$ mkdir Foo
$ touch -t 200001010000 Foo
$ ls -dlT Foo
drwxr-xr-x  2 bob  bob  512 Jan  1 00:00:00 2000 Foo
$ ls -dluT Foo
drwxr-xr-x  2 bob  bob  512 Jan  1 00:00:00 2000 Foo
$ mkdir Bar
$ mv Foo Bar/
$ ls -dlT Bar/Foo
drwxr-xr-x  2 bob  bob  512 Apr 12 07:55:30 2017 Foo/Bar
$ ls -dluT Bar/Foo
drwxr-xr-x  2 bob  bob  512 Jan  1 00:00:00 2000 Foo/Bar

Note that I have noatime on this FS.

> Sounds like a bad idea.  Do not add non-standard options to standard
> utilities unless they are useful to a very unusual degree.  Even if
> there is some corner case that you failed to describe, this seems
> by far not important enough for adding an option.

The problem I am solving here is that, when moving folders into other
folders (often to clean up its parent a little and organise the FS),
mv(1) does not preserve the time stamps of moved directories.

If I move the directory into another FS, this information is preserved.

> Besides, neither FreeBSD nor NetBSD have -p, so it would be an
> egregious example of introducing gratuitious incompatibility.

I don't see any gratuitious incompatibility here. The utility behaves
exactly as before without the -p option, and will therefore be
compatible with existing scripts.

It may help to modify the behaviour of rename(2), since there is
nothing I see in the POSIX standard
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html)
about requiring the change in time stamps. The advantage is consistent
behaviour across all applications rather than just mv(1).

Reply via email to