Open fdncred opened 8 months ago
Does this issue only occur when moving files between different drives? I tried it locally and uutils mv maintains the access, modify and birth timestamps.
$ touch a
$ mkdir b
$ stat a
File: a
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 10304h/66308d Inode: 2097353 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ mtiman) Gid: ( 1000/ mtiman)
Access: 2024-02-24 17:21:58.597614640 +0200
Modify: 2024-02-24 17:21:58.597614640 +0200
Change: 2024-02-24 17:21:58.597614640 +0200
Birth: 2024-02-24 17:21:58.597614640 +0200
$ ../target/debug/coreutils mv a b/
$ stat b/a
File: b/a
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 10304h/66308d Inode: 2097353 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ mtiman) Gid: ( 1000/ mtiman)
Access: 2024-02-24 17:21:58.597614640 +0200
Modify: 2024-02-24 17:21:58.597614640 +0200
Change: 2024-02-24 17:22:18.265634719 +0200
Birth: 2024-02-24 17:21:58.597614640 +0200
Let me know if I misunderstood anything.
@mtimaN The original issue is linked above where @sgon00 talks about moving files to an external drive.
@mtimaN yeah, this issue only happens when moving files to/from external drives. I am running Ubuntu 23.10. Both internal drive filesystem and external drive filesystem are ext4
.
(Btw, they are both LUKS encrypted, but I don't think that does matter).
Edited: The external drive is connected via type-c USB port.
I think this issue is exceeding my expertise.. I don't get why uutils' mv would work differently if the destination is on another drive.
@mtimaN It's probably because we try to use std::fs::rename
, which can't move between file systems and then we fall back to alternative implementation if that fails. So the problem is with that alternative implementation.
@mtimaN It's probably because we try to use
std::fs::rename
, which can't move between file systems and then we fall back to alternative implementation if that fails. So the problem is with that alternative implementation.
Thanks! I took a better look at the code and identified the alternative implementation. However, it seems that uutils' implementation yields the same results as GNU's so I don't think that it should be changed.
In the case of adding a new flag for treating this option, I tried using fs::FileTimes but it doesn't seem to work when trying to change the accessed time.
Feature Request related to #6002
It may be helpful to some users for mv to be able to maintain attributes like timestamps when moving files to/from internal/external drives, or really just moving files/folders in general.
A nushell user requested this functionality. Here's the linked issue. https://github.com/nushell/nushell/issues/11943
Kind of related with cp https://github.com/uutils/coreutils/issues/4192