Commit 3fab70c165795431f00ddf9be8b84ddd07bd1f8f

Authored by Lingzhu Xiang
Committed by Matt Fleming
1 parent f722406faa

efivarfs: Never return ENOENT from firmware again

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>

Showing 1 changed file with 12 additions and 2 deletions Side-by-side Diff

... ... @@ -44,8 +44,11 @@
44 44  
45 45 bytes = efivar_entry_set_get_size(var, attributes, &datasize,
46 46 data, &set);
47   - if (!set && bytes)
  47 + if (!set && bytes) {
  48 + if (bytes == -ENOENT)
  49 + bytes = -EIO;
48 50 goto out;
  51 + }
49 52  
50 53 if (bytes == -ENOENT) {
51 54 drop_nlink(inode);
... ... @@ -76,7 +79,14 @@
76 79 int err;
77 80  
78 81 err = efivar_entry_size(var, &datasize);
79   - if (err)
  82 +
  83 + /*
  84 + * efivarfs represents uncommitted variables with
  85 + * zero-length files. Reading them should return EOF.
  86 + */
  87 + if (err == -ENOENT)
  88 + return 0;
  89 + else if (err)
80 90 return err;
81 91  
82 92 data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);