NAME
Solaris::Disk::VTOC - Read Solaris VTOC (aka. slices or partitions) from disks
SYNOPSIS
use Solaris::Disk::VTOC;;
$vtoc = Solaris::Disk::VTOC->new();
$vtoc = Solaris::Disk::VTOC->new(
sourcedir => "/path/containing/c0t0d0.txt/" );
$vtoc = Solaris::Disk::VTOC->new(
init => 1);
# get c0t0d0 slices. All 3 are valid:
$vtoc->readvtoc( device => "c0t0d0s0" );
$vtoc->readvtoc( device => "c0t0d0s7" );
$vtoc->readvtoc( device => "c0t0d0" );
# from file
$vtoc->readvtoc( device => "c0t0d0", source => "/tmp/c0t0d0.dump" );
# read vtoc from file in a directory
$vtoc->readvtocdir( "/tmp/" );
$size = $vtoc->size("c0t0d0s1"); # slice 1
$size = $vtoc->size("c0t0d0s3"); # slice 3
$size = $vtoc->size("c0t0d0", 1); # slice 1
$size = $vtoc->size("c0t0d0s2", 3); # slice 3
$vtoc->show("c0t0d0", ...);
# when code is written:
$vtoc->dump("c0t0d0");
$vtoc->format("c0t0d0"); # or should it be `partition' or `slice'?
# or `label'
DESCRIPTION
Solaris::Disk::VTOC aims to provide methods to read Solaris disks partitions (aka slices).
GLOBALS
Two global hashes are defined for completeness. They are not this useful if you are a used Solaris administrator.
%VTOCSliceType
Global hash to translate slice types ([0-9a]) to plain english.
%VTOCSliceFlag
Global hash to translate partition flags (00, 01, 10, 11) to format(1M) codes (wm, wu, rm, ru).
METHODS
new
The new
method returns a Solaris::Disk::VTOC
object, which will then be used to read partitions for disks, to access these data, or to dump them in a human or computer readable manner.
Create the object, but not initialize:
my $vtoc = Solaris::Disk::VTOC->new();
Create the object, initialize from devices, with prtvtoc(1M) :
my $vtoc = Solaris::Disk::VTOC->new(init => 1);
Create the object, initialize from a directory containing prtvtoc(1M) dumps (see the
readvtocdir
method).my $vtoc = Solaris::Disk::VTOC->new( sourcedir => '/path/to/dir/' );
readvtoc
$vtoc->readvtoc( device => 'c0t0d0s0' [, source => 'c0t0d0s0.txt' ] );
readvtoc loads the vtoc and disk parameters (bytespersector, sectorspertrack, sectorspercyl, cylinders and accylinders) in the object referenced by $vtoc.
Only the controler+target+LUN part of the name is keeped, the slice number is dropped (s2
is used internally).
The device
parameter is mandatory, even if it could be read from the default source (prtvtoc /dev/rdsk/$device |
). This will allow further testing at the expense of a little typing overhead.
The source
parameter allows one to specify a different data source such as a file containing a dump from the prtvtoc
command for the specified disk.
readvtocdir
readvtocdir
allows one to specify a directory containing prtvtoc(1M) dumps, with names in the form c\d+t\d+d\d+[s\d]\.txt
@disknames = $vtoc->readvtocdir('/path/to/dir/');
readvtocdir
return the list of the disk vtocs found in the given directory.
size
The size
method, taking one or two parameters, gives the size of a slice.
$vtoc->size( $diskwithslice )
$vtoc->size( $disk, $slice )
$vtoc->size( "c0t0d0s1" ) # get slice 1 size for c0t0d0
$vtoc->size( "c0t0d0", 1 ) # same
$vtoc->size( "c0t0d0s0", 1 ) # same
The size() methods returns the block count in a partition specified as cXtXdXsX
If the disk does not currently exists in the current configuration, it tries to load it from system.
Bug: no named parameters for now.
show
The show
method prints on STDOUT the disk details and partitions for the disks asked.
dump
The dump
method, when implemented, will dump in a prtvtoc(1M) fashion, the information about the specified disk. Its output should be suitable to feed the fmthard(1M) command.
BUGS
Not all methods take named parameters for now.
This module has only been tested on Solaris for Sparc. Please contact the author for feedback about Solaris on Intel and/or AMD.
The dump method is not currently implemented. Maybe a format method should be implemented as well (could be dangerous, don't you think?)
AUTHOR
Jérôme Fenal <jfenal@free.fr>
VERSION
This is version 0.03 of the Solaris::Disk::VTOC module.
COPYRIGHT
Copyright (C) 2004 Jérôme Fenal. All Rights Reserved
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
The prtvtoc(1M) command and man page.
The format(1M) command and man page.
The fmthard(1M) command and man page.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 433:
Non-ASCII character seen before =encoding in 'Jérôme'. Assuming CP1252