Skip to content

Commit

Permalink
efivarfs: Never return ENOENT from firmware again
Browse files Browse the repository at this point in the history
Previously in 1fa7e69 efi_status_to_err() translated firmware status
EFI_NOT_FOUND to -EIO instead of -ENOENT for efivarfs operations to
avoid confusion. After refactoring in e14ab23, 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 <jwboyer@redhat.com>
Cc: Jeremy Kerr <jk@ozlabs.org>
Cc: Lee, Chun-Yi <jlee@suse.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Lingzhu Xiang <lxiang@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
  • Loading branch information
Lingzhu Xiang authored and Matt Fleming committed May 13, 2013
1 parent f722406 commit 3fab70c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fs/efivarfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
drop_nlink(inode);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3fab70c

Please sign in to comment.