aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

commit 62102c5abfd3147becc3aba1c3d923c999212cc5
parent f9624b5660936abc609358561f0bfd11a49eec6b
Author: xplshn <anto@xplshn.com.ar>
Date:   Sun, 22 Nov 2026 00:06:40 -0300

fdisk: the linux filesystem type, and the kernel reads the table again

Diffstat:
Mcmd/extra/fdisk.c | 2+-
Mshared/diskutil.h | 1+
Mshared/libutil/diskutil.c | 11+++++++++++
3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/cmd/extra/fdisk.c b/cmd/extra/fdisk.c @@ -143,7 +143,7 @@ static const struct { 0x4f} }, /* 8300: linux filesystem data */ {"8300", - {0xaf, 0x3d, 0xc6, 0x0f, 0x84, 0x83, 0x72, 0x47, 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, + {0xaf, 0x3d, 0xc6, 0x0f, 0x83, 0x84, 0x72, 0x47, 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4} }, }; #define GPT_TYPE_TABLE_LEN (int)(sizeof(gpt_type_table) / sizeof(gpt_type_table[0])) diff --git a/shared/diskutil.h b/shared/diskutil.h @@ -11,6 +11,7 @@ struct BlockDev { int fd; uint64_t size; size_t sec_size; + int dirty; // written to: the kernel's view of the table is stale }; struct BlockDevInfo { diff --git a/shared/libutil/diskutil.c b/shared/libutil/diskutil.c @@ -47,6 +47,7 @@ blockdev_open(struct BlockDev *dev, const char *path, int writable) dev->fd = fd; dev->size = st.st_size; dev->sec_size = 512; + dev->dirty = 0; if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) { #if defined(__linux__) @@ -108,6 +109,7 @@ blockdev_write(struct BlockDev *dev, uint64_t sector, const void *buf, size_t se n = write(dev->fd, buf, size); if (n < 0 || (size_t)n != size) return -1; + dev->dirty = 1; return 0; } @@ -115,6 +117,15 @@ blockdev_write(struct BlockDev *dev, uint64_t sector, const void *buf, size_t se void blockdev_close(struct BlockDev *dev) { +#if defined(__linux__) + struct stat st; + + // the kernel keeps the partition table it read when the disk appeared: + // a table written here has no device nodes until it is asked to read + // again, which fails harmlessly while a partition is in use + if (dev->dirty && dev->fd >= 0 && fstat(dev->fd, &st) == 0 && S_ISBLK(st.st_mode)) + ioctl(dev->fd, BLKRRPART); +#endif if (dev->fd >= 0) { close(dev->fd); dev->fd = -1;