From db60b1a313b63a46fdbda149717944ddbb51b413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 26 Jan 2023 05:56:17 +0100 Subject: [PATCH] dom0-updates: fix checking free space on disk Use current dir - it's after chroot() already. And then, if it fails anyway, use default limit and just log the failure. Do not prevent installing updates. (cherry picked from commit 1adc253e51eb55b0eabc680a9f1f6d1be7d586f2) --- dom0-updates/qfile-dom0-unpacker.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dom0-updates/qfile-dom0-unpacker.c b/dom0-updates/qfile-dom0-unpacker.c index 8d6171db..2675ae4f 100644 --- a/dom0-updates/qfile-dom0-unpacker.c +++ b/dom0-updates/qfile-dom0-unpacker.c @@ -80,11 +80,13 @@ int main(int argc, char ** argv) exit(1); } - statvfs(incoming_dir, &st); - // take a little margin with 90% of the free space - root_free_space = max(0, st.f_bfree * st.f_bsize * 0.90); - - bytes_limit = min(root_free_space, DEFAULT_MAX_UPDATES_BYTES); + if (statvfs(".", &st) == 0) { + // take a little margin with 90% of the free space + root_free_space = max(0, st.f_bfree * st.f_bsize * 0.90); + bytes_limit = min(root_free_space, DEFAULT_MAX_UPDATES_BYTES); + } else { + perror("Failed to check free space"); + } if ((var=getenv("UPDATES_MAX_BYTES"))) bytes_limit = atoll(var);