diskfs / go-diskfs

MIT License
515 stars 113 forks source link

Detect block device size using platform-specific IOCTL on Mac & Linux #173

Closed yadutaf closed 1 year ago

yadutaf commented 1 year ago

Currently, diskfs attempts to detect the size of a block device using a "seek" based approach. Unfortunately, while this looks generic, it does not work on Mac, at least not in a VM.

Based on the previous commit, this commit adds a Mac and Linux implementation for getting the size of a Block device through IOCTL inspired by https://github.com/tytso/e2fsprogs/blob/master/lib/ext2fs/getsize.c

This was manually tested using a Linux loopback device and in a Mac virtual machine.

yadutaf commented 1 year ago

Let me know if you'd rather see 2 distinct PRs (one for the refactoring and 1 for the IOCTL)

deitch commented 1 year ago

I like this, no need to split it. I have some questions, going to comment inline.

deitch commented 1 year ago

Thank you!