summaryrefslogtreecommitdiff
path: root/lib/loopdev.c
AgeCommit message (Collapse)AuthorFilesLines
2013-05-13lib/loopdev: fix loopcxt_check_size() to work with blkdevsKarel Zak1-1/+15
The loopcxt_check_size() is workaround for kernels < v3.9, kernel has been fixed by commit 541c742a7559eb65f0e36d3e2338c2ca532a3e61. The function sets loopdev size according to backing file size. The problem is that the backing file could be a block device where stat.st_size is zero, so we have to use blkdev_get_size() for block devices. Addresses: https://bugs.archlinux.org/task/35193 Reported-by: Dave Reisner <d@falconindy.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-09loopdev: sync capacity after setting itJeff Mahoney1-3/+83
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>
2013-04-03lib: use O_CLOEXEC in libcommonKarel Zak1-5/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08include: cleanup copyright headersKarel Zak1-1/+4
We use the code from include/ and lib/ on many places, so use public domain if possible or LGPL for code copied from libs. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19lib/loopdev: fix loopdev_find_by_backing_file()Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12lib/loopdev: make loopcxt_get_device() more robustKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-17lib/loopdev: check for /sysKarel Zak1-0/+6
The current loopdev code prefers /sys to get information about loop devices. The old methods like scan /dev are fallback solution only. Unfortunately, the code does not check if /sys is mounted. Addresses: http://blog.flameeyes.eu/2012/10/sophistication-can-be-bad Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-17lib/loopdev: improve debug messagesKarel Zak1-4/+18
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-11mount: losetup: remove obsolete encryption supportLudwig Nussel1-56/+0
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>
2012-07-16lib/loopdev: minor bug fix: add missing semicolonSami Kerola1-1/+1
Missing semicolon made test_loop_info() to return function loopcxt_enable_debug() return value, which happen to be void. I suspect the loopcxt_enable_debug() was usually not executed, while it should be. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-09fix buffer overrun in some calls to sscanfKarel Zak1-1/+1
Reported-by: Sergei Antonov <saproj@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21lib/loopdev: use warn_unused_result forimportant functionsKarel Zak1-24/+41
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12losetup: improve -a to report loopdevs < 512 bytesKarel Zak1-17/+95
# 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>
2012-05-28libmount: add MNT_ERR_LOOPDEVKarel Zak1-0/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-02lib/loopdev: more robust initializationKarel Zak1-1/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02lib/loopdev: remove dead assigment and null deferenceKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02lib/loopdev: fix part scan detection codeKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-01lib/loopdev: fix possible dir leak on errorKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17lib,loopdev: remove duplicate includesKarel Zak1-1/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16libmount: avoid duplicate loopdevsKarel Zak1-1/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09loopdev: improve debug messagesKarel Zak1-2/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09loopdev: support LO_FLAGS_PARTSCAN flag (kernel 3.2)Karel Zak1-2/+62
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22losetup: rewrite loop setupKarel Zak1-0/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22lib,loopdev: add missing functionsKarel Zak1-41/+166
- 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>
2011-11-07lib,loopdev: add LOOP_CTL_GET_FREE supportKarel Zak1-7/+29
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-30umount: use new lib/loopdev.c codeKarel Zak1-0/+40
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-30mount: use new lib/loopdev.c codeKarel Zak1-1/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-29lib,loopdev: add debugu messagesKarel Zak1-17/+109
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27lib,loopdev: fix use of logical '&&' with constant operandFrancesco Cosoleto1-2/+2
Found by clang. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-12libmount: potential null derefence [smatch scan]Karel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-23lib: [loopdev.c] correct qsort compare functionKarel Zak1-1/+2
Reported-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-08lib: [loopdev.c] correct trivial typoDavidlohr Bueso1-1/+1
Should say "failed to find" instead of "failed to found". Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-28build-sys: fix 'make checkincludes' warningsKarel Zak1-2/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-10lib: [loopdev.c] cleanup flags usageKarel Zak1-17/+97
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-30lib: [loopdev.c] add module for work loop devicesKarel Zak1-0/+1053
Signed-off-by: Karel Zak <kzak@redhat.com>