From b53661676c976d249188386442f46a7fefeb6d8b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 13 Aug 2020 12:55:51 +0100 Subject: [PATCH] trivial: Use O_APPEND for FU_EFIVAR_ATTR_APPEND_WRITE --- libfwupdplugin/fu-efivar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libfwupdplugin/fu-efivar.c b/libfwupdplugin/fu-efivar.c index 7579b383a..0bde17fd6 100644 --- a/libfwupdplugin/fu-efivar.c +++ b/libfwupdplugin/fu-efivar.c @@ -349,6 +349,7 @@ fu_efivar_set_data (const gchar *guid, const gchar *name, const guint8 *data, { #ifndef _WIN32 int fd; + int open_wflags; gboolean was_immutable; g_autofree gchar *fn = fu_efivar_get_filename (guid, name); g_autofree guint8 *buf = g_malloc0 (sizeof(guint32) + sz); @@ -374,8 +375,11 @@ fu_efivar_set_data (const gchar *guid, const gchar *name, const guint8 *data, return FALSE; } - /* open file for writing */ - fd = open (fn, O_WRONLY); + /* open file for writing, optionally append */ + open_wflags = O_WRONLY; + if (attr & FU_EFIVAR_ATTR_APPEND_WRITE) + open_wflags |= O_APPEND; + fd = open (fn, open_wflags); if (fd < 0) { g_set_error (error, G_IO_ERROR,