Re: [PATCH 2/8] losetup: Re-use loop device with matching parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 03, 2016 at 11:33:34AM +0200, Karel Zak wrote:
> On Tue, Aug 02, 2016 at 07:55:58PM +0200, Stanislav Brabec wrote:
> > If losetup --find is called with parameters matching to an existing loop device,
> > re-use this loop device instead of allocating new one.
> > 
> > If --force is used, fall back to the old behavior.
> > 
> > Signed-off-by: Stanislav Brabec <sbrabec@xxxxxxx>
> > ---
> >  sys-utils/losetup.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 46 insertions(+)
> > 
> > diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
> > index 0a323a9..ef6f52b 100644
> > --- a/sys-utils/losetup.c
> > +++ b/sys-utils/losetup.c
> > @@ -682,6 +682,51 @@ int main(int argc, char **argv)
> >  	{
> >  		int hasdev = loopcxt_has_device(&lc);
> >  
> > +		if (!hasdev && !force) {
> > +			res = loopcxt_find_by_backing_file(&lc,
> > +				file, offset, sizelimit,
> > +				LOOPDEV_FL_OFFSET | LOOPDEV_FL_SIZELIMIT);
> 
> Is it valid to set always the flags? If I do not specify --sizelimit
> then this code will use 0 as wanted size, right?

Ah... but /sys/.../sizelimit also uses 0 if not specified for the
original loop. So, seems correct.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux