From: Dietmar Maurer Date: Wed, 4 Mar 2020 10:46:21 +0000 (+0100) Subject: base plugin: return ctime for vm images X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=51eee96d31f2b2c3cf9f982cfa7e0cf11c8e2776 base plugin: return ctime for vm images Changed file_size_info() to additionally return ctime to avoid another stat() call. Signed-off-by: Dietmar Maurer --- diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 85af1c8..7951c13 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -718,8 +718,12 @@ sub free_image { sub file_size_info { my ($filename, $timeout) = @_; - if (-d $filename) { - return wantarray ? (0, 'subvol', 0, undef) : 1; + my @fs = stat($filename); + my $mode = $fs[2]; + my $ctime = $fs[10]; + + if (S_ISDIR($mode)) { + return wantarray ? (0, 'subvol', 0, undef, $ctime) : 1; } my $json = ''; @@ -737,7 +741,7 @@ sub file_size_info { my ($size, $format, $used, $parent) = $info->@{qw(virtual-size format actual-size backing-filename)}; - return wantarray ? ($size, $format, $used, $parent) : $size; + return wantarray ? ($size, $format, $used, $parent, $ctime) : $size; } sub volume_size_info { @@ -872,7 +876,7 @@ sub list_images { next if !$vollist && defined($vmid) && ($owner ne $vmid); - my ($size, $format, $used, $parent) = file_size_info($fn); + my ($size, $format, $used, $parent, $ctime) = file_size_info($fn); next if !($format && defined($size)); my $volid; @@ -888,10 +892,14 @@ sub list_images { next if !$found; } - push @$res, { + my $info = { volid => $volid, format => $format, size => $size, vmid => $owner, used => $used, parent => $parent }; + + $info->{ctime} = $ctime if $ctime; + + push @$res, $info; } return $res;