SmartAudio/tools/squashfs4/patches/200-add-fixed-timestamp-opt...

84 lines
2.5 KiB
Diff
Raw Normal View History

2018-12-13 10:48:25 +00:00
diff -Naur squashfs4.3/squashfs-tools/mksquashfs.c squashfs4.3-bak/squashfs-tools/mksquashfs.c
--- squashfs4.3/squashfs-tools/mksquashfs.c 2014-05-13 06:18:20.000000000 +0800
+++ squashfs4.3-bak/squashfs-tools/mksquashfs.c 2018-08-24 14:48:35.268576971 +0800
@@ -129,6 +129,9 @@
2018-07-13 01:31:50 +00:00
/* inode lookup table */
squashfs_inode *inode_lookup_table = NULL;
2018-12-13 10:48:25 +00:00
2018-07-13 01:31:50 +00:00
+/* override all timestamps */
+time_t fixed_time = -1;
+
/* in memory directory data */
#define I_COUNT_SIZE 128
#define DIR_ENTRIES 32
2018-12-13 10:48:25 +00:00
@@ -2265,7 +2268,8 @@
pathname_reader(dir_ent), strerror(errno));
goto read_err;
}
-
2018-07-13 01:31:50 +00:00
+ if (fixed_time != -1)
+ buf2.st_mtime = fixed_time;
2018-12-13 10:48:25 +00:00
if(read_size != buf2.st_size) {
close(file);
memcpy(buf, &buf2, sizeof(struct stat));
@@ -3139,7 +3143,7 @@
buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
buf.st_uid = getuid();
buf.st_gid = getgid();
2018-07-13 01:31:50 +00:00
- buf.st_mtime = time(NULL);
+ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL);
2018-12-13 10:48:25 +00:00
buf.st_dev = 0;
buf.st_ino = 0;
dir_ent->inode = lookup_inode2(&buf, PSEUDO_FILE_OTHER, 0);
@@ -3148,6 +3152,8 @@
/* source directory has disappeared? */
BAD_ERROR("Cannot stat source directory %s because %s\n",
pathname, strerror(errno));
2018-07-13 01:31:50 +00:00
+ if(fixed_time != -1)
+ buf.st_mtime = fixed_time;
2018-12-13 10:48:25 +00:00
dir_ent->inode = lookup_inode(&buf);
}
@@ -3370,6 +3376,8 @@
free_dir_entry(dir_ent);
continue;
}
2018-07-13 01:31:50 +00:00
+ if(fixed_time != -1)
+ buf.st_mtime = fixed_time;
2018-12-13 10:48:25 +00:00
if((buf.st_mode & S_IFMT) != S_IFREG &&
(buf.st_mode & S_IFMT) != S_IFDIR &&
@@ -3526,7 +3534,7 @@
buf.st_gid = pseudo_ent->dev->gid;
buf.st_rdev = makedev(pseudo_ent->dev->major,
pseudo_ent->dev->minor);
2018-07-13 01:31:50 +00:00
- buf.st_mtime = time(NULL);
+ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL);
2018-12-13 10:48:25 +00:00
buf.st_ino = pseudo_ino ++;
if(pseudo_ent->dev->type == 'd') {
@@ -5076,6 +5084,15 @@
force_progress = TRUE;
else if(strcmp(argv[i], "-no-exports") == 0)
exportable = FALSE;
2018-07-13 01:31:50 +00:00
+ else if(strcmp(argv[i], "-fixed-time") == 0) {
+ if((++i == argc) || (fixed_time =
+ strtoll(argv[i], &b, 10), *b != '\0')) {
+ ERROR("%s: -fixed-time missing or invalid "
+ "timestamp\n", argv[0]);
+
+ exit(1);
+ }
+ }
2018-12-13 10:48:25 +00:00
else if(strcmp(argv[i], "-processors") == 0) {
if((++i == argc) || !parse_num(argv[i], &processors)) {
ERROR("%s: -processors missing or invalid "
@@ -5717,7 +5734,7 @@
sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments,
always_use_fragments, duplicate_checking, exportable,
no_xattrs, comp_opts);
2018-07-13 01:31:50 +00:00
- sBlk.mkfs_time = time(NULL);
+ sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL);
2018-12-13 10:48:25 +00:00
disable_info();