diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-06-22 11:36:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-08 21:40:44 +0200 |
commit | e0e8d177c8b2b41adfb966640042ea4ed323dd40 (patch) | |
tree | 3274ed3ae363d250aa7036e18b812ee4a2935935 /src/boot/bootctl.c | |
parent | 1634ebb54a8955ab01dac9a59fc16f02f16cf007 (diff) | |
download | systemd-e0e8d177c8b2b41adfb966640042ea4ed323dd40.tar.gz |
bootctl: let's be paranoid and synchronize the ESP in full after all changes
We already synchronize all files we write individually, as well as the
directories they are stored in. Let's also synchronize the ESP as a
whole after our work, just in case.
Diffstat (limited to 'src/boot/bootctl.c')
-rw-r--r-- | src/boot/bootctl.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 827927f18b..0ee908e8a3 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -1066,6 +1066,22 @@ static int verb_list(int argc, char *argv[], void *userdata) { return 0; } +static int sync_esp(void) { + _cleanup_close_ int fd = -1; + + if (!arg_path) + return 0; + + fd = open(arg_path, O_CLOEXEC|O_DIRECTORY|O_RDONLY); + if (fd < 0) + return log_error_errno(errno, "Couldn't open ESP '%s' for synchronization: %m", arg_path); + + if (syncfs(fd) < 0) + return log_error_errno(errno, "Failed to synchronize the ESP '%s': %m", arg_path); + + return 1; +} + static int verb_install(int argc, char *argv[], void *userdata) { sd_id128_t uuid = SD_ID128_NULL; @@ -1092,6 +1108,8 @@ static int verb_install(int argc, char *argv[], void *userdata) { } } + (void) sync_esp(); + if (arg_touch_variables) r = install_variables(arg_path, part, pstart, psize, uuid, @@ -1111,6 +1129,8 @@ static int verb_remove(int argc, char *argv[], void *userdata) { r = remove_binaries(arg_path); + (void) sync_esp(); + if (arg_touch_variables) { int q; |