1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00
lvm2/test/lvm-utils.sh
Jim Meyering 8bcd888dbc Clean-up and wording changes; add copyright notices.
* test/Makefile.in (srcdir, top_srcdir): Use @srcdir@, etc.
(top_builddir, abs_srcdir, abs_top_builddir, abs_top_srcdir): Likewise.
(so_name): Remove definition.
(.bin-dir-stamp): No longer create symlink in $(DMDIR) tree.
Prompted by suggestions from Alasdair Kergon.
* test/t1000-lvcreate-usage.sh (cleanup_): Redirect to a file,
rather than to /dev/null.
Change wording of some test titles.
Suggestions from Alasdair Kergon.

* test/Makefile.in: Add a copyright notice.
* test/lvm-utils.sh: Likewise.
* test/mkdtemp: Likewise.
* test/t0000-basic.sh: Likewise.
* test/t1000-lvcreate-usage.sh: Likewise.
* test/t3000-lvcreate-pvtags.sh: Likewise.
* test/t4000-pv-range-overflow.sh: Likewise.
* test/test-lib.sh: Likewise.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:02:22 +00:00

57 lines
1.6 KiB
Bash

# Put lvm-related utilities here.
# This file is sourced from test-lib.sh.
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
export LVM_SUPPRESS_FD_WARNINGS=1
ME=$(basename "$0")
warn() { echo >&2 "$ME: $@"; }
unsafe_losetup_()
{
f=$1
# Prefer the race-free losetup from recent util-linux-ng.
dev=$(losetup --find --show "$f" 2>/dev/null) \
&& { echo "$dev"; return 0; }
# If that fails, try to use util-linux-ng's -f "find-device" option.
dev=$(losetup -f 2>/dev/null) \
&& losetup "$dev" "$f" \
&& { echo "$dev"; return 0; }
# Last resort: iterate through /dev/loop{,/}{0,1,2,3,4,5,6,7,8,9}
for slash in '' /; do
for i in 0 1 2 3 4 5 6 7 8 9; do
dev=/dev/loop$slash$i
losetup $dev > /dev/null 2>&1 && continue;
losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
break
done
done
return 1
}
loop_setup_()
{
file=$1
dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
|| { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
dev=$(unsafe_losetup_ "$file" 2>/dev/null) \
|| { warn "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
return 0;
}