Subject: rc WRT vnconfig
To: None <netbsd-users@NetBSD.ORG>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-users
Date: 12/07/2003 02:46:23
--8P1HSweYDcXXzwPJ
Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw"
Content-Disposition: inline


--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

I've noticed that there's no rc script for configuring vnode disks. IMHO,
vnds are similar to swap partitions - not fish, not flesh. However,
vnds are related to mounting and I think it's useful that you can put
them into ``critical_mount_local'' in your /etc/rc.conf. Otherwise,
it would be hard to figure out at which level vnconfig should happen.
Therefore, I've wrote a little pseudo mount_vnd as a shell script. The
syntax for a fstab-entry is straight-forward:

<vnode_disk> <regular_file> vnd <params>

<vnode_disk> is e.g., /dev/vnd0 or vnd0
<regular_file> is the file that contains the image
<params> contains the normal flags for vnconfig. For flags that need
a parameter use "-t=3Dblah" instead of the normal "-t blah".  I've added
the flag -g which takes the geometry for the disk as parameter. Also
note that the flags -F, -l and -l are ignored because I see no sense
in using them in this context.

Use with caution, it's NOT fool-proof!
--=20
Christian

--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=mount_vnd
Content-Transfer-Encoding: quoted-printable

#! /bin/sh

debug=3D0

[ $debug -gt 0 ] && echo $0 ${1+"$@"}

geom=3D
args=3D
cmd=3D$0

ecco=3D"$0 "

while [ $# -gt 2 ]; do

  ecco=3D${ecco}"'$1' "

  if [ "$1" =3D -o ]; then
    ecco=3D${ecco}"'$2' "

    case "$2" in
    rw)=20
	shift
        ;;
    ro)
	args=3D${args}"-r "
	shift
	;;
    c|r|v)
	args=3D${args}"-$2 "
	shift
	;;
    *) =20
	echo "$cmd: Unknown option '$2'" >&2
	exit 1
        ;;
    esac
  else
    ecco=3D${ecco}"'$2' "

    case "$1" in
    -t)
	if [ -z "$2" ]; then
    	  echo "$cmd: Missing parameter for flag $1" >&2
	  exit 1
	fi
	=09
	args=3D${args}"$1 $2"
	shift
	;;
    -g)
	if [ -z "$2" ]; then
    	  echo "$cmd: Missing parameter for flag $1" >&2
	  exit 1
	fi
	=09
	geom=3D$2
	shift
	;;
    -F|-l|-u)
	echo "$cmd: Ignoring flag '$1' in mount context" >&2=20
	;;
    *)
	echo "$cmd: Unknown flag '$1'" >&2=20
    	exit 1
    esac
  fi

  shift
done

vnode=3D$1
regfile=3D$2

if [ -z "$vnode" ]; then
  echo "$cmd: Missing parameter 'vnode'" >&2=20
  exit 1
fi

if [ -z "$regfile" ]; then
  echo "$cmd: Missing parameter 'regular file'" >&2=20
  exit 1
fi

if [ $debug -gt 0 ]; then
  echo $ecco
  echo "/usr/sbin/vnconfig $args $vnode $regfile $geom"
fi

/usr/sbin/vnconfig $args $vnode $regfile $geom

--GvXjxJ+pjyke8COw--

--8P1HSweYDcXXzwPJ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQE/0oZv0KQix3oyIMcRAnjiAJ46dIs39p5uUMmRgPp+XPEZbZCYPACgzUYF
JuVfZ+QTyI93Z8ypm8KE8qk=
=qjr1
-----END PGP SIGNATURE-----

--8P1HSweYDcXXzwPJ--