#!/usr/local/bin/perl # -*- perl -*- # Copyright (c) 1999 by Jeff Weisberg # Author: Jeff Weisberg # Function: calculate partition table params use Getopt::Std; getopts("bc:h:s:vu"); sub usage { print < ); $total += $s; $remain -= $s; $desired{$p} = $s; } $k = $cyl / $megs; print "\n"; $start = 0; foreach $p (@parts){ if( $p ne 'c' ){ $d = $desired{$p}; if( $p eq 'h' ){ $c = $cyl - $start; }else{ $c = int( $d * $k + .99 ); } $a = sprintf "%.2f", $c / $k; $s = $c * $hds * $sec; $o = $start * $hds * $sec; $st = $start; $type = ($p eq 'b')? 'swap' : '4.2BSD'; print "$p: start = $st, ncyl = $c, nsec = $s, $a MB\n" if $opt_v; $start += $c; }else{ $s = $nsect; $c = $cyl; $a = $c / $k; $o = 0; $st = 0; $type = 'unused'; } if( $opt_b ){ print " $p: $s\t$o\t$type\t0 0\t# (ncyl $c \@ $st) $a MB\n"; }else{ printf " partition $p - starting cyl %8d, # blocks %9d ($c/0/0)\n", $st, $s; } }