diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-26 12:34:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-26 13:27:16 +0000 |
commit | a28728bc868ded45ec916adb5c26f81375c01acc (patch) | |
tree | 6843f54131cb3aa5ee6287e27fb5ca64b1cf0dbc /setup-apkcache.in | |
parent | ea514130cd49220ccc77a91eb5a9604bf5d846e7 (diff) | |
download | alpine-conf-a28728bc868ded45ec916adb5c26f81375c01acc.tar.bz2 alpine-conf-a28728bc868ded45ec916adb5c26f81375c01acc.tar.xz |
setup-apkcache: search fstab for mount point first
ref #786
Diffstat (limited to 'setup-apkcache.in')
-rw-r--r-- | setup-apkcache.in | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/setup-apkcache.in b/setup-apkcache.in index d184214..ba40488 100644 --- a/setup-apkcache.in +++ b/setup-apkcache.in @@ -22,15 +22,34 @@ is_mounted() { awk '{print $2}' /proc/mounts | grep -q "^$1$" } +find_fstab_mount_point() { + local dir="$1" + local res= + while [ -n "$dir" ]; do + res=$(awk "\$2 == \"$dir\" {print \$2}" /etc/fstab) + if [ -n "$res" ]; then + echo $res + return + fi + dir=${dir%/*} + done +} + # figure out mount point find_mount_point() { + local dir=$(find_fstab_mount_point $1) + if [ -d "$dir" ] && [ "$dir" != "/" ]; then + echo $dir + return + fi + local dir="$1" while ! [ -d "$dir" ]; do dir=${dir%/*} done local fs_id=$(stat -f -c %i "$dir") local parent="${dir%/*}" - while [ -n "$parent" ] && [ "$(stat -f -c %i $parent)" = "$fs_id" ]; do + while [ -n "$dir" ] && [ "$(stat -f -c %i $parent/)" = "$fs_id" ]; do dir=$parent parent=${parent%/*} done |