archive: dragora-installer: added parts (MenuMedia)
[dragora.git] / patches / squashfs-tools / 0009-unsquashfs-preserve-symlink-times.patch
blob604c2e0654ce0be2c93afe6aa581348465bd6c0f
1 From ff6f3f685498d33858d9306884962075415ab5f2 Mon Sep 17 00:00:00 2001
2 From: Tyler Hicks <tyhicks@canonical.com>
3 Date: Wed, 29 Nov 2017 16:48:23 +0000
4 Subject: [PATCH] unsquashfs: Preserve times on symlink inodes
6 This patch fixes a bug that caused symlinks created by unsquashfs to
7 use the current time for atime and mtime rather than the times present
8 in the squashfs archive.
10 The timestamps are set using utimensat(2) which does not dereference the
11 symlink when the AT_SYMLINK_NOFOLLOW flag is used. The utimensat(2)
12 system call supports nanosecond precision but that's not needed by
13 squashfs so timespec.tv_nsec is unconditionally set to 0.
15 Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
16 Bug-Ubuntu: https://launchpad.net/bugs/1724152
17 Forwarded: https://sourceforge.net/p/squashfs/mailman/message/36140758/
18 ---
19 squashfs-tools/unsquashfs.c | 15 ++++++++++++++-
20 1 file changed, 14 insertions(+), 1 deletion(-)
22 Index: squashfs-tools-4.3/squashfs-tools/unsquashfs.c
23 ===================================================================
24 --- squashfs-tools-4.3.orig/squashfs-tools/unsquashfs.c
25 +++ squashfs-tools-4.3/squashfs-tools/unsquashfs.c
26 @@ -1087,7 +1087,12 @@ int create_inode(char *pathname, struct
27 file_count ++;
28 break;
29 case SQUASHFS_SYMLINK_TYPE:
30 - case SQUASHFS_LSYMLINK_TYPE:
31 + case SQUASHFS_LSYMLINK_TYPE: {
32 + struct timespec times[2] = {
33 + { i->time, 0 },
34 + { i->time, 0 }
35 + };
37 TRACE("create_inode: symlink, symlink_size %lld\n",
38 i->data);
40 @@ -1101,6 +1106,13 @@ int create_inode(char *pathname, struct
41 break;
44 + if (utimensat(AT_FDCWD, pathname, times,
45 + AT_SYMLINK_NOFOLLOW) == -1) {
46 + ERROR("create_inode: failed to set time on "
47 + "%s, because %s\n", pathname,
48 + strerror(errno));
49 + }
51 write_xattr(pathname, i->xattr);
53 if(root_process) {
54 @@ -1113,6 +1125,7 @@ int create_inode(char *pathname, struct
56 sym_count ++;
57 break;
58 + }
59 case SQUASHFS_BLKDEV_TYPE:
60 case SQUASHFS_CHRDEV_TYPE:
61 case SQUASHFS_LBLKDEV_TYPE: