OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:37 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: FUSE-mounting partitions in image file
PostPosted: Sat May 28, 2022 9:50 am 
Offline

Joined: Tue Aug 18, 2020 6:55 pm
Posts: 10
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)?


Top
 Profile  
 
 Post subject: Re: FUSE-mounting partitions in image file
PostPosted: Sat May 28, 2022 10:40 am 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
If this is a QEMU image, use qemu-nbd(8) to manipulate it like a normal device.


Top
 Profile  
 
 Post subject: Re: FUSE-mounting partitions in image file
PostPosted: Sat May 28, 2022 10:46 am 
Offline

Joined: Tue Aug 18, 2020 6:55 pm
Posts: 10
It's not, it's just a raw disk image.


Top
 Profile  
 
 Post subject: Re: FUSE-mounting partitions in image file
PostPosted: Sat May 28, 2022 12:05 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 78 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group