| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.9 2006/11/06 13:55:04 uberlord Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.10 2006/11/10 15:56:59 uberlord Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Diego Pettenò <flameeyes@gentoo.org> |
5 | # Author: Diego Pettenò <flameeyes@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass is created to avoid using non-portable GNUisms inside ebuilds |
7 | # This eclass is created to avoid using non-portable GNUisms inside ebuilds |
| 8 | # |
8 | # |
| … | |
… | |
| 129 | echo pmake |
129 | echo pmake |
| 130 | fi |
130 | fi |
| 131 | } |
131 | } |
| 132 | |
132 | |
| 133 | # Portable method of getting mount names and points. |
133 | # Portable method of getting mount names and points. |
| 134 | # Returns as "point node fs" |
134 | # Returns as "point node fs options" |
| 135 | # Remember to convert 040 back to a space. |
135 | # Remember to convert 040 back to a space. |
| 136 | get_mounts() { |
136 | get_mounts() { |
| 137 | local point= node= fs= foo= |
137 | local point= node= fs= opts= foo= |
| 138 | |
138 | |
| 139 | # Linux has /proc/mounts which should always exist |
139 | # Linux has /proc/mounts which should always exist |
| 140 | if [[ $(uname -s) == "Linux" ]] ; then |
140 | if [[ $(uname -s) == "Linux" ]] ; then |
| 141 | while read node point fs foo ; do |
141 | while read node point fs opts foo ; do |
| 142 | echo "${point} ${node} ${fs}" |
142 | echo "${point} ${node} ${fs} ${opts}" |
| 143 | done < /proc/mounts |
143 | done < /proc/mounts |
| 144 | return |
144 | return |
| 145 | fi |
145 | fi |
| 146 | |
146 | |
| 147 | # OK, pray we have a -p option that outputs mounts in fstab format |
147 | # OK, pray we have a -p option that outputs mounts in fstab format |
| … | |
… | |
| 151 | # have to be patched. |
151 | # have to be patched. |
| 152 | # Athough the BSD's may support /proc, they do NOT put \040 in place |
152 | # Athough the BSD's may support /proc, they do NOT put \040 in place |
| 153 | # of the spaces and we should not force a /proc either. |
153 | # of the spaces and we should not force a /proc either. |
| 154 | local IFS=$'\t' |
154 | local IFS=$'\t' |
| 155 | LC_ALL=C mount -p | while read node point fs foo ; do |
155 | LC_ALL=C mount -p | while read node point fs foo ; do |
|
|
156 | opts=${fs#* } |
|
|
157 | fs=${fs%% *} |
| 156 | echo "${point// /\040} ${node// /\040} ${fs%% *}" |
158 | echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}" |
| 157 | done |
159 | done |
| 158 | } |
160 | } |
| 159 | |
161 | |