Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 11, 2023

Conversation

yadutaf
Copy link
Contributor

@yadutaf yadutaf commented Mar 8, 2023

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 yadutaf force-pushed the feat-os-specific-block-get-size branch from 6d0974f to 9188c11 Compare March 8, 2023 22:04
@yadutaf
Copy link
Contributor Author

yadutaf commented Mar 8, 2023

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

@deitch
Copy link
Collaborator

deitch commented Mar 9, 2023

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

yadutaf added 2 commits March 10, 2023 23:10
Darwin and Windows specific diskfs features already live in their own
module. Linux support however remains in a catch-all "unix" modules that
builds only for Linux in practice.

This commit makes the Unix module only target Linux and introduces a new
catch-all-other module to stub out block device specific functions.

This paves the road for using platform-specific IOCTL to get the
physical block device size and ultimately help with the Windows port of
block device support.

Signed-off-by: Jean-Tiare Le Bigot <jt@yadutaf.fr>
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.

Closes diskfs#171

Signed-off-by: Jean-Tiare Le Bigot <jt@yadutaf.fr>
@yadutaf yadutaf force-pushed the feat-os-specific-block-get-size branch from 9188c11 to b03a5db Compare March 10, 2023 22:10
@yadutaf yadutaf requested a review from deitch March 11, 2023 14:00
@deitch deitch merged commit a78c15f into diskfs:master Mar 11, 2023
@deitch
Copy link
Collaborator

deitch commented Mar 11, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants