*BSD News Article 18668


Return to BSD News archive

Newsgroups: comp.os.386bsd.apps
Path: sserve!sserve.cc.adfa.oz.au!jjh
From: jjh@cserve.cs.adfa.oz.au (Joe Holloway)
Subject: Disklabel to Disktab Filter
Message-ID: <JJH.93Jul21112400@cserve.cs.adfa.oz.au>
Sender: news@sserve.cc.adfa.oz.au
Organization: Australian Defence Force Academy, Canberra, Australia
Date: Wed, 21 Jul 1993 01:24:00 GMT

Here is a little script for converting the output of disklabel
for insertion into the disktab file.

I hope it is usefull.

			-Joe-

--8<-- Cut Here --8<--
#!/bin/sh
# qlabel	Script for converting Disklabel data to Disktab format
# Author:	jjh@cs.adfa.oz.au (Joe Holloway)
# Thanks:	wkt@cs.adfa.oz.au (Warren Toomey)
# Date:		Tue Jul 20 17:42:01 EST 1993
#
# Comment:	What a really disgusting hack...
# Usage:	disktab -r [device] | qlabel >> <file>
#
tr -d ':' | awk '
BEGIN { FS = " "; RS = "\n" }
NR == 1 { device = $2 
	next }
NR == 2 { dt = $2 
	next }
NR == 3 { label = $2 
	next }
NR == 4 { name = $2 
	next }
NR == 5 { ty = "winchester"
	next }
NR == 6 { se = $2
	next }
NR == 7 { ns = $2 
	next }
NR == 8 { nt = $2 
	next }
NR == 9 { sc = $2 
	next }
NR == 10 { nc = $2 
	next }
NR == 11 { rm = $2 
	next }
NR == 12 { il = $2 
	next }
NR == 13 { sk = $2 
	next }
NR == 14 { cs = $2 
	next }
NR == 15 { hs = $2 
	next }
NR == 16 { ts = $2 
	next }
NR == 17 { 
	next }
NR == 18 { printf ("%s|Device %s on %s:\\ \n", label, device, name)
	printf ("\t:dt=%s:ty=%s:se#%d:nt#%d:ns#%d:nc#%d:", dt, ty, se, nt, ns, nc)
	next }
NR == 19 { partitions = $1
	next }
NR == 20 { 	# comment line
	next }
NR >= 21  && /./ && partitions >= 2 { pn = $1
	px = $2
	ox = $3
	tx = $4
	fx = $5
	bx = $6
	printf (" \\ \n\t:p%s#%d:o%s#%d:t%s=%s:", pn, px, pn, ox, pn, tx)
	if ( tx != "swap" && tx != "unused" )
		printf ("b%s#%d:f%s#%d:", pn, bx, pn, fx)
	next }
END { printf ("\n") }'