]> git.proxmox.com Git - pve-storage.git/commitdiff
file_size_info: handle dangling symlinks
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 2 Oct 2020 11:55:15 +0000 (13:55 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 5 Oct 2020 10:51:44 +0000 (12:51 +0200)
and other stat failure modes.

this method returns undef if 'qemu-img info ...' fails to return
information, so callers must handle this already.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/Storage/Plugin.pm

index e6cd99c0611f32540cf0babe00bff40fada23a81..63f68dafe765f919499b1f4568168c3753182519 100644 (file)
@@ -783,6 +783,12 @@ sub file_size_info {
 
     my $st = File::stat::stat($filename);
 
+    if (!defined($st)) {
+       my $extramsg = -l $filename ? ' - dangling symlink?' : '';
+       warn "failed to stat '$filename'$extramsg\n";
+       return undef;
+    }
+
     if (S_ISDIR($st->mode)) {
        return wantarray ? (0, 'subvol', 0, undef, $st->ctime) : 1;
     }