2000-12-15 03:51:26

by Tim Riker

[permalink] [raw]
Subject: loop device length

losetup allows for setting a starting offset within a file for the loop
block device. There however is no length parameter to permit setting the
length. Adding a length parameter would allow for multiple fs images in
a single file (or device) and would correctly handle programs like
resize2fs.

What do you think? We could add a lo_length to struct loop_device and
return that if it was non-zero and less than the physical length
calculated normally by figure_loop_size().

While I'm at it why are loop_sizes[] and loop_blksizes[] not part of
struct loop_device now?
--
Tim Riker - http://rikers.org/ - short SIGs! <g>
All I need to know I could have learned in Kindergarten
... if I'd just been paying attention.


2000-12-17 11:09:34

by Peter Samuelson

[permalink] [raw]
Subject: Re: loop device length


[Tim Riker]
> losetup allows for setting a starting offset within a file for the
> loop block device. There however is no length parameter to permit
> setting the length. Adding a length parameter would allow for
> multiple fs images in a single file (or device) and would correctly
> handle programs like resize2fs.

You don't need a length field for this, although it may be a good idea.
Filesystems know how big they are. You only need to force it at mkfs
and resize time, and in both cases you can override the tool's
knowledge.

In other words, you *can* put multiple fs images on a single piece of
backing store as long as you manage the lengths manually, which you
have to do anyway since you're keeping track of the starting offsets.

All the length parameter buys is not having to specify the same length
to losetup and mke2fs. And a little protection from shooting yourself
in the foot, but by the time you are messing with stuff like this you
had better be careful anyway.

Peter