#!/bin/sh
#
#     tiger - A UN*X security checking system
#     Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford
#
#     Please see the file `COPYING' for the complete copyright notice.
#
# SunOS/4/gen_mounts - 06/14/93
#
#-----------------------------------------------------------------------------
#

dirname()
{
  _path="$1"

  saveifs=$IFS
  IFS=/
  set X $_path
  IFS=$saveifs

  shift

  if [ $# -eq 1 ]; then
    _dirname='/'
  else
    _dirname=$1
    shift
    while [ $# -ne 1 ]
    do
      _dirname="$_dirname/$1"
      shift
    done
  fi
  
  echo "$_dirname"
}
  
LOCAL_ONLY=$1
CHKRO=$2

ronly()
{
  RO=1
  case "$1" in
    *[!a-zA-Z]ro[!a-zA-Z]*) RO=0
      ;;
  esac
  return $RO
}

localfs()
{
  LOCAL=1
  [ "$1" = "4.2" ] && LOCAL=0

  return $LOCAL
}

/etc/mount |
while read fs o mtpoint t fstype opts
do
  PRINT=1
  [ "$CHKRO" = "rw" ] && { ronly "$opts" && PRINT=0; }
  [ "$LOCAL_ONLY" = "local" ] && { localfs "$fstype" || PRINT=0; }
  [ "$PRINT" = "1" ] && {
    dir=`dirname $fs`
    file=`/usr/bin/basename $fs`
    rfs="$dir/r$file"
    echo "$mtpoint $fstype $fs $rfs"
  }
done

