diff options
author | Ricardo Branco <rbranco@suse.de> | 2024-03-16 17:13:10 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2024-04-16 13:18:15 +0000 |
commit | 428f86fd2ff1fd2b073d556fac273c8c7f457376 (patch) | |
tree | 5643c1c0657bd2799ef7227bb540e29363ae13b9 /bin | |
parent | 219d8fb0361f459ab458f17fe58da32ea00c0104 (diff) | |
download | src-428f86fd2ff1fd2b073d556fac273c8c7f457376.tar.gz src-428f86fd2ff1fd2b073d556fac273c8c7f457376.zip |
mv: Set file flags after setting file times
Some file flags prevent modification of file times, so they should be
set later. This matches NetBSD's behaviour.
Reviewed by: markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/1138
Diffstat (limited to 'bin')
-rw-r--r-- | bin/mv/mv.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 7a1ecba7e076..8aea4bbf567c 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -319,6 +319,12 @@ err: if (unlink(to)) */ preserve_fd_acls(from_fd, to_fd, from, to); (void)close(from_fd); + + ts[0] = sbp->st_atim; + ts[1] = sbp->st_mtim; + if (futimens(to_fd, ts)) + warn("%s: set times", to); + /* * XXX * NFS doesn't support chflags; ignore errors unless there's reason @@ -339,11 +345,6 @@ err: if (unlink(to)) } else warn("%s: cannot stat", to); - ts[0] = sbp->st_atim; - ts[1] = sbp->st_mtim; - if (futimens(to_fd, ts)) - warn("%s: set times", to); - if (close(to_fd)) { warn("%s", to); return (1); |