summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorRoy Marples <uberlord@gentoo.org>2006-11-06 13:55:04 +0000
committerRoy Marples <uberlord@gentoo.org>2006-11-06 13:55:04 +0000
commitdcb7a19288238a85881d93b4359d99fd5a6ce235 (patch)
tree3d53343b8efc9ce91c34b3c65d851c822743e758 /eclass
parentVersion bump (diff)
downloadhistorical-dcb7a19288238a85881d93b4359d99fd5a6ce235.tar.gz
historical-dcb7a19288238a85881d93b4359d99fd5a6ce235.tar.bz2
historical-dcb7a19288238a85881d93b4359d99fd5a6ce235.zip
Added get_mounts to portability.eclass
Diffstat (limited to 'eclass')
-rw-r--r--eclass/portability.eclass30
1 files changed, 29 insertions, 1 deletions
diff --git a/eclass/portability.eclass b/eclass/portability.eclass
index 90d1b3139589..f8d0a12f1d75 100644
--- a/eclass/portability.eclass
+++ b/eclass/portability.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.8 2006/03/08 20:08:13 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.9 2006/11/06 13:55:04 uberlord Exp $
#
# Author: Diego Pettenò <flameeyes@gentoo.org>
#
@@ -129,3 +129,31 @@ get_bmake() {
echo pmake
fi
}
+
+# Portable method of getting mount names and points.
+# Returns as "point node fs"
+# Remember to convert 040 back to a space.
+get_mounts() {
+ local point= node= fs= foo=
+
+ # Linux has /proc/mounts which should always exist
+ if [[ $(uname -s) == "Linux" ]] ; then
+ while read node point fs foo ; do
+ echo "${point} ${node} ${fs}"
+ done < /proc/mounts
+ return
+ fi
+
+ # OK, pray we have a -p option that outputs mounts in fstab format
+ # using tabs as the seperator.
+ # Then pray that there are no tabs in the either.
+ # Currently only FreeBSD supports this and the other BSDs will
+ # have to be patched.
+ # Athough the BSD's may support /proc, they do NOT put \040 in place
+ # of the spaces and we should not force a /proc either.
+ local IFS=$'\t'
+ LC_ALL=C mount -p | while read node point fs foo ; do
+ echo "${point// /\040} ${node// /\040} ${fs%% *}"
+ done
+}
+