Skip to content

Commit

Permalink
dom0-updates: fix checking free space on disk
Browse files Browse the repository at this point in the history
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 1adc253)
  • Loading branch information
marmarek committed Jul 24, 2023
1 parent cd1beb7 commit db60b1a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dom0-updates/qfile-dom0-unpacker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db60b1a

Please sign in to comment.