FUSE-mounting partitions in image file

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kurtmweber
Posts: 10
Joined: Tue Aug 18, 2020 6:55 pm

FUSE-mounting partitions in image file

Post by kurtmweber »

Let's say I've written a FUSE driver for my OS's filesystem. On a particular disk image file, that filesystem is one of several partitions. I'd like to be able to mount that partition in my host/development system to streamline the process of populating it for testing purposes, particularly before I get writing working in my OS project.

The FUSE manual doesn't seem to indicate any way to specify a specific partition by name within an image file to mount (or even by specifying an offset + length, as one might with losetup).

It occurs to me that (as perhaps indicated above) one could use losetup + partx to detect and add loopback devices for the partitions, and then mount the partition's loopback device via fuse--but that seems a bit kludgey. Is there a better, more straightforward way that I'm overlooking or that someone else has come up with (and that does not require privilege elevation, as working with loopback devices does)?
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: FUSE-mounting partitions in image file

Post by Ethin »

If this is a QEMU image, use qemu-nbd(8) to manipulate it like a normal device.
kurtmweber
Posts: 10
Joined: Tue Aug 18, 2020 6:55 pm

Re: FUSE-mounting partitions in image file

Post by kurtmweber »

It's not, it's just a raw disk image.
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: FUSE-mounting partitions in image file

Post by nullplan »

Add an "offset" option to your FUSE driver (or, more likely, offset and length), then write a program that parses the partition table of the disk image and tells you offset and length of the partition you want. Change your FUSE driver to limit your file accesses to the given range.

That is how UNIX was supposed to work, use different tools for different jobs. Parsing partition tables is not the same job as implementing a file system.
Carpe diem!
Post Reply