From: Roy Marples Date: Mon, 6 Nov 2006 13:55:04 +0000 (+0000) Subject: Added get_mounts to portability.eclass X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dcb7a19288238a85881d93b4359d99fd5a6ce235;p=gentoo.git Added get_mounts to portability.eclass --- 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ò # @@ -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 +} +