So far, barebox-state with a MMC backend always opened the whole disk read/write, which triggers a partition table reread when closing the device. This can be avoided in some cases:
- If we are only interested in reading, we can open it O_RDONLY - If there happens to be an on-disk-described partition at exactly the region we are interested, we can open that instead. So let's do that. The result can be easily verified with strace. Without this patch: openat(AT_FDCWD, "/dev/mmcblk0", O_RDWR|O_LARGEFILE) = 4 With this patch: openat(AT_FDCWD, "/dev/mmcblk0p6", O_RDONLY|O_LARGEFILE) = 4 Ahmad Fatoum (3): state: backend: direct: open block device in read-only mode if possible libdt: factor out u64 sysattr parsing into helper libdt: use block device partition instead of parent if found src/barebox-state/backend_bucket_direct.c | 5 +- src/barebox-state/backend_storage.c | 2 +- src/barebox-state/state.c | 6 +- src/barebox-state/state.h | 3 +- src/libdt.c | 104 +++++++++++++++++----- 5 files changed, 92 insertions(+), 28 deletions(-) -- 2.39.2