summaryrefslogtreecommitdiffstats
path: root/patches/opkg-0.2.2/0002-preserve-symlink-timestamps-if-possible.patch
blob: 00ded7e51a5675e65dfaa6672327da89c0631cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Thu, 17 Jul 2014 17:51:44 +0200
Subject: [PATCH] preserve symlink timestamps if possible

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 libbb/unarchive.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index e2e016b846d4..ede16c2a3fc3 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -21,6 +21,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <string.h>
@@ -240,6 +241,16 @@ extract_archive(FILE *src_stream, FILE *out_stream,
 #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
 			lchown(full_name, file_entry->uid, file_entry->gid);
 #endif
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 6)
+			if (function & extract_preserve_date) {
+				struct timespec times[2];
+				times[0].tv_sec = file_entry->mtime;
+				times[0].tv_nsec = 0;
+				times[1].tv_sec = file_entry->mtime;
+				times[1].tv_nsec = 0;
+				utimensat(AT_FDCWD, full_name, times, AT_SYMLINK_NOFOLLOW);
+			}
+#endif
 		} else {
 			if (function & extract_preserve_date) {
 				t.actime = file_entry->mtime;