diff --git a/ChangeLog b/ChangeLog index 87f8a31..5ced63e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ # ChangeLog for squashmount +*squashmount-19.1: + Martin Väth : + - Introduce print-mtime + - Output mtime of squashed file with squashmount -vv status + *squashmount-19.0.2: Martin Väth : - Avoid wrong linebreak in manpage diff --git a/bin/squashmount b/bin/squashmount index c2c8850..0469698 100755 --- a/bin/squashmount +++ b/bin/squashmount @@ -1,6 +1,6 @@ #!/usr/bin/env perl BEGIN { require 5.022 } -package Squashmount v19.0.2; +package Squashmount v19.1.0; use strict; use warnings; @@ -261,6 +261,10 @@ For usage in scripts, combine this with B<-q>/B<-S> and pass a tag. Output the absolute path to the squash-file. For usage in scripts, combine this with B<-q>/B<-S> and pass a tag. +=item B + +Output the mtime of the squash-file. + =item B Output the tool actually used for mounting. @@ -2750,7 +2754,14 @@ sub cmd_status { push(@status, 'WORKDIR: ' . &get_abspath('WORKDIR', $force, 1)) if (&is_valid_workdir($force)); my $file = &get_abspath('FILE', $force); - push(@status, 'FILE: ' . $file) if (&is_abspath($file)); + if (&is_abspath($file)) { + push(@status, 'FILE: ' . $file); + if (-f $file) { + my $mtime = &local_mtime($file); + push(@status, 'mtime: ' . $mtime) + if (&is_nonempty($mtime)) + } + } push(@status, "TEMPDIR: $tempdir") if (&is_abspath($tempdir)); push(@status, "BACKUP: $backup") if (&is_nonempty($backup)); &mksquashfs_options(\my @options); @@ -2796,6 +2807,10 @@ sub cmd_print_file { &do_print(&get_abspath('FILE', $force)) } +sub cmd_print_mtime { + &do_print(&local_mtime(&get_abspath('FILE', $force)) // '') +} + sub cmd_print_type { &do_print($current->{'TYPE'} // '') } @@ -4862,6 +4877,14 @@ sub bad_status { $exitstatus = 1 unless ($fatalreturn || ($exitstatus != 0)) } +sub local_mtime { + my $file = shift(); + return undef unless (&is_nonempty($file)); + my $mtime = (stat($file))[9]; + return undef unless (&is_nonempty($mtime)); + localtime($mtime) +} + # check whether argument is a nonempty string and the corresponding file exists sub file_exists { @@ -5271,6 +5294,9 @@ my $action = (shift(@ARGV) // ''); } elsif ($action =~ m{fil}i) { $cmd = 'print-file'; $action = \&cmd_print_file + } elsif ($action =~ m{tim}i) { + $cmd = 'print-mtime'; + $action = \&cmd_print_mtime } elsif ($action =~ m{s.*typ}i) { $cmd = 'print-squashtype'; $action = \&cmd_print_squashtype diff --git a/zsh/_squashmount b/zsh/_squashmount index 16334ca..0419da6 100644 --- a/zsh/_squashmount +++ b/zsh/_squashmount @@ -83,6 +83,7 @@ case $state in 'print-readonly:print READONLY directory or 1' 'print-changes:print CHANGES directory' 'print-file:print squash-file path' + 'print-mtime:print squash-file mtime' 'print-type:print mount type' 'print-squashtype:print squash mount type' 'print-new:print 1 if there is new data'