Commit 3fab70c1 authored by Lingzhu Xiang's avatar Lingzhu Xiang Committed by Matt Fleming

efivarfs: Never return ENOENT from firmware again

Previously in 1fa7e695 efi_status_to_err() translated firmware status
EFI_NOT_FOUND to -EIO instead of -ENOENT for efivarfs operations to
avoid confusion. After refactoring in e14ab23d, it is also used in other
places where the translation may be unnecessary.

So move the translation to efivarfs specific code. Also return EOF
for reading zero-length files, which is what users would expect.

Cc: Josh Boyer <>
Cc: Jeremy Kerr <>
Cc: Lee, Chun-Yi <>
Cc: Andy Whitcroft <>
Signed-off-by: default avatarLingzhu Xiang <>
Signed-off-by: default avatarMatt Fleming <>
parent f722406f
......@@ -44,8 +44,11 @@ static ssize_t efivarfs_file_write(struct file *file,
bytes = efivar_entry_set_get_size(var, attributes, &datasize,
data, &set);
if (!set && bytes)
if (!set && bytes) {
if (bytes == -ENOENT)
bytes = -EIO;
goto out;
if (bytes == -ENOENT) {
......@@ -76,7 +79,14 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
int err;
err = efivar_entry_size(var, &datasize);
if (err)
* efivarfs represents uncommitted variables with
* zero-length files. Reading them should return EOF.
if (err == -ENOENT)
return 0;
else if (err)
return err;
data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment