aboutsummaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-22 03:28:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-22 17:12:45 +0200
commitadc8e37d7f86d661ab54adf9c43e4b0aa67a939c (patch)
treed075abb80d7cd22935a32e20e5bfcb53acef087d /mkfs
parentc673f305ec0c2c80bc3873bcc8718d9ba85340c9 (diff)
Add a way to optionally keep the original time stamps
First of all, this commit adds a mod_time field to a tree node. When creating the tree node, the field is set from the struct stat. When scanning a directory, the time stamps from the input are used if set. Second, the libsqfs code that reads inodes is modified to store the mod_time from the inode in the fstree node and to write the tree node into a generated inode. Finally, tar2sqfs is modified to optionally keep the timestamps from the tar archive instead of setting defaults. gensquashfs is similarly modified to keep the input timestamps if specified. The result is as follows: - sqfs2tar will always carry the timestamps from the squashfs over to the tar ball. - tar2sqfs will set defaults, unless explicitly asked to preserve the mtime from the tar ball. - gensquashfs can optionally preserve the mtime from the input hierarchy it processes if only --pack-dir is specified. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/mkfs.c2
-rw-r--r--mkfs/mkfs.h1
-rw-r--r--mkfs/options.c12
3 files changed, 12 insertions, 3 deletions
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 91cb9bd..654534d 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -81,7 +81,7 @@ static int read_fstree(fstree_t *fs, options_t *opt)
int ret;
if (opt->infile == NULL)
- return fstree_from_dir(fs, opt->packdir);
+ return fstree_from_dir(fs, opt->packdir, opt->keep_time);
fp = fopen(opt->infile, "rb");
if (fp == NULL) {
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index 70a2ed6..21a308b 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -29,6 +29,7 @@ typedef struct {
int outmode;
int blksz;
int devblksz;
+ bool keep_time;
bool exportable;
bool quiet;
const char *infile;
diff --git a/mkfs/options.c b/mkfs/options.c
index fe2bc69..f14e6ef 100644
--- a/mkfs/options.c
+++ b/mkfs/options.c
@@ -9,6 +9,7 @@ static struct option long_opts[] = {
{ "comp-extra", required_argument, NULL, 'X' },
{ "pack-file", required_argument, NULL, 'F' },
{ "pack-dir", required_argument, NULL, 'D' },
+ { "keep-time", required_argument, NULL, 'k' },
{ "exportable", no_argument, NULL, 'e' },
{ "force", no_argument, NULL, 'f' },
{ "quiet", no_argument, NULL, 'q' },
@@ -20,9 +21,9 @@ static struct option long_opts[] = {
};
#ifdef WITH_SELINUX
-static const char *short_opts = "s:F:D:X:c:b:B:d:efqhV";
+static const char *short_opts = "s:F:D:X:c:b:B:d:kefqhV";
#else
-static const char *short_opts = "F:D:X:c:b:B:d:efqhV";
+static const char *short_opts = "F:D:X:c:b:B:d:kefqhV";
#endif
extern char *__progname;
@@ -67,6 +68,9 @@ static const char *help_string =
" --selinux, -s <file> Specify an SELinux label file to get context\n"
" attributes from.\n"
#endif
+" --keep-time, -k When using --pack-dir only, use the timestamps\n"
+" from the input files instead of setting\n"
+" defaults on all input paths.\n"
" --exportable, -e Generate an export table for NFS support.\n"
" --force, -f Overwrite the output file if it exists.\n"
" --quiet, -q Do not print out progress reports.\n"
@@ -125,6 +129,7 @@ void process_command_line(options_t *opt, int argc, char **argv)
opt->compressor = compressor_get_default();
opt->blksz = SQFS_DEFAULT_BLOCK_SIZE;
opt->devblksz = SQFS_DEVBLK_SIZE;
+ opt->keep_time = false;
opt->exportable = false;
opt->quiet = false;
opt->infile = NULL;
@@ -169,6 +174,9 @@ void process_command_line(options_t *opt, int argc, char **argv)
case 'd':
opt->fs_defaults = optarg;
break;
+ case 'k':
+ opt->keep_time = true;
+ break;
case 'e':
opt->exportable = true;
break;