Skip to content

Commit 4af837a

Browse files
committed
Introduce print-mtime. Let -vv status output mtime
1 parent 7388870 commit 4af837a

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# ChangeLog for squashmount
22

3+
*squashmount-19.1:
4+
Martin Väth <martin at mvath.de>:
5+
- Introduce print-mtime
6+
- Output mtime of squashed file with squashmount -vv status
7+
38
*squashmount-19.0.2:
49
Martin Väth <martin at mvath.de>:
510
- Avoid wrong linebreak in manpage

bin/squashmount

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env perl
22
BEGIN { require 5.022 }
3-
package Squashmount v19.0.2;
3+
package Squashmount v19.1.0;
44

55
use strict;
66
use warnings;
@@ -261,6 +261,10 @@ For usage in scripts, combine this with B<-q>/B<-S> and pass a tag.
261261
Output the absolute path to the squash-file.
262262
For usage in scripts, combine this with B<-q>/B<-S> and pass a tag.
263263

264+
=item B<print-mtime>
265+
266+
Output the mtime of the squash-file.
267+
264268
=item B<print-type>
265269

266270
Output the tool actually used for mounting.
@@ -2750,7 +2754,14 @@ sub cmd_status {
27502754
push(@status, 'WORKDIR: ' . &get_abspath('WORKDIR', $force, 1))
27512755
if (&is_valid_workdir($force));
27522756
my $file = &get_abspath('FILE', $force);
2753-
push(@status, 'FILE: ' . $file) if (&is_abspath($file));
2757+
if (&is_abspath($file)) {
2758+
push(@status, 'FILE: ' . $file);
2759+
if (-f $file) {
2760+
my $mtime = &local_mtime($file);
2761+
push(@status, 'mtime: ' . $mtime)
2762+
if (&is_nonempty($mtime))
2763+
}
2764+
}
27542765
push(@status, "TEMPDIR: $tempdir") if (&is_abspath($tempdir));
27552766
push(@status, "BACKUP: $backup") if (&is_nonempty($backup));
27562767
&mksquashfs_options(\my @options);
@@ -2796,6 +2807,10 @@ sub cmd_print_file {
27962807
&do_print(&get_abspath('FILE', $force))
27972808
}
27982809

2810+
sub cmd_print_mtime {
2811+
&do_print(&local_mtime(&get_abspath('FILE', $force)) // '')
2812+
}
2813+
27992814
sub cmd_print_type {
28002815
&do_print($current->{'TYPE'} // '')
28012816
}
@@ -4862,6 +4877,14 @@ sub bad_status {
48624877
$exitstatus = 1 unless ($fatalreturn || ($exitstatus != 0))
48634878
}
48644879

4880+
sub local_mtime {
4881+
my $file = shift();
4882+
return undef unless (&is_nonempty($file));
4883+
my $mtime = (stat($file))[9];
4884+
return undef unless (&is_nonempty($mtime));
4885+
localtime($mtime)
4886+
}
4887+
48654888
# check whether argument is a nonempty string and the corresponding file exists
48664889

48674890
sub file_exists {
@@ -5271,6 +5294,9 @@ my $action = (shift(@ARGV) // '');
52715294
} elsif ($action =~ m{fil}i) {
52725295
$cmd = 'print-file';
52735296
$action = \&cmd_print_file
5297+
} elsif ($action =~ m{tim}i) {
5298+
$cmd = 'print-mtime';
5299+
$action = \&cmd_print_mtime
52745300
} elsif ($action =~ m{s.*typ}i) {
52755301
$cmd = 'print-squashtype';
52765302
$action = \&cmd_print_squashtype

zsh/_squashmount

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ case $state in
8383
'print-readonly:print READONLY directory or 1'
8484
'print-changes:print CHANGES directory'
8585
'print-file:print squash-file path'
86+
'print-mtime:print squash-file mtime'
8687
'print-type:print mount type'
8788
'print-squashtype:print squash mount type'
8889
'print-new:print 1 if there is new data'

0 commit comments

Comments
 (0)