Here is a draft which works fine for normal mount points:

http://cr.opensolaris.org/~pavelf/6778894-v2/

It uses sh(1) pattern matching features:

sh(1)
 case word in [ pattern [ | pattern ] ) list ;; ] ...  esac

         A case command executes the  list  associated  with  the
         first  pattern  that  matches word. The form of the pat-
         terns is the same as that used for file-name  generation
         (see File Name Generation section), except that a slash,
         a leading dot, or a dot immediately  following  a  slash
         need not be matched explicitly.
=================

This solution is vulnerable to e.g. * expansion:

$ mkdir /\*
$ mount server:/export /\*
$ umountall -l

Nothing will be unmounted since every mountpoint will match against '/*'
and will be considered as a NFS mountpoint.

I do not expect that sysadmins use often '*' in names for mountpoints,
but such solution is not acceptable.

Any suggestions how to implement a robust grep in a shell?

--Pavel



Nicolas Williams wrote:
> On Tue, Dec 16, 2008 at 09:31:14PM +0100, Pavel Filipensky wrote:
>   
>> If you provide a path to df it will use realpath() -> resolvepath(2) :
>>
>> $ truss df -n /WWW
>> resolvepath("/WWW", "/WWW", 1024)               = 4
>>     
>
> Ah!
>
>   
>> But the point was to specify the path (mountpoint) to df, without it we 
>> do not get any advantage from using df.
>> So we must parse the /etc/mnttab anyway.
>>     
>
> OK.  Glad I asked!
>
> Nico
>   


Reply via email to