BuildRequires: pkgconfig(libsyscommon-plugin-api-sessiond)
Requires: /usr/sbin/mkfs.ext4
+Requires: /usr/sbin/fsck.ext4
%if %{with resize2fs}
Requires: /usr/sbin/resize2fs
%endif
OS::do_mount(template_img, template_dir);
try {
+ OS::do_fsck(subsession_img);
OS::do_resize2fs(subsession_img, size_kB);
OS::change_owner_and_group(subsession_img, uid, gid);
fs::create_directory(subsession_dir);
}
}
+void OS::do_fsck(const fs::path& fs_path)
+{
+ const auto child_pid = OS::throwing_fork();
+ if (child_pid == 0) {
+ const auto cmd = "/usr/sbin/fsck.ext4"sv;
+
+ const auto r = execl
+ ( cmd.data(), cmd.data() /* argv[0] convention */
+ , fs_path.c_str()
+ , "-fp"
+ , (char *) NULL
+ );
+
+ LOGE("Failed to execute `%s -fp %s`: %m"
+ , cmd.data()
+ , fs_path.c_str()
+ );
+ assert(r == -1);
+
+ _exit(1);
+ } else {
+ OS::throw_if_child_failed(child_pid, "fsck.ext4 failed!");
+ }
+}
+
void OS::do_umount(const fs::path& path)
{
const auto child_pid = OS::throwing_fork();
void do_resize2fs(const fs::path& fs_path, uint64_t size_kB);
+ void do_fsck(const fs::path& fs_path);
+
void do_mount(const fs::path& image_path, const fs::path& mount_path);
void do_umount(const fs::path& path);