summaryrefslogtreecommitdiffstats
path: root/include/loopdev.h
Commit message (Collapse)AuthorAgeFilesLines
* lib/loopdev: set blocksize when create a new deviceKarel Zak2019-01-221-0/+2
| | | | | | | | | | | The partition scanner in kernel depends on blocksize. We need to set the blocksize before we call LOOP_SET_STATUS64 (this ioctl triggers the scanner). This patch extends the internal API to save blocksize into loopdev context to be usable later for loopcxt_setup_device(). Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: differentiate between setter()s and ioctl callsKarel Zak2019-01-221-4/+5
| | | | | | | | Now the internal API uses loopcxt_set_...() to set context variables as well as to call ioctls. This patch introduces loopcxt_ioctl_...() to makes things more obvious to readers. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: use new ul_path_* APIKarel Zak2018-06-211-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: Add support for logical block sizeStanislav Brabec2017-09-271-0/+3
| | | | | | | | | | | | | | | | | | | | Kernel since 4.14 supports setting of logical block size[1]. It allows to create loop devices that report logical block size different from 512. Add support for this feature to losetup. References: [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/block/loop.c?id=89e4fdecb51cf5535867026274bc97de9480ade5 [kzak@redhat.com: - fix loopcxt_get_blocksize() - remove lo_blocksize from loop_info64] Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Cc: Ming Lei <ming.lei@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: Implememt loopcxt_set_status()Stanislav Brabec2016-08-171-0/+1
| | | | | | | | | | | | Implement stand-alone loopcxt_set_status(). It allows manipulation with some loop device parameters even if it is initialized. Its function is limited by the kernel implementation, and only a small subset of changes is allowed. For more see linux/drivers/block/loop.c:loop_set_status() Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* lib/loopdev: cleanup sizelimit checkKarel Zak2016-08-041-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Implement loopcxt_check_conflict()Stanislav Brabec2016-08-031-0/+3
| | | | | | | Add a function that searches for a possible conflicting (i. e. overlaying loop device). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* Add sizelimit to internal APIStanislav Brabec2016-08-031-3/+5
| | | | | | | | | | | | | | Fully safe checks of loop device need to check sizelimit. To prevent need of two nearly equal functions, introduce sizelimit parameter to several internal functions: loopdev_is_used() loopdev_find_by_backing_file() loopcxt_is_used() loopcxt_find_by_backing_file() If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* losetup: support list direct ioMing Lei2015-11-191-0/+2
| | | | | | So that user can see if DIO is set for current loop device. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
* losetup: support ioctl cmd of LOOP_SET_DIRECT_IOMing Lei2015-11-191-0/+2
| | | | | | | | From v4.4, linux kernel starts to support direct I/O and AIO to backing file for loop driver, so allow losetup to enable the feature by using LOOP_SET_DIRECT_IO ioctl cmd. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
* lib/loopdev: replace custom DBG() with include/debug.hKarel Zak2014-11-041-2/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix typo "ioclt" in various files.Lauri Nurmi2014-07-111-1/+1
|
* losetup: wait for udevKarel Zak2014-01-241-0/+1
| | | | | | | | | | | | | On system with /dev/lop-control the udevd creates /dev/loopN nodes. It seems better to wait a moment after unsuccessful open(/dev/loopN) and try it to open again. The problem is pretty visible on systems where udevd also modifies permission for loopN devices, then open() fails with EACCES when losetup executed by non-root user (but user who is in "disk" group). Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432 Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: use loop-control to explicitly ask for deviceKarel Zak2013-08-061-0/+1
| | | | | | | | | | | | | | | | Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example losetup -f foo.img Unfortunately, losetup(8) allows to ask for specified device losetup /dev/loop100 foo.img and in this case we assume that the device already exists in the system. This is incorrect, we should be able to use loop-control LOOP_CTL_ADD ioctl to ask for the specified device. Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: sync capacity after setting itJeff Mahoney2013-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I recently tried to mount an hfsplus file system from an image file with a partition table by using the loop offset and sizelimit options to specify the location of the file system. hfsplus stores some metadata at a set offset from the end of the partition, so it's sensitive to the device size reported by the kernel. It worked with this: But failed with this: /dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /proc/partitions shows the correct number of blocks to match the sizelimit. But if I set a breakpoint in mount before the mount syscall, I could see: 102400000 102432768 The kernel loop driver will set the gendisk capacity of the device at LOOP_SET_STATUS64 but won't sync it to the block device until one of two conditions are met: All open file descriptors referring to the device are closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl is called to sync it. Since mount opens the device and passes it directly to the mount syscall after LOOP_SET_STATUS64 without closing and reopening it, the sizelimit argument is effectively ignroed. The capacity needs to be synced immediately for it to work as expected. This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since the device isn't yet released to the user, so it's safe to sync the capacity immediately. [kzak@redhat.com: - port to the current git HEAD, - use uint64_t] Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: losetup: remove obsolete encryption supportLudwig Nussel2012-09-111-3/+0Star
| | | | | | | | | | | | | | | kernel cryptoloop is deprecated since ages and support for cryptoloop in util-linux is incomplete/broken. - no password hashing - last 8 bit of key are always set to zero - no binary keys possible (stops reading key at \n and \0) In the past some Distros added the above features with patches. So remove cryptoloop support from util-linux completely to make sure people won't try using it. Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: use warn_unused_result forimportant functionsKarel Zak2012-06-211-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: improve -a to report loopdevs < 512 bytesKarel Zak2012-06-121-0/+1
| | | | | | | | | | | | | | | | | | # ll ~/xxx2 -rw-r--r-- 1 root root 500 Jun 12 14:30 /root/xxx2 old version: # losetup -a new version: # losetup -a /dev/loop0: [2052]:535312 (/root/xxx2) The new version scans /sys/block/loopN, kernel >= 2.6.37 is required otherwise fallback to the original not-so-smart /proc/partitions scan. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: more robust initializationKarel Zak2012-04-021-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: add --partscan optionKarel Zak2012-01-091-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: support LO_FLAGS_PARTSCAN flag (kernel 3.2)Karel Zak2012-01-091-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: rewrite loop setupKarel Zak2011-12-221-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,loopdev: add missing functionsKarel Zak2011-12-221-0/+12
| | | | | | | | | - improve loop_info usage (don't call ioctl more than once) - add functions to get devno and inode of the backing file - add function for compare any file with backing file by devno + inode or by filename Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,loopdev: add LOOP_CTL_GET_FREE supportKarel Zak2011-11-071-1/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/loopdev.h: add missing function prototypeDave Reisner2011-10-121-0/+1
| | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* umount: use new lib/loopdev.c codeKarel Zak2011-09-301-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,loopdev: add debugu messagesKarel Zak2011-09-291-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use unsigned int for bit-filedsKarel Zak2011-07-291-4/+4
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [loopdev.c] cleanup flags usageKarel Zak2011-06-101-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [loopdev.c] add module for work loop devicesKarel Zak2011-05-301-0/+154
Signed-off-by: Karel Zak <kzak@redhat.com>