7ac1765eed22a371f8584e4a3968941eb923fa89
[openwrt/svn-archive/archive.git] / tools / squashfs4 / patches / 200-add-fixed-timestamp-option.patch
1 Index: squashfs4.2/squashfs-tools/mksquashfs.c
2 ===================================================================
3 --- squashfs4.2.orig/squashfs-tools/mksquashfs.c
4 +++ squashfs4.2/squashfs-tools/mksquashfs.c
5 @@ -175,6 +175,9 @@ unsigned int cache_bytes = 0, cache_size
6 /* inode lookup table */
7 squashfs_inode *inode_lookup_table = NULL;
8
9 +/* override all timestamps */
10 +time_t fixed_time = -1;
11 +
12 /* in memory directory data */
13 #define I_COUNT_SIZE 128
14 #define DIR_ENTRIES 32
15 @@ -2452,6 +2455,8 @@ again:
16 restat:
17 fstat(file, &buf2);
18 close(file);
19 + if (fixed_time != -1)
20 + buf2.st_mtime = fixed_time;
21 if(read_size != buf2.st_size) {
22 memcpy(buf, &buf2, sizeof(struct stat));
23 file_buffer->error = 2;
24 @@ -3612,7 +3617,7 @@ void dir_scan(squashfs_inode *inode, cha
25 buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
26 buf.st_uid = getuid();
27 buf.st_gid = getgid();
28 - buf.st_mtime = time(NULL);
29 + buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL);
30 buf.st_dev = 0;
31 buf.st_ino = 0;
32 dir_ent->inode = lookup_inode(&buf);
33 @@ -3623,6 +3628,8 @@ void dir_scan(squashfs_inode *inode, cha
34 pathname, strerror(errno));
35 return;
36 }
37 + if(fixed_time != -1)
38 + buf.st_mtime = fixed_time;
39 dir_ent->inode = lookup_inode(&buf);
40 }
41
42 @@ -3677,6 +3684,8 @@ struct dir_info *dir_scan1(char *pathnam
43 filename, strerror(errno));
44 continue;
45 }
46 + if(fixed_time != -1)
47 + buf.st_mtime = fixed_time;
48
49 if((buf.st_mode & S_IFMT) != S_IFREG &&
50 (buf.st_mode & S_IFMT) != S_IFDIR &&
51 @@ -3795,7 +3804,7 @@ struct dir_info *dir_scan2(struct dir_in
52 buf.st_gid = pseudo_ent->dev->gid;
53 buf.st_rdev = makedev(pseudo_ent->dev->major,
54 pseudo_ent->dev->minor);
55 - buf.st_mtime = time(NULL);
56 + buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL);
57 buf.st_ino = pseudo_ino ++;
58
59 if(pseudo_ent->dev->type == 'f') {
60 @@ -4674,6 +4683,15 @@ int main(int argc, char *argv[])
61 progress = FALSE;
62 else if(strcmp(argv[i], "-no-exports") == 0)
63 exportable = FALSE;
64 + else if(strcmp(argv[i], "-fixed-time") == 0) {
65 + if((++i == argc) || (fixed_time =
66 + strtoll(argv[i], &b, 10), *b != '\0')) {
67 + ERROR("%s: -fixed-time missing or invalid "
68 + "timestamp\n", argv[0]);
69 +
70 + exit(1);
71 + }
72 + }
73 else if(strcmp(argv[i], "-processors") == 0) {
74 if((++i == argc) || (processors =
75 strtol(argv[i], &b, 10), *b != '\0')) {
76 @@ -5314,7 +5332,7 @@ printOptions:
77 sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments,
78 always_use_fragments, duplicate_checking, exportable,
79 no_xattrs, comp_opts);
80 - sBlk.mkfs_time = time(NULL);
81 + sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL);
82
83 restore_filesystem:
84 if(progress && estimated_uncompressed) {