blob: f9bf51bfa0e5229938a4082a180e40f2058bf164 (
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
|
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# functions that may not be defined, but are used by the udev-start and udev-stop addon
# used by baselayout-1 and openrc before version 0.4.0
cmd_exist()
{
type "$1" >/dev/null 2>&1
}
# does not exist in baselayout-1, does exist in openrc
if ! cmd_exist yesno; then
yesno() {
[ -z "$1" ] && return 1
case "$1" in
yes|Yes|YES) return 0 ;;
esac
return 1
}
fi
if ! cmd_exist mountinfo; then
mountinfo() {
# returning false makes the behaviour same as without check
return 1
}
fi
# does not exist in baselayout-1, does exist in openrc
#
# used syntax: fstabinfo --mount /dev
# it should mount /dev if an entry exists in /etc/fstab
#
# return value:
# 0 mount succeeded
# 1 mount failed or no entry exists
#
if ! cmd_exist fstabinfo; then
fstabinfo() {
[ "$1" = "--mount" ] || return 1
local dir="$2"
# RC_USE_FSTAB does only exist in baselayout-1
# this emulation is only needed on bl-1, so check always
yesno "${RC_USE_FSTAB}" || return 1
# no need to check fstab, mount does this already for us
# try mounting - better first check fstab and then mount without surpressing errors
mount -n "${dir}" 2>/dev/null
return $?
}
fi
|