NAME

Linux::Disks -- find all blockdevices in a Linux System

VERSION

Version 0.01

SYNOPSIS

 use Linux::Disks;
 my $disks=Linux::Disks->new();
 for my $dev ($disks->drives())
 {
   print " NAME        : ".$dev->name()."\n";
   print " DEVICE      : ".$dev->device()."\n";
   print " VENDOR/MODEL: ".$dev->vendor().'/'.$dev->model()."\n";
   print " MAJOR ID    : ".$dev->major()."\n";
   print " MINOR ID    : ".$dev->minor()."\n";
   print " BUS TYPE    : ".$dev->bus_type()."\n";
   print " UUID        : ".$dev->uuid()."\n";
   print " SERIAL      : ".$dev->serial()."\n";
   if($dev->mountable())
   {
     print " MOUNTED     : ".($dev->mounted()?'YES':'NO')."\n";
     print " IN FSTAB    : ".($dev->in_fstab()?'YES':'NO')."\n";
     print " FS TYPE     : ".$dev->fs_type()."\n";
     print " SPECIAL FS  : ".($dev->special_fs()?'YES':'NO')."\n";
     print " SIZE        : ".$dev->size()."\n";
     print " FREE        : ".$dev->free()."\n";
     print " MOUNT POINT : ".$dev->mount_point()."\n";
   }
   else
   {
     print " PARTITIONS  :\n";
     for my $part ($dev->partitions())
     {
       print "    NAME        : ".$part->name()."\n";
       print "    MAJOR ID    : ".$part->major()."\n";
       print "    MINOR ID    : ".$part->minor()."\n";
       print "    LABEL       : ".$part->label()."\n";
       print "    DEVICE      : ".$part->device()."\n";
       print "    IN FSTAB    : ".($part->in_fstab()?'YES':'NO')."\n";
       print "    MOUNTED     : ".($part->mounted()?'YES':'NO')."\n";
       print "    FS TYPE     : ".$part->fs_type()."\n";
       print "    SPECIAL FS  : ".($part->special_fs()?'YES':'NO')."\n";
       print "    SIZE        : ".$part->size()."\n";
       print "    FREE        : ".$part->free()."\n";
       print "    MOUNT POINT : ".$part->mount_point()."\n";
       print "    ---------------\n";
     }
   }
   print " -------------------\n";
 }

DESCRIPTION

This Modul uses System Tools (blkid,fdisk,df,udevadm) and parse "/etc/fstab" and search in "/dev" to find all aviable Informations about Blockdevices.

AUTHOR

ToPeG

Linux::Disks

PACKAGE VARIABLES

$dev_dir

Directory of the device filesystem

predefined: /dev

$blkid_cmd

Command to find all Blockdevice IDs

predefined: /sbin/blkid

$fdisk_cmd

Command for fdisk

predefined: LC_ALL=C /sbin/fdisk -l 2>/dev/null

$dfree_cmd

command for df

predefined: LC_ALL=C /bin/df -PTx tmpfs 2>/dev/null

$udev_cmd

command for udevadm

predefined: /sbin/udevadm info --query=all --name="%s" 2>/dev/null

$fstab_file

path to the fstab

predefined: /etc/fstab

$mount_dir

path to the default mount directory

predefined: /media/

path to the mountpoint of sysfs

$sys_dir

predefined: /sys/

METHODS

new(%OPTIONS)

create a new Object

Options

fake : a hashtree of deviceinformations. See result and code of __parse for more. Only for testpurpes

update()

search for new Disks and Partitions. Remove old Disk-Informations

update_partitions()

actualisize the partition information

it will not serach for new Disks or Partitions

drives()

Retuns a list of Linux::Disks::Drive Objects

partitions()

Returns a list of Linux::Disks::Partition Objects

has_errors()

returs 1 if an Error occured

errors()

return a list of all Errors.

Resets the internel Errorlist.

Linux::Disks::Partition

METHODS

size()

returns the size of the partition in bytes

used()

if aviable it's returns the bytes used 0 otherwise

free()

returns the free Partitionspace if aviable or 0

percent()

returns the percent usage of the Partition if aviable or 0

bootable()

return 1 if the partition have the bootflag

mount_point()

returns a path to the mountpoint.

A mountpoint will be generated if not set

start()

returns the Startposition of the Partition

end()

the endposition of the Partition

fs_type()

the Filesystem Type

special_fs()

1 if it's an special fs.

Detects: raid, swap, usbfs, proc, rootfs, tmpfs

uuid()

the UUID of the Partition

mounted()

1 if the Partition is mounted

mountable()

1 if the Partition is mountable.

A Partition is mountable if the Bockdevice is avaiable, the mountpoints exists and is and Directory and the fstype is aviable

in_fstab()

1 if the Partition is mentiond in the fstab.

name()

name of the Partition

device()

device of the Partition

links()

alternative devicenames

path()

sys-path of the Partition

label()

Label of the Partition

major()

Major Device Name

minor()

Minor Device Name

vendor()

Vendor Device Name

model()

Device Model

serial_shor()

short serial number of the device

serial()

serial number of the Device

revision()

revision of the Devide

bus_type()

bustype of the Device

Aviable: scsi, usb, ide, net, raid

Linux::Disks::Drive

METHODS

size()

returns the size of the Device in bytes

used()

if aviable it's returns the bytes used 0 otherwise

free()

returns the free Diskspace if aviable or 0

percent()

returns the percent usage of the Partition if aviable or 0

bootable()

return 0

mount_point()

returns a path to the mountpoint.

A mountpoint will be generated if not set

start()

returns the Startposition of the Disk

end()

the endposition of the Disk

fs_type()

the Filesystem Type

special_fs()

1 if it's an special fs.

Detects: raid, swap, usbfs, proc, rootfs, tmpfs

uuid()

the UUID of the Partition

mounted()

1 if the Partition is mounted

mountable()

1 if the Device is mountable.

A Partition is mountable if the Bockdevice is avaiable, the mountpoints exists and is and Directory and the fstype is aviable

in_fstab()

1 if the Partition is mentiond in the fstab.

name()

name of the Partition

device()

device of the Partition

links()

alternative devicenames

path()

sys-path of the Partition

label()

Label of the Partition

major()

Major Device Name

minor()

Minor Device Name

vendor()

Vendor Device Name

model()

Device Model

serial_shor()

short serial number of the device

serial()

serial number of the Device

revision()

revision of the Devide

bus_type()

bustype of the Device

Aviable: scsi, usb, ide, net, raid

partitions()

returns a list of all Partitions on this Device

AUTHOR

Tobias Grönhagen <linux_disks@topeg.de>

BUGS

Please report any bugs or feature requests to bug-linux-disks at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-Disks. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE AND COPYRIGHT

Copyright 2012 Tobias Grönhagen.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.