Skip to content

Commit fc20737

Browse files
James Bottomleyardbiesheuvel
authored andcommitted
efivarfs: allow creation of zero length files
Temporarily allow the creation of zero length files in efivarfs so the 'fwupd' user space firmware update tool can continue to operate. This hack should be reverted as soon as the fwupd mechanisms for updating firmware have been fixed. fwupd has been coded to open a firmware file, close it, remove the immutable bit and write to it. Since commit 908af31 ("efivarfs: fix error on write to new variable leaving remnants") this behaviour results in the first close removing the file which causes the second write to fail. To allow fwupd to keep working code up an indicator of size 1 if a write fails and only remove the file on that condition (so create at zero size is allowed). Tested-by: Richard Hughes <richard@hughsie.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> [ardb: replace LVFS with fwupd, as suggested by Richard] Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent cb6ae45 commit fc20737

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/efivarfs/file.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ static ssize_t efivarfs_file_write(struct file *file,
5757

5858
if (bytes == -ENOENT) {
5959
/*
60-
* zero size signals to release that the write deleted
61-
* the variable
60+
* FIXME: temporary workaround for fwupdate, signal
61+
* failed write with a 1 to keep created but not
62+
* written files
6263
*/
63-
i_size_write(inode, 0);
64+
i_size_write(inode, 1);
6465
} else {
6566
i_size_write(inode, datasize + sizeof(attributes));
6667
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
@@ -124,7 +125,8 @@ static int efivarfs_file_release(struct inode *inode, struct file *file)
124125
struct efivar_entry *var = inode->i_private;
125126

126127
inode_lock(inode);
127-
var->removed = (--var->open_count == 0 && i_size_read(inode) == 0);
128+
/* FIXME: temporary work around for fwupdate */
129+
var->removed = (--var->open_count == 0 && i_size_read(inode) == 1);
128130
inode_unlock(inode);
129131

130132
if (var->removed)

0 commit comments

Comments
 (0)