Skip to content

Commit

Permalink
cptofs: remount as read-only prior to exiting
Browse files Browse the repository at this point in the history
also umount returns and /proc/self/mounts no longer lists the filesystem, ext4 seems to only flush the filesystem properly after a certain delay.
To work around this, we now remount the filesystem as read-only to ensure that it is actually finished by the time we exited

Signed-off-by: Jörg Thalheim <[email protected]>
  • Loading branch information
Mic92 committed Oct 12, 2023
1 parent 3023e6f commit dd6a274
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/lkl/cptofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,27 @@ int main(int argc, char **argv)
break;
}

/* FIXME: Remouting as readonly seems to be required to make sure the filessytem is cleanly umounted. Otherwise the journal will be still dirty... */
char dev_str[] = { "/dev/xxxxxxxx" };

snprintf(dev_str, sizeof(dev_str), "/dev/%08x", disk_id);
for (;;) {
ret = lkl_sys_mount(dev_str, mpoint, (char *)cla.fsimg_type, LKL_MS_RDONLY|LKL_MS_REMOUNT, NULL);
if (ret == 0)
break;
if (ret == -EBUSY) {
struct lkl_timespec ts = {
.tv_sec = 1,
.tv_nsec = 0,
};
lkl_sys_nanosleep((struct __lkl__kernel_timespec *)&ts, NULL);
continue;
} else if (ret < 0) {
fprintf(stderr, "cannot remount mount disk read-only: %s\n", lkl_strerror(ret));
break;
}
}

umount_ret = lkl_umount_dev(disk_id, cla.part, 0, 1000);
if (ret == 0)
ret = umount_ret;
Expand Down

0 comments on commit dd6a274

Please sign in to comment.