Skip to contentSkip to conversation

erofs-utils: mkfs: introduce `--preserve-mtime'

PATCH New Gao Xiang 1 participant 1 message Jun 11, 2022

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: mkfs: introduce `--preserve-mtime'

In the past versions, -Eforce-inode-compact' worked since timestamps were ignored. Currently, since we don't ignore mtime by default any more, -Eforce-inode-compact' fails and that breaks compatibility.

Let's fix -Eforce-inode-compact' to ignore mtime as the past versions did, also add another option --preserve-mtime' for this.

---
 man/mkfs.erofs.1 | 4 ++++
 mkfs/main.c      | 5 +++++
 2 files changed, 9 insertions(+)
man/mkfs.erofs.1 +4 -0
index d61e33e..6017760 100644
@@ -119,6 +119,10 @@ can reduce total metadata size.
 .TP
 .BI "\-\-max-extent-bytes " #
 Specify maximum decompressed extent size # in bytes.
+.TP
+.B "\-\-preserve-mtime"
+File modification time is preserved whenever \fBmkfs.erofs\fR decides to use
+extended inodes over compact inodes.
 .SH AUTHOR
 This version of \fBmkfs.erofs\fR is written by Li Guifu <[email protected]>,
 Miao Xie <[email protected]> and Gao Xiang <[email protected]> with
mkfs/main.c +5 -0
index 9d43cd4..54a3fed 100644
@@ -50,6 +50,7 @@ static struct option long_options[] = {
 	{"quiet", no_argument, 0, 12},
 	{"blobdev", required_argument, NULL, 13},
 	{"ignore-mtime", no_argument, NULL, 14},
+	{"preserve-mtime", no_argument, NULL, 15},
 #ifdef WITH_ANDROID
 	{"mount-point", required_argument, NULL, 512},
 	{"product-out", required_argument, NULL, 513},
@@ -158,6 +159,7 @@ static int parse_extended_opts(const char *opts)
 			if (vallen)
 				return -EINVAL;
 			cfg.c_force_inodeversion = FORCE_INODE_COMPACT;
+			cfg.c_ignore_mtime = true;
 		}
 
 		if (MATCH_EXTENTED_OPT("force-inode-extended", token, keylen)) {
@@ -377,6 +379,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 		case 14:
 			cfg.c_ignore_mtime = true;
 			break;
+		case 15:
+			cfg.c_ignore_mtime = false;
+			break;
 		case 1:
 			usage();
 			exit(0);
Signature · 1 line
2.30.2