target/linux/4.4|4.9: use fixed timestamp for files within initramfs
[openwrt/staging/lynxis.git] / target / linux / generic / patches-4.9 / 999-initramfs-cpio-fix-source-date-epoch-files.patch
1 Index: linux-4.9.34/usr/gen_init_cpio.c
2 ===================================================================
3 --- linux-4.9.34.orig/usr/gen_init_cpio.c
4 +++ linux-4.9.34/usr/gen_init_cpio.c
5 @@ -23,6 +23,7 @@
6 static unsigned int offset;
7 static unsigned int ino = 721;
8 static time_t default_mtime;
9 +static time_t source_date_epoch = -1;
10
11 struct file_handler {
12 const char *type;
13 @@ -336,6 +337,9 @@ static int cpio_mkfile(const char *name,
14 /* data goes on last link */
15 if (i == nlinks) size = buf.st_size;
16
17 + if (source_date_epoch != -1)
18 + buf.st_mtime = source_date_epoch;
19 +
20 if (name[0] == '/')
21 name++;
22 namesize = strlen(name) + 1;
23 @@ -536,6 +540,7 @@ int main (int argc, char *argv[])
24 switch (opt) {
25 case 't':
26 default_mtime = strtol(optarg, &invalid, 10);
27 + source_date_epoch = default_mtime;
28 if (!*optarg || *invalid) {
29 fprintf(stderr, "Invalid timestamp: %s\n",
30 optarg);