Skip to content

Commit

Permalink
add new systemd-bless-boot.service that marks boots as successful
Browse files Browse the repository at this point in the history
This is the counterpiece to the boot counting implemented in
systemd-boot: if a boot is detected as successful we mark drop the
counter again from the booted snippet or kernel image.
  • Loading branch information
poettering committed Oct 19, 2018
1 parent 82ea382 commit 36695e8
Show file tree
Hide file tree
Showing 6 changed files with 537 additions and 0 deletions.
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,15 @@ if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
install_rpath : rootlibexecdir,
install : true)
public_programs += exe

executable('systemd-bless-boot',
'src/boot/bless-boot.c',
include_directories : includes,
link_with : [libshared],
dependencies : [libblkid],
install_rpath : rootlibexecdir,
install : true,
install_dir : rootlibexecdir)
endif

exe = executable('systemd-socket-activate', 'src/activate/activate.c',
Expand Down
28 changes: 28 additions & 0 deletions src/basic/fs-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,34 @@ int fsync_directory_of_file(int fd) {
return 0;
}

int fsync_path_at(int at_fd, const char *path) {
_cleanup_close_ int opened_fd = -1;
int fd;

if (isempty(path)) {
if (at_fd == AT_FDCWD) {
opened_fd = open(".", O_RDONLY|O_DIRECTORY|O_CLOEXEC);
if (opened_fd < 0)
return -errno;

fd = opened_fd;
} else
fd = at_fd;
} else {

opened_fd = openat(at_fd, path, O_RDONLY|O_CLOEXEC);
if (opened_fd < 0)
return -errno;

fd = opened_fd;
}

if (fsync(fd) < 0)
return -errno;

return 0;
}

int open_parent(const char *path, int flags, mode_t mode) {
_cleanup_free_ char *parent = NULL;
int fd;
Expand Down
1 change: 1 addition & 0 deletions src/basic/fs-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ void unlink_tempfilep(char (*p)[]);
int unlinkat_deallocate(int fd, const char *name, int flags);

int fsync_directory_of_file(int fd);
int fsync_path_at(int at_fd, const char *path);

int open_parent(const char *path, int flags, mode_t mode);
Loading

0 comments on commit 36695e8

Please sign in to comment.