From 9a94b634a343e83bfa2a9d311074e3e520abdddd Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 17 Aug 2016 12:28:33 +0200 Subject: losetup: add --nooverlap options This patch introduces overlap detections and loop devices re-use for losetup(8). We already support this feature for mount(8) where it's enabled by default (because we mount filesystems and it's always mistake to share the same filesystem between more loop devices). Stanislav has suggested to enable this feature also for losetup by default. I'm not sure about it, IMHO it's better to keep losetup(8) simple and stupid by default, and inform users about possible problems and solutions in the man page. The feature forces losetup to scan all loop devices always when new one is requested. This maybe disadvantage (especially when we use control-loop to avoid /sys or /dev scans) on system with huge number of loop devices. Co-Author: Stanislav Brabec Signed-off-by: Karel Zak --- sys-utils/losetup.8 | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sys-utils/losetup.8') diff --git a/sys-utils/losetup.8 b/sys-utils/losetup.8 index b614416df..805051290 100644 --- a/sys-utils/losetup.8 +++ b/sys-utils/losetup.8 @@ -67,6 +67,11 @@ device is shown. If no option is given, all loop devices are shown. .sp Note that the old output format (i.e. \fBlosetup -a\fR) with comma-delimited strings is deprecated in favour of the \fB--list\fR output format. +.sp +It's possible to create more independent loop devices for the same backing +file. +.B This setup may be dangerous, can cause data loss, corruption and overwrites. +Use \fB\-\-nooverlap\fR to avoid this problem. .SH OPTIONS The \fIsize\fR and \fIoffset\fR @@ -102,6 +107,12 @@ Find the first unused loop device. If a argument is present, use the found device as loop device. Otherwise, just print its name. .TP +.BR \-L , " \-\-nooverlap" +Check for conflicts between loop devices to avoid situation when the same +backing file is shared between more loop devices. If the file is already used +by another device then re-use the device rather than a new one. The option +makes sense only with \fB\-\-find\fP. +.TP .BR \-j , " \-\-associated " \fIfile Show the status of all loop devices associated with the given .IR file . -- cgit v1.2.3-55-g7522