summaryrefslogtreecommitdiff
path: root/mount/lomount.c
AgeCommit message (Collapse)AuthorFilesLines
2009-02-24mount: remove useless if-before-free testsKarel Zak1-2/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-19losetup: detach more devices by "-d <loop> [<loop> ..]"Karel Zak1-14/+19
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>
2009-02-11mount: move realpath.c code to lib/Karel Zak1-1/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-11-18losetup: add warning about read-only modeKarel Zak1-0/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-11-18losetup: try to set up loop readonly if EACCESMatthias Koenig1-1/+2
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>
2008-10-03losetup: several strings without gettext stringsPedro Ribeiro1-4/+4
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2008-09-30losetup: missing EBUSY error hint messageKarel Zak1-5/+16
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>
2008-08-21losetup: remove dependence on minor numbersKarel Zak1-0/+4
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>
2008-08-04losetup: looplist_* refactoring, remove scandir()Karel Zak1-149/+153
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>
2008-07-02losetup: clean up code around LO_FLAGS_AUTOCLEARKarel Zak1-21/+20
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-07-02umount: improve "-d" option for autoclear loopsKarel Zak1-0/+23
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>
2008-04-16losetup: split help message into two smaller partsBenno Schulenberg1-4/+5
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>
2008-04-15losetup: mark the option -s as deprecatedKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-04-15losetup: add --sizelimit optionShachar Shemesh1-10/+23
[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>
2008-02-19mount: allow auto-destruction of loop devicesBernardo Innocenti1-6/+28
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>
2008-02-08losetup: add --associated optionKarel Zak1-17/+59
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>
2008-02-08losetup: support unlimited number of loopsKarel Zak1-109/+318
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>
2007-12-03losetup: use standard uintxy_t types (struct loop_info64)Samuel Thibault1-4/+5
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>
2007-11-26mount: fix fd leakMatthias Koenig1-0/+1
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
2007-10-26mount: prevent loop mounting the same file twiceKarel Zak1-1/+107
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>
2007-10-26losetup: canonicalize loopfile nameKarel Zak1-2/+12
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>
2007-10-25losetup: fix errno usageKarel Zak1-8/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-25mount: clean up global variablesKarel Zak1-5/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-25losetup: remove duplicate xstrdup() and error()Karel Zak1-31/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-11losetup: clean up gcc warningsRandy Dunlap1-5/+5
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>
2007-08-27mount: free loop device on failureSascha Sommer1-0/+1
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>
2007-07-10lomount.c: don't use mlockall if CRYPT_NONEMasatake YAMATO1-6/+7
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>
2007-06-27losetup: add long options and fix man pageKarel Zak1-9/+31
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-06-27mount: loop device race conditionMatthias Koenig1-5/+18
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>
2007-06-27mount: loop device race conditionMatthias Koenig1-2/+10
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>
2007-06-18losetup: add a new option -sKarel Zak1-3/+10
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>
2007-03-22losetup: add support read-only loopsKarel Zak1-2/+6
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>
2007-03-22losetup: add -a option to list all used loop devicesKarel Zak1-14/+58
Signed-off-by: Karel Zak <kzak@redhat.com>
2006-12-07Imported from util-linux-2.12o tarball.Karel Zak1-5/+4
2006-12-07Imported from util-linux-2.12k tarball.Karel Zak1-3/+7
2006-12-07Imported from util-linux-2.12j tarball.Karel Zak1-51/+75
2006-12-07Imported from util-linux-2.12h tarball.Karel Zak1-15/+19
2006-12-07Imported from util-linux-2.12b tarball.Karel Zak1-6/+7
2006-12-07Imported from util-linux-2.12a tarball.Karel Zak1-151/+216
2006-12-07Imported from util-linux-2.12pre tarball.Karel Zak1-216/+151
2006-12-07Imported from util-linux-2.12 tarball.Karel Zak1-151/+216
2006-12-07Imported from util-linux-2.11x tarball.Karel Zak1-2/+3
2006-12-07Imported from util-linux-2.11o tarball.Karel Zak1-1/+1
2006-12-07Imported from util-linux-2.11b tarball.Karel Zak1-6/+5
2006-12-07Imported from util-linux-2.10s tarball.Karel Zak1-9/+42
2006-12-07Imported from util-linux-2.10m tarball.Karel Zak1-214/+339
2006-12-07Imported from util-linux-2.9v tarball.Karel Zak1-24/+34
2006-12-07Imported from util-linux-2.8 tarball.Karel Zak1-8/+7
2006-12-07Imported from util-linux-2.7.1 tarball.Karel Zak1-87/+145
2006-12-07Imported from util-linux-2.2 tarball.Karel Zak1-0/+223