git-trunc-times
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
committerAurelien Jarno <aurel32@debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
Committed for glibc 2.32

commit e095db0bc6c53a0b7ac3d915c5feb7678049dc33
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Mar 29 19:42:55 2020 +0200

    hurd: Make O_TRUNC update mtime/ctime

    * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Call
    __file_utimens after __file_set_size.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-trunc-times.diff

hurd/lookup-retry.c

index c90eda808d8d49a2f2e88386292fad73867f110a..6d8b05e4e685ffee3a9c64e4afdec282c674ffb2 100644 (file)
@@ -178,8 +178,17 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
              /* We got a successful translation.  Now apply any open-time
                 action flags we were passed.  */
 
-             if (!err && (flags & O_TRUNC)) /* Asked to truncate the file.  */
-               err = __file_set_size (*result, 0);
+             if (!err && (flags & O_TRUNC))
+               {
+                 /* Asked to truncate the file.  */
+                 err = __file_set_size (*result, 0);
+                 if (!err)
+                   {
+                     struct timespec atime = { 0, UTIME_OMIT };
+                     struct timespec mtime = { 0, UTIME_NOW };
+                     __file_utimens (*result, atime, mtime);
+                   }
+               }
 
              if (err)
                __mach_port_deallocate (__mach_task_self (), *result);