Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
This patch allows to detach more devices by "losetup -d",
for example:
# losetup -a
/dev/loop0: [0804]:9955739 (/home/images/ary0.img)
/dev/loop1: [0804]:9955740 (/home/images/ary1.img)
/dev/loop2: [0804]:9955745 (/home/images/ary2.img)
# losetup -d /dev/loop0 /dev/loop1 /dev/loop2
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Currently mounting/losetup an image fails if it is accessable readonly.
There are no problems if it is a file on a local filesystem.
It seems only to happen if it is a NFS mounted image, which is
read-write in permission but with root_squash option.
set_loop checks only for EROFS to retry open with readonly mode,
but in this case we get EACCES.
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
|
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
old version:
# losetup /dev/loop0 /foo.img
# losetup /dev/loop0 /bar.img; echo $?
2
new version:
# losetup /dev/loop0 /foo.img
# losetup /dev/loop0 /bar.img; echo $?
losetup: /dev/loop0: device is busy
2
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
The latest kernel supports partitioned loop devices (kernel commit
476a4813cfddf7cf159956cc0e2d3c830c1507e3). Unfortunately, this change
makes minor numbers useless, because mirror number does not match with
loop device name (loop<N>).
We have to follow loop device names only.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
This patch replaces scandir-based implementation with readdir(). The
readdir(3) is less expensive and more portable (to non-glibc environment).
The patch also replaces sysfs-based solution with simpler /proc/partitions
parsing. The /proc/partitions includes all used loop devices on all systems
(include 2.4). This solution seems faster than scandir(/sys/block/) too.
Summary, the losetup (with this patch) uses three methods to found a
loop device:
a) parse /proc/partitions to found already used loop devices (for
loserup -a)
b) stat(2) for all loop[0-7] devices (default number of loop devices).
This is classic method from util-linux <= 2.13. This method is good
enough for standard Linux machines with default number of loop
devices.
c) scan all /dev or /dev/loop/ for loop devices. This is useful for
crazy people who need more than 8 loop devices.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
The new loop auto-destruct feature detaches automatically loop devices
when no longer used. This means they are detached with the umount()
call. But when we call umount with -d, del_loop() is called and fails
because the ioctl() returns ENXIO. We have to check for autoclear
loop devices rather than blindly call del_loop().
Reported-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
As it has already changed since the previous release, take the opportunity
to cut it into two more manageable chunks for translators.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
[kzak@redhat.com: split the original patch to small patches]
Signed-off-by: Shachar Shemesh <shachar@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
This allows a flag to be set on loop devices so that when they are closed
for the last time, they'll self-destruct.
The kernel part has been submitted to lkml by David Woodhouse.
Signed-off-by: Bernardo Innocenti <bernie@codewiz.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
losetup -j | --associated <file> [-o <num>]
This new option lists all loop devices associated with given file
(and optionally file offset).
Examples:
# losetup -a
/dev/loop0: [0807]:21921808 (/foo/vfat-mbr.img)
/dev/loop1: [0807]:21921808 (/foo/vfat-mbr.img), offset 100
/dev/loop2: [0807]:21921802 (/bar/ext3.img)
# losetup -j /foo/vfat-mbr.img
/dev/loop0: [0807]:21921808 (/foo/vfat-mbr.img)
/dev/loop1: [0807]:21921808 (/foo/vfat-mbr.img), offset 100
# losetup -j /foo/vfat-mbr.img -o 100
/dev/loop1: [0807]:21921808 (/foo/vfat-mbr.img), offset 100
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Old implementation:
- supports 256 loop devices only
- doesn't support gaps in list of loop devices
(e.g. loop0, loop1, loop3 -- loop3 is invisible)
Kernel 2.6.21 removes artificial maximum 256 loop device. Now the maximum
of loop devices could be really huge (depends on limit of MINOR
numbers). It means we need a better way how work with loop devices
than blindly call stat(2) for all 0-1048575 devices.
This patch uses three methods:
a) scan /sys/block/loopN (used for losetup -a only). This method is
probably the fastest way how found used loop device on machine with
huge number of devices in /dev.
b) classic way, stat(2) for all loop[0-7] devices (default number of
loop devices). This cheap method is sufficient for 99% of all machines.
c) scan all /dev/loopN or /dev/loop/N
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
The kernel loop_info64 definition uses __u{8,32,64} types,
but userspace uses unsigned {long long,int,char} types.
This patch turns into exactly defined standard uint{8,32,64}_t types.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
|
The mount syscall prevents mounting the same device twice
to the same mountpoint. When loop mounting a file, for each
file a new loop device gets allocated, which prevents the detection
of loop mounting the same file to the same mountpoint twice.
The patch adds a check to prevent double mounts, if the same loopfile
is going to be mounted with the same offset to the same mountpoint.
Co-Author: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
When setting up a loop device, canonicalize the loop file
name. This simplifies a later identification of loop file names
when querying the loop devices.
Co-Author: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Fix strict gcc warnings that come from using:
("-Wall -Wp,-D_FORTIFY_SOURCE=2")
lomount.c:98: warning: pointer targets in initialization differ in signedness
lomount.c:111: warning: format '%04x' expects type 'unsigned int', but argument 4 has type '__kernel_old_dev_t'
lomount.c:300: warning: pointer targets in passing argument 1 of 'xstrncpy' differ in signedness
lomount.c:307: warning: pointer targets in passing argument 1 of '__builtin___snprintf_chk' differ in signedness
lomount.c:339: warning: pointer targets in passing argument 1 of 'xstrncpy' differ in signedness
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
|
|
Testcase:
$ mount -oloop /etc/group /mnt
ioctl: LOOP_CLR_FD: Device or resource busy
mount: you must specify the filesystem type
$ losetup /dev/loop0
/dev/loop0: [0803]:1931929 (/etc/group)
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
|
loop back mounting emits two system calls: mount and mlockall.
mount is obviously needed. mlockall is needed for encryption.
As the result both CAP_SYS_ADMIN and CAP_IPC_LOCK are needed
to do loopback mounting.
The problem is that CAP_IPC_LOCK is always needed through my
command doesn't need encryption.
With the following patch, mount calls mlockall only when
encryption is needed.
Signed-off-by: Masatake YAMATO <jet@gyve.org>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Fix race in losetup
Retry acquiring a loop device if set_loop failed with EBUSY
Signed-Off-By: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Fix race in mount -o loop
Retry acquiring a loop device if the setup failed with EBUSY.
Signed-Off-By: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
The losetup provides an -f option to discover an unused loop device. As
implemented, it is racy. The problem is that -f prints the loop device
to stdout only when used standalone. This means a script has to do:
lodev=$(losetup -f)
losetup $lodev $filename
which is racy if another script may be running.
This patch add a new option '-s'. The '-s' option prints device name
if the -f option and a file argument are present. For example:
lodev=$(losetup -f -s $filename)
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
This feature has been already supported by mount, but it wasn't accessible by
losetup command. Now you can use "losetup -r".
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|