Introduction
Contributors
- Brett Bieber
Описание
System_Mount provides methods to mount and unmount
filesystems and partitions listed in a system's
/etc/fstab
. The fstab file is common on Unix/Linux
based systems and is used to list the available filesystems and partitions
which users can mount into the filesystem hierarchy. Common entries include
root partitions, boot partitions, as well as cdrom drives and other
removable media.
The System_Mount command utilizes File_Fstab to discover entries in the
/etc/fstab
file, and allow easy mount/unmount operations.
Using System_Mount
General usage
<?php
require_once 'System/Mount.php';
// Create the mount class
$m = new System_Mount();
// Get an object representing the CD-ROM entry
$cdrom = $m->getEntryForPath('/media/cdrom0');
if (PEAR::isError($cdrom)) {
die($cdrom->message."\n");
}
// Mount it
$res = $cdrom->mount();
if (PEAR::isError($res)) {
die($res->getMessage()."\n");
}
// List its contents
print `ls {$cdrom->mountPoint}`;
// Unmount it
$cdrom->unmount();
if (PEAR::isError($res)) {
die($res->getMessage()."\n");
}
?>
At first, you need to instantitiate a new System_Mount object.
Use the mount point for the corresponding entry in your
/etc/fstab
to obtain an object to mount,
then check if there are any errors. If there are no errors mount the cdrom.