120-add-fixed-timestamp-support.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --- a/squashfs-tools/mksquashfs.c
  2. +++ b/squashfs-tools/mksquashfs.c
  3. @@ -117,6 +117,9 @@ unsigned int inode_bytes = 0, inode_size
  4. char *data_cache = NULL;
  5. unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
  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. @@ -1554,6 +1557,11 @@ void dir_scan(squashfs_inode *inode, cha
  13. perror(buffer);
  14. return;
  15. }
  16. +
  17. + /* override timestamp of lstat if fixed_time is given */
  18. + if(fixed_time != -1)
  19. + inode_info->buf.st_mtime = fixed_time;
  20. +
  21. if(sorted)
  22. sort_files_and_write(dir_info);
  23. dir_scan2(inode, dir_info);
  24. @@ -1582,6 +1590,10 @@ struct dir_info *dir_scan1(char *pathnam
  25. perror(buffer);
  26. continue;
  27. }
  28. +
  29. + if(fixed_time != -1)
  30. + buf.st_mtime = fixed_time;
  31. +
  32. if(excluded(filename, &buf))
  33. continue;
  34. @@ -1621,6 +1633,9 @@ int dir_scan2(squashfs_inode *inode, str
  35. char *dir_name = dir_ent->name;
  36. unsigned int inode_number = ((buf->st_mode & S_IFMT) == S_IFDIR) ? dir_ent->inode->inode_number : dir_ent->inode->inode_number + dir_inode_no;
  37. + if(fixed_time != -1)
  38. + buf->st_mtime = fixed_time;
  39. +
  40. if(dir_ent->inode->inode == SQUASHFS_INVALID_BLK) {
  41. switch(buf->st_mode & S_IFMT) {
  42. case S_IFREG:
  43. @@ -1898,6 +1913,16 @@ int main(int argc, char *argv[])
  44. exit(1);
  45. }
  46. }
  47. + } else if(strcmp(argv[i], "-fixed-time") == 0) {
  48. + if(++i == argc) {
  49. + ERROR("%s: -fixed-time missing a timestamp\n", argv[0]);
  50. + exit(1);
  51. + }
  52. + fixed_time = strtoll(argv[i], &b, 10);
  53. + if(*b != '\0') {
  54. + ERROR("%s: -fixed-time has an invalid number\n", argv[0]);
  55. + exit(1);
  56. + }
  57. } else if(strcmp(argv[i], "-noI") == 0 ||
  58. strcmp(argv[i], "-noInodeCompression") == 0)
  59. noI = TRUE;
  60. @@ -1967,6 +1992,7 @@ printOptions:
  61. ERROR("-all-root\t\tmake all files owned by root\n");
  62. ERROR("-force-uid uid\t\tset all file uids to uid\n");
  63. ERROR("-force-gid gid\t\tset all file gids to gid\n");
  64. + ERROR("-fixed-time timestamp\tset all timestamps to timestamp\n");
  65. ERROR("-le\t\t\tcreate a little endian filesystem\n");
  66. ERROR("-be\t\t\tcreate a big endian filesystem\n");
  67. ERROR("-nopad\t\t\tdo not pad filesystem to a multiple of 4K\n");
  68. @@ -2190,7 +2216,7 @@ printOptions:
  69. sBlk.block_size = block_size;
  70. sBlk.block_log = block_log;
  71. sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, check_data, noF, no_fragments, always_use_fragments, duplicate_checking);
  72. - sBlk.mkfs_time = time(NULL);
  73. + sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL);
  74. restore_filesystem:
  75. write_fragment();