1. Introduction

Introduction

Introduction – Mount and Unmount filesystems

Contributors

  • Brett Bieber

Description

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.

System_Mount (Previous) System_Daemon (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.