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

Loopback with offset #21

Closed
tsemczyszyn opened this issue Apr 12, 2022 · 2 comments
Closed

Loopback with offset #21

tsemczyszyn opened this issue Apr 12, 2022 · 2 comments

Comments

@tsemczyszyn
Copy link
Contributor

Is it possible to mount a loop device with a given offset? If so how might I do that?

@mmstick
Copy link
Member

mmstick commented Apr 12, 2022

https://docs.rs/sys-mount/latest/sys_mount/struct.MountBuilder.html

Try passing the options to the data parameter.

@tsemczyszyn
Copy link
Contributor Author

I tried that but no luck. It looks like the offset actually has to be specified when the loop device is being set up. From an strace on my program I see this before the mount syscall:

ioctl(8, LOOP_SET_STATUS64, {lo_device=makedev(0, 0), lo_inode=0, lo_rdevice=makedev(0, 0), lo_offset=0, lo_sizelimit=0, lo_number=0, lo_encrypt_type=LO_CRYPT_NONE, lo_encrypt_key_size=0, lo_flags=0, lo_file_name="", lo_crypt_name="", lo_encrypt_key="", lo_init=[0, 0]}) = 0

If I look at the same strace from the mount command instead of my program I see this:

ioctl(4, LOOP_SET_STATUS64, {lo_offset=0x20100000, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/my/disk/image.img", ...}) = 0

So my guess is that the mount command detects that offset parameter in the options and feeds it into the loop device creation.

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

No branches or pull requests

2 participants