Source for file Mount.php
Documentation is available at Mount.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Ian Eure <ieure@php.net> |
// +----------------------------------------------------------------------+
// $Id: Mount.php 304150 2010-10-06 12:11:32Z clockwerx $
require_once 'File/Fstab.php';
require_once 'System/Command.php';
* Mount and unmount devices in fstab
* $sm = &new System_Mount();
* $cdrom = &$sm->getEntryForPath('/cdrom');
* @author Ian Eure <ieure@php.net>
* @copyright Copyright © 2004, Ian Eure
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @link http://atomized.org/PEAR/System_Mount/
var $_defaultMountOptions = array (
'entryClass' => "System_Mount_Entry",
'mtabFile' => "/etc/mtab",
* @param $options array Class options
* @see File_Fstab::setOptions()
$opts = array_merge($this->_defaultMountOptions, $options);
// Get a static mtab instance
$mtab = &PEAR ::getStaticProperty ('@package@', 'mtab');
$mtab = File_Fstab ::singleton ($opts['mtabFile']);
// Make sure the entryClass knows how to mount/unmount
$options = &PEAR ::getStaticProperty ('@package@', 'options');
$options = $this->options;
* Class which handles the mount/unmount operation
* This is the heart of System_Mount- the main class exists only to instruct
* File_Fstab to use this class, making it easier on the end-user.
* @author Ian Eure <ieure@php.net>
* @copyright Copyright © 2004, Ian Eure
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* This contains an instance of File_Fstab (created with
* {@link File_Fstab::singleton()} so we don't waste memory) which parses
* /etc/mtab and holds the current device mount state.
* This contains the options passed to System_Mount when it was instantiated
* @see System_Mount::System_Mount()
* @param $entry fstab entry
* @see File_Fstab::File_Fstab()
$this->_smOptions = &PEAR ::getStaticProperty ('@package@', 'options');
$this->_mtab = &PEAR ::getStaticProperty ('@package@', 'mtab');
// Thunk to parent's constructor
return parent ::$pc($entry);
* Is this device mounted?
* @return boolean true if mounted, false if unmounted
PEAR ::pushErrorHandling (PEAR_ERROR_RETURN );
$ent = $this->_mtab->getEntryForPath ($this->mountPoint);
PEAR ::popErrorHandling ();
if (PEAR ::isError ($ent)) {
* May a user mount this device?
* @return boolean true if user may mount, false if not
return $this->hasMountOption ('user');
* May this device be mounted?
* Similar to userMayMount(), but this takes the UID the script is running as
* in to account, and returns 'true' if the current UID is 0, or the result of
* userMayMount otherwise.
* @return boolean true if user may mount, false if not
// Root may mount anything
* @return mixed boolean or PEAR_Error
return PEAR ::raiseError ("{ $this->mountPoint} is already mounted ");
* @return mixed boolean true on success, PEAR_Error otherwise
return PEAR::raiseError("{ $this->mountPoint } is not mounted" );
* Dispatch an (un)mount command
* @param int $command SYSTEM_MOUNT_CMD_MOUNT (to mount device) or _UNMOUNT
* @return return value from System_Command or PEAR_Error
* @see System_Command::execute()
return PEAR::raiseError("Users may not (un)mount { $this->mountPoint }" );
$cmd = new System_Command;
$cmd->pushCommand($command, $this->mountPoint);
Documentation generated on Mon, 11 Mar 2019 15:39:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|