efivarfs: Revert "allow creation of zero length files"

As agreed with the fwupd/LVFS maintainer, this reverts commit
fc20737d8b85691ecabab3739ed7d06c9b7bc00f again for the v6.15 cycle,
leaving them sufficient time to roll out a fix for the issue that the
reverted commit works around.

Link: https://lore.kernel.org/all/63837c36eceaf8cf2af7933dccca54ff4dd9f30d.camel@HansenPartnership.com/
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Ard Biesheuvel 2025-03-06 14:08:27 +01:00
parent 48140f8bca
commit b6b227e36b

View File

@ -57,11 +57,10 @@ static ssize_t efivarfs_file_write(struct file *file,
if (bytes == -ENOENT) {
/*
* FIXME: temporary workaround for fwupdate, signal
* failed write with a 1 to keep created but not
* written files
* zero size signals to release that the write deleted
* the variable
*/
i_size_write(inode, 1);
i_size_write(inode, 0);
} else {
i_size_write(inode, datasize + sizeof(attributes));
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
@ -125,8 +124,7 @@ static int efivarfs_file_release(struct inode *inode, struct file *file)
struct efivar_entry *var = inode->i_private;
inode_lock(inode);
/* FIXME: temporary work around for fwupdate */
var->removed = (--var->open_count == 0 && i_size_read(inode) == 1);
var->removed = (--var->open_count == 0 && i_size_read(inode) == 0);
inode_unlock(inode);
if (var->removed)