blob: 3cb288a7d1144145958212aa4390f81a5311f7ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/bin/sh
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author: Martin Schlemmer <azarah@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/media-video/drip/files/dripgetdvd.sh,v 1.3 2004/03/04 18:52:12 vapier Exp $
# This basically resolves a symlink in /dev to the block device node. If
# $1 is a absolute path, and that do not exist, we also check /etc/fstab
# if there is an entry, if not we check for an entry of `basename $1`.
if test -z "$1"
then
exit 1
fi
DVD="$1"
check_device() {
local DVD="$1"
local NEWDVD=
while test -L "${DVD}"
do
NEWDVD="$(readlink "${DVD}")"
if test -z "$(echo "${NEWDVD}" | grep -e "^/dev")"
then
DVD="${DVD%/*}/${NEWDVD}"
else
DVD="${NEWDVD}"
fi
done
echo "${DVD}"
}
get_fstab_entry() {
test -z "$1" && return 1
echo "$(grep "$1" /etc/fstab | awk '$0 !~ /^[[:space:]]*#/ {print $1}')"
}
if ! test -L "${DVD}" && ! test -b "${DVD}"
then
NEWDVD="$(get_fstab_entry "${DVD}")"
if test -z "${NEWDVD}"
then
NEWDVD="$(get_fstab_entry $(basename "${DVD}"))"
fi
if test -z "${NEWDVD}"
then
exit 1
else
DVD="${NEWDVD}"
fi
fi
DVD="$(check_device "${DVD}")"
if test -z "${DVD}"
then
exit 1
fi
if test -b "${DVD}"
then
echo "$(echo ${DVD} | sed -e 's://:/:g')"
else
exit 1
fi
exit 0
|