200-add-fixed-timestamp-option.patch 2.5 KB

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