Skip to content

Commit

Permalink
Introduce print-mtime. Let -vv status output mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Aug 12, 2018
1 parent 7388870 commit 4af837a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog for squashmount

*squashmount-19.1:
Martin Väth <martin at mvath.de>:
- Introduce print-mtime
- Output mtime of squashed file with squashmount -vv status

*squashmount-19.0.2:
Martin Väth <martin at mvath.de>:
- Avoid wrong linebreak in manpage
Expand Down
30 changes: 28 additions & 2 deletions bin/squashmount
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<print-mtime>

Output the mtime of the squash-file.

=item B<print-type>

Output the tool actually used for mounting.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'} // '')
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions zsh/_squashmount
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4af837a

Please sign in to comment.