Skip to content

Commit 79b8360

Browse files
xypronardbiesheuvel
authored andcommitted
efivarfs: fix statfs() on efivarfs
Some firmware (notably U-Boot) provides GetVariable() and GetNextVariableName() but not QueryVariableInfo(). With commit d86ff33 ("efivarfs: expose used and total size") the statfs syscall was broken for such firmware. If QueryVariableInfo() does not exist or returns EFI_UNSUPPORTED, just report the file system size as 0 as statfs_simple() previously did. Fixes: d86ff33 ("efivarfs: expose used and total size") Link: https://lore.kernel.org/all/20230910045445.41632-1-heinrich.schuchardt@canonical.com/ Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> [ardb: log warning on QueryVariableInfo() failure] Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent e7761d8 commit 79b8360

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fs/efivarfs/super.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ static int efivarfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3232
u64 storage_space, remaining_space, max_variable_size;
3333
efi_status_t status;
3434

35-
status = efivar_query_variable_info(attr, &storage_space, &remaining_space,
36-
&max_variable_size);
37-
if (status != EFI_SUCCESS)
38-
return efi_status_to_err(status);
35+
/* Some UEFI firmware does not implement QueryVariableInfo() */
36+
storage_space = remaining_space = 0;
37+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
38+
status = efivar_query_variable_info(attr, &storage_space,
39+
&remaining_space,
40+
&max_variable_size);
41+
if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
42+
pr_warn_ratelimited("query_variable_info() failed: 0x%lx\n",
43+
status);
44+
}
3945

4046
/*
4147
* This is not a normal filesystem, so no point in pretending it has a block

0 commit comments

Comments
 (0)