[pve-devel] [PATCH storage] file_size_info: handle dangling symlinks

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Oct 2 13:55:15 CEST 2020


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 at proxmox.com>
---

Notes:
    https://forum.proxmox.com/threads/local-storage-unable-to-display-content.76741

 PVE/Storage/Plugin.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index e6cd99c..63f68da 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -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;
     }
-- 
2.20.1






More information about the pve-devel mailing list